akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define bit_cnt(n) (__builtin_popcountll(n))
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll binpow(ll x, ll e,ll d=1) {//もともとの数,MOD-2
  ll ret = d, p = x;
  while(e > 0) {
    if(e%2 == 0) {p = p*p%MOD; e /= 2;}
    else {ret = ret*p%MOD; e--;}
  }
  return ret;
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(int i=0;i<n;i++)cin>>A[i];
  ll fact = 1;
  for(int i=0;i<n;i++){fact*=(i+1);fact%=MOD;}
  ll rui[n+10]={};
  for(int i=0;i<n;i++){
    rui[i+1]=(rui[i]+(fact*binpow(i+1,MOD-2))%MOD)%MOD;
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ll hoge=rui[i+1];
    hoge%=MOD;
    hoge+=(rui[n-i]-rui[1]+MOD)%MOD;
    hoge%=MOD;
    ans+=A[i]*hoge%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int lim = 2e5+7;
#define pb push_back
vector<int>grp[lim];
bool visited[lim];
int dist[lim];
void dfs(int src)
{
	visited[src] = true;
	for(auto it:grp[src])
	{
		if(!visited[it])
		{
			dfs(it);
		}
		dist[src] = max(dist[src],1+dist[it]);
		
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		grp[u].pb(v);
	}
	fill_n(visited,lim,false);
	fill_n(dist,lim,0);
	for(int i=1;i<=n;i++)
	{
		if(visited[i]==false)
		{
			dfs(i);
			//ans = max(ans,dis);
		}
	}
	int ans = INT_MIN;
	for(int i=1;i<=n;i++)
	{
		ans = max(ans,dist[i]);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() { 
  ll n,ans;
  cin >> n;
  vector<ll> a(n);
  REP(i,n){cin>>a[i];}
  sort(ALL(a));
  a.erase(unique(ALL(a)), a.end());
  ans = a[0];
  REP(i, a.size()) { ans = gcd(ans, a[i]); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
# -*- coding: utf-8 -*-

N=input()

#約数列挙
def make_divisors(n):
    divisors=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n/i:
                divisors.append(n/i)
    return divisors

def func(a,b):
    return a**5-b**5

L=make_divisors(N)
for yakusu in L:
    for a in range(1,10**3):
        b=a-yakusu
        if func(a,b)==N:
            print a,b
            quit()


Measured memory_bytes: 72940
import scala.io.StdIn.{readLine,readInt}

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val s = readLine.split(" ").map(_.toInt)
    val q = readInt
    val t = readLine.split(" ").map(_.toInt)
    println(t.filter(s.contains(_)).length)
  }
}

Measured memory_bytes: 52360
import java.util.*;
import java.util.stream.Stream;


public class Main {

    private static int N;
    private static int M;
    private static int[] max;

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a*b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  int S = accumulate(begin(A), end(A), 0);
  int ret = inf, T = 0;
  for(int i = 0; i < N; i++) {
    T += A[i];
    chmin(ret, abs((S - T) - T));
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = true;

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

  map<string, int> days;
  days["SUN"] = 0;
  days["MON"] = 1;
  days["TUE"] = 2;
  days["WED"] = 3;
  days["THU"] = 4;
  days["FRI"] = 5;
  days["SAT"] = 6;

  string d;
  cin >> d;

  cout << 7 - (days[d] - days["SUN"]) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,a,b,i,j,k,n,x;

     cin>>a>>b;
     string s[a+5];
     for(i=0;i<a;i++)
     {
         cin>>s[i];
     }
     for(i=0;i<a;i++)
     {
         cout<<s[i]<<endl;
         cout<<s[i]<<endl;
     }
     return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define Long long long
#define fastIO ios::sync_with_stdio(0) , cin.tie(0)

#define all(v) v.begin() ,v.end()
#define rall(v) v.rbegin(),v.rend()
#define forn(i,n) for(__typeof(n) i=0 ;i<n ;++i)
#define pb push_back
#define debug(x) cout << "[ " << #x << " = " << x << " ]\n"

#define PI acos(-1.0)
#define EPS 1e-6
#define MOD 1e9+7

const int MXS = 2e5 + 5 ;
const Long MX = 1e18 + 5 ;


int main(){
    fastIO;
    string s;
    cin >> s;
    if( s== "ABC") cout << "ARC";
    else cout << "ABC";
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = list(input())
B = list(input())
C = list(input())
from collections import Counter
ans = 0
for i in range(N):
    da = [A[i],B[i],C[i]]
    c = Counter(da)
    li = list(c.values())
    li.sort()
    ans += 3-li[-1]
print(ans)

Measured memory_bytes: 3316
n = gets.chomp.to_i
k = []
n.times do |i|
  k[i] = gets.chomp.split.map(&:to_i)
end

dp = Array.new(10 ** 5 + 5) { Array.new(3, 0) }
dp[0][0] = 0
dp[0][1] = 0
dp[0][2] = 0

1.upto(n) do |i|
  (0..2).each do |j|
    max = 0
    (0..2).each do |d|
      next if d == j
      tmp = dp[i-1][d] + k[i-1][d]
      max = tmp if tmp > max
    end
    dp[i][j] = max
  end
end
p [dp[n][0], dp[n][1], dp[n][2]].max


Measured memory_bytes: 11900
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
unique = set(range(0, 102)) - set(p)
ans = {}
ans2 = []
for i in unique:
  calc = abs(x-i)
  if calc in ans.keys():
    ans[calc] = min(ans[calc], i)
  else:
    ans[calc] = i
  ans2.append(calc)
print(ans[min(ans2)])

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

using namespace std;

int64_t solve(const std::vector<int>& as) {
  int64_t max = 0;
  auto const endItr = as.cend() - 1;
  for (auto itr = as.cbegin(); itr != endItr; itr++) {
    auto const a = *itr;
    if (*(itr + 1) != a) {
      continue;
    }
    if (max) {
      return max * a;
    }
    max = a;
    itr++;
  }
  return 0;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::sort(as.rbegin(), as.rend());
  std::cout << solve(as) << std::endl;
  return 0;
}

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

constexpr int D = 365;
constexpr int T = 26;
int c[D];
int s[D][T];

int maxday[T];
int last[T];
int score = 0;
vector<int> ans;

void Input() {
    int tmp; cin >> tmp;
    REP(i, T) cin >> c[i];
    REP(i, D) REP(j, T) cin >> s[i][j];
    return;
}

int CalcMaxDay(int type) {
    int max_profit = s[type][0], argmax = 0;
    REP(day, D) {
        if(s[type][day] > max_profit) {
            max_profit = s[type][day];
            argmax = day;
        }
    }
    return argmax;
}

double lambda2 = 5.8; // 6.1 is better

int FindMaxProfitContest(int day) {
    double max_profit = -1e9;
    int argmax = -1;
    REP(type, T) {
        double profit = 0;
        profit += s[day - 1][type];
        // if(maxday[type] == day) profit += lambda1 * s[day - 1][type];
        profit += lambda2 * c[type] * (day - last[type]);
        if(profit > max_profit) {
            max_profit = profit;
            argmax = type;
        }
    }
    return argmax;
}

void Commit(int day, int contest) {
    ans.push_back(contest);
    last[contest] = day + 1;
    score += s[day - 1][contest];
    REP(type, T) score -= c[type] * (day - last[type]);
    return;
}



void ReverseClimbing() {

}

void Output() {
    for(auto contest: ans) cout << contest + 1 << endl;
    return;
}

int main() {
    Input();
    REP(i, T) maxday[i] = CalcMaxDay(i);
    for(int day = 1; day <= D; day++) {
        int contest = FindMaxProfitContest(day);
        Commit(day, contest);
    }
    Output();
    // cerr << score << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    ll D;
    cin >> D;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll X, Y;
        cin >> X >> Y;
        if (X*X+Y*Y <= D*D) ans++;
    }
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a, long p) {return powmod(a, mod-2);}


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

    string s;
    cin>>s;
    if(s=="AAA" ||s=="BBB")cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
    }


Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
struct Segment{Point p1,p2;};
typedef Segment Line;
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
int ccw(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if(cross(a,b)>EPS) return 1;
	if(cross(a,b)<-EPS) return -1;
	if(dot(a,b)<-EPS) return 2;
	if(a.abs()<b.abs()) return -2;
	if(a.abs()>=b.abs()) return 0;
}
bool intersect(Segment s1,Segment s2){
	Point p1=s1.p1,p2=s1.p2;
	Point p3=s2.p1,p4=s2.p2;
	return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0 );
}
double disPtP(Point a,Point b){
	return (b-a).abs();
}
double disLtP(Line l,Point p){
	return fabs(cross(l.p2-l.p1,p-l.p1)/(l.p2-l.p1).abs());
}
double disStP(Segment s,Point p){
	if(dot(p-s.p1,s.p2-s.p1)<0.0) return (p-s.p1).abs();
	if(dot(p-s.p2,s.p1-s.p2)<0.0) return (p-s.p2).abs();
	return disLtP(s,p); 
}
double disStS(Segment s1,Segment s2){
	if(intersect(s1,s2)) return 0.0;
	return min(min(disStP(s1,s2.p1),disStP(s1,s2.p2)),min(disStP(s2,s1.p1),disStP(s2,s1.p2)));
}
main(){
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Point p1(x1,y1),p2(x2,y2);
		Segment s1;
		s1.p1=p1;s1.p2=p2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Point p3(x1,y1),p4(x2,y2);
		Segment s2;
		s2.p1=p3;s2.p2=p4;
		printf("%.10lf\n",disStS(s1,s2));
	}
}


Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

string replace_with_str(string str, string str_from, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(str_from, pos), pos != string::npos) {
        str.replace(pos, str_from.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(int argc, char const *argv[]){
    int N, M;
    int T[100], P[100], X[100];
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        cin >> T[i];
    }
    scanf("%d", &M);
    for(int i=0; i<M; i++){
        cin >> P[i] >> X[i];
    }

    // 出力
    int all_time = 0;
    for(int i=0; i<N; i++){
        all_time += T[i];
    }
    for(int i=0; i<M; i++){
        int ans = all_time;
        ans -= T[P[i]-1];
        ans += X[i];
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    N=int(input())
    edge = [[]for _ in range(N)]
    for _ in range(N-1):
        u,v,w = map(int,input().split())
        u,v = u-1,v-1
        edge[u].append((v,w))
        edge[v].append((u,w))
    color = [-1]*N
    color[0]=0
    stack = [(0,0)]
    while stack:
        v,col = stack.pop()
        for to,dist in edge[v]:
            if color[to]!=-1:
                continue
            c = (col+dist)%2  # 色
            color[to] = c
            stack.append((to,c))
    print(*color,sep="\n")
            

if __name__ == '__main__':
    main()


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

map<long long,int> mp;
int i=1;

void f(long long n){
  long long cal;
  if(n%2==0){
    cal=n/2;
  }else{
    cal=3*n+1;
  }
  i++;
  if(mp[cal]==1){
    cout << i << endl;
  }else{
    mp[cal]++;
    f(cal);
  }
}


int main(){
  long long s;
  cin >> s;
  mp[s]++;
  f(s);
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
result = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):

            result = 500*i + 100*j + 50*k
            if x == result:
                count = count + 1

print(count)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string st; cin >> st;
	if (st.size() % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	bool f = true;
	for (int i = 0; i < st.size(); i += 2) {
		if (st[i] != 'h' || st[i + 1] != 'i')f = false;
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define PB push_back
const long long int TOP=1e13;
const int N=1510;
struct bignum{
    int size;
    vector<long long int>val;
    void init(int n){
        val.clear();
        val.PB(n);
        pull();
        return ;
    }
    void pull(){
        int k=0;
        for(int i=0;i<val.size();i++){
            val[i]+=k;
            k=0;
            if(val[i]>=TOP){
                k=val[i]/TOP;
                val[i]%=TOP;
            }
        }
        if(k>0)val.PB(k);
        size=(int)val.size();
    }
    void out(){
        long long int now;
        reverse(val.begin(),val.end());
        printf("%lld",val[0]);
        for(int i=1;i<size;i++){
            now=TOP/10;
            while(val[i]<now){
                now/=10;
                printf("0");
            }
            printf("%lld",val[i]);
        }
        printf("\n");
        reverse(val.begin(),val.end());
        return ;
    }
    void operator *=(long long int n){
        for(int i=0;i<size;i++)val[i]*=n;
        pull();
        return ;
    }
    void operator +=(long long int n){
        val[0]+=n;
        pull();
        return ;
    }
};
int main(){
    int n,dp[N];
    bignum a;
    scanf("%d",&n);
    n++;
    a.init(2);
    for(int i=3;i<=N;i+=2){
        dp[i]=0;
        dp[i-1]=2;
    }
    for(int i=3;i<=n;i+=2)if(dp[i]==0){
        dp[i]=i;
        for(int j=i*i;j<=n;j+=(i<<1))dp[j]=i;
        a*=i;
    }
    a+=2;
    a.out();
    for(int i=2;i<=n;i++)printf("%d\n",dp[i]);
}


Measured memory_bytes: 2752
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AGrouping {
public:
	void solve(istream& in, ostream& out) {
        int x, y;
        in >> x >> y;
        if(x == 2 || y == 2) out << "No" << endl;
        else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 4 || y == 6 || y == 9 || y == 11)) {
            out << "No" << endl;
        }else if((y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) && (x == 4 || x == 6 || x == 9 || x == 11)) {
            out << "No" << endl;
        }else{
            out << "Yes" << endl;
        }
	}
};

int main() {
	AGrouping solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int n;
int MAXIMUM=100005;
long INF = 1e15;
// W:未訪問
// G:訪問する候補
// B:訪問済み
int W=0,G=1,B=2;
vector<pair<int,int>> adj[100005];
long d[100005];
long c[100005];
void dijkstra(int K){
  priority_queue<pair<int,int>> PQ;
  int u,minv;
  int color[MAXIMUM];
  // d[n]:Tに属する頂点と V - T に属する頂点をつなぐ辺の中で重みが最小の辺の重みを記録

  //初期化
  for(int i=0;i<n;i++){
    d[i]=INF;
    color[i]=W;
  }

  d[K]=0;
  PQ.push(make_pair(0,K));
  color[K] = G;

  while (!PQ.empty()) {
    pair<int,int> f = PQ.top();
    PQ.pop();
    u = f.second;
    // 頂点を訪問済に
    color[u] = B;
    //最小値を取り出し、それが最短でなければ無視
    if( d[u]<f.first*(-1)) continue;

    //訪問済みでないかつ辺がつながっている頂点の中でコストが最小の辺を選択
    for(int j=0;j<adj[u].size();j++){
      int v = adj[u][j].first;
      if(color[v]== B) continue;
      if(d[v]>d[u]+adj[u][j].second){
        d[v]=d[u]+adj[u][j].second;
        PQ.push(make_pair(d[v]*(-1),v));
        color[v]=G;
      }
    }
  }


}

int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
      adj[a-1].push_back(make_pair(b-1,c));
      adj[b-1].push_back(make_pair(a-1,c));
    }

  dijkstra(0);
  for(int i=0;i<n;i++){
    if(d[i]%2) cout<<0<<endl;
    else cout<<1<<endl;
  }

}


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

typedef long long ll;

#define PB push_back
bool checkSame(int a[], int b[], int n) {
	for (int i = 0; i < n; ++i) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int p[n]; 
	int ps[n];
	for (int i = 0; i < n; ++i) {
		int pi; cin >> pi;
		p[i] = pi;
		ps[i] = pi;
	}
	sort(ps, ps+n);
	string result = "NO";
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j < n; ++j) {
			int tmpA = p[i];
			int tmpB = p[j];
			p[i] = tmpB;
			p[j] = tmpA;
			
			if (checkSame(p, ps, n)) {
				result = "YES";
				break;
			}
			p[i] = tmpA;
			p[j] = tmpB;
		}
	}
	cout << result << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        long count=0;
        for (int i = 1; i <=n ; i++) {
            if(i%3==0 || i%5==0)
                continue;
            else
                count+=i;
        }
        System.out.println(count);
    }
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse

//最小公倍数-1のmod?
//感覚で解くのよくなかった

int main(){
    int N,ans=0;
    cin>>N;
    vector<int> A(N);
    rep(i,N){
        cin>>A[i];
        ans+=A[i]-1;
    }
    cout<<ans<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
import itertools

H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]
memo = [[0] * W for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if S[i][j] == '#':
        memo[i][j] = '#'
        for k, l in itertools.product(range(-1, 2), repeat=2):
            if 0 <= i+k and i+k<H and 0<=j+l and j+l<W and memo[i+k][j+l] != '#':
                memo[i+k][j+l] += 1
[print(''.join(map(str, _))) for _ in memo]


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,q;
int a[21],b[21];
ll x[10005],y[100005],w[100005],z[100005];
int main()
{
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++)
    cin>>w[i]>>x[i]>>y[i]>>z[i];
    for(int i=1;i<m;i++)
    b[i]=0;
    for(int i=m;i<n+m;i++)
    b[i]=1;
    ll ans=0;
    do{
        int val=1,cnt=0;
        for(int i=1;i<m+n;i++)
        {
            if(!b[i]) val++;
            else a[++cnt]=val;
        }
        ll res=0;
        for(int i=1;i<=q;i++)
        if(a[x[i]]-a[w[i]]==y[i]) res+=z[i];
        ans=max(ans,res);
    }while(next_permutation(b+1,b+m+n));
    cout<<ans;
}   

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

#define inf 2000000000
#define min(a,b) ((a)<(b)?(a):(b))

int n,m,rr[10],r;
long long dis[500][500];
long long ans=inf;

void warshall_floyd(){
	int i,j,k;
	for(k=0;k<n;k++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
}

int dfs(int d,int *a,long long co,int now){
	if(d==1){
		ans=min(ans,co);
		return 0;
	}
	int i;
	for(i=0;i<r;i++){
		if(a[i]==0){
			a[i]=1;
			dfs(d-1,a,co+dis[now][rr[i]],rr[i]);
			a[i]=0;
		}
	}
}

int main(){
	int i,j;
	scanf("%d%d%d",&n,&m,&r);
	for(i=0;i<r;i++){
		scanf("%d",&rr[i]);
		rr[i]--;
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			dis[i][j]=inf;
		}
		dis[i][i]=0;
	}
	for(i=0;i<m;i++){
		int a,b;
		long long c;
		scanf("%d%d%lld",&a,&b,&c);
		dis[a-1][b-1]=c;
		dis[b-1][a-1]=c;
	}
	warshall_floyd();
	int a[10]={0};
	for(i=0;i<r;i++){
		a[i]=1;
		dfs(r,a,0,rr[i]);
		a[i]=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt64()
	d := make([]sortTarget0, n)
	for i := range d {
		d[i].a = readInt64()
		d[i].b = readInt64()
	}

	sort.Sort(sortTarget0Slice(d))
	var ans int64
	for i := 0; i < len(d) && m > 0; i++ {
		b := minInt64(d[i].b, m)
		ans += d[i].a * b
		m -= b
	}
	println(ans)

}

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

type sortTarget0 struct {
	a int64
	b int64
}

type sortTarget0Slice []sortTarget0

func (s sortTarget0Slice) Len() int {
	return len(s)
}

func (s sortTarget0Slice) Less(i, j int) bool {
	return s[i].a < s[j].a
}

func (s sortTarget0Slice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 3840
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;

const long MOD = 1e9+7;


int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	long hit = 0;
	int n; cin >> n;
	string s; cin >> s;

	long res = 1;
	{
		long fac = 1;
		for(long i = 1; i <= n; i++) fac = (fac*i)%MOD;
		long hit = 0;

		for(int i = 0; i < 2*n; i++)
		{
			if(hit&1)
			{
				// cout << "A\n";
				if(s[i] == 'W')
					hit++;
				
				if(s[i] == 'B')
				{
					if(hit)
					{
						res = (1LL*res*hit)%MOD;
						hit--;
					}
					else
					{
						cout << "0\n";
						return 0;
					}
				}
			}
			else 
			{
				// cout << "B\n";
				if(s[i] == 'B')
					hit++;
				if(s[i] == 'W')
				{
					if(hit)
					{
						res = (1LL*res*hit)%MOD;
						hit--;
					}
					else
					{
						cout << "0\n";
						return 0;
					}
				}
			}
			// cout << hit << " " << s[i] << "\n";
		}
		if(hit == 0)
			cout << (res*fac)%MOD << "\n";
		else cout << "0\n";
	}
}










Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int n;
    cin >> n;
    VI b(n-1);
    VI a(n);
    for(int i=0; i<n-1; ++i)cin >> b[i];
    a[0] = b[0];
    for(int i=1; i<n-1; ++i){
        a[i] = min(b[i-1], b[i]);
    }
    a[n-1] = b[n-2];
    

    ll ans = accumulate(a.begin(),a.end(),0);

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int main() {
	while(1) {
		int a, b;
		char s[3];
		int ret;
		cin >> a >> s >> b;
		if(!strcmp(s,"?")) break;
		else if(!strcmp(s,"+")) ret = a + b;
		else if(!strcmp(s,"-")) ret = a - b;
		else if(!strcmp(s,"*")) ret = a * b;
		else ret = a / b;
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
class Dice():
    directions = "EEENEEENEEESEEESEEENEEEN"

    def __init__(self, lst):
        self.top = lst[0]
        self.front = lst[1]
        self.right = lst[2]
        self.left = lst[3]
        self.back = lst[4]
        self.bottom = lst[5]

    def rotate(self, direction):
        if direction == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        if direction == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        if direction == "S":
            self.top, self.front, self.bottom, self.back = self.back, self.top, self.front, self.bottom
        if direction == "W":
            self.top, self.left, self.bottom, self.right = self.right, self.top, self.left, self.bottom

    def fit_top_front(self, num_top, num_front):
        for direction in Dice.directions:
            if self.top == num_top and self.front == num_front:
                break
            self.rotate(direction)

    def fit_all(self, dice):
        for direction in Dice.directions:
            if self.top == dice.top and self.front == dice.front and self.right == dice.right and self.left == dice.left and self.back == dice.back and self.bottom == dice.bottom:
                return True
            self.rotate(direction)
        return False


def main():
    diceA_nums = list(map(int, input().split()))
    diceA = Dice(diceA_nums)

    diceB_nums = list(map(int, input().split()))
    diceB = Dice(diceB_nums)

    result = diceB.fit_all(diceA)
    if result == True:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()



Measured memory_bytes: 5608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, l, r) for(int i = (l); i < (r); i++)
#define INF 1000000
#define all(x) (x).begin(), (x).end()

vector<vector<int>> a;
vector<int> dp;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(3, -1));
    rep(i, n){
        cin >> v.at(i).at(0) >> v.at(i).at(1) >> v.at(i).at(2);
    }
    vector<vector<int>> dp(n + 1, vector<int>(3, -1));
    dp.at(0) = {0,0,0};
    repi(i, 1, n + 1){
        dp.at(i).at(0) = max(dp.at(i - 1).at(1) + v.at(i - 1).at(0), dp.at(i - 1).at(2) + v.at(i - 1).at(0));
        dp.at(i).at(1) = max(dp.at(i - 1).at(0) + v.at(i - 1).at(1), dp.at(i - 1).at(2) + v.at(i - 1).at(1));
        dp.at(i).at(2) = max(dp.at(i - 1).at(0) + v.at(i - 1).at(2), dp.at(i - 1).at(1) + v.at(i - 1).at(2));
    }
    int ans = 0;
    rep(i, 3){
        ans = max(ans, dp.at(n).at(i));
    }
    cout << ans << endl;
    return 0;
}


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


int main()
{
    std::ios_base::sync_with_stdio(0);	
    cin.tie(0);
    cout.tie(0);
    
	
	ll 	H,N;
	cin>>H>>N;
	
	ll arr[N];
	ll s = 0;
	for(ll i=0;i<N;i++)
	{
		cin>>arr[i];
		s+=arr[i];
	}
	
	if(!(s>=H))
	{
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	
}


Measured memory_bytes: 1024
def manh(coord_x, coord_y):
    return abs(coord_x + coord_y)

def main():
    N = int(input())
    nt, nx, ny = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        d = manh(x - nx, y - ny)
        T = t - nt

        if d > T or (d - T) & 1:
            print("No")
            return
        
        nt, nx, ny = t, x, y
    
    print("Yes")
        

if __name__ == "__main__":
    main()

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

int main(){
  
int n;
cin>>n;
vector<int>a(n,0);
vector<int>b(n,0);
vector<int>c(n,0);
for(int i=0;i<n;i++)
{
  cin>>a[i]>>b[i]>>c[i];
}
vector<vector<int>>dp(n,vector<int>(3,0));
for(int i=0;i<n;i++)
{
  for(int j=0;j<3;j++)
  {
    if(i==0)
    {
      if(j==0)dp[i][j]=a[0];
      else if(j==1)dp[i][j]=b[0];
      else dp[i][j]=c[0];
    }
    else
    {
      if(j==0)
      {
        dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i];
      }
      else if(j==1)
      {
        dp[i][j]=max(dp[i-1][0],dp[i-1][2])+b[i];
      }
      else
      {
        dp[i][j]=max(dp[i-1][1],dp[i-1][0])+c[i];
      }
    }
    
  }
}
  int ret=0;
  ret=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<ret<<endl;
  
  
}


Measured memory_bytes: 6912
from functools import reduce

n = int(input())

S = [0] * 13
H = [0] * 13
C = [0] * 13
D = [0] * 13

for i in range(n):
    mark, num = input().split()
    num = int(num) - 1
    if mark == 'S':
        S[num] = 1
    elif mark == 'H':
        H[num] = 1
    elif mark == 'C':
        C[num] = 1
    elif mark == 'D':
        D[num] = 1

for s in range(len(S)):
    if S[s] == 0:
        print('S ' + str(s + 1))

for h in range(len(H)):
    if H[h] == 0:
        print('H ' + str(h + 1))

for c in range(len(C)):
    if C[c] == 0:
        print('C ' + str(c + 1))

for d in range(len(D)):
    if D[d] == 0:
        print('D ' + str(d + 1))



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

int main() {
  int N, M, X = 0;
  
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for (int j = 0; j < M; j++) {
    cin >> t.at(j);
  }

  vector<int> p(N);
  for (int k = 0; k < N; k++) {
    for (int i = k; i < N; i++) {
      p.at(k) += (s.at(k) == s.at(i));
    }
    for (int j = 0; j < M; j++) {
      p.at(k) -= (s.at(k) == t.at(j));
    }
  }

  for (int k = 0; k < N; k++) { 
    if ( p.at(k) > X) {
      X = p.at(k);
    }
    else {
      continue;
    }
  }
  
  cout << X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s, t;
    cin>>s>>t;

    ll n = sz(s);
    ll cnt = 0;
    rep(i, n) if (s[i] != t[i]) cnt++;
    cout<<cnt<<endl;
}

Measured memory_bytes: 3808
while True:
    a, b, c = input().split()
    if b == '?':
        break
    a = int(a)
    c = int(c)
    if b == '+':
        print(a + c)
    if b == '-':
        print(a - c)
    if b == '*':
        print(a * c)
    if b == '/':
        print(a // c)



Measured memory_bytes: 5596
//huc.c C-Minimization
#include<stdio.h>

int main(void){
    int n,k,ans=0;
    scanf("%d %d",&n,&k);
    int a[n];
    for(int i=0;i<n;++i){
        scanf("%d",&a[i]);
    }

    int num;
    for(int i=0;i<n;++i){
        if(a[i]==1){
            num = i;
        }
    }

    if((n-1)%(k-1)==0){
        ans += (n-1)/(k-1);
    }else{
        ans += (n-1)/(k-1) + 1;
    }

    printf("%d\n",ans);
    return 0;
}

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

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

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root;

void insert(int k)
{
	Node *y = nullptr;
	Node *x = root;
	Node *z ;

	z = new Node;
	z->key = k;
	z->left = nullptr;
	z->right = nullptr;

	while(x!=nullptr)
	{
		y=x;
		if(z->key<x->key)
		{
			x = x->left;
		}
		else
		{
			x = x ->right;
		}
	}
	
	z -> parent = y;
	if(y == nullptr)
	{
		root = z;
	}
	else
	{
		if(z->key < y->key)
		{
			y->left = z;
		}
		else
		{
			y -> right = z;
		}
	}
}

void inorder(Node *u)
{
	if(u == nullptr)return;
	inorder(u->left);
	cout<<' '<<u->key;
	inorder(u->right);
}

void preorder(Node *u)
{
	if(u==nullptr)return;
	cout<<' '<<u->key;
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,x;
	cin >> n;
	string s;
	for(int i =0;i<n;i++)
	{
		cin >> s;
		if(s=="insert")
		{
			cin >> x;
			insert (x);
		}
		else
		{
			inorder(root);cout<<endl;
			preorder(root);cout<<endl;
		}
	}
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int or1or3or6or(int x,int y,int z){
  if(x == y && y == z)
    return 1;
  else if((x-y)*(y-z)*(z-x) == 0)
    return 3;
  else
    return 6;
}
int main(){
  int k,s;
  cin >> k >> s;
  
  int a,b,c,ans = 0;
  
  FOR(i,0,k+1){
    FOR(j,i,k+1){
      a = i;
      b = j;
      c = s-(i+j);
      
      if(b > c)continue;
      
      if(c > k)continue;
      
      ans += or1or3or6or(a,b,c);
    }
  }
  
  cout << ans << endl;
}

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

namespace atcoder_BegginerContest93_Question1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            if (input.Contains('a') && input.Contains('b') && input.Contains('c'))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11612
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int N;
	cin >> N;
	if (N%10==0|| N % 10 == 1|| N % 10 == 6|| N % 10 == 8)
	{
		cout << "pon";
	}

	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7||N%10==9)
	{
		cout << "hon";
	}

	if (N % 10 == 3 )
	{
		cout << "bon";
	}
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int x, y;
	cin >> x >> y;
	for(int i = 0; i <= x; i++) {
		if(i*2 + (x-i)*4 == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3588
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][][] house = new int[4][3][10];

		for(int i=0;i<n;i++){
			int tou = scan.nextInt();
			int floor = scan.nextInt();
			int room = scan.nextInt();
			int people = scan.nextInt();

			house[tou-1][floor-1][room-1]=house[tou-1][floor-1][room-1]+people;
		}

		for(int i=0;i<4;i++){
			for(int j=0;j<3;j++){
				for(int k=0;k<10;k++){
					if(house[i][j][k]>0){
						System.out.print(" "+house[i][j][k]);
					}else{
						System.out.print(" 0");
					}
				}
				System.out.println();
			}
			if(i!=3){
				for(int j=0;j<20;j++){
					System.out.print("#");
				}
				System.out.println();
			}
		}

	}

}

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

const ll INF = 1LL << 60;

void chmax(ll &a, ll b){
  if( a < b){ swap(a,b);} return ;}

void chmin(ll &a, ll b){
  if( a > b){ swap(a,b);} return ;}

int main(){
ll N,Z,W; cin >> N >> Z >> W;
   vector<ll> A(N);
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  vector<vector<ll>> dp(N, vector<ll> (2));
  
  for(ll i = N-1; i >= 0; i--){
    ll Y; 
    dp[i][0] = -INF;
    if(!i){ Y = W;} else{ Y = A[i-1];}
    
    chmax(dp[i][0], abs(Y-A[N-1]));
    
    for(ll j = i+1; j < N; j++){ chmax( dp[i][0], dp[j][1]);}
    
    ll X; 
    dp[i][1] = INF;
    if(!i){ X = Z;} else{ X = A[i-1];}
    
    chmin( dp[i][1], abs( X-A[N-1]));
    
    for(ll j = i+1; j < N; j++){ chmin( dp[i][1], dp[j][0]);}
  }
  
  cout << dp[0][0] << endl; return 0;}
    
    

Measured memory_bytes: 384
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var s = o.l();
  var t = o.l();
  var dp = xArray(0,n+1,m+1);
  var ans = 1;
  for(var i = 0; i < n; i++){
    var x = 0;
    for(var j = 0; j < m; j++){
      if(s[i] === t[j]){
        x += dp[i][j]+1;
        ans += dp[i][j]+1;
        ans %= mod;
        dp[i+1][j+1] = dp[i+1][j]+dp[i][j+1]+1;
      }else{
        dp[i+1][j+1] = x+dp[i][j+1];
      }
      dp[i+1][j+1] %= mod;
    }
  }
  return ans;
}

Measured memory_bytes: 129408
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
#define int ll

int N;
int a[100001];
std::map<int, int> cnt;

signed main() {
    cin >> N;
    for (int i = 0; i < N; i ++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i ++) {
        cnt[a[i]] ++;
    }
    int res = 0;
    for (auto it : cnt) {
        int x = it.first;
        int c = it.second;
        if (c >= x) {
            res += c - x;
        } else {
            res += c;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,sum=0;
  cin>>a>>b>>c;
  vector<int> vect={a,b,c};
  sort(vect.begin(),vect.end());
  for(int i=0;i<2;i++){
    sum+=abs(vect[i+1]-vect[i]);
  }
  cout<<sum<<endl;
}
 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c,d,e,f;
  scanf("%d %d",&a,&b);
  c=a+b;
  d=a-b;
  e=a*b;
  f=1;
  while(f==1)
  {
  
  if(c>=d&&c>=e)
  {
    printf("%d",c);
  break;
  }
  else if(d>=c&&d>=e)
  {
    printf("%d",d);
  break;
  }
  else if(e>=c&&e>=d)
  {
    printf("%d",e);
  break;
  }
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

int main() {
	int n; std::cin >> n;
	std::vector<int> bits(n); for (auto& b : bits) std::cin >> b;
	std::vector<int> state(n, 0);
	std::vector<int> result;
	for (int i = n; i > 0; --i) {
		int sum = 0;
		for (int j = i * 2; j <= n; j += i) {
			sum += state[j - 1];
		}
		if (bits[i - 1] != sum % 2) {
			state[i - 1] = 1;
			result.push_back(i);
		}
	}
	std::cout << result.size() << std::endl;
	for (auto i = 0; i < result.size(); ++i) {
		if (i != 0) {
			std::cout << ' ';
		}
		std::cout << result[i];
	}
	if (!result.empty())std::cout << std::endl;
}

Measured memory_bytes: 3064