akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

vector<int> graph[100010];

int main(void){
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	int ans = 0;
	rep(i, n) {
		bool ok = true;
		for(auto &j: graph[i]) {
			if(h[i] <= h[j]) {
				ok = false;
			}
		}
		ans += ok;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8808
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll solve(ll n){
    ll num=0;
    while(n){
        n/=10;
        num++;
    }
    return num;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;
    cin>>n;
    a=ll(sqrt(n));
    for(ll i=a;i>=1;i--){
        if(n%i==0){
            a=n/i;
            b=i;
            break;
        }
    }
    cout << (max(solve(a),solve(b))) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  cout << (N - (H - 1)) * (N - (W - 1)) << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    ll ans=(n+111-1)/111;
    ans*=111;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#D
from collections import deque
N,X,Y = map(int,input().split())
dist = [0 for _ in range(N)]

for i in range(N):
    s = i+1
    sdist = [-1 for _ in range(N)]
    d = deque([])
    d.append([s,0])
    while d:
        x,n = d.popleft()
        if sdist[x-1] == -1:
            sdist[x-1] = n
            
            if x < N:
                d.append([x+1,n+1])
            if x > 1:
                d.append([x-1,n+1])
            if x == X:
                d.append([Y,n+1])
            if x == Y:
                d.append([X,n+1])
    
    for sd in sdist:
        dist[sd]+=1
        
for i in range(N-1):
    print(dist[i+1]//2)
        
    



Measured memory_bytes: 58588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 13

int main(){
   double xs,ys,xe,ye;
   scanf("%lf%lf%lf%lf",&xs,&ys,&xe,&ye);
   double kyori;
   double tmp;
   tmp=(xe-xs)*(xe-xs)+(ye-ys)*(ye-ys);
   kyori = sqrt(tmp);
   printf("%f\n",kyori);
   return 0;
}


Measured memory_bytes: 2100
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        if (a==1||b==1)System.out.println(1);
        else System.out.println(function(gcd(Math.max(a,b),Math.min(a,b))));

    }
    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long function(long num){
        long n = num;
        long count = 2;
        long ans = 0;
        long lim = (long)Math.ceil(Math.sqrt(num))+1000;
        while (n>1&&count<=lim){
            if (n%count==0)ans++;
            while (n%count==0){
                n/=count;
            }
            count++;
        }
        if (count>lim)ans++;
        return ++ans;
    }
}


Measured memory_bytes: 35736
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
int main()
{
    int n,m = INT_MIN;
    long int rm;
    cin >> n >> rm;
    for(int i = 1;i < n;i++)
    {
         long int r;
         cin >> r;
         if(r - rm > m)
         {
             m = r - rm;
         }
         if(rm > r)
         {
             rm  = r;
         }
    }
    cout << m << endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int H,A,num;
    cin >> H >> A;
    num=H/A;
    if(H==A*num){
        cout << num;
    }
    else{
        cout << num+1;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
N, M = list(map(int, input().split()))
ls = [[] for i in range(N)]
for i in range(M):
    a, b = list(map(int, input().split()))
    ls[a].append(b)

if len(ls[1]) == 0:
    print('IMPOSSIBLE')
    sys.exit()

for i in ls[1]:
    if (N in ls[i]):
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 35864
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int K,A,B,res=0,S,W;
long long int N,sum=0;
int main()
{
    cout << fixed << setprecision(18);
    cin>>S>>W;
    if(S<=W){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
    
    
}    


Measured memory_bytes: 3636
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    stack<char>st;
    string s;
    cin>>s;
    int n=s.len;
    rep0(i,n){
        if(s[i]=='B'){
            if(!st.empty()) st.pop();
        }
        else st.push(s[i]);
    }
    string ans="";
    while(!st.empty()){
        ans+=st.top();
        st.pop();
    }
    reverse(ans.beg,ans.en);
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int a, b, N, M, ans = 0, sum;
  int glaph[8][8] = {};
  vector<int> p;
  cin >> N >> M;

  for(int i = 0;i < M;i++){
    cin >> a >> b;
    glaph[a-1][b-1] = 1;
    glaph[b-1][a-1] = 1;
  }

  for(int i = 1;i < N;i++){
    p.push_back(i);
  }

  do{
    sum = 0;
    sum += glaph[0][p[0]];
    for(int i = 0;i < N-2;i++){
      sum += glaph[p[i]][p[i+1]];
    }

    if(sum == N-1) ans++;
  } while(next_permutation(p.begin(), p.end()));

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


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			String s = stdIn.next();
			if(s.equals("-"))
				break;
			int m = stdIn.nextInt();
			for (int i=0; i<m; i++) {
				int h = stdIn.nextInt();
				String temp = s.substring(h,s.length());
				temp += s.substring(0,h);
				s = temp;
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 17240
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  list<char> lis;
  char s[SIZE];
  int ans = 0;
  int n;
  
  scanf("%s",s);
  n = strlen(s);

  for(int i=0;i<n;i++){
    lis.push_back(s[i]);
  }

  auto l=lis.begin();
  auto r=lis.begin();
  r++;
  
  while(l!= lis.end() && r != lis.end()){
    if(*l == 'S' && *r == 'T'){
      lis.erase(r);
      l = lis.erase(l);
      if(l != lis.begin())l--;
      if(l != lis.begin())l--;
      r = l;
      r++;
      ans++;
    }else{
      l++;
      r++;
    }
  }

  ans = n - ans*2;

  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 6656
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
    int n; cin>>n;
    string s; cin>>s;
    int ans = 0;
    f(i,n-2){
    	string a = s.substr(i,3);
    	if(a == "ABC") ans++;
	}
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3612
n = int(input())
div = [2 for _ in range(n)]
div[0] = 1
ans = 1
for num in range(2, n + 1):
    ans += num * div[num - 1]
    tmp = num - 1
    while 1:
        tmp += num
        try:
            div[tmp] += 1
        except IndexError:
            break
print(ans)

Measured memory_bytes: 219392
def graph_to_edges(graph):
    '''(cosr,from,to)を要素に持つリストに変換 未verify'''
    # edgeへの変換
    edges = []
    for ot, v in graph.items():
        for to, c in v:
            edges.append((c, ot, to))
    return edges

def bellman_ford(edges, s, N):
    '''
    edges ... (cost,from,to)を各要素に持つリスト
    s...始点ノード
    N...頂点数

    return
    ----------
    D ... 各点までの最短距離
    P ... 最短経路木における親
    '''
    P = [None] * N
    inf = float('inf')
    D = [inf] * N
    D[s] = 0
    for n in range(N):  # N-1回で十分だけど、N回目にもアップデートがあったらnegative loopを検出できる
        update = False  # 早期終了用
        for c, ot, to in edges:
            if D[ot] != inf and D[to] > D[ot] + c:
                update = True
                D[to] = D[ot] + c
                P[to] = ot
        if not update:
            break  # 早期終了
        if n == len(edges) - 1:
            raise ValueError('NegativeCycleError')
    return D, P

# load datas
N = int(input())
from collections import defaultdict
adj = defaultdict(lambda:[])
'''
例
[
(0について) [(1,1235), (4,65)]
(1について) [(20,6000)]
...
]
'''
for _ in range(N):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:
        node = tmp[0]
        for i in range(2, 2 + tmp[1] * 2, 2):
            adj[node].append((tmp[i], tmp[i + 1]))
            
edges=graph_to_edges(adj)


D, P = bellman_ford(edges,0,N)

for i in range(N):
    print(i, D[i])


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


int main() {
	int N, T; cin >> N >> T;
	int c[N],t[N],i,cost=1000,flag=0;

	for (i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
	}
	for (i = 0; i < N; i++) {
		if (t[i] <= T && c[i] <= cost) {
			cost = c[i];
			flag = 1;
		}
	}

	if(flag==1){
		cout << cost << endl;
	}
	else { cout << "TLE" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
void solve()
{
	ll n,b,r;
	rl3(n,b,r);
	ll ans=n/(b+r);
	n=n%(b+r);
	ans*=b;
	ans+=min(n,b);
	cout<<ans<<endl;
	return;
}
int main()
{
	
	ll t=1;
	//rl(t);

	//cin>>t;
	//scanf()
	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n;
int Q[105];
int head = 0;
int tail = 0;
int d[101];
int G[101][101],color[101];

void enqueue(int a){
  Q[tail]=a;
  tail++;
}

int dequeue(){
  int a;
  a = Q[head];
  head++;
  return a;
}

/*void visit(u){
  int i;
  G[u].color = 1;
  d[u] = ++time;
  for(i=0;i<G[u].k;i++){
    if(G[G[u].next[i]].color == 0)
      visit(G[u].next[i]);
  }
  G[u].color = 2;
  f[u] = ++time;
  }*/

void bfs(int s){
  int i,u,v;
  for(i=1;i<=n;i++){
    color[i] = 0;
    d[i] = -1;
  }
  color[s] = 1;
  d[s] = 0;
  enqueue(s);
  while(tail != head){
    u = dequeue();
    //printf("%d\n",u);
    for(v = 1;v <= n;v++){
      if(color[v] == 0 && G[u][v] == 1){
	color[v] = 1;
	d[v]  = d[u] + 1;
	//	printf("%d:%d\n",j,d[j]);
	enqueue(v);
      }
    }
    color[u] = 2;
  }
}

int main(){
  int i,j,a,k,v;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&a,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[a][v] = 1;
    }
    //for(j=1;j<=n;j++)
    //  printf("%d:%d\n",G[i].id,G[i].next[j]);
  }
  bfs(1);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bucnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int H, W, h, w;	cin >> H >> W >> h >> w;
	if (W%w == 0 && H%h == 0) {
		cout << "No" << endl;
		return 0;
	}
	vector<vector<ll>> ret(H, vector<ll>(W, 1LL));
	//(w-1,h-1)からw,hずつ進めて-infで埋めていく
	for (int i = h - 1; i < H; i += h)	for (int j = w - 1; j < W; j += w)	ret[i][j] = -inf;
	//(0,0)からw,hずつ進めてinf-(w*h)で埋めていく
	for (int i = 0; i < H; i += h)	for (int j = 0; j < W; j += w)	ret[i][j] = inf - (w*h);
	ll sum = 0;
	rep(i, H)	rep(j, W)	sum += ret[i][j];
	if (sum <= 0)	cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		rep(i, H) {
			rep(j, W)	cout << (j ? " " : "") << ret[i][j];
			cout << endl;
		}
	}
	return 0;
}

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

using namespace std;



// n-1の約数の数
int countDivisor(long long n){
    long long val = n;
    int insu[500001] = {};
    while(val % 2 == 0){
        val /= 2;
        insu[0] ++;
    }

    for(int i = 1; i <= 500000; i++){
        int num = 2 * i + 1;
        while (val % num == 0)
        {
            val /= num;
            insu[i]++;
        }
        if(val < num) break; // val is prime or 1
    }

    long long divisor = 1;
    for(int i = 0; i <= 500000; i++)
        divisor *= (insu[i] + 1);
    if(val > 1)divisor *= 2;
    return divisor;
}

//nの約数のうち，連続するもの
int countDiv(long long n){
    long long ans = 0;
    for(long long k = 2; k * k <= n; k++){
        long long na = n;
        if(na % k != 0)continue;
        while(na % k == 0){ na /= k;}
        if(na % k == 1)ans++;
    }
    return ans;
}
int main(){
    long long n;
    cin >> n;
    cout << countDivisor(n-1) + countDiv(n);
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='?' && s[i-1]=='P'){
      s[i]='D';
    }else if(s[i]=='?' && s[i-1]=='D' && s[i+1]=='D'){
      s[i]='P';
    }else if(s[i]=='?' && s[i-1]=='D' && s[i+1]=='P'){
      s[i]='D';
    }else if(s[i]=='?' && s[i+1]=='?'){
      s[i]='P';
    }else if(s[i]=='?'){
      s[i]='D';
    }
  }
  for(int i=0;i<s.size();i++){
    cout << s[i] ;
  }
  cout << endl;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
 
int main(){
    int n, m, l, i, j, k;
    long long t;
    cin >> n >> m >> l;
    int A[n][m], B[m][l];
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            cin >> B[i][j];
        }
    }
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            t = 0;
            for(k = 0; k < m; k++){
                t += A[i][k]*B[k][j];
            }
            if(j == 0) cout << t;
            else cout << " " << t;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;

int N, A, B, C, D;
std::string s;

bool dfs(int a, int g) {
    if(a == g) return true;
    bool ok = false;
    if(a+1 < N && s[a+1] == '.') ok = dfs(a+1,g);
    else 
    if(a+2 < N && s[a+2] == '.') ok |= dfs(a+2,g);
    return ok;
}

int main(){
    INIT;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    cin >> s;
    if(C < D) {
       cout << ((dfs(A,C) && dfs(B,D)) ? "Yes" : "No");
       return 0;
    }

    int b2 = -1;
    for(int i = B; i <= D; i++) {
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') b2 = i;
    }

    if(b2 == -1) {
        cout << "No";
        return 0;
    }

    cout << ((dfs(A,C) && dfs(b2,D)) ? "Yes" : "No");
}

Measured memory_bytes: 592
N = int(input())
S = input()
m = 0
for i in range(1, N):
    S1, S2 = S[:i], S[i:]
    S1 = set(S1)
    S2 = set(S2)
    now = len(S1&S2)
    if m < now:
        m = now
print(m)

Measured memory_bytes: 8996
import sys
readline = sys.stdin.buffer.readline

a,op,b = readline().rstrip().decode('utf-8').split()

class Input():
    def __init__(self,a,op,c):
        self.a = int(a)
        self.b = int(b)
        self.op = op

class Calc(Input):
    def __call__(self):
        if self.op == "+":
            return self.a+self.b
        else:
            return self.a-self.b

x = Calc(a,op,b)
print(x())

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

int main() {
    ll n, x;
    cin >> n;
    vector<ll> cnt(n,0);
    for (ll i=1; i<n; i++) {
        cin >> x;
        cnt[x-1]++;
    }
    for (auto i : cnt) cout << i << endl;
    return 0;
}

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

int main(){
        string s;
        cin >> s;
        bool flag=true;
        for(int i=0; i<s.size(); i++) {
                for(int j=1+i; j<s.size(); j++) {
                        if(s[i]==s[j]) {
                                flag = false;
                        }
                }
        }
        if(flag) {
                cout << "yes" <<endl;
        }else{
                cout << "no" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9+7;
constexpr int N_MAX = 1e6+1;
ll dp[N_MAX][3] = {};
int main()
{
    int n;
    cin >> n;
    dp[0][0]=1;
    for(int i=1; i<=n; ++i){
        // 0も9も存在しない列
        dp[i][0] = (8*dp[i-1][0])%MOD;
        // 0が存在して9が存在しない列（逆も同数）
        dp[i][1] = (dp[i-1][0] + dp[i-1][1]*9)%MOD;
        // 0,9が存在する列
        dp[i][2] = (dp[i-1][1]*2 + dp[i-1][2]*10)%MOD;
    }
    cout << dp[n][2];
    return 0;
}


Measured memory_bytes: 26828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        int x=a[i];
        for(int j=i+1;j<n;j++)
        {
            ans+=x*a[j];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
#define mod 1000000007
int x,y,z,n,a,b,c,f;
ll dp[41][(1<<17)]={},ans;
int main(){
    scanf("%d %d %d %d",&n,&x,&y,&z);
    a=1<<(17);
    dp[0][0]=1;
    ans=1;
    for(int i=0;i<n;i++){
        ans*=10;
        ans%=mod;
    }
    b=1;
    b=b<<x;
    b+=1;
    b=b<<y;
    b+=1;
    b=b<<(z-1);
    for(ll i=0;i<n;i++){
        for(ll j=0;j<a;j++){
            if(j&(1<<(x+y+z-1))&&j&(1<<(y+z-1))&&j&(1<<(z-1)));
            else{
                for(ll k=1;k<=10;k++){
                    dp[i+1][((j<<k)%(a))+(1<<(k-1))]+=dp[i][j];
                    dp[i+1][((j<<k)%(a))+(1<<(k-1))]%=mod;
                }
            }
        }
    }
    for(int i=0;i<a;i++){
        if(i&(1<<(x+y+z-1))&&i&(1<<(y+z-1))&&i&(1<<(z-1)));
        else{
            ans+=mod-dp[n][i];
            ans%=mod;
        }
    }
    printf("%lld\n",ans);
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;

	VL ys1, ys2;
	ll ans = 1LL<<50;
	for(ll i=1; i*i<=n; i++){
		if(n%i ==0){
			ll w1 = i -1;
			ll w2 = n/i -1;
			ans = min(ans, w1 +w2);
		}
	}

	cout << ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> field(H, vector<int>(W, 0));
  rep(i, H) rep(j, W)
  {
    char c;
    cin >> c;
    if (c != '.')
      field[i][j] = K--;
  }

  rep(i, H) rep(j, W - 1)
  {
    if (field[i][j + 1] == 0)
      field[i][j + 1] = field[i][j];
  }

  rep(i, H) rep(j, W - 1)
  {
    if (field[i][W - 2 - j] == 0)
      field[i][W - 2 - j] = field[i][W - 1 - j];
  }

  rep(i, H - 1) rep(j, W)
  {
    if (field[i + 1][j] == 0)
      field[i + 1][j] = field[i][j];
  }

  rep(i, H - 1) rep(j, W)
  {
    if (field[H - 2 - i][j] == 0)
      field[H - 2 - i][j] = field[H - 1 - i][j];
  }
  rep(i, H)
  {
    rep(j, W)
    {
      cout << field[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    string a[h];

    for(int i=0;i<h; i++){
        cin >> a[i];
    }   
    int z[h]={0};
    int z2[w]={0};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j]=='#'){
                z[i]++;
                z2[j]++;
            }
        }
    }

    for(int i=0; i<h; i++){
        if(z[i]){
            for(int j=0; j<w; j++){
                if(z2[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 998244353
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec L(K), R(K);
    REP(i,0,K) cin >> L[i] >> R[i];

    vec dp(N+1, 0);
    vec sum(N+1, 0);
    dp[1] = 1;
    sum[1] = 1;
    REP(i,2,N+1) {
        ll sr = 0, sl = 0;
        REP(j,0,K) {
            if(i - L[j] >= 0) sl = (sl + sum[i-L[j]]) % MOD;
            if(i - R[j] - 1 >= 0) sr = (sr + sum[i-R[j]-1]) % MOD;
        }
        dp[i] = (sl - sr + MOD) % MOD;
        sum[i] = (sum[i-1] + dp[i]) % MOD;
    }
    PR(dp[N]);

    return 0;
}

/*



*/

Measured memory_bytes: 6420
#!/usr/bin/env python3
from sys import stdin
from collections import defaultdict
from math import gcd

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    MOD = 1000000007
    
    N, *AB = map(int, stdin.buffer.read().split())
    d = defaultdict(int)
    zeros = 0
    for a, b in zip(AB[::2], AB[1::2]):
        if a == 0 and b == 0:
            zeros += 1
        else:
            g = gcd(a, b)
            a //= g
            b //= g
            if a < 0:
                a *= -1
                b *= -1
            if a == 0 and b == -1:
                b = 1
            d[(a, b)] += 1
        
    ans = 1
    free = 0
    for (a, b), n in d.items():
        if b > 0:
            if (b, -a) in d:
                m = d[(b, -a)]
                ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD
            else:
                free += n
        else:
            if (-b, a) not in d:
                free += n

    ans = (ans * pow(2, free, MOD) + zeros - 1) % MOD
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77296
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    string S; cin >> S; bool can=true;
    sort(S.begin()+1,S.end());
    rep(i,9){
    if(binary_search(S.begin()+1,S.end(),(char)'0'+i))
    {can = false; break;}
    }
    int ans=(int)(S[0]-'0')+(S.size()-1)*9;
    if(can) cout << ans << endl;
    else cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int N = 200000 + 7;

int n;
int a[N];

int check(int x) {
	static int pos[N], chr[N], top;

	auto split = [&](int p) {
		while (top && pos[top] >= p) --top;
		int c = chr[top + 1];
		if (pos[top] < p - 1) pos[++top] = p - 1, chr[top] = c;
		pos[++top] = p, chr[top] = c;
	};
	pos[top = 1] = a[1], chr[1] = 1;
	for (int i = 2; i <= n; ++i)
		if (a[i] > a[i - 1])
			pos[++top] = a[i], chr[top] = 1;
		else {
			split(a[i]);	
			while (top && chr[top] == x) --top;
			if (!top) return 0;
			split(pos[top]), ++chr[top];
			if (pos[top] < a[i]) pos[++top] = a[i], chr[top] = 1;
		}
	return 1;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	int l = 1, r = n, m;
	while (l < r)
		check(m = l + r >> 1) ? (r = m) : (l = m + 1);
	printf("%d", r);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1ll << 60;

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

  vector<vector<long long>> dp(n + 1, vector<long long>(h + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= h; ++j) {
      chmin(dp[i + 1][j], dp[i][j]);
      chmin(dp[i + 1][min(j + a[i], h)], dp[i + 1][j] + b[i]);
    }
  }
  cout << dp[n][h] << endl;
}

Measured memory_bytes: 78592
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e5 + 5;

int N, M;
int deg[MAXN];

void input()
{
    read(N); read(M);
    for (int i = 1; i <= M; ++i) {
        int u, v;
        read(u); read(v);
        ++deg[u]; ++deg[v];
    }
}

void solve()
{
    for (int i = 1; i <= N; ++i) {
        if (deg[i] & 1) {
            puts("NO");
            return;
        }
    }
    puts("YES");
}

int main()
{
#ifdef __DEBUG
    freopen("B.in", "r", stdin);
    freopen("B.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 谁料同心结不成，翻就相思结。
//     -- 夏完淳《卜算子·秋色到空闺》


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 1000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n-1)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
void solve()
{
    int n,i,j;
    cin>>n;
    int arr[n][3];
    rep(i,n)
    rep(j,3)
    cin>>arr[i][j];
    int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    rep1(i,n)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]) );
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


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

public class Main {
	int num = -1;
	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = new char[s.length()];
		c = s.toCharArray();
		String t = sc.next();
		char[] t2 = new char[t.length()];
		t2 = t.toCharArray();
		
		for(int i = s.length()-t.length(); i >= 0; i--) {
			for(int j = 0; j < t.length(); j++) {
				if(c[i+j] != t2[j] && c[i+j] !='?')break;
				
				if(j == t.length()-1) {
					for(int k = i; k < i+t.length(); k++) {
						c[k] = t2[k-i];
					}
					for(int l = 0; l < s.length(); l++) {
						if(c[l] == '?') c[l] = 'a';
					}
					String ans = new String(c);
					System.out.println(ans);
					return;
				}
			}
		}
		System.out.println("UNRESTORABLE");
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
count = [0,0,0]
for i in range(N):
    A[i] = A[i] % 4
    if A[i] == 0:
        count[0] += 1
    elif A[i] == 2:
        count[1] += 1
    else:
        count[2] += 1
#print(count)
if count[1] == 0:
    if count[2] <= count[0] + 1:
        print("Yes")
    else:
        print("No")
else:
    if count[2] <= count[0]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;



int main()
{
    string w;
    int cnt = 0;
    bool flag = true;
    char R[2] = "R";
    char S[2] = "S";

    cin >> w;
   
    for (int i = 0; i < 3; i++) {
        if (w[i] == R[0]) {
            cnt++;
            flag = false;
        }

        else if (w[i] == S[0] && flag == false && i < 2) {

            cout << 1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;

    

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    vector<int>colors(h*w);
    int num = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<a[i];j++){
            colors[num] = i+1;
            num++;
        }
    }
    for(int i=0;i<h;i++){
        
        for(int j=0;j<w;j++){
            int ww = j;
            if(i%2==0)ww = w-j-1;
            cout<<colors[i*w+ww]<<" ";

        }
        cout<<endl;
    }
    
}

Measured memory_bytes: 3664
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete


main = do
    n <- getInt
    a <- getInt
    putStrLn $ cond "Yes" "No" $ (n `mod` 500) <= a

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B && A != C) {
    printf("Yes\n");
  } else if (A == C && A != B) {
    printf("Yes\n");
  } else if (B == C && B != A) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


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

int main() {
  int n;
  cin >> n;
  string s;
  int ans = 0;
  cin >> s;
  for(int i = 1; i < n; i++){
    int cnt = 0;
    for(char c = 'a'; c <= 'z'; c++){
      bool left = false;
      bool right = false;
      for(int j = 0; j < i; j++){
        if(s.at(j) == c) left = true;
      }
      for(int j = i; j < n; j++){
        if(s.at(j) == c) right = true;
      }
      if(left && right) cnt++;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int x[200][200],y[200],z[200],n,i,a,j,k,b,s,c;
int main(){
	while(true){
		cin>>n;b=0;
		if(!n){break;}
		for(i=1;i<=n;i++){
			cin>>z[i];
			for(j=0;j<z[i];j++){
				cin>>x[i][j];
			}
		}
		cin>>a;
		for(i=0;i<a;i++){cin>>y[i];}
		for(i=1;i<=n;i++){
			s=0;
			for(j=0;j<a;j++){
				for(k=0;k<z[i];k++){
					if(x[i][k]==y[j]){
						s++;
					}
				}
			}
			if(s==a){c=i;b++;}
		}
		if(b-1){c=-1;}
		cout<<c<<endl;
	}
}

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


int main(){
    int N, T, X, n;
    int ans = 0;
    std::cin >> N >> X >> T;

    if(N%X !=0 ){
        n = (N-N%X)/X + 1;
    }else{
        n = N/X;
    }
    ans = n * T;

    std::cout << ans;
}


Measured memory_bytes: 3612