akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std; 

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef set <int> st;
typedef set <char> stc;
typedef vector<int>::iterator itr;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sq(a) a*a
#define cu(a) (sq(a)*a)


const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int inf = 1e9+9;
const ll INF = 1e18;

int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    
    int k,n,m;
    
    int a[maxn];
    char c[maxn];
    string s;
    
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a,a+3);
    
    if((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[1] != a[0])) cout << "Yes";
    else cout << "No";
    
    return 0; 
    
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,W;
  cin >> N >> W;
  vector<pair<long long,long long>> wv(N);
  for(int i = 0; i < N; ++i) cin >> wv[i].first >> wv[i].second;
  vector<long long> minw(N*1000+1,INT_MAX);
  minw[0] = 0;
  for(int i = 0; i < N; ++i){
    long long w = wv[i].first, val = wv[i].second;
    for(long long j = N*1000-val; j >= 0; --j){
      minw[j+val] = min(minw[j+val],minw[j]+w);
    }
  }
  for(long long val = N*1000; val >= 0; --val){
    if(minw[val] <= W){
      cout << val;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;class Main{public static void main(String[]z){int a,b,i;for(Scanner s=new Scanner(System.in);s.hasNext();System.out.println(a+"\n"+b)){String x=s.next();for(i=a=0;0<(i=x.indexOf("JOI",i)+1);)++a;for(i=b=0;0<(i=x.indexOf("IOI",i)+1);)++b;}}}

Measured memory_bytes: 12000
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	
	int64_t n,m;

	cin >> n >> m;
	
	int64_t s = 0;
	for (int64_t i = 0; i < m; i++) {
		int a = 0;
		cin >> a;
		s += a;
	}
	

	if (n >= s) {
		cout << n - s << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
#define LINF 1e18
using namespace std;
struct Edge{
    ll from, to, cost;
};
 
using Edges = vector<Edge>;
 
bool bellman_ford(Edges &Es, int V, int s, vector<ll>& dis){
    dis.resize(V,LINF);
    dis[s] = 0;
    int cnt = 0;
    ll t_num;
    while(cnt < 2*V){
        bool end = true;
        for(auto e: Es){
            if(dis[e.from] != LINF && dis[e.from]+e.cost < dis[e.to]){
                dis[e.to] = dis[e.from] + e.cost;
                end = false;
            }
        }
        if(end) return false;
        if(cnt==V-1) t_num = dis[V-1];
        cnt++;
    }
    return (t_num!=dis[V-1]);
}
int main() {
  int a,b,c,N,M;
  cin >> N >> M;
  Edges E(M);
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    E[i] = {--a,--b,-c};
  }
  vector<ll> dis;
  if (bellman_ford(E,N,0,dis)) {
    cout << "inf";
  } else {
    cout << -dis.back();
  }
}

Measured memory_bytes: 3680
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    k = int(input())
    rc = [list(map(int, input().split())) for _ in range(k)]
 
    def dfs(d, perm):
        if d==8:
            ok = True
            for i in rc:
                if perm[i[0]]!=i[1]:
                    ok = False
            if ok:
                okok = True
                for j in range(7):
                    for k in range(j+1, 8):
                        if j-perm[j]==k-perm[k] or j+perm[j]==k+perm[k]:
                            okok = False
                if okok:
                    for j in range(8):
                        pos = perm[j]
                        print('.'*pos+'Q'+'.'*(7-pos))
            return perm
        else:
            for i in range(8):
                if i not in perm:
                    dfs(d+1, perm+[i])
    dfs(0, [])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5620
#include <iostream>
#include <utility>
#include <vector>
#include <map>

using namespace std;

typedef pair<int,int> P;
typedef map<int, P> M;
typedef vector<P> V;

struct F{
	int a[10][10];
};

void acopy(int a[10][10], int b[10][10], int w, int h)
{
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			b[i][j] = a[i][j];
		}
	}
	
	return ;
}

vector<F> res;
void func(F r, V vec, M mpp, int w, int h, int c)
{
	if(c == vec.size()){
		res.push_back(r);
	} else {
		int t = vec[c].second, u = vec[c].first;
		int p = mpp[u].first, q = mpp[u].second;
		for(int m = 1; m <= t; m++){
			if(t%m == 0){
				F b;
				int s = t/m;
				for(int i = 0; i <= h-s; i++){
					for(int j = 0; j <= w-m; j++){
						if(i > p || i+s <= p || j > q || j+m <= q){
							continue;
						}
						acopy(r.a, b.a, w, h);
						bool f1 = true, f2 = false;
						for(int k = 0; k < s && f1; k++){
							for(int l = 0; l < m && f1; l++){
								if(!(b.a[i+k][j+l] == 0 || b.a[i+k][j+l] == u)){
									f1 = false;
								}
								if(b.a[i+k][j+l] == u){
									f2 = true;
								}
								b.a[i+k][j+l] = u;
							}
						}
						
						if(f1 && f2){
							func(b, vec, mpp, w, h, c+1);
						}
					}
				}
			}
		}
	}
	
	return ;
}

int main()
{
	int w, h, n, s, t;
	F r;
	
	while(cin>>w>>h>>n && (w+h+n)){
		V vec;
		M mpp;
		for(int i = 0; i < n; i++){
			cin >> s >> t;
			vec.push_back(P(s, t));
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> r.a[i][j];
				if(r.a[i][j] != 0){
					mpp[r.a[i][j]] = P(i, j);
				}
			}
		}
		
		func(r, vec, mpp, w, h, 0);
		if(res.size() == 1){
			r = res[0];
			for(int i = 0; i < h; i++){
				cout << r.a[i][0];
				for(int j = 1; j < w; j++){
					cout << " " << r.a[i][j];
				}
				cout << endl;
			}
		} else {
			cout << "NA" << endl;
		}
		
		res.clear();
	}
	
	return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <iomanip>

using namespace std;

long double dp[330][330][330];

int N;
int a[330];

int N3, N2, N1;

int check[330][330][330];

long double SOLVE(int N3, int N2, int N1) {

	if (check[N3][N2][N1] == 1) { return dp[N3][N2][N1]; }

	check[N3][N2][N1] = 1;

	long double ret = 0.0;

	if (N3 > 0) { ret += 1.0L*N3 / double(N1 + N2 + N3)*(SOLVE(N3 - 1, N2 + 1, N1)+1.0); }
	if (N2 > 0) { ret += 1.0L*N2 / double(N1 + N2 + N3)*(SOLVE(N3, N2 - 1, N1 + 1)+1.0); }
	if (N1 > 0) { ret += 1.0L*N1 / double(N1 + N2 + N3)*(SOLVE(N3, N2, N1 - 1)+1.0); }


	ret += 1.0L*(N - N1 - N2 - N3) / (N1 + N2 + N3);

	dp[N3][N2][N1] = ret;

	return ret;

}

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) { cin >> a[i]; }

	for (int i = 1; i <= N; i++) {
		if (a[i] == 3) { N3++; }
		else if (a[i] == 2) { N2++; }
		else { N1++; }
	}

	check[0][0][0] = 1; dp[0][0][0] = 0.0;

	cout << setprecision(16)<<fixed<<SOLVE(N3,N2,N1) << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 641152
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a, b, x;
 cin >> a >> b;
 x = (a * b) % 2;
  
  if ( x == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b == 15)
    cout << "+" << endl;
  else if (a * b == 15)
    cout << "*" << endl;
  else
    cout << "x" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n;
  cin >> n;
  map<ll,int>mp;
  rep(i,n){
    ll a;
    cin >> a;
    mp[a]++;
  }
  ll ans1=0,ans2=0;
  for(auto p:mp){
    ll f=p.first;
    ll s=p.second;
  
    if(s>=4){
      ans1=f;
      ans2=f;
    }
    else if(s>=2){
      ans1=ans2;
      ans2=f;
    }
    else continue;
  }
  ll ans=ans1*ans2;
  cout << ans << endl;

}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];

int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    ans += abs(a[i] - a[i - 1]);
  }
  ans += abs(a[n]);
  for(int i = 1; i <= n; ++i) {
    int gg = ans;
    gg -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
    gg += abs(a[i + 1] - a[i - 1]);
    printf("%d\n", gg);
  }
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    string S, T;
    cin >> S >> T;

    int count = 0;
    for(int i = 0; i < 3; i++) {
        if(S[i] == T[i]){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, m;
    int p[10], k[10], s[10][10];
    int bit;
    int ans = 0;
    int i, j, cnt;
    scanf("%d%d", &n, &m);

    for(i = 0; i < m; i++){
        scanf("%d", &k[i]);
        for(j = 0; j < k[i]; j++){
            scanf("%d", &s[i][j]);
        }
    }

    for(i = 0; i < m; i++){
        scanf("%d", &p[i]);
    }

    for(bit = 0; bit < (1<<n); ++bit){//スイッチパターンをbit全探索するループ
        for(i = 0; i < m; i++){//i番目のスイッチのonoffを調べる
            cnt = 0;
            for(j = 0; j < k[i]; j++){
                if(bit & (1 << (s[i][j] - 1))){
                    cnt++;
                }
            }
            if(cnt%2 != p[i]){//i番目のスイッチがoffの場合は諦めて次のスイッチパターンに入る
                break;
            }
            if(i == (m - 1)){
                ans++;
            }
        }    
    }
    printf("%d\n", ans);


}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(i=0; i<n; i++)
#define ford(i,n) for(i=n-1; i>=0; i--)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define fi first
#define se second
using namespace std;


int main(int argc, char const *argv[]){
	ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    ll n,i,j;
    vll a;
    cin>>n;
    fori(i,n){
        cin>>j;
        a.pb(j);
    }
    ll max=0,tempmax=0;
    for(i=1; i<n; i++){
        if(a[i-1]>=a[i]) tempmax++;
        else{
            if(tempmax>max) max=tempmax;
            tempmax=0;
        }
    }
    if(tempmax>max) max=tempmax;
    cout<<max<<"\n";
    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <iostream>
#include <map>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int calc(int i) {
    if (i % 2 == 0) {
        return 1 + calc(i / 2);
    } else {
        return 0;
    }
}

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

    map<int, int> m;
    REP(1, i, 101) {
        m.insert(make_pair(i, calc(i)));
    }

    int ans = 0;
    int cnt = -1;
    REP(1, i, N + 1) {
        if (m[i] > cnt) {
            ans = i;
            cnt = m[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
LL dp[101][100001];
int main() {
    ios_base::sync_with_stdio(false);
    LL n,w;
    cin >> n >> w;
    LL wgt[w+1],val[n+1];
    for(int i=1; i<=n; i++) cin >> wgt[i] >> val[i];
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=w; j++) {
            if(wgt[i]>j) dp[i][j] = dp[i-1][j];
            else dp[i][j]=max(val[i]+dp[i-1][j-wgt[i]],dp[i-1][j]);
        }
    }
    cout << dp[n][w] << "\n";
}


Measured memory_bytes: 78336
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = gets.chomp

strs = S.split('')

e_num = 0
w_num = 0
strs.each do |s|
  if s == 'E'
    e_num += 1
  else
    w_num += 1
  end
end

ans = 10 ** 9
cur_e_num = 0
cur_w_num = 0
strs.each.with_index do |s, i|
  e_to_w = if s == 'E'
    e_num - cur_e_num - 1
  else
    e_num - cur_e_num
  end
  w_to_e = cur_w_num
  sum = e_to_w + w_to_e
  ans = sum if sum < ans

  if s == 'E'
    cur_e_num += 1
  else
    cur_w_num += 1
  end
end

puts ans


Measured memory_bytes: 38216
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[105],b[105],c[105];
int lena,lenb,lenc,cnta,cntb,cntc;
void F1();
void F2();
void F3();
int main() {
	scanf("%s%s%s",a+1,b+1,c+1);
	lena=strlen(a+1);
	lenb=strlen(b+1);
	lenc=strlen(c+1);
	F1();
}






void F2() {
	cntb++;
	if(lenb==cntb-1) {
		puts("B");
		return;
	}
	if(b[cntb]=='a')
		F1();
	else if(b[cntb]=='b')
		F2();
	else
		F3();
}
void F1() {
	cnta++;
	if(lena==cnta-1) {
		puts("A");
		return;
	}
	if(a[cnta]=='a')
		F1();
	else if(a[cnta]=='b')
		F2();
	else
		F3();
}

void F3() {
	cntc++;
	if(lenc==cntc-1) {
		puts("C");
		return;
	}
	if(c[cntc]=='a')
		F1();
	else if(c[cntc]=='b')
		F2();
	else
		F3();
}
/////////////////////


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	if N/4 > 0 {
		switch N % 4 {
		case 0:
			fmt.Println("Yes")
			return
		case 1:
			if N > 20 {
				fmt.Println("Yes")
				return
			}
		case 2:
			if N > 13 {
				fmt.Println("Yes")
				return
			}
		case 3:
			if N > 6 {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
'use strict';
function Main(input) {   
  const temp = input.split(" ");
  const n = temp[0];
  const k = temp[1];
  let ans;
  
  if(k == 1) ans = 0;
  else ans = n - k;
  
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

Measured memory_bytes: 3524
k = int(input())
anss = [1,2,3,4,5,6,7,8,9]
for i in range(12):
    if len(anss) > k:
        print(anss[k-1])
        break
    new_anss = []
    for ans in anss:
        if ans % 10 != 0:
            new_anss += [ans*10+ans%10-1]
        new_anss += [ans*10+ans%10]
        if ans % 10 != 9:
            new_anss += [ans*10+ans%10+1]
    k -= len(anss)
    anss = new_anss


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight; //親との差分
 
    UnionFind(int n = 1, Abel SUM_UNITY = 0){
        init(n, SUM_UNITY);
    }
 
    void init(int n = 1, Abel SUM_UNITY = 0){
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for(int i=0; i<n; i++) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }
 
    int root(int x){
        if(par[x] == x){
            return x;
        }
        else{
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
 
    Abel weight(int x){
        root(x);
        return diff_weight[x];
    }
 
    bool issame(int x, int y){
        return root(x) == root(y);
    }
 
    // weight[y] - weight[x] = w になるようにマージする（x yがそれぞれの木でrootになってるわけではないことに注意）
    bool merge(int x, int y, Abel w){
        // xとyそれぞれについて、rootとの重み差分を補正
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w = -w;
        if(rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
 
    Abel diff(int x, int y){
        return weight(y) - weight(x);
    }
};

int main(){
    int N, M; cin >> N >> M;
    
    UnionFind<int> uni(N);

    for(int i=0; i<M; i++){
        int l, r, d; cin >> l >> r >> d;
        if(uni.issame(l, r)){
            if(uni.diff(l, r) != d){
                cout << "No" << endl;
                return 0;
            }
        }
        else uni.merge(l, r, d);
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 1408
//abc128_d.cpp
//Sun May 26 20:47:33 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k;
	cin >> n >> k;

	int v[n];
	int vinv[n];
	fill(vinv,vinv+n,0);
	for (int i=0;i<n;i++){
		cin >> v[i];
		vinv[n-1-i] = v[i];
	}

	int ans = 0;
	for (int i=0;i<=min(n,k);i++){
		for (int j=0;j<=i;j++){
			priority_queue<int, vector<int>, greater<int>> pq; //
			int temp = 0;
			for (int l=0;l<j;l++){
				temp += v[l];
				pq.push(v[l]);
			}
			for (int l=0;l<i-j;l++){
				temp += vinv[l];
				pq.push(vinv[l]);
			}
			for (int l=0;l<k-i;l++){
				if (pq.size()==0){
					break;
				}
				int xxx = pq.top();
				pq.pop();
				if (xxx<0){
					temp = temp-xxx;
				}else {
					break;
				}
			}
//			cout << i << " " << j << " " << temp << endl;
			ans = max(ans,temp);
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a,b;
        a = input.nextInt();
        b = input.nextInt();
        System.out.printf("%d %d\n",a*b,a*2+b*2);
    }
}


Measured memory_bytes: 26212
#include<bits/stdc++.h>
//<(")
#define ll long long  
using namespace std;

typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;

const ll MAXX = 1e18;
const ll mod = 1e9 + 7;
const ll mod2 = mod * mod;
const ll siz = 3e5 + 10;
const ll base = 32;

ll n, m;
vector<ll> hold;

ll tree[4 * siz];

void update(ll node, ll left, ll right, ll pos, ll val) {
	if (pos < left || pos > right) {
		return;
	}
	if (left == right) {
		if (pos == left) {
			tree[node] = max(tree[node], val);
		}
		return;
	}
	ll mid = (left + right) / 2;
	update(node * 2, left, mid, pos, val);
	update(node * 2 + 1, mid + 1, right, pos, val);
	tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
}

ll get(ll node, ll left, ll right, ll gLeft, ll gRight) {
	if (gLeft > right || gRight < left) {
		return 0;
	}
	if (gLeft <= left && gRight >= right) {
		return tree[node];
	}
	ll mid = (left + right) / 2;
	return max(get(node * 2, left, mid, gLeft, gRight), get(node * 2 + 1, mid + 1, right, gLeft, gRight));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n >> m;
	hold.resize(n + 1);
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> hold[i]; 
	}
	for (ll i = n; i > 0; i--) {
		ll sub = get(1, 1, siz, max(hold[i] - m + 1, 1LL), min(hold[i] + m + 1, siz - 1)) + 1;
		//cerr << sub << '\n';
		ans = max(ans, sub);
		update(1, 1, siz, hold[i] + 1, sub);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 13864
def get_min_score(flags):
    score = 0
    num_probs = 0
    for j, flag in enumerate(flags):
        if flag == '1':
            score += PC[j][1] + PC[j][0] * (j + 1) * 100
            num_probs += PC[j][0]
            if score >= G:
                return num_probs

    for j in range(len(flags) - 1, -1, -1):
        if flags[j] == '0':
            for k in range(PC[j][0]):
                score += (j + 1) * 100
                num_probs += 1
                if score >= G:
                    return num_probs
    return float('inf')


D, G = map(int, input().split())
PC = [list(map(int, input().split())) for _ in range(D)]
ans = float('inf')
for i in range(2 ** D):
    flags = bin(i)[2:].zfill(D)
    ans = min(ans, get_min_score(flags))
print(ans)


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

#define Bye return 0
#define ll long long

void solve(){
    string str; getline(cin, str);

    int a = 0, b = 0,  i = 0;
    while(str[i] != ' ') a = a*10 + (str[i] - '0'), i++;

    bool oper = (str[i+1] == '+') ? true : false;

    i += 3;
    while(i<str.size()) b = b*10 + (str[i] - '0'), i++;

    cout<<((oper) ? a + b : a - b)<<endl;
}

int main()
{
    solve();
    Bye;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string ans = "";
  while (N != 0) {
    if (N % 2 == 0)
      ans = "0" + ans;
    else {
      ans = "1" + ans;
      N--;
    }
    N /= -2;
  }
  if (ans == "")
    ans = "0";
  cout << ans << '\n';
  return 0;
}


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


Measured memory_bytes: 5596
#include <stdio.h>

int main(void)
{
	char s[1000000];
	int i;

	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		if(i%2 == 0){
			printf("%c",s[i]);
		}
	}
	printf("\n");
	return 0;
}




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

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

using namespace std;
using lint=long long;

int main(){
	int n;
	lint d; scanf("%d%lld",&n,&d);

	int ans=0;
	rep(i,n){
		lint x,y; scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=d*d) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3784
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int k , s;

int main(){
    int cnt = 0;
    scanf("%d%d" , &k , &s);
    for(int a = 0; a <= k; a++){
        for(int b = 0; b <= k; b++){
            int c = s - (a + b);
            if(0 <= c && c <= k){
                cnt++;
            }
        }
    }
    printf("%d\n" , cnt);
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, count=0;
  cin >> N;
  int n;
  for (int c=1; c<N; c++) {
    n=N;
    n-=c;
    int m, del=0;
    for (int i=1; i<=n+1; i++) {
      if (i*i>n) {
        m=i-1;
        if (m*m==n) {del=1;}
        break;
      }
    }
    count-=del;
    if (n%2==0) {
      for (int a=1; a<=m; a++) {
        if (n%a==0) {count+=2;}
      }
    }
    else {
      for (int a=1; a<=m; a+=2) {
        if (n%a==0) {count+=2;}
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input!{
        a: usize,
        b: usize
    }
    if a == b {
        println!("{}", 2 * a);
    } else {
        println!("{}", max(a,b) * 2 - 1);
    }
}


Measured memory_bytes: 4352
n = int(input())
l = input().split(" ")
for i in range(len(l)):
    l[i] = int(l[i])

l.sort(reverse=True)
sum = 0
for i in range(1, n):
    sum += l[i]

if sum > l[0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<cstdio>
const static int MAX_N = 100000;
using ll = long long;
unsigned bucket[MAX_N+1];

int main(){
    unsigned N;
    scanf("%u", &N);
    ll sum = 0;
    for (size_t i = 0; i < N; i++){
        ll tmp;
        scanf("%lld", &tmp);
        bucket[tmp]++;
        sum += tmp;
    }
    unsigned Q;
    scanf("%u", &Q);
    for (size_t i = 0; i < Q; i++){
        ll B, C;
        scanf("%lld %lld", &B, &C);
        sum += (C - B)*bucket[B];
        bucket[C] += bucket[B];
        bucket[B] = 0;
        printf("%lld\n", sum);
    }
	return 0;
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x <<" "<< y << " " << z << endl;

   

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int n,a,b;
  cin >>n;
  vector<pair<int,int>> w(n);
  rep(i,n){
    cin >> a >> b;
    w.at(i)=make_pair(b,a);
  }
  sort(w.begin(),w.end());
  bool ans=true;
  ll t=0;
  rep(i,n){
    t+=w.at(i).second;
    if(t>w.at(i).first){ 
      ans=false;
      break;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout << "No" <<endl;
    
}


Measured memory_bytes: 1792
n, m = map(int,input().split())
s = []
c = []
for _ in range(m):
  x, y = map(int,input().split())
  s.append(x)
  c.append(y)

for i in range(10 ** (n + 1)):
    Str = str(i)

    if len(Str) == n and all([Str[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(Str)
        exit()

print(-1)


Measured memory_bytes: 9132
a,v=[int(j)for j in input().split()]
b,w=[int(j)for j in input().split()]
t=int(input())
p=abs(a-b)
if v-w<0:
    print("NO")
else:
    if t*(v-w)>=p:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    if ((n + k) / 2 == (double)(n + k) / 2) {
        out((n + k) / 2);
    } else out("IMPOSSIBLE");
}


Measured memory_bytes: 256
n, m = map(int, input().split())
suki = [0]*(m+1)

for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(1, ka[0]+1):
        suki[ka[j]] += 1

ans = 0
for i in range(1, m+1):
    if suki[i] == n:
        ans += 1
print(ans)


Measured memory_bytes: 62512
import java.util.Scanner;

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

		    String str1 = scanner.next();
            String str2 = scanner.next();

            int A = Integer.parseInt(str1);
            int B = Integer.parseInt(str2);
            
            int C = A * B;
            
            if(C % 2 == 0) 
            {
            	System.out.println("Even");
            }
            else 
            {
            	System.out.println("Odd");
            }
        	scanner.close();}
		  }

Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;

const int INF=10000000;
typedef struct edge{
  int t,c;
  edge(){}
  edge(int t,int c):t(t),c(c){}
};
typedef pair<int ,pair<int,int> > P;


vector<edge> g[105];
int id[11][105];
int c,n,m,s,d;

int main(void){
  while(1){
    scanf("%d %d %d %d %d",&c,&n,&m,&s,&d);
    if(!c && !n && !m && !s && !d) break;
    for(int i=0;i<=n;i++)g[i].clear();

    for(int i=0;i<m;i++){
      int a,b,f;
      scanf("%d %d %d",&a,&b,&f);
      g[a].push_back(edge(b,f));
      g[b].push_back(edge(a,f));
    }

    priority_queue<P,vector<P>,greater<P> > que;
    for(int i=0;i<=c;i++) fill(id[i],id[i]+n+1,INF);
    for(int i=0;i<10;i++)id[i][s]=0;
    que.push(P(0,pair<int,int>(s,c)));
    while(!que.empty()){
      P p=que.top();
      que.pop();
      int v=p.second.first;
      int nc=p.second.second;
      if(v == d) {
	printf("%d\n",id[c-nc][v]);
	break;
      }
      if(id[c-nc][v]<p.first) continue;
      for(int i=0;i<g[v].size();i++){
	edge e = g[v][i];
	if(id[c-nc][e.t]>id[c-nc][v]+e.c){
	  id[c-nc][e.t]=id[c-nc][v]+e.c;
	  que.push(P(id[c-nc][e.t],pair<int,int>(e.t,nc)));
	}
	if(nc>0 && id[c-nc+1][e.t]>id[c-nc][v]+e.c/2){
	  id[c-nc+1][e.t]=id[c-nc][v]+e.c/2;
	  que.push(P(id[c-nc+1][e.t],pair<int,int>(e.t,nc-1)));
	}
      }
    }
    /*
    for(int i=1;i<=n;i++) printf("%d:%d  ",i,id[c][i]);
    puts("");
    printf("%d\n",id[c][d]);
    */
  }
}

Measured memory_bytes: 0
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = IL()
N = I()*1000

a = A/250
b = B/500
c = C/1000
d = D/2000
score = [a,b,c,d]
val = {a:(A,250),b:(B,500),c:(C,1000),d:(D,2000)}

score.sort()

ans = 0
for i in score:
    tmp = N//val[i][1]
    N -= tmp*val[i][1]
    ans += tmp*val[i][0]
print(ans)

Measured memory_bytes: 12488
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int W,H,N,ans=0;
    cin >> W >> H >> N;
    int x[N],y[N],a[N];
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    int flg[W][H];
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            flg[i][j] = 0;
            for(int k=0;k<N;k++){
                if(a[k]==1 && i<x[k]) flg[i][j]++;
                if(a[k]==2 && i>=x[k]) flg[i][j]++;
                if(a[k]==3 && j<y[k]) flg[i][j]++;
                if(a[k]==4 && j>=y[k]) flg[i][j]++;
            }
        }
    }
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if(!flg[i][j]) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    a = LI()
    b = [0] * N

    for i in range(N-1, -1, -1):
        total = 0

        for cur in range(i, N, i+1):
            # print(i + 1, '->', cur + 1)
            total += b[cur]

        if a[i] != total % 2:
            b[i] = 1
            # print(i+1, 'in', a[i],  total)
        # print(*b)

    ans = []
    for i in range(N):
        if b[i] == 1:
            ans.append(i+1)

    print(len(ans))
    if len(ans) > 0:
        print(*ans)


if __name__ == '__main__':
    main()


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

#define N 100

char grid[N][N+1];

int main(void){
    for(long i=0; i<N/2; i++){
        memset(grid[i    ], '#', N);
    }
    for(long i=0; i<N/2; i++){
        memset(grid[i+N/2], '.', N);
    }
    long a;
    scanf("%ld", &a);
    for(long i=0; i<a-1; i++){
        long r=i/50*2;
        long c=i%50*2;
        grid[r][c]='.';
    }
    long b;
    scanf("%ld", &b);
    for(long i=0; i<b-1; i++){
        long r=i/50*2;
        long c=i%50*2;
        grid[r+51][c]='#';
    }
    puts("100 100");
    for(long i=0; i<N; i++){
        puts(grid[i]);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x, y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e[22],dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[21][22];
int l[21];
int j[21];


long long x,y,z,mod=1000000007;
//string r;
char r[22][22];

P u[1];
priority_queue<int> q;
stack<int> s;
//set<P> s;
map<int,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

unsigned long long mix(unsigned long long o){
    o+=0x9e3779b97f4a7c15;
    o=(o^(o>>30))*0xbf58476d1ce4e5b9;
    o=(o^(o>>27))*0x94d049bb133111eb;
    return o^(o>>31);
    //Those constants supposedly are chosen to give this function better pseudo-random properties, but on any on-site contest, when one can't have team reference document/doesn't want to waste time searching it for implementation typing arbitrary large odd numbers by hand should be good enough
}

unsigned long long salt = (chrono::steady_clock::now().time_since_epoch().count());

int f()
{
  unsigned long long l1[22],l2[22];
  int e[22],i=0;
  if(a%2) i=1;
  for(int t=1;t<=a;t++)
    l1[t]=l2[t]=0,e[t]=1;
  for(int t=1;t<=a;t++)
  {
    for(int w=1;w<=b;w++)
    {
      l1[t]^=mix(w^mix(o[t][w]^salt));
      l2[t]^=mix((b-w+1)^mix(o[t][w]^salt));
    }
  }
  for(int t=1;t<=a;t++)
  if(e[t])
  {
    for(int w=t+1;w<=a;w++)
    if(l2[w]==l1[t])
    {
      e[t]=0;
      e[w]=0;
      goto qwe;
    }
    if(i&&l1[t]==l2[t]) i=0;
    else
    {
      return 0;
    }
    qwe:;
  }
  return 1;
}



void uu(int n)
{
  if(n>b/2)
  {
    if(b%2)
    {
      for(int i=1;i<=b;i++)
        if(!e[i]) j[b/2+1]=i;
    }
    for(int t=1;t<=a;t++)
      for(int w=1;w<=b;w++)
        o[t][w]=r[t][j[w]]-'a';
    //for(int t=1;t<=b;t++)
    //printf("%d ",j[t]);
    //puts("");
    if(f())
    {
      puts("YES");
      exit(0);
    }
  }
  for(int i=j[n-1]+1;i<b;i++)
  if(!e[i])
  for(int t=i+1;t<=b;t++)
  if(!e[t])
  {
    e[i]=e[t]=1;
    j[n]=i;
    j[b-n+1]=t;
    uu(n+1);
    e[i]=e[t]=0;
  }
  
}

int main()
{
  scanf("%d %d",&a,&b);
  for(int t=1;t<=a;t++)
    scanf("%s",r[t]+1);
  uu(1);
  puts("NO");
}
//0
//14



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<vector<ll>> aa(n, vector<ll>(3, 0));
    vector<vector<ll>> dp(n, vector<ll>(3, 0));
    rep (i, 0, n) cin >> aa[i][0] >> aa[i][1] >> aa[i][2];
    dp[0][0] = aa[0][0];
    dp[0][1] = aa[0][1];
    dp[0][2] = aa[0][2];
    rep (i, 1, n) {
        chmax(dp[i][0], dp[i - 1][1] + aa[i][0]);
        chmax(dp[i][0], dp[i - 1][2] + aa[i][0]);
        chmax(dp[i][1], dp[i - 1][0] + aa[i][1]);
        chmax(dp[i][1], dp[i - 1][2] + aa[i][1]);
        chmax(dp[i][2], dp[i - 1][0] + aa[i][2]);
        chmax(dp[i][2], dp[i - 1][1] + aa[i][2]);
    }
    r = 0;
    rep(i, 0, 3) chmax(r, dp[n - 1][i]);
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 11264
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <queue>   
#include <utility>
#include <stdio.h>
#include <math.h>

using namespace std;
typedef pair<int,int> P;

int h,w,k;
char g[801][801];

int sx,sy,gx,gy;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int d[801][801];
int f[801][801];

int main(){
   cin>>h>>w>>k;
    for (int i=0;i<h;i++){
        for (int j=0; j<w;j++){
            cin>>g[i][j];
            if (g[i][j]=='S') {sx=i; sy=j;}
        }
    }

  queue<P> que1;
  for (int i=0;i<h;i++){
    for (int j=0; j<w;j++) {
      f[i][j]=700000;
    }
  }
 
  que1.push(P(sx,sy));
  f[sx][sy]=0;
  
 
  while (que1.size()){
    P p=que1.front(); que1.pop();
    if (p.first==0 or p.first==h-1 or p.second==0 or p.second==w-1)
      break;
    for (int i=0; i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
     
      if (0<=nx && nx<h && 0<=ny && ny<w && f[nx][ny]==700000 && g[nx][ny]=='.'){
	que1.push(P(nx,ny));
	f[nx][ny]=f[p.first][p.second]+1;

      }
    }
    
  }
 
  queue<P> que2;
  for (int i=0;i<h;i++){
    for (int j=0; j<w;j++) {
      if (f[i][j]<=k) que2.push(P(i,j));
    }
  }

  
  double minr=700000;
  while (que2.size()>0){
      P p1=que2.front(); que2.pop();
      int temp1,temp2,temp;
      int p1f,p1s,p1f1,p1s1;
      p1f=p1.first;
      p1f1=h-1-p1.first;
      p1s=p1.second;
      p1s1=w-1-p1s;
      temp1=min(p1f,p1f1);
      temp2=min(p1s,p1s1);
      temp=min(temp1,temp2);
      if (temp<minr) minr=temp;
     
  }
    double ans1;
    int ans;
    ans1=ceil(minr/k)+1;
    ans=(int)ans1;
   
    cout<<ans<<endl;
   
    return 0;
}
    


Measured memory_bytes: 5376
#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)
#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll oo=1e15;
int n,cap,w[100005],v[100005];
int main()
{
    scanf("%d %d",&n,&cap);
    f(i,0,n)
        scanf("%d %d",&w[i],&v[i]);
    ll knapsack[n+1][cap+1];
    f(i,0,n+1){
       f(j,0,cap+1){
           if (i==0 || j==0)
               knapsack[i][j] = 0;
           else if (w[i-1]<=j)
                 knapsack[i][j] = max(v[i-1] + knapsack[i-1][j-w[i-1]],  knapsack[i-1][j]);
           else
                 knapsack[i][j] = knapsack[i-1][j];
       }

   }
    cout<<knapsack[n][cap]<<'\n';
    return 0;
}


Measured memory_bytes: 79104
#include<iostream>
using namespace std;
 
int main() {
	//入力
	int n;
	cin >> n;
	string s[100];
	for (int i = 0; i < n; i++) cin >> s[i];
 
	int m;
	cin >> m;
	string t[100];
	for (int i = 0; i < m; i++) cin >> t[i];
 
	//計算
	int max = 0;
 
	for (int i = 0; i < n; i++) {
		int score = 0;
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j]) score++;
		}
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) score--;
		}
 
		if (score > max) max = score;
	}
 
	//出力
	cout << max << endl;
 
	return 0;
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL k, n;
	cin >> k >> n;
	vector<LL> a(n * 2);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i + n] = k + a[i];
	}
	LL ans = 1LL << 60;
	for (int i = 0; i < n; ++i) {
		ans = min(ans, a[i + n - 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

std::vector<long long> LikeEratoshtnes(long long N)
{
    // 求める最大素数
    long long maxPrime = 2;
    std::vector<long long> p;
    for (long long i=0; i<=N; ++i)
    {
        if (i * i <= N)
            maxPrime = i;

        p.push_back(i);
    }

    long long prime = 2;
    p[0] = -1;
    p[1] = -1;

    long long loopCount = 0;
    while (prime <= maxPrime)
    {
        for (auto i=loopCount; i<p.size(); ++i)
        {
            // 素数でないことが確定してる
            if (p[i] == -1)
                continue;

            if (p[i] % prime == 0)
            {
                // 素数
                if (p[i] / prime == 1)
                    continue;
                // 倍数
                else
                    p[i] = -1;
            }
        }

        prime++;
        loopCount++;
    }

    std::vector<long long> result;
    for (long long i=0; i<p.size(); ++i)
    {
        // i が素数でないならスルー
        if (p[i] == -1)
            continue;

        // 素数 i が 2017 likeNumber か
        auto likeNumber = p[i] * 2 - 1;
        if (N < likeNumber)
            break;

        if (p[likeNumber] != -1)
            result.emplace_back(likeNumber);
    }

    return result;
}

int main()
{
    int Q;
    std::cin >> Q;

    const int Max = 100000;
    auto primeNumbers = LikeEratoshtnes(Max);

    std::vector<int> sum(Max+1, 0);

    /*
    for (auto num : primeNumbers)
    {
        std::cout << "num " << num << " / " << (num + 1) / 2 << std::endl;
    }
    */

    auto lastPrimeIndex = 0;
    for (auto i=1; i<=Max; ++i)
    {
        auto candidates = 0;
        while (primeNumbers[lastPrimeIndex] < i && lastPrimeIndex < primeNumbers.size())
        {
            candidates++;
            lastPrimeIndex++;
        }

        sum[i] = sum[i-1] + candidates;
    }

    /*
    for (auto i=0; i<sum.size(); ++i)
        std::cout << i << " : " << sum[i] << std::endl;
        */

    for (auto i=0; i<Q; ++i)
    {
        int from, to;
        std::cin >> from >> to;
        std::cout << sum[to + 1] - sum[from] << std::endl;
    }
}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

using namespace std;

#define MOD 1000000007
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ALL(x) ((x).begin(), (x).end())
#define sync(); ios_base::sync_with_stdio(0);

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


int main(){
   sync();

   int a,b,c;
   cin >> a >> b >>c;
   if(a < b && b < c){
     cout << "Yes" <<endl;
     
   }else{
     cout << "No" <<endl;
   }
   
   
}

Measured memory_bytes: 3124