akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const unsigned LIMIT = 50000;

int main(){
	bool table[ LIMIT ] = { false };
	table[ 2 ] = true;
	for ( int i = 3; i < LIMIT; i += 2 ){
		table[ i ] = true;
	}
	for ( int i = 3; i < LIMIT; i += 2 ){
		if ( !table[ i ] ) continue;
		for ( int j = i + i; j < LIMIT; j += i ){
			table[ j ] = false;
		}
	}

	int n;
	while ( cin >> n ){
		if ( !( n ) ) break;

		int cnt = 0;
		if ( table[ n - 2 ] ) ++cnt;
		for ( int i = 3; i <= n / 2; i += 2 ){
			if ( !table[ i ] ) continue;
			if ( table[ n - i ] ) ++cnt;
		}

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 912
N = int(input())
list=[]
for i in range(N):
    list.append(int(input()))
count=0
X=list[0]
while True:
    count+=1
    if X == 2:
        print(count)
        break
    elif count == N:
        print(-1)
        break
    X=list[X-1]

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

string exec(vector<string> &v, string s){
    string ret = "";
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '"'){
            i++;
            string tmp = "";
            while(i < s.length() && s[i] != '"')  tmp += s[i], i++;
            v.push_back(tmp);
            ret += "_";
        }else{
            ret += s[i];
        }
    }
    return ret;
}

int main(){
    string s, t;
    while(cin >> s, s != "."){
        cin >> t;
        int slen = s.length(), tlen = t.length();
        vector<string> vs, vt;
        string ss = exec(vs, s);
        string tt = exec(vt, t);
        
        if(ss != tt || vs.size() != vt.size()){
            cout << "DIFFERENT" << endl;
            continue;
        }

        int cnt = 0;
        for(int i = 0; i < vs.size(); i++){
            if(vs[i] != vt[i])  cnt++;
        }

        if(cnt == 0){
            cout << "IDENTICAL" << endl;
        }else if(cnt == 1){
            cout << "CLOSE" << endl;
        }else if(cnt > 1){
            cout << "DIFFERENT" << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3192
N = int(input().strip())
A = list(map(int, input().strip().split()))

def mod(x):
	return x % 1000000007

sa = sum(A[1:])
s = mod(A[0] * sa)

for a in A[1:-1]:
	sa -= a
	s = mod(s + a * sa)

print(s)

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

graph = [[0] * 9 for i in range(9)]

for i in range(1, n + 1):
    if i % 10 != 0:
        i = str(i)
        sentou = int(i[0])
        matubi = int(i[-1])
        graph[sentou - 1][matubi - 1] += 1

import numpy as np

graph = np.array(graph)

print(np.trace(np.dot(graph, graph)))

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

#define X first
#define Y second
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int ans=0;
	for (int j=1;j<=n;++j)
	{
		int x;
		scanf("%d",&x);
		if (x<a||x>=b) ++ans;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int card [][] = new int[N][3];
		int score [] = new int[N];
		int count [][] = new int[N][3];
		for(int i = 0 ; i < N ; i++){
			card[i][0] = sc.nextInt();
			card[i][1] = sc.nextInt();
			card[i][2] = sc.nextInt();
		}
		
		
		for(int i = 0 ; i < N ; i++){
			for(int k = 0 ; k < 3 ; k++){
				for(int j = 0 ; j < N ; j++){
					if(card[i][k] != card[j][k]){
						count[i][k]++;
					}
				}
				if(count[i][k] == N - 1){
					score[i] = score[i] + card[i][k];
				}
			}
			
		}
	
			
			
		for(int i = 0 ; i < N ; i++){
			System.out.println(score[i]);
		}
        }
}

Measured memory_bytes: 28792
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define int long long
#define mod 1000000007

void solve() {
        int a, b; cin >> a>> b;
        cout << a * b / __gcd(a, b)<< "\n";
        return;
}

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  char c;
  cin >> c;
  if('A' <= c && c <= 'Z'){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
std::string s;
int main() {
	std::cin >> s;
	int size = s.size();
	if (size % 2) {
		if (s[0] == s[size - 1]) {
			std::cout << "Second" << std::endl;
		}
		else {
			std::cout << "First" << std::endl;
		}
	}
	else {
		if (s[0] == s[size - 1]) {
			std::cout << "First" << std::endl;
		}
		else {
			std::cout << "Second" << std::endl;
		}
	}
	return 0;
}

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


int main() {

  int a[5]; for(int i=0;i<5;i++) cin >> a[i];
  int  k; cin >> k;
  
  int cnt=0;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(a[j]-a[i] > k) cnt++;
    }
  }

  
  if(cnt==0)  cout << "Yay!" << endl;    
  if(cnt!=0)  cout << ":(" << endl;    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
  int a,b,C;
  double S,L,h;
  cin >> a >> b >> C;

  double pi = acos(-1);
  double rad = pi * C / 180;

  S = a * b * sin(rad) * 0.5;
  L = sqrt( pow(a,2) + pow(b,2) - 2*a*b*cos(rad) );
  h = b * sin(rad);

  cout << fixed << setprecision(10) << S <<endl
       << fixed << setprecision(10) << L+a+b<< endl
       << fixed << setprecision(10) << h << endl;

  return 0;
}



Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 小数のときは，精度の設定する．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int64_t L, R; cin >> L >> R;
const int m = 2019;

int64_t mini = INF;
int Lm, Rm;
VI ra;
if (R - L >= m){
    Lm = 0;
    Rm = m;
}
else if (R/m - L/m) { // [L, R] が m の倍数をまたぐ
    rep(i, 0, R%m+1) ra.push_back(i);
    rep(i, L%m, m) ra.push_back(i);
    for (int64_t i : ra) for (int64_t j : ra ) mini = min(mini , (i * j) % m);
    cout << mini << "\n";
    return 0;
}
else { // またがない
    Lm = L % m;
    Rm = R % m;
}

rep(i, Lm, Rm+1) rep(j, i+1 , Rm+1) mini = min(mini , (i * j) % m);

cout << mini << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
map<ll, vl>g;
ll vis[200010], ans = 0;
ll dfs(ll node)
{
	ll len = 1;
	vis[node] = 1;
	FOR(i, 0, g[node].size())
	{
		ll child = g[node][i];
		if (!vis[child])
		{
			len+=dfs(child);
		}
	}
	return len;
}
void solve()
{
	IN(n)IN(m);
	FOR(i, 0, m)
	{
		IN(in1)IN(in2);
		g[in1].pb(in2);
		g[in2].pb(in1);
	}
	FOR(i, 1, n+1)
	{
		if (!vis[i])
			ans=max(ans,dfs(i));
	}
	cout << ans;

}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 51964
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int h,w,n;
int r,c;
std::string s,t;

//R->U->L->D

bool IsYes(){
  char tak_move[4]={'R','U','L','D'};
  char aok_move[4]={'L','D','R','U'};


  for(int dir=0;dir<4;dir++){
    int pos=(dir%2==0)?c:r;
    int limit=(dir%2==0)?w:h;
    for(int i=0;i<n;i++){
      if(s[i]==tak_move[dir]){
        if(dir==0||dir==3){
          pos++;
          if(pos>limit){
            return false;
          }
        }else{
          pos--;
          if(pos<=0){
            return false;
          }
        }
      }
      if(t[i]==aok_move[dir]){
        if(dir==0||dir==3){
          if(pos-1>=1){
            pos--;
          }
        }else{
          if(pos+1<=limit){
            pos++;
          }
        }
      }
    }
  }
  return true;
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);


  cin>>h>>w>>n;

  cin>>r>>c;

  cin>>s>>t;

  cout<<(IsYes()?"YES":"NO")<<endl;



  return 0;
}

Measured memory_bytes: 920
#include<stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a*b>=c*d){
        printf("%d\n",a*b);
    }else{
        printf("%d\n",c*d);
    }
    return 0;
}

Measured memory_bytes: 1728
//
// Created by yamunaku on 2020/05/03.
//

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    ll ans = 0;
    rep(i, n){
        ans += mp[i - a[i]];
        mp[i + a[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21092
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
  int n;
  char a,b;
  map<char,char> m;
  string s;
  while(cin>>n,n){
    m.clear();
    while(n--){
      cin>>a>>b;
      m[a]=b;
    }
    cin>>n;
    s="";
    while(n--){
      cin>>a;
      if(m.find(a)==m.end()) s+=a;
      else s+=m[a];
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}



int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n, k, cnt = 0;
    cin>>n>>k;

    while (n){
        cnt++;
        n = n/k;
    }
    cout<<cnt<<"\n";
    return 0;
    
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  for(int i = 0; i < A + B + 1; i++) {
    if((i == A && S[i] != '-') || (i != A && (S[i] - '0' < 0 || S[i] - '0' > 9))) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (n, k): (usize, usize) = readln();
    let mut c: HashMap<i64, usize> = HashMap::new();
    let a: Vec<i64> = readln();
    for &x in &a {
        *c.entry(x).or_insert(0) += 1;
    }
    let mut kv = c.into_iter().map(|(k, v)| v).collect::<Vec<_>>();
    kv.sort();
    kv.reverse();
    let ans: usize = n - kv.into_iter().take(k).sum::<usize>();
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 18064
#include<stdio.h>
#include<string.h>
int main(){
  char ARF[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char arf[27]="abcdefghijklmnopqrstuvwxyz";
  char s1[11],s2[1001];
  int i,j,sum=0;
  scanf("%s",s1);
  while(1){
    scanf("%s",s2);
    if(strcmp("END_OF_TEXT",s2)==0) break;
    int len=strlen(s2);
    for(i=0;i<len;i++){
      if(s2[i]<91){
	for(j=0;j<26;j++){
	  if(s2[i]==ARF[j]){
	    s2[i]=arf[j];
	  }
	}
      }
    }
    if(strcmp(s1,s2)==0){
      sum++;
    }
  }
  printf("%d\n",sum);
  return(0);
}

Measured memory_bytes: 976
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    string s;
    s = to_string(N);
    
    int ans = 0;
    for (int i=0; i<4; i++) {
        if(s[i]=='2') ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;
using G=vector<V>;

int main()
{
   ll a,b,c,d;cin >>a>>b>>c>>d;
   bool flg=true;
   int t=0;
   while(a>0&&c>0){
    t++;
    if(t%2==1)c-=b;
    else a-=d;
   }
   if(t%2!=0)flg=false;
   if(!flg)puts("Yes");
   else puts("No");
    return 0;
}


Measured memory_bytes: 3632
// In the name of God

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=(int)1e5+5;
int n, m;
pair<int,int> a[N];
priority_queue<int> pq[N];

void merge(priority_queue<int> &p1, priority_queue<int> &p2) {
	while(p2.size()) {
		int x = p2.top();
		p2.pop();
		p1.push(x);
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for(int i=0;i<n;i++) {
		cin >> a[i].first >> a[i].second;
		pq[a[i].first].push(a[i].second);
	}
	priority_queue<int> tmp;
	int ans = 0;
	for(int i=m-1;i>=0;i--) {
		merge(tmp, pq[m-i]);
		if(tmp.size()) {
			ans += tmp.top();
			tmp.pop();
		}
	}
	cout << ans;
	return 0;
}


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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
A = list(map(int, input().split()))

## Logic

ans = [0,0,0,0,0,0,0,0]
tmp = 0

for i in range(0,N):
    if A[i] >= 3200:
        tmp += 1
    else:
        ans[A[i]//400] = 1

print(max(1,sum(ans)),sum(ans)+tmp)



Measured memory_bytes: 63980
n, m = map(int, input().split())
s = [None] * m
c = [None] * m
for i in range(m):
  s[i], c[i] = map(int, input().split())
num = [0 for i in range(n)]
if n != 1:
  num[0] = 1
determined = [False for i in range(n)]
possible = True
for i in range(m):
  if n != 1 and s[i] == 1 and c[i] == 0:
    possible = False
    break
  if determined[s[i]-1] and num[s[i]-1] != c[i]:
    possible = False
    break
  num[s[i]-1] = c[i]
  determined[s[i]-1] = True

if not possible:
  print(-1)
else:
  for i in range(n):
    print(num[i], end="")
  print("")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	map<int, int> odd_mp, even_mp;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		
		if( i % 2 == 0 ) odd_mp[a]++;
		if( i % 2 == 1 ) even_mp[a]++;
	}
	
	vector< pair<int, int> > odd_x, even_x;
	
	int ans1 = 0;
	for(auto& s : odd_mp) {
		odd_x.push_back(make_pair(s.second, s.first));
		ans1 += s.second;
	}
	
	for(auto& s : even_mp) {
		even_x.push_back(make_pair(s.second, s.first));
		ans1 += s.second;
	}
	
	sort(odd_x.rbegin(), odd_x.rend());
	sort(even_x.rbegin(), even_x.rend());
	
	int ans2 = ans1;
	
	if( odd_x[0].second == even_x[0].second ) {
		ans1 -= (odd_x[1].first + even_x[0].first);
		ans2 -= (odd_x[0].first + even_x[1].first);
	} else {
		ans1 -= even_x[0].first + odd_x[0].first;
	}
	
	int ans = min(ans1, ans2);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6136
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
x=[0]*10
s=0
ans=0
for i in range(q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
for a0 in range(1,m+1):
  x[0]=a0
  for a1 in range(x[0],m+1):
    x[1]=a1
    for a2 in range(x[1],m+1):
      x[2]=a2
      for a3 in range(x[2],m+1):
        x[3]=a3
        for a4 in range(x[3],m+1):
          x[4]=a4
          for a5 in range(x[4],m+1):
            x[5]=a5
            for a6 in range(x[5],m+1):
              x[6]=a6
              for a7 in range(x[6],m+1):
                x[7]=a7
                for a8 in range(x[7],m+1):
                  x[8]=a8
                  for a9 in range(x[8],m+1):
                    x[9]=a9
                    for j in range(q):
                      if x[b[j]-1]-x[a[j]-1]==c[j]:
                        s=s+d[j]
                    ans=max(ans,s)
                    s=0
print(ans)

Measured memory_bytes: 9256
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int d;
    cin >> d;
    int c[27];
    for(int i = 1; i <= 26; i++) cin >> c[i];
    int s[d+1][27];
    for(int i = 1; i <= d; i++){
        for(int j = 1; j <= 26; j++){
            cin >> s[i][j];
        }
    }
    set<int> h[27];
    for(int i = 1; i <= 26; i++) h[i].insert(0), h[i].insert(d+1);
    int t[d+1];
    int last[27] = {};
    ll now = 0;
    for(int i = 1; i <= d; i++){
        cin >> t[i];
        h[t[i]].insert(i);
        now += s[i][t[i]];
        last[t[i]] = i;
        ll dec = 0;
        for(int j = 1; j <= 26; j++)    dec += c[j]*(i-last[j]);
        now -= dec;
    }
    
    int m;
    cin >> m;
    while(m--){
        int d, q;
        cin >> d >> q;
        int bef = t[d];
        now -= s[d][bef];
        h[bef].erase(d);
        {
            int from = *(--h[bef].lower_bound(d));
            int to = *(h[bef].lower_bound(d));
            now -= (ll)c[bef]*(to-d)*(d-from);
        }
        t[d] = q;
        now += s[d][q];
        h[q].insert(d);
        {
            int from = *(--h[q].lower_bound(d));
            int to = *(h[q].upper_bound(d));
            now += (ll)c[q]*(to-d)*(d-from);
        }
        cout << now << endl;
    }
    return 0;
}

Measured memory_bytes: 3688
import numpy as np
 
c = np.array([list(map(int, input().split())) for i in range(3)])
 
flag = True
for a1 in range(c.max()+1):
  b1, b2, b3 = c[0, :] - a1
  if (c[1, 0] - b1 != c[1, 1] - b2) or (c[1, 2] - b3 != c[1, 0] - b1):
    flag = False
    break
    
  if (c[2, 0] - b1 != c[2, 1] - b2) or (c[2, 2] - b3 != c[2, 0] - b1):
    flag = False
    break

print("Yes" if flag else "No")

Measured memory_bytes: 14524
loop do
h,w=gets.split.map &:to_i
break if h==0 && w==0
n=1
h.times do
    if n%2==0
    puts ".#"*(w/2) if w%2==0
    puts ".#"*(w/2)+"." if w%2==1
    else
    puts "#."*(w/2) if w%2==0
    puts "#."*(w/2)+"#" if w%2==1     
    end
    n+=1
end
puts
end


Measured memory_bytes: 8892
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b,c;
	cin >> a >> b >>c;
	if (a == b) {
		cout << c << endl;
	} else if (b == c) {
		cout << a << endl;
	} else {
		cout << b << endl;
	}
	return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 2e5 + 5;

int F[N], I[N];

int P(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;

}
int C(int n, int r) { return r > n ? 0 : 1LL * I[r] * I[n - r] % MOD * F[n] % MOD; }

int main() {

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

	F[0] = 1;
	for (int i = 1; i < N; i++) F[i] = 1LL * F[i - 1] * i % MOD;
	I[N - 1] = P(F[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--) I[i] = 1LL * I[i + 1] * (i + 1) % MOD;

	int n, m, k; cin >> n >> m >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++) ans = (ans + 1LL * i * (n - i) % MOD * m % MOD * m % MOD) % MOD;
	for (int i = 1; i <= m; i++) ans = (ans + 1LL * i * (m - i) % MOD * n % MOD * n % MOD) % MOD;
	cout << 1LL * ans * C(n * m - 2, k - 2) % MOD << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>

int ans;

int getNum( char ch )
{
	switch( ch )
	{
		case 'I':
			return 1;
		case 'V':
			return 5;
		case 'X':
			return 10;
		case 'L':
			return 50;
		case 'C':
			return 100;
		case 'D':
			return 500;
		case 'M':
			return 1000;
	}
}

int main()
{
	std::string str;
	while( std::cin >> str )
	{
		ans = 0;

		for( int i = 0; i < str.size(); i++ )
		{
			if( i == str.size() - 1 )
			{
				ans += getNum( str[i] );
				break;
			}

			int a = getNum( str[i] ), b = getNum( str[i+1] );
		
			if( a < b )
				ans -= a;
			else
				ans += a;
		}

		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1180
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        ans += ((i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main(){
  int x, y, s;
  while(cin >> x >> y >> s) {
    if(x == 0 && y == 0 && s == 0) break;
    int maxi = 0;
    for(int a = 1; a < s; a++) {
      for(int b = 1; b < s; b++) {
	if(int(a * (100 + x) / 100) + int(b * (100 + x) / 100) == s){
	  maxi = max(maxi, int(a * (100 + y) / 100) + int(b * (100 + y) / 100));
	}
      }
    }
    cout << maxi << endl;
  }
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;

    vector<vector<bool>> graph(N, vector<bool>(N, false));
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    vector<vector<ll>> dp(1 << N, vector<ll>(N, 0));
    dp[1][0] = 1;
    rep(s, 1 << N) {
        rep(u, N) {
            if ((s & (1 << u)) == 0) continue;
            rep(v, N) {
                if ((s & (1 << v)) == 0 && graph[u][v]) dp[s | (1 << v)][v] += dp[s][u];
            }
        }
    }
    ll ans = 0;
    rep2(i, 1, N) {
        ans += dp[(1 << N) - 1][i];
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
function main(standardInput) {
    let lenghtList = standardInput.split(' ');
    let varticalLength = parseInt(lenghtList[0]);
    let horizonLength = parseInt(lenghtList[1]);

    console.log(varticalLength * horizonLength + ' ' + 2 * (varticalLength + horizonLength));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 15128
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
 cin>>n>>k;
  
  vector<int>a(n);
  for(int i=0;i<n;i++){
   cin>>a[i];
  }
  sort(a.begin(),a.end());
  int sum=0;
  for(int i=0;i<k;i++){
   sum+=a[i];
 
  }
   
cout<<sum;
}


Measured memory_bytes: 3612
<?php
  $tmp = explode(" ",trim(fgets(STDIN)));

  $x = $tmp[0];
  $n = $tmp[1];

  $tmpData = explode(" ",trim(fgets(STDIN)));
  $data = [];
  foreach($tmpData as $val){
    $data[$val] = $val;
  }

  for($i=0; $i<=100; $i++){
    $val1 = $x-$i;
    $val2 = $x+$i;
    
    if(!isset($data[$val1])){
      echo $val1."\n";
      break;
    }else if(!isset($data[$val2])){
      echo $val2."\n";
      break;
    }
  }

Measured memory_bytes: 16152
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Set<String> a = new HashSet<>();
        for(int i = 0 ; i < n ; i++){
            a.add(scanner.next());
        }

        System.out.println(a.size() == n ? "YES" : "NO");
    }

}

Measured memory_bytes: 79680
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  char C;
  cin >> C;
  if(C == 'a'){
    cout << "vowel";
    return 0;
  }
  if(C == 'i'){
    cout << "vowel";
    return 0;
  }
  if(C == 'u'){
    cout << "vowel";
    return 0;
  }
  if(C == 'e'){
    cout << "vowel";
    return 0;
  }
  if(C == 'o'){
    cout << "vowel";
    return 0;
  }
  else{
    cout << "consonant";
  }
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
	int ret = 1; while (b > 0) {
		if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1;
	} return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
typedef vector<int> Vec;
typedef vector<Vec> Mat;
Vec mulMatVec(Mat a, Vec b)
{
	int n = b.size(); Vec ret(n, 0);
	rep(i, 0, n) rep(j, 0, n) ret[i] = add(ret[i], mul(a[i][j], b[j]));
	return ret;
}
Mat mulMatMat(Mat a, Mat b)
{
	int n = a.size(); Mat ret(n, Vec(n, 0));
	rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
	return ret;
}
Mat fastpow(Mat x, ll n)
{
	Mat ret(x.size(), Vec(x.size(), 0));
	rep(i, 0, x.size()) ret[i][i] = 1;
	while (0 < n) { if ((n % 2) == 0) { x = mulMatMat(x, x); n >>= 1; } else { ret = mulMatMat(ret, x); --n; } }
	return ret;
}
void printVec(Vec a) { cout << "[\t"; rep(i, 0, a.size()) cout << a[i] << "\t"; cout << "]" << endl; }
void printMat(Mat a) { rep(i, 0, a.size()) printVec(a[i]); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void solve() {
	cin >> N;

	if (N <= 4) {
		printf("0\n");
		return;
	}

	Mat m(16 * 2, Vec(16 * 2));

	rep(group, 0, 16) rep(p, 0, 2) {
		m[group * 2 + 1 - p][group * 2 + p] += 1;
		if (group < 5 && p == 1) continue;
		rep(dest, group + 1, 16) m[dest * 2 + 1][group * 2 + p] += 1;
	}

	Vec v(16 * 2);
	v[0] = 1;

	m = fastpow(m, N - 4);
	v = mulMatVec(m, v);

	int ans = add(v[15 * 2], v[15 * 2 + 1]);
	printf("%d\n", ans);
}
//---------------------------------------------------------------------------------------------------
void _main() {
	int T; cin >> T;
	rep(t, 0, T) solve();
}







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

using namespace std;

void Solve(){
    int k;
    cin>>k;
    if(k < 10){
        cout<<k<<endl;
        return;
    }
    queue<long long> q;
    int res = 9;
    for(long long i = 1; i < 10; i++)
        q.push(i);
    while(true){
        long long current = q.front();
        q.pop();
        long long a = current * 10 + current % 10 - 1;
        long long b = current * 10 + current % 10;
        long long c = current * 10 + current % 10 + 1;
        if(current % 10 > 0){
            res++;
            q.push(a);
            if(res == k){
                cout<<a<<'\n';
                return;
            }
        }
        res++;
        if(res == k){
            cout<<b<<'\n';
            return;
        }
        q.push(b);
        if(current % 10 < 9){
            res++;
            q.push(c);
            if(res == k){
                cout<<c<<'\n';
                return;
            }
        }
    }

}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    while(q--){
        Solve();
    }
}

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

using ll = long long;

int main() {
    string s;
    int k;
    cin >> s >> k;
    const int n = s.size();
    vector<string> v;
    for(int i = 0; i < n; ++i) {
        string t;
        for(int j = 0; j <= 5 && i + j < n; ++j) {
            t += s[i + j];
            v.push_back(t);
        }
    }
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));

    cout << v[k - 1] << endl;
}


Measured memory_bytes: 1916
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
ll n, m;
    cin>>n>>m;
    vector<ll> a(n);
    vector<int> id(n);
    vector<pair<ll, ll>> cb;
    ll sum=0;
    fori(n) {
        cin>>a[i];
        sum+=a[i];
        id[i]=i;
    }

    fori(m) {
        ll b, c;
        cin>>b>>c;
        cb.push_back({ c, b });
    }

    sort(cb.begin(), cb.end());
    sort(id.begin(), id.end(), [&](int i1, int i2) {
        return a[i1]<a[i2];
    });

    int nextCb=m-1;
    int nextA=0;
    while(nextCb>=0 && nextA<n) {
        int d= cb[nextCb].first - a[id[nextA]];
        if(d>0) {
            sum+=d;
            nextA++;
            cb[nextCb].second--;
            if(cb[nextCb].second==0)
                nextCb--;
        } else 
            break;
    }
    
    cout<<sum<<endl;

}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define VIEW(dat) for(auto v : dat){cout<<v<<endl;}

int main(){
	int n,a;
	cin>>n;
	vector<int> dat;
	rep(i,n){
		cin>>a;
		dat.push_back(a);
	}
	
	
	for(int k=0;k<dat.size()-1;k++){
		cout<<dat[k]<<" ";
	}
	cout<<dat[dat.size()-1]<<endl;
	
	for(int j=1;j<dat.size();j++){
		auto key = dat[j];
		auto i =j-1;
		while(i>=0&&dat[i]>key){
			dat[i+1]=dat[i];
			i--;
		}
		dat[i+1]=key;
		
		
		for(int k=0;k<dat.size()-1;k++){
			cout<<dat[k]<<" ";
		}
		cout<<dat[dat.size()-1]<<endl;
	}
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, Y; cin >> N >> Y;
    int fukuzawa = -1, ichiyoh = -1, hideyo = -1;
    for(int yukichi = 0; yukichi <= N; yukichi++) for(int higuchi = 0; higuchi <= N - yukichi; higuchi++) {
        int noguchi = N - yukichi - higuchi;
        int otoshidama = 10000 * yukichi + 5000 * higuchi + 1000 * noguchi;
        if(otoshidama == Y) {
            fukuzawa = yukichi; ichiyoh = higuchi; hideyo = noguchi;
            break;
        }
    }
    cout << fukuzawa << ' ' << ichiyoh << ' ' << hideyo << endl;
    return 0;
}


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

int main()
{
	long long n; cin >> n;

	vector<long long> a(n); for (int i = 0; i < n; i++) cin >> a[i];

	long long ans = 0;

	for (int i = 0; i < n - 1; i++) {

		for (int j = i + 1; j < n; j++) {

			ans = max(ans, abs(a[i] - a[j]));

		}

	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
int n;
int dp[maxn];

int main() {
	cin >> n;
	dp[0] = 0;
	for(int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] + 1;
		for(int j = 9; j <= i; j *= 9) dp[i] = min(dp[i], dp[i - j] + 1);
		for(int j = 6; j <= i; j *= 6) dp[i] = min(dp[i], dp[i - j] + 1);
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int a,b,s;
    cin>>a>>b;
    s=a+b;
    if(s%2==0){
        s=s/2;
        cout<<s;
    }else
    {
        s=s/2;
        s++;
        cout<<s;
    }

    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main()
{
	int n, m, a[10000], b[10000], r, i, j;
	while (cin >> n >> m)
	{
		if (!n && !m) break;
		bool f[10000] = {false};
		for (i = 0; i < m; i++)
			cin >> a[i] >> b[i];
		for (i = r = 0; i < m; i++)
			if (a[i] == 1)
			{
				f[b[i]-1] = true;
				for (j = 0; j < m; j++)
				{
					if (b[i] == a[j]) f[b[j]-1] = true;
					if (b[i] == b[j]) f[a[j]-1] = true;
				}
			}
		for (i = 1; i < n; i++)
			if (f[i]) r++;
		cout << r << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a; i<=(b); ++i)
#define Fod(i,a,b) for(int i=a; i>=(b); --i)
#define Rep(i,n) for(int i=0; i<n; ++i)
#define fi first
#define se second
#define sz(x) (int) x.size()
using namespace std;
 
int test, n;
const int maxn = 2e5 + 5;
int a[maxn];
 
int main()
{
    //#define NTMA
    #ifdef NTMA
        freopen("input.inp", "r", stdin);
        freopen("output.out", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int ans = 0, ok = 0; string s[maxn], x;
    cin >> n;
    For(i, 1, n) cin >> s[i] >> a[i];
    cin >> x;
    For(i, 1, n) if (s[i] == x) ok = 1;
    else ans += ok*a[i];
    cout << ans;  
 
}

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

int main(){
	
	int n,m;
	scanf("%d %d",&n,&m);
	
	int first=m-n+1;
	int last=m+n-1;
	
	for(int i=first;i<=last;i++){
		printf("%d",i);
		if(i!=last){
			printf(" ");
		}
	}
	
	
	return 0;	
}







/*
-1000000,-999999,-999998,[?],999999?1000000?

*/



Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU

solve :: VU.Vector Int
solve = VU.constructN (10^5+100) $ branch
    where
        branch vec
            | VU.length vec == 0 = 0
            | otherwise = value vec

        value vec = (minimum $ as ++ bs) + 1
            where
                l = VU.length vec
                six = filter (<=l) $! map (6^) [0..6]
                nine = filter (<=l) $! map (9^) [0..5]
                as = map (\i -> vec VU.! (l - i)) six
                bs  = map (\j -> vec VU.! (l - j)) nine

main = do
    n <- readLn :: IO Int
    print $ solve VU.! n

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

n = 0
for fiveHundred in range(a+1):
    for hundred in range(b+1):
        for fifty in range(c+1):
            if x == 500*fiveHundred + 100*hundred + 50*fifty:
                n +=1

print(n)

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

int main(){
    int n, q, ans = 0, s[10000], t;

    cin >> n;
    for(int i=0; i<n; ++i) cin >> s[i];
    cin >> q;
    while(q--){
        cin >> t;
        for(int i=0; i<n; ++i){
            if(s[i] == t){
                ++ans;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int p[30];
int main()
{
    int n;
    int ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<n-1;i++)
    {
        if((p[i-1]>p[i]&&p[i+1]<p[i])||(p[i-1]<p[i]&&p[i+1]>p[i]))
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int getsum(int x) {
	int rv = 0;
	while (x) {
		rv += x % 10;
		x /= 10;
	}
	return rv;
}
int main() {
	int N, i;

	int mn = INF;
	scanf("%d", &N);
	for (i = 1; i < N; i++) mn = min(mn, getsum(i) + getsum(N - i));
	return !printf("%d\n", mn);
}

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  long A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A * B > C * D)
    cout << A * B << endl;
  else
    cout << C * D << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[111];
int ans=1e9,ans2=0;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x[i];
	for(int i=1;i<=100;i++)
	{
		ans2=0;
		for(int c=0;c<n;c++)
		{
			int y=abs(x[c]-i);
			y=y*y;
			ans2+=y;
		}
		ans=min(ans,ans2);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005



int32_t main(){
sp;
    int n;
    cin>>n;
    int a[n],b[n];
    memset(b,0,sizeof b);
    b[0]=1;
    for(int i=0; i<n; ++i)
        cin>>a[i];
    for(int i=1; i<n; ++i)
        if(a[i]<=a[i-1])
            b[i]=1+b[i-1];
        else
            b[i]=1;
    int ans=0;
    for(auto &it:b)
        ans=max(ans,it);
    cout<<ans-1;
    return 0;
}


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

namespace ABC151C {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var waCounts = new int[input[0]];
            var acFlags = new bool[input[0]];
            var wa = 0;
            var ac = 0;
            
            for (var i = 0; i < input[1]; i++) {
                var l = Console.ReadLine().Split(' ');
                var qId = int.Parse(l[0]) - 1;
                if (acFlags[qId]) continue;
                if (l[1] == "AC") {
                    acFlags[qId] = true;
                    ac++;
                    wa += waCounts[qId];
                } else {
                    waCounts[qId]++;
                }
            }

            Console.WriteLine($"{ac} {wa}");
        }
    }
}

Measured memory_bytes: 17484