akhauriyash/Code-Regression huggingface dataset:
h,w,m = map(int,input().split())
hw = [[int(i) for i in input().split()] for j in range(m)]

tate = [0]*(w+1)
yoko = [0]*(h+1)

for i in range(m):
    yoko[hw[i][0]] += 1
    tate[hw[i][1]] += 1
    
ans = 0

t_max = -1


for i in range(1,w+1):
    if t_max < tate[i]:
        t_max = tate[i]
        t_max_idx = []
        t_max_idx.append(i)
    elif t_max == tate[i]:
        t_max_idx.append(i)

y_max = -1

for i in range(1,h+1):
    if y_max < yoko[i]:
        y_max = yoko[i]
        y_max_idx = []
        y_max_idx.append(i)
    elif y_max == yoko[i]:
        y_max_idx.append(i)
        
s_y = set(y_max_idx)
s_t = set(t_max_idx)

if len(y_max_idx)*len(t_max_idx) > m:
    print(t_max+y_max)
else:
    ans = 0
    for i in range(m):
        if hw[i][0] in s_y and hw[i][1] in s_t:
            ans += 1
    if ans < len(y_max_idx)*len(t_max_idx):
        print(t_max+y_max)
    else:
        print(t_max+y_max-1)

Measured memory_bytes: 175172
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
 

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> h(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    vector<vector<int> > g(n);
    for (i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int cnt = 0;
    int j;
    for (i = 0; i < n; i++) {
        int bad = 0;
        for (j = 0; j < (int)g[i].size(); j++) {
            int ne = g[i][j];
            if (h[ne] >= h[i]) bad = 1;
        }
        if (bad == 0) cnt++;
    }
    printf("%d\n", cnt);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 8328
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	long long int number,code,tanka,kazu;
	int count,flag;
	int syain[4000];
	long long int total[4000];
	while(cin >> number && number != 0){
		count = 0;
		for(int i=0;i<number;i++){
			cin >> code >> tanka >> kazu;
			count++;
//			cout << code << tanka << kazu << endl;
			for(int j = 0;j<count;j++){
				if(syain[j] == code){
					//cout << "yahoo" << endl;
					total[j] += (tanka * kazu);
					count--;
					break;
				}
				if(j == count - 1){
					//cout << "bb" << endl;
					syain[j] = code;
					total[j] = tanka * kazu;
				}
			}

			//			cout << code << " " << tanka*kazu << endl;
		}
		flag = 0;
		for(int j = 0; j < count;j++){
			if(total[j]>=1000000){
				cout << syain[j] << endl;
				flag = 1;
			}
			syain[j] = 0;
		}
		if(!flag){
			cout << "NA" << endl;
		}
	}

}

Measured memory_bytes: 0
<?php
fscanf(STDIN, "%d", $N);
$c[1] = 0;
for ($i = 0; $i < $N - 1; $i++) {
    fscanf(STDIN, "%d %d %d", $u, $v, $w);
    $l[$u][$v] = $w;
    $l[$v][$u] = $w;
}
$stack = [1];
while(true) {
    if (! $stack) {
        break;
    } else {
        $tmp = array_pop($stack);
        if (!isset($l[$tmp])) continue;
        foreach ($l[$tmp] as $k => $v) {
            if ($v % 2 === 0) {
                if ($c[$tmp] === 0) {
                    $c[$k] = 0;
                } else {
                    $c[$k] = 1;
                }
            } else {
                if ($c[$tmp] === 0) {
                    $c[$k] = 1;
                } else {
                    $c[$k] = 0;
                }
            }
            array_push($stack, $k);
        }
        unset($l[$tmp]);
    }
}
ksort($c);
echo implode(PHP_EOL, $c);

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

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

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

	bool ok = true;
	if ((s.length() + 1) != t.length())
		ok = false;
	// if (s.length() > 10 || s.length() == 0)
	// 	ok = false;

	for (int i = 0; i < s.length() && i < t.length(); i++) {
		if (s[i] != t[i] || !islower(s[i]) || !islower(t[i])) {
			ok = false; break;
		}
	}


	cout << (ok ? "Yes\n" : "No\n");

}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer n;
  n = nil->next;
  while( n != nil && n->key != key){
    n = n->next;

  }
  return n;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer n;
  n = nil->prev;
  if( n == nil ) return;
  deleteNode(n);
}

void delete(int key){
  NodePointer n;
  n = listSearch(key); 
  if( n == nil ) return;
  deleteNode(n); 
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;

int S,r;
ll sum,ans;
int f[25000000];

ll power(ll x,ll y) {
	ll ret=1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) ret=ret*x%mod;
	return ret;
}

inline void add(ll &x,ll y) {x=(x+y)%mod;}

ll cal(int x) {
	return 9*power(10,x-1)-S/x+1;
}

int main()
{
	scanf("%d",&S);
	for (int i=1;i<=23000000;i++) f[i]=f[i/10]+1;
	for (int i=1;i<10000000;i++) {
		while (sum<S) sum+=f[++r];
		if (sum==S) ans++;
		sum-=f[i];
	}
	for (int i=1;i<=sqrt(S);i++)
		if (S%i==0) {
			if (i>=8)add(ans,cal(i));
			if (i*i!=S && S/i>=8) add(ans,cal(S/i));
		}
	add(ans,S/8);
	for (int i=1;i<=S/8;i++) if (S%i==0) ans--;
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 90368
#include <iostream>

using namespace std;

struct Card {
    char suit, value;
};

static const int MAX = 36;

void bubbleSort(struct Card card[], int n) {
    for (int i = 0; i < n - 1; i++) {
        for (int j = n - 1; j >= i + 1; j--) {
            if (card[j].value < card[j - 1].value) {
                swap(card[j], card[j - 1]);
            }
        }
    }
}

void selectionSort(struct Card card[], int n) {
    for (int i = 0; i < n - 1; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (card[minj].value > card[j].value) minj = j;
        }
        swap(card[minj], card[i]);
    }
}

bool isStable(struct Card c1[], Card c2[], int n) {
    for (int i = 0; i < n; i++) {
        if (c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

void output(struct Card c[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << c[i].suit << c[i].value;
    }
    cout << endl;
}

int main() {
    Card c1[MAX], c2[MAX];
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) cin >> c1[i].suit >> c1[i].value;
    for (int i = 0; i < n; i++) c2[i] = c1[i]; // copied

    bubbleSort(c1, n);
    output(c1, n);
    cout << "Stable" << endl;

    selectionSort(c2, n);
    output(c2, n);
    if (isStable(c1, c2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    ll ans = 0;
    rep(i, pow(2,s.size()-1)){
        ll n = s[0]-'0';
        rep(j, s.size()-1){
            if((1<<j)&i)ans+=n, n=0;
            n = n*10+(s[j+1]-'0'); 
        }ans += n; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

signed main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	priority_queue <int> pq;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		pq.push(x);
	}	

	for(int i=0; i<m; i++){
		int tp = pq.top();
		pq.pop();
		tp /= 2;
		pq.push(tp);
	}

	int res=0;
	while(!pq.empty()){
		res += pq.top();
		pq.pop();
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 1400
n = int(input())
h = list(map(int,input().split()))
mcnt = 0
cnt = 0
for i in range(1,len(h)):
    if h[i] <= h[i-1] :
        cnt += 1
        if mcnt < cnt :
            mcnt = cnt
    else :
            cnt = 0
print(mcnt)


Measured memory_bytes: 14252
def main17():
    data = input().split()
    num = []
    for i in range(3):
        num.append(int(data[i]))
    num2 = []
    num2.append((num[0]+num[1]))
    num2.append((num[0]+num[2]))
    num2.append((num[2]+num[1]))
    print((min(num2)))

if __name__ == "__main__":
    main17()

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

const int N = 1000010;
const int moder = (int) 1e9 + 7;

char s[N];
int cnt[N];

int main(){
    int n;
    scanf("%d%s", &n, s);
    for (int i = 0; i < n; ++ i){
        ++ cnt[s[i] - 'a'];
    }
    int ans = 1;
    for (int i = 0; i < 26; ++ i){
        ans = 1ll * ans * (cnt[i] + 1) % moder;
    }
    -- ans;
    ans += ans < 0 ? moder : 0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;++i)
char s[201010];
int main()
{
    int n;
    int a,b,c,d;
    int res=0;
    scanf("%d",&n);
    scanf("%d%d%d%d",&a,&b,&c,&d);
    scanf("%s",s);
    for(int i=a-1;i<max(c,d);i++){
        if(s[i]=='#'&&s[i-1]=='#'){
            printf("No\n");
            return 0;
        }
    }
    if(s[c-1]=='#'||s[d-1]=='#')
    {
        printf("No\n");
        return 0;
    }
    int  flag=0;
    for(int i=b-1;i<min(c,d);i++){
        if(s[i]=='.'&&s[i-1]=='.'){
            if(i+1<n){
                if(s[i+1]=='.')
                    flag=1;
            }
            else
                flag=1;
        }
        //cout << flag << endl;
    }
    //cout << c << d << flag << endl;
    if(c>d){
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    int N;
    ArrayList<String> ans = new ArrayList<String>();

    Main() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        // int[][] dp = new dp[N][N];
        // for(int i=0;)
        solve("a", 'a');
        Collections.sort(ans);
        PrintWriter pw = new PrintWriter(System.out);
        for (String str : ans)
            pw.println(str);
        pw.flush();
    }

    void solve(String s, char max) {
        if (s.length() == N) {
            ans.add(s);
            return;
        }
        char c = s.charAt(s.length() - 1);
        for (char i = 'a'; i <= max + 1; i++) {
            solve(s + i, i<max?max:i);
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


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

int n;
vector<ll> a, c;

void input() {
    cin >> n;
    rep(i, n) {
        ll x;
        cin >> x;
        a.push_back(-x);
    }
}

int main() {
    input();
    for (ll x : a) {
        auto itr = upper_bound(c.begin(), c.end(), x);
        if (itr == c.end()) c.push_back(x);
        else c[itr-c.begin()] = x;
    }
    cout << c.size() << endl;
}


Measured memory_bytes: 2548
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a, b, diff, snow;
    cin >> a >> b;
    diff = b - a;

    snow = 0;
    int i;
    for(i=1; i<=diff; ++i){
        snow += i;
    }
    snow -= b;
    cout << snow;

    return 0;
}

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

char arr[12][12];
void subsetsUtil(vector<int>& A, vector<vector<int> >& res, 
                 vector<int>& subset, int index) 
{ 
    res.push_back(subset); 
    for (int i = index; i < A.size(); i++) { 
  
        // include the A[i] in subset. 
        subset.push_back(A[i]); 
  
        // move onto the next element. 
        subsetsUtil(A, res, subset, i + 1); 
  
        // exclude the A[i] from subset and triggers 
        // backtracking. 
        subset.pop_back(); 
    } 
  
    return; 
} 
  
// below function returns the subsets of vector A. 
vector<vector<int> > subsets(vector<int>& A) 
{ 
    vector<int> subset; 
    vector<vector<int> > res; 
  
    int index = 0; 
    subsetsUtil(A, res, subset, index); 
  
    return res; 
} 

int main() {
    ll h, w, k, total_bl = 0;
    cin >> h >> w >> k;

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

    vector<int> subs;
    for (int i = 0; i < h + w; i++) subs.push_back(i);

    auto ind = subsets(subs);

    ll num = 0;
    for (auto v : ind) {
        vector<int> row, col;
        for (auto x : v) {
            if (x < h) row.push_back(x);
            else col.push_back(x - h);
        }

        ll cnt = 0;
        for (int i = 0; i < h; i++) {
            if (find(row.begin(), row.end(), i) != row.end()) continue;
            for (int j = 0; j < w; j++) {
                if (find(col.begin(), col.end(), j) != col.end()) continue;
                if (arr[i][j] == '#') {
                    cnt++;
                }
            }
        }
        if (cnt == k) {
            num++;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 3856
#include <iostream> 
using namespace std;
typedef long long int ll;
ll findProductSum(ll A[], ll n) 
{ 
    ll array_sum = 0; 
    for (ll i = 0; i < n; i++) 
        array_sum = array_sum + A[i]; 
    ll array_sum_square = array_sum * array_sum; 
    ll individual_square_sum = 0; 
    for (ll i = 0; i < n; i++) 
        individual_square_sum += A[i]*A[i]; 
    return (array_sum_square - individual_square_sum)/2; 
} 
int main() 
{ 
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    cout <<findProductSum(a, n); 
    return 0; 
}

Measured memory_bytes: 256
def ForBaseConvert(Roop,MaxD,Base):
    if all(type(TT) is int for TT in [Roop,MaxD,Base]):
        if Base>=2 and MaxD>=1:
            ConvertN = []
            while Roop>0:
                ConvertN.append(Roop%Base)
                Roop = Roop//Base

            BaseConv = [0]*(MaxD-len(ConvertN))+ConvertN[::-1]
            BaseSInd = [[] for TB in range(0,Base)]
            for TB in range(0,Base):
                BaseSInd[TB] = [SInd for SInd,SNum in enumerate(BaseConv) if SNum==TB]
            return BaseConv,BaseSInd
        else:
            return []
    else:
        return []

import math
D,G = (int(T) for T in input().split())
PCList = [[] for TD in range(0,D)]
MINSolve = 1000
for TD in range(0,D):
    PCList[TD] = [int(T) for T in input().split()]

for Roop in range(0,2**D):
    Failed = False
    BaseConv,BaseSInd = ForBaseConvert(Roop,D,2)
    Solve = 0
    Point = 0
    for TD in range(0,D):
        if BaseConv[TD]==1:
            Solve += PCList[TD][0]
            Point += (100*(TD+1)*PCList[TD][0])+PCList[TD][1]
    
    if len(BaseSInd[0])>0:
        Add = BaseSInd[0][-1]
        Ned = math.ceil(max(G-Point,0)/(100*(Add+1)))
        if Ned<=(PCList[Add][0]-1):
            Solve += Ned
            Point += 100*(Add+1)*Ned
     
    if Point>=G and Solve<MINSolve:
        MINSolve = Solve
print(MINSolve)

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

typedef long long ll;

const int MOD = 1e9+7;

int main(){
  int n, m; cin >> n >> m;
  ll x[n+1], y[m+1];
  for(int i=1; i<=n; i++) cin >> x[i];
  for(int i=1; i<=m; i++) cin >> y[i];

  ll xsum=0, ysum=0;
  for(int k=1; k<=n; k++){
    xsum += (k-1)*x[k]-(n-k)*x[k];
    xsum %= MOD;
  }
  for(int k=1; k<=m; k++){
    ysum += (k-1)*y[k]-(m-k)*y[k];
    ysum %= MOD;
  }

  cout << xsum*ysum%MOD << endl;

  return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    repl(i, 1, n + 2) {
        if(i * i > n) {
            cout << (i - 1) * (i - 1) << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 105;
char s[maxn][maxn];
int f[maxn][maxn];

int main () {
	int n = read, m = read;
	for (int i = 1; i <= n; i ++)
		scanf("%s", s[i] + 1);

	for (int i = 0; i < maxn; i ++)
		f[i][0] = f[0][i] = 1000000000;

	f[1][1] = s[1][1] == '#';
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++)
			if (i > 1 or j > 1) {
				f[i][j] = std::min({
						f[i - 1][j] + (s[i][j] == '#' and s[i - 1][j] == '.'),
						f[i][j - 1] + (s[i][j] == '#' and s[i][j - 1] == '.')});
			}

	/* for (int i = 1; i <= n; i ++) */
	/* 	for (int j = 1; j <= m; j ++) */
	/* 		debug("%d\n", f[i][j]); */

	printf("%d\n", f[n][m]);
}


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

int main(){
    string stone;
    int n,r,w;
    int ans=0;
    
	cin>>n;
    cin>>stone;
    
	r=n-1;
    w=0;
    
    while(r>w){
        while(stone[r]!='R'&&r!=w){
            r--;
        }
        while(stone[w]!='W'&&r!=w){
            w++;
        }
        if(r==w) break;
        stone[r]='W';
        stone[w]='R';
        r--;
        w++;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3744
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

a=1
b=0
if A[0]-B[0]==A[1]-B[1]==A[2]-B[2]:
    b=1
else:
    a=0

if B[0]-C[0]==B[1]-C[1]==B[2]-C[2]:
    b=1
else:
    a=0

if A[0]-A[1]==B[0]-B[1]==C[0]-C[1]:
    b=1
else:
    a=0
if A[1]-A[2]==B[1]-B[2]==C[1]-C[2]:
    b=1
else:
    a=0

if a==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=2005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
int main()
{
    std::ios::sync_with_stdio(false);
    int n,sum=0;
    cin>>n;
    bitset<N*N> bi;
    bi[0]=1;
    for(int i=1;i<=n;i++)
    {
        int c;
        cin>>c;
        sum+=c;
        bi|=bi<<c;
    }
    for(int i=(sum+1)/2;i<=sum;i++)
    {
        if(bi[i])
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k, s;
	scanf("%d %d", &k, &s);
	
	int cnt=0;
	for(int x=0; x<=k; ++x){
		for(int y=0; y<=k; ++y){
		int	z=s-(x+y);
			if(z>=0&&z<=k)
			++cnt;
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

static int compare_ll (const void *a, const void *b) {
    if ( *(long long*)a > *(long long*)b )
        return -1;
    else if ( *(long long*)a < *(long long*)b )
        return 1;
    else
        return 0;
}

static void swap (int *a, int *b) {
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

static int gcd (int a, int b) {
    int r;

    if ( a < b )
        swap(&a, &b);

    r = a % b;
    while ( r != 0 ) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main (void) {
    long long ans;
    long long i;
    long long N, X;
    scanf("%lld%lld", &N, &X);

    long long x[N+1];
    x[0] = X;
    for ( i=1; i<=N; i++ )
        scanf("%lld", &x[i]);

    /* sort */
    qsort(x, N+1, sizeof(long long), compare_ll);

    ans = x[0] - x[1];
    for ( i=1; i<N; i++ )
        ans = gcd(ans, x[i]-x[i+1]);

    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}


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

int main(void){
    int N;
    cin>>N;
    vector<long long> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    cout<<A[N-1]-A[0]<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int a, b;

int main(void) {
	cin >> a >> b;
	int ret=-1;
	for (int i = 1; i < 1001; i++) {
		if (int(0.08 * i) == a && int(0.1 * i) == b) {
			ret = i;
			break;
		}
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll a;cin>>a;
    ll b;cin>>b;
    ll c;cin>>c;
    ll d;cin>>d;
    a=(a+d-1)/d;
    c=(c+b-1)/b;
    if(a>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        long N = Long.parseLong(scanner.next());
        long A = Long.parseLong(scanner.next());
        long B = Long.parseLong(scanner.next());
        long abs = Math.abs(A - B);
        long ans;
        if (abs % 2 == 0) {
            ans = abs / 2;
        } else {
            ans = (abs / 2) + 1 + Math.min(Math.min(A, B) - 1, N - Math.max(A, B));
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 22740
#include <iostream>

int main()
{

    int a, b, c;
    int count = 0;
    std::cin >> a >> b >> c;

    for (int i = a; i <  b + 1; i++) {
        if (c % i == 0) {
            count++;
        }
    }



    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;


int32_t main(){
 	fastIO;
	int k;cin>>k;
	int ans=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				ans+=__gcd(i,__gcd(j,l));
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3612
n,x,y=map(int,input().split())
edge=[None]*n
edge[0]=[1]
edge[n-1]=[n-2]
for i in range(1,n-1):
    edge[i]=[i-1,i+1]
edge[x-1].append(y-1)
edge[y-1].append(x-1)
ans=[0]*n

from collections import deque
def bfs(start):
    q=deque([start])
    d=[None]*n
    d[start]=0
    while q:
        v=q.popleft()
        for nv in edge[v]:
            if d[nv]==None:
                d[nv]=d[v]+1
                q.append(nv)
    for i in d:
        ans[i]+=1

for i in range(n):
    bfs(i)
for i in ans[1:]:
    print(i//2)

Measured memory_bytes: 77176
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);

int main() {
    // source
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4) {
        if (s[i] == '-') {
            ans--;
        } else {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int gcd(long long int a, long long int b){
	return (b > 0)? gcd(b, a % b) : a ;
}

long long int lcm(long long int a, long long int b){
	return a / gcd(a, b) * b;
}

int main(void) {
    int A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,s,d;
    char o;

    cin>>a>>o>>b;
    s=a-b;
    d=a+b;
    if ( a<1 || b<1) {cout<<"error"; return 0 ;
    }
    if (b>1000000000||a>1000000000) {cout<<"error"; return 0 ;
    }
    if(o =='+') cout<<d;
    if(o =='-') cout<<s;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		int n;
		cin >> n;

		if (n == 0) {
			return 0;
		} else {
			vi v;
			v.resize(n);
			REP(i, n) cin >> v[i];
			sort(ALL(v));
			ll ans = INF;
			REP(i, n - 1)
			{
				ans = min(ans, v[i + 1] - v[i]);
			}
			ans = min(ans, v[n - 1] - v[n - 2]);
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t="CODEFESTIVAL2016";
  cin>>s;
  auto i=t.begin();
  cout << accumulate(s.begin(),s.end(),0,[&](int a,char c){return a+(*(i++)!=c);}) << endl;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

signed main(){
	int n=read();
	assert(1<=n&&n<=100000);
	const int inf=LLONG_MAX/3;
	int dp[3]={0,-inf,-inf};
	REP(i,n){
		string op="+";
		if(i)
			op=readString();
		assert(op=="+"||op=="-");
		int x=read();
		assert(1<=x&&x<=1000000000);
		if(op=="-"){
			dp[2]=dp[1];
			dp[1]=dp[0];
			dp[0]=-inf;
		}
		dp[0]+=x;
		dp[1]-=x;
		dp[2]+=x;
		chmax(dp[1],dp[2]);
		chmax(dp[0],dp[1]);
	}
	cout<<dp[0]<<endl;
}


Measured memory_bytes: 2432
import Foundation

let line: [Int] = readLine()!.components(separatedBy: " ").map { Int($0)! }
let H1 = line[0]
let M1 = line[1]
let H2 = line[2]
let M2 = line[3]
let K = line[4]

print((H2 - H1) * 60 + (M2 - M1) - K)

Measured memory_bytes: 14176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};



int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[2] != s[1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n){
        int x, y;
        cin >> x >> y;
        if (x == y) mp[i] = 1;
        else mp[i] = 0;
    }
    string ans = "No";
    rep(i,n-2){
        if (mp[i] == 1 && mp[i+1] == 1 && mp[i+2] == 1) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    for(int i = n;i<10000;i++){
       string str = std::to_string(i);
       if(str[0] == str[1]&&str[1] == str[2]){
         cout<<i;
         return 0;
         break;
       }
    }
      
    return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int N, K; std::cin >> N >> K;
    std::vector<int> A(N);
    for(int i(0); i < N; ++i) std::cin >> A[i];
    
    int ng(0), ok(INF);
    while(ok > ng + 1){
        int mid((ng + ok) / 2);
        long long cnt(0);
        for(int i(0); i < N; ++i){
            cnt += (A[i] - 1) / mid;
        }
        if(cnt <= K) ok = mid;
        else ng = mid;
    }
    std::cout << ok << std::endl;
    return 0;
}


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

int main(){ 
  string O,E;
  cin >> O >> E;

  string ans;
  while(E.size() > 0){
    ans.push_back(O.at(0));
    ans.push_back(E.at(0));
    O= O.substr(1);
    E= E.substr(1);
  }
  if(O.size() > 0){
    ans+= O;
  }

  cout << ans << endl;
}

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

#define INF 100000000

int main(){
    int a[5];
    rep(i,5) cin>>a[i];

    int ans =0;
    int hasu = INF;
    rep(i,5){
        ans += ((a[i]+9)/10)*10;
        if(a[i]%10 != 0){
            hasu = min(hasu, a[i]%10);
        }
    }

    cout << ( hasu == INF ? ans :  ans +(hasu -10)) <<endl;
    
    return 0;
}

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

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

    if(r < 1200)
    {
        cout << "ABC" << endl;
    }
    
    else if (r < 2800) {
        cout << "ARC" << endl;
    }
    
    else
    {
        cout << "AGC" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main()
{
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll x[100005];
    ll ans = (ll)pow(10,9);
    REP(i,n){
        cin >> x[i];
        ans = (ll)min(ans,(ll)abs(x[i]));
    }
    if(k==1){
        cout << ans << endl;
        return 0;
    }
    ll Minsum = (ll)pow(10,9);
    REP(i,n-k+1){
        ll Mins = (ll)pow(10,9);
        ll rightNum = x[i];
        ll leftNum = x[i+k-1];
        //cout << i << i+k-1 << ":::" << endl;
        if(rightNum < 0){
            if(leftNum > 0){
                Mins = (ll)min((ll)abs(leftNum*2)+(ll)abs(rightNum),(ll)abs(rightNum*2)+(ll)abs(leftNum));
            }else{
                Mins = (ll)abs(rightNum);
            }
        }else{
            Mins = (ll)abs(leftNum);
        }
        Minsum = (ll)min(Minsum,Mins);
    }
    cout << Minsum << endl;

    return 0;
}


Measured memory_bytes: 1024
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int n;
	cin >> n;
	ll ans=0;
	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j < n; ++j)
		{
			if(i*j>=n)break;
			ans++;
		}
	}
	printf("%lld\n",ans);
	
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int key(int x){
	int s=0,m=0;
	for(int i=2;i<=x;i++){
		if(x%i==0){
			s+=i;
			m=i;
			while(x%i==0){
				x/=i;
			}
		}
	}
	return m-(s-m);
}
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int a,b; cin >> a >> b;
		if(a==0&&b==0)break;
		cout << (key(a)>key(b)?'a':'b') << endl;
	}
	return 0;
}


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


int main() {
    int r,D,x2k;
    cin >> r >> D >> x2k;
    for (int i = 0; i < 10; i++)
    {
        x2k = r* x2k -D;
        cout <<x2k <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
#define SORT(x) (sort(x.begin(),x.end()))
#define REV(x) (reverse(x.begin(),x.end()))
#define QSORT(x) (qsort(x,x.length(),sizeof(x[0]),compare_str))
const ll INF=1e9+7;
const ll N = 200003;
string s,t;


int main(){
	cin>>s>>t;
	SORT(s);
	SORT(t);
	REV(t);
	string ans=(s<t)?"Yes":"No";
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  @scala.annotation.tailrec
  def loop(pairs: List[(Int, Int)], k: Int, acc: Int): Int = pairs match {
    case _ if k <= 0 => acc
    case Seq() => acc
    case (i, j) :: xs if i <= k => loop(xs, k - i, acc + i * j)
    case (_, j) :: xs => loop(xs, 0, acc + k * j)
  }

  val sc = new java.util.Scanner(System.in)
  val A, B, C, K = sc.nextInt()
  println(loop(List(A, B, C).zip(List(1, 0, -1)), K, 0))
}


Measured memory_bytes: 55444
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(int a, int b){
    int max_int = max(a,b);
    int min_int = min(a,b);
    
    return max_int % min_int;
}

int main(){
    long long A, B;
    
    // 入力
    cin >> A >> B;
    
    
    long long temp_A = max(A,B);
    long long temp_B = min(A,B);
    while (temp_B!=0) {
        long long temp = temp_A % temp_B;
        temp_A = temp_B;
        temp_B = temp;
    }
    
    cout << A*B/temp_A << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;

signed main(){  
    cin >> N;
    if(65 <= N && N <=90){
        cout << 1 << endl;
    }
    else if(97 <= N && N <= 122){
        cout << 2 << endl;
    }
    else {
        cout << 0 << endl;
    }


    return 0;
}

/*

*/


Measured memory_bytes: 3100
while True:

    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2 == 0:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()



Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a1=0,a2=0,b1;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    if(A>a1)
      a2=a1,b1=i,a1=A;
    else if(A>a2)
      a2=A;
  }
  for(int i=0;i<N;i++){
    if(i==b1)
      cout<<a2<<endl;
    else
      cout<<a1<<endl;
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

const ll MAX_INT = 1e9;
int main()
{
    ll s;
    cin >> s;

    // s = (x1*y2 - x2*y1)
    // s = 1e9*y2 - x2
    // y2 = s / 1e9 + x2
    // x2 = 1e9*y2 - s
    const ll v = 1000000000;

    ll x = (v - s % v) % v;
    ll y = (x + s) / v;

    printf("0 0 1000000000 1 %ld %ld\n", x, y);

    return 0;
}

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

int dp[200009][5],n,x,ans=1e9;

int main(){
  r(i,200009)r(j,5)dp[i][j]=1e9;
  dp[0][0]=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    int A=0;
    if(!x)A=1;
    for(int j=0;j<5;j++){
      if(j==0){
        dp[i+1][0]=min(dp[i+1][0],dp[i][0]+x);
        dp[i+1][1]=min(dp[i+1][1],dp[i][0]+(x%2==1&&x)+A*2);
        dp[i+1][2]=min(dp[i+1][2],dp[i][0]+(x%2==0&&x)+A*1);
      }
      if(j==1){
        dp[i+1][1]=min(dp[i+1][1],dp[i][1]+(x%2==1&&x)+A*2);
        dp[i+1][2]=min(dp[i+1][2],dp[i][1]+(x%2==0&&x)+A*1);
        dp[i+1][4]=min(dp[i+1][4],dp[i][1]+x);
      }
      if(j==2){
        dp[i+1][2]=min(dp[i+1][2],dp[i][2]+(x%2==0&&x)+A*1);
        dp[i+1][3]=min(dp[i+1][3],dp[i][2]+(x%2==1&&x)+A*2);
        dp[i+1][4]=min(dp[i+1][4],dp[i][2]+x);
      }
      if(j==3){
        dp[i+1][3]=min(dp[i+1][3],dp[i][3]+(x%2==1&&x)+A*2);
        dp[i+1][4]=min(dp[i+1][4],dp[i][3]+x);
      }
      if(j==4){
        dp[i+1][4]=min(dp[i+1][4],dp[i][4]+x);
      }
    }
  }
  r(i,5)ans=min(ans,dp[n][i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 4096
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int K;cin>>K;
    vector<int> A(K+1);
    A[1] = 7 % K;
    for(int i=2;i<=K;i++) A[i] = (A[i-1]*10 + 7) % K;
    for(int i=1;i<=K;i++){
        if(A[i]==0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7152
MOD = 998244353
n, s = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
dp = [0] * (s + 1)
dp[0] = 1
for x in a:
    for j in range(s, x - 1, -1):
        dp[j] += dp[j - x]
        if dp[j] >= MOD:
            dp[j] -= MOD
    ans += dp[s]
    dp[0] += 1
print(ans % MOD)


Measured memory_bytes: 42348
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(a>b)swap(a,b);
    put(max(b-(w+a),0));
    return 0;
}


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

const int MaxN = 1e5;
using namespace std;

int a, b,c;

int main()
{
	cin >> a >> b >> c;
	if(a + b >= c)
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int B[n-1];
    for(int i=0;i<n-1;i++)
        cin>>B[i];
    int curr=INT_MAX,next=INT_MAX,sum=0;
    for(int i=0;i<n-1;i++){
        curr=min(next,B[i]);
        next=B[i];
        sum+=curr;
    }
    sum+=next;
    cout<<sum<<endl;
}

Measured memory_bytes: 256