akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, m; std::cin >> n >> m;
  std::cout << (n == m ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
unittest
{
	assert( [ "BBW" ].parse.expand.solve == 2 );
	assert( [ "BWBWBW" ].parse.expand.solve == 6 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto ans = 0L;
	auto w = ( s[ $ - 1 ] == 'W' ) ? 1L : 0L;
	for( auto i = s.length.signed - 2; 0 <= i; i-- )
	{
		if( s[ i ] == 'B' )
		{
			if( s[ i + 1 ] == 'W' )
			{
				s[ i ] = 'W';
				ans += w;
			}
			else
			{
				w = 0;
			}
		}
		else
		{
			w++;
		}
	}
	return ans;
}


Measured memory_bytes: 3256
import sys
input = sys.stdin.buffer.readline

def main():

    H, W, M = map(int, input().split())
    #HW = [0]*m

    HC = [0]*H
    WC = [0]*W

    A = [0]*M

    for i in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        #HW[i] = (h, w)
        HC[h] += 1
        WC[w] += 1
        A[i] = (h, w)

    from collections import Counter
    hct = Counter(HC)
    wct = Counter(WC)
    hct = list(hct.items())
    wct = list(wct.items())
    hct.sort(reverse=True)
    wct.sort(reverse=True)
    #print(hct)
    #print(wct)
    temph = hct[0][0]
    tempw= wct[0][0]
    tempa = temph+tempw
    cnthw = hct[0][1]*wct[0][1]
    cnt = 0
    for h, w in A:
        if HC[h]+WC[w] ==tempa:
            cnt += 1
    #print(cnt, cnthw)
    if cnt < cnthw:
        print(tempa)
    else:
        print(tempa-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 89748
# -*- coding: utf-8 -*-
#D - Good Grid
import sys 
from itertools import permutations
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,C = map(int,readline().split())
D = []
for _ in range(C):
    row = list(map(int,readline().split()))
    D.append(row)
data = []
for _ in range(N):
    row = list(map(int,readline().split()))
    data.append(row)

INF = 10**31
ans = INF
X = defaultdict(int)
Y = defaultdict(int)
Z = defaultdict(int)

for i in range(N):
    for j in range(N):
        pre_c = data[i][j]-1
        if (i+j) % 3 == 0:
            X[pre_c] += 1   
        elif (i+j) % 3 == 1:
            Y[pre_c] += 1
        else:
            Z[pre_c] += 1

M = [i for i in range(C)]
for a,b,c in permutations(M,3):
    total = 0
    for k,v in X.items():
        total += D[k][a]*v
    for k,v in Y.items():
        total += D[k][b]*v
    for k,v in Z.items():
        total += D[k][c]*v
    
    ans = min(ans,total)
print(ans)

Measured memory_bytes: 77160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007

int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll a[4];
    for(i=1;i<4;i++) cin>>a[i];
    ll l[n];
    for(i=0;i<n;i++) cin>>l[i];

    ll ans=1e18;
    for(i=0;i<1<<(2*n);i++){
        ll ii =i;
        vector<ll> v(4,0);
        ll tmp=0;
        for(j=0;j<n;j++){
            if(ii%4>0&&v[ii%4]>0) tmp+=10;
            v[ii%4]+=l[j];
            ii>>=2;
        }

        if (v[1]==0) continue;
        if (v[2]==0) continue;
        if (v[3]==0) continue;

        for(j=1;j<4;j++) {
            tmp+=abs(v[j]-a[j]);
        }
        ans=min(ans,tmp);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll mod = 1e9+7;
ll inf = 1e10;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b){
  return (a/gcd(a,b))*b;
}

template<class T>
bool contain(const string& s, const T& v){
  return s.find(v) != std::string::npos;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  for(int a = 0; a < n; ++a){
    for(int b = a+1; b < n; ++b){
      auto ptr = lower_bound(l.begin(), l.end(), l[a]+l[b]);
      ans += n-b-1-distance(ptr, l.end());
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
const int MOD = 1000000007;
const int BASE = 27;
const int oo = 1e9;
const double EPS = 1e-9;
const int MX = 1e5 + 1;

int n ,a[MX],p[MX];

map<int,int> mv;

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i){
    cin >> a[i];
    p[i] = a[i];
  }
  sort(p,p+n);
  for (int i = 1; i < n; i+= 2){
    mv[p[i]] = 1;
  }
  int cnt = 0;
  for(int i = 1 ; i < n ; i += 2){
    if(!mv[a[i]])cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,k;cin>>n>>m>>k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i*m+j*n-2*i*j==k){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}
/*

in:
3 5 8

out:
Yes

*/

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vector<pii> bridges, cons;
int par_br[MAXN];

int get_par_br(int v) {
	return par_br[v] == v ? v : par_br[v] = get_par_br(par_br[v]);
}

void finish_no() {
	printf("No\n");
	exit(0);
}

void solve(){
	int n, q, a, b, t;
	ll m;
	scanf("%d%lld%d", &n, &m, &q);
	REP(i, 0, q) {
		scanf("%d%d%d", &a, &b, &t);
		a++, b++;
		if (t == 0) {
			bridges.pb(mp(a, b));
		} else {
			cons.pb(mp(a, b));
		}
	}
	
	if (m == n - 1) {
		if (SZ(cons) > 0) {
			finish_no();
		}
		printf("Yes\n");
		return;
	}
	
	REPN(i, 1, n) {
		par_br[i] = i;
	}
	REP(i, 0, SZ(bridges)) {
		a = bridges[i]._1, b = bridges[i]._2;
		a = get_par_br(a), b = get_par_br(b);
		if (a != b) {
			par_br[b] = a;
		}
	}
	REP(i, 0, SZ(cons)) {
		a = cons[i]._1, b = cons[i]._2;
		a = get_par_br(a), b = get_par_br(b);
		if (a == b) {
			finish_no();
		}
	}
	ll comp_br = 0, comp_con = 0;
	REPN(i, 1, n) {
		int br = get_par_br(i);
		if (br == i) {
			comp_br++;
		}
	}
	
	ll mx = n - comp_br + comp_br * (comp_br - 1) / 2ll;
	
	if (m > mx) {
		finish_no();
	}
	
	if (comp_br < 3) {
		finish_no();
	}
	printf("Yes\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main() {
  int N;
  cin >> N;
  ll sum=0;
  for (int i = 1; i <= N; i++) {
    if (i%3!=0 && i%5!=0){
        sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vll v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  vll l(n + 1), r(n + 1);
  l[0] = 0;
  for (int i = 1; i <= n; i++) {
    l[i] = gcd(l[i - 1], v[i - 1]);
  }
  r[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    r[i] = gcd(r[i + 1], v[i]);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, gcd(l[i], r[i + 1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<bitset>
using namespace std;

int n,k;
int a[5005];

int C(int x)
{
    bitset<5005> dp;
    if(a[x]>=k) return 1;
    dp[0]=1;
    for(int i=0;i<n;++i)
    {
        if(i==x) continue;
        dp|=(dp<<a[i]);
    }
    for(int i=k-1;i>=k-a[x];--i)
        if(dp[i]) return 1;
    return 0;
}

int main()
{
    while(~scanf("%d %d",&n,&k))
    {
        for(int i=0;i<n;++i)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int l=0,r=n;
        while(l<r)
        {
            int mid=(l+r)/2;
            if(C(mid)) r=mid;
            else l=mid+1;
        }
        printf("%d\n",l);
    }
}


Measured memory_bytes: 256
from operator import mul
n, m, c = (int(i) for i in input().split())
b = list(int(i) for i in input().split())
cnt = 0
for i in range(n):
    a = list(int(i) for i in input().split())
    if sum(list(map(mul, b, a))) + c > 0:
        cnt = cnt + 1
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<algorithm> 
using namespace std;
const int N=3005;
char s1[N],s2[N];
int dp[N][N];
int main(){
	
	scanf("%s",s1);
    scanf("%s",s2);
		memset(dp,0,sizeof(dp));
//		memset(vis,0,sizeof(vis));
		int l1=strlen(s1);
		int l2=strlen(s2);
	    for(int i=l1-1;i>=0;--i)
        	for(int j=l2-1;j>=0;--j)
	            if(s1[i]==s2[j])  dp[i][j] = dp[i+1][j+1]+1;
	            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);

		int i=0,j=0;	
		while(i<l1&&j<l2){
			if(s1[i]==s2[j]){
				putchar(s1[i]);
				i++,j++;
			}else if(dp[i][j]==dp[i+1][j]) i++;
			else j++;
		}
	return 0;
}

Measured memory_bytes: 35584
#include <cstdio>
#include <vector>
#include <cstring>
#include <limits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX (numeric_limits<int>::max()-1)/2

int dfs(int s, int *v, int *pa, vector<int> *dag){
  if(s<0)return 1;
  rep(i,dag[s].size()){
    if(!v[dag[s][i]]){
      v[dag[s][i]]=1;
      if(dfs(pa[dag[s][i]],v,pa,dag)){
        pa[dag[s][i]]=s;
        return 1;
      }
    }
  }
  return 0;
}

int main(){
  int N,M,L;
  while(scanf("%d%d%d",&N,&M,&L),N){
    int d[N][N];
    rep(i,N)rep(j,N)d[i][j]=MAX;
    rep(i,N)d[i][i]=0;
    rep(i,M){
      int u,v,w;scanf("%d%d%d",&u,&v,&w);
      d[u][v]=w;d[v][u]=w;
    }

    int p[L],t[L];
    rep(i,L)scanf("%d%d",&p[i],&t[i]);
    rep(k,N)rep(i,N)rep(j,N)d[i][j]=(d[i][j]>d[i][k]+d[k][j])?(d[i][k]+d[k][j]):d[i][j];

    vector<int> dag[L];
    rep(i,L)rep(j,L){if(i!=j && d[p[i]][p[j]]<=t[j]-t[i])dag[i].push_back(j);}

    int num=L;
    int pa[L]; memset(pa,-1,sizeof(pa));
    rep(i,L){
      int v[L]; memset(v,0,sizeof(v));
      if(dfs(i,v,pa,dag)){num--;}
    }
    printf("%d\n",num);
  }
  return 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define minch(a,b) a=min(a,b)
#define fi first
#define se second

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;

D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }

struct L : public vector<P> {
  L(const P& a,const P& b){
    push_back(a);
    push_back(b);
  }
};

int ccw(P a,P b,P c){
  b=b-a; c=c-a;
  if(cross(b,c)>0)return 1;
  if(cross(b,c)<0)return -1;
  if(dot(b,c)<0) return +2;
  if(norm(b)<norm(c)) return -2;
  return 0;
}

bool intersectSS(L s,L t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0&&ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

int na,nb;
P pa[1111],pb[1111];
D dist[1111];
typedef pair<D,int> pdi;

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

    cin>>na>>nb;
    rep(i,na){
      D x,y;
      cin>>x>>y;
      pa[i]=P(x,y);
    }
    rep(i,nb){
      D x,y;
      cin>>x>>y;
      pb[i]=P(x,y);
    }
    D res=inf;
    {
      rep(i,1111)dist[i]=inf;
      priority_queue<pdi,vector<pdi>,greater<pdi> > que;
      que.push(pdi(0.0,0));
      while(que.size()){
        D nd=que.top().fi; int nv=que.top().se;
        que.pop();
        if(dist[nv]!=inf)continue;
        dist[nv]=nd;
        rep(i,na){
          if(i==nv||intersectSS(L(pb[0],pb[1]),L(pa[nv],pa[i])))continue;
          que.push(pdi(nd+abs(pa[nv]-pa[i]),i));
        }
      }
      minch(res,abs(pb[0]-pb[1])+dist[1]);
    }
    {
      rep(i,1111)dist[i]=inf;
      priority_queue<pdi,vector<pdi>,greater<pdi> > que;
      que.push(pdi(0.0,0));
      while(que.size()){
        D nd=que.top().fi; int nv=que.top().se;
        que.pop();
        if(dist[nv]!=inf)continue;
        dist[nv]=nd;
        rep(i,nb){
          if(i==nv||intersectSS(L(pa[0],pa[1]),L(pb[nv],pb[i])))continue;
          que.push(pdi(nd+abs(pb[nv]-pb[i]),i));
        }
      }
      minch(res,abs(pa[0]-pa[1])+dist[1]);
    }
    if(res==inf)printf("-1");
    else printf("%.15Lf\n", res);
  return 0;
}

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

int main(int argc, char const *argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l == r)
    cout << "Balanced" << endl;
  else if (l > r)
    cout << "Left" << endl;
  else
    cout << "Right" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 yymm(int s) {

}

void solve(long long S) {
    int x = S / 100;
    int y = S % 100;

    int a = false;
    if (x >= 1 && x <= 12) {
        a = true;
    }
    int b = false;
    if (y >= 1 && y <= 12) {
        b = true;
    }
    if( a && b ){
        cout << "AMBIGUOUS" << endl;
    }else if( a && !b){
        cout << "MMYY" << endl;
    }else if( !a && b){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}

int main() {
    long long S;
    scanf("%lld", &S);
    solve(S);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
using namespace std;

int main() {
	int N;
	char S[109], T[200];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	int M=0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 'a'; j <= 'z'; j++) {
			T[j] = 0;
		}
		for (int j = 0; j <= i; j++) {
			for (int k = N-1; k > i;k--) {
				if (S[j] == S[k]) {
					T[S[j]] = 1;
					break;
				}
			}
		}
		for (int j = 'a'; j <= 'z'; j++) {
			sum += T[j];
		}
		M = max(M, sum);
	}
	cout << M;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int c=1e6;
const ll mod=1e9+7;
ll fact[10000000], inv[10000000];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    calcFacAndInv(c);
    ll arr[n+6],ar[n+6],mx=0,mn=0;
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    sort(ar,ar+n);
    for(int i=1;i<=n;i++){
        arr[i]=ar[i-1];
    }
    if((n-1)>=(k-1))
    mn=mn+((arr[1]*ncr(n-1, k-1))%mod);
    for(ll i=2;i<n;i++){
            if((n-i)>=(k-1))
    mn=mn+((arr[i]*ncr(n-i, k-1))%mod);
    if((i-1)>=(k-1))
    mx=mx+((arr[i]*ncr(i-1, k-1))%mod);

    }
    if((n-1)>=(k-1))
    mx=mx+((arr[n]*ncr(n-1, k-1))%mod);
    cout<<(mx-mn)%mod;
    //cout<<mn<<" "<<mx;
    return 0;
}


Measured memory_bytes: 18176
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s, t;
    cin >> s >> t;
    int ans = mod;
    rep(i, s.size() - t.size() + 1) {
        int cnt = 0;
        rep(j, t.size()) {
            if(s[i + j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    output(ans);
    
    
    
    return 0;
}


Measured memory_bytes: 3640
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        if(n==0){
            System.out.println(0);
            return;
        }
        long []dp = new long[3];
        dp[0] = in.nextLong();
        dp[1] = in.nextLong();
        dp[2] = in.nextLong();
        for(int i=1;i<n;i++){
            long [] curr = new long[3];
            long [] temp_dp = new long[3];
            for(int k = 0;k<3;++k)curr[k] = in.nextLong();
            for(int k =0 ;k<3;++k){
                for(int j=0;j<3;j++){
                    if(k==j)continue;
                    temp_dp[k]= Math.max(temp_dp[k],dp[j]);
                }
                temp_dp[k]+=curr[k];
            }
            dp = temp_dp;
        }
        long ret = 0;
        for(long i : dp)ret = Math.max(ret,i);
        System.out.println(ret);
    }
}


Measured memory_bytes: 88316
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
matrixC = [ [ sum( matrixA[i][k] * matrixB[k][j]  for k in range( m ) ) for j in range( l ) ] for i in range( n )  ]

for i in range( n ):
	print( " ".join( map( str, matrixC[i] ) ) )

Measured memory_bytes: 5000
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    vi K(N);
    vvi A(N);
    vector<set<ll>> B(N);
    REP(i, N)
    {
        cin >> K[i];
        A[i].assign(K[i], 0);
        REP(j, K[i])
        {
            cin >> A[i][j];
            B[i].insert(A[i][j]);
        }
    }
    ll ans = 0;
    REP1(j, M)
    {
        bool ok = true;
        REP(i, N)
        {
            ok &= B[i].find(j) != B[i].end();
        }
        ans += ok;
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int maxn(2e5 + 10);
std::pair<int, int> t[maxn]; long long ans;
int n, lx[maxn], ly[maxn], rx[maxn], ry[maxn];

int main()
{
	scanf("%d", &n), ly[0] = ry[n + 1] = 1e9;
	for (int i = 1; i <= n; i++)
	{
	    scanf("%d%d", &t[i].first, &t[i].second);
	    if (t[i].first > t[i].second) std::swap(t[i].first, t[i].second);
	}
	std::sort(t + 1, t + n + 1);
	for (int i = 1; i <= n; i++) lx[i] = std::max(lx[i - 1], t[i].second);
	for (int i = 1; i <= n; i++) ly[i] = std::min(ly[i - 1], t[i].second);
	for (int i = n; i; i--) rx[i] = std::max(rx[i + 1], t[i].second);
	for (int i = n; i; i--) ry[i] = std::min(ry[i + 1], t[i].second);
	ans = 1ll * (t[n].first - t[1].first) * (lx[n] - ly[n]);
	for (int i = 1; i < n; i++)
	{
		int ax = std::max(t[n].first, lx[i]), ay = std::min(t[i + 1].first, ly[i]);
		int bx = std::max(rx[i + 1], t[i].first), by = std::min(ry[i + 1], t[1].first);
		ans = std::min(ans, 1ll * (ax - ay) * (bx - by));
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		int[][] a = new int[n+1][n+1];
		int[][] p = new int[q][2];
		for(int i = 0; i<m; i++){
			int c = sc.nextInt();
			int b = sc.nextInt();
			a[c][b]++;
		}
		for(int i = n-1; i>=1; i--){
			for(int j=i; j<=n; j++){
				a[i][j]+=a[i+1][j]+a[i][j-1]-a[i+1][j-1];
			}
		}
		for(int i = 0; i<q; i++){
			int h = sc.nextInt();
			int w = sc.nextInt();
			p[i][0]=h;
			p[i][1]=w;
		}
		for(int i = 0; i<q; i++){
			System.out.println(a[p[i][0]][p[i][1]]);
		}
	}
}

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

int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    int l[n], times = 1;
    for (int i = 0; i < n; i ++) {
        cin >> l[i];
        x -= l[i];
        if (x >= 0)
            times ++;
    }
    cout << times << '\n';
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}


int main() {
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  sort(ALL(s));
  vector<pair<int, string>> v;
  int cnt = 0;
  rep(i, n-1){
    ++cnt;
    if(s[i]!=s[i+1]){
      v.pb(make_pair(-cnt, s[i]));
      cnt = 0;
    }
  }
  ++cnt;
  v.pb(make_pair(-cnt, s[n-1]));
  sort(ALL(v));

  int maxi = v[0].first;
  rep(i, v.size()){
    if(v[i].first != maxi) return 0;
    cout << v[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 19932
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define INFTY (1<<30)
#define MAX 100010

int n;
vector<pair<int,int>> adj[MAX];

void dijkstra(){
  priority_queue<pair<int,int>> PQ;
  int d[MAX];
  for(int i=0;i<n;i++) d[i]=INFTY;

  d[1]=0;
  PQ.push(make_pair(0,1));

  while(!PQ.empty()){
    pair<int,int> f=PQ.top();
    //cout<<f.first<<" "<<f.second<<endl;
    PQ.pop();
    int u=f.second;

    if(d[u]<f.first*(-1)) continue;

    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(d[v]>d[u]+adj[u][j].second){
        d[v]=d[u]+adj[u][j].second;
        PQ.push(make_pair(d[v]*(-1),v));
      }
    }
  }

  cout<<d[0]+1<<endl;
  /*for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
  }*/
}

int main(){
  cin>>n;
  for(int i=1;i<n;i++){
    adj[i].push_back(make_pair((i+1)%n,1));
    adj[i].push_back(make_pair((i*10)%n,0));
    //cout<<i<<" "<<(i+1)%n<<" "<<i*10%n<<endl;
  }
  dijkstra();
  return 0;
}


Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
vector<int> ans,b;
int main(){
    cin>>n;
    int bi;
    rep(i,n){
        cin>>bi;
        b.pb(bi);
    }
    rep(i,n){
        int nx=-1;
        for(int j=(int)b.size()-1;j>=0;--j){
            if(b[j]==j+1){
                nx=j+1;
                b.erase(b.begin()+j);
                break;
            }
        }
        if(nx==-1){
            cout<<-1<<endl;
            return 0;
        }
        ans.pb(nx);
    }
    reverse(ans.begin(),ans.end());
    rep(i,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll h, w, n, K;
int a[55][55];

int main() {
    cin >> h >> w >> n >> K;
    rep(i,h)rep(j,w)a[i][j] = 0;

    // 愚直
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            cout << "? " << i << " " << j << " " << i << " " << j << endl << flush;
            int res;
            cin >> res;
            a[i][j] = res;
            cnt += a[i][j];
            if(cnt == n)break;
        }
    }

    // ans出力
    ll ans = 0;
    rep(i,h){
        rep(j,w){
            if(a[i][j])ans = (ans + mod_pow(2,i*w+j,K)) % K;
        }
    }
    cout << "! " << ans << endl << flush;
    return 0;
}




Measured memory_bytes: 3756
w,h,n = map(int, input().split())
xx = 0
xr = w
yy = 0
yt = h
for i in range(n):
	x,y,a = map(int ,input().split())
	if a == 1:
		xx = max(xx,x)
	elif a == 2:
		xr = min(xr,x)
	elif a == 3:
		yy = max(yy,y)
	else:
		yt = min(yt,y)
s = max(min(w,xr)-xx,0) * max(min(h,yt)-yy,0)
print (s)


Measured memory_bytes: 3064
n = int(input())
c = input()

wi = c.find('W')
ri = c.rfind('R')

if wi == -1 or ri == -1:
    print(0)
else:
    ans = 0
    while wi < ri:
        wi += 1
        wi = c[wi:].find('W') + wi
        ri = c[:ri].rfind('R')
        ans += 1

    print(ans)

Measured memory_bytes: 9312
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int C = sc.nextInt();
      	int D = sc.nextInt();
      	int ab = 0;
      	int cd = 0;
        if(A<B){
        	ab = A;
        }else{
        	ab = B;
        }
      	if(C<D){
        	cd = C;
        }else{
        	cd = D;
        }
      
      	System.out.println(ab+cd);
    }
}

Measured memory_bytes: 21844
var heredoc = null;
if (process.argv[2] == "-debug") {
    debug = true;
    heredoc = (()=>{/*
3 3
...
.#.
...
*/}).toString().replace(/^[^\/]+\/\*\n/, "").replace(/\*\/}$/m, "");
}

function main(input) {
    var wrk = input.shift().split(" ");
    H = parseInt(wrk.shift(), 10);
    W = parseInt(wrk.shift(), 10);
    mat = [];
    var lines = Array(H);
    for(var i = 0; i<H;i++)
    {
        var line = input.shift();
        var lineN =  Array(W);
        for(var j = 0; j<W; j++)
        {
            if(line[j]=="#")
            {
                lineN[j] = 1;
                mat.push([i, j, 0]);
            }
            else
            {
                lineN[j] = 0;
            }
        }
        lines[i] = lineN;
    }

    p = function(i,j,cnt){
        if(lines[i][j]==0)
        {
            lines[i][j] = 1;
            mat.push([i, j, cnt+1]);
        }
    };
	var k = 0;
    while(mat.length > k)
    {
        var wrk = mat[k++];
        var i = wrk[0];
        var j = wrk[1];
        var cnt = wrk[2];

        if(i > 0)
            p(i-1,j, cnt);
        if(i < H-1)
            p(i+1,j, cnt);
        if(j > 0)
            p(i,j-1, cnt);
        if(j < W-1)
            p(i,j+1, cnt);
    }
    console.log(cnt);

}

var lines;
if (!heredoc)
    lines = require("fs").readFileSync("/dev/stdin", "utf8");
else
    lines = heredoc;
main(lines.trim().split("\n"));


Measured memory_bytes: 145108
#include <iostream>
using namespace std;
int ctoi(char c){return c - '0';}
int abs(int x){return x > 0 ? x : -x;}

int main(){
	string s;
	cin >> s;
	int X = ctoi(s[0]) * 100 + ctoi(s[1]) * 10 + ctoi(s[2]);
	int dif = abs(753 - X);
	int num;
	for(int i = 1; i < s.size() - 2; i++){
		num = ctoi(s[i]) * 100 + ctoi(s[i+1]) * 10 + ctoi(s[i+2]);
		if(abs(753 - num) < dif){
			X = num;
			dif = abs(753 - X);
		}
	}
	cout << dif << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC162
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

void solve(void){
  
  int K;
  ll ans=0;
  
  cin >> K;
  
  REP2(i,1,K+1){
    REP2(j,1,K+1){
      ll tmp=gcd((ll)i,(ll)j);
      REP2(k,1,K+1){
        ans += gcd(tmp,(ll)k);
      }
    }
  }
  cout << ans <<endl;
   
  
  return;
   
}



#define TESTCASES 1

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


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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

struct point{
    double x,y,z;
};
int n,m;
vector<point> ps;
int selected[100];

double maxSum=0;

void dfs(int idx,int cnt){
    // mツ古つ選ツづアツつセツづァツ計ツ算
    if(cnt==m){
        double sum=0;
        // ツ債キツづ個和ツづーツ計ツ算
        for(int i = 0; i < m; i++){
            for(int j = i+1; j < m; j++){
                sum+=pow(ps[selected[i]].x-ps[selected[j]].x,2);
                sum+=pow(ps[selected[i]].y-ps[selected[j]].y,2);
                sum+=pow(ps[selected[i]].z-ps[selected[j]].z,2);
            }
        }
        maxSum=max(maxSum,sum);
    }
    else if(idx>=n)
        return;
    else{
        for(int i = idx; i < n; i++){
            selected[cnt]=i;
            dfs(i+1,cnt+1);
        }
    }
}

void solve(){
    cin>>n>>m;
    for(int i = 0; i < n; i++){
        point p;
        cin>>p.x>>p.y>>p.z;
        ps.push_back(p);
    }
    dfs(0,0);
    printf("%.6f\n",maxSum);
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

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

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

    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << " ";
    if (x == w / 2 && y == h / 2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int mae = 0;
    int ato = 0;
    int sw = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] == 1){
            sw = 1;
        }
        if(sw == 0){
            mae++;
        }
        else{
            ato++;
        }
    }
    ato--;

    int ans = 100000000;
    for(int i=0; i<=k-1; i++){
        int tmp_ans;
        tmp_ans += (mae-i)/(k-1);
        if((mae-i)%(k-1) != 0) tmp_ans++;
        tmp_ans += (ato - (k-i-1))/(k-1);
        if((ato - (k-i-1))%(k-1) != 0) tmp_ans++;
        ans = min(tmp_ans, ans);
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, M = MAP()

S = input()
T = input()

L = N*M//gcd(N, M)
G = gcd(N, M)

for i in range(G):
	if S[N//G*i] != T[M//G*i]:
		print(-1)
		break
else:
	print(L)





Measured memory_bytes: 5472
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin>>x;
    if(x>=400&&x<=599)
    cout<<"8"<<endl;
    else if(x>=600&&x<=799)
    cout<<"7"<<endl;
    else if(x>=800&&x<=999)
    cout<<"6"<<endl;
    else if(x>=1000&&x<=1199)
    cout<<"5"<<endl;
    else if(x>=1200&&x<=1399)
    cout<<"4"<<endl;
    else if(x>=1400&&x<=1599)
    cout<<"3"<<endl;
    else if(x>=1600&&x<=1799)
    cout<<"2"<<endl;
    else if(x>=1800&&x<=1999)
    cout<<"1"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int sum{15};
  for(int i=0; i<5; i++){
    int a; cin>>a;
    sum -= a;
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 3620
#include <iostream>
#include<vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
typedef long long int lld;
typedef unsigned long long int llu;
using namespace std;
const int m=1e9;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n],i;
	for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	int dp[3][n];
	dp[0][0]=a[0];
	dp[1][0]=b[0];
	dp[2][0]=c[0];
	for(i=1;i<n;i++)
	{
		dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
		dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
		dp[2][i]=c[i]+max(dp[1][i-1],dp[0][i-1]);
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int n = s.nextInt();
            int x = s.nextInt();
            if(n == 0 && x ==0) break;
            int c = 0;
            for(int i = 1; i <= n; ++i) {
                for(int j = i + 1; j <= n; ++j) {
                    for(int k = j + 1; k <= n; ++k) {
                        if(i + j + k == x) {
                            c++;
                            break;
                        } else if(i + j + k > x) {
                            break;
                        }
                    }
                    if(i + j * 2 > x) break;
                }
                if(i * 3 > x) break;
            }
            System.out.println(c);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

ll a, b;

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

    cin>>a>>b;
    if (a==b)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 6

int main(void)
{
  int input[N];
  int i,j;
  
  for( i = 0; i < N; i++ ){
    scanf("%d", input+i);
  }
  
  for( i = 0; i < N; i++ ){
    for( j = i + 1; j < N; j++){
      if(input[5] < input[j] - input[i]){
        printf(":(\n");
        return 0;
      }
    }
  }
  
  printf("Yay!\n");
  
  return 0;
}

Measured memory_bytes: 128
from math import gcd
from functools import reduce

# def gcd(*numbers):
#     r = reduce(math.gcd, numbers)
#     return r

def main():
    K = int(input())
    g = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                g += gcd(gcd(i, j), k)         
    print(g)
main()

Measured memory_bytes: 9572
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n,mx,cnt;
    cin >> n;
    cnt =0,mx = -1;
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        if(mx <= temp){
            cnt++;
            mx = temp;
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()

N, A, B = map(int, input().split())

A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
N = int(input())
P = list(map(int, input().split()))
counter = 0
for i in range(1, len(P) - 1):
    if (P[i - 1] < P[i] and P[i] < P[i + 1]) or (P[i - 1] > P[i] and P[i] > P[i + 1]):
        counter += 1

print(counter)



# def main():

# if __name__ == '__main__':
#     main()


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

int main(){
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define RREP(i, n, m) for(int i = 0;i < n;i+=m)
    #define REPM(i, n) for(int i = n-1;i >= 0;i--)
    #define REPP(i,l,n) for(int i = l;i<n;i++)

    int sum = 0;
    int N;
    string n;
    cin >> N;
    n = to_string(N);
    REP(i,10){
        if(n[i]){
        sum = sum + (n[i] - '0');
        }
    }
    if(N % sum == 0){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
LR = [[int(_) for _ in input().split()] for _ in range(M)]
L = 0
R = 10 ** 5
for l, r in LR:
    L = max(L, l)
    R = min(R, r)

if L > R:
    print(0)
else:
    print(R - L + 1)

Measured memory_bytes: 21156
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


int main()
{
  ll a,b;
  cin >> a >> b;
  ll x = a * b;

  ll tmp;
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  ll r;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  cout << x/b << endl;
  return 0;

}


Measured memory_bytes: 256
list = input().split()
list = [int(s) for s in list]

N = list[0]
T = list[1]

c = [0]*N
t = [0]*N

for i in range(N):
    templist = input().split()
    templist = [int(s) for s in templist]
    c[i] = templist[0]
    t[i] = templist[1]

    i = i + 1

n = 0

for i in range(N):
    if t[i] <= T:
        n = n + 1
    
    i = i + 1

if n == 0:
    print("TLE")

else:

    d = [0]*n
    k = 0

    for i in range(N):
        if t[i] <= T:
            d[k] = c[i]
            k = k + 1

    m = d[0]

    for j in range(n):
        if m >= d[j]:
            m = d[j]
    
        j = j + 1

    print(m)


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

int main() {
  int a,b,c,d,e,f,g,h,i;
  cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
  puts(a+e+i==b+f+g && a+e+i==c+d+h ? "Yes" : "No" );
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;

    if(n <= 26) {
        cout << char('a' + n - 1) << endl;
        return 0;
    }

    --n;
    ll p = 1, sum = 1, n_digit = 1;
    for(int i=1;i<=10;++i) {
        p *= 26;
        if(p <= n) {
            n -= p;
            ++n_digit;
        }
    }
    
    string s = "";
    for(int i=0;i<n_digit;++i) {
        s += 'a' + n%26;
        n /= 26;
    }
    reverse(s.begin(), s.end());

    cout << s << endl;
}


Measured memory_bytes: 3524
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int N;
char ans[10];

int DFS(int turn, int cnt){
  if (turn == N){
    for (int i = 0; i < N; i++){
      printf("%c", ans[i]);
    }
    printf("\n");
    return 0;
  }

  for (int i = 0; i < cnt; i++){
    ans[turn] = 'a' + i;
    DFS(turn + 1, cnt);
  }
  
  ans[turn] = 'a' + cnt;
  DFS(turn + 1, cnt + 1);
  return 0;
}

int main(){
  cin >> N;
  DFS(0, 0);

  return 0;
}


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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double ah = M_PI * (60.0 * h + m) / 360.0;
  double am = M_PI * m / 30.0;
  
  double xh = a * sin(ah);
  double yh = a * cos(ah);
  double xm = b * sin(am);
  double ym = b * cos(am);
  
  double dx = xh - xm;
  double dy = yh - ym;
  
  double ans = sqrt(dx*dx + dy*dy);
  cout << fixed << setprecision(20) << ans << endl;
}

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

using ll = long long;

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

    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        int sum = a[i] + a[i - 1];
        if (sum > x)
        {
            int sub = sum - x;
            ans += min(a[i], sub);
            int tmp = a[i];
            a[i] -= min(sub, a[i]);
            sub -= tmp;
            if (sub > 0)
            {
                ans += sub;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772