akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end() 
using namespace std;
typedef long long ll;

const int N = 1e5 + 5;
int n, a[N];

int sign(ll p) {
    if(p < 0ll)
        return 1;
    return 0;
}

ll calc() {
    ll curr = a[0], res = 0ll;
    int flag = 1;
    if(curr < 0ll) 
       flag = 0;
    for(int i=1; i<n; ++i) {
       ll x = a[i];
       if(curr+x == 0) {
           ++res;
           if(flag) curr = -1;
           else curr = 1;
       }
       else if(flag != sign(curr + x)) { 
           res += abs(curr + x) + 1;
         //  cout << "i: " << i << " curr: " << curr << " abs(curr+x)+1: " << abs(curr + x)+1 << " res: " << res << "\n";
           if(flag) { 
              // res += (x <= 0) ? curr + x + 1: i;
               curr = -1;
           }
            else {
             //   res += (x <= 0) ? : ;
                curr = 1;
            }
       }
       else
           curr += x;
       flag ^= 1;
    }
    return res;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n;
   for(int i=0; i<n; ++i) 
       cin >> a[i];
   ll res;
   if(a[0] != 0) {
       res = calc();
       if(a[0] > 0) {
           ll p = abs(a[0]) + 1;
           a[0] = -1;
           res = min(res, p + calc());
       } else {
           ll p = abs(a[0]) + 1;
           a[0] = 1;
           res = min(res, p + calc());
       }
   } else {
       a[0] = -1;
       res = calc() + 1;
       a[0] = 1;
       res = min(res, calc() + 1);
   }
   cout << res << "\n";
   return 0;
}  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

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

	ll ans = 0;
	FOR(i, 1, N + 1) {
		ll m = N / i;
		ans += i * m * (m + 1) / 2;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

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

        int w = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();

        if (a < b) {
            if ((b <= a + w) && (a <= b + w)) {
                System.out.println(0);
            } else {
                System.out.println(b - (a + w));
            }
        } else {
            if ((a <= b + w) && (b <= a + w)) {
                System.out.println(0);
            } else {
                System.out.println(a - (b + w));
            }
        }
    }
}


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

int main(){
    int c,d;
  cin>>c>>d;
 
    if(c>=13){
cout<<d<<endl;
  }
   else if(c<=5){
      cout<<0<<endl;
    }
 else{
       cout<<d/2<<endl;
 }
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl num(4);
    string s[] = {"AC", "WA", "TLE", "RE"};
    for (ll i = 0; i < N; i++) {
        string t;
        cin >> t;
        for (ll j = 0; j < 4; j++) {
            if (s[j] == t) {
                ++num[j];
            }
        }
    }

    for (ll i = 0; i < 4; i++) {
        cout << s[i] << " x " << num[i] << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int x=0,n,max=0;
	char s[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			x=x+1;
			
			if(x>max){
				max=x;
			}
		}
		
		else if(s[i]=='D'){
			x=x-1;
		}
	}
	
	cout<<max<<endl;
	
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s, t;
  cin >> n >> s >> t;

  int ans = n+n;

  REP(i,n) if(s.substr(i, n-i) == t.substr(0, n-i)) {
    ans = i+n;
    break;
  }

  cout << ans << endl;
  
  return 0;
}


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

int main()
{
    int n,m,ans=1,best=-1000;
    cin>>n;
    string b[n];
    for (int i=0; i<n; i++) cin>>b[i];
    cin>>m;
    string r[m];
    for (int i=0; i<m; i++) cin>>r[i];
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            if (i==j) continue;
            else if (b[i]==b[j]) ans++;
        }
        for (int j=0; j<m; j++)
        {
            if (b[i]==r[j]) ans--;
        }
        best=max(best,ans);
        ans=1;
    }
    if (best<0) best=0;
    cout<<best<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200010], n;
int largest[200010], mx;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
	{
		largest[a[i]] = 1 + largest[a[i]-1];
		mx = max(mx, largest[a[i]]);
	}
	printf("%d\n", n-mx);
}

Measured memory_bytes: 1792
from queue import PriorityQueue
N = int(input())
A = map(int, input().split())
q = PriorityQueue()
for a in A:
  q.put(a)
x = q.get()
while not q.empty():
  y=q.get()
  if y == 0:
    continue
  q.put(x % y)
  x = y
print(x)

Measured memory_bytes: 83356
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    map<int, ll> m;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i : v) {
        ll ans2 = ans;
        (ans += m[i]) %= MOD;
        (m[i] += ans2) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int n = 5;
    //注文してから届くまでの時間
    vector<int> time = {a, b, c, d, e};
    //注文してから次に注文できるまでの時間
    vector<int> nextTime(n);

    for (int i = 0; i < n; ++i) {
        if (time[i] % 10 == 0)
            nextTime[i] = time[i];
        else
            nextTime[i] = time[i] - time[i] % 10 + 10;
        // nextTime[i] = (time[i] + 9) / 10 * 10
    }
    int bestTime = INT_MAX;  // 適当に大きい値
    // 最後に注文するものを全通り計算
    for (int i = 0; i < n; ++i) {
        int sumTime = 0;
        for (int j = 0; j < n; ++j) {
            if (i == j) {
                // 最後の処理
                sumTime += time[j];
            } else {
                // 最後以外の処理
                sumTime += nextTime[j];
            }
        }
        bestTime = min(bestTime, sumTime);
        //if (bestTime > sumTime) bestTime = sumTime;
    }
    cout << bestTime << endl;
}

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

#define INFINITE 1000000007
#define LLI      long long int

using namespace std;

LLI getMaximumSum(LLI weightsArray[], LLI valuesArray[], LLI maxWeightAllowed, int totalItems)
{
    LLI maxSum = 0;
    for(int i = 0 ; i < totalItems ; i++)
    {
        maxSum += valuesArray[i];
    }
    vector<LLI> dpVector(maxSum+1, INFINITE);
    LLI         currMaxSum = 0;
    for(int i = 0 ; i < totalItems ; i++)
    {
        currMaxSum    += valuesArray[i];
        LLI backStart  = currMaxSum;
        LLI frontEnd   = valuesArray[i];
        for(LLI j = backStart ; j > frontEnd ; j--)
        {
            dpVector[j] = min(dpVector[j], weightsArray[i] + dpVector[j-valuesArray[i]]);
        }
        dpVector[frontEnd] = min(dpVector[frontEnd], weightsArray[i]);
    }
    
    LLI maximumValue = 0;
    for(LLI i = maxSum ; i >= 0 ; i--)
    {
        if(dpVector[i] <= maxWeightAllowed)
        {
            maximumValue = i;
            break;
        }
    }
    return maximumValue;
}

int main(int argc, const char * argv[])
{
    int           totalItems;
    long long int maxWeightAllowed;
    cin>>totalItems>>maxWeightAllowed;
    long long int weightsArray[totalItems];
    long long int valuesArray[totalItems];
    for(int i = 0 ; i < totalItems ; i++)
    {
        cin>>weightsArray[i]>>valuesArray[i];
    }
    cout<<getMaximumSum(weightsArray, valuesArray, maxWeightAllowed, totalItems)<<endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] = max(self.bit[x - 1], w)
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res = max(res, self.bit[x - 1])
            x -= x & -x
        return res

n = I()
H = LI()
A = LI()
D = {e:i for i,e in enumerate(sorted(H))}
bit = BIT(n)
for i in range(n):
    idx = D[H[i]]
    bit.add(idx, bit.sum(idx) + A[i])

print(bit.sum(n - 1))


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

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

string ans = "NG";

for (int i = a; i <= b; i++)
{
  if (i % k == 0)
  {
    ans = "OK";
    break;
  }
  
}

cout << ans << endl;


}

Measured memory_bytes: 3596
import re
def dotexit(s):
  return re.sub("^\.","",s)

def prod(l):
  x=1
  for i in l:
    x *= i
  return x

def rec(s):
  nums=[dotexit(x) for x in s[1:]]
  ad = []
  for i in range(len(nums)):
    if nums[i]=='+' or nums[i]=='*':
      rl=[nums[i]]
      for j in range(i+1,len(nums)):
        if nums[j][0] == '.':
          rl.append(nums[j])
        else:
          break
      ad.extend(rec(rl))
  nums.extend(ad)
  nums = [x for x in nums if x !='+' and x != '*' and x[0]!='.']
  if s[0]=='+':
    return [str(sum([int(x) for x in nums]))]
  elif s[0]=='*':
    return [str(prod([int(x) for x in nums]))]
  else:
    return s

while True:
  n=int(input())
  if n==0:
    break
  s=[]
  for i in range(n):
    s.append(input())
  print(rec(s)[0])


Measured memory_bytes: 6560
hs = []
ws = []
while True:
  h, w = (int(i) for i in input().split())
  if not h == 0 == w:
    hs.append(h)
    ws.append(w)
  else:
    break

for i in range(len(hs)):
  h = hs[i]
  w = ws[i]
  for height in range(1, h + 1):
    for width in range(1, w + 1):
      if height == 1 or height % 2 != 0:
        if width % 2 != 0:
          print('#',end='')
        else:
          print('.',end='')
      else:
        if width % 2 != 0:
          print('.',end='')
        else:
          print('#',end='')
    print('')
  print('')

Measured memory_bytes: 6812
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


void solve(){

    ll n, m;
    cin >> n >> m;
    ll a[n];
    ll s = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    ll cnt = 0;
    if(s %(4*m) == 0) s = s/ (4*m);
    else s = s/ (4*m)+1;
    for(ll i = 0; i < n; i++){
        if(a[i] >= s)cnt++;
    }
    if(cnt >= m) cout << "Yes";
    else cout << "No";

}

int main()
{
    //fast();
    solve();
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    string S, T, U;
    ll A, B;
    in >> S >> T;
    in >> A >> B;
    in >> U;
    ll ans = 0;
    A -= S == U ? 1 : 0;
    B -= T == U ? 1 : 0;
    out << A << " " << B << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


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

#define forn(i,n) for (int i = 0; i < int(n); i++)

const int MOD = 998244353;
const int N = 1e5 + 10;

int n, nim[3][N], cnt[3][N], mx[3], pot[N];
vector<int> adj[N];
bool vis[N];

void add(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;

    pot[0] = 1;
    pot[1] = 1; forn(_,18) pot[1] = 10LL*pot[1]%MOD;
    for (int i = 2; i < N; i++) pot[i] = (long long) pot[i-1] * pot[1] % MOD;

    forn(i,3) {
        forn(j,n) {
            adj[j].clear();
            nim[i][j] = 0;
        }
        int m; cin >> m;
        while (m--) {
            int u,v; cin >> u >> v;
            u--; v--;
            if (u > v) swap(u,v);
            adj[u].push_back(v);
        }
        for (int j = n-1; j >= 0; j--) {
            int sz = adj[j].size();
            fill_n(vis, sz+2, 0);
            for (auto k : adj[j]) vis[nim[i][k]] = 1;
            while (vis[nim[i][j]]) nim[i][j]++;

            add(cnt[i][nim[i][j]], pot[j+1]);
            mx[i] = max(mx[i], nim[i][j]);
        }
    }

    long long ans = 0;
    for (int x = 0; x <= mx[0]; x++) {
        for (int y = 0; y <= mx[1]; y++) {
            int z = x^y;
            ans += (long long) cnt[0][x] * cnt[1][y] % MOD * cnt[2][z] % MOD;
        }
    }
    cout << ans % MOD << endl;
    return 0;
}



Measured memory_bytes: 8064
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define watch(x) cout << (#x) << " is " << (x) << endl
#define N 100002

using namespace std;
int main()
{
	fastio
	ll T=1,n,m;string str;
	// cin>>T;
	// cin.ignore(); put after cin, just b4 a getline(cin, s) to avoid getline() directly getting \n
	while(T--)
	{
		ll p=0,q=0,tmp=0,sum=0,count=0; //tmp variable
		int flag=0;
		
		cin>>n;
		string s,t;
		cin >> s >> t;
		string res;
		for (int i = 0; i < n; ++i)
		{
			res+=s[i];
			res+=t[i];	
		}
		cout << res << endl;
	}
	return 0;
}

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

long power(long m, long n);

int main(void)
{
    long n,kmax,i,ans[60]={0},k=0;

    scanf("%ld",&n);

    for ( i = 0; 1; i++)
    {
        if(power(2,2*i)>=abs(n)) break;
    }
    kmax=2*(i+1);

    if(n==0) ans[0]=0;
    else
    {
        i=0;
        while(n!=0)
        {
            ans[i]=abs(n%-2);
            n=(n-abs(n%-2))/-2;
            i++;
        }
    }

    for ( i = 0; i < 60; i++)
    {
        if(ans[i]==1)
        {
            k=i;
        }
    }

    for ( i = k; i >= 0; i--)
    {
        printf("%ld",ans[i]);
    }

    return 0;
}

long power(long m, long n)
{
    long p=1;
    for (long i = 0; i < n; i++) p*=m;
    return p;
}

Measured memory_bytes: 128
n, Y = map(int, input().split())
for x in range(n + 1):
    for y in range(n + 1 - x):
        z = n - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
print("-1 -1 -1")

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

int main()
{
    string str;
    while (cin >> str && str != "-") {
        int m, h, n = str.size();
        cin >> m;
        while (--m >= 0) {
            cin >> h;
            str = str.substr(h, n - h) + str.substr(0, h);
        }
        cout << str << endl;
    }
}


Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    ll N, K;
    ll Sunuke[100]{ 0 };
    ll d[100]{ 0 };
    ll A[100][100]{ 0 };
    cin >> N >> K;
    rep(i,K) {
        cin >> d[i];
        rep(j,d[i]) {
            cin >> A[i][j];
        }
    }
    rep(i, K) {
        rep(j, d[i]) {
            Sunuke[A[i][j] - 1] = 1;
        }
    }
    ll count = 0;
    rep(i,N) {
        if (Sunuke[i] == 0)count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_back
int main() {


	int t = 1;
	//cin >> t;
	while (t--) {
		string n;
		cin >> n;
		if (n == "AAA" || n == "BBB") {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int i,j,k,m,n;
char S[100];

int main()
{
  cin >>S;
  
  n=strlen(S);
  j=0;
  for(i=0;i<n/2;i++)
  {
    if(S[i]!=S[n-1-i])
    {
      j++;
    }
  }
 
  cout <<j;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool even=true;
    for(char c='a';c<='z';c++){
        int cnt=0;
        for(int i=0;i<s.length();i++){
            if(s[i]==c){
                cnt++;
            }
        }
        if(cnt%2==1)even=false;
    }
    cout<<(even?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma warning (disable:4996)
#include <stdio.h>
#include <stdlib.h>

int** inputSize(int *r, int*c){
	unsigned short int i;
	int **matrix;
	scanf("%d %d", r, c);
	
	matrix = (int**)calloc(*r+1, sizeof(int *));
	if (matrix == NULL)exit(1);

	for (i = 0; i < *r+1; i++){
		matrix[i] = (int*)calloc(*c + 1,sizeof(int));
		if (matrix[i] == NULL)exit(1);
	}

	return matrix;
}

void inputMatrix(int *r, int *c, int **matrix){
	unsigned short int i, j;
	for (i = 0; i < *r; i++){
		for (j = 0; j < *c; j++){
			scanf("%d", &matrix[i][j]);
		}
	}
}

void addSpread(int *r, int *c, int **matrix){
	unsigned short int i, j;
	for (i = 0; i < *r; i++){
		for (j = 0; j < *c; j++){
			matrix[i][*c] += matrix[i][j];
			matrix[*r][j] += matrix[i][j];
			matrix[*r][*c] += matrix[i][j];
		}
	}
}
void output(int *r, int *c, int **matrix){
	unsigned short int i, j;
	for (i = 0; i <= *r; i++){
		for (j = 0; j <= *c; j++){
			printf("%d", matrix[i][j]);
			if (j != *c)printf(" ");
		}
	printf("\n");
	}
}
int main(void){
	unsigned short int i;
	int r, c;
	int **matrix;

	matrix = inputSize(&r, &c);
	inputMatrix(&r, &c, matrix);
	addSpread(&r, &c, matrix);
	output(&r, &c, matrix);
	
	for (i = 0; i <= r; i++){
		free(matrix[i]);
	}
	free(matrix);
	return 0;
}

Measured memory_bytes: 656
#include<stdio.h>
int main(void){
  char data[4];//文字
  char* result="";//文字列
  int flag=0;
  scanf("%s" , data);
  for(int i=0;i<sizeof data-1;i++){
    for(int j=i+1;j<sizeof data;j++){
      if(data[i]==data[j]){
        flag+=1;
      }
    }
  }
  if(flag==2){
    result="Yes";
  }else{
    result="No";
  }
  printf("%s",result);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main() {
  int n, t, h;
  char a[101], b[101];

  scanf("%d", &n);
  t = 0;
  h = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s %s", a, b);
    if (strcmp(a, b) > 0) {
      t = t + 3;
    } else if (strcmp(a, b) < 0) {
      h = h + 3;
    } else {
      t = t + 1;
      h = h + 1;
    }
  }
  printf("%d %d\n", t, h);
  
  return 0;
}


Measured memory_bytes: 2148
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()

	t := make([]int, 3)
	if s[0] == 'R' {
		t[0]++
	}
	if s[1] == 'R' {
		t[1] = t[0] + 1
	}
	if s[2] == 'R' {
		t[2] = t[1] + 1
	}

	puts(max(t...))
}


Measured memory_bytes: 1784
#include<stdio.h>
#define INF 100000000
int m[101][101];
int p[101];
int n;
void matrixChainOrder(void){
  int i,j,k,q,l;
  for(i=1;i<=n;i++) m[i][i] = 0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      //printf("a%d %d\n",i,j);
      m[i][j] = INF;
      for(k=i;k<=j-1;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = m[i][j] > q ? q : m[i][j];
      }
    }
  }
}
int main(){
  int i,j;
  for(i=0;i<101;i++)
    for(j=0;j<101;j++) m[i][j] = INF;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  matrixChainOrder();
  printf("%d\n",m[1][n]);
  /*
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      if(m[i][j] == INF) printf("-1");
      else printf("%d ",m[i][j]);
    }
    printf("\n");
  }
  for(i=1;i<=n;i++){
    printf("%d %d\n",p[i-1],p[i]);
  }
  */
  return 0;
}



Measured memory_bytes: 2052
n,m = map(int,input().split())

cakes = []
s = []

for i in range(n):
    cakes.append(list(map(int,input().split())))

from itertools import product

for a in product([-1,1],repeat=3):
    scores = []
    for i in range(n):
        scores.append(a[0]*cakes[i][0]+a[1]*cakes[i][1]+a[2]*cakes[i][2])
    scores.sort(reverse=True)
    s.append(sum(scores[:m]))

print(max(s))

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll Min = LINF;

    rep(yi, n) {
        ll y = a[yi]; //最小値の候補
        vector<ll> larger_y, v;

        rep(i, n) {
            if (a[i] >= y && i != n - 1) {
                v.push_back(a[i]);
            } else {
                if (a[i] >= y && i == n - 1) v.push_back(a[i]);
                sort(v.begin(), v.end());
                if (v.size() >= k) larger_y.insert(larger_y.end(), v.begin(), v.end() - k + 1);
                v.clear();
            }
        }

        sort(larger_y.begin(), larger_y.end());
        ll x;
        if (larger_y.size() >= q) x = larger_y[q - 1];
        else x = LINF;
        Min = min(Min, x - y);
    }

    cout << Min << endl;
    return 0;
}


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

int main()
{
   int N;
   cin >>N;
   vector<int> d(N);
   for(int t=0;t<N;t++){
       cin >>d.at(t);
   }
   //以上入力
   
   sort(d.begin(), d.end());
   cout <<d.at(N/2)-d.at(N/2-1) <<endl;
   
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn=200000+10;
const int maxm=4000+10;
const int base=2001;
const int mod=1e9+7;
int n,a[maxn],b[maxn],f[maxm][maxm],fac[maxm<<1],inv[maxm<<1];

inline int C(int n,int m){
	if(n<m) return 0;
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
	scanf("%d",&n);
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<(maxm<<1);i++) fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=2;i<(maxm<<1);i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<(maxm<<1);i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++) f[base-a[i]][base-b[i]]++;
	for(int i=1;i<=(base<<1);i++)
		for(int j=1;j<=(base<<1);j++) f[i][j]=(f[i][j]+(f[i][j-1]+f[i-1][j])%mod)%mod;
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=(ans+f[base+a[i]][base+b[i]])%mod;
		ans=(ans-C(2*a[i]+2*b[i],2*a[i])+mod)%mod;
	}
	ans=1ll*ans*(mod+1)/2%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 64640
import Control.Applicative
import Control.Monad
import System.IO.Unsafe
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f :: String -> String
f = concat . map (\ss -> let len = length ss in show len ++ [head ss]) . group

main = do
    n <- getInt
    when (n/=0) $ do
        s <- getLine
        putStrLn $ flip appEndo s $ mconcat $ map Endo $ replicate n f
        main

Measured memory_bytes: 4184
// 2018.09.05 3.5min

#include <iostream>

using namespace std;

int main() {
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;

    int maxv,minv,mid;
    maxv = max(a1,max(a2,a3));
    mid  = max(a1,min(a2,a3));
    minv = min(a1,min(a2,a3));

    cout << (maxv -mid) + (mid-minv) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for(int i = s.size()-1; i >= 0; i--){
		if(i >= 6 && (s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 'm' && s[i-3] == 'a' && s[i-4] == 'e' && s[i-5] == 'r' && s[i-6] == 'd')){
			i -= 6;
		}
		else if(i >= 4 && (s[i] == 'm' && s[i-1] == 'a' && s[i-2] == 'e' && s[i-3] == 'r' && s[i-4] == 'd')){
			i -= 4;
		}
		else if(i >= 5 && (s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 's' && s[i-3] == 'a' && s[i-4] == 'r' && s[i-5] == 'e')){
			i -= 5;
		}
		else if(i >= 4 && (s[i] == 'e' && s[i-1] == 's' && s[i-2] == 'a' && s[i-3] == 'r' && s[i-4] == 'e')){
			i -= 4;
		}
		else{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())

n = ni()
btc = 380000
ans = 0
for _ in range(n):
  a, b = ns().split()
  if b == "BTC":
    ans += float(a) * btc
  else:
    ans += int(a)
print(ans)


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

struct grid{
	int X, Y;
};

char kotak[55][55];
bool visit[55][55];

int x1[4]={0, 1, 0, -1};
int y2[4]={1, 0, -1, 0};

queue<grid> pos;
int bfs(int EX, int EY)
{
	memset(visit, 0, sizeof(visit));
	while(!pos.empty())
	{
		pos.pop();
	}
	grid star; star.X=1; star.Y=1;
	pos.push(star);
	visit[1][1]=1;
	int moves=0;
	while(!pos.empty())
	{
		moves++;
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int nowx=pos.front().X;
			int nowy=pos.front().Y;
			pos.pop();
			for(int z=0;z<4;z++)
			{
				int newx=nowx+x1[z];
				int newy=nowy+y2[z];
				if(newx>0 && newy>0 && newx<=EX && newy<=EY && !visit[newy][newx] && kotak[newy][newx]=='.')
				{
					visit[newy][newx]=1;
					if(newy==EY && newx==EX)
					{
						return moves;
					}
					grid nxt; nxt.X=newx; nxt.Y=newy;
					pos.push(nxt);
				}
			}
		}
	}
	return -1;
}

int main()
{
	int H, W;
	cin>>H>>W;
	int count=0;
	for(int a=1;a<=H;a++)
	{
		for(int b=1;b<=W;b++)
		{
			cin>>kotak[a][b];
			if((a==1 && b==1)) continue;
			if(kotak[a][b]=='.')
			{
				count++;
			}
		}
	}
	int h=bfs(W, H);
	if(h==-1)
	{
		cout<<-1;
	}
	else
	{
		cout<<count-h;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli unsigned long long int


int main() {
    lli n;
    cin>>n;
    lli min = 1000000000000000000, i;
    bool cond = false;
    for( i=1;i*i<=n;i++){
        if(n % i == 0){
            lli sum = i+ (n/i) -2;
            if(sum < min)
             min = sum;
        }
    }
    
 cout<<min<<endl;
     

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N = 2e5 + 10;
 
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a, b;
  cin >> a;
  cin >> b;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (a[i] == b[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int a, b, sum, digit;
    while(cin >> a >> b){
        sum = a + b;
        digit = 0;
        while(sum){
            sum = sum / 10;
            digit++;
        }
        cout << digit << endl;
    };
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<unordered_map>
#include<string>;
#include<bits/stdc++.h>
using namespace std;


int main() {

	int t;
	cin>>t;
	if(t<30){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var top, bottom, front, back, left, right, count int
	var command string = "WWWWSSSS"
	fmt.Scan(&top, &front, &right, &left, &back, &bottom, &count)

	for i := 0; i < count; i++ {
		var a, b int
		fmt.Scan(&a, &b)

		for i := 0; i < len(command); i++ {
			switch string(command[i]) {
			case "S":
				top, front, bottom, back = back, top, front, bottom
			case "N":
				top, front, bottom, back = front, bottom, back, top
			case "E":
				top, left, bottom, right = left, bottom, right, top
			case "W":
				top, left, bottom, right = right, top, left, bottom
			}
			if a == top {
				for j := 0; j < 4; j++ {
					front, left, back, right = right, front, left, back
					if b == front {
						fmt.Println(right)
					}
				}
				break
			}
		}
	}
}

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}



Measured memory_bytes: 1184
def get_max(ar, c):
    cnt = 0
    rtn = []
    rest = 0
    for a in ar:
        if a == "o" and rest <= 0:
            cnt += 1
            rest = c
        else:
            rest -= 1
        rtn.append(cnt)
    return rtn


n, k, c = map(int, input().split())
s = input().rstrip()

from_start = get_max(s, c)
from_last = get_max(s[::-1], c)[::-1]
for i in range(n):
    aa = 0 if i == 0 else from_start[i - 1]
    aaa = from_start[i]
    bb = 0 if i == n - 1 else from_last[i + 1]
    bbb = from_last[i]
    if aaa == aa + 1 and bbb == bb + 1 and aaa + bb == k:
        print(i + 1)


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

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

    int k, x;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
n = int(input())

l = len(str(n))

if l == 1:
    ans = n - 10**(l-1) + 1
    print(ans)
elif l == 2:
    print(9)
elif l == 3:
    ans = n - 10**(l-1) + 1 + 9
    print(ans)
elif l == 4:
    print(9+999-100+1)
elif l == 5:
    ans = n - 10**(l-1) + 1
    print(ans + 9+999-100+1)
elif l == 6:
    print(9+999-100+1 + 99999 - 10000 + 1)


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int N, temp, j, k;
    scanf("%d", &N);
    int A[N];
    for (int i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    for (j=1; j<N; j++) {
        for (int l=0; l<N; l++) {
            printf("%d", A[l]);
            if (l == (N - 1)) {
                putchar('\n');
            } else {
                putchar(' ');
            }
        }
        temp = A[j];
        k = j - 1;
        while ((k >= 0) && (A[k] > temp)) {
            A[k+1] = A[k];
            k--;
        }
        A[k+1] = temp;
    }
    for (int m=0; m<N; m++) {
        printf("%d", A[m]);
        if (m == (N - 1)) {
            putchar('\n');
        } else {
            putchar(' ');
        }
    }
    
    return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 H, W, N;
  cin >> H >> W >> N;

  map<tuple<i64, i64>, int> mp;
  REP(i, N) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    for (int r = a - 1; r <= a + 1; ++r) {
      if (r <= 0 || r >= H - 1) continue;
      for (int c = b - 1; c <= b + 1; ++c) {
        if (c <= 0 || c >= W - 1) continue;
        mp[{r, c}]++;
      }
    }
  }
  vector<i64> ans(10);
  i64 total = 0;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    int cnt = it->second;
    assert(cnt > 0);
    assert(cnt < 10);
    ans[cnt]++;
    total++;
  }
  ans[0] = (H - 2) * (W - 2) - total;
  REP(i, 10) { cout << ans[i] << '\n'; }
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll x;
  cin >> x;

  cout << (2000-x+199)/200 << endl;

  return 0;
}


Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n;
    double ans=0;
    cin>>n;
    rep(i,n){
        double a;
        cin>>a;
        ans+=1/a;
    }
    ans=1/ans;
    printf("%.10f",ans);
}

Measured memory_bytes: 3732
#69 ベクトルと行列の積

n, m = map(int,input().split())

a = []
for i in range(n):
    a.append(list(map(int,input().split())))

b = []
for i in range(m):
        b.append(int(input()))

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



Measured memory_bytes: 6008
function Main(input){
  
  input = input.split("\n");
  N = parseInt(input[0]);
  A = input[1].split(" ");
  var S = Array(N+1);
  for(var x=0;x<N;x++){
    S[A[x]] = x;
  }
  S.shift();
    
  for(var x=0;x<N;x++){
    console.log(S[x]+1);
  }
}

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

Measured memory_bytes: 34276
#include<bits/stdc++.h>
using namespace std;
char c[3][3];
int main()
{
	int i,j;
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			scanf("%c",&c[i][j]);
		}
		getchar();
	}
	for(i=0;i<3;i++)
	{
		printf("%c",c[i][i]);
	}
	return 0;
}

Measured memory_bytes: 256
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  import numpy as np #pypy不可
  n,k = map(int,readline().split())
  p =  np.array(read().split(),np.int32)
  np.cumsum(p,out=p)
  chk = p[k-1]
  for i in range(n-k):
    c = p[i+k]-p[i]
    chk = max(c,chk)
  print((chk+k)/2)
if __name__ == '__main__':
    main()

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

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

  int A[2] = {0};
  rep(i,0,N-1) {
    int a;
    cin >> a;
    a % 2 == 0 ? A[0]++ : A[1]++;
  }

  ll ans = 0;
  for (int i = 1;; ++i) {
    int times = i * 2 - 1;
    if (A[1] < times) break;

    ll max_denominator = times;
    ll min_numerator = A[1] - times + 1;

    ll numerator = 1, denominator = 1;
    rep(j,0,times-1) {
      ll current = A[1] - j;
      if (current <= max_denominator) break;
      numerator *= current;
    }

    rep(j,0,times-1) {
      ll current = j + 1;
      if (min_numerator <= current) break;
      denominator *= current;
    }

    ans += numerator / denominator;
  }

  ans *= pow(2, A[0]);

  if (P == 0) {
    ll total = pow(2, N);
    ans = total - ans;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int cake[101];

int main(){
    int k, t;
    cin >> k >> t;
    int mx = 0;
    rep(i, t){
        cin >> cake[i];
        mx = max(cake[i], mx);
    }
    int others = k - mx;
    cout << max(mx - others - 1, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
#define ll long long
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define MOD 998244353
#define endL << '\n'
#define ii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define endL << '\n'
#define vii vector<ii>
#define pb push_back

/*
ll powmod(ll x, ll y, ll mod){
	ll res = 1;
	while (y > 0){
		if (y%2) res = (res*x) % mod;
		x = (x*x) % mod;
		y /= 2;
	}
	return res;
}
*/

/*const int N = 1000000;
int lp[N+1];
vector<ll> pr;

void sieve(){
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}*/

const int maxV = 100001;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; //cin >> t;
	while(t--){
		string s, t; cin >> s >> t;
		int n = s.length(), m = t.length();
		vvi dp(n+1, vi(m+1, 0));
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				if (s[i-1] == t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
				else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}

		string ans = ""; int len = dp[n][m];
		int x = n, y = m;
		for (int i = 0; i < len; i++){
			if (s[x-1] == t[y-1]){
				ans += s[x-1];
				x--; y--;
				continue;
			}
			if (dp[x][y] == dp[x-1][y]){x--; i--;}
			else if (dp[x][y] == dp[x][y-1]) {y--; i--;}
		}
		reverse(ans.begin(), ans.end());
		cout << ans;
	}
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main()
{
    ll N;
    cin >> N;
    string stones;
    cin >> stones;
    
#ifdef SOURCE_TEST
    stones =  "";
    for ( ll i = 0; i < 200000; ++ i ){
        stones += (i%2)?"W":"R";
    }
#endif

    ll count = 0;
    ll wIndex = stones.find('W');
    ll rIndex = stones.find_last_of("R");

    if ( wIndex != string::npos && rIndex != string::npos) {
        while( wIndex < rIndex ){
            swap(stones[wIndex], stones[rIndex]);
            ll w = wIndex;
            ll r = rIndex;
            wIndex = stones.find('W', w);
            rIndex = stones.find_last_of("R", r);
            count++;
        }
    }

#ifdef SOURCE_TEST
    cout << stones << endl;
    cout << wIndex << ":" << rIndex << endl;
#endif
cout << count << endl;

    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A = 0, B = 0, AN = 1, BN = 0;
	cin >> A;
	int dame = 0;
	rep(i, N - 1) {
		int a;
		cin >> a;
		if (!B) {
			if (A == a) AN++;
			else if (abs(a - A) == 1) {
				B = a;
				BN++;
				if (A < B) {
					swap(A, B);
					swap(AN, BN);
				}
			}
			else dame = 1;
		}
		else {
			if (A == a) AN++;
			else if (B == a) BN++;
			else dame = 1;
		}
	}

	if (dame) co("No");
	else if (B == 0 && A == N - 1) co("Yes");
	else {
		A -= BN;
		if (A <= 0) co("No");
		else if (A * 2 > AN) co("No");
		else co("Yes");
	}

	Would you please return 0;
}

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

using namespace std;

int main()
{
    char ch[5], c = '0';
    scanf("%s", &ch);
    for(int i = 0; i < 3; i++){
        if(ch[i] == '7'){
            c = '1';
            break;
        }
    }
    if(c == '1') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>

int main() {
	int n;
	std::cin >> n;
	int a[n];
	for (int i = 0;i<n;i++) {
		std::cin >> a[i];
	}
	int max = a[0], min = a[0];
	long long int sum = 0;
	sum += a[0];
	for (int i = 1;i<n;i++) {
		if (a[i]<min)min = a[i];
		if (a[i]>max)max = a[i];
		sum += a[i];
	}
	std::cout << min << " " << max << " " << sum << std::endl;
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int x;
	cin >> x;
	cout << x * x * x << endl;
}




Measured memory_bytes: 3180
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){

    int i,j,k;
    char line[256];
    int N,v;

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d",&N);

    printf("%d",N/3);

    return 0;
}

Measured memory_bytes: 128
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))

h,w = inpl()
a,b = inpl()
print(h*w-(a*w+h*b-a*b))

Measured memory_bytes: 5080