akhauriyash/Code-Regression huggingface dataset:
// Your code here!
    #include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  int n,ans=0;
  string s;
  cin>>n>>s;
  rep(i,10){
      rep(j,10){
          rep(k,10){
              bool ans3=false;
              bool ans2=false;
              rep(h,s.size()){
                  
                  if(ans3){
                      
                      if(s.at(h)-'0'==k){
                          ans++;
                          //cout<<i<<" "<<j<<" "<<k<<" "<<"ans3"<<endl;
                          break;
                      }
                  }
                  else if(ans2){
                      if(s.at(h)-'0'==j)ans3=true;//cout<<"ans2"<<endl;
                  }else{
                      if(s.at(h)-'0'==i)ans2=true;//cout<<"ans1"<<endl;
                      
                  }
                  
              }
          }
      }
  }
  cout<<ans<<endl;
}

   
    

   



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i, j, k;
	cin >> n;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	int ans = 0;
	fo(i, 0, n) {
		fo(j, i + 1, n) {
			fo(k, j + 1, n) {
				vector <int> v{arr[i], arr[j], arr[k]};
				sort(all(v));
				if(v[0] + v[1] > v[2] && v[0] != v[1] && v[1] != v[2])
				++ans;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int N;
vector<int> a;

LL dp[3001][3001];  //! [l][r] => answer when the deque is in [l..r] range, of course l <= r
bool done[3001][3001];

LL solve(int l, int r) {
    if (!done[l][r]) {
        if (N%2 == (r-l+1)%2) {
            //! taro's turn
            if (l == r) {
                dp[l][r] = a[l];
            } else {
                dp[l][r] = max(a[l] + solve(l+1,r), a[r] + solve(l,r-1));
            }
        } else {
            //! jiro's turn
            if (l == r) {
                dp[l][r] = -a[l];
            } else {
                dp[l][r] = min(-a[l] + solve(l+1,r), -a[r] + solve(l,r-1));
            }
        }
        done[l][r] = true;
    }

    return dp[l][r];
}

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

    cin >> N;
    a.resize(N);
    rep(i, N) cin >> a[i];

    cout << solve(0, N-1) << endl;

    return 0;
}


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

using namespace std;
 
int main() {
string S;
cin >> S;
if (S.at(0) == S.at(1) && S.at(1) == S.at(2))
{
    cout << "No" <<endl;
}
else
{
    cout << "Yes" <<endl;
}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int n;
vector<ll>x,y,h;
ll cx,cy,ch;
bool solve(){
    rep(i,n){
        ll now = max(ch-abs(x[i]-cx)-abs(y[i]-cy),0LL);
        if(now!=h[i])return false;
    }
    return true;
}

int main(){
    cin >> n;
    x.resize(n);
    y.resize(n);
    h.resize(n);
    rep(i,n)cin>>x[i]>>y[i]>>h[i];
    rep(i,101){
        rep(j,101){
            cx = i;
            cy = j;
            rep(k,n){
                if(h[k]!=0){
                    ch = abs(x[k]-cx) + abs(y[k]-cy) + h[k];
                    break;
                }
            }
            if(solve()){
                cout << cx << ' ' << cy << ' ' << ch << endl;
                return 0;
            }

        }
    }
    return 0;
}


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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n * 2);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        uf.unionSet(a, b + n);
        uf.unionSet(a + n, b);
    }
    long long all = 0;
    if (uf.findSet(0, n)) {
        all = 1LL * n * (n - 1) / 2;
    } else {
        for (int i = 0; i < n; i++) all += uf.findSet(0, i);
        all *= n - all;
    }
    cout << all - m << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 2147483600;

char str[MAXN+1]; int a[MAXN+1];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",str+1); int N=strlen(str+1);
	for(int i=1;i<=N;i++){
		if(str[i]=='B') a[i]=1;
		else a[i]=0;
	} LL ans=0,cnt=0;
	for(int i=N;i>=1;i--){
		if(!a[i]) ++cnt;
		else ans+=cnt; 
	} cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 1280
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

# H <= 2000, W <= 2000
# H*W -> O(4*10^6)
H, W = [int(x) for x in stdin.readline().rstrip().split()]
S = [[x for x in stdin.readline().rstrip()] for _ in range(H)]

# L[i][j]: i行目j列目に明かりを置いたときにそこから左方向に照らされるマスの個数
#          (i行目j列目のマスを含む)
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

# L
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            L[i][j] = 0
            continue

        if j == 0:
            L[i][j] = 1
        # j >= 1
        else:
            L[i][j] = L[i][j-1] + 1

# R
for i in range(H-1, -1, -1):
    for j in range(W-1, -1, -1):
        if S[i][j] == "#":
            R[i][j] = 0
            continue

        if j == W-1:
            R[i][j] = 1
        else:
            R[i][j] = R[i][j+1] + 1

# U
for j in range(W):
    for i in range(H):
        if S[i][j] == "#":
            U[i][j] = 0
            continue

        if i == 0:
            U[i][j] = 1
        else:
            U[i][j] = U[i-1][j] + 1

# D
for j in range(W-1, -1, -1):
    for i in range(H-1, -1, -1):
        if S[i][j] == "#":
            D[i][j] = 0
            continue

        if i == H-1:
            D[i][j] = 1
        else:
            D[i][j] = D[i+1][j] + 1


ans = -INF

for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3)

# for DEBUG
#print(*S, sep="\n")
#print(L)
#print(R)
#print(D)
#print(U)

print(ans)

Measured memory_bytes: 311664
program gridian_mst
  implicit none
  integer :: w, h, i, a, b
  integer(8) :: c(200000,2), m
  c = 0_8
  read(*,*) w, h
  do i = 1, w
    read(*,*) c(i,1)
    c(i,2) = -1_8
  end do
  do i = w+1, w+h
    read(*,*) c(i,1)
    c(i,2) = 1_8
  end do
  call quick_sort(c(1:w+h,1:2),1)
  a = w+1
  b = h+1
  m = 0_8
  do i = 1, w+h
    if (c(i,2).lt.0_8) then
      if (a.eq.0) cycle
      m = m+c(i,1)*int(b,8)
      a = a-1
    else
      if (b.eq.0) cycle
      m = m+c(i,1)*int(a,8)
      b = b-1
    end if
  end do
  write(*,'(i0)') m
  stop
contains
  recursive subroutine quick_sort(a,i)
    implicit none
    integer(8), intent(inout) :: a(:,:)
    integer, intent(in) :: i
    integer(8) p, c(size(a(1,:)))
    integer :: n, l, r
    n = size(a(:,1))
    l = 1
    r = n
    p = a((l+r)/2,i)+a(l,i)+a(r,i)-max(a((l+r)/2,i),a(l,i),a(r,i))-min(a((l+r)/2,i),a(l,i),a(r,i))
    do
      do while (a(l,i).lt.p)
        l = l+1
      end do
      do while (a(r,i).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l,:)
      a(l,:) = a(r,:)
      a(r,:) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1,:),i)
    if (n.gt.r+1) call quick_sort(a(r+1:n,:),i)
    return
  end subroutine quick_sort
end program gridian_mst

Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,x;
    cin>>k>>x;
    FOR(i,0,k*2 - 1){
      cout<<x+i-k+1;
      if(i!=k*2-2)cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 256
N = int(input())
count = 0
ans = []
for i in range(N+1):
    count1 = 0
    count2 = 0
    N1 = N - i
    x = i
    while x:
        count1 += x % 6
        x //= 6
    while N1:
        count2 += N1 % 9
        N1 //= 9
    count = count1 + count2
    ans.append(count)
print(min(ans))


Measured memory_bytes: 3864
#include<stdio.h>

int main()
{
  int a,b,i,sum;
  
  while(scanf("%d %d",&a, &b)!=EOF){
    sum=a+b;

    for(i=0;sum!=0;i++){
      sum=sum/10;
    }
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 600
function main(input) {
    var lines = input.split('\n');
    var line1 = lines[0];
    var line2 = lines[1].split(' ');

    var N = parseInt(line1);

    var aList = line2.map(function (str) { return parseInt(str) });

    var max = aList.reduce(function(prev, curr){
        return Math.max(prev, curr);
    }, aList[0]);

    var halfMax = max / 2;
    var mostCloseToHalf = aList.reduce(function(prev, curr){
        if(prev === max) return curr;
        if(curr === max) return prev;
        return Math.abs(prev - halfMax) <= Math.abs(curr - halfMax) ? prev : curr;
    }, aList[0]);

    console.log(max + ' ' + mostCloseToHalf);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 28208
program test 
implicit none

character(len=100)  s
integer(8) :: i,j,k,l,m,n,a,b,ans,ans2
integer ::ss

ans = 0

read(*,*) s
read(*,*) k

n = len_trim(s)

do i=1,n
read (s(i:i),*) ss

if( ss == 1 ) then
ans = ans + 1
if(ans == k) then
write(*,*) ss
goto 10
endif
else
write(*,*) ss
goto 10
endif

enddo

10 continue

end program

Measured memory_bytes: 768
a_len = int(input())
a_list = list(map(int, input().split(' ')))


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


if a_len == 1:
    print(a_list[0])
else:
    element = gcd(a_list[0], a_list[1])
    if a_len == 2:
        print(element)
    else:
        for i in range(2, a_len):
            element = gcd(element, a_list[i])
        print(element)

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

const int DIM = 1e5 + 5;

int mxm[DIM], arr[DIM];

int main( void ) {
    
    int n, t;
    cin >> n >> t;
    
    int ans = 0, cnt = 0;
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    for( int i = n; i >= 1; i -- ) {
        mxm[i] = max( mxm[i + 1], arr[i] );
        arr[i] = mxm[i] - arr[i];
        
        if( ans < arr[i] ) {
            ans = arr[i];
            cnt = 1;
        } else
        if( ans == arr[i] )
            cnt ++;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N,ans = 0,maxi = 0,mini = INF;
	cin >> N;

	for (int i = 0; i < N; i++) {
		lli A;
		cin >> A;
		CHMAX(maxi, A); CHMIN(mini, A);
	}

	cout << maxi - mini << endl;

	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self,N):
        self.par =[-1 for i in range(N)]
    def find(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.par[x] > self.par[y]:
            x,y = y,x
        self.par[x] +=self.par[y]
        self.par[y] = x

    def size(self,x):
        return -self.par[self.find(x)]
    def same(self,x,y):
        return self.find(x)==self.find(y)

N,M=map(int,input().split(' '))
bridge = [list(map(int,input().split(' '))) for i in range(M)]
ans = N*(N-1)//2
ans_list = [ans]
uf = UnionFind(N)
for a,b in bridge[::-1][:-1]:
    if not uf.same(a-1,b-1):
        A = uf.size(a-1)
        B = uf.size(b-1)
        ans += (A*(A-1)+B*(B-1)-(A+B)*(A+B-1))//2
    ans_list.append(ans)
    uf.unite(a-1,b-1)
for i in ans_list[::-1]:
    print(i)

Measured memory_bytes: 35604
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char str[] = s.toCharArray();
//        char str[] = new char[s.length()];
//        for (int i=0; i<s.length(); i++){
//            str[i] = s.indexOf
//        }

        int i = 0;
        while(i<s.length()){
            int r = 0;
            int l = 0;

            while(i<s.length() && str[i]=='R'){
                r++;
                i++;
            }
            while(i<s.length() && str[i]=='L'){
                l++;
                i++;
            }

            int R;
            int L;

            R = (int)Math.ceil(r/2.0);
            R += (int)l/2.0;

            L = (int)Math.ceil(l/2.0);
            L += (int)r/2.0;

            for (int j=0; j<r-1; j++) System.out.print(0+" ");
            System.out.print(R+" ");
            System.out.print(L+" ");
            for (int j=0; j<l-1; j++) System.out.print(0+" ");

        }

        }

    }


Measured memory_bytes: 39720
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int k;//global variable
bool check(vector<int> v){
	bool ok=true;
	int n=(int)v.size();
  	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
		  if((v[j]-v[i])>k){
			   ok=false;break; 
			 }
		}
	}
	return ok;
}
void solve(){
  vector<int> v(5);
  for(auto &it:v)cin>>it;
  cin>>k;
  cout<<(check(v)?"Yay!":":(")<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
// ABC098_C
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

int main(void)
{

    int N, reader_num, change_person, min;
    string str;

    cin >> N;
    cin >> str;

    change_person = 0;

    // 最も西の人をリーダーにした場合について、まず考える
    for(int i = 1; i < N; i++)
    {
        if( str[i] == 'E' )
        {
            // リーダーより東で, 東を向いている人は西を向いてもらう
            change_person++;
        }
    }

    // 最小値の初期値
    min = change_person;
    reader_num = 1;
    // change_personは方向を変える人の状態変数としてゼロで初期化しない

    // リーダーになる人を東方向に順番に移動させていく
    // リーダーより西の人の状態と, リーダの状態のみ考える
    // ( リーダー前後以外の状態は、変化しないはず )
    while( reader_num < N )
    {

        if( str[reader_num - 1] == 'W' )
        {
            // リーダーより西で, 西を向いている人は東を向いてもらう
            change_person++;
        }

        if( str[reader_num] == 'E' )
        {
            // リーダー自身が東を向いていたら, 方向を変える人が一人減る
            change_person--;
        }

        // リーダより東側は最初に検討しているので、状態は変わらない
        /*
        if( str[reader_num + 1] == 'E' )
        {
            // リーダーより東で, 東を向いている人は西を向いてもらう
            change_person++;
        }
        */

        if( change_person < min )
        {
            // 最小値を検索する
            min = change_person;
        }

        reader_num++;
    }

    printf("%d\n", min);

    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	string s;
	cin>>s;
	for(auto&i:s)if(i=='?')i='D';
	cout<<s<<'\n';
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n;
int P[100001];
int Q[100001];
int L[100001];
int R[100001];
int A[100001];
int B[100001];
int T[100001];
int X[100001];

void init(int v[]) {
    for (int i = 1; i <= n; ++i) v[i] = i;
}

void add(int v[], int s[]) {
    for (int i = 1; i <= n; ++i) {
        T[i] = s[v[i]];
    }
    for (int i = 1; i <= n; ++i) {
        v[i] = T[i];
    }
}

void move(int v[], int s[]) {
    for (int i = 1; i <= n; ++i) {
        v[i] = s[i];
    }
}

void print(int v[]) {
    for (int i = 1; i <= n; ++i) {
        printf("%d ", v[i]);
    }
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> P[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> Q[i];
    }
    if (k == 1) print(P);
    if (k <= 100) {
        for (int i = 3; i <= k; ++i) {
            init(X);
            for (int j = 1; j <= n; ++j) L[P[j]] = j;
            add(X, L);
            add(X, Q);
            move(P, Q);
            move(Q, X);
        }
        print(Q);
    }
    for (int i = 1; i <= n; ++i) {
        L[P[i]] = i;
        R[Q[i]] = i;
    }
    init(X);
    add(X, R);
    add(X, P);
    add(X, Q);
    add(X, L);
    move(A, X);
    init(X);
    int pw = (k - 2) / 6;
    while (pw) {
        if (pw & 1) {
            add(X, A);
        }
        init(B);
        add(B, A);
        add(B, A);
        move(A, B);
        pw >>= 1;
    }
    move(A, X);
    for (int i = 1; i <= n; ++i) B[A[i]] = i;
    init(X);
    switch(k % 6) {
    case 0:
        add(X, A);
        add(X, R);
        add(X, P);
        add(X, P);
        add(X, R);
        add(X, L);
        add(X, Q);
        add(X, B);
        break;
    case 1:
        add(X, A);
        add(X, R);
        add(X, P);
        add(X, Q);
        add(X, P);
        add(X, R);
        add(X, L);
        add(X, Q);
        add(X, B);
        break;
    case 2:
        add(X, A);
        add(X, Q);
        add(X, B);
        break;
    case 3:
        add(X, A);
        add(X, L);
        add(X, Q);
        add(X, B);
        break;
    case 4:
        add(X, A);
        add(X, R);
        add(X, L);
        add(X, Q);
        add(X, B);
        break;
    case 5:
        add(X, A);
        add(X, R);
        add(X, P);
        add(X, R);
        add(X, L);
        add(X, Q);
        add(X, B);
        break;
    }
    print(X);
    return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		while (true)
		{
			int n = sc.nextInt();
			if (n == 0)
			{
				break;
			}
			int[] scores = new int[n];
			for (int i = 0; i < n; i++)
			{
				scores[i] = sc.nextInt();
			}

			double sd = getStandardDeviation(scores);

			System.out.println(sd);
		}
	}

	static double getStandardDeviation(int[] data)
	{
		int sum = 0;
		for (int d :
				data)
		{
			sum += d;
		}

		double ave = (double) sum / data.length;

		double sumSquareDeviation = 0.0;
		for (int d :
				data)
		{
			sumSquareDeviation += Math.pow(d - ave, 2);
		}

		double variance = sumSquareDeviation / data.length;

		double standardDeviation = Math.sqrt(variance);

		return standardDeviation;
	}
}



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

int main(){
    int64_t N, i, step, record = 1000000000000;

    cin >> N;

    for(i = 1; i < 1000001; i++){
        if(N % i == 0){
            step = (i-1) + (N/i - 1);
            if(record > step)record = step;
            else break;
        }
    }
    cout << record <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

ll d[int(1e7) + 1];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    memset(d, 0, sizeof(d));

    ll ans = 0;
    FOR(i, 1, N+1) {
        for(int j = i; j <= N; j += i) ans += j;
    }

    print(ans);
    
}


Measured memory_bytes: 81744
#include <bits/stdc++.h>
using namespace std;
//A<B<Cを満たす
int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        if (a >= b)
        {
            b = b * 2;
        }
        else if (b >= c)
        {
            c = c * 2;
        }
    }
    if (a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int  n;
    int a[2] ;
    a[0] = 0;
    a[1] = 0;

    for(int i = 0; i < 3 ; i++){
        cin >> n ;
        
        if(n == 5){
            a[0]++;
        }else if(n == 7){
            a[1]++;
        }
    } 

    if(a[0]==2 &&a[1]==1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, a[2000 + 4];
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + 1 + n);
	LL ans = 0;
	for (int i = 1; i <= n - 2; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int A = a[i], B = a[j];
			LL gg = lower_bound(a + 1, a + 1 + n, A + B) - a - 1 - 1;
			//LL hh = lower_bound(a + 1, a + 1 + n, max(max(A - B, B - A), B + 1)) - a;
			ans += max(0ll, gg - j + 1);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k,count=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0)
      count++;
  }
  if(count==0)
    cout<<"NG"<<endl;
  else
    cout<<"OK"<<endl;
}

Measured memory_bytes: 3676
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	nums := io.ScanInts(n)
	numCountMap := map[int]int{}
	for _, n := range nums {
		numCountMap[n]++
	}
	combCountMap := map[int]int{}
	var totalCombCount int
	for _, count := range numCountMap {
		combCount := CombCount(count, 2)
		combCountMap[count] = combCount
		totalCombCount += combCount
	}
	for _, n := range nums {
		io.Println(totalCombCount - (numCountMap[n] - 1))
	}
}

func CombCount(left int, right int) int {
	rightFac := Factorial(right, right)
	if rightFac <= 0 {
		return 0
	}
	return Factorial(left, right) / rightFac
}

func Factorial(n int, times int) (res int) {
	facts := make([]int, n+1)
	if facts[n] != 0 {
		res = facts[n]
		return res
	}

	if n > 0 && times > 0 {
		res = n * Factorial(n-1, times-1)
		return res
	}

	return 1
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    System.out.println(four(n, sc));
  }
  
  public static String four(int n, Scanner s) {
    for(int i = 0; i < n; i++) {
      String curr = s.next();
      if(curr.equals("Y"))
        return "Four";
    }
    return "Three";
  }
}
 

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int, int>>> a(n);
	for (int i = 0, p, y; i < m; i++) {
		cin >> p >> y;
		p--;
		a[p].emplace_back(i, y);
	}
	vector<pair<int, long long>> b;
	for (int i = 0; i < n; i++) {
		sort(a[i].begin(), a[i].end(), [](auto &e1, auto &e2) {
			return e1.second < e2.second;
		});
		for (int j = 0; j < (int) a[i].size(); j++)
			b.emplace_back(a[i][j].first,
					(long long) (i + 1) * 1000000 + j + 1);
	}
	sort(b.begin(), b.end(), [](auto &e1, auto &e2) {
		return e1.first < e2.first;
	});
	for (int i = 0; i < m; i++)
		cout << std::setfill('0') << std::setw(12) << b[i].second << endl;

}


Measured memory_bytes: 8688
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B; 
    cin >> N >> A >> B;
    int ans = 0;
    ans += N/(A + B) * A;
    N -= (N/(A + B)) * (A + B);
    cout << ans + min(A, N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;
int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half;
	}
	else {

		return a * modpow(a, p - 1);
	}
}
bool calc(int a) {
	int cnt = 0;

	while (a) {
		cnt += a % 2;
		a /= 2;
	}

	if (cnt % 2)return true;
	return false;
}
int N;
VI G[60];
map<pii, int>mp;

VI dfs(int now, int b, int pa) {

	VI root;
	queue<pair<int, VI> >Q;
	bool vis[60] = { false };
	vis[now] = 1;
	VI tmp;
	Q.push(make_pair(now, tmp));
	
	while (!Q.empty()) {

		tmp = Q.front().second;
		int now = Q.front().first;
		//cout << now << endl;
		Q.pop();
		tmp.push_back(now);
		if (now == b) {
			root = tmp;
			break;
		}
		fore(to, G[now]) {
			if (!vis[to]) {
				vis[to] = 1;
				Q.push(make_pair(to, tmp));
			}
		}
	}

	VI res;
	REP(i, root.size() - 1) {
		res.push_back(mp[pii(root[i], root[i + 1])]);
	}
	//fore(i, root)cout << i << endl;
	return res;

}


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

	cin >> N;
	REP(i, N - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		mp[pii(a, b)] = mp[pii(b, a)] = i;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	VI C[30];
	int M;
	cin >> M;
	REP(i, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		C[i] = dfs(a, b, -1);
		//cout << "K" << endl;
	}
	int ans = 0;

	
	REP(i, 1 << M) {
		//cout << i << endl;
		int sum = 0;
		bool F[52] = { false };
		REP(j, M) {
			if (i&(1 << j)) {
				REP(k, C[j].size()) {
					F[C[j][k]] = 1;
				}
			}
		}
		int a = 0;
		REP(i, N - 1)a += F[i];
		sum = (modpow(2, a) - 1)*modpow(2, N - 1 - a);
		if (calc(i))ans += sum;
		else ans -= sum;
	}



	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,q,a) for(long long i=q; i<a; i++)
#define ll long long
#define pb push_back
#define mod 1000000007
#define oo 666666666666666
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
    return 0;
}


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

const ll infLL = 1e18;
int N, M, L;
vector<vector<ll>> Warshall_Floyd(vector<vector<ll>> table){
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                table[i][j] = min(table[i][j], table[i][k] + table[k][j]);
            }
        }
    }
    return table;
}

int main() {
    cin >> N >> M >> L;
    vector<vector<ll>> graph(N, vector<ll>(N, infLL));
    for (int i = 0; i < M; ++i) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        graph[A][B] = graph[B][A] = C;
    }
    auto v = Warshall_Floyd(graph);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if(v[i][j] <= L) {
                v[i][j] = 1;
            } else {
                v[i][j] = infLL;
            }
        }
    }
    auto ans = Warshall_Floyd(v);
    int Q;
    cin >> Q;
    vector<ll>res(Q);
    for (int i = 0; i < Q; ++i) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        if(ans[s][t] == infLL){
            res[i] = -1;
        } else{
            res[i] = ans[s][t] - 1;
        }
    }
    for (int i = 0; i < Q; ++i) {
        cout << res[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 603;

i64 n, m;

vector<i64> e[MAXN];
double dp[MAXN];
pair<double, double> de[MAXN][MAXN];


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> m;
    for (i64 i = 0; i < m; i++) {
        i64 u, v;
        cin >> u >> v;
        e[u].push_back(v);
    }

    for (i64 i = n - 1; i > 0; i--) {
        double z = 1.0 / e[i].size();
        for (auto t : e[i]) {
            dp[i] += z * (dp[t] + 1);
        }
    }

    for (i64 j = 1; j < n; j++) {
        for (i64 i = n - 1; i > 0; i--) {
            //if (i > j) {
            if(0) {
                de[j][i].second = dp[i];
            }
            else if (i == j) {
                de[j][i].first = 1.0;
            }
            else {
                double z = 1.0 / e[i].size();

                de[j][i].second += 1.0;
                for (auto t : e[i]) {
                    de[j][i].first += z * de[j][t].first;
                    de[j][i].second += z * de[j][t].second;
                }
            }
        }
    }

    /*
    cerr << dp[1] << endl;
    for (i64 j = 1; j < n; j++) {
        double t = de[j][1].first * dp[j] + de[j][1].second;
        cerr << "de[" << j << "][1] = " << t << endl;
    }
    */


    double R = dp[1];
    /*
    for (i64 j = 1; j < n; j++) {
        if (e[j].size() < 2) {
            continue;
        }

        vector<double> te;
        for (auto t : e[j]) {
            te.push_back(dp[t]);
        }
        sort(te.begin(), te.end(), greater<double>());

        double ej = 1.0;
        double z = 1.0 / (e[j].size() - 1);
        for (i64 i = 1; i < te.size(); i++) {
            ej += z * te[i];
        }

        double r = de[j][1].first * ej + de[j][1].second;
        R = min(R, r);
    }
    */
    for (i64 j = 1; j < n; j++) {
        if (e[j].size() < 2) {
            continue;
        }

        double ts = 0;
        for (auto t : e[j]) {
            ts += dp[t];
        }

        double z = 1.0 / (e[j].size() - 1);

        for (auto t : e[j]) {
            double ej = 1.0 + z * (ts - dp[t]);
            double r = de[j][1].first * ej + de[j][1].second;
            R = min(R, r);

        }
    }
    cout << R << endl;

    return 0;
}

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

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


Measured memory_bytes: 3108
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int r,l,m,n,rr,ll,aa,bb,w[210000],b[210000];
string s;
int main()
{
	cin>>m;
	cin>>s;
	for(int x=0;x<s.size();x++)
	{
		if(x!=0)
		{
		w[x]=w[x-1];
		}
		if(s[x]=='#')
		{
			w[x]+=1;
		}
	}
	for(int x=s.size()-1;x>=0;x--)
	{
		b[x]=b[x+1];
        if(s[x]=='.')
		{
		b[x]+=1;
		}
	}
	int ans=1e9;
	ans=min(b[0],w[s.size()-1]);
	for(int x=0;x<s.size();x++)
	{
		ans=min(w[x]+b[x+1],ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2180
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

############
############
############


N, K = s_inpl()
V = l_inpl()
rV = V[::-1]
ans = 0
for l in range(K+1):
    for r in range(K+1-l):
        if l + r > N:
            continue
        d = K - l - r
        get_l = []
        current_score = 0
        for i in range(l):
            current_score += V[i]
            get_l.append(V[i])
        for i in range(r):
            current_score += rV[i]
            get_l.append(rV[i])
        get_l.sort()
        for i in range(d):
            if i >= len(get_l):
                break
            if get_l[i] > 0:
                break
            current_score -= get_l[i]

        ans = max(ans, current_score)

print(ans)



Measured memory_bytes: 41584
#include <stdio.h>

int main()
{
	int n, i, a[100];
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(i = 0; i < n; i++){
		if(a[i] % 2 == 0){
			if(!(a[i] % 3 == 0 || a[i] % 5 == 0)){
				printf("DENIED\n");
				return 0;
			}
		}
	}
	printf("APPROVED\n");
	
	return 0;
}


Measured memory_bytes: 128
#例題3
x = 100000

N = int(input())
if N <=200:
    A = list(map(int,input().split()))
    for i in range(N):
            y = 0
            #print('A' + str(i+1) +'='+ str(A[i]))
            while A[i] % 2 == 0:
                y += 1
                A[i] = A[i]//2
            if x > y:
                x = y

else:
    print('error')
    
print(x)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

vector<int> v;
vector<int> w;
vector<int> m;
vector<int> dp1, dp2;

// {quantity, value}
deque<pair<int, int>> q;

int solve(const int N, const int W) {
    for (int i = 1; i <= N; i++) {
        for (int r = 0; r < w[i]; r++) {
            q.clear();
            for (int j = 0; j * w[i] + r <= W; j++) {
                int a = dp1[j * w[i] + r];
                int b = a - j * v[i];
                while (!q.empty()) {
                    int val = q.back().second;
                    if (val <= b) {
                        q.pop_back();
                    } else {
                        break;
                    }
                }
                q.push_back({j, b});
                dp2[j * w[i] + r] = q.front().second + j * v[i];
                if (q.front().first == j - m[i]) {
                    q.pop_front();
                }
            }
        }
        dp1 = dp2;
    }
    return dp2[W];
}

int main(void) {
    int N, W;
    cin >> N >> W;

    v.resize(N + 1);
    w.resize(N + 1);
    m.resize(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> v[i + 1] >> w[i + 1] >> m[i + 1];
    }

    dp1.resize(W + 1, 0);
    dp2.resize(W + 1, 0);
    cout << solve(N, W) << endl;

    return 0;
}



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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> long long iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

int main() {
    int a;
    cin>>a;
    char s[30];
    cin>>s;
    if (a<3200)
        cout<<"red"<<endl;
    else
        cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256