akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
#define dump2(v) for(auto i:v) { for(auto j:i) std::cout << j << ' '; std::cout << "\n"; }
const int MOD = 1e9+7;

int modpow(int v,int k){int r(1),t(v);while(k){if(k&1){r*=t;r%=MOD;}t*=t;t%=MOD;k>>=1;} return r;}

signed main() {
	std::string s;
	std::cin >> s;
	std::vector<std::vector<int> > dp(s.size()+1,std::vector<int>(4,0));
	dp[0][3] = 1;
	rep(i,s.size()) {
		if(s[i]=='A') {
			dp[i+1][0] = (dp[i][0]+dp[i][3])%MOD;
			dp[i+1][1] = dp[i][1];
			dp[i+1][2] = dp[i][2];
			dp[i+1][3] = dp[i][3];
			continue;
		}
		if(s[i]=='B') {
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = (dp[i][0]+dp[i][1])%MOD;
			dp[i+1][2] = dp[i][2];
			dp[i+1][3] = dp[i][3];
			continue;
		}
		if(s[i]=='C') {
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = dp[i][1];
			dp[i+1][2] = (dp[i][1]+dp[i][2])%MOD;
			dp[i+1][3] = dp[i][3];
			continue;
		}
		if(s[i]=='?') {
			dp[i+1][0] = (dp[i][0]*3+dp[i][3])%MOD;
			dp[i+1][1] = (dp[i][0]+dp[i][1]*3)%MOD;
			dp[i+1][2] = (dp[i][1]+dp[i][2]*3)%MOD;
			dp[i+1][3] = (dp[i][3]*3)%MOD;
			continue;
		}
	}
	print(dp[s.size()][2]);

	return 0;
}


Measured memory_bytes: 7424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASheepAndWolves solver = new ASheepAndWolves();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASheepAndWolves {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int s = in.nextInt();
            int w = in.nextInt();

            String ret = w >= s ? "unsafe" : "safe";

            out.println(ret);

        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 25576
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W,N;
	scan(N);scan(H);scan(W);
	prin((N-H+1)*(N-W+1));
	return 0;
}


Measured memory_bytes: 256
fn get_line() -> String
{
  let mut ret = String::new();
  std::io::stdin().read_line(&mut ret).ok();
  ret
}

fn main()
{
  let str = get_line();
  let split_str:Vec<_> = str.trim().split(' ').collect();
  let h:i32 = split_str[0].parse().unwrap();
  let w:i32 = split_str[1].parse().unwrap();
  
  let mut mat = Vec::new();
  
  for i in {0..h} {
    let str = get_line();
    mat.push(str);
  }
  
  for i in {0..h} {
    for j in {0..w} {
      let mut val = 0;
      for k in {-1..2} {
        for l in {-1..2} {
          let y = i + k;
          let x = j + l;
          if 0 <= y && y < h && 0 <= x && x < w {
            if mat[y as usize].chars().nth(x as usize).unwrap() == '#' {
              val += 1;
            }
          }
        }
      }
      if mat[i as usize].chars().nth(j as usize).unwrap() == '#' {
        print!("#");
      } else {
        print!("{}", val);
      }
    }
    println!("")
  }
  
}

Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
  int a;
  int b;
  int c;
  int ah;
  int bh;
  int ch;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
           bh=b;
            b=a;
            a=bh;
         }
  if(b>c){
          ch=c;
           c=b;
           b=ch;
         }
  if(a>b){
          bh=b;
           b=a;
           a=bh;
         }
  printf("%d %d %d\n",a,b,c);
      
  return 0;
}

Measured memory_bytes: 596
//
//  main.cpp
//  green_programmig
//
//  Created by 渡辺隆太郎 on 2017/10/09.
//  Copyright © 2017年 渡辺隆太郎. All rights reserved.
//

#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
using namespace std;
long long inf=100000000000007;
#define int long long
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
int n,m;
char fi[55][55];
int dx[3]={1,0,-1};
int dy[3]={1,0,-1};

signed main(){
    cin>>n>>m;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>fi[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            int count=0;
            if(fi[i][j]=='.'){
                 for(int k=0;k<=2;k++){
                    for(int h=0; h<=2;h++){
                        int sx=i+dx[k],sy=j+dy[h];
                        if(fi[sx][sy]=='#')count++;
                    }
                }
            cout<<count;
            }
            else cout<<"#";
        }
        cout<<endl;
    }
    return 0;
}

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

int main()
{
  int X , N;
  cin >> X >> N;
  if (N==0)
  {
    cout << X << endl;
    exit(0);
  }
  vector<int> P(N);
  for (int i=0; i<N; i++)
  {
    cin >> P.at(i);
  }
  int count = 0;
  int comp = 0;
  int check = 0;
  bool flag = true;
  while(flag)
  {
    comp = 0;
    check = 0;
    comp = X - count;
    for (int i=0; i<N; i++)
    {
      if (comp == P.at(i))
      {
        check++;
      }
    }
    if (check == 0)
    {
      cout << comp << endl;
      flag = false;
      break;
    }
      
    comp = 0;
    check = 0;
    comp = X + count;
    for (int i=0; i<N; i++)
    {
      if (comp == P.at(i))
      {
        check++;
      }
    }
    if (check == 0)
    {
      cout << comp << endl;
      flag = false;
      break;
    }
    count += 1; 
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int u=__gcd(a[0],a[1]);
    rep(i,n-2){
        u=__gcd(a[i+2],u);
    }
    cout << u << endl;
}


Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
dp = [INF] * (n+5)
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i] + abs(a[i+1]-a[i]))
    if i != n-2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(a[i+2]-a[i]))
print(dp[n-1])

Measured memory_bytes: 80156
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;

int memo[300];
int dp(int num);

int main(void){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;

		memset(memo, -1, sizeof(memo));

		cout << (int)ceil(dp(n) / 3650.0) << endl;
		//cout << dp(n) << endl;
		
	}

	return 0;
}

int dp(int num){
	memo[0] = memo[1] = 1;
	memo[2] = 2;

	for(int i=3; i<=num; i++){
		memo[i] = memo[i-1] + memo[i-2] + memo[i-3];
	}

	return memo[num];
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int V[10] = { 1,2,4,8,16,32,64,128,256,512 };
bool judge[10] = { false };

int main() {

	int n, cnt = 0;

	while (cin >> n && n!= EOF) {
		REPR(i,9) {
			if (n >= V[i]) {
				judge[i] = true;
				n -= V[i];
			}
			if (n == 0)
				break;
		}

		REP(i,10) {
			if (judge[i] == true) {
				if (cnt != 0)cout << " ";
				cnt++;
				cout << V[i];
				
			}
			judge[i] = false;
		}
		cnt = 0;
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3048
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    mid = n//2-1
    left = d[mid]
    right = d[mid+1]
    print(right-left)


if __name__=="__main__":
    main()


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

int main() {
	int a,b,ans;
	string s,t;
	cin>>s>>t;
	if(s[0]==t[0])
	    ans++;
	if(s[1]==t[1])
	    ans++;
	    if(s[2]==t[2])
	    ans++;
	    cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
int main(){
	//???????????°?????????
	char CARD[]={'S','H','C','D'};
	int cards[4][13]={0};
	int i,j,id,num,kind_id;
	char kind;
	
	//???????????¨????????§????????????????????¨???0?????????
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			cards[i][j]=0;
		}
	}
	
	//????????????????????????
	//?????????????????????????????°?????????
	scanf("%d",&num);
	for(i=0;i<num;i++){
		//?????????????¨??????¨?????????????????????
		scanf(" %c", &kind);
		scanf("%d", &id);
		//??????????????????????????????????????°?????????????????????
		if(kind=='S') kind_id=0;
		if(kind=='H') kind_id=1;
		if(kind=='C') kind_id=2;
		if(kind=='D') kind_id=3;
		
		//?????§???????????????????????§??????????????????
		cards[kind_id][id-1]=1;
	}
	
	//????????????????????????
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(cards[i][j]==0) printf("%c %d\n", CARD[i],j+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string a, b;
    cin >> a >> b;

    if (a=="H" && b=="H")   
        cout << "H" << endl;
    if (a=="H" && b=="D")   
        cout << "D" << endl;
    if (a=="D" && b=="D")   
        cout << "H" << endl;
    if (a=="D" && b=="H")   
        cout << "D" << endl;
 
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [0]*n
a = [int(input()) for i in range(n)]
if a[0] != 0:
    ans = -1
    

else:
    b = a[::-1]
    ans = 0
    for i in range(n-1):
        if abs(b[i] - b[i+1]) <= 1:
            if b[i] > b[i+1]:
                ans += 1
            else:
                ans += b[i]
            
        else:
            if b[i] < b[i+1]:
                ans += b[i]
            else:
                ans = -1
                break
print(ans)

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N){
    ll answer = 0;
    rep(a,1,N) {
        rep(b,1,N) {
            if (a*b >= N) break;
            answer++;
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(){
  int N;
  cin >> N;

  string S;
  cin >> S;

  vector<bool> field(2 * N + 2);
  field[0] = field[2 * N + 1] = false;
  for(int i = 1; i <= 2 * N; i++){
    if(S[i - 1] == 'B'){
      field[i] = true;
    }
  }

  vector<bool> op(2 * N, false); // true for ')'
  for(int i = 0; i < 2 * N; i++){
    bool cond1 = false;
    if(i > 1 && op[i - 1] == true){
      cond1 = true;
    }
    bool cond2 = (field[i] == field[i + 1]);
    if(cond1 == cond2){
      op[i] = false;
    }else{
      op[i] = true;
    }
  }

  int left_cnt = 0, right_cnt = 0;
  for(auto b: op){
    if(b){
      right_cnt++;
    }else{
      left_cnt++;
    }
  }
  if(left_cnt != right_cnt){
    cout << 0 << endl;
    return 0;
  }

  const long long mod = 1e9 + 7;
  long long ans = 1;
  for(int i = 1; i <= N; i++){
    ans *= i;
    ans %= mod;
  }
  long long left_cnt_now = 0;
  for(auto b: op){
    if(b == false){
      left_cnt_now++;
    }else{
      ans *= left_cnt_now;
      left_cnt_now--;
      ans %= mod;
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 832
#include <bits/stdc++.h>
 
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   ll a,b;
   cin>>a>>b;
   if(a<=5)cout<<0<<endl;
   else if(a<=12)cout<<b/2<<endl;
   else cout<<b<<endl;
   
   
   
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n, k; cin >> n >> k;
    vll x(n); rep(i, n) cin >> x[i];

    auto l = x.begin();
    auto r = x.begin()+(k-1);

    ll ans = INF;
    while(r != x.end()){
        chmin(ans, *r-*l+min(abs(*l),abs(*r)));
        r++;
        l++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3940
#include <algorithm>
#include <cstring>
#include <numeric>
#include <cstdio>
int lst[100005], to[200005], pre[200005], tot; 
int ans[100005], seq[100005], deg[100005], dis1[100005], dis2[100005], que[100005], n; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	deg[u]++; 
	lst[u] = tot++; 
}
int bfs(int st, int *dis)
{
	memset(dis, 0x3f, n << 2); 
	dis[st] = 0; 
	int he = 0, ta = 0;
	que[ta++] = st; 
	while (he < ta)
	{
		int u = que[he++]; 
		for (int i = lst[u]; ~i; i = pre[i])
		{
			if (dis[to[i]] > dis[u] + 1)
			{
				dis[to[i]] = dis[u] + 1; 
				que[ta++] = to[i]; 
			}
		}
	}
	int res = 0; 
	for (int i = 1; i < n; i++)
	{
		if (dis[i] > dis[res])
			res = i; 
	}
	return res; 
}
inline void move(int pos, int val)
{
	int orig = seq[pos]; 
	for (int i = pos; i < pos + val; i++)
		seq[i] = seq[i + 1]; 
	seq[pos + val] = orig; 
}
void calc(int st, int en)
{
	int u = st, sum = 0, x = -1; 
	for (int i = 0; i < n; i++)
		seq[i] = i; 
	while (true)
	{
		int val = deg[u] - (u != st) - (u != en), orig = seq[sum]; 
		for (int i = sum; i < sum + val; i++)
			seq[i] = seq[i + 1];
		seq[sum + val] = orig; 
		sum += val + 1; 
		if (u == en)
			break; 
		for (int i = lst[u]; ~i; i = pre[i])
		{
			if (dis1[to[i]] + dis2[to[i]] == dis1[st] + dis1[en] && to[i] != x)
			{
				x = u; 
				u = to[i];
				break; 
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (ans[i] < seq[i])
			return; 
		if (ans[i] > seq[i])
			memcpy(ans, seq, sizeof(seq)); 
	}
}
int main()
{
	// freopen("ARC095-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst));
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v); 
		add_edge(v, u); 
	}
	int u = bfs(0, dis1), v = bfs(u, dis1); 
	bfs(v, dis2); 
	for (int i = 0; i < n; i++)
	{
		bool flg = dis1[i] + dis2[i] == dis1[v]; 
		for (int j = lst[i]; ~j && !flg; j = pre[j])
		{
			if (dis1[to[j]] + dis2[to[j]] == dis1[v])
				flg = true; 
		}
		if (!flg)
		{
			puts("-1"); 
			return 0; 
		}
	}
	memset(ans, 0x3f, sizeof(ans)); 
	calc(u, v); 
	calc(v, u); 
	for (int i = 0; i < n; i++)
		printf("%d%c", ans[i] + 1, " \n"[i + 1 == n]);
	return 0; 
}


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

int main() {
  int n;
  cin>>n;
  map<string, int> m;
  for (int i=0; i<n; i++) {
    string s;
    cin>>s;
    ++m[s];
  }
  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
  cout<<"TLE x "<<m["TLE"]<<endl;
  cout<<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1){
        cout << "No\n";
        exit(0);
    }
    if(s.substr(0, n/2) == s.substr(n/2,n))
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

double N, K;
int NUM;

double p(int a, int key) {
  int res = 1;
  int x = key;
  while(x > 0) {
    if(x & 1) {
      res *= a;
    }
    x >>= 1;
    a *= a;
  }
  return res;
}

int main() {
  cin >> N >> K;
  NUM = floor(log2(K - 0.1)) + 1;
  double ans = 0;
  double par = pow(2, NUM);
  double ch = 0;
  for(int i = 1; i <= N; i++) {
    if(i >= K) {
      ch += par;
      continue;
    }
    int temp = floor(log2((K - 0.1) / i)) + 1;
    ch += pow(2, NUM - temp);
  }
  cout << std::fixed << std::setprecision(11) << ch / (par * N) << endl;
  return 0;
}

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

int main() {
  int h1, m1;
  int h2, m2;
  int k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int mins = (h2 - h1) * 60 + m2 - m1;
  cout << mins - k << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()

{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(0<=x-r&&0<=y-r&&x+r<=W&&y+r<=H)
        cout <<"Yes"<<endl;
    else
        cout <<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3116
N = int(input())

memolist = [-1]*(N+1)
def fib(x):
    if memolist[x] == -1:
        if x == 0 or x == 1:
            memolist[x] = 1
        else:
            memolist[x] = fib(x - 1) + fib(x - 2)
    return memolist[x]

print(fib(N))


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

long long gcd(long long x, long long y) {
    long long g,l;
    if(x > y){
        g = x;
        l = y;
    }else{
        l = x;
        g = y;
    }
        return g%l==0? l : gcd(l,g%l);
}

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n,1);
    return res;
}

int main(){
    ll A,B;
    cin >> A >> B;
    ll gc = gcd(A,B);
    //ll rgc = ll(sqrt(gc)) + 1;
    //ll cnt=0;
    /*for(int i = 1;i*6+1<rgc;i++){
        if(i == 1 || i==2||i==3)cnt++;
        if(gc % i*6-1 == 0) 
    }*/
    cout << factorize(gc).size()+1 << endl;

}


Measured memory_bytes: 256
using System;
using System.Text;

namespace _020_Capitalize
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr = Console.ReadLine ();

			StringBuilder result = new StringBuilder (inputStr.Length);

			foreach (var item in inputStr)
			{
				if (char.IsLower (item))
					result.Append (char.ToUpper (item));
				else
					result.Append (item);
			}

			Console.WriteLine (result);
		}
	}
}

Measured memory_bytes: 9108
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    long total = 0;
    int minus_cnt = 0;
    for(int i=0; i<n; i++) {
        if(a[i] < 0) minus_cnt++;
        a[i] = abs(a[i]);
        total += a[i];
    }
    if(minus_cnt % 2) { // マイナスの数が奇数
       total -= 2 * (*min_element(a.begin(), a.end()));
    }
    cout << total << endl;


    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);

    int A[N];
    int i;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    int check=0;
    for(i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                check=1;
                break;
            }
        }
    }

    if(check==0)    puts("APPROVED");
    else    puts("DENIED");

    return 0;
}

Measured memory_bytes: 1632
// AOJ 1063
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair <int, int> P;

int main(void)
{
	int n, p;

	while (cin >> n, n){
		vector < pair <P, int> > v, must;
		vector < string > name;
		string tmp;
		int week, start;
		for (int i = 0; i < n; i++){
			cin >> tmp >> week >> start;
			int s = (week * 60 * 60 * 24) + (start / 100 * 60 * 60) + ((start % 100) * 60);
			int t = s + (60 * 30);
			v.push_back(make_pair(make_pair(t, s), i));
			name.push_back(tmp);
		}
		cin >> p;
		for (int i = 0; i < p; i++){
			cin >> tmp;
			for (int j = 0; j < n; j++){
				if (tmp == name[j]){
					must.push_back(make_pair(v[j].first, j));
					break;
				}
			}
		}

		sort(v.begin(), v.end());
		sort(must.begin(), must.end());

		// for (int i = 0; i < n; i++){
		// 	int s = v[i].first.second, e = v[i].first.first, id = v[i].second;
		// 	cout << name[id] << " " << s << " " << e << endl;
		// }

		int ret = -1, last = -1;
		bool done[512] = {false}, flag = true;
		for (int i = 0; i < p; i++){
			if (last > must[i].first.second){
				flag = false;
				break;
			}
			last = must[i].first.first;
		}
		if (!flag){
			cout << -1 << endl;
			continue;
		}

		ret = p;
		for (int i = 0; i < p; i++){
			done[must[i].second] = true;
		}

		last = -1;
		// cout << "*****" << endl;
		for (int i = 0; i < n; i++){
			int s = v[i].first.second, e = v[i].first.first, id = v[i].second;
			// cout << last << " " << name[id] << endl;
			if (done[id]){
				// cout << " <3 " << name[id] << endl;
				last = e;
				for (int j = i - 1; j >= 0; j--){
					// cout << name[v[j].second] << " " << done[v[j].second] << endl;
					if (s < v[j].first.first){
						if (done[v[j].second]){
							ret--;
							done[v[j].second] = false;
						}
						// cout << " xx " << name[v[j].second] << endl;
					}
					else break;
				}
				continue;
			}
			if (last > s) continue;
			ret++;
			last = e;
			done[id] = true;
			// cout << " <3 " << name[id] << endl;
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1268
a, b = map(int, input().split())
c = [list(input())for _ in range(a)]
x = y = 0
c[x][y] = "."
while True:
    moved = False
    if x < a-1:
        if c[x+1][y] =="#":
            c[x+1][y] = "."
            x += 1
            if not moved:
                moved = not moved
    if y < b-1:
        if c[x][y+1] == "#":
            c[x][y + 1] = "."
            y += 1
            if not moved:
                moved = not moved
    if x == a-1 and y == b-1:
        for i in range(a):
            for j in range(b):
                if c[i][j] == "#":
                    print("Impossible")
                    exit()
        print("Possible")
        exit()
    if not moved:
        print("Impossible")
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
int h;
int a[maxn];
int b[maxn];
int dp[maxn];

int main()
{
	//freopen("D:\\code\\text\\input.txt","r",stdin);
	//freopen("D:\\code\\text\\output.txt","w",stdout);
	h = readint(); n = readint();
	repd(i, 1, n)
	{
		a[i] = readint();
		b[i] = readint();
	}
	repd(i, 1, h)
	{
		dp[i] = inf;
	}
	repd(i, 1, n)
	{
		repd(j, a[i], h + a[i])
		{
			dp[min(j, h)] = min(dp[min(j, h)], dp[j - a[i]] + b[i]);
		}
	}
	printf("%d\n", dp[h] );

	return 0;
}




Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define rep(i,r,l) for(int i = r; i < l; i++)
#define elif else if
#define ll long long

int nextint(void){int n;scanf("%d",&n);return n;}
void printint(int d){printf("%d\n",d);}


int main(void){ 

    int sum = 0, n = 0;
    char c;
    for(;(c = getchar())!='\n';){

        n = c - '0';
        sum += n;
    }
    (sum%9==0)?puts("Yes"):puts("No");
    
    return 0;
}



Measured memory_bytes: 1516
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[2000200];
int main()
{
	int n,minn=11020102;
	cin>>n;
	int i,s=0;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(minn>a[i]) {
			minn=a[i];s++;
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  string S;
  cin >> S;

  int min = 1000;
  for (int i = 0; i < S.length() - 2; i++) {
    string subStr = S.substr(i, 3);
    int num = stoi(subStr);
    if (abs(753 - num) < min) {
      min = abs(753 - num);
    }
  }

  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        arr[0]  = sc.nextInt();
        int max = arr[0];
        int maxi = 0;
        int max2 = -1;

        for(int i = 1;i < n;i++){
            arr[i]  = sc.nextInt();
            if(arr[i] > max){
                max2 = max;
                max = arr[i];
                maxi = i;
            } else if (arr[i] > max2){
                max2 = arr[i];
            }
        }

        for(int i = 0;i < n;i++){
            if(i == maxi){
                System.out.println(max2);
            } else {
                System.out.println(max);
            }
        }
    }
}



Measured memory_bytes: 86468
#include <iostream>

using namespace std;

void dfs(char **data, int x, int y, int &count){
  if (data[y][x] == '.' || data[y][x] == '@'){
    data[y][x] = '#';
    ++count;
    //cout << count << endl;
    dfs(data, (x-1), y, count);
    dfs(data, x, (y-1), count);
    dfs(data, (x+1), y, count);
    dfs(data, x, (y+1), count);  
  }
  return;
}

int main(int argc, char* argv[]){
  int w, h;
  
  while (cin >> w >> h && w!=0 && h!=0){
    char **data = new char*[h+2];
    for (int i=0; i<(h+2); ++i){
      data[i] = new char[w+2];
    }
    
    int x,y;
    
    for (int i=0; i<(h+2); ++i){
      for (int j=0; j<(w+2); ++j){
	if ( i==0 || j==0 || i==(h+1) || j==(w+1)){
	  data[i][j] = '#';
	}
	else{
	  cin >> data[i][j];
	  //black: .   red: #   person: @
	  if (data[i][j] == '@'){
	    x = j;
	    y = i;
	  }
	}      
      }
    }
    /*
    cout << endl << endl;
    for (int i=0; i<(h+2); ++i){
      for (int j=0; j<(w+2); ++j){
	cout << data[i][j];
      }
      cout << endl;
    }
    */
    int count = 0;
    dfs(data, x, y, count);
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1416
#include <stdio.h>
int main(void){
     int a,b;
     char r;
     while(1){ 
          scanf("%d %c %d", &a ,&r, &b);      
           if ( r == '?' )   
            break; 
             if ( r == '+' ){       
                  printf("%d\n",a+b)
                  ;}
                   else if ( r == '-' ){
                       printf("%d\n",a-b)
                       ;}
                       else if ( r == '*' ){
                           printf("%d\n",a*b)
                           ;}
                           else if ( r == '/' ){
                               printf("%d\n",a/b)
                               ;}
                               }
                               return 0;}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
string a;
bool y;
int main()
{
    cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='F'&&y==1)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		if(a[i]=='C')
		{
			y=1;
		}
	}
	cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {

    val mem = new Array[Int](50001)
    val scanner = new Scanner(System.in)
    var n = scanner.nextInt()
    val arrayC: Array[Int] = {
        val m = scanner.nextInt()
        new Array[Int](m)
    }
    input(arrayC.length)
    System.out.println(calc(n))

    def input(i: Int): Unit = {
        if (i == 0) return

        arrayC(i - 1) = scanner.nextInt()
        input(i - 1)
    }

    def calc(x: Int): Int = {
        if (x < 0) {
            return Integer.MAX_VALUE
        }
        if (x == 0) {
            return 0
        }
        if (mem(x) != 0) {
            return mem(x)
        }

        var i = 0
        var min = Integer.MAX_VALUE
        while (i < arrayC.length) {
            val temp = calc(x - arrayC(i))
            if (temp < min) {
                min = temp
            }
            i += 1
        }

        mem(x) = min + 1
        return mem(x)
    }
}

Measured memory_bytes: 45364
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int a[100];

int main(){
	int n,i,sa=0,sb=0;
	cin >> n;
	for(i=0;i<n;i++)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	for(i=0;i<n;i++){
		if(i%2==0)
			sa+=a[i];
		else
			sb+=a[i];
	}
	cout << sa-sb;
}


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


int main() {
	// 코틀린 ,문자열 알고리즘 보기, 앳코더, (시간되면 코드포스까지)
	ios_base::sync_with_stdio(false); cin.tie(NULL); //9 90 900 
	string s; cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << ' ' << i + 2 << '\n'; return 0;
		}
		else if (i + 2 < s.size() && s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3 << '\n'; return 0;
		}
	}
	cout << -1 << ' ' << -1 << '\n';


}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dl;
const int iNF = 1e9 + 100;
const ll INF = 1e18 + 100;
typedef pair<int, int> pii;

int main(){
   ll k, a, b, c;
   cin >> a >> b >> c >> k;
   // a  = 1
   // b = 0
   // c = -1
   ll total = 0;
   if(k > a){
      total += a;
      k -= a;
      if(k > b){
        k -= b;
        total += (k * -1);
        cout << total << endl;
      }else{
         cout << total << endl;
      }
   }else{
      cout << k;
   }
   return 0;
}

Measured memory_bytes: 3624
a=[]
b=[]
n,m=map(int,input().split())
for _ in range(n):
    a.append(list(map(int,input().split())))
for _ in range(m):
    b.append(int(input()))

for i in range(n):
    cnt=0
    for j in range(m):
        cnt+=a[i][j]*b[j]
    print(cnt)



Measured memory_bytes: 6016
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
from collections import defaultdict
from pprint import pprint
import math
import datetime
import sys
import fcntl
import time

#N = [int(x) for x in input().split()]
N = int(input())

ans = 0
for n in range(1, N+1):
    if len(str(n)) % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 3828
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};
const int D=365;
const int beam = 200;
int c[26];
int s[D][26];
int ans[D];

struct State{
    ll val = 0;
    int out[D]={0};
    int cnt[26]={0};
};

bool operator< (const State &a, const State &b){
    return a.val<b.val;
}
bool operator> (const State &a, const State &b){
    return a.val>b.val;
}


void solve(int ca){
    int waste;
    scanf("%d",&waste);
    for (int i = 0; i < 26; ++i) {
        scanf("%d",c+i);
    }
    for (auto & i : s) {
        for (int & j : i) {
            scanf("%d",&j);
        }
    }

    priority_queue<State> pq[2];
    pq[0].push(State());
    for (int i = 0; i < D; ++i) {
        int prev=i&1,next = prev^1;
        for (int j = 0; !pq[prev].empty()&&j < beam; ++j) {
            auto state = pq[prev].top();
            pq[prev].pop();
            ll dec=0;
            for (int k = 0; k < 26; ++k) { 
                state.cnt[k]++;
                dec+=(ll)c[k]*state.cnt[k];
            }
            for (int k = 0; k < 26; ++k) {
                const ll inc = (ll)c[k]*state.cnt[k];
                const int tmp = state.cnt[k];
                const int tmp_val = state.val;
                state.val = state.val-dec+inc+s[i][k];
                state.cnt[k]=0;
                state.out[i]=k;
                pq[next].push(state);
                state.cnt[k]=tmp;
                state.val = tmp_val;
            }
        }
        pq[prev]=priority_queue<State>();
    }
    auto best = pq[D&1].top().out;
    for (int i = 0; i < D; ++i) {
        ans[i]=best[i]+1;
    }
    for (int i = 0; i < D; ++i) {
        printf("%d\n",ans[i]);
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 31992
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)2e5+3;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
using cd = complex<double>;
const double PI = acos(-1);

void fft(vector<cd> & a, bool invert) {
    int n = a.size();

    for (int i = 1, j = 0; i < n; i++) {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1)
            j ^= bit;
        j ^= bit;

        if (i < j)
            swap(a[i], a[j]);
    }

    for (int len = 2; len <= n; len <<= 1) {
        double ang = 2 * PI / len * (invert ? -1 : 1);
        cd wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) {
            cd w(1);
            for (int j = 0; j < len / 2; j++) {
                cd u = a[i+j], v = a[i+j+len/2] * w;
                a[i+j] = u + v;
                a[i+j+len/2] = u - v;
                w *= wlen;
            }
        }
    }

    if (invert) {
        for (cd & x : a)
            x /= n;
    }
}

vector<LL> multiply(vector<int> const& a, vector<int> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    int n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);

    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<LL> result(n);
    for (int i = 0; i < n; i++)
        result[i] = round(fa[i].real());
    return result;
}

LL a[200009];
LL p[200009];//pow of 2
LL inv[200009];//position in the cycle

int main() {
	DRI(n);
	LL sum2 = 0; // squares
	REP(i,n){
		scanf("%lld",&a[i]);
		sum2 += (a[i]*a[i])%MOD;
	}
	p[0]=1;
	inv[1]=0;
	REPP(i,1,MOD-1){
		p[i] = (p[i-1]*2)%MOD;
		inv[p[i]] = i;
	}
	vector<int> poly(MOD-1,0);
	REP(i,n){
		if(a[i]==0)continue;
		poly[inv[a[i]]]++;
	}
	LL ans = 0;
	vector<int> poly2 = poly;
	vector<LL> poly3 = multiply(poly,poly2);
	REP(i,SZ(poly3)){
		ans += (LL)p[i%(MOD-1)]*poly3[i];
	}
	printf("%lld",(ans-sum2)/2);
}


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

int main(){
    int ans=0,sum=0;
    int n,m;
    
    cin >>n;
    int h[n];
    int cost[n];


    for (int i = 0; i < n; i++){
        cin >> h[i];
    }

    cost[0]=0;
    cost[1]=abs(h[0]-h[1]);

    for (int i = 2; i < n; i++){
        int c;
        c=min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
        cost[i] = c;
    }
    
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << cost[n-1] << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#define ll long long
#define mod 1000000007

using namespace std;

ll n,m,arr[1005][1005],dp[1005][1005];

int main()
{
    string s;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        for(int j=0;j<m;j++)
        {
            (s[j]=='.')?arr[i][j]=1:arr[i][j]=0;
        }
    }
    arr[0][0]=0;arr[n-1][m-1]=0;
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<arr[i][j]<<' ';
        }
        cout<<'\n';
    }*/
    for(int c=m-1;c>=0;c--)
    {
        for(int r=n-1;r>=0;r--)
        {
            if(!arr[r][c]&&(r||c))continue;
            ll a=0,b=0;
            if(c+1<m)
            {
                a=dp[r][c+1];
            }
            if(r+1<n)
            {
                b=dp[r+1][c];
            }
            if(c==m-1&&r==n-2||c==m-2&&r==n-1)
                dp[r][c]+=((a+b)%mod+arr[r][c]%mod)%mod;
            else dp[r][c]+=(a+b)%mod;
        }
    }
    cout<<dp[0][0]%mod<<'\n';
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<dp[i][j]<<' ';
        }
        cout<<'\n';
    }*/
    return 0;
}

Measured memory_bytes: 16000