akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int top,operand[101],v;
  char s[200];

  top = 0;
  
  while(scanf("%s",s) != EOF){
    
    if(top > 101)break;
    
    if(s[0] == '+'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v + operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(1);
      
    } else if(s[0] == '-'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v - operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(2);
      
    } else if(s[0] == '*'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v * operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(3);
        
    } else if(s[0] == '/'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v / operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(4);
    } else {
      top++;
      operand[top] = atoi(s);
      if(operand[top] > 1000000)exit(5);
    }
  }
  printf("%d\n",operand[top]);
       
  return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#define EPS (1e-7)
using namespace std;


long long lcm(long long n, long long m) {
	long long r,x,tmp;
	x = m * n;
	/* 自然数 a > b を確認・入替 */
	if (n < m) {
		tmp = n;
		n = m;
		m = tmp;
	}

	/* ユークリッドの互除法 */
	r = n % m;
	while (r != 0) {
		n = m;
		m = r;
		r = n % m;
	}
	return x / m;

}



int main() {

	int N;
	cin >> N;
	vector<int> s(N);
	int sum = 0;
	int sum10 = 0;
	int amari,ans;
	for (auto i = 0; i < N; i++)
	{
		cin >> s[i];
		sum += s[i];
	}
	sort(s.begin(), s.end());
	amari = sum % 10;
	
	if (amari == 0) {

		for (auto i	= 0; i < N; i++)
		{
			if (s[i] % 10 != 0) {
				sum -= s[i];
				break;
			}
		}
		ans = sum;

	}
	else {
		ans = sum;
	}
	if (ans % 10 == 0) ans = 0;


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


Measured memory_bytes: 256
N=int(input())
X=list()
U=list()
for i in range(N):
    a,b = [i for i in input().split()]
    X.append(float(a))
    U.append(b)
sum=0.0
for price,kind in zip(X,U):
    if kind == 'JPY':
        sum += price
    else:
        sum+= 380000 * price
print (sum)




Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int ans=0;
	sort(A,A+N,greater<>());
	ans+=A[0];
	deque<int> d;
	for(int i=1;i<N;i++){
		d.push_back(A[i]);
		d.push_back(A[i]);
	}
	REP(i,N-2){
		ans+=d.front();
		d.pop_front();
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7956
#include<bits/stdc++.h>
#define ll long long
#define cri const register int
#define re register
using namespace std;
const int mod=1e9+7;
inline int qpow(int a,int b,int ans=1){
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
int fac[201],inv[201],n,k,nxt[77],v[77],vv[77],ans,num,len[77],R[77];
char s[77];
inline int C(cri x,cri y){
	return x<y||x<0||y<0?0:1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline char check(cri p){
	memset(v,0,sizeof v);memset(vv,0,sizeof vv);
	for(int i=p,l=1;i;i--,l++){
		if(l>num) return 0;
		v[R[l]]=1;
		if(len[i]>=2){
			if(!nxt[l]) return 0;
			v[nxt[l]]=1;vv[nxt[l]]=i;
		}
	}
	for(int i=k,sum=0;i;i--){
		if(!v[i]) sum++;
		else if(vv[i]){
			sum-=max(0,len[vv[i]]-2);
			if(sum<0) return 0;
		}
	}
	return 1;
}
char dfs(cri p,cri mn,cri LEN){
	if(LEN>n||!check(p)) return 0;
	int s=p+1;
	for(int i=1;i<=p;i++) s+=2*len[i]-1;
	int tmp=1ll*C(n-LEN+s-1,s-1)*fac[p]%mod,t=0;
	for(int i=1;i<=p;i++,t++) 
		if(len[i]!=len[i-1]) tmp=1ll*tmp*inv[t]%mod,t=0;
	ans=(ans+1ll*tmp*inv[t])%mod;
	if(p==num) return 1;
	for(int i=mn;i<=k;i++) 
		if(!dfs(p+1,len[p+1]=i,LEN+(p!=0)+(i<=2?1:i*2-3))) break;
	return 1;
}
int main(){
	cin>>n>>k;
	scanf("%s",s+1);
	for(int i=fac[0]=1;i<=200;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[200]=qpow(fac[200],mod-2);
	for(int i=200;i;i--) inv[i-1]=1ll*inv[i]*i%mod;
	for(int i=1;i<=k;i++) if(s[i]=='r')
		for(int j=(R[++num]=i,i+1);j<=k;j++) if(!v[j]&&s[j]=='b'){
			nxt[num]=j;v[j]=1;break;
		}
	dfs(0,1,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, yen;
    cin >> N >> yen;
    vector<int> vec(3, 0);
    
    // calculation
    int s10000, nokori, s5000, s1000, sum;
    for (int i = 0; i <= N; ++i) {
        s10000 = i;
        nokori = N - i;
        for (int j = 0; j <= nokori; ++j) {
            s5000 = j;
            s1000 = nokori - s5000;
            sum = 10000*s10000 + 5000*s5000 + 1000*s1000;
            if (sum == yen) {
                cout << s10000 << " " << s5000 << " " << s1000 << "\n";
                return 0;
            }
        }
    }
    
    cout << -1 << " " << -1 << " " << -1 << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8

n = int(input().rstrip())
toku =[0,0]
narabe = []

for i in range(n):
    taro, hana = input().rstrip().split()
    if taro == hana:
        toku[0] +=1
        toku[1] +=1

    else:
        narabe = [taro, hana]
        narabe.sort()
        toku[0] += narabe.index(taro)*3
        toku[1] += narabe.index(hana)*3
    
print(" ".join(list(map(str,toku))))

Measured memory_bytes: 7592
#include<cstdio>
#include<cstring>
int main() {
	int n, a = 0, b = 0, i;
	scanf("%d", &n);
	char t[101], h[101];
	for (i = 0; i < n; i++) {
		scanf("%s%s", t, h);
		if (strcmp(t, h) > 0)a += 3;
		else if (strcmp(t, h) < 0)b += 3;
		else { a++; b++; }
	}
	printf("%d %d\n", a, b);
	return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int c=0;
    string s;
    cin>>s;
    int ans=0;
    int n=s.length();
    for(int i=0;i<s.length();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            c++;
        }else{
            ans=max(c,ans);
            c=0;
        }
    }
    ans=max(c,ans);
    cout<<ans<<endl;
    
    return 0;
    
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin >> n;
    cout << ((n + 110) / 111) * 111 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		String[] S = new String[N];
		Arrays.setAll(S, $ -> sc.get());
		int[] min = new int['z' - 'a' + 1];
		Arrays.fill(min, Integer.MAX_VALUE);
		for (String s : S) {
			int[] count = new int['z' - 'a' + 1];
			char[] chars = s.toCharArray();
			for (char ch : chars) {
				count[ch - 'a'] += 1;
			}
			for (int i = 0; i < 'z' - 'a' + 1; i++) {
				min[i] = Math.min(min[i], count[i]);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 'z' - 'a' + 1; i++) {
			char c = (char) (i + 'a');
			for (int j = 0; j < min[i]; j++) {
				sb.append(c);
			}
		}
		System.out.println(sb);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			private StringTokenizer tokenizer;

			public String get() {
				try {
					return (tokenizer = tokenizer != null && tokenizer.hasMoreTokens() ? tokenizer : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 29524
#include <string>
#include <cstdint>
#include <cassert>
#include <functional>
#include <vector>
#include <unordered_map>
#include <iostream>
namespace lc {
struct Edge {
	int to;
	explicit Edge(int to) : to(to) { }
};
}
namespace lc {
template <typename EdgeType>
class AdjacencyList {
public:
	typedef std::vector<EdgeType> ListType;
private:
	std::vector<ListType> m_lists;
public:
	explicit AdjacencyList(int n = 0)
		: m_lists(n)
	{ }
	int size() const { return m_lists.size(); }
	template <typename... Args>
	void add_edge(int u, Args&&... args){
		m_lists[u].emplace_back(args...);
	}
	const ListType &operator[](int u) const { return m_lists[u]; }
};
}
namespace lc {
template <typename EdgeType, typename Func>
void enumerate_maximal_independent_sets(
	const AdjacencyList<EdgeType> &graph, Func func)
{
	const int n = graph.size();
	std::vector<uint64_t> bit_graph(n), incr_bit_graph(n + 1);
	for(int i = n - 1; i >= 0; --i){
		uint64_t mask = (1ull << i);
		for(const auto &e : graph[i]){ mask |= (1ull << e.to); }
		bit_graph[i] = mask;
		incr_bit_graph[i] = mask | incr_bit_graph[i + 1];
	}
	std::function<void(int, uint64_t, uint64_t)> recur =
		[&, n](int i, uint64_t picked, uint64_t eliminated) -> void {
			if(i == n){
				if((picked | eliminated) == (1ull << n) - 1){ func(picked); }
			}else if(bit_graph[i] & ~(incr_bit_graph[i + 1] | eliminated)){
				if(!(eliminated & (1ull << i))){
					recur(i + 1, picked | (1ull << i), eliminated | bit_graph[i]);
				}else{
					recur(i + 1, picked, eliminated);
				}
			}else if((incr_bit_graph[i + 1] | eliminated) & (1ull << i)){
				recur(i + 1, picked, eliminated);
				if(!(eliminated & (1ull << i))){
					recur(i + 1, picked | (1ull << i), eliminated | bit_graph[i]);
				}
			}else{
				recur(i + 1, picked | (1ull << i), eliminated | bit_graph[i]);
			}
		};
	recur(0, 0, 0);
}
}
namespace lc {
class NameTable {
private:
	std::unordered_map<std::string, int> m_table;
	std::vector<std::string> m_inv_table;
public:
	NameTable(){ }
	int operator[](const std::string &s){
		const auto it = m_table.find(s);
		if(it != m_table.end()){ return it->second; }
		const int t = m_inv_table.size();
		m_table.insert(std::make_pair(s, t));
		m_inv_table.push_back(s);
		return t;
	}
};
}
using namespace std;
typedef lc::Edge Edge;
int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		lc::NameTable name_table;
		vector<int> powers(n);
		lc::AdjacencyList<Edge> graph(n);
		for(int i = 0; i < n; ++i){
			string u_name;
			int p, m;
			cin >> u_name >> p >> m;
			const int u = name_table[u_name];
			powers[u] = p;
			for(int j = 0; j < m; ++j){
				string v_name;
				cin >> v_name;
				const int v = name_table[v_name];
				graph.add_edge(u, v);
			}
		}
		int answer = 0;
		lc::enumerate_maximal_independent_sets(graph, [&](uint64_t s){
			if((s & 1) == 0){ return; }
			int sum = 0;
			for(int i = 0; i < n; ++i){
				if(s & (1ull << i)){ sum += powers[i]; }
			}
			answer = max(answer, sum);
		});
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int a[500000];
int main()
{
    int n,k;
    int sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[][] card = new int[3][3];
    boolean[][] cardflg = new boolean[3][3];
    boolean flag = false;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        card[i][j] = sc.nextInt();
      }
    }
    int n = sc.nextInt();
    for(int k=0;k<n;k++){
      int num = sc.nextInt();
      for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
          if(num == card[i][j]){
            cardflg[i][j] = true;
          }
        }
      }
    }
    if(
      (cardflg[0][0] && cardflg[0][1] && cardflg[0][2])
      || (cardflg[1][0] && cardflg[1][1] && cardflg[1][2])
      || (cardflg[2][0] && cardflg[2][1] && cardflg[2][2])
      || (cardflg[0][0] && cardflg[1][0] && cardflg[2][0])
      || (cardflg[0][1] && cardflg[1][1] && cardflg[2][1])
      || (cardflg[0][2] && cardflg[1][2] && cardflg[2][2])
      || (cardflg[0][0] && cardflg[1][1] && cardflg[2][2])
      || (cardflg[2][0] && cardflg[1][1] && cardflg[0][2])
    ){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
int a[300];
int main()
{
    int n;cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    int ans=0;
    //sort(a+1,a+1+n);
    int s[4];
    for(int i=1; i<=n-2; i++){
        for(int j=i+1; j<=n-1; j++){
            for(int k=j+1; k<=n; k++){
                //cout<<i<<' '<<j<<' '<<k<<endl;
                s[1]=a[i];s[2]=a[j];s[3]=a[k];
                if(s[1]==s[2]||s[1]==s[3]||s[2]==s[3])continue;
                sort(s+1,s+1+3);
                //cout<<ans<<"    ";
                if(s[1]+s[2]>s[3])ans++;
               // cout<<ans<<' ';
                //for(int p=1; p<=3; p++)cout<<s[p]<<' ';
               // cout<<endl;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};




int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        vec.push_back(b);
    }
    vector<int> w = vec;
    sort(vec.begin(),vec.end());

    for(int i = 0;i < N;i++){
        if(vec.back() == w.at(i)){

            cout<<vec.at(N-2)<<endl;
        }else{
            cout<<vec.back()<<endl;
        }
    }
}


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

// Union-Find
class DisjointSet {
public:
  vector<int> p, rank, size;
  int group_num;
  DisjointSet(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    size.assign(n, 0);
    group_num = n;
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }

  void make_set(int x) {
    p[x] = x;
    rank[x] = 0;
    size[x] = 1;
  }

  bool same(int x, int y) {
    return find_set(x) == find_set(y);;
  }

  int find_set(int x) {
    if (x != p[x]) {
      p[x] = find_set(p[x]);
    }
    return p[x];
  }

  int union_size(int x) {
    if (x != p[x]) {
      size[x] = union_size(find_set(x));
    }
    return size[x];
  }

  void link(int x, int y) {
    if(rank[x]  > rank[y]) {
      p[y] = x;
      size[x] = size[x] + size[y];
    }else if(rank[x] < rank[y]){
      p[x] = y;
      size[y] = size[x] + size[y];
    }else if(x != y) {
      p[y] = x;
      rank[x]++;
      size[x] = size[x] + size[y];
    }
  }

  void unite(int x, int y) {
    if (find_set(x) != find_set(y)) group_num--;
    link(find_set(x), find_set(y));
  }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    int f[N]{};
    int b[N]{};
    DisjointSet ds(N);
    int A, B, C, D;
    for (int i = 0; i < M; i++) {
        cin >> A >> B;
        A--;
        B--;
        ds.unite(A, B);
        f[A]++;
        f[B]++;
    }
    for (int i = 0; i < K; i++) {
        cin >> C >> D;
        C--;
        D--;
        if (ds.same(C, D)) {
            b[C]++;
            b[D]++;
        }
    }

    for (int i = 0; i < N; i++) {
        int p = ds.union_size(i) - f[i] - b[i] - 1;
        if (i == N - 1) {
            cout << p << "\n";
        } else {
            cout << p << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char S[4];

    scanf("%s", S);

    int p = 700;

    for(int i = 0; i < 3; i++){
        if(S[i] == 'o'){
            p += 100;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<queue>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N,M; cin>>N>>M;
    priority_queue<ll> A;
    REP(i,N){
        ll a;cin>>a;
        A.push(a);
    }
    REP(i,M){
        int top = A.top();A.pop();
        top /= 2;
        A.push(top);
    }
    ll ans = 0;
    REP(i,N){
        ll a = A.top(); A.pop();
        ans += a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(){

  int n,m,l,s,A[100][100],c[100],a,i,j;
  a=0;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&l);
      A[i][j]=l;
    }
  }
  for(j=0;j<m;j++){
    scanf("%d",&s);
    c[j]=s;
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      a += A[i][j]*c[j];
    }
    printf("%d\n",a);
    a=0;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
map<pa,int>mp;
const int N=2e5+100;
int n,m;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int pos;
    cin>>pos;
    ll ans=0;
    for(int i=2;i<=n;i++){
        int x;cin>>x;
        ans+=min(1ll*b,1ll*(x-pos)*a);
        pos=x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
fun main(args: Array<String>) {
  val N = readInt()
  val n = N % 10
  println(
    when (n) {
      0 -> "pon"
      1 -> "pon"
      2 -> "hon"
      3 -> "bon"
      4 -> "hon"
      5 -> "hon"
      6 -> "pon"
      7 -> "hon"
      8 -> "pon"
      9 -> "hon"
      else -> ""
    }
  )
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 34588
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define W while
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffor(i,a,b) for(ll i=a;i<=b;i++)
#define rfor(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define go_t ll testcases; cin>>testcases; while(testcases--)
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';
using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 2005;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 1e8 + 8;

ll power(ll x, ll y, ll M = MOD) // default argument
{ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;}

int main()
{

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	// WHILE(!(SUCCEED == TRY()));
	// BEFORE WRITING MAKE SURE YOU HAVE ANALYSED THE CONSTRAINTS
	// AND THINK THROUGH THE LOGIC ONCE MORE
	FIO
	ll n, k; cin >> n >> k;
	ll ar[n];
	FOR(i, n) cin >> ar[i];
	sort(ar, ar + n);
	ll sum = 0;
	FOR(i, k) sum += ar[i];
	cout << sum;


	return 0;
}

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

int main() {
int n,k,r;
cin>>n;
for(int kk=0;kk<n;kk++){
	cin>>k>>r;
	
	
	int a[100000];
	int l;
	for(int j=0;j<k;j++){
		cin>>a[j];
	}
	l=a[k-1]-a[0];
	int b[100000];
	for(int jj=0;jj<k-1;jj++){
		b[jj]=a[jj+1]-a[jj];
	}
	sort(b,b+k-1);
	for(int f=k-2;f>k-1-r;f--){
		l=l-b[f];
	}
	if(k==1 || r>=k){
		cout<<0<<endl;
	}
	else{
	cout<<l<<endl;
	}
}
	return 0;
}

Measured memory_bytes: 1956
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = sc.nextInt
    val B = sc.nextInt

    (if (B % A == 0) A + B else B - A).toString
  }
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

int n = 8;
vector<string> s(n);

bool isIn(int i, int j){
    return i>=0 && i<n & j>=0 && j<n;
}

int count(int i, int j, char c){
    int res = 0;
    for(int k=0;k<8;k++){
        int ni = i+di[k], nj = j+dj[k];
        int cnt = 0;
        while(1){
            if(!isIn(ni,nj) || s[ni][nj] == '.'){
                cnt = 0;
                break;
            }
            else if(s[ni][nj]==c) break;
            else {
                cnt++;
                ni += di[k]; nj += dj[k];
            }
        }
        res += cnt;
    }
    return res;
}

void put(int i, int j, char c){
    for(int k=0;k<8;k++){
        int ni = i+di[k], nj = j+dj[k];
        while(1){
            if(!isIn(ni,nj) || s[ni][nj] == '.'){
                break;
            }
            else if(s[ni][nj]==c){
                while(1){
                    ni -= di[k]; nj -= dj[k];
                    s[ni][nj] = c;
                    if(ni == i && nj == j) break;
                }
                break;
            }
            else {
                ni += di[k]; nj += dj[k];
            }
        }
    }
}

int solve(){
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    bool turn = true;
    bool update = true;
    while(1){
        int pi = -1, pj = -1, maxi = 0;
        char c = (turn ? 'o' : 'x');
        if(turn){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    if(s[i][j] != '.') continue;
                    int cnt = count(i,j,c);
                    if(cnt > maxi){
                        pi = i; pj = j;
                        maxi = cnt; 
                    }
                }
            }
        }else{
            for(int i=n-1;i>=0;i--){
                for(int j=n-1;j>=0;j--){
                    if(s[i][j] != '.') continue;
                    int cnt = count(i,j,c);
                    if(cnt > maxi){
                        pi = i; pj = j;
                        maxi = cnt;
                    }
                }
            }
        }
        if(maxi > 0){
            put(pi, pj, c);
            update = true;
        }else{
            if(!update) break;
            update = false;
        }
        turn = !turn;
    }
    for(int i=0;i<n;i++){
        cout << s[i] << endl;
    }
    return 0;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int key[100];
    string a;
    for(int i=0;i<n;i++)cin>>key[i];
    cin>>a;
    for(int i=0;i<a.size();i++){
      if(a[i]>='a'){
        if(a[i]-key[i%n]<'a')a[i]-=('a'-'Z')+key[i%n]-1;
        else a[i]-=key[i%n];
        if(a[i]<'A')a[i]+=('z'-'A')+1;
        }else{
        if(a[i]-key[i%n]<'A'){
          a[i]-=-('z'-'A')+key[i%n]-1;
          if(a[i]<'a')a[i]-=('a'-'Z')-1;
        }
        else a[i]-=key[i%n];
        }
    }
    cout<<a<<endl;;
  }
  return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.length() <= K) cout << S << endl;
    else cout << S.substr(0,K) << "..." << endl;
}

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

int main()
{
	int n;
	cin >> n;
	int mn;
	cin >> mn;
	int ans = -1e9;
	for(int i = 1; i < n; i++)
	{
		int r;
		cin >> r;
		ans = max(ans, r - mn);
		mn = min(r, mn);
	}
	cout << ans << "\n";
}



Measured memory_bytes: 3100
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5 + 5;
int main()
{
	int dp[maxn];
	int h[maxn];
	int n;
	while(~scanf("%d",&n)){
		for(int i=1;i<=n;i++)
			scanf("%d",&h[i]);
		dp[1] = 0;
	    for(int i=2;i<=n;i++)
	    {
		if(i==2) dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
		else dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    
	}
	printf("%d\n",dp[n]);
	}
	return 0;
}


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

signed main(){
	int n,x;cin>>n>>x;
	vector<int> a(n),b(n);
	int ans;
	for(auto&& w:a)cin>>w;
	copy(begin(a),end(a),begin(b));
	ans=accumulate(begin(a),end(a),0ll);
	
	for(int i=1;i<n;i++){
	for(int j=0;j<n;j++){
		b[j]=min(b[j],a[(j+i)%n]);	
	}
		ans=min(ans,(accumulate(begin(b),end(b),0ll)+i*x));
}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int N;cin >> N;
  int a[3]={7,5,3};
  for(int i=0;i<3;i++){
    if(a[i]==N){
      puts("YES");
      return 0;
    }
  }
	puts("NO");
  return 0;
}

Measured memory_bytes: 3524
import java.util.*;

//グラハムスキャン
//幾何
//凸包
class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n=sc.nextInt();
			if(n==0)break;
			P[] ps=new P[n];
			for(int i=0;i<n;i++){
				String[] str=sc.next().split(",");
				ps[i]=new P(Double.parseDouble(str[0]),Double.parseDouble(str[1]));
			}
			Arrays.sort(ps);

			int k=0;
			P[] qs =new P[2*n];
			//下側
			for(int i=0;i<n;i++){
				while(k>1 && P.cross(qs[k-1].s(qs[k-2]),ps[i].s(qs[k-1]))<=0)k--;//凸包になるまで戻す
				qs[k++]=ps[i];
			}
			//上側
			for(int i=n-2,t=k;i>=0;i--){
				while(k>t && P.cross(qs[k-1].s(qs[k-2]),ps[i].s(qs[k-1]))<=0)k--;
				qs[k++]=ps[i];
			}
			qs=Arrays.copyOf(qs,k-1);

			ln(ps.length-qs.length);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
	public static void pr(Object o) {
		System.out.print(o);
	}
	public static void ln(Object o) {
		System.out.println(o);
	}
	public static void ln() {
		System.out.println();
	}
}

class P implements Comparable<P>{
	double x;
	double y;
	P(double _x,double _y){
		x=_x;
		y=_y;
	}
	@Override
	public int compareTo(P o) {
		if(x>o.x){
			return 1;
		}else if(x<o.x){
			return -1;
		}
		return y>o.y?1:y<o.y?-1:0;
	}

	public static double dot(P a,P b){
			return a.x*b.x+a.y*b.y;
	}
	public static  double cross(P a,P b){
		return a.x*b.y-a.y*b.x;
	}
	public static boolean isParallel(P a1,P a2,P b1,P b2){
		return Math.abs(cross(a2.s(a1),b2.s(b1)))<Double.MIN_NORMAL;
	}
	public static boolean isVertical(P a1,P a2,P b1,P b2){
		return Math.abs(dot(a2.s(a1),b2.s(b1)))<Double.MIN_NORMAL;
	}

	public P a(P a){
		return new P(x+a.x,y+a.y);
	}
	public P s(P a){
		return new P(x-a.x,y-a.y);
	}

	public double norm(){
		return Math.sqrt(x*x+y*y);
	}

	public static int ccw(P a,P b,P c){
		if(P.cross(b.s(a),c.s(a))>Double.MIN_NORMAL){
			return 1;
		}
		if(P.cross(b.s(a),c.s(a))<-Double.MIN_NORMAL){
			return -1;
		}
		if(P.dot(b,c)<-Double.MIN_NORMAL)return 2;
		if(b.norm()<c.norm()-Double.MIN_NORMAL)return -2;
		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof P){
			P p=(P)obj;
			return x==p.x && y==p.y;
		}
		return false;
	}
	public String toString(){
		return "("+x+","+y+")";
	}
}

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

string map[12];

void bfs(int i,int j){
  if( map[i][j] == '0' ) return;
  if( map[i][j] == '1' ){
    map[i][j] = '0';
    if( i-1 >= 0 ) bfs(i-1,j);
    if( i+1 <= 11 ) bfs(i+1,j);
    if( j+1 <= 11 ) bfs(i,j+1);
    if( j-1 >= 0 ) bfs(i,j-1);
  }
}

int main(){
  string str;

  while( cin >> str ){
    map[0] = str;
    for( int i = 1; i < 12; i++ ) cin >> map[i];
    int cnt = 0;
    for( int i = 0; i < 12; i++ ){
      for( int j = 0; j < 12; j++ ){
	if( map[i][j] == '1' ){
	  cnt++;
	  bfs(i,j);
	}
      }
    }
    cout << cnt << endl;
    // for( int i = 0; i < 12; i++ ) cout << map[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
import sys
Dir = [(1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (-1, 1), (1, -1), (-1, -1)]
def ds(here, didx, lb, ub, field, start, string, spell):
	s = string + field[here[1]][here[0]]
	if s in spell :
		spell[s] -= 1
	else :
		spell[s] = -1
	delta = Dir[didx]
	next = [here[0] + delta[0], here[1]+ delta[1]]
	if next[0] < lb[0]:   next[0] = ub[0]
	elif next[0] > ub[0]: next[0] = lb[0]
	if next[1] < lb[1]:   next[1] = ub[1]
	elif next[1] > ub[1]: next[1] = lb[1]

	if next != start:
		ds(next, didx, lb, ub, field, start, s, spell)

sys.setrecursionlimit(10000)

while 1:
	h,w = map(int,raw_input().split(" "))
	if w == h == 0: break
	lb = (0,0)
	ub = (w-1,h-1)
	spell = dict()
	donut = [[c for c in raw_input()] for _ in range(h)]
	for j in range(h):
		for i in range(w):
			for d in range(8):
				ds([i,j], d, lb, ub, donut, [i,j], "", spell)
	spell_sort = sorted(spell.iteritems(), key = lambda x : (-len(x[0]),x[0],x[1]))
	lenspell = len(spell_sort)
	for i in range(lenspell):
		if len(spell_sort[i][0]) >= 2 and spell_sort[i][1] <= -2:
			print spell_sort[i][0]
			break
	else :
		print 0

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

int main() {

  int N;
  int ans=0;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i < N;i++){
      cin >> a.at(i);
  }
  for(int j=0;j<N;j++){
  if(j%2==0){
      if(a.at(j)%2==1){
          ans++;
      }
  }
  }
cout << ans << endl;

}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(){
  int N;
  cin >> N;
  ll x[N], y[N];
  for(int i=0;i<N;i++) cin >> x[i] >> y[i];

  map<pair<ll, ll>, int> mp;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i == j) continue;

      mp[P(x[j] - x[i], y[j] - y[i])]++;
    }
  }

  int ans = 0;
  for(auto it = mp.begin(); it != mp.end(); it++){
    ans = max(ans, it->second);
  }

  cout << N - ans << endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
using namespace std;
typedef long long LL;

int main(void) {
	int aa = 0, bb = 0, cc = 0;
	string a, b, c;
	char s = 'a';
	cin >> a >> b >> c;
	for (;;) {
		if (s == 'a') {
			if (aa == a.size()) break;
			s = a[aa];
			aa++;
		}
		else if (s == 'b') {
			if (bb == b.size()) break;
			s = b[bb];
			bb++;
		}
		else if (s == 'c') {
			if (cc == c.size()) break;
			s = c[cc];
			cc++;
		}
	}
	s -= 32;
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s;
    int k;
    cin>>k>>s;
    if(s.size()<=k) cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
}

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

int main(){
	int A,B,C;
	cin >> A>>B>>C;
	
	if(A*B*C==175){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	
	}

	
	

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
func next() string{
    sc.Scan()
    return sc.Text()
}

func nextInt() int{
    a, _ := strconv.Atoi(next())
    return a
}

func main() {
    var (
        a     int
        b     int
        c     int
        x     int
        count int
    )

    a = nextInt()
    b = nextInt()
    c = nextInt()
    x = nextInt()

    for i := 0; i <= a; i++ {
        for j := 0; j <= b; j++ {
            for k := 0; k <= c; k++ {
                if x == 500*i + 100*j + 50*k {
                    count++
                }
            }
        }
    }

    fmt.Println(count)
}

Measured memory_bytes: 640
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//--------------------------------------------

ll cost[3005][3005]; ll dp[3005][3005][4];
//--------------------------------------------
ll maxup(int i , int j)
{
    ll g =  max(dp[i][j][0],dp[i][j][1]);
    ll h = max(dp[i][j][2], dp[i][j][3]);

    return max(g,h);
}




//============================================
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

	//THE WATER WAS DEEP, I DROWNED AND THEN CAME FLOATING UP,DEAD!!

	
      ll r,c,k;
      cin>>r>>c>>k;

      
      for(int i = 0 ; i <= r ; i++)
          for(int j = 0 ; j<= c ; j++)
          {
              cost[i][j] = 0;
              for(int k = 0 ; k < 4 ; k++)
                  dp[i][j][k] = 0;
          }

      for(int i = 1 ;i <= k ; i++)
      {
          int u, v , val;
          cin>>u>>v>>val;
          cost[u][v] = val;
      }

      for(int i = 1 ; i <= r ; i++)
      {
            for(int j = 1 ; j <= c ; j++)
            {
                  if(cost[i][j] ==  0)
                  {
                      dp[i][j][0] = max(maxup(i-1,j),dp[i][j-1][0]);
                      dp[i][j][1] = dp[i][j-1][1];
                      dp[i][j][2] = dp[i][j-1][2];
                      dp[i][j][3] = dp[i][j-1][3];
                  }
                  else
                  {
                      dp[i][j][0] =  max(maxup(i-1,j),dp[i][j-1][0]);
                      dp[i][j][1] = max(cost[i][j] + maxup(i-1,j) , dp[i][j-1][1]);
                      dp[i][j][2] = max(cost[i][j] + dp[i][j-1][1] , dp[i][j-1][2]);
                      dp[i][j][3] = max(cost[i][j] + dp[i][j-1][2] , dp[i][j-1][3]);
                  }
            }
      }

      cout<<maxup(r,c);






return 0;
}

Measured memory_bytes: 355916
def f(a, b, c, d):
    if a <= c:
        if b <= c:
            return 0
        if b <= d:
            return b - c
        else:
            return d - c
    else:
        return f(c, d, a, b)

a, b, c, d = [int(x) for x in input().strip().split()]
print(f(a, b, c, d))


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

int main(){
    int h,w; cin>>h>>w;
    vector<vector<char>> v(h+1,vector<char>(w+1));
    vector<vi> dp(h+1,vi(w+1,0));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++) cin>>v[i][j];
    }
    dp[0][1] = 1;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++) if(v[i][j]=='.') dp[i][j] = (dp[i][j-1] + dp[i-1][j])%INF;
    }
    cout<<dp[h][w];
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
	int K;
	cin >> K;
	int ans=0;
	rep(a,K){
		rep(b,K){
			rep(c,K) ans+=__gcd(a+1,__gcd(b+1,c+1));
		}
	}
	cout << ans << endl;

	return 0;
}


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


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

  int N, M;
  cin >> N >> M;
  vector<vector<int>> adj(N);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }

  queue<int> q;
  q.emplace(0);
  vector<int> vis(N, -1);
  vis[0] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : adj[u]) if (vis[v] == -1) {
      vis[v] = u;
      q.emplace(v);
    }
  }

  for (int i = 0; i < N; i++) {
    if (vis[i] == -1) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  for (int i = 1; i < N; i++) {
    cout << vis[i] + 1 << "\n";
  }

}

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

const long long INF = 1LL<<60;

int main() {
	long long N; cin >> N;
	long long res = INF;
	for (long long i = 1; i * i <= N; i++)
	{
		if(N % i == 0) res = min(res, i + N / i - 2);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main () {
	int N;
  	cin >> N;
  
  	int n1 = N /1000;
	int n2 = (N - 1000 * n1) /100;
  	int n3 = (N - 1000 * n1 - 100 * n2) /10;
  	int n4 = N -1000 * n1 - 100 * n2 - 10 * n3;
  
  	if (n1 == n2) {
    	if (n2 == n3) {
        	cout << "Yes" << endl;
        }
      	else {
        	cout << "No" << endl;
        }
    }
  	else if (n2 == n3) {
    	if (n3 == n4) {
        	cout << "Yes" << endl;
        }
      	else {
        	cout << "No" << endl;
        }
    }
  	else {
    	cout << "No" << endl;
    }


}

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

const double pi = acos(-1);

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  cout << fixed << setprecision(10);

  double ans = 0;
  double v = a*a*b;
  if(x <= v/2){
    double y = a*b*b/(2*x);
    ans = atan(y);
  }else{
  	double y = 2*(v - x)/(a*a*a);
  	ans = atan(y);
  }
  ans = ans/pi*180;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,n,t,s,jj,sheng;
	cin>>n>>a>>b;
	t=a+b;
	jj=n/t;
	s=jj*a;
	sheng=n-jj*t;
	s+=min(sheng,a);
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,d;
  cin >> n >> d;
  vector<pair<ll,ll>> vec(n);
  ll ans = 0;
  rep(i,n){
    cin >> t1 >> t2;
    if(t1 * t1 + t2 * t2 <= d*d){
      ans++;
    }
  }
  cout << ans << endl;
}

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


int main()
{
    int n,m,x,s=0,t=0;
    cin>>n>>m>>x;
    rep(i,m){
      int p;
    cin>>p;
    if(p<x)s++;
    if(p>x) t++;
    }
    cout<<min(s,t)<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
int n;
int dp[5005][5005];
int main(){
    cin >> n >> s;
    rep(i,5005)rep(j,5005)dp[i][j]=-INF;
    n = s.size();
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<i;j++){
            if(s[j] == s[i]){
                dp[j][i] = max(dp[j][i],max(0,dp[j+1][i+1])+1);
            }
        }
    }
    int ans = 0;
    rep(i,5005)rep(j,5005)ans=max(ans,min(j-i,dp[i][j]));
    cout<<ans<<endl;
}

Measured memory_bytes: 98048
#include <iostream>
#include <cstdio>
#define MN 610
#define mod 1000000007

int s[MN], to[MN], f[MN][MN], n; 
bool ok[MN][MN];
int fac[MN], inv[MN], mi[MN];

int C(int a, int b) {return 1ll * fac[a] * inv[b] % mod * inv[a - b] % mod;}

int calc(int n) {if(n & 1) return 0; n >>= 1; return 1ll * C(2 * n, n) * fac[n] % mod * mi[n] % mod;}

int main()
{
	int n, k; scanf("%d%d", &n, &k); n *= 2;
	fac[0] = inv[0] = inv[1] = mi[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	for(int i = 2; i <= n; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 1; i <= n; i++) inv[i] = 1ll * inv[i - 1] * inv[i] % mod;
	for(int i = 1; i <= n; i++) mi[i] = 1ll * mi[i - 1] * (mod + 1 >> 1) % mod;
	for(int i = 1; i <= k; i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		to[a] = b; to[b] = a;
	}
	for(int i = 1; i <= n; i++)
	{
		if(!to[i]) s[i] = 1;
		s[i] += s[i - 1];
	}
	for(int l = 1; l <= n; l++)
	{
		int Max = 0;
		for(int r = l; r <= n; r++)
		{
			if(to[r] && to[r] < l) break; 
			Max = std::max(Max, to[r]);
			if(Max <= r) ok[l][r] = 1;
		}
	}
	int ans = 0;
	for(int len = 2; len <= n; len++)
		for(int l = 1; l + len - 1 <= n; l++)
		{
			int r = l + len - 1;
			if(!ok[l][r]) continue;
			f[l][r] = calc(s[r] - s[l - 1]);
			if(!f[l][r]) continue;
			for(int i = l; i < r; i++)
				f[l][r] = (f[l][r] - 1ll * f[l][i] * (ok[i + 1][r] ? calc(s[r] - s[i]) : 0) % mod + mod) % mod;
			ans = (ans + 1ll * f[l][r] * calc(s[n] - s[r] + s[l - 1]) % mod) % mod;
		}
	printf("%d\n", ans);
}

Measured memory_bytes: 2048
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d %d", $A, $B, $C);

if ($A == $B) {
    echo $C . PHP_EOL;
} elseif ($A == $C) {
    echo $B . PHP_EOL;
} else {
    echo $A . PHP_EOL;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[100000];
int main(){
  for(cin>>n>>a[0],i=1;i<n;i++){
    cin>>a[i];
    if(a[i]>a[i-1])a[i]--;
    else if(a[i]==a[i-1])continue;
    else if(a[i]<a[i-1])return cout<<"No",0;
  }
  cout<<"Yes";
}

Measured memory_bytes: 1024