akhauriyash/Code-Regression huggingface dataset:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,c=MI()
colors=[LI() for i in range(c)]
grid=[LI() for i in range(n)]
lis0=[]
lis1=[]
lis2=[]
for i in range(n):
    for j in range(n):
        if (i+j)%3==0:
            lis0.append(grid[i][j]-1)
        elif (i+j)%3==1:
            lis1.append(grid[i][j]-1)
        else:
            lis2.append(grid[i][j]-1)
#print(grid)
c0=Counter(lis0)
c1=Counter(lis1)
c2=Counter(lis2)
ind=[i for i in range(c)]
mn=inf
for i in product(ind,repeat=3):
    ans=0
    if i[0]==i[1] or i[1]==i[2] or i[2]==i[0]:
        continue
    #print(i[0],i[1],i[2])
    for x in c0.keys():
        #print(x,i[0])
        ans+=c0[x]*colors[x][i[0]]
    for y in c1.keys():
        #print(y,i[1])
        ans+=c1[y]*colors[y][i[1]]
    for z in c2.keys():
        #print(z,i[2])
        ans+=c2[z]*colors[z][i[2]]
    if ans<mn:
        mn=ans
print(mn)

        
    


    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int H = in.nextInt();
		int W = in.nextInt();
		System.out.println((N - H + 1) * (N - W + 1));

	}

}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main()
{
int A,B,C,K;
cin>>A>>B>>C>>K;
int m=max(A,max(B,C));
int n=A+B+C-m;
	for(int i=1;i<=K;i++)
		m=m*2;
cout<<m+n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int f(int y,int m,int d){
	return (y-1)/3*590+(y-1)%3*39*5+(m-1)/2*(39+!(y%3))+(m-1)%2*20+d;
}
int main(){
	while(1){
		int a,l;
		cin>>a>>l;
		if(!l)break;
		int d[21]={a};
		REP(i,1,20){
			int b[l],c[l];
			int t=d[i-1];
			rep(j,l){
				b[j]=c[j]=t%10;
				t/=10;
			}
			sort(b,b+l);
			reverse(b,b+l);
			sort(c,c+l);
			int bb=0,cc=0;
			rep(j,l)bb=bb*10+b[j];
			rep(j,l)cc=cc*10+c[j];
			d[i]=bb-cc;
		}
		REP(i,1,20){
			rep(j,i){
				if(d[i]==d[j]){
					cout<<j<<" "<<d[i]<<" "<<i-j<<endl;
					goto END;
				}
			}
		}
		END:;
	}
	return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0 ; i < 5 ; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0 ; i < 5 ; i++) {
            if (a[i] == 0) {
                System.out.println(i+ 1);
                return;
            }
        }

    }

}

Measured memory_bytes: 35660
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
using ll = long long;
int main(){
  int a,b,c;
  cin >> a >>b >> c;
  
  int f = a-b;
  int z = (c >= f)?c-f:0;
  cout << z<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
connected = []
remain = []
for n in range(N):
    connected.append([])
    remain.append(n)
for _ in range(M):
    a, b = map(int, input().split())
    connected[a-1].append(b-1)
    connected[b-1].append(a-1)
    

ans = 0
node = 0
remain.remove(0)

def find_next_node(remain_arr, current_node):
    global ans
    if remain_arr == []:
        ans += 1
        return
    for next_node in connected[current_node]:
        if next_node in remain_arr:
            find_next_node([i for i in remain_arr if i != next_node], next_node)

find_next_node(remain, 0) 
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
map<ll,ll> help;
int main(){
	
    ll j,n,k;
    map<ll,ll> help;
    cin>>n;
    ll s=0;
    for(ll i=1;i<=n;i++)cin>>j,help[j]++,s+=j;
    ll q;
    cin>>q;
    while(q--){
    	ll b,c;
    	cin>>b>>c;
    	s-=help[b]*b;
        s+=help[b]*c;
    	help[c]+=help[b];
    	help[b]=0;
    	cout<<s<<endl;
	}
	
    
    
}
    


	
	
    



Measured memory_bytes: 9364
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T>typename make_signed<decltype(T() % 0)>::type size(T a) { return a; }
#define REP(t,a,N)for(decltype(size(N))t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(decltype(size(N))t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)begin(a),end(a)

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  int h, w, n;
  in, h, w, n;
  map<int, map<int, char>> m;
  vector<ll> ans(10);
  rep(i, n) {
    int a, b;
    in, a, b;
    a--, b--;

    rep(i, -1, 2)if (1 <= i + a && i + a < h - 1) rep(j, -1, 2) if (1 <= j + b&&j + b < w - 1) {
      auto &tmp = m[i + a][j + b];
      if (tmp++) {
        ans[tmp - 1]--;
      }
      ans[tmp]++;
    }
  }
  ll a = ll(h - 2) * (w - 2);
  ans[0] = a - std::accumulate(all(ans), 0l);
  for (auto& i : ans) {
    cout << (i) << endl;
  }
}


Measured memory_bytes: 70656
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String s = br.readLine();
        int ans = 0;
        
        for(int i = 0; i < 3; i++){
            if(s.charAt(i) == '1'){
                ans++;
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector <int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data[i];
  }
  sort(data.begin(), data.end());
  int border = N / 2;
  int a = data[border];
  int b = data[border - 1];
  int ans = a - b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i <= (b); i++ )
#define per(i, a, b) for ( int i = (b); i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans = -1, h, w, d[1005][1005];
char a[1005][1005];

int main(void) {
    cin >> h >> w;
    rep(i, 0, h-1) scanf("%s", a[i]);
    memset(d, 0x3f, sizeof(d));
    rep(i, 1, h) rep(j, 1, w) {
        if (a[i-1][j-1]=='#') d[i][j] = 0;
    }

    rep(hi, 1, h) {
        rep(wi, 1, w) d[hi][wi] = min(d[hi][wi], d[hi][wi-1]+1);
        per(wi, 1, w) d[hi][wi] = min(d[hi][wi], d[hi][wi+1]+1);
    }

    rep(wi, 1, w) {
        rep(hi, 1, h) d[hi][wi] = min(d[hi][wi], d[hi-1][wi]+1);
        per(hi, 1, h) d[hi][wi] = min(d[hi][wi], d[hi+1][wi]+1);
    }

    rep(i, 1, h) rep(j, 1, w) ans = max(ans, d[i][j]);

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; ++i){cin >> h[i];}
    sort(h.begin(), h.end(), greater<int>());
    ll cnt = 0;
    for(int i=k; i<n; ++i){
        cnt += h[i];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=105;
ll f[N][N][N],g[N][N][N],mod2;
int c[N][N],ycf[N][N][N],ycg[N][N][N],mod;
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	int n=read(),m=read(),K=read(); mod=read(); mod2=(ll)mod*mod*7;
	For(i,1,K)For(k,0,m){
		ll xs=(ksm(i,m-k)-ksm(i-1,m-k)+mod)*ksm(K-i+1,k)%mod; 
		For(l,ycf[i][k][0]=1,n)ycf[i][k][l]=ycf[i][k][l-1]*xs%mod;
	}
	For(i,1,K)For(j,0,n){
		ll xs=(ksm(K-i+1,j)-ksm(K-i,j)+mod)*ksm(i,n-j)%mod;
		For(l,ycg[i][j][0]=1,m)ycg[i][j][l]=ycg[i][j][l-1]*xs%mod;
	}
	For(i,0,max(n,m))For(j,c[i][0]=1,i)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	f[1][0][0]=1;
	For(i,1,K){
		For(j,0,n)For(k,0,m){
			f[i][j][k]%=mod; g[i][j][k]%=mod;
			For(l,0,n-j){
				g[i][j+l][k]+=f[i][j][k]*c[n-j][l]%mod*ycf[i][k][l];
				if(g[i][j+l][k]>=mod2)g[i][j+l][k]-=mod2;
			}
			For(l,0,m-k){
				f[i+1][j][k+l]+=g[i][j][k]*c[m-k][l]%mod*ycg[i][j][l];
				if(f[i+1][j][k+l]>=mod2)f[i+1][j][k+l]-=mod2;
			}
		}
	}
	cout<<f[K+1][n][m]%mod<<endl;
}

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

#define ll long long
#define MAX 100001

int main() {
    int a, b, c , d, left = 0, right = 0;
    cin >> a >> b >> c >> d;

    left = a + b;
    right = c + d;

    if (left == right) cout << "Balanced" << endl;
    else if (left > right) cout << "Left" << endl;
    else cout << "Right" << endl;
}


Measured memory_bytes: 256
set = 0
card = []
while True:
    card.append("".join(list(input())))
    if card[set] == "-":
        del card[set]
        break
    n = int(input())
    i = 0
    while n > i:
        h = int(input())
        a = "".join(list(card[set])[0:h])
        b = "".join(list(card[set])[h:])
        card[set] = b + a
        i += 1
    set += 1

for r in card:
    print(r)



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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n;
    cin >> n;
    ll A[n];
    FOR(i, 0, n) {cin >> A[i];}
    sort(A, A + n);
    reverse(A, A + n);
    vector<ll> duplicates;
    FOR(i, 0, n-1) {
        if (A[i] == A[i+1]) {
            duplicates.pb(A[i]);
            i++;
        }
    }
    if (duplicates.size() < 2) {
        cout << 0 << "\n"; 
    } else {
        cout << duplicates[0]*duplicates[1] << "\n";
    }
    return 0;
}
 

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
void read(pp& x){ scanf("%d%d",&x.first, &x.second); }
void read(pll& x){ scanf("%lld%lld",&x.first, &x.second); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define sz(x) (int)(x).size()

int main()
{
	vector<ll> pos, neg;
	int n, k;
	read(n, k);
	rep(i, n){
		int x; read(x);
		if(x>0) pos.pb(x);
		else neg.pb(-x);
	}
	reverse(all(neg));

	ll ans = (1ll<<60);
	if(sz(pos) >= k) ans = min(ans, pos[k-1]);
	if(sz(neg) >= k) ans = min(ans, neg[k-1]);

	for(int i=1; i<k; ++i){
		if(sz(pos) >= i && sz(neg) >= k-i){
			ans = min(ans, pos[i-1] + neg[k-i-1] + min(pos[i-1], neg[k-i-1]));
		}
	}

	printf("%lld\n", ans);

	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> arr(n);
	for(int i=0; i<n; ++i){
		cin>>arr[i];
	}
	vector<bool> dp(k+1,false);
	for(int i=0; i<=k; ++i){
		for(int j=0; j<n; ++j){
			if( arr[j] <= i and dp[i-arr[j]] == false){
				dp[i] = true;
			}
		}
	}
	dp[k] ? cout<<"First\n" : cout<<"Second\n";

	return 0;
}


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

int main() {
  int k;
  int kisu,gusu;
  int kekka;
  
  cin >> k;
  
  if(k % 2 == 0){
    kisu = k / 2;
    gusu = k / 2;
  }else{
    kisu = k / 2 +1;
    gusu = k / 2;
  }
  
  kekka = kisu * gusu;
  cout << kekka;
}


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

int main(){
  ll X, Y, A, B, C, i, j, t = 0, ans = 0;
  vector<ll> p(100000), q(100000), r(100000), box(200000);
  cin >> X >> Y >> A >> B >> C;
  rep(i, A){
    cin >> p[i];
  }
  rep(i, B){
    cin >> q[i];
  }
  rep(i, C){
    cin >> r[i];
  }
  
  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  sort(r.begin(), r.end(), greater<ll>());
  
  rep(i, X){
    box[i] = p[i];
  }
  rep(j, Y){
    box[i] = q[j];
    i++;
  }
  
  sort(box.begin(), box.begin() + i);
  
  rep(j, i){
    if(box[j] < r[t]){
      box[j] = r[t];
      t++;
    } else {
      break;
    }
    if(t >= C) break;
  }
  
  rep(j, i){
    ans += box[j];
  }
  
  cout << ans << endl;
  
  return 0;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((c+b-a)>=0)cout<<(c+b-a)<<'\n';
	else 
		cout<<0<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String c[] = new String[n];
        Set<String> colors = new HashSet<>();
        for (int i=0;i<n;i++){
            c[i] = scanner.next();
            colors.add(c[i]);
        }
        if (colors.size() == 3) {
            System.out.println("Three");
        }else{
            System.out.println("Four");
        }
    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int h, w;
int a[80][80];
int b[80][80];

const int kMax = 80 * 80 * 2;

using bs = bitset<kMax + 1>;
bs dp[81][81];

int main() {
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  dp[0][1][0] = true;
  rep(i, h) rep(j, w) {
    int diff = abs(a[i][j] - b[i][j]);
    for (int d = 0; d <= kMax; ++d) {
      if (dp[i][j + 1][d] || dp[i + 1][j][d]) {
        dbg(i, j, d, diff);
        dp[i + 1][j + 1][abs(d - diff)] = true;
        if (d + diff <= kMax) {
          dp[i + 1][j + 1][diff + d] = true;
        }
      }
    }
  }
  rep(i, kMax + 1) if (dp[h][w][i]) {
    out(i);
    return 0;
  }
}


Measured memory_bytes: 10496
n = int(input())
t = input()
b = input()

dp = [0] * n
mod = 10 ** 9 + 7

if t[0] == b[0]:
    dp[0] = 3
else:
    dp[0] = 6

for i in range(1, n):
    if t[i] == t[i-1]:
        dp[i] = dp[i-1]
    else:
        if t[i-1] == b[i-1]:
            if t[i] == b[i]:
                dp[i] = dp[i-1] * 2 % mod
            else:
                dp[i] = dp[i-1] * 2 % mod
        else:
            if t[i] == b[i]:
                dp[i] = dp[i-1] % mod
            else:
                dp[i] = dp[i-1] * 3 % mod

print(dp[-1])


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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(2,vector<int>(N));
  for(vector<int> &i:A)
    for(int &j:i)
      cin>>j;
  vector<int> B(N+1),C(N+1);
  B[0]=0;
  C[N]=0;
  for(int i=0;i<N;i++)
    B[i+1]=B[i]+A[0][i];
  for(int i=N-1;i>=0;i--)
    C[i]=C[i+1]+A[1][i];
  int j=0;
  for(int i=0;i<N;i++)
    j=max(j,B[i+1]+C[i]);
  cout<<j<<endl;
}

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

int main() 
{
    int i, j;
    int h, w; cin >> h >> w;
    bool consecutive = true;
    vector<int> row_index(1, -1);
    vector<vector<char>> board(h, vector<char>(w));
    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            cin >> board.at(i).at(j);
        }
    }

    for (i=0; i<h; i++)
    {
        consecutive = true;
        for (j=0; j<w; j++)
        {
            if (board.at(i).at(j) == '#') consecutive = false;
        }

        if (consecutive)
        {
            row_index.push_back(i);
            for (j=0; j<w; j++)
            {
                board.at(i).at(j) = 'n';
            }
        }
    }

    for (i=0; i<w; i++)
    {
        consecutive = true;
        for (j=0; j<h; j++)
        {
            if (board.at(j).at(i) == '#') consecutive = false;
        }

        if (consecutive)
        {
            for (j=0; j<h; j++)
            {
                board.at(j).at(i) = 'n';
            }
        }
    }

    bool row = true;
    for (i=0; i<h; i++)
    {
        row = true;
        for (j=0; j<w; j++)
        {
            for (int x : row_index) if (x == i) {row = false; break;}
            if (board.at(i).at(j) != 'n')
            {
                cout << board.at(i).at(j);
            }
        }
        if (row) cout << endl;
    }
}



Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;

typedef long long ll;

struct Movie
{
	int num, a, b;
	bool isUsed;
	Movie()
	{
		a = 0;
		b = 1e9;
		isUsed = false;
	}

	bool operator < (const Movie &a) const
	{
		if (isUsed != a.isUsed)
		{
			return isUsed;
		}
		return b > a.b;
	}
};

int main(){
	int N;
	Movie movie[100];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> movie[i].a >> movie[i].b;
		movie[i].num = i;
	}

	int ans = 0;
	for (int i = 1; i <= 31; i++)
	{
		Movie ma = Movie();
		ma.isUsed = true;
		for (int j = 0; j < N; j++)
		{
			if(i < movie[j].a || movie[j].b < i) continue;
			ma = max(ma, movie[j]);
		}
		movie[ma.num].isUsed = true;
		if (ma.isUsed) ans += 50;
		else ans += 100;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n;
        ll a[n];
        FOR(i,0,n)  cin>>a[i];
        k=1;
        FOR(i,1,n)
        {
            int fl=1;
            RFOR(j,i-1,0)
                if(a[j]>a[i]){
                    fl=0;
                }
            if(fl)
                k++;
        }
        cout<<k<<endl;
    }
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  vector<p> lr(m);
  for (int i = 0; i < m; i++) {
    cin >> lr[i].first >> lr[i].second;
    // lr[i].first--;
    // lr[i].second--;
  }
  vector<p> query(q);
  for (int i = 0; i < q; i++) {
    cin >> query[i].first >> query[i].second;
    // query[i].first--;
    // query[i].second--;
  }
  vector<vector<int>> area(n+1, vector<int>(n+1, 0));
  for (int i = 0; i < m; i++) {
    int start = lr[i].first;
    int goal = lr[i].second;
    area[start][goal]++;
  }
  // print(area);

  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      area[i][j] += area[i][j-1];
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      area[j][i] += area[j-1][i];
    }
  }

  // print(area);
  for(auto a : query){
    int minv = min(a.first, a.second);
    int maxv = max(a.first, a.second);
    int res = area[maxv][maxv] + area[minv-1][minv-1];
    // cout << res << endl;
    res -= (area[maxv][minv-1] + area[minv-1][maxv]);
    cout << res << endl;
    // cout << "====" << endl;
  }
}


Measured memory_bytes: 4352
#include<cstdio>
using namespace std;
int n,m,c[26],sum1,sum2;;
char ch[105];
int main(void){
	register int i,j,k;
	scanf("%d%d",&n,&m);
	sum1=((n&1)&(m&1)),
	sum2=m*(n&1)+n*(m&1)-2*sum1;
	for(i=1;i<=n;++i){
		scanf("%s",ch);
		for(j=0;j<m;++j)++c[ch[j]-'a'];
	}
	for(i=0;i<26;++i){
		if(c[i]&1)--sum1;
		if(c[i]%4>=2)sum2-=2;
		if(sum1<0||sum2<0){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cassert>
#include <fstream>
#include <sstream>
#include <math.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <time.h>
#include <stdio.h>
#include <deque>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

ll N;

void solve() {

}

int main() {
	cin >> N;

	ll ans = N * (1 + N) / 2;

	cout << ans << endl;

	return 0;
}


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

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

struct Adj{
	int v, w;
};
vector<Adj> a[N];

int dis[N];

void Dijkstra(){
	memset(dis, 0x3f, sizeof(dis));
	priority_queue<pint, vector<pint>, greater<pint> > q;
	dis[1] = 1;
	q.push(make_pair(1, 1));
	static bool vst[N];
	
	while(!q.empty()){
		int u = q.top().se; q.pop();
		if(vst[u]) continue;
		vst[u] = 1;
		for(auto e: a[u]){
			if(dis[e.v] > dis[u] + e.w){
				dis[e.v] = dis[u] + e.w;
				q.push(make_pair(dis[e.v], e.v));		
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(0);

	int n; cin >> n;
	for(int i=0; i<n; i++){
		a[i].push_back((Adj){i * 10 % n, 0});
		a[i].push_back((Adj){(i + 1) % n, 1});
	}
	Dijkstra();
	cout << dis[0] << endl;

	return 0;
}

Measured memory_bytes: 6908
N,M = map(int,input().split())
MOD = 10**9+7

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

fac = [1,1] + [0]*(N+100)
finv = [1,1] + [0]*(N+100)
inv = [0,1] + [0]*(N+100)
for i in range(2,N+102):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 1
facs = factorize(M)
for v in facs.values():
    ans *= ncr(N+v-1,v)
    ans %= MOD
print(ans)

Measured memory_bytes: 15972
X = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    # パターン１
    return is_prime

arr =primes(10**5+100)

for i in range(X,10**5+100,1):
    if arr[i]:
        print(i)
        exit()

Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, s, n) for(int i = s; i <= (int)n; ++i)
#define per(i, n) for(int i = n; i > 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define int long long
static const int INF = 1ll<<60ll;
static const int dx[] = { -1, 0, 1, 0 };
static const int dy[] = { 0, -1, 0, 1 };
int n,m;
int ans;
int cost[150];
int used[150];
int V[150][150];

int prim(){
    int res=0;
    cost[0]=0;
    while(1){
        int v=-1;
        rep(i,n){
            if(used[i]!=1&&v==-1)v=i;
            else if(used[i]!=1&&cost[i]<cost[v])v=i;
        }
        if(v==-1)break;
        used[v]=1;
        res+=cost[v];
        rep(i,n){
            cost[i]=min(cost[i],V[v][i]);
        }
    }
    return res;
}

signed main(){
    while(1){
        rep(i,150){
            used[i]=0;
            cost[i]=INF;
        }
        rep(i,150)rep(j,150)V[i][j]=INF;
        cin>>n;
        if(n==0)break;
        cin>>m;
        rep(i,m){
            int x,y,z;
            char c;
            cin>>x>>c>>y>>c>>z;
            V[x][y]=z/100-1;
            V[y][x]=z/100-1;
        }
        cout<<prim()<<endl;
    }
    return 0;
}

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

class Program {
    static void Main (string[] args) {
        var p = Console.ReadLine ().Split (' ');
        long N = long.Parse (p[0]);
        long M = long.Parse (p[1]);

        long[] x = new long[10000];
        long[] y = new long[10000];
        long[] z = new long[10000];
        long[] v = new long[10000];

        List<long>[] w = new List<long>[8];
        for (int i=0;i<8;i++){
            w[i] = new List<long>();
        }

        for (int i = 0; i < N; i++) {
            var p2 = Console.ReadLine ().Split (' ');
            x[i] = long.Parse (p2[0]);
            y[i] = long.Parse (p2[1]);
            z[i] = long.Parse (p2[2]);

            v[i] = (long) (Math.Abs (x[i]) + Math.Abs (y[i]) + Math.Abs (z[i]));

            // w[0][i] = x[i] + y[i] + z[i];
            // w[1][i] = x[i] + y[i] - z[i];
            // w[2][i] = x[i] - y[i] + z[i];
            // w[3][i] = x[i] - y[i] - z[i];
            // w[4][i] = -x[i] + y[i] + z[i];
            // w[5][i] = -x[i] + y[i] - z[i];
            // w[6][i] = -x[i] - y[i] + z[i];
            // w[7][i] = -x[i] - y[i] - z[i];


            w[0].Add(x[i] + y[i] + z[i]);
            w[1].Add( x[i] + y[i] - z[i]);
            w[2].Add( x[i] - y[i] + z[i]);
            w[3].Add( x[i] - y[i] - z[i]);
            w[4].Add( -x[i] + y[i] + z[i]);
            w[5].Add( -x[i] + y[i] - z[i]);
            w[6].Add( -x[i] - y[i] + z[i]);
            w[7].Add( -x[i] - y[i] - z[i]);


        }

        for (int i = 0; i < 8; i++) {
            w[i].Sort ();
            w[i].Reverse ();
        }

        long output = -100000;
        for (int j = 0; j < 8; j++) {
            long value = 0;
            for (int i = 0; i < M; i++) {
                value += w[j][i];
            }
            if (value > output){
                output = value;
            }
        }

 
  Console.WriteLine (output);

    }
}

Measured memory_bytes: 13356
while True:
    n = int(raw_input())
    if n == 0:
        break

    bridge = {}

    for i in range(n):
        m, a, b = map(int, raw_input().split())
        if a in bridge:
            bridge[a] += m
        else:
            bridge[a] = m

        if b in bridge:
            bridge[b] -= m
        else:
            bridge[b] = -m

    w = 0
    for key in sorted(bridge.keys()):
        w += bridge[key]
        if w > 150:
            break

    print "OK" if w <= 150 else "NG"

Measured memory_bytes: 4256
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 10;

int cnt[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ++cnt[x];
    sum += x;
  }
  int tt;
  cin >> tt;
  while (tt--) {
    int x, y;
    cin >> x >> y;
    sum -= (ll) cnt[x] * x;
    sum += (ll) cnt[x] * y;
    cnt[y] += cnt[x];
    cnt[x] = 0;
    cout << sum << '\n';
  }
  return 0;
}


Measured memory_bytes: 3948
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	static int INF = (int) 1e9;
	static ArrayList<Integer>[] adjList;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println((x>=30)?"Yes":"No");
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}

	public static int gcd(int a, int b) {
		if (a == 0)
			return b;

		return gcd(b % a, a);
	}

	public static void shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

	public static long square(long l) {
		return l * l;
	}
}


Measured memory_bytes: 32840
import collections

chars = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
         "w", "x", "y", "z"]


def eratosthenes_sieve(n):
    primes = [2]
    for odd in range(3, n + 1, 2):
        for p in primes:
            if odd % p == 0:
                break
            if p ** 2 > odd:
                primes.append(odd)
                break
    return primes


era = eratosthenes_sieve(150)
n = int(input())
array = [0] * n
for i in range(n):
    new = input()
    var = 1

    for j in range(10):
        h = chars.index(new[j])
        var *= era[h]

    array[i] = var

c = collections.Counter(array)
cv = list(c.values())
ans = 0
for i in range(len(c)):
    ans += cv[i] * (cv[i] - 1) // 2

print(ans)


Measured memory_bytes: 17332
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int d;
	cin >> d;
	cout << "Christmas";
	rep(i, 25 - d) {
		cout << " Eve";
	}

	cout << "\n";

	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    var S = readLine()!!
    for(i in (S.length-2 downTo 0)){
        var s = S.slice(0..i)
        if(s.length % 2 != 0) continue
        if(s.slice(0..i/2) == s.slice(i/2 + 1 .. i)){
            println(s.length)
            break
        }
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,K;
    string S;
    cin >> N>>K;
    vector<ll> A(N);
    REP(i,N){
        cin >>A.at(i);
    }

    REP(i,N-K){
        if(A.at(i)<A.at(i+K)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 4780
import math

N=int(input())

t=[]
a=[0]*N

for i in range(N):
    x,y=map(int,input().split())
    t.append([x,y])

for i in range(N):
    for j in range(N):
        if i!=j:
            a[i]+=math.sqrt((t[i][0]-t[j][0])**2+(t[i][1]-t[j][1])**2)
    a[i]/=N-1

print(sum(a)*(N-1)/N)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int N;
    cin >> N;
    int val[N+10][3];
    rep(i,N) rep(j,3) cin >> val[i][j];
    int DP[N+10][3];    
    rep(i,3) DP[0][i] = val[0][i];
    rep1(i,N-1) rep(j,3) DP[i][j] = max(DP[i-1][(j+1)%3], DP[i-1][(j+2)%3]) + val[i][j];
    pr(max({DP[N-1][0],DP[N-1][1],DP[N-1][2]}));
}


Measured memory_bytes: 2560
#include <iostream>
#include <climits>
#include <cstring>
#include <vector>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
const ll maxn = 200010;
const ll mod = 1000000007;

ll arr1[maxn];
ll arr2[maxn];
ll tree[4*maxn];

void update(ll nd, ll b, ll e, ll idx, ll val){
    if(b == e){

        tree[nd] = val;
    }
    else{
        ll mid = (b+e)/2;
        if(b <= idx && idx <= mid)
            update(2*nd,b,mid,idx,val);
        else
            update(2*nd+1,mid+1,e,idx,val);
        tree[nd] = max(tree[2*nd],tree[2*nd+1]);
    }
}
// rmq kortisi
ll query(ll nd, ll b, ll e, ll qb, ll qe){
    if(e < qb || qe < b)    return -inf;
    if(qb <= b && e <= qe)    return tree[nd];
    ll mid = (b+e)/2;
    return max(query(2*nd,b,mid,qb,qe),query(2*nd+1,mid+1,e,qb,qe));
}


int main(){
//    freopen("in.txt","r",stdin);
    ll n;

    scanf("%lld",&n);
    ll ans = 0;
    for(ll i = 1; i <= n; i++)  scanf("%lld",arr1+i);
    for(ll i = 1; i <= n; i++)  scanf("%lld",arr2+i);
    for(ll i = 1; i <= n; i++){
        ll a,b;
        //scanf("%lld %lld",&a,&b);
        ll tempans = query(1,1,n,1,arr1[i]);
        ans = max(ans,tempans+arr2[i]);
        update(1,1,n,arr1[i],tempans+arr2[i]);
    }
    printf("%lld\n",ans);

}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int line = in.nextInt();
		int column = in.nextInt();

		// ???????????????????´?????????????
		int[][] matrix = new int[line][column];
		// ????????????????????????????´?????????????
		int[] vector = new int[column];

		for(int l = 0; l < line; l++) {

			for(int c = 0; c < column; c++) {

				int column_num = in.nextInt();
				matrix[l][c] = column_num;

			}
		}

		for(int c = 0; c < column; c++) {

			int column_num = in.nextInt();
			vector[c] = column_num;

		}

		for(int l = 0; l < line; l++) {

			int ans = 0;

			for(int c = 0; c < column; c++) {

				ans += matrix[l][c] * vector[c];
			}

			System.out.println(ans);

		}
	}
}

Measured memory_bytes: 40236
#pragma warning(disable:4996)
#include<iostream>
#include<cstring>
#include<cstdio>
#include <string.h>
#include<string>
#include <algorithm>
using namespace std;

int main()
{
	string s;
	cin>>s;
	s[5] =s[13]= ' ';
	cout<<s<<endl;	
	//system("pause");
	return 0;
}

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

long int n, a[80], f = -1, kabu = 0, kane = 1000;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
        if ((f * (a[i] - a[i - 1])) < 0) {
            if (f < 0) {
                kabu += kane / a[i - 1];
                kane = kane - a[i - 1] * (kane / a[i - 1]);
                f = 1;
            }
            else if (f > 0) {
                kane += kabu * a[i - 1];
                kabu = 0;
                f = -1;
            }
        }
    }
    kane += kabu * a[n - 1];
    cout << kane << endl;
    return 0;
}

Measured memory_bytes: 3440
def merge(A, left, mid, right):
    L = A[left:mid] + [2147483648]
    R = A[mid:right] + [2147483648]
    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global c
    c += right - left


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


c = 0
n = int(input())
A = list(map(int, input().split()))
mergeSort(A, 0, n)
print(" ".join(map(str, A)))
print(c)



Measured memory_bytes: 66760
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	#define f first
	#define s second
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	//int arr[900006];
	vector<int>v;
	void preprocess(){
		v.push_back(0);
		for(int i=0;i<1000;i++){
			v.pb(v[i]*10+4);
			v.pb(v[i]*10+7);
		}
	}
	int32_t main(){
		IOS;
		string s;
		cin>>s;
		if(s=="ABC") cout<<"ARC"<<endl;
		else cout<<"ABC"<<endl;
		return 0;
	}


Measured memory_bytes: 3656
# import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
from copy import deepcopy
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

a , b = map(int,input().split())
print(a * b )
                





Measured memory_bytes: 9520
#include <iostream>
using namespace std;
#define M 1000

int main(){
    int r,c,mat[M][M];
    
    for(int i = 0 ; i < M ; i++)
        for(int j = 0 ; j < M ; j++)
            mat[i][j] = 0;
    
    cin >> r >> c;
    for(int i = 0 ; i < r ; i++)
        for(int j = 0 ; j < c ; j++)
            cin >> mat[i][j];
    
    for(int i = 0 ; i < r ; i++){
        for(int j = 0 ; j < c ; j++){
            mat[i][c] += mat[i][j];
        }
    }
    
    for(int i = 0 ; i < r ; i++){
        for(int j = 0 ; j < c ; j++){
            mat[r][j] += mat[i][j];
        }
    }
    
    for(int i = 0 ; i < r ; i++){
        for(int j = 0 ; j < c ; j++){
            mat[r][c] += mat[i][j];
        }
    }
    
    for(int i = 0 ; i <= r ; i++){
        for(int j = 0 ; j <= c ; j++){
            if(!j) cout << mat[i][j];
            else cout << ' ' << mat[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
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; }


int main()
{
  cout << fixed << setprecision(10);
  string N;
  cin >> N;
  int n = N.size();
  bool ok = true;
  bool ifok = false;
  if(n==1)
  {
    cout << N << endl;
    return 0;
  }
  rep(i,n)
  {
    if(N[i]!='9'&&i==0)
    {
      ifok = true;
      continue;
    }
    if(N[i]!='9')
    {
      ok = false;
      break;
    }
  }
  if(ifok&&ok)
  {
    int num = N[0] - '0';
    cout << num + 9 * (n-1) << endl;
    return 0;
  }
  if(ok)
  {
    cout << 9 * n << endl;
  }
  else
  {
    int num = N[0] - '1';
    cout << num + 9 * (n-1) << endl;
  }
  return 0;
}


Measured memory_bytes: 3604