akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    vector<int> queries;
    int q_max = 0;
    while(1){
        int q;
        cin >> q;
        if(q == 0) break;
        queries.push_back(q);
        q_max = max(q_max, q);
    }

    int num = 0;
    vector<int> tetra;
    int x = 1;
    while(num <= q_max){
        num = x * (x+1) * (x+2) / 6;
        tetra.push_back(num);
        ++x;
    }

    int m = tetra.size();

    const int INF = 1001001001;
    vector<vector<int>> dp(2, vector<int>(q_max+1, INF)); // 0: all, 1: odd only
    dp[0][0] = 0;
    dp[1][0] = 0;
    rep1(i, q_max+1){
        rep(j, m){
            if(tetra[j] > i) break;
            dp[0][i] = min(dp[0][i], dp[0][i-tetra[j]] + 1);
            if(tetra[j]%2 == 1) dp[1][i] = min(dp[1][i], dp[1][i-tetra[j]] + 1);
        }
    }

    rep(i, queries.size()) cout << dp[0][queries[i]] << " " << dp[1][queries[i]] << endl;

    return 0;
}


Measured memory_bytes: 14024
using System;
using System.Collections.Generic;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {

            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            var S = vals[0];
            var W = vals[1];
            string ans = (W >= S) ? "unsafe" : "safe";
            Console.WriteLine(ans);


        }
       
       

    }
}


Measured memory_bytes: 19060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 10000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buff[20],len; len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buff[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buff[--len]+'0');
}
inline void writeln(ll x)
{
	write(x); putchar('\n');
}
inline void writesp(ll x)
{
	write(x); putchar(' ');
}
int a[4];
int main()
{
	for(int i=1;i<=4;i++)
		a[i]=read();
	std::sort(a+1,a+5);
	if(a[1]==1&&a[2]==4&&a[3]==7&&a[4]==9)printf("YES\n");
	else printf("NO\n");
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second

const int maxn = 2e5 + 5;
const long long oo = 1e18;

int n;
long long a[maxn];
long long s[maxn];

pair<long long, long long> get(int l, int r) {
  int L = l, R = r;
  if (l > r) return mp(oo, oo);
  int found = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    long long t1 = s[mid] - (L ? s[L - 1] : 0); // l -> mid
    long long t2 = s[R] - s[mid]; // mid + 1 -> r
    if (t1 >= t2) {
      found = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }

  assert(~found);

  long long t1 = s[found] - (L ? s[L - 1] : 0);
  long long t2 = s[R] - s[found];
  if (t1 > t2) swap(t1, t2);

  if (found - 1 >= L) {
    found--;
    long long t3 = s[found] - (L ? s[L - 1] : 0);
    long long t4 = s[R] - s[found];
    if (t3 > t4) swap(t3, t4);
    if (t3 > t1) {
      t1 = t3;
      t2 = t4;
    }
  }

  return mp(t1, t2);
}

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) cin >> a[i];

  s[0] = a[0];
  for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];

  long long ans = 1e18;
  for (int i = 1; i < n - 2; i++) {
    auto v1 = get(0, i);
    auto v2 = get(i + 1, n - 1);
//    cout << i << ' ' << v1.fi << ' ' << v1.se << ' ' << v2.fi << ' ' << v2.se << endl;
    long long hi = max(v1.se, v2.se);
    long long lo = min(v1.fi, v2.fi);
    ans = min(ans, hi - lo);
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include <algorithm>
#include <vector>
#define INF (1<<30)
using namespace std;
int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<vector<int>> ans(H, vector<int>(W, INF));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W;j++) {
			char c; cin >> c;
			if (c == 'c') {
				ans[i][j] = 0;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W;j++) {

			if (ans[i][j] == 0) {

				for (int k = j + 1; k < W;k++) {
					ans[i][k] = min(ans[i][k], ans[i][k - 1] + 1);
				}

			}

		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W;j++) {
			if (ans[i][j] == INF) {
				cout << -1;
			}else{
				cout << ans[i][j];
			}
			if (j != W - 1)cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3148
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

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

	int A, B, X;
	cin >> A >> B >> X;

	if (A + B >= X && A <= X) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IL inline
#define _ 1000005
#define ll long long
#define ld long double
using namespace std ; 

IL ll gi(){
	ll data = 0 , m = 1; char ch = 0 ; 
	while((ch != '-') && (ch < '0' || ch > '9')) ch = getchar() ; 
	if(ch == '-'){m = 0 ; ch = getchar() ; }
	while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar() ; }
	return (m) ? data : -data ; 
}

int n , m , z , Q , MOD , g , mod ; 
int U[_] , V[_] , C[_] , dsu[7 * _] , ok[2][_] ; 

IL int Find(int x) {return dsu[x] ^ x ? dsu[x] = Find(dsu[x]) : x ; }
IL int ID(int u,int q,int p){return u + n * (q * 3 + p) ; }

int main() {
	n = gi() ; m = gi() ; Q = gi() ; MOD = gi() ;
	for(int i = 1; i <= m; i ++) {
		U[i] = gi() , V[i] = gi() ;  C[i] = gi() ;
		if(i == 2) g = abs(C[i] - C[1]) ;
		else if(i > 2) g = __gcd((int)(abs(C[i] - C[1])) , g) ; 
	}
	if(!g) g = MOD ; 
	z = C[1] % g ; mod = __gcd(MOD , 3 * g) ;
	for(int i = 0,t = 1; i <= mod + 1; i += 2,t = 4ll * t % mod) ok[0][1ll * z * t % mod] = true ; 
	for(int i = 1,t = 2; i <= mod + 1; i += 2,t = 4ll * t % mod) ok[1][1ll * z * t % mod] = true ; 	
	for(int i = 1; i <= 6 * n; i ++) dsu[i] = i ; 	
	for(int i = 1; i <= m; i ++) {
		int c = (C[i] - z) / g ; 
		c %= 3 ; 
		for(int q = 0; q < 2; q ++) 
			for(int p = 0; p < 3; p ++) {
				dsu[Find(ID(U[i],q,p))] = Find(ID(V[i] , q ^ 1 , (2*p+c)%3)) ; 
				dsu[Find(ID(V[i],q,p))] = Find(ID(U[i] , q ^ 1 , (2*p+c)%3)) ; 
			}
	}
	int s , t , r ;
	while(Q --) {
		s = gi() ; t = gi() ; r = gi() ; r = (r + z) % mod ; 
		bool flag = false ; 
		for(int q = 0; q < 2; q ++) 
			for(int p = 0; p < 3; p ++) 
				if(Find(ID(t,0,0)) == Find(ID(s,q,p))) {
					if(ok[q][(r - p * g % mod + mod) % mod]) flag |= ok[q][(r - p * g % mod + mod) % mod] ; 
				}
		if(flag) puts("YES") ; 
		else puts("NO") ; 
	}
	return 0 ;
}


Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    int a,b;
    cin >>a >>b;

    REP(i,10000){

        if((int)((i+1)*0.08) ==a && (int)((i+1)*0.1) ==b){
            cout << i+1 <<endl;
            return 0;
        }
    }
    cout <<-1 <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int main(){
    string s;
    string S[11];
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '0'){
            S[cnt] = '0';
            cnt++;
        }
        else if(s[i] == '1'){
            S[cnt] = '1';
            cnt++;
        }
        else{
            if(cnt != 0){
                S[cnt] = "\0";
                cnt--;
            }
        }
    }
    rep(i, cnt) cout << S[i];
    cout << endl;
    return 0;
}


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


vector<int> readVec(int n) {
    vector<int> v;
    for (int i=0; i<n; i++) {
        int x;
        scanf("%d",&x);
        v.PB(x);
    }
    return v;
}
int main() {
    int n; cin>>n;
    vector <int> v=readVec(n);
    int c=0,mx,mn;
    for (int i=1;i<n-1;i++){
        mx=max(v[i-1],max(v[i],v[i+1]));
        mn=min(v[i-1],min(v[i],v[i+1]));
        if (v[i]!=mx &&v[i]!=mn) c++;
    }
    cout<<c<<'\n';
}

Measured memory_bytes: 3640
N, W = map(int, input().split())
d = {0:0}
for _ in range(N):
  w, v = map(int, input().split())
  for dw, dv in d.copy().items():
    if dw + w <= W:
      d[dw + w] = max(d.get(dw + w, 0), dv + v)
print(max(d.values()))

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
  int n;
  cin >> n;
vector<bool>dp(n+1,false);
dp.at(0)=true;
int che [6] ={100,101,102,103,104,105};
for(int i=0;i<n;i++){
  if(dp.at(i)){
    for(int j=0;j<6;j++){
      if(che[j]+i>n)continue;
      dp.at(i+che[j])=true;
    }
  }
}
cout << dp.at(n)<<endl;
}







Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl10
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(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 (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

signed main() {
  SS(ll,a);
  ll ans=0;
auto q = prime_factor(a);
for (auto itr=q.begin(); itr!=q.end(); ++itr) {
int soinnsuu_kosuu = itr->second;
  for(int i=1;i<10000000;i++){
    if(i*(i+1)/2>soinnsuu_kosuu){
      ans+=i-1;
      break;
  }
}
}
p(ans);
  
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int ans=-1000;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		int ans2=0;
		for(int c=i;c<s.size();c++)
		{
			if(s[c]=='A'||s[c]=='C'||s[c]=='G'||s[c]=='T')
				ans2++;
			else
				break;
		}
		ans=max(ans,ans2);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int n,i;
  scanf("%d",&n);
  char a[n],b[n];
  scanf("%s",a);
  scanf("%s",b);
  for(i=0;a[i]!='\0';i++){
    printf("%c%c",a[i],b[i]);
  }
  printf("\n");
}


Measured memory_bytes: 128
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))
  }
  val primes: IndexedSeq[Int] = prime_sieve(75000)
  val pi_cache: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
  val phi_cache: collection.mutable.Map[(Int, Int), Int] = collection.mutable.Map.empty

  def prime_sieve(x: Int): IndexedSeq[Int] = {
    val n = x - x % 6 + 6
    val correction = if (x % 6 > 1) 1 else 2
    val sieve = Array.fill(n/3)(true)
    for (i <- 1 to (Math.sqrt(n) / 3).toInt if sieve(i)) {
      val k = (3 * i + 1) | 1
      for (j <- (k * k) / 3 until sieve.length by 2*k) sieve(j) = false
      for (j <- (k*(k-2*(i&1)+4))/3 until sieve.length by 2*k) sieve(j) = false
    }
    2 +: 3 +: (for (i <- 1 until n / 3 - correction if sieve(i)) yield (3*i+1)|1)
  }
  def bisect(n: Int): Int = {
    def loop(left: Int, right: Int): Int = {
      val mid = (left + right) / 2
      if (primes(mid) <= n && n < primes(mid+1)) mid+1
      else if (n < primes(mid)) loop(left, mid)
      else loop(mid+1, right)
    }
    if (n < primes.head) 0
    else if (n >= primes.last) primes.length
    else loop(0, primes.length)
  }
  def pi(x: Int): Int =
    pi_cache.getOrElseUpdate(x,
      if (x <= primes.last) bisect(x)
      else {
        val a = pi(Math.sqrt(Math.sqrt(x)).toInt)
        val b = pi(Math.sqrt(x).toInt)
        val c = pi(Math.cbrt(x).toInt)
        var result = phi(x, a) + ((b + a - 2) * (b - a + 1)) / 2
        for (i <- a + 1 to b) {
          val w = x / primes(i - 1)
          val b_i = pi(Math.sqrt(w).toInt)
          result -= pi(w)
          if (i <= c)
            for (j <- i to b_i)
              result = result - pi(w / primes(j - 1)) + j - 1
        }
        result
      }
    )
  def phi(x: Int, a:Int): Int =
    phi_cache.getOrElseUpdate(
      (x,a),
      {
        if (a == 1) (x + 1) / 2
        else phi(x, a - 1) - phi(x / primes(a - 1), a - 1)
      }
    )
}

Measured memory_bytes: 45332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> Q;

ll mod = 1000000007;
int n, m, l, r, fl[100010];
ll ans;
vector<P> vec;

int po(int x, int y)
{
	if (y == 0) return 1;
	return po(x, y - 1) * x;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> l >> r;
		fl[l]++;
		fl[r + 1]--;
	}
	for (int i = 1; i <= n; i++)
	{
		fl[i + 1] += fl[i];
	}
	for (int i = 1; i <= n; i++)
	{
		if (fl[i] == m)
		{
			ans++;
		}
	}
	cout << ans << endl;
	cin >> m;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	String befId = sc.next();
	String aftId = sc.next();
    String trancatedLast = aftId.substring(0, aftId.length()-1);
    //check
    //System.out.println(trancatedLast);
    
    if(befId.equals(trancatedLast)){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }

  }
}



Measured memory_bytes: 35548
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    ans = 1
    num = 7
    while True:
        if num % k == 0:
            print(ans)
            break
        else:
            ans += 1
            num += 7 * pow(10, ans - 1, k)
            num %= k


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

int main() {
    while (1) {
        string s1, s2, s3;
        cin >> s1;
        if (s1 == "0") break;
        cin >> s2 >> s3;
        int a = 0, b = 0;
        for (int i = 1; i < s1.size(); i++) {
            if (s1[i] == 'A') a++;
            else b++;
        }
        if (s2[0] == 'A') a++;
        else b++;
        cout << a << " " << b << endl;
        a = 0, b = 0;
        for (int i = 1; i < s2.size(); i++) {
            if (s2[i] == 'A') a++;
            else b++;
        }
        if (s3[0] == 'A') a++;
        else b++;
        cout << a << " " << b << endl;
        a = 0, b = 0;
        for (int i = 1; i < s3.size(); i++) {
            if (s3[i] == 'A') a++;
            else b++;
        }
        if (a < b) b++;
        else a++;
        cout << a << " " << b << endl;
    }

    return 0;
}

Measured memory_bytes: 3060
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ril()
acc = [0]
for x in ls:
    acc.append(acc[-1] + x)
counter = collections.Counter(acc)
res = 0
for v in counter.values():
    res += v * (v - 1) // 2
print(res)

Measured memory_bytes: 41728
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll h,w;
int main(){
	cin>>h>>w;
	if(h!=1&&w!=1)
	{
		cout<<(h*w+1)/2<<endl;
	}
	else
	{
		cout<<1<<endl;
	}
	return 0;
}

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

string s;
int flag;

bool Check(int i,char ch){
  if (i%2==1) return (ch=='R' || ch=='U' || ch=='D');
  if (i%2==0) return (ch=='L' || ch=='U' || ch=='D');
}

int main(){
  cin>>s;
  int n=s.length();s=" "+s;
  flag=1;
  for(int i=1;i<=n;i++){
    if (Check(i,s[i])==false) flag=0;
  }
  if (flag==0) cout<<"No";
  else cout<<"Yes";
}


Measured memory_bytes: 256
n = int(input())
la = list(map(int, input().split()))
q = int(input())
lq = [list(map(int, input().split())) for i in range(q)]

s = sum(la)

num = [0 for i in range(10 ** 5)]
for i in la:
    num[i - 1] += 1

for i in lq:
    s += (i[1] - i[0]) * num[i[0] - 1]
    num[i[1] - 1] += num[i[0] - 1]
    num[i[0] - 1] = 0
    print(s)
    

Measured memory_bytes: 32820
/// Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;


#define FASTIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt", "w+", stdout)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define DBG printf("hey!!!\n")
#define all(x) (x).begin(), (x).end()
#define fap(x) cout << " -- " << #x << ": " << (x) << "\n"
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))



typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;



const ll MAX= 998244353;
const ll MAX2=1271309838631957LL;
long double PI = acosl(-1);
const ll INF = 1e15;
const int NMAX = 1e5+5;
const int MAXLG = log2(NMAX)+1;
const int oo = 1e9+10;
const int sz = 100005;
const int MOD = 10000019;
const double EPS = 1e-9;

/// code starts from here

void solve(){
    int n;
    cin >> n;
    vector<int> happiness[3];

    for(int i = 0; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        happiness[0].push_back(a);
        happiness[1].push_back(b);
        happiness[2].push_back(c);
    }

    int dp[NMAX][3];

    dp[0][0] = happiness[0][0];
    dp[0][1] = happiness[1][0];
    dp[0][2] = happiness[2][0];

    for(int i = 1; i < n; i++){
        for(int j = 0; j < 3; j++){
            int pos1 = (j+1)%3;
            int pos2 = (j+2)%3;
            dp[i][j] = max(dp[i-1][pos1], dp[i-1][pos2])+happiness[j][i];
        }
    }

    int ans = 0;
    for(int i = 0; i < 3; i++){
        ans = max(ans, dp[n-1][i]);
    }

    cout << ans << endl;
}

int main(){
    //IN;
    FASTIO;

    solve();




}


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

int main()
{
	int n, k, p = 1;
	std::cin >> n >> k;

	std::vector<int> a(n);
	for (int i = 0; i < n; i++)
		std::cin >> a[i];

	for (int i = 0; i < k; i++)
		p *= a[i];
	
	for (int i = k; i < n; i++)
		std::cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N];
int n,k,ans;
int main()
{
    scanf("%d%d%s",&n,&k,s+1);
    for(int i=1;i<=n;i++)
        if((s[i]=='L'&&s[i-1]=='L')||(s[i]=='R'&&s[i+1]=='R'))
            ans++;
    ans+=2*k;
    printf("%d\n",min(ans,n-1));
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>

int main()
{
        char r[2][4002] = {};
        while (gets (r[0])) {
                gets (r[1]);
                int d[2][4002] = {}, le, ri, a = 0;
                le = strlen (r[0]), ri = strlen (r[1]);
                for (int i=1; i<=le; i++) {
                        for (int j=1; j<=ri; j++) {
                                if (r[0][i-1] == r[1][j-1]) d[i&1][j] = d[1-(i&1)][j-1] + 1;
                                else d[i&1][j] = 0;
                                a = a>d[i&1][j] ? a:d[i&1][j];
                        }
                }
                printf ("%d\n", a);
        }
        return 0;
}

Measured memory_bytes: 992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication76
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            if(a%10==9||(a-(a%10))/10==9)
            Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
N = input()

def f(s):
    if int(s) > int(N):
        return 0
    for t in '3','5','7':
        if all(['3' in s,'5' in s,'7' in s]):
            ans.append(1)
        f(s+t)

ans=[]
f('0')
print(sum(ans)//3)

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    ll n, d; cin >> n >> d;
    int cnt = 0;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        if (x*x+y*y<=d*d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  string S;
  cin >> N >> S;

  int ans = 0;
  for(int i = 0;i < N-2;i++) {
    if(S.substr(i,3) == "ABC") ans++;
  }

  cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long dp[100005][4];

long long dist[200][200];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	vector<int>p(N);
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
	}
	
	int ans = 0;
	for (int i = 0; i < N;++i) {
		if (p[i] == i + 1) {
			if(i!=N-1)swap(p[i],p[i+1]);
			else swap(p[i-1],p[i]);
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;

int N, M;
vector<int> v[SIZE];
int dp[SIZE];

int rec(int indx){
	
	if(dp[indx]>=0) return dp[indx];
	int &ret=dp[indx]=0;
	for(int i=0;i<(int)v[indx].size();i++){
		int idx=v[indx][i];
		ret=max(ret,rec(idx)+1);
	}
	return ret;
}

int main (){
	
	int a, b;
	
	scanf("%d %d", &N, &M);
	for(int i=0;i<M;i++){
		scanf("%d %d", &a, &b);
		v[a].pb(b);
	}
	int ans=0;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=N;i++){
		ans=max(ans,rec(i));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int mx = -1000;
	rep(i, n) {
		int X;
		cin >> X;
		mx = max(mx, X);
	}
	int mn = 1000;
	rep(i, m) {
		int Y;
		cin >> Y;
		mn = min(mn, Y);
	}
	if (x < mx && mn <= y && mx < mn) cout << "No War" << endl;
	else cout << "War" << endl;
}

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

using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;



long long fe[32];
long long k; 
void decToBinary(long long n) 
{ 
    
    memset(fe,-1,sizeof(fe));
    long long i = 0; 
    while (n > 0) { 
  
        fe[i] = n % 2; 
        n = n / 2; 
        i++; 
    } 
} 

/*int main()
{
    long long n,q,m,b1,ans=0,a1,s,cntn=0,cntp=0,cntz=0,max1=-1,max2=-1;
    cin>>n;
    vector< pair <int,int> >a;
    long long p[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>p[i];
    }
}*/

int main()
{
    long long n,a,b,c,k,flag=0,y;
    cin>>n;
    int h[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>h[i];
    }
    h[0]--;
    for (int i =1; i < n-1; ++i)
    {
        if(h[i]>=h[i+1] && h[i-1]<h[i])
            h[i]--;

    }
    for (int i = 0; i < n-1; ++i)
    {
        if(h[i]>h[i+1])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"No";
    else
        cout<<"Yes";
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int c[][] = new int[10][10];
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		int A[][] = new int[H][W];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		int ans[] = new int[10];
		ans[1] = 0;
		boolean flag[] = new boolean[10];
		for(int i = 0; i < 10; i++) {
			if(i == 1) continue;
			flag[i] = true;
			ans[i] = DFS(i, c, flag, 0, Integer.MAX_VALUE);
			flag[i] = false;
		}
		
		int sum = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(A[i][j] == -1) continue;
				sum += ans[A[i][j]];
			}
		}
		System.out.println(sum);
	}
	
	public static int DFS(int k, int c[][], boolean flag[], int cnt, int min) {
		for(int i = 0; i < 10; i++) {
			if(flag[i]) continue;
			if(i == 1) {
				min = Math.min(min, cnt + c[k][i]);
			} else {
				flag[i] = true;
				min = Math.min(min, DFS(i, c, flag, cnt + c[k][i], min));
				flag[i] = false;
			}
		}
		return min;
	}
}


Measured memory_bytes: 45096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 5000000000000000000;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        rep(i, N) par[i] = -1;
    }
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -par[root(x)];
    }
};

struct Edge {int from; int to; ll cost;};

int main() {
    int N;
    cin >> N;
    vector<tuple<ll, ll, int>> S(N);
    rep(i, N) {
        cin >> get<0>(S[i]) >> get<1>(S[i]);
        get<2>(S[i]) = i;
    }
    
    vector<Edge> Edges;
    sort(ALL(S));
    rep(i, N - 1) Edges.push_back(Edge{get<2>(S[i]), get<2>(S[i + 1]), min(get<0>(S[i + 1]) - get<0>(S[i]), abs(get<1>(S[i]) - get<1>(S[i + 1])))});
    rep(i, N) swap(get<0>(S[i]), get<1>(S[i]));
    sort(ALL(S));
    rep(i, N - 1) Edges.push_back(Edge{get<2>(S[i]), get<2>(S[i + 1]), min(get<0>(S[i + 1]) - get<0>(S[i]), abs(get<1>(S[i]) - get<1>(S[i + 1])))});
    
    sort(ALL(Edges), [](Edge a, Edge b) {
        return a.cost < b.cost;
    });
    UnionFind U(N);
    ll ans = 0;
    for (auto e : Edges) {
        if (U.same(e.from, e.to)) continue;
        U.unite(e.from, e.to);
        ans += e.cost;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9796
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	char s[5];
	chin(s);
	puts(s[0]==s[2]?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,a,b=map(int,input().split());c=0\n"
"while n:c+=n*(a<=sum(map(int,str(n)))<=b);n-=1\n"
"print(c)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        
        if 0 <= i-1:
            up = s[i-1][j]
        else:
            up = s[i][j]
        
        if i+1 < h:
            down = s[i+1][j]
        else:
            down = s[i][j]

        if 0 <= j-1:
            left = s[i][j-1]
        else:
            left = s[i][j]
        
        if j+1 < w:
            right = s[i][j+1]
        else:
            right = s[i][j]
        
        if s[i][j] != up and s[i][j] != down and s[i][j] !=left and s[i][j] != right:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3064
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,M;
  cin >> N;
  vector<ll> T(N);
  ll T_sum=0;
  for(int i=0;i<N;++i){
    cin >> T.at(i);
    T_sum+=T.at(i);
  }
  cin >> M;
  vector<pair<int,ll>> drink(M);
  int P;
  ll X;
  for(int i=0;i<M;++i){
    cin >> P >> X;
    drink.at(i)=make_pair(P,X);
  }

  for(int i=0;i<M;++i){
    int P=drink.at(i).first-1;
    ll X=drink.at(i).second;
    cout << T_sum-T.at(P)+X << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  int table[n][n];
  fill_n(*table, n * n, -1);
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int x, y;
      cin >> x >> y;
      x--;
      table[i][x] = (y == 1);
    }
  }
  int ans = 0;
  rep(i, 1 << n) {
    vector<int> x(n, -1);
    int flg = 0;
    rep(j, n) {
      if (i & (1 << j)) {
        // 正直者が正直者だと言う人
        rep(k, n) {
          if (table[j][k] == -1) continue;
          if (x[k] == -1) x[k] = table[j][k];
          else if (x[k] != table[j][k]) { flg = 1; break; }
        }
      }
      if (flg) break;
    }

    rep(j, n) {
      if (i & (1 << j)) {
        if (x[j] == 0) {
          flg = 1;
          break;
        }
      } else {
        if (x[j] == 1) {
          flg = 1;
          break;
        }
      }
    }
    if (flg) continue;

    chmax(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
def main():
    INF = float("inf")

    N, M, *ABC = map(int, open(0).read().split())

    D = [0] + [INF] * (N - 1)
    E = tuple((a - 1, b - 1, -c) for a, b, c in zip(*[iter(ABC)] * 3))

    for _ in range(N - 1):
        for a, b, c in E:
            if D[a] == INF:
                continue
            D[b] = min(D[b], D[a] + c)

    ans = D[-1]
    neg = [False] * N

    for _ in range(N):
        for a, b, c in E:
            if D[a] == INF:
                continue

            if D[b] > D[a] + c:
                D[b] = D[a] + c
                neg[b] = True

            if neg[a]:
                neg[b] = True

    print("inf" if ans != D[-1] else -ans)

main()


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    vector<long double> X,Y;
    for (int i = 0; i < N; i++) {
        long double x,y;
        cin >> x >> y;
        X.pb(x); Y.pb(y);
    }
    vector<ll> v(N);
    iota(v.begin(), v.end(), 0);
    ll cnt = 0;
    long double ans = 0.0;
    do {
        for (int i = 1; i < v.size(); i++) {
            ans += sqrt((X[v[i-1]] - X[v[i]])*(X[v[i-1]] - X[v[i]]) + 
                   (Y[v[i-1]] - Y[v[i]])*(Y[v[i-1]] - Y[v[i]]));
        }
        cnt++;
    } while(next_permutation(v.begin(),v.end()));
    printf("%.10Lf\n",ans / (long double)cnt);
}

Measured memory_bytes: 3808
n, m = map(int, input().split())
L = [list(map(int, input().split())) for i in range(m)]
for i in range(1, n+1):
  count = 0
  for k in range(m):
    for v in range(2):
      if i == L[k][v]:
        count += 1
  print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		// ?????? A ??\???
		int[][] A;
		A = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		// ?????? B ??\???
		int[][] B;
		B = new int[m][l];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				B[i][j] = scan.nextInt();
			}
		}

		// ?????? C ??\???
		// long ?????????
		long[][] C;
		C = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					C[i][j] = C[i][j] + A[i][k] * B[k][j];
				}
			}
		}

		// ?????? C ??????
		for (int i = 0; i < n; i++) {

			// C[i][j]???1???????????????????????????(" " + C[i][j])?????????
			int j = 0;
			System.out.print(C[i][j]);

			for (j = 1; j < l; j++) {
				System.out.print(" " + C[i][j]);
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 52408
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64);
    puts!("{}\n", (n + 1) / 2);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
using namespace std;
int main(){
  int N,K,Q,A[100000],i,P[100000];
  cin >> N >> K >> Q;
  for(i=0;i<Q;i++)cin >> A[i];
  for(i=0;i<N;i++)P[i]=K-Q;
  for(i=0;i<Q;i++)P[A[i]-1]++;
  for(i=0;i<N;i++){
    if(P[i]>0)cout << "Yes" << endl;
    else cout << "No" << endl;
    }
  }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll a[200005];
fastmap <ll, ll> occ;
int main(){
	ll n; cin >> n;
	for (ll i = 0; i < n; i++) cin >> a[i], occ[a[i]]++;
	ll ans = 0;
	vll t;
	for (ll i = 0; i < n; i++){
		if (occ[a[i]] >= 4) ans = max(ans, a[i] * a[i]);
		if (occ[a[i]] >= 2) t.pb(a[i]); 
		occ[a[i]] = 0;
	}
	sort(t.begin(), t.end());
	ll x = 0;
	if (t.size() <= 1) x = 0;
	else ans = max(ans, t[t.size() - 1] * t[t.size() - 2]);
	cout << ans << endl;
}

Measured memory_bytes: 10352
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int min=sc.nextInt();
		int max=sc.nextInt();
		int tmp=sc.nextInt();
		int bg = tmp;
		if(tmp>max-min){
			bg=max-min;
		}
if(max==min) {
			bg=1;
		}
		int mn = tmp;
		if(mn>max-min) {
			mn=max-min;
		}
		int big[] = new int[bg];
		int small[] = new int[mn];
		ArrayList<Integer> list=new ArrayList<>();
		for(int i=0;i<bg;i++) {
			big[i]=min+i;
			list.add(big[i]);
		}
		for(int i=0;i<mn;i++) {
			small[mn-1-i]=max-i;
		}
		ch:for(int i=0;i<mn;i++) {
			for(int j=0;j<list.size();j++) {
				if(small[i]==list.get(j)) {
					continue ch;
				}
			}
			list.add(small[i]);
		}
		for(int i=0;i<list.size();i++) {
			System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

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

    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int &i : v)
        cin >> i;
    int cnt = 0;
    int cur = 1;
    if (k <= n)
    {
        for (int i = 0; i < k; i++)
        {
            cur = v[cur - 1];
        }
        cout << cur;
        return 0;
    }
    bool vis[n + 1];
    memset(vis, 0, sizeof(vis));
    while (!vis[cur])
    {
        vis[cur] = 1;
        cur = v[cur - 1];
        cnt++;
    }
    if (cur != 1)
    {
        int temp = cnt;
        cnt = 0;
        memset(vis, 0, sizeof(vis));
        while (!vis[cur])
        {
            vis[cur] = 1;
            cur = v[cur - 1];
            cnt++;
        }
        k -= (temp - cnt);
    }
    k = k % cnt;
    for (int i = 0; i < k; i++)
    {
        cur = v[cur - 1];
    }
    cout << cur;

    return 0;
}

Measured memory_bytes: 5044
#include <iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;

using namespace std;

int main(void){

    int A,B;
    cin >> A >> B;

    if(A == 1) A = 14;
    if(B == 1) B = 14;

    if(A > B){
        cout << "Alice" << endl;
    }else if(A < B){
        cout << "Bob" << endl;
    }else{
        cout << "Draw" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main() {
    long long N;
    cin >> N;
    vector<long long>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long long ans = 1;
    for(int i = 0; i < N; i++) {
        if(INF/A[i] < ans) {
            cout << -1 << endl;
            return 0;
        }
        ans*=A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4048