akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
ll inf=1e10+1;
int main(){
	int n ,m;
	cin >> n >> m;
	ll checkpointsx[m],studentsx[n],checkpointsy[m],studentsy[n];
	int i=0,j=0;
	while(i < n){
		cin >> studentsx[i] >> studentsy[i];
		i++;
	}
	FOR(j,m){
		cin >> checkpointsx[j] >> checkpointsy[j];
	}	
	ll ans[i];
	ll index=0;
	FOR(i,n){
		ans[i]=inf;
		index=0;
		FOR(j,m)
			if(abs(studentsx[i]-checkpointsx[j])+abs(studentsy[i]-checkpointsy[j]) < ans[i]){
				ans[i]=abs(studentsx[i]-checkpointsx[j])+abs(studentsy[i]-checkpointsy[j]);
				index=j;
			}
			cout << index +1<< "\n";
	}

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,d1,x;
    cin>>N>>d1>>x;

    double A=1;
    for(int i=2;i<=N;i++){
        A=1+1.0*(i+1)/i*A;
    }

    printf("%.20f\n",A*(d1+0.5*x*(2*N-1)));
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

mapping = {}
for s, t in zip(S, T):
    if s not in mapping and t not in mapping.values():
        mapping[s] = t
    elif s not in mapping and t in mapping.values():
        print('No')
        break
    elif mapping[s] != t:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3632
def main():
    N, K = map(int, input().split())
    lst_a = list(map(int, input().split()))
    # 石の個数が残りi個の局面で勝ちTrue 負け False　
    dp = [False] * (K+1)
    for i in range(1, K+1):
        for j in range(N):
            if i - lst_a[j] >= 0:
                dp[i] |= not(dp[i - lst_a[j]])
    
    if dp[K]:
        print('First')
    else:
        print('Second')
main()

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  static constexpr unsigned mod = M;
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<(int)1e9 + 7>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  mint res;
  for (int i = k; i <= n + 1; ++i) {
    res += mint(i) * (n - i + 1 + n) / 2 - mint(i) * (i - 1) / 2 + 1;
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll x,ans=0;
    cin>>x;
    map<string,ll>m;
    for (int i=1;i<=x;i++){
        string s=to_string(i);
        string t="";
        t+=s[0];
        t+=s.back();
        m[t]++;
    }
    for (auto j:m){
        string t=j.first;
        if (t[0]==t[1]){
            ans=ans+j.second*j.second;
        }
        else{
            string p="";
            p+=t[1];
            p+=t[0];
            ans=ans+j.second*m[p];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
M = list(map(int,input().split()))
b = 0
max = 0
for i, v in enumerate(M):
    if i >= a-1:
        break
    if M[i] >= M[i+1]:
        b += 1
        if max < b:
            max = b
    else:
        b = 0

print(max)

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

const int64_t mod = 1'000'000'007;

int main(){
    int n, m;
    unordered_set<int> a;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a_;
        cin >> a_;
        a.insert(a_);
    }

    static int64_t dp[100002];
    dp[0] = 1;
    for(int i=1;i<=n;i++) dp[i] = 0;
    for(int i=0;i<n;i++){
        if(a.count(i+1)==0) dp[i+1] = (dp[i+1] + dp[i]) % mod;
        if(a.count(i+2)==0) dp[i+2] = (dp[i+2] + dp[i]) % mod;
    }

    cout << dp[n] << endl;
    
    return 0;
}

Measured memory_bytes: 5156
import scala.io.StdIn._
object Main extends App {
  val x = readInt

  def check(min: Int, max: Int): Int = {
    val newMin = min + 100
    val newMax = max + 105
    if (newMin > x) 0
    else if (newMin <= x && x <= newMax) 1
    else check(newMin, newMax)
  }

  println(check(0, 0))
}

Measured memory_bytes: 25524
fn get_min(cur: Option<u64>, next: u64) -> u64 {
    match cur {
        Some(x) => min(x, next),
        None => next
    }
}
fn main() {
    let (n, ma, mb): (usize, usize, usize) = readln();
    let mut a = Vec::new();
    let mut b = Vec::new();
    let mut c = Vec::new();
    for _ in 0..n {
        let (x, y, z): (usize, usize, u64) = readln();
        a.push(x);
        b.push(y);
        c.push(z);
    }
    const MAX: usize = 404;
    let mut dp = [[None; MAX]; MAX];
    dp[0][0] = Some(0 as u64);
    for k in 0..n {
        let x = a[k];
        let y = b[k];
        let z = c[k];
        let mut next = [[None; MAX]; MAX];
        for i in 0..MAX {
            for j in 0..MAX {
                if let Some(val) = dp[i][j] {
                    next[i][j] = Some(get_min(next[i][j], val));
                    let ni = i + x;
                    let nj = j + y;
                    let nval = val + z;
                    next[ni][nj] = Some(get_min(next[ni][nj], nval));
                }
            }
        }
        dp = next;
    }
    let mut answer: u64 = u64::max_value();
    for i in 0..MAX {
        for j in 0..MAX {
            if i * mb == j * ma && i != 0 && j != 0 {
                if let Some(val) = dp[i][j] {
                    answer = min(answer, val);
                }
            }
        }
    }
    if answer == u64::max_value() {
        println!("-1");
    } else {
        println!("{}", answer);
    }
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::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: 9468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

    int a = -1;
    int ans = 0;

    rep(i, N)
    {
        if (a != S[i])
        {
            ans++;
            a = S[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e9+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
//it gives the lexicographically smallest string//


void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 ll n,ans=0;
 cin>>n;
 ll arr[n];
 for(int i=0;i<n;i++) cin>>arr[i];
for(int i=0;i<n;i++)
  for(int j=i+1;j<n;j++)
    for(int k=j+1;k<n;k++)
    {
      ll brr[]={arr[i],arr[j],arr[k]};
      sort(brr,brr+3);
      if(brr[0]+brr[1]>brr[2] && brr[0]!=brr[1] && brr[1]!=brr[2] && brr[0]!=brr[2]) ans++;
    }
    cout<<ans;
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
  solve();
  return 0;
}

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

typedef pair<int,int> P;

int main(){
    string s;
    cin >> s;
    bool a = false,b = false;
    for (int i = 0; i < s.size(); i++){
        if (s.at(i) == 'A') a = true;
        if (s.at(i) == 'B') b = true;
    }
    if (a && b){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
/*
  Date: 9/19/2020 20:04:18
  Description:
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e3;
char s[N];

int main() {
	scanf("%s", s);
	printf("%s", s);
	s[strlen(s)-1] == 's' ? printf("es") : putchar('s');
	return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	int ans = 100, anstmp;
	int N, x[nmax_def], y[nmax_def], distx[nmax_def][nmax_def], disty[nmax_def][nmax_def];
	cin >> N;
	for (i = 0; i < N; i++)
		cin >> x[i] >> y[i];
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < N; j++)
		{
			if (i != j)
			{
				distx[i][j] = x[i] - x[j];
				disty[i][j] = y[i] - y[j];
			}
		}
	}
	if (N == 1)
		ans = 1;
	else
	{
		for (int p = 0; p < N; p++)
		{
			for (int q = 0; q < N; q++)
			{

				if (p != q)
				{
					anstmp = N;
					int distX = distx[p][q];
					int distY = disty[p][q];
					for (i = 0; i < N; i++)
					{
						for (j = 0; j < N; j++)
						{
							if (i != j)
							{
								if (distX == distx[i][j] && distY == disty[i][j])
									anstmp--;
							}
						}
					}
					ans = min(ans, anstmp);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
    string s;
    long t = 0, sum = 0;
    cin >> s;
    char c[s.size()];
    for (int i = 0; i < s.size(); ++i)
    {
        c[i] = s.at(i);
        t = stol(&c[i]);
        sum += t;
    }
    long N = stol(s);
    puts((N) % sum == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
struct dice {
  int label[7];
};
 
struct dice *make_dice(int *num) {
  int i;
  struct dice *dice1;
  dice1 = (struct dice *)malloc(sizeof(struct dice));
  for(i = 1;i <= 6;i++) {
    dice1->label[i] = num[i];
  }
  return dice1;
}
 
void turnS(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[5];
  a->label[5] = a->label[6];
  a->label[6] = a->label[2];
  a->label[2] = temp;
}
 
void turnW(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[3];
  a->label[3] = a->label[6];
  a->label[6] = a->label[4];
  a->label[4] = temp;
}
 
void turnN(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[2];
  a->label[2] = a->label[6];
  a->label[6] = a->label[5];
  a->label[5] = temp;
}
 
void turnE(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[4];
  a->label[4] = a->label[6];
  a->label[6] = a->label[3];
  a->label[3] = temp;
}
 
void spin(struct dice *a) {
  turnS(a);
  turnE(a);
  turnN(a);
}
 
int cmp_dice(struct dice *a, struct dice *b) {
  int i;
  for(i = 1;i <= 6;i++) {
    if(a->label[i] != b->label[i]) return 1;
  }
  return 0;
}
 
int cmp_dice2(struct dice *dice1, struct dice *dice2) {
  int i,j;
   
  for(i = 0;i < 4;i++) {
    for(j = 0;j < 4;j++) {
      if(cmp_dice(dice1, dice2) == 0) break;
      spin(dice1);
    }
    if(cmp_dice(dice1, dice2) == 0) break;
    turnW(dice1);
  }
  for(i = 0;i < 4;i++) {
    for(j = 0;j < 4;j++) {
      if(cmp_dice(dice1, dice2) == 0) break;
      spin(dice1);
    }
    if(cmp_dice(dice1, dice2) == 0) break;
    turnS(dice1);
  }
  if(cmp_dice(dice1, dice2) == 0) {
    return 0;
  }else{
    return 1;
  }
}
 
int main() {
  int i,j,n,t,num[7];
  struct dice **dice;
 
  scanf("%d", &n);
  dice = (struct dice **)malloc(sizeof(struct dice *)*n);
  for(i = 0;i < n;i++) {
    for(j = 1;j <= 6;j++) {
      scanf("%d", num+j);
    }
    dice[i] = make_dice(num);
  }
  t = 0;
  for(i = 0;i < n-1;i++) {
    for(j = i+1; j < n;j++) {
      t += 1 - cmp_dice2(dice[i], dice[j]);
    }
  }
 
  if(t == 0) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2096
def main():
    from fractions import gcd
    from collections import Counter
    a,b=map(int,input().split())
    c=len(Counter(soinsuu(gcd(a,b))))+1
    print(c)
    
def soinsuu(a):
    yy,j=[],2
    y=yy.append
    while(a>1):
        for i in range(j,int(a**0.5)+1):
            if a%i==0:
                y(i)
                a,j=a//i,i
                break
        else:
            y(a)
            break
    yy.sort()
    return yy
    
if __name__ == '__main__':
	main()

Measured memory_bytes: 65260
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() 
{
  int n,a,b,ans = 0;
  cin >> n >> a >> b;
  for(int i = 1; i <= n; i++)
  {
    int sum = 0;
    int x = i/10;
    int y = x/10;
    int z = y/10;
    if(i%10 != 0) sum += i%10;
    if(x%10 != 0) sum += x%10;
    if(y%10 != 0) sum += y%10;
    if(z%10 != 0) sum += z%10;
    if(z/10 != 0) sum += z/10;

    if(a <= sum && sum <= b) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main() {
  int H, i;
  scanf("%d", &H);
  int A[H];
  for(i = 0; i < H; i++) {
    scanf("%d", &A[i]);
  }
  for(i = 0; i < H; i++) {
    printf("node %d: key = %d, ", i+1, A[i]);
    if(i != 0) {
      if(i%2 == 0) printf("parent key = %d, ", A[(i-1)/2]);
      else printf("parent key = %d, ", A[i/2]);
    }
    if(i*2+1 < H) printf("left key = %d, ", A[i*2+1]);
    if(i*2+2 < H) printf("right key = %d, ", A[i*2+2]);
    printf("\n");
  }
  return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    int l = 0, h = (int) s.size() - 1;
    int ct = 0;
    while (l <= h) {
        if (s[l] == s[h])l++, h--;
        else if (s[l] != s[h]) {
            if (s[l] != 'x' and s[h] != 'x') {
                cout << "-1";
                return;
            }
            if (s[l] == 'x')l++;
            else h--;
            ct++;
        }
    }
    cout << ct << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 512
import itertools
from collections import defaultdict

n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))
    
dd = defaultdict(int)
for lst in itertools.combinations(xy, 2):
    dx = lst[0][0] - lst[1][0]
    dy = lst[0][1] - lst[1][1]
    dd[(dx, dy)] += 1
    dd[(-dx, -dy)] += 1
ans = 0
for i, j in dd.items():
    ans = max(ans, j)
print(n - ans)

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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    string taro, hanako;

    int ptTaro = 0;
    int ptHanako = 0;
    REP(i, n) {
        cin >> taro >> hanako;
        if (taro > hanako) ptTaro += 3;
        if (taro < hanako) ptHanako += 3;
        if (taro == hanako) {
            ptTaro++;
            ptHanako++;
        }
    }

    cout << ptTaro << " " << ptHanako << endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    string s;
    cin >> s;
    string t="AKIHABARA";
    ll c=0;
    bool f=true;
    for (ll i=0;i<s.size();i++){
        if (t[c]!=s[i]){
            if (t[c]=='A'){
                c++;
                i--;
                continue;
            }
            else{
                f=false;
            }
        }
        c++;
    }
    if (f and c>=t.size()-1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

const int mod = 1000000007;

int ll[100010], rr[100010];
long long dp[100010], ndp[100010], sum[100010];
int tot;

int main(){
	int n, k; scanf("%d%d", &n, &k);
	int pos = 1;
	while (pos != n + 1){
		int l = pos, r = n + 1;
		while (l < r){
			int mid = l + r + 1 >> 1;
			if (n / mid != n / pos) r = mid - 1;
			else l = mid;
		}
		ll[++tot] = pos, rr[tot] = l;
		pos = l + 1;
	}
	for (int i = 1; i <= tot; i++){
		dp[i] = 1;
	}
	for (int i = 1; i < k; i++){
		for (int j = 1; j <= tot; j++){
			sum[j] = (sum[j - 1] + dp[j] * (rr[j] - ll[j] + 1)) % mod;
		}
		for (int j = tot; j >= 1; j--){
			int pos = lower_bound(rr + 1, rr + tot + 1, n / ll[j]) - rr;
			ndp[j] = (sum[pos - 1] + dp[pos] * (n / ll[j] - ll[pos] + 1)) % mod;
		}
		swap(ndp, dp);
	}
	long long ans = 0;
	for (int i = 1; i <= tot; i++){
		ans = (ans + dp[i] * (rr[i] - ll[i] + 1)) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
int N;
set<int> kaburi;
  cin >> N;
vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
    kaburi.insert(vec[i]);  
  }
  if(kaburi.size() == N){
  	cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1);
}
template<typename T> T combination(T n, T k){
    vector<vector<T>> v(n+1, vector<T>(n+1, 0)); //dpテーブル
    REP(i, v.size()){
        v[i][0] = 1; v[i][i] = 1;
    }
    for(int j=1; j<v.size(); j++){
        for(int k=1; k<j; k++){
            v[j][k] = v[j-1][k-1] + v[j-1][k];
        }
    }
    return v[n][k];
}
struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll d = c - a - b;
    if(d <= 0){
        cout << "No" << endl;
    }else{
        if(4*a*b < d*d){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
b_list = list(map(int,input().split()))

a_list = [0 for i in range(n)]

for i,b in enumerate(b_list):
    if i == 0:
        a_list[i] = b
        a_list[i+1] = b
    else:
        a_list[i] = min(a_list[i],b)
        a_list[i+1] = b

print(sum(a_list))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int r = sc.nextInt();
		
		double h = Math.sin(Math.toRadians(r))*b;
		double S = a*h/2.0;
		
		double l1 = Math.cos(Math.toRadians(r))*b;
		double l2 = a-l1;
		double c = Math.sqrt(l2*l2+h*h);
		
		System.out.println(String.format("%.5f", S));
		System.out.println(String.format("%.5f", a+b+c));
		System.out.println(String.format("%.5f", h));
	}
}



Measured memory_bytes: 26372
n = int(input())
s = input()
alphabets = 'abcdefghijklmnopqrstuvwxyz'
scores = []
for i in range(n):
    count = 0
    for alphabet in alphabets:
        if alphabet in s[:i] and alphabet in s[i:]:
            count += 1
    scores.append(count)
print(max(scores))


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int n;
	int card[200][3];
	int count[3][101] = {0};
	int score;
	int i, j;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		for (j = 0; j < 3; j++){
			scanf("%d", &card[i][j]);
			count[j][card[i][j]]++;
		}
	}
	
	for (i = 0; i < n; i++){
		score = 0;
		
		for (j = 0; j < 3; j++){
			if (count[j][card[i][j]] == 1){
				score += card[i][j];
			}
		}
		
		printf("%d\n", score);
	}
	
	return (0);
}

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

#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;

int N;
int W;

vi w;
vi v;

ll dp[100][1000000];

ll solve(int idx, int weight){

    if(weight > W) return -1e12;

    if(idx == N) return 0;

    ll &d = dp[idx][weight];
    if(d != -1) return d;

    return d = max(solve(idx+1, weight), solve(idx+1, weight+w[idx]) + v[idx]);

}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;
    cin >> W;

    w.resize(N);
    v.resize(N);

    for(int i=0; i < N; i++){
        cin >> w[i] >> v[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;


    return 0;
}

Measured memory_bytes: 781692
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)

void solve()
{
    ll n,d;
    cin>>n>>d;
    ll x[n],y[n];
    ll ans=0;
    map<pair<ll,ll>,ll>m;
    rep(i,n){
        cin>>x[i]>>y[i];
        // if(m[mp(x[i],y[i])])
        // {
        //     continue;
        // }
        ll dis=(x[i]*x[i])+(y[i]*y[i]);
        ld y1=(sqrt(dis));
        // cout<<i<<" "<<y1<<"\n";
        // ll di=dis;
        if(y1<=(ld)d)ans++;
        m[mp(x[i],y[i])]++;

    }
    cout<<ans<<"\n";
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 19268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;

int N,K,Q;
int ct[MAX];
void input(){
	cin>>N>>K>>Q;
	rep(_,Q){
		int a;
		cin>>a;
		a--;
		ct[a]++;
	}
}

void solve(){
	rep(i,N){
		int po=K-(Q-ct[i]);
		if(po<=0) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 1024
import sys
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans += reduce(math.gcd, [i, j, k])
    print(ans)


main()


Measured memory_bytes: 69536
from collections import defaultdict, Counter
from fractions import Fraction
import math


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
if N == 1:
    print(0)
    exit()
result = Counter(prime_factorize(N))

count = 0
for key in result.keys():
    v = result[key]
    i = 1
    while(v >= i):
        v -= i
        count += 1
        i += 1
print(count)

Measured memory_bytes: 72844
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
res=sum(B)
for i in range(1, N):
  if A[i]==A[i-1]+1:
    res+=C[A[i-1]-1]
print(res)

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

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<P> ans;
    if (n % 2) {
        for (int l = 1, r = n - 1; l < r; l++, r--)
            ans.emplace_back(l, r);
    } else {
        bool flag = false;
        for (int l = 1, r = n - 1; l < r; l++, r--) {
            if (!flag && r - l <= n / 2) {
                --r;
                flag = true;
            }
            ans.emplace_back(l, r);
        }
    }
    rep(i, m)
        cout << ans[i].first << ' ' << ans[i].second << endl;
    return 0;
}

Measured memory_bytes: 4244
#include <iostream>
//#include "bits/stdc++.h"
#include <vector>
#include <stdlib.h>
#include <string>
#include <cctype>

using namespace std;

int main() {
	int a;
	int b;

	cin >> a >> b;

	cout <<  a * b << endl;
	return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

struct node{
    ll x,y,h;
    node(){}
    node(ll x,ll y,ll h) : x(x),y(y),h(h) {}
};
bool compare(node a,node b){
    return a.h>b.h;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    node a[n];
    for(ll i=0;i<n;i++){
        ll x,y,h;
        cin >> x >> y >> h;
        a[i] = node(x,y,h);
    }
    sort(a,a+n,compare);
    for(ll cx=0;cx<=100;cx++){
        for(ll cy=0;cy<=100;cy++){
            ll md = abs(a[0].x-cx)+abs(a[0].y-cy);
            ll possH = md+a[0].h;
            if(possH<1)
                continue;
            bool f = 1;
            for(ll i=1;i<n;i++){
                ll tempMD = abs(a[i].x-cx)+abs(a[i].y-cy);
                if(max(possH-tempMD,0LL)!=a[i].h){
                    f = 0;
                    break;
                }
            }
            for(int i=0;i<n;i++){
                ll ht = max(possH-abs(a[i].x-cx)-abs(a[i].y-cy),0LL);
                if(ht!=a[i].h){
                    f = 0;
                    break;
                }
            }
            if(f){
                cout << cx << " " << cy << " " << possH;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
ll n,k,h[310];
ll f[310][310];
int main(){
  cin>>n>>k;
  k=n-k;
  for(int i=0;i<310;i++)for(int j=0;j<310;j++)f[i][j]=1e17;
  f[0][0]=0,h[0]=0;
  for(int i=1;i<=n;i++){
      cin>>h[i];
      for(int j=0;j<=n;j++){
	  for(int r=0;r<i;r++){
	      if(j)chmin(f[i][j],f[r][j-1]+abs(h[i]-h[r]));
	  }
      }
  }
  ll ans=1e17;
  for(int i=0;i<=n;i++)for(int j=k;j<=n;j++){
      chmin(ans,f[i][j]+h[i]);
  }
  cout<<ans/2<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    vi v(6,0); rep(i,6)cin>>v[i];
    int ans=v[0]+v[1]*5+v[2]*10+v[3]*50+v[4]*100+v[5]*500;
    cout<< ((ans/1000)>=1 ? 1:0)<<endl;
}

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    long long ans = 1;
    for (int i=1; i<=n; i++){
        ans = (ans * i) % (1000000007);
    }
    cout << (ans) << "\n";

    return 0;
}


Measured memory_bytes: 3616
def count(sent):
    kind = list(set(sent))
    ki_cou = []
    for ki in kind:
        ki_cou.append(sent.count(ki))
    
    return kind[ki_cou.index(max(ki_cou))]


def length(sent):
    kind = list(set(sent))
    ki_len = []
    for ki in kind:
        ki_len.append(len(ki))
    return kind[ki_len.index(max(ki_len))]


sent = map(str, raw_input().split(' '))

print count(sent),length(sent)

Measured memory_bytes: 4236
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="AC") a++;
    if(s=="WA") b++;
    if(s=="TLE") c++;
    if(s=="RE") d++;
  }
  cout<<"AC"<<" "<<'x'<<" "<<a<<endl;
  cout<<"WA"<<" "<<'x'<<" "<<b<<endl;
  cout<<"TLE"<<" "<<'x'<<" "<<c<<endl;
  cout<<"RE"<<" "<<'x'<<" "<<d<<endl;
  return 0;
}


Measured memory_bytes: 3628
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int x = int.Parse(s[0]);
        int y = int.Parse(s[1]);

        Console.WriteLine(GCDivisor(x,y));
    }

    static int GCDivisor(int x, int y)
    {
        int n = Math.Min(x, y);
        int d = 0;
        for(d = n;d > 0; d--)
        {
            if (x % d == 0 && y % d == 0)
                break;
        }
        return d;
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        b.at(a.at(i) - 1) = i + 1;
    }
    for (int i = 0; i < n - 1; i++) {
        cout << b.at(i) << " ";
    }
    cout << b.at(n - 1) << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main(){
  int n,i,j,s[3],max;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d %d %d",&s[0],&s[1],&s[2]);
    max = s[0];
    for(j = 1;j<3;j++){
      if(max < s[j]){
	max = s[j];
      }
    }
    for(j = 0;j<3;j++){
      if(max == s[j]){
	s[j] = 0;
	break;
      }
    }
    if(max == sqrt(pow(s[0],2) + pow(s[1],2) + pow(s[2],2))){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return(0);
}
    

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int n, m, k, x, y;
string s;

int main(void)
{
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
        {
            cnt++;
        }
    }
    if (s[1] == 'S' && cnt == 2) cnt = 1;
    cout << cnt << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    string S;
    cin >> N >> S;

    vector<int> alp(26);
    REP(i, N) { alp[S[i] - 'a']++; }

    ll ans = 1;

    // そのアルファベットを使う数 + 使わない選択肢を掛ける
    REP(i, 26) {
        if (alp[i] > 0) {
            ans *= (alp[i] + 1);
            ans %= 1000000007;
        }
    }
    // 何も選ばない選択肢は存在しないから
    ans--;

    cout << ans << endl;

    return 0;
}

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

#define FOR(i,N) for(int i=0;i<N;i++)

int main(){
    long long N,K,X,D,X1,X2,ans=0,cnt=0;
    string S,T;
    cin >>S>>T;
    for(int i=0;i<S.size()-T.size()+1;i++){
        cnt=0;
        for(int j=i;j<i+T.size();j++){
            if(S[j]==T[j-i]){
                cnt++;
            }
        }
        if(ans<cnt){
            ans=cnt;
        }
    }
    cout << T.size()-ans;
}	

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>a-b)
    {
        if(a+b>a*b)
        cout<<a+b;
        else
        cout<<a*b;
        
    }
    else
    {
        if(a-b>a*b)
        cout<<a-b;
        else
        cout<<a*b;
        
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int H,W;
    cin >> H >> W;
    int A,B;
    cin >> A >> B;
    vector<vector<int> > vec(H, vector<int> (W));
    for (int i = 0; i < B; i++){
        for (int j = 0; j < A; j++){
            vec[i][j] = 1;
        }
        for (int j = A; j < W; j++){
            vec[i][j] = 0;
        }
    }
    for (int i = B; i < H; i++){
        for (int j = 0; j < A; j++){
            vec[i][j] = 0;
        }
        for (int j = A; j < W; j++){
            vec[i][j] = 1;
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << vec[i][j];
        }
        cout << endl;
    }
}

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

int cnt=0;
string a;
int main()
{
  	cin>>a;
	for(int i=0;i<a.length();i++)
      if(a[i]=='7')
      	cnt++;
	if(cnt)
      cout<<"Yes";
  	else
      cout<<"No";
}

  


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 105000;

int n, m;
int qn;
set<long long> a, b;
vector<long long> av, bv;
long long x;

long long calc(long long a, long long b, long long x) {
  long long res = abs(a - x) + abs(a - b);
  res = min(res, abs(b - x) + abs(a - b));
  return res;
}

int main() { 

  scanf("%d %d %d", &n, &m, &qn);

  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    a.insert(x);
  }
  for (int i = 0; i < m; i++) {
    scanf("%lld", &x);
    b.insert(x);
  }

  while (qn--) {
    scanf("%lld", &x);
    av.clear(); bv.clear();

    auto it = a.upper_bound(x);
    if (it != a.end()) {
      av.push_back(*it);
    }
    if (it != a.begin()) {
      it--;
      av.push_back(*it);
    }

    it = b.upper_bound(x);
    if (it != b.end()) {
      bv.push_back(*it);
    }
    if (it != b.begin()) {
      it--;
      bv.push_back(*it);
    }
    

    /* for (int i = 0; i < sz(av); i++) {
      cerr << av[i] << endl;
    }
    for (int i = 0; i < sz(bv); i++) {
      cerr << bv[i] << endl;
    }
    cerr << "---------" << endl; */

    long long curAns = -1;
    for (int i = 0; i < sz(av); i++) {
      for (int j = 0; j < sz(bv); j++) {
        long long f = calc(av[i], bv[j], x);
        if (curAns == -1 || f < curAns) {
          curAns = f;
        }
      }
    }

    printf("%lld\n", curAns);
  }

  return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  REP(i, N) { cin >> a[i] >> b[i] >> c[i]; }
  vector<vector<int>> dp(N, vector<int>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  FOR(i, 0, N - 1) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1];
    dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b[i + 1];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1];
  }
  cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;
  return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w, h, x, y; cin >> w >> h >> x >> y;
  cout << fixed << setprecision(10);
  if(w%2==0 && h%2==0) {
    if(w/2==x && h/2==y) {
      cout << (ld)w*h/2 << ' ' << 1 << endk;
    } else {
      cout << (ld)w*h/2 << ' ' << 0 << endk;
    }
  } else {
    cout << (ld)w*h/2 << ' ' << 0 << endk;
  }
  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> D(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    ll sum = 0;
    ll lsum = 0;
    ll count = 0;
    for(int i = 0; i < N; i++){
        D[i] = A[i] - B[i];
        sum += D[i];
        if(D[i] < 0){
            lsum += D[i];
            count++;
        }
    }
    if(sum < 0){
        cout << -1 << endl;
    }
    sort(D.begin(),D.end(),greater<ll>());
    for(int i = 0; i < N; i++){
        if(lsum >= 0){
            cout << count << endl;
            return 0;
        }
        lsum += D[i];
        count++;
    }
    if(lsum >= 0){
        cout << count << endl;
        return 0;
    }


}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

vi ans;
vvii edges;

void dfs(int x, int c) {
  if (ans[x] != -1) return;
  ans[x] = c;
  rep (i, edges[x].size()) {
    int to = edges[x][i].ff, nc = edges[x][i].ss;
    dfs(to, (c+nc)%2);
  }
}

int main() {
  int n; cin >> n;
  edges.resize(n);
  ans.assign(n, -1);
  rep(i, n-1) {
    int u, v, w; cin >> u >> v >> w;
    u--; v--; w %= 2;
    edges[u].pb(mp(v, w));
    edges[v].pb(mp(u, w));
  }

  dfs(0, 0);
  rep(i, n) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 9216
N = int(input())
DP = [False for _ in range(N *100 + 1)]
DP[0] = True
for i in range(N):
  k = int(input())
  for i2 in range(i * 100 + 1,-1,-1):
    if DP[i2] != 0:
      DP[i2 + k] = True
ans = 0
for i in range(N *100 + 1):
  if DP[i] == True and i % 10 != 0:
    ans = i
print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

void dfs(string head, int pos, int len)
{
    if (len == 0)
    {
        cout << head << endl;
        return;
    }

    for (int i = 0; i <= pos; i++)
    {
        char c = 'a' + (char)i;
        dfs(head + c, max(pos, i+1), len - 1);
    }
}

int main()
{
    int n; cin >> n;
    dfs("", 0, n);
}

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC074C {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int H = input[0];
            int W = input[1];
            int across = (H % 3 == 0) ? 0 : W;
            int down = (W % 3 == 0) ? 0 : H;
            int Hdiv = H / 3;
            int leftdown = (H - Hdiv) * (W / 2);
            int rightdown = (H - Hdiv) * ((W + 1) / 2);
            int[] acrdow1set = { Hdiv * W, leftdown, rightdown };
            int acrdow1 = acrdow1set.Max() - acrdow1set.Min();
            int[] acrdow2set = { (Hdiv + 1) * W, leftdown - (W / 2), rightdown - ((W + 1) / 2) };
            int acrdow2 = acrdow1set.Max() - acrdow2set.Min();
            int Wdiv = W / 3;
            int upright = (W - Wdiv) * (H / 2);
            int downright = (W - Wdiv) * ((H + 1) / 2);
            int[] dowacr1set = { Wdiv * H, upright, downright };
            int dowacr1 = dowacr1set.Max() - dowacr1set.Min();
            int[] dowacr2set = { (Wdiv + 1) * H, upright - (H / 2), downright - ((H + 1) / 2) };
            int dowacr2 = dowacr2set.Max() - dowacr2set.Min();
            int ans = (new int[] { across, down, acrdow1, acrdow2, dowacr1, dowacr2 }).Min();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if (N == 1){
    cout << 1 << endl;
    cout << 0 << endl;
  } else if (N == 2){
    cout << 2 << endl;
    cout << 0 << endl;
    cout << 11 << endl;
  } else {
    cout << N - 1 << endl;
    for (int i = 0; i < N - 2; i++){
      cout << 0;
      for (int j = 0; j < i; j++){
        cout << 1;
      }
      cout << 0;
      cout << endl;
    }
    for (int i = 0; i < N; i++){
      cout << 1;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3112
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Text.Printf

gcd' :: Integer -> Integer -> Integer
gcd' a 0 = a
gcd' a b = gcd' b (a `mod` b)

lcm' :: Integer -> Integer -> Integer
lcm' a b = a * b `quot` (gcd' a b)

main = do
  n <- getLine
  a <- map (read::String->Integer) . words <$> getLine
  print $ foldl lcm' 1 a


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int D[N];
  for(int i = 0; i < N; i++){
  	cin >> D[i];
  }
  sort(D,D+N);
  int count = 0;
  for(int i = 0; i < N - 1; i++){
  	if(D[i] != D[i+1]){
    	count++;
    }
  }
  cout << count + 1 << endl;
}

Measured memory_bytes: 256