akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <math.h>

 
int sub(int);
 
int main()
{
int s,i,c,k,n[10000];

k=0;

scanf("%d",&s);

for(i = 0;i<s;i++){
 scanf("%d", &n[i]);
  }
 
for(i = 0;i < s;i++){
    c = sub(n[i]);
    if(c == 1) k++;
  }
   
printf("%d\n", k);
   
  return 0;
}
 
int sub(int x)
{
int j;
 
if(x == 2) return 1;
else if(x < 2 || x % 2 == 0) return 2;
else{
    j = 3;
    while(j <= sqrt(x)){
      if(x % j == 0) return 2;
      j = j + 2;
    }
  }
  return 1;
}


Measured memory_bytes: 2064
import numpy as np

def main(Z, D):
    lengthes = np.linalg.norm(Z, axis=1)
    ans = np.sum(lengthes<=D)
    return ans

if __name__ == '__main__':
    N, D = map(int, input().split())
    Z = np.zeros([N, 2])
    for i in range(N):
        X, Y = map(int, input().split())
        Z[i][0] = X
        Z[i][1] = Y
    #print(Z)
    ans = main(Z, D)
    print(ans)



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

#define fr(i, a, b) for (long long i = a; i < b; ++i)
#define fr2(i, b, a) for (long long i = b; i >= a; --i)
#define pb push_back

#define set0(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))
#define setinf(a) memset(a, 126, sizeof(a))
#define trace(a) cerr << #a << ": " << a << endl

#define N 1000000007
#define PI acos(-1.0)

typedef vector<long long> vll;
typedef vector<pair<long long, long long>> vllp;
typedef pair<long long, long long> llp;
typedef long long int ll;
typedef unsigned long long ull;

ll Npow(ll x, ll n, ll M = 1000000007)
{
	if (n == 0)
		return 1;
	else if (n % 2 == 0)
		return Npow((x * x) % M, n / 2, M);
	return (x * Npow((x * x) % M, (n - 1) / 2, M)) % M;
}
void print()
{
	;
}
template <typename T, typename... Types>
void print(T var1, Types... var2)
{
	cout << var1 << " ";
	print(var2...);
}

template <typename T>
void show(T *a, int size)
{
	int i;
	cout << endl
		 << "The array is ";
	fr(i, 0, size)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

template <typename T>
void show_vector(vector<T> v)
{
	cout << endl
		 << "The vector is ";
	int i;
	fr(i, 0, v.size())
	{
		cout << v[i] << " ";
	}
	cout << endl;
}
//GLOBAL
#define M 1000
//FUNCTIONS

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, m, num;
	cin >> n >> m >> num;
	if (n > m)
	{
		cout << ceil(1.0*num / n);
	}
	else
	{
		cout << ceil(1.0*num / m);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    cout << max(A + B, max(A - B, A * B)) << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int i,a,b;
    cin>>a>>b;
    string stra,strb;
    for(i=0;i<a;i++)
    stra.push_back(b+48);
    for(i=0;i<b;i++)
    strb.push_back(a+48);
    vector<string>str;
    str.push_back(stra);
    str.push_back(strb);
    sort(str.begin(),str.end());
    cout<<str[0]<<endl;
    return 0;
}





Measured memory_bytes: 3596
function main()
  
  S = chomp(readline())
  
  check = false
  
  for i in 1:length(S)-1
    if S[i] == 'A' && S[i+1] == 'C'
      check = true
      break
    end
  end
  
  if check
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 108040
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, r = 0;
    cin >> n >> m;
    int oh[n + 1];
    vector<bool> o(n + 1, true);

    for (int i = 1; i <= n; ++i)
        cin >> oh[i];
    
    while (m--) {
        int o1, o2;
        cin >> o1 >> o2;
        if (oh[o1] < oh[o2]) o[o1] = false;
        else if (oh[o1] == oh[o2]) o[o1] = o[o2] = false;
        else o[o2] = false;
    }

    for (vector<bool>::iterator it = o.begin() + 1; it < o.end(); ++it)
        r += *it;

    cout << r;

    return 0;
}


Measured memory_bytes: 3528
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 1e6+1;
const ll inf = 1e8;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pwr(x, MOD-2);
}

void solve()
{
    int l, r; cin>>l>>r;
    int MOD = 2019;
    if(r-l>=MOD)
        cout<<0;
    else{
        int ans = r*(r-1);
        for(int i=l;i<=r;i++)
        {
            for(int j=i+1;j<=r;j++)
            {
                ans = min(ans, (i*j)%MOD);
            }
        }
        cout<<ans;
    }

}

signed main()
{
// #ifndef ONLINE_JUDGE
//     freopen("ladders_and_snakes_sample_input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    
    int t=1;
    // cin >>t;
    for(int tt=1;tt<=t;tt++){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    int t = a * b;
    if(t&1)
        cout << "Odd" << endl;
    else
        cout << "Even" << endl;
    return 0;
}

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

cnt = 0
for i in range(N):
    if A[i] < 0:
        A[i] = -A[i]
        cnt+=1

if cnt%2==0:
    print(sum(A))

else:
    a = min(A)
    print(sum(A)-2*a)


Measured memory_bytes: 14412
# -*- coding: utf-8 -*-

from queue import Queue
import sys
import subprocess
import json
import time
import math
import re
#import sqlite3
import random
import numpy as np
#from sklearn.datasets import fetch_mldata
from statistics import mean, median, variance, stdev
#from chainer import cuda, Variable, FunctionSet, optimizers
#import chainer.functions  as F

def ans():
    remain = X - Y - 2 * Z
    if (remain < 0): return 0
    res = 1
    while (remain >= Y + Z):
        remain -= Y + Z
        res += 1
    return res
    

X, Y, Z = map(int, input().split())
print(ans())


Measured memory_bytes: 23964
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int main(){
      int w,h,n,solve=0,dx[]={0,1,-1,0},dy[]={1,0,0,-1};
      P cheese[9];
      cin>>h>>w>>n;
      char d[h][w];
      int dis[h][w];
      for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                  cin>>d[i][j];
                  if('1'<=d[i][j]&&'9'>=d[i][j])
                        cheese[d[i][j]-'0'] = make_pair(i,j);
                  else if(d[i][j]=='S')
                        cheese[0] = make_pair(i,j);
            }
      }
      for(int i=0;i<n;i++){
            queue<P> que;
            for(int a=0;a<h;a++)for(int b=0;b<w;b++)dis[a][b]=-1;
            dis[cheese[i].first][cheese[i].second]=0;
            que.push(cheese[i]);
            while(!que.empty()){
                  P p = que.front();que.pop();
                  if(p == cheese[i+1]){
                        solve += dis[p.first][p.second];break;
                  }
                  for(int j = 0;j < 4;j++){
                        int nx = p.first + dx[j],ny = p.second+ dy[j];
                        if(0<=nx&&nx<h&&0<=ny&&ny<w&&d[nx][ny]!='X'&&dis[nx][ny]==-1){
                              dis[nx][ny] = dis[p.first][p.second]+1;
                              que.push(make_pair(nx,ny));
                        }

                  }
            }
      }
      cout << solve << endl;
}

Measured memory_bytes: 6096
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 3e5;
ll fac[MAX_N+1], ifac[MAX_N+1];

//comb(n, k)でnCk
ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

//perm(n, k)でnPk
ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

//mpow(x,n)で(x^n)をO(log(n))で計算
ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n%2 == 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n /= 2;
    }
    return res;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    ll ans = mpow(2, N);
    //1〜MAX_Nまでのmod(MOD)における逆元
    ll inv[MAX_N+1];
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
    ll a = 1, b = 1;
    rep(i, A){
        a *= (N-i);
        a %= MOD;
    }
    rep(i, B){
        b *= (N-i);
        b %= MOD;
    }
    a *= ifac[A], a %= MOD;
    b *= ifac[B], b %= MOD;
    ans += (MOD-a)+(MOD-b)+(MOD-1);
    cout << ans%MOD << endl;
}

Measured memory_bytes: 7296
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

digits = len(format(K, "b"))
bits_list = [((A >> shift) & 1).sum() for shift in range(digits)]
bits_list.reverse()

X = 0
half = (N + 1) // 2
digit = 1 << (len(format(K, "b")) - 1)

for bits in bits_list:
    if bits < half and (X | digit) <= K:
        A ^= digit
        X |= digit
    digit >>= 1

print(A.sum())


Measured memory_bytes: 26016
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
x = int(input())
L = make_divisors(x)
for i in L:
    for a in range(-118,120):
        if a**5 - (a-i)**5 == x:
            print('{} {}'.format(a,a-i))
            break
    else:
        continue
    break

Measured memory_bytes: 9344
#include<iostream>
#include<iomanip>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
#include <functional>
#include <cassert>
typedef long long int ll;
using namespace std;

int main(){
	int N,X,Y,n;
	cin>>N>>X>>Y;
	vector<int>A(N,0);
	for(int i=1;i<=N-1;i++){
		for(int j=i+1;j<=N;j++){
			n=min(abs(j-i),abs(X-i)+1+abs(j-Y));
			n=min(n,abs(Y-i)+1+abs(j-X));
			A[n-1]++;
		}
	}
	for(int i=0;i<N-1;i++){
		cout<<A[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
breakstep = [True]*(N+1)
for _ in range(M):
    breakstep[int(input())] = False
#a = [breakstep[int(input())] for _ in range(M)]
dp = [0]*(N+1)

for i in range(N+1):
    if i == 0:
        dp[0] = 1
    elif i == 1:
        if breakstep[i]:
            dp[1] = 1
    else:
        if breakstep[i]:
            dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%1000000007)

Measured memory_bytes: 470520
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>t;
cout<<pow(t,2)<<endl;

    }



Measured memory_bytes: 3828
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;



int main(){
	int64_t n;
	cin>>n;
	if(n==3){
		cout<<"2 5 63"<<endl;
	}else{
		int32_t loop=n/8;
		for(int32_t i1=0;i1<loop;i1++){
			cout<<12*i1+2<<" "<<12*i1+3<<" "<<12*i1+4<<" "<<12*i1+6<<" "<<12*i1+8<<" "<<12*i1+9<<" "<<12*i1+10<<" "<<12*i1+12<<" ";
		}
		switch(n%8){
		case 1:
			cout<<12*loop+6<<endl;
			break;
		case 2:
			cout<<12*loop+2<<" "<<12*loop+4<<endl;
			break;
		case 3:
			cout<<12*loop+2<<" "<<12*loop+4<<" "<<12*loop+6<<endl;
			break;
		case 4:
			cout<<12*loop+2<<" "<<12*loop+3<<" "<<12*loop+4<<" "<<12*loop+9<<endl;
			break;
		case 5:
			cout<<12*loop+2<<" "<<12*loop+3<<" "<<12*loop+4<<" "<<12*loop+6<<" "<<12*loop+9<<endl;
			break;
		case 6:
			cout<<12*loop+2<<" "<<12*loop+3<<" "<<12*loop+4<<" "<<12*loop+6<<" "<<12*loop+9<<" "<<12*loop+12<<endl;
			break;
		case 7:
			cout<<12*loop+2<<" "<<12*loop+3<<" "<<12*loop+4<<" "<<12*loop+8<<" "<<12*loop+9<<" "<<12*loop+10<<" "<<12*loop+12<<endl;
			break;

		}
	}

	return 0;
}



Measured memory_bytes: 384
// -*- coding:utf-8-unix -*-

use proconio::input;

fn a(l1: i32, l2: i32, l3: i32) -> bool {
    l1 != l2 && l2 != l3
}

fn b(l1: i32, l2: i32, l3: i32) -> bool {
    l1 + l2 > l3
}

fn main() {
    input! {
        n: usize,
        l: [i32; n],
    }
    let mut l: Vec<i32> = l;
    l.sort();

    let count = (0..n)
        .map(|n1| {
            (n1..n)
                .map(|n2| {
                    (n2..n)
                        .filter(|&n3| a(l[n1], l[n2], l[n3]) && b(l[n1], l[n2], l[n3]))
                        .count() as i32
                })
                .sum::<i32>()
        })
        .sum::<i32>();

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


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

int main()
{
  int H, W;
  cin >> H >> W;
  char s[H][W];
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      cin >> s[i][j];
    }
  }

  bool res = true;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      char target = s[i][j];
      if (target == '#')
      {
        int prev_H = i - 1;
        int prev_W = j - 1;
        int next_H = i + 1;
        int next_W = j + 1;
        if (prev_H >= 0)
        {
          if (s[prev_H][j] == '#')
          {
            continue;
          }
        }
        if (prev_W >= 0)
        {
          if (s[i][prev_W] == '#')
          {
            continue;
          }
        }
        if (next_H < H)
        {
          if (s[next_H][j] == '#')
          {
            continue;
          }
        }
        if (next_W < W)
        {
          if (s[i][next_W] == '#')
          {
            continue;
          }
        }
        res = false;
        break;
      }
    }
    if (!res)
    {
      break;
    }
  }
  if (res)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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


int main() {
    int h, w, k, ans = 0,cnt=0;
    cin >> h >> w >> k;
    vector<string> c(h),tmp(h);
    for (int i = 0; i < h; i++)cin >> c.at(i);

    for (int hbit = 0; hbit < (1 << h); hbit++) {
        for (int wbit = 0; wbit < (1 << w); wbit++) {
            tmp = c;
            cnt = 0;
            for (int j = 0; j < w; j++) {
                for (int i = 0; i < h; i++) {
                    if (hbit&(1 << i)) {
                        replace(tmp.at(i).begin(), tmp.at(i).end(), '#', 'r');
                    }
                   if (wbit&(1 << j))tmp.at(i).at(j)='r';
                }
            }
            for (int i = 0; i < h; i++)cnt += count(tmp.at(i).begin(), tmp.at(i).end(), '#');
            if (cnt == k) {
                ans++;
            }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;

    int tuuka = 0;
    int brank = 1;
    REP(i,N) {
        if (S[i] == 'a') {
            if (tuuka < A+B) {
                tuuka++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
            continue;
        }
        if (S[i] == 'b') {
            if ((tuuka < A+B) && (brank <= B)) {
                brank++;
                tuuka++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
            continue;
        }
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 3632
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    aset = list(set(A))

    memo = [0] * (10 ** 6 + 1)

    for a in aset:
        for i in range(2, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            memo[a * i] += 1

    ans = 0
    c = collections.Counter(A)
    for a in A:
        # 同じ数が入っていた場合もカウントしない
        if memo[a] == 0 and c[a] == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S)
{
    if (S == "AAA" || S == "BBB")
    {
        cout << NO << endl;
    }
    else
    {
        cout << YES << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;

int main() 
{
	string s;
	cin>>s;
	int count=1;
	int flag=0;
	for(int i=1;i<3;i++)
	{
		if(s[i-1]=='R'&&s[i]=='R') count++;
		if(s[i-1]=='R'||s[i]=='R') flag=1;
	}
	if(flag)
	{
		cout<<count<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	return 0;
}



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

int main() {
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	int num = 0;
	string value;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> value;
		if (value == "AC") {
			ac++;
		}
		else if (value == "TLE") {
			tle++;
		}
		else if (value == "WA") {
			wa++;
		}
		else if (value == "RE") {
			re++;
		}
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

return 0;
}

Measured memory_bytes: 3608
from collections import Counter
N, P = map(int,input().split())
S = input()

'''
N, P  = 10, 7
S = '1234567890'
tans = 0
for i in range(N):
    for j in range(i+1,N+1):
        t = int(S[i:j])
        tans += ((t % P) == 0)
print(tans)
'''

S = list(map(int,S))

ans = 0
if P == 2:
    for i,s in enumerate(S):
        if s % 2 == 0:
            ans += i + 1
elif P == 5:
    for i,s in enumerate(S):
        if s % 5 == 0:
            ans += i + 1
else:
    res = []
    n = 0
    k = 1
    for s in S[::-1]:
        n = (s * k + n) % P
        k = (k * 10) % P
        res.append(n)

    res.append(0) # right
    #print(N,P,S)
    #print(res)

    cnts = Counter(res)
    for ind, cnt in cnts.items():
        if cnt == 1:
            continue
        ans += cnt * (cnt - 1) // 2

print(ans)

    



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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

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

V v[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    rep(i,0,n){
    	ll x,y;
    	cin>>x>>y;
    	if(x<=m){
    		v[x-1].pb(y);
    	}
    }
    ll ans=0;
    priority_queue<ll> q;
    rep(i,0,m){
    	rep(j,0,v[i].size())	q.push(v[i][j]);
    	if(!q.empty()){
    		ans += q.top();
    		q.pop();
    	}	
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b; a--; b--;
    cout<<"100 100\n";
    rep(i,100){
        rep(j,100){
            if (i<50){
                if (!(i&1) && !(j&1) && a>0){
                    cout<<'.';
                    a--;
                }else{
                    cout<<'#';
                }
            }else{
                if (i&1 && j&1 && b>0){
                    cout<<'#';
                    b--;
                }else{
                    cout<<'.';
                }
            }
        }
        cout<<"\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 repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0,m=0;
  std::cin >> x>>y;
  int v[x];
  int w[x];
  int dp[x+1][y+1];
  rep(i,x)std::cin >> v[i]>>w[i];
  rep(i,y+1)dp[0][i]=0;
  rep(i,x){
    Rep(j,y+1){
      if(j>=w[i])dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j]);
      else dp[i+1][j] = dp[i][j];
    }
  }
  std::cout << dp[x][y] << '\n';
}



Measured memory_bytes: 10972
while True:
  H, W = map(int, input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    if i == 0 or i%2 == 0:
      for j in range(W):
        if j == 0 or j%2 == 0:
          print("#",end="")
        else:
          print(".",end="")
      print()#改行
    else:
      for j in range(W):
        if j == 0 or j%2 == 0:
          print(".",end="")
        else:
          print("#",end="")
      print()#改行
  print()


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

typedef long long ll;


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

int main(void){
    double n,a,b;
    cin >> n >> a >> b;
    double sub = (a-b)*1000/6;
    double sa = INT_MAX;
    int ans = 0;
    rep(i,n){
        double num;
        cin >> num;
        double sa2 = abs(num-sub);
        if(sa2 < sa){
            ans = i+1;
            sa = sa2;
        }
    }
    cout << ans <<endl;
    return 0;
}

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

char c;

int main()
{
    cin>>c;
    string s="aeiou";
    for (int i=0; i<5; i++) {
        if (c==s.at(i)) {
            cout<<"vowel";
            return 0;
        }
    }
    cout<<"consonant";
    return 0;
}


Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

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

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    println!("{}", n * (n - 1) / 2 + m * (m - 1) / 2);
}


Measured memory_bytes: 4352
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    string s, t;
    cin >> s >> t;

    int x;
    for (x = s.size() - t.size();; --x) {
        if (x < 0) {
            cout << "UNRESTORABLE\n";
            return 0;
        }

        bool flag = true;
        rep(i, t.size()) flag &= s[x + i] == '?' || s[x + i] == t[i];
        if (flag) break;
    }

    rep(i, s.size()) {
        if (i < x) cout << (s[i] == '?' ? 'a' : s[i]);
        else if (i < x + t.size()) cout << t[i - x];
        else cout << (s[i] == '?' ? 'a' : s[i]);
    }
    cout << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
char a[4],b[4],c[4];
 scanf ("%s",a);
 scanf ("%s",b);
 scanf ("%s",c);
//  printf ("%s%s%s",a[1],b[2],c[3]);
 printf ("%c%c%c",a[0],b[1],c[2]);
  return 0;
}


Measured memory_bytes: 128
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
ll n;
cin>>n;
string s[200010];
rep(i,0,n)cin>>s[i];
map<string,ll>mp;
rep(i,0,n) mp[s[i]]++;
ll r=0;
for(auto &e:mp) r=max(r,e.second);
vector<string> v;
for(auto &e: mp){
if(e.second==r) v.push_back(e.first);
}
sort(v.begin(),v.end());
for(auto &e:v)print(e);

}


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

int main() {
    
    string S;
    int n;
    cin>>S>>n;
    for(int i=0;i<n;i++){
        string Q;
        int a,b;
        cin>>Q>>a>>b;
        if(Q=="print"){
            cout<<S.substr(a,b-a+1)<<endl;
        }
        if(Q=="reverse"){
            string D=S.substr(a,b-a+1);
            reverse(D.begin(),D.end());
            S=S.replace(a,b-a+1,D);
        }
        if(Q=="replace"){
            string c;
            cin>>c;
            S=S.replace(a,b-a+1,c);
        }
    }
}



Measured memory_bytes: 3216
# coding: utf-8
import math
while True:
    n = int(input())
    
    if n == 0:
        break
    
    fn = math.factorial(n)
    
    z_c = 0
    
    for i in str(fn)[::-1]:
        if i != "0":
            break
        else:
            z_c += 1
    
    print(z_c)

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

int a, b, c;

int main(){
  cin >> a >> b >> c;
  int high = max(a, max(b, c));
  int low = min(a, min(b, c));
  int mid = a + b + c - high - low;
  int num1 = high - mid; //sousa1nokaisuu
  int num2 = (high - low - num1) / 2;//sousa2nokaisuu
  int num3 = (high - low - num1) % 2;//saigo
  num3 *= 2;
  cerr <<num1 <<" "<<num2<<" "<<num3<<endl;
  cout << num1 + num2 + num3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string sa,sb;
	getline(cin,sa);
	getline(cin,sb);
	int i,la=sa.size(),chk=0;
	for(i=0;i<la;i++){
		if(sa[i]==sb[i]) chk++;
	}
	cout<<chk;
	return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
lr_array = [[int(x) for x in input().split()] for y in range(m)]
pq_array = [[int(x) for x in input().split()] for y in range(q)]


def solve1():
    table = [[0 for x in range(n + 1)] for y in range(n + 1)]
    for l, r in lr_array:
        table[l][r] += 1
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            table[i][j] = table[i][j - 1] + table[i][j]
    for p, q in pq_array:
        res = 0
        for i in range(p, q + 1):
            # print(i)
            res += table[i][q]
        print(res)

    return 0


# 横軸：スタート
# 縦軸：ゴール
# 2次元累積和で解く
def solve2():
    cumulative_lr = [[0 for x in range(n + 1)] for y in range(n + 1)]
    for l, r in lr_array:
        for i in range(1, l + 1):
            for j in range(r, n + 1):
                cumulative_lr[i][j] += 1

    for p, q in pq_array:
        print(cumulative_lr[p][q])


if __name__ == '__main__':
    solve1()


Measured memory_bytes: 108888
#include<stdio.h>
int main()
{
    long long n,i,sum=0;
    scanf("%lld",&n);

        for(i=1;i<=n;i++)
        {
             if(i%3!=0&&i%5!=0&&i%15!=0)
             {sum=sum+i;}
        }

    printf("%lld",sum);
}

Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int l=s.size();
    bool n=false,e=false,so=false,w=false;
    for(int i=0;i<l;i++){
        if(s[i]=='N')n=true;
        if(s[i]=='E')e=true;
        if(s[i]=='S')so=true;
        if(s[i]=='W')w=true;
    }
    if(n!=so||e!=w)puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
long long a[100000+10];
main()
{
    long long n,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	long long maxl=a[0];
	for(i=1;i<n;i++)
	{
		maxl=max(a[i],maxl);
		if(maxl-a[i]>1)
		{
			cout<<"No";
		    return 0;
		}
		
	}
	cout<<"Yes";
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  int R; cin >> R;
  if (R < 1200) {
	cout << "ABC";
  }
  else if (R < 2800) {
	cout << "ARC";
  }
  else {
	cout << "AGC";
  }

  return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
D=sorted(list(map(int,input().split())))
ans=0
L=[i for i in range(10) if i not in D]

for i in range(N,10*N+1):
    I=[int(j) for j in list(str(i))]
    cnt=0
    
    for j in I:
        if j not in L:
            break
        else:
            cnt+=1
    if cnt==len(I):
        ans=i
        break

print(ans)


Measured memory_bytes: 41436
def popcount(u):
    t = bin(u)
    h = t.count("1")
    return u % h 

n = int(input())
x = list(input())
c = x.count("1") + 1
d = c - 2

amaric = [1 % c]
if d >= 1:
    amarid = [1 % d]
for i in range(n-1):
    amaric.append((amaric[-1]*2)%c)
    if d >= 1:
        amarid.append((amarid[-1]*2)%d)

motoc = 0
motod = 0
for i in range(n):
    if x[i] == "1":
        motoc += amaric[n-1-i]
        if d >= 1:
            motod += amarid[n-1-i]

for i in range(n):
    if x[i] == "0":
        op = motoc
        op += amaric[n-1-i]
        op %= c
    elif x[i] == "1":
        if d >= 1:
            op = motod
            op -= amarid[n-1-i]
            op %= d
        elif d == 0:
            print(0)
            continue
    cou = 1
    while True:
        if op == 0:
            break
        op = popcount(op)
        cou += 1
    print(cou)

Measured memory_bytes: 26536
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 0x7fffffffffffffff;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    ll k, n, x[55], y[55];

    cin >> n >> k;
    REP(i, n){
        cin >> x[i] >> y[i];
    }

    ll ans = INF;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < n; j++){
            for(ll l = 0; l < n; l++){
                for(ll m = 0; m < n; m++){
                    ll left, right, up, down;

                    left = min(x[i], x[j]);
                    right = max(x[i], x[j]);
                    up = max(y[l], y[m]);
                    down = min(y[l], y[m]);

                    ll sum = 0;
                    for(ll o = 0; o < n; o++){
                        if(    left <= x[o] && x[o] <= right
                            && down <= y[o] && y[o] <= up   ){
                                sum++;
                        }
                    }

                    if(sum >= k){
                        ans = min(ans, abs(right - left) * abs(up - down));
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
# coding: utf-8
# Your code here!

s = input().rstrip()

front = s[:2]
back = s[2:4]

isyymm = True if (0 <= int(front) <= 99 and 1 <= int(back) <= 12) else False
ismmyy = True if (0 <= int(back) <= 99 and 1 <= int(front) <= 12) else False

if isyymm and (not ismmyy):
    print("YYMM")
elif (not isyymm) and ismmyy:
    print("MMYY")
elif isyymm and ismmyy:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var dp = new int[3];
        for (int i = 0; i < N; i++)
        {
            int a = Math.Max(dp[1], dp[2]) + cin.nextint;
            int b = Math.Max(dp[0], dp[2]) + cin.nextint;
            int c = Math.Max(dp[0], dp[1]) + cin.nextint;

            dp[0] = a;
            dp[1] = b;
            dp[2] = c;
        }
        WriteLine(dp.Max());
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 15416
from collections import deque
n,m=map(int,input().split())

r = [[] for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  r[a].append(b)
  r[b].append(a)

d = deque([0])
ans = [-1]*n
ans[0]=0
while d:
  p=d.popleft()
  for v in r[p]:
    if ans[v]!=-1: continue
    ans[v]=p
    d.append(v)
if -1 in ans:
  print('No')
  exit()
else:
  print('Yes')
  for v in ans[1:]:
    print(v+1)    

Measured memory_bytes: 34772
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll ma,mi,t;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&t);
		if(i == 0)
			ma = mi = t;
		else
		{
			ma = max(ma,t);
			mi = min(mi,t);
		}
	}
	printf("%lld\n",ma-mi);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    if (A[0] == A[1] && A[1] != A[2]) cout << "Yes" << endl;
    else if (A[1] == A[2] && A[0] != A[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    ll n;
    cin >> n;
    ll x = n;
    ll y = 0;
    while (x > 0)
    {
        y += x % 10;
        x /= 10;
    }
    if (n % y == 0)
    {
        c("Yes");
    }
    else
    {
        c("No");
    }
    ed;
    return 0;
}

Measured memory_bytes: 256