akhauriyash/Code-Regression huggingface dataset:
N = int(input())
name = []
N = N - 1
while N >= 26:
    name.append(N % 26)
    N = int(N / 26) - 1
name.append(N)

def swap(X):
    if X == 0:
        return "a"
    elif X == 1:
        return "b"
    elif X == 2:
        return "c"
    elif X == 3:
        return "d"
    elif X == 4:
        return "e"
    elif X == 5:
        return "f"
    elif X == 6:
        return "g"
    elif X == 7:
        return "h"
    elif X == 8:
        return "i"
    elif X == 9:
        return "j"
    elif X == 10:
        return "k"
    elif X == 11:
        return "l"
    elif X == 12:
        return "m"
    elif X == 13:
        return "n"
    elif X == 14:
        return "o"
    elif X == 15:
        return "p"
    elif X == 16:
        return "q"
    elif X == 17:
        return "r"
    elif X == 18:
        return "s"
    elif X == 19:
        return "t"
    elif X == 20:
        return "u"
    elif X == 21:
        return "v"
    elif X == 22:
        return "w"
    elif X == 23:
        return "x"
    elif X == 24:
        return "y"
    elif X == 25:
        return "z"

swap_name = []
for i in range(len(name)):
    swap_name.append(swap(name[len(name)-i-1]))
print(*swap_name, sep="")


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

int main(){
  
  int n;
  
  cin >> n;
  
  int a[n];
  
  bool flag = true;
  
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if(a[i] % 2 == 0)
    {
      if(a[i] % 3 != 0 && a[i] % 5 != 0)
      {
       	flag = false; 
        break;
      }
    }
  }
  
  if(flag)
  {
  	cout << "APPROVED";
  }
  else
  {
    cout << "DENIED";
  }
  
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

a = list(map(int, input().split()))
done = [0]*n
stay = 1

for i in range(1, k+1):
    if done[stay-1] != 0:
        break
    done[stay-1] = i
    stay = a[stay-1]

nokori = k + 1 - i
if nokori != 1:
    loop = i - done[stay-1]
    for i in range(nokori%loop):
        stay = a[stay-1]

print(stay)

Measured memory_bytes: 32368
/*
 * atcoder/dp_3rd/h.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

const int MAX = 1100;
int H, W;
bool G[MAX][MAX] = {0};
mint dp[MAX][MAX] = {0};

void input() {
  cin >> H >> W;
  char c;
  loop(h,0,H) {
    loop(w,0,W) {
      cin >> c;
      G[h][w] = c == '.';
    }
  }
}

void solve() {
  for (int h=0; h<H; h++) {
    for (int w=0; w<W; w++) {
      if (h+w==0) { dp[h][w] = 1; continue; }
      if (h == 0) { dp[h][w] = G[h][w] ? dp[h][w-1] : 0; continue; }
      if (w == 0) { dp[h][0] = G[h][w] ? dp[h-1][0] : 0; continue; }
      dp[h][w] = G[h][w] ? (dp[h-1][w] + dp[h][w-1]) : 0;
    }
  }
  cout << dp[H-1][W-1] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 10752
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  struct chan{
    int b;
    ll c;
  };
  int n,m;
  cin>>n>>m;
  ll a[n];
    vector<chan> key(m);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<m;i++){
    int p;
    ll q;
    cin>>p>>q;
    key[i].b=p;
    key[i].c=q;
  }
  sort(key.begin(),key.end(),[](const chan& x,const chan& y){return x.c<y.c;});
  int tmp=m-1,ro=0;
  for(int i=0;i<n;i++){
    if(tmp==-1) break;
    if(a[i]>=key[tmp].c){
      tmp--;
      ro=0;
      continue;
    }else{
      a[i]=key[tmp].c;
    }
    ro++;
    if(ro==key[tmp].b){
      tmp--;
      ro=0;
    }
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=a[i];
    //cout<<a[i]<<endl;
  }
  //cout<<endl;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int mex(vector<int> a)
{
	sort(a.begin(), a.end());
	for(int i = 0; i < (int)a.size(); i++)
		if(i != a[i]) return i;
	return (int)a.size();
}

int n;
int A[MAXN], K[MAXN]; 

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i] >> K[i];
}

int solve(int a, int k)
{
	if(a % k == 0) return a / k;
	if(a < k) return 0;

	int v = a / k + 1, bg = (a / k) * k;
	if((a - bg) % v == 0) return v - 1;
	return solve((a - bg) % v + bg - v, k);
}

void solve()
{
	int answer = 0;
	for(int i = 0; i < n; i++)
		answer ^= solve(A[i], K[i]);

	if(answer == 0) cout << "Aoki" << endl;
	else cout << "Takahashi" << endl;
}

int tmp_sg[MAXN];

void prepare()
{
	for(int k = 1; k <= 20; k++)
	{
		cout << k << ": ";
		tmp_sg[0] = 0;
		for(int v = 1; v <= 60; v++)
		{
			vector<int> li;
			int mx = v / k;

			for(int i = v - 1; i >= v - mx; i--)
				li.push_back(tmp_sg[i]);

			tmp_sg[v] = mex(li);
			cout << tmp_sg[v] << " ";
		}

		cout << endl;
	}
}

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

	//prepare();
	read();
	solve();
	return 0;
}



Measured memory_bytes: 4480
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]

scr = [((i+1)*100)*pc[i][0]+pc[i][1] for i in range(D)]

ans = 10**10
for i in range(2**D):
    a = 0
    c = 0
    for j in range(D):
        if i>>j&1:
            a += scr[j]
            c += pc[j][0]
    if a < G:
        continue
    ans = min(ans,c)
    for j in range(D):
        if i>>j&1:
            a -= scr[j]
            c -= pc[j][0]
            if a >= G:
                continue
            if (G-a+((j+1)*100)-1)//((j+1)*100) < pc[j][0]:
                ans = min(ans,c+(G-a+((j+1)*100)-1)//((j+1)*100))
            a += scr[j]
            c += pc[j][0]

print(ans)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

long double x[8],y[8],s=0.0;

int main(void){
	int n,i,j;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i];
		for(j=0; j<i; ++j){
			s += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	s *= 2.0;
	s /= n;
	cout << fixed << setprecision(50) << s << endl;
	return 0;
}


Measured memory_bytes: 256
'use strict'
var rooter;
const ROOT = -1;

function connected(a,b){
	a--;b--;
	let c = getRoot(a);
	let d = getRoot(b);
	if(c==d) return 0;
	let size = rooter[c] + rooter[d];
	let count = rooter[c] * rooter[d];
	rooter[a] = c;
	rooter[b] = c;
	rooter[d] = c;
	rooter[c] = size;

	//console.log(a,b);
	//console.log(c,d);
	//console.log(rooter[c],rooter[d]);
	//console.log(size,count);
	return count;
}
function getRoot(a){
	while(rooter[a]>ROOT){
		a = rooter[a];
	}
	return a;
}

function Main(input){
	let temp = input.trim().split("\n");
	let temp2 = temp[0].split(" ");
	let N = parseInt(temp2[0]);
	let M = parseInt(temp2[1]);	
	temp.shift();

	const AB = temp.map( (v)=>
		v.split(" ").map( (w)=>
			parseInt(w)
		)
	);


	//全ての橋がない時の数を計算
	let huben = 0;
	for(var i=1;i<N;i++){
		huben += i;
	}

	//ルートがない状態
	rooter = new Array(N).fill(ROOT);
	
	const answer = new Array(M+1).fill(0);
	answer[M] = huben;
	for(var i=M-1;i>=0;i--){
		if(huben <= 0) break;
		huben -= connected(AB[i][0],AB[i][1]);
		answer[i] = huben;
		//console.log(AB[i],"huben:",huben,"rooter:",rooter);
	}
	//console.log("----------------------------");
	//console.log("answer:",answer);
	//console.log(rooter);

	answer.shift();
	console.log(answer.join("\n") + "\n");

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 60496
#include<bits/stdc++.h>
using namespace std;
const int r = pow(10,5) + 1;
int x[r] = {};
int main(){
  int n;
  int ans = 0;

  cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < n;++i){
    int a;
    cin >> a;
    if(a >= r)ans++;
    else x[a]++;
  }


  for(int i = 1; i < r; ++i){
    if(x[i] >= i)ans += x[i] - i;
    else ans += x[i];
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,y;
    cin>>n>>y;
    int res10000 =-1,res5000=-1,res1000=-1;
    for(int a=0;a<=n;a++){
        for(int b=0;b+a<=n;b++){
        int c=n-a-b;
         int count =10000*a+5000*b+1000*c;
         if(count ==y){
             res10000=a;
             res5000=b;
             res1000=c;
         }

        }
    }
    cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
aa = ["A","C","G","T"]
dic = {}
invdic = {}
n = int(input())
for i in range(4):
    for j in range(4):
        for k in range(4):
            dic[16*i+4*j+k] = aa[i]+aa[j]+aa[k]
            invdic[aa[i]+aa[j]+aa[k]] = 16*i+4*j+k


dp = [[0 for j in range(64)] for i in range(101)]

for i in range(64):
    dp[3][i] = 1

dp[3][invdic["AGC"]]=0
dp[3][invdic["GAC"]]=0
dp[3][invdic["ACG"]]=0

for i in range(3,100):
    for j in range(64):
        moji = dic[j]
        if(moji[0] == "A" and moji[2] == "G") or(moji[0] == "A" and moji[1] == "G")or(moji[1] == "A" and moji[2] == "G")or(moji[1] == "G" and moji[2] == "A"):
            dp[i+1][invdic[moji[1]+moji[2]+"A"]] = (dp[i+1][invdic[moji[1]+moji[2]+"A"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"G"]] = (dp[i+1][invdic[moji[1]+moji[2]+"G"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"T"]] = (dp[i+1][invdic[moji[1]+moji[2]+"T"]]+dp[i][j]) % MOD
        elif(moji[1] == "A" and moji[2] == "C"):
            dp[i+1][invdic[moji[1]+moji[2]+"A"]] = (dp[i+1][invdic[moji[1]+moji[2]+"A"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"C"]] = (dp[i+1][invdic[moji[1]+moji[2]+"C"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"T"]] = (dp[i+1][invdic[moji[1]+moji[2]+"T"]]+dp[i][j]) % MOD
        else:
            dp[i+1][invdic[moji[1]+moji[2]+"A"]] = (dp[i+1][invdic[moji[1]+moji[2]+"A"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"C"]] = (dp[i+1][invdic[moji[1]+moji[2]+"C"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"T"]] = (dp[i+1][invdic[moji[1]+moji[2]+"T"]]+dp[i][j]) % MOD
            dp[i+1][invdic[moji[1]+moji[2]+"G"]] = (dp[i+1][invdic[moji[1]+moji[2]+"G"]]+dp[i][j]) % MOD        
    
        

ans = 0

for i in range(64):
    ans = (ans+dp[n][i]) % MOD

print(ans)

Measured memory_bytes: 3320
def sieve(n):
    res = []
    nums = [1] * n
    nums[0] = 0
    for i in range(int(n ** 0.5) + 1):
        if nums[i] == 0: continue
        j = 2
        while (i + 1) * j <= n:
            nums[(i+1) * j - 1] = 0
            j += 1
    for i in range(len(nums)):
        if nums[i] == 1:
            res.append(i+1)
    return res

primes = sieve(50021)

while True:
    try:
        n = int(input())
        minn, maxn = 0, 0
        for i in range(len(primes)):
            if primes[i] > n:
                maxn = primes[i]
                minn = primes[i-1]
                if minn == n: minn = primes[i-2]
                break
        print('%d %d' % (minn, maxn))
    except:
        break

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

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO(){
    #ifndef SHAILESH
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m){int res=1;a=a%m;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b=b>>1;}return res;}

int dp[101][100005];

int func(int W,int w[],int v[],int n){
	if(n==0 or W==0) return 0;
	if(dp[n][W]!=-1) return dp[n][W];

	if(w[n-1]>W) return dp[n][W]=func(W,w,v,n-1);
	else{
		int op1=v[n-1]+func(W-w[n-1],w,v,n-1);
		int op2=func(W,w,v,n-1);
		return dp[n][W]=max(op1,op2);
	}

}

void solve(){
	memset(dp,-1,sizeof(dp));
	int N,W;
	cin>>N>>W;
	int w[N],v[N];
	for(int i=0;i<N;i++) cin>>w[i]>>v[i];
	cout<<func(W,w,v,N);
}
    

int32_t main()
{
   // FIO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();


    return 0;
}

Measured memory_bytes: 82568
#include <bits/stdc++.h>    
#define pb push_back

#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
const int inf = 2e9;
using namespace std;
ll MOD = 1000000007;
typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;


void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}
ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}

bool ord(int a, int b){
	return b < a;
}

ll ans;
int k,q,n,m,t,a,b,u,f,l,x,z,y,s,d,h,r,V,E;
int A[100005];
vector<ii> v;
int dp[200005][2];
char S[200005];


int main(){
	scanf("%d%s",&n,S);
	FOR(i,n){
		int ant = i;
		while(S[i]=='.') i++;
		if(i-ant>0) v.pb({i-ant,'.'});
		ant = i;
		while(S[i]=='#') i++;
		if(i-ant>0) v.pb({i-ant,'#'});
		i--;
	}

	int l = v.size();

	dp[l-1][0] = 0;
	dp[l-1][1] = v[l-1].first;

	for(int i=v.size()-2; i>-1; i--){

		if(v[i].second=='#' && v[i+1].second == '.'){
				dp[i][0] = dp[i+1][1];
				dp[i][1] = v[i].first + dp[i+1][0];
		}

		if(v[i].second=='#' && v[i+1].second == '#'){
				dp[i][0] = dp[i+1][0];
				dp[i][1] = v[i].first + min(dp[i+1][0],dp[i+1][1]);
		}

		if(v[i].second=='.' && v[i+1].second == '.'){
				dp[i][0] = min(dp[i+1][0],dp[i+1][1]);
				dp[i][1] = v[i].first + dp[i+1][1];
		}
				
		if(v[i].second=='.' && v[i+1].second == '#'){
				dp[i][0] =  min(dp[i+1][0],dp[i+1][1]);
				dp[i][1] = v[i].first + dp[i+1][0];
		}

	}


	printf("%d\n",min(dp[0][0],dp[0][1]));
	return 0;
}



// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll w,h,x,y;
  cin>>w>>h>>x>>y;
  int num=(x+x==w)&&(y+y==h);
  cout<<(double)w*h/2<<" "<<num<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main() {
    double n,ans=0;
    cin >> n;
    vector<double>x(n);
    vector<string>u(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> u[i];
    }
    for(int i=0;i<n;i++){
        if(u[i]=="JPY"){
            ans+=x[i];
        }else{
            ans+=x[i]*(380000.0);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
l=int(input())
ans_max = (l/3)**3
for a in range(l):
    min = l-a
    max = l
    mid = min + (max - min) // 2
    for i in range(100):
        if ans_max < a * mid * (l - a - mid):
            ans_max = a * mid * (l - a - mid)
        max = mid
print(ans_max)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    REP(i, N) {
        FOR(j, N, i + 1) {
            if (A[i] == A[j])
                continue;
            FOR(k, N, j + 1) {
                if ((A[i] == A[k]) || (A[j] == A[k]))
                    continue;
                ll sum = A[i] + A[j] + A[k];
                ll mx = std::max({A[i], A[j], A[k]});
                if (sum - mx > mx)
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vvl it(n,vl(3));
    rep(i,n){
        rep(j,3)cin >> it[i][j];
    }
    vvl dp(n,vl(3));
    rep(j,3)dp[0][j]=it[0][j];
    rep(i,n-1){
        rep(j,3){
            rep(k,3){
                if(j==k)continue;
                chmax(dp[i+1][j],dp[i][k]+it[i+1][j]);
            }
        }
    }
    ll ans=0;rep(i,3)chmax(ans,dp[n-1][i]);
    cout << ans <<endl;
}

Measured memory_bytes: 13972
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<array>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
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);
}


//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main() {

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

	int K;
	cin >> K;
	ll sum = 0;
	for(int i = 1;i <= K;i++){
		for(int j = 1;j <= K;j++){
			for(int k = 1;k <= K;k++){
				int hoge = i;
				hoge = gcd(hoge,j);
				hoge = gcd(hoge,k);
				sum += hoge;
			}
		}
	}

	cout << sum << endl;

	return 0;
}






Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    int n;
    std::cin >> n;
    ll ans=1;
    std::vector<int> d(1001,0);
    rrep(i,2,n+1){
        int ii=i;
        rrep(j,2,i+1){
            while(ii%j==0){
                d[j]++;
                ii/=j;
            }
        }
    }
    rep(i,1001){
        ans*=d[i]+1;
        ans%=MOD;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
bool dp[200000];
int a[] = {100,101,102,103,104,105};
int main(){
    dp[0] = true;
    for(int i = 0; i <= 100000; i++){
        if(dp[i]){
            for(int x:a){
                dp[i+x] = true;
            }
        }
    }
    int x;
    cin >> x;
    if(dp[x])cout << 1;
    else cout << 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int cnt;
int main()
{
	int n, a[100];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)
	{
		int jud=1;
		for(int j=i-1;j>=0;j--)
		{
			if(a[j]>a[i])
			{
				jud=0;
				break;
			}
		}
		if(jud==1)cnt++;
	}
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;
  if(U == S){
    cout << A-1 << " " << B << endl;
  }
  else{
    cout << A << " " << B-1 << endl;
  }
}

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

string s;

int main()
{
	cin>>s;
	if(s.length()<4) puts("No");
	else if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I') puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, D;
int X[11][11];

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

    cin >> N >> D;
    rep(i,N){
      rep(j,D){
        cin >> X[i][j];
      }
    }

    int cnt = 0;
    rep(i, N){
      for(int j=i+1; j<N; j++){
        int sm = 0;
        rep(k, D){
          sm+= pow(X[i][k]-X[j][k], 2);
        }
        int n =0;
        int l =0;
        while(n<=sm){
          if (n==sm){
            cnt++;
            break;
          }
          l++;
          n=pow(l,2);
        }
      }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

int n;
int a[200005], cnt[1000005];
vector<int> vec[1000005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for(int i = 1; i <= 1000000; i++){
		for(int j = i; j <= 1000000; j += i) vec[j].push_back(i);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int sum = 0;
		for(int j = 0; j < vec[a[i]].size(); j++){
			sum += cnt[vec[a[i]][j]];
		}
		if(sum == 1) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 122428
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    int x, n, C=1, i=0;
    std::vector<int> data(10);
        
    cin>>n>>x;

    while((n!=0)||(x!=0))
    {
        int  count=0;
        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k < j; k++)
            {
                for (int l = 1; l < k; l++)
                {
                    if (j+k+l==x)   
                    {
                        count++;
                    }   
                }   
            }   
        }
        data[i] = count;
   
        cin>>n>>x;    

        if(++i==C*10)
        {
            C++;
            data.resize(count*10);
        }
    }

    for (int j = 0; j < i; j++)
    {
        cout<<data[j]<<endl;
    }


    return 0;
}


Measured memory_bytes: 3108
a,b,c = map(int, input().split())
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
  print(0)
else:
  for i in range(10**6):
    temp1 = a
    temp2 = b
    temp3 = c
    a = int((temp2+temp3)/2)
    b = int((temp1+temp3)/2)
    c = int((temp1+temp2)/2)
    if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
      break
  if i == 10**6 - 1:
    print(-1)
  else:
    print(i+1)

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H,W;
  cin>>H>>W;
  vector<string> data(H);
  for(int i =0;i < H;i++){
    cin >> data.at(i) ;
  }
  vector<bool> row(H,false);
  vector<bool> col(W,false);
  for(int i=0; i<H;i++){
    for(int j=0;j< W;j++){
      if(data.at(i).at(j)=='#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  for(int i=0;i<H;i++){
    if(row.at(i)){
      for(int j=0; j<W ;j++){
        if(col.at(j)){
          cout << data.at(i).at(j);
        }
      }
        cout <<endl;
    }
  }
}

Measured memory_bytes: 256
x,n = list(map(int,input().split()))


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    p2 = [x for x in range(-200,200)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in p_p2_diff_list:
        val = abs(x - i)
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])


Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, ll> P;

#define N_OVERSIZE 100050
vector<P> root[N_OVERSIZE];
int color[N_OVERSIZE] = {0}; //white 1, black -1


void dfs(int parent, int now, int parent_color){
    if (root[now].size() == 1 && now != 0){
        return;        
    } 
    for (auto node : root[now])
    {
        if (node.first != parent){
            if (node.second%2 == 0){
                color[node.first] = parent_color;
            } else {
                color[node.first] = -parent_color;
            }
            dfs(now, node.first, color[node.first]);
        }
    }

}

int main()
{
    int n;
    cin >> n;
    rep(i, n -1){ 
        int tmpu, tmpv, tmpw; 
        cin >> tmpu >> tmpv >> tmpw;
        tmpu--; tmpv--; 
        root[tmpu].push_back(P(tmpv, tmpw));
        root[tmpv].push_back(P(tmpu, tmpw));
    }

    color[0] = -1;
    dfs(-1, 0, -1); //white_start

    rep(i, n){
        cout << (color[i] == 1 ? 1: 0) << endl;
    }

}



Measured memory_bytes: 10624
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    s = [ns() for _ in range(n)]
    m = ni()
    t = [ns() for _ in range(m)]

    c1 = Counter(s)
    c2 = Counter(t)
    ans = []
    for key1, value1 in c1.items():
        if key1 in c2.keys():
            ans.append(value1 - c2[key1])
        else:
            ans.append(value1)

    print(max(max(ans), 0))
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=pow(10,9)+7
    lcma={}
    for ai in a:
      f=factorization(ai)
      for fi in f:
        if fi[0] in lcma:
          lcma[fi[0]]=max(lcma[fi[0]],fi[1])
        else:
          lcma[fi[0]]=fi[1]
    l=1
    for k,v in lcma.items():
      l*=pow(k,v,mod)
      l%=mod
    ans=0
    for ai in a:
      ans+=l*pow(ai,mod-2,mod)
      ans%=mod
    print(ans)

main()


Measured memory_bytes: 4596
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

#define rep(i, n)	        for(int i = 0; i < (int)(n); i++)
#define rep_1(i, n) 	    for(int i = 1; i <=(int)(n); i++)

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

void solve() {
    int n;
    read(n);
    vint vec(n);
    readvec(vec);
    for(int i = n - 1;i >= 0;i--){
        print(vec.at(i));
        if(i != 0){
            print(" ");
        }

    }
    printn;
}

signed main() {
    solve();
    return 0;
}


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

int	main() {
	string s;
	cin >>s;
	vector<char> SS(0);
	for (int i=0; i<s.size(); i++) 
		if ('x' != s.at(i))
			SS.push_back(s.at(i));
	int L=SS.size();
	for (int i=0; i<L/2; i++)
		if (SS.at(i)==SS.at(L-1-i))
			continue;
		else {
			cout <<-1 <<endl;
			return 0;
		}
	int i=0;
	int j=s.size()-1;
	int X=0;
	while(i<j) {
		if (s.at(i)==s.at(j)) {
			i++;
			j--;
		} else if ('x'==s.at(i)) {
			i++;
			X++;
		} else {
			j--;
			X++;
		}
	}
	cout <<X <<endl;
	return 0;
};


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, bool> P;
typedef pair<ll, P> PP;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    multiset<ll> mst;
    for(int i = 0; i < n; i++)
    {
        ll x; cin >> x;
        mst.insert(x);
    }
    ll ans = 0;
    while(!mst.empty())
    {
        auto itr = mst.end();
        itr--;
        //cout << "itr : " << *itr << endl;
        ll t = 1<<30;
        for(int i = 30; i >= 0; i--)
        {
            ll val = t - *itr;
            if(val <= 0) break;
            auto it = mst.find(val);
            if(it != mst.end() && it != itr) 
            {
                mst.erase(it);
                ans++;
                break;
            }
            t /= 2;
        }
        mst.erase(itr);
        //for(auto x : mst) cout << x << " "; cout << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String str = sc.next();
      char[] array = str.toCharArray();
      int count = 0;
      for(int i = 0;i < array.length;i++){
      	if(array[i] == '1'){
        	count++;
        }
      }
      System.out.println(count);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    LL x,y;
    cin >> x >> y;
    int count=0;
    while(y>=x){
        y/=2;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
            using namespace std;
             
            int main()
            {
              int N,X,T,n;
              cin>>N>>X>>T;
              if (N%X==0)
              {
                n=(N/X);
              }
              else
              {
                 n = (N/X)+1;
              }
              cout<<n*T;
              
              return 0;
            }

Measured memory_bytes: 3148
#include <stdio.h>

int main(void) {
  char c;

  scanf("%c", &c);

  switch(c) {
    case 'A':
      printf("T\n");
      break;
    case 'T':
      printf("A\n");
      break;
    case 'G':
      printf("C\n");
      break;
    case 'C':
      printf("G\n");
      break;
    default:
      break;
  }

  return 0;
}


Measured memory_bytes: 128
//Moh_K_Imar .......
//22/08/2020  ... 12,36 .
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    cout<<ceil(a/2.0)<<endl;

    return 0;
}



Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   
  string s,t;
  cin >> s >> t;
  int ans=0;

 rep(i,s.length()){
     if(s[i]!=t[i])
     ans ++;
 }

 cout << ans << endl;

 return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i{}; i < n; ++i) {
    for (int j{}; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  vector<int> b(m);
  for (int j{}; j < m; ++j) {
    cin >> b[j];
  }
  for (int i{}; i < n; ++i) {
    int c{};
    for (int j{}; j < m; ++j) {
      c += a[i][j] * b[j];
    }
    cout << c << endl;
  }
  return 0;
}



Measured memory_bytes: 3144
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		if(s[s.length-1].equals("1") ||s[s.length-1].equals("0") || s[s.length-1].equals("6")||s[s.length-1].equals("8")){
			System.out.println("pon");
		} else if(s[s.length-1].equals("3")){
			System.out.println("bon");
		} else {
			System.out.println("hon");
		}
		
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


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

int main(){
  int M,K;
  cin >> M >> K;

  if(M==1){
    if(K==0)  cout << "0 0 1 1" << endl;
    else  cout << -1 << endl;
    return 0;
  }
  if((1<<M)<=K){
    cout << -1 << endl;
    return 0;
  }

  cout << K;
  for(int i=0;i<(1<<M);i++) if(i!=K)  cout << " " << i;
  cout << " " << K;
  for(int i=(1<<M)-1;i>=0;i--) if(i!=K)  cout << " " << i;
  cout << endl;

  return 0;
}

Measured memory_bytes: 1792
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int cur[100111],ok[100111],n,m;
int main()
{
	get2(n,m);
	ok[1]=1;for(int i=1;i<=n;i++)cur[i]=1;
	for(int i=1,x,y;i<=m;i++)
	{
		get2(x,y);cur[x]--;cur[y]++;
		if(ok[x])ok[y]=1;if(cur[x]==0)ok[x]=0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans+=ok[i];
	printendl(ans);
	return 0;
}

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

#define MAX_V 100010
using namespace std;
vector<int> G[MAX_V];
vector<int> l[MAX_V];
bool used[MAX_V];
int n,m;

void dfs(int s){
	used[s] = true;
	for(int i=0;i<G[s].size();i++){
		int e = G[s][i];
		if(!used[e]){
			dfs(e);
		}
	}
}

int main(){
	int i,j;
	cin >> n >> m;
	for(i=0;i<n;i++){
		int k;
		cin >> k;
		for(j=0;j<k;j++){
			int x;
			cin >> x;
			l[x].push_back(i);
		}
	}
	for(i=1;i<=m;i++){
		for(j=1;j<l[i].size();j++){
			G[l[i][j-1]].push_back(l[i][j]);
			G[l[i][j]].push_back(l[i][j-1]);
		}
	}
	for(i=0;i<n;i++){
		used[i] = false;
	}
	dfs(0);
	for(i=0;i<n;i++){
		if(!used[i]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 11640
#include <iostream>
#include <bits/stdc++.h>
#define mod 100000000000000000
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

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

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

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    for(int i=0; i<a.size(); i++){
        if(a[i]!='0'){swap(a[i],a[0]); break;}
    }
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int main()
{
    Fastio();
    int n; cin>>n;
    vector<int>a(n),b(n),c;
    for(int i=0; i<n; i++){cin>>a[i];}
    for(int i=0; i<n; i++){cin>>b[i];}
    c=a;
    sort(c.begin(), c.end());
    int x1,x2,s=0;
    do{
        s++;
        bool st=1;
        for(int i=0; i<n; i++){
            if(c[i]!=a[i]){st=0; break;}
        }
        if(st)x1=s;
        st=1;
        for(int i=0; i<n; i++){
            if(c[i]!=b[i]){st=0; break;}
        }
        if(st)x2=s;
    }while(next_permutation(c.begin(), c.end()));
    cout<<abs(x1-x2)<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N, K;
long long h[100010];
long long dp[100100];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    for (int i = 0; i < 100100; ++i) dp[i] = INF;
    
    dp[0] = 0;
    
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792