akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>

struct TDice
{
    int Top;
    int Front;
    int Right;
    int Back;
    int Left;
    int Bottom;
};
TDice MakeDice(std::istream& in)
{
    TDice Dice;
    in >> Dice.Top
       >> Dice.Front
       >> Dice.Right
       >> Dice.Left
       >> Dice.Back
       >> Dice.Bottom;
    return Dice;
}
void RollN(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Front;
    Dice.Front  = Dice.Bottom;
    Dice.Bottom = Dice.Back;
    Dice.Back   = temp;
}
void RollE(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Left;
    Dice.Left   = Dice.Bottom;
    Dice.Bottom = Dice.Right;
    Dice.Right  = temp;
}
void RollW(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Right;
    Dice.Right  = Dice.Bottom;
    Dice.Bottom = Dice.Left;
    Dice.Left   = temp;
}
void RollS(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Back;
    Dice.Back   = Dice.Bottom;
    Dice.Bottom = Dice.Front;
    Dice.Front  = temp;
}

void Roll(char c, TDice& Dice)
{
    switch(c){
    case 'N': RollN(Dice); break;
    case 'E': RollE(Dice); break;
    case 'W': RollW(Dice); break;
    case 'S': RollS(Dice); break;
    }
}
bool IsInclude(int Num, const TDice& Dice)
{
    return
        Dice.Top    == Num ||
        Dice.Front  == Num ||
        Dice.Right  == Num ||
        Dice.Back   == Num ||
        Dice.Left   == Num ||
        Dice.Bottom == Num; 
}
void RollToTop(int Num, TDice& Dice)
{
    assert(IsInclude(Num, Dice));
    if(Dice.Top == Num){
    }else
    if(Dice.Left == Num){
        RollE(Dice);
    }else
    if(Dice.Right == Num){
        RollW(Dice);
    }else
    if(Dice.Front == Num){
        RollN(Dice);
    }else
    if(Dice.Back == Num){
        RollS(Dice);
    }else
    if(Dice.Bottom == Num){
        RollE(Dice);
        RollE(Dice);
    }else{
        assert(false);
    }
}
void RollToFront(int Num, TDice& Dice)
{
    RollToTop(Num, Dice);
    RollS(Dice);
}
void RollToTopFront(int Top, int Front, TDice& Dice)
{
    RollToFront(Front, Dice);
    RollToTop(Top, Dice);
}
int main()
{
    TDice Dice = MakeDice(std::cin);
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        int Top, Front;
        std::cin >> Top >> Front;
        RollToTopFront(Top, Front, Dice);
        std::cout << Dice.Right << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
use std::cmp::max;
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!(iter), parse!(iter))
    };
    ($iter: ident,3) => {
        (parse!(iter), parse!(iter), parse!(iter))
    };
    ($iter: ident,4) => {
        (parse!(iter), parse!(iter), parse!(iter), parse!(iter))
    };
}

fn gcd(a: u64, b: u64) -> u64 {
    match b {
        0 => a,
        _ => gcd(b, a % b),
    }
}

const MOD: u64 = 1000000007;

fn powmod(base: u64, exp: u64, m: u64) -> u64 {
    let b: Vec<bool> = format!("{:b}", exp)
        .chars()
        .map(|x| x.to_digit(10).unwrap() != 0)
        .collect();
    let mut v = 1;
    for bi in b {
        v *= v;
        v %= m;
        if bi {
            v *= base;
            v %= m
        }
    }
    return v % m;
}

fn invmod(x: u64, m: u64) -> u64 {
    powmod(x, m - 2, m)
}

fn prime_factors(x: u64) -> Vec<u64> {
    let mut res = vec![];
    let mut y = x;
    let mut p = 2;
    let upper = (y as f64).sqrt() as u64;
    while y > 1 && p <= upper {
        match y % p {
            0 => {
                res.push(p);
                y /= p;
            }
            _ => {
                p += 1;
            }
        }
    }
    if y > 1 {
        res.push(y)
    }
    return res;
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let _: u64 = parse!(iter);
    let a: Vec<u64> = iter.map(|x| x.parse().unwrap()).collect();
    let mut pv = vec![0; 1000000];
    for ai in &a {
        let mut prev = 0;
        let mut count = 0;
        for p in prime_factors(*ai) {
            if p == prev {
                count += 1;
            } else {
                pv[prev as usize] = max(pv[prev as usize], count);
                prev = p;
                count = 1;
            }
        }
        pv[prev as usize] = max(pv[prev as usize], count);
    }
    let l = pv
        .into_iter()
        .enumerate()
        .fold(1, |x, (i, y)| (x * powmod(i as u64, y, MOD)) % MOD);
    let res = a
        .iter()
        .fold(0, |x, y| (x + (l * invmod(*y, MOD)) % MOD) % MOD);

    println!("{:}", res);
}


Measured memory_bytes: 12540
n = int(input())
a = [int(input()) for i in range(n)]

# ほとんどは全体のmax?
m1 = max(a)

# max値が多い場合用に2nd max
m2 = sorted(a)[n-2]

for i in range(n):
  if a[i] == m1:
    print(m2)
  else:
    print(m1)


Measured memory_bytes: 13968
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int a ,b;
    cin >> a >> b;
    if((a < 0 && 0 < b) || (b < 0 && 0 < a) || a == 0  || b == 0){
        cout << "Zero" << endl;
        return 0;
    }

    if(a < 0){
        int c = abs(a) - abs(b);
        cout << ( c % 2 == 1 ? "Positive" : "Negative") << endl;
    }else{
        cout << "Positive" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for i in range(N)]

s.sort()

ans = sum(s)
for i in range(N):
    if ans%10 != 0:
        break
    elif s[i]%10 != 0:
        ans -= s[i]

print(ans if ans%10!=0 else 0)

Measured memory_bytes: 62428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int max_n = 1e6;
ll a[max_n];
ll gcd(ll a, ll b){
  if(b == 0)  return a;
  return gcd(b, a%b);
}
int main(){
  cin >> n;
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  reverse(a, a+n);
  ll GCD = a[0];
  for(int i=1 ; i<n ; i++){
    GCD = gcd(GCD, a[i]);
  }
  cout << GCD << endl;
  return 0;
}


Measured memory_bytes: 1024
num753 = []
num753.append([0,0,0,0,0,0,0])  #3,5,7,35,37,57,357
num753.append([1,1,1,0,0,0,0])

for i in range(1,10):
    num753.append([num753[i][0],num753[i][1],num753[i][2],num753[i][0]+num753[i][1]+num753[i][3]*2,num753[i][0]+num753[i][2]+num753[i][4]*2,num753[i][1]+num753[i][2]+num753[i][5]*2,num753[i][3]+num753[i][4]+num753[i][5]+num753[i][6]*3])

N = input()

ans = 0
for i in range(len(N)):
    ans += num753[i][6]

check3 = False
check5 = False
check7 = False
for i in range(len(N)):
    if int(N[i])<3:
        break
    if int(N[i])==3:
        if i==len(N)-1:
            if check5 and check7:
              ans += 1
        check3 = True
        continue
    ans += num753[len(N)-i-1][5]+num753[len(N)-i-1][6]
    if check5:
        ans += num753[len(N)-i-1][2]+num753[len(N)-i-1][4]
    if check7:
        ans += num753[len(N)-i-1][1]+num753[len(N)-i-1][3]
    if check5 and check7:
        ans += num753[len(N)-i-1][0]
    if int(N[i])<5:
        break
    if int(N[i])==5:
        if i==len(N)-1:
            if check5 and check7:
                ans += 1
            if check3 and check7:
                ans += 1
        check5 = True
        continue
    ans += num753[len(N)-i-1][4]+num753[len(N)-i-1][6]
    if check3:
        ans += num753[len(N)-i-1][2]+num753[len(N)-i-1][5]
    if check7:
        ans += num753[len(N)-i-1][0]+num753[len(N)-i-1][3]
    if check3 and check7:
        ans += num753[len(N)-i-1][1]
    if int(N[i])<7:
        break
    if int(N[i])==7:
        if i==len(N)-1:
            if check5 and check7:
                ans += 1
            if check3 and check7:
                ans += 1
            if check3 and check5:
                ans += 1
        check7 = True
        continue
    ans += num753[len(N)-i-1][3]+num753[len(N)-i-1][6]
    if check3:
        ans += num753[len(N)-i-1][1]+num753[len(N)-i-1][5]
    if check5:
        ans += num753[len(N)-i-1][0]+num753[len(N)-i-1][4]
    if check3 and check5:
        ans += num753[len(N)-i-1][2]
    break

print(ans)


Measured memory_bytes: 3284
class XYZ_Triplets
  def initialize(n)
    @n = n
    @ac = Array.new(n+1, 0)
    @ls = (1..).take_while{|i| i * i < n}
  end

  def solve
    @ls.each do |x|
      @ls.each do |y|
        @ls.each do |z|
          m = x * x + y * y + z * z + x * y + y * z + z * x
          if m <= @n
            @ac[m] += 1
          end
        end
      end
    end
    
    (1..@n).each do |i|
      puts @ac[i]
    end
  end
end

def run
  n = gets.chomp.to_i
  
  XYZ_Triplets.new(n).solve
end

run


Measured memory_bytes: 14264
// ALPCF.cpp :
#include <cstdio>
#include <iostream>
#include <atcoder/convolution.hpp>
#include <atcoder/modint.hpp>

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

using namespace std;
using namespace atcoder;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    rep(i, n) {
        cin >> a.at(i);
    }
    vector<int>b(m);
    rep(i, m) {
        cin >> b.at(i);
    }
    auto ans = convolution(a, b);
    for (auto x : ans) {
        cout << x << " ";
    }
    cout << endl;
}


Measured memory_bytes: 19008
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
long long minmax(int n, int k){
    long long ans = 0;
    int tmp1 = 0;
    int tmp2 = n;
    for(int i = 0; i < k; i++){
        ans += tmp2 - tmp1;
        ans %= mod;
        tmp1 ++;
        tmp2 --;
    }
    return ans;
}
int main(){
    //std::stack<int> stack;
    
    int n,k;
    cin >> n >> k;
    if(n <= k){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    //cout << ans << endl;
    return 0;
}





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

int euclid(int a, int b)
{
    if(a < b){
        int k = a;
        a = b;
        b = k;
    }
    while(a % b != 0){
        int k = a % b;
        a = b;
        b = k;
    }
    return b;
}

int main()
{
    int n, a, ans;
    cin >> n >> a;
    ans = a;
    for(int i = 1; i < n; i++){
        scanf("%d", &a);
        ans = euclid(ans, a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 123123
int a[MAX],N;
int c[100][100];

int main(){
  int H,W;
  cin >> H >> W >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int it=0;
  for(int i=0;i<H;i++){
    if(it>N-1)break;
    if(i%2==0){
      for(int j=0;j<W;j++){
        c[i][j]=it+1;
        a[it]--;
        if(a[it]==0)it++;
        if(it>N-1)break;
      }
    }else{
      for(int j=W-1;j>=0;j--){
        c[i][j]=it+1;
        a[it]--;
        if(a[it]==0)it++;
        if(it>N-1)break;
      }
    }
  }
  for(int i=0;i<H;i++){
    cout << endl;
    for(int j=0;j<W;j++){
      cout << c[i][j] << " ";
    }
  }
  return 0;
}


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

long long INF = 1e18;
long long MOD = 1e9+7;

int main() {
	int m, n;	cin>>m>>n;
	
	long long temp;
	long long sumX = 0;
	for (int i = 1; i <= m; ++i) {
		cin>>temp;
		sumX = (sumX + (2*i-m-1) * temp % MOD) % MOD;
	}
	
	long long sumY = 0;
	for (int j = 1; j <= n; ++j) {
		cin>>temp;
		sumY = (sumY + (2*j-n-1) * temp % MOD) % MOD;
	}
	
	long long res = sumX * sumY % MOD;
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

ll dp[3001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, S;
	cin >> N >> S;

	int A[3000];
	rep(i, N) cin >> A[i];

	ll k2 = modpow(2, mod - 2);
	dp[0] = modpow(2, N);
	rep(i, N) {
		for (int j = S - A[i]; j >= 0; j--) {
			dp[j + A[i]] += dp[j] * k2 % mod;
			dp[j + A[i]] %= mod;
		}
	}

	co(dp[S] % mod);

	Would you please return 0;
}

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

using namespace std;

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int num1 = 0;
    int num2 = 0;
    for(int i =0;i<s.length();i++)
    {
        if(s[i]=='a'&&num1<a+b)
        {
            cout<<"Yes"<<endl;
            num1++;
        }else if(s[i]=='b'&&(num1<a+b)&&(num2<b))
        {
            cout<<"Yes"<<endl;
            num1++;
            num2++;
        }else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;
 

int main() {
    fastio
    int n,w;
    cin>>n>>w;
    int value[n+1],weight[n+1];
    rng(i,0,n){
        cin>>weight[i+1]>>value[i+1];
    }
    LL dp[n+1][w+1];
    rng(i,0,n+1){
        rng(j,0,w+1){
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(weight[i]<= j)
                dp[i][j] = (LL)max(dp[i-1][j], value[i] + dp[i-1][j-weight[i]]) ;
            else
                dp[i][j] = (LL)dp[i-1][j];
        }
    }
    cout<<(LL)dp[n][w]<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct query { ll a, b, c, d; };

ll result = 0;
vector<ll> now;
vector<query> q;

int N, M, Q;

void dfs(int l=0, int p=0) {
  if (p!=N) {
    repr(i,l,M) {
      now[p] = i;
      dfs(i,p+1);
    }
  }
  else {
    ll rt = 0;
    rep(i,Q) {
      if (now[q[i].b]-now[q[i].a]==q[i].c) rt += q[i].d;
    }
    // if (result<rt) { cout << rt << ":"; debug(all(now)); }
    result = max(result,rt);
  }
}

int main() {
  cin >> N >> M >> Q;
  q.resize(Q);
  rep(i,Q) {
    ll a, b, c, d; cin >> a >> b >> c >> d; a--; b--;
    q[i] = {a, b, c, d};
  }
  now.resize(N);
  dfs();
  cout << result << endl;
  return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int A, B;
    cin >> A >> B;
    bool bs = (A < B);  // true:B, false:W
    if (bs) swap(A, B);
    int n = 99;
///    int n = 29;
    vector<vector<bool>> ans(n, vector<bool>(n, bs));
    REP (i, 0, n) ans[0][i] = ans[n - 1][i] = ans[i][0] = ans[i][n - 1] = !bs;
    int interval = 4;
    int cnt = 1;

    // yoko
    for (int i = interval; i < n - 1 && cnt < B; i += interval, cnt++) {
        REP (j, 0, n) ans[i][j] = !bs;
    }

    // tate
    for (int i = interval; i < n - 1 && cnt < B; i += interval) {
        int idx = 0;
        while (idx < n - 1 && cnt < B) {
            while (idx < n - 1 && ans[idx][i] == !bs) idx++;
            for (; idx < n - 1 && cnt < B && ans[idx][i] == bs; idx++) ans[idx][i] = !bs;
            cnt++;
        }
    }

    A--;
//    if (A == B) A--;
    for (int i = 2; i < n - 1 && A > 0; i += interval) {
        for (int j = 2; j < n - 1 && A > 0; j += interval, A--) {
            ans[i][j] = !bs;
        }
    }

    cout << n << ' ' << n << endl;
    REP (i, 0, n) {
        REP (j, 0, n) {
            cout << (ans[i][j] ? '.' : '#');
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(A,B);
    if(A<10 && B<10) cout << A*B << nn;
    else cout << -1 << nn;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

int N;

ll solve() {
    ll ret = 0;
    FOR (i, 1, N+1) {
        if (i % 3 != 0 && i % 5 != 0) ret += i;
    }
    return ret;
}

int main() {
    cin >> N;
    cout << solve() << endl;
}

Measured memory_bytes: 3576
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int sum[100005],n,mi[100005];
char s[100005];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i='a';i<='z';i++)
	{
		sum[0]=mi[0]=0;
		for(int j=1;j<=n;j++)
		{
			if(s[j]==i)sum[j]=sum[j-1]+1;
			else sum[j]=sum[j-1]-1;
			mi[j]=mi[j-1];
			if(sum[j]<sum[mi[j]])mi[j]=j;
			if(j>=2&&sum[mi[j-2]]<sum[j])
			{
				printf("%d %d\n",mi[j-2]+1,j);
				return 0;
			}
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 2592
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let (a, b) = input_tuple();  
    let s = input_char_vec();
    for i in 0..(a+b+1) {
        if i == a {
            if s[i as usize] != '-' {
                println!("No");
                return;
            }
        } else {
            if (s[i as usize] as u64) < ('0' as u64) || s[i as usize] as u64 > '9' as u64 {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,mod,i,j,k,f[5005][5005],g[5005][5005],g2[5005][5005],ans;
int main()
{
//	cerr<<sizeof(f)*2/1024.0/1024.0<<endl;
	cin>>n>>mod;
	fz0g(i,n) f[i][0]=1;
	fz0g(i,n){
		fz1(j,n){
			f[i][j]=f[i][j-1];
			if(i>=j) inc(f[i][j],f[i-j][j])
		}
	}
	int midp=n/2+1,lim=n-midp;
	g[0][0]=1;
	fz0g(i,n){
		fz1(j,n){
			g[i][j]=g[i][j-1];
			if(i>=j) inc(g[i][j],g[i-j][j])
		}
		fz1(j,n){
			if(i>lim) dec(g[i][j],g[i-lim-1][j-1])
		}
	}
	fz1(i,n){					//a[midp]==i
		int tmp=0;
		fz0g(j,i-1){					// sum(i-a[_])==j  (_<midp)
			k=i-1-j;					// sum(i-a[_])<=k  (midp<_)
			int sl=f[j][midp-1];
			int sr=g[k][n-i];
			tmp+=sl*sr;
			ans=(ans+1ll*sl*sr)%mod;
		}
//		cerr<<i<<' '<<tmp<<endl;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 197504
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

vector<map<int,int>> mp(100010);

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    mp[a][b] = 1;
    mp[b][a] = 1;
  }
  int tree[n + 1] = {};
  tree[1] = 1;
  queue<int> que;
  que.push(1);
  while (!que.empty()) {
    int top = que.front();
    que.pop();
    for (auto p: mp[top]) {
      if (tree[p.first] == 0) {
        tree[p.first] = top;
        que.push(p.first);
      }
    }
  }
  int pos = n;
  int dist = 0;
  while (1) {
    if (tree[pos] != 1) {
      dist++;
      pos = tree[pos];
    } else {
      break;
    }
  }
  dist /= 2;
  int tmp = n;
  for (int i = 0; i < dist; i++) {
    tmp = tree[tmp];
  }
  int cnt = 0;
  que.push(tmp);
  while (!que.empty()) {
    int top = que.front();
    que.pop();
    cnt++;
    for (auto p: mp[top]) {
      if (p.first != tree[top]) {
        que.push(p.first);
      }
    }
  }
  if (n - cnt > cnt) {
    puts("Fennec");
  } else {
    puts("Snuke");
  }
  return 0;
}


Measured memory_bytes: 14720
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
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; }

int main(void) {
    string s; cin >> s;
    bool t = true;
    REP(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
            else t = false;
        }
        else {
            if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
            else t = false;
        }
    }
    if (t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    vector<ll> pre(n+1),suf(n+1);
    for(int i=0;i<n+1;i++) {
        sum=(sum+i)%mod;
        pre[i]=sum;
    }
    sum=0;
    for(int i=n;i>=0;i--) {
        sum=(sum+i)%mod;
        suf[n-i]=sum;
    }
    ll ans=0;
    for(int i=k-1;i<n+1;i++) {
        ans=(ans+(suf[i]-pre[i]+1)+mod)%mod;
    }
    cout<<ans;
}   


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

}


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

int main() {
  
  int H, W;
  cin >> H >> W;
  while ( H != 0 && W != 0) {
  
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
		if ( (i+1)%2==0 ) {
		  if ( (j+1)%2==0 ) {
			cout << '#';
          } else {
            cout << '.';
          }
        } else if ( (j+1)%2==0 ) {
			cout << '.';
        } else {
          cout << '#';
        }
      }
      cout << endl;
    }
    
    cout << endl;
    cin >> H >> W;
  }
  
  return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> mp(h);
  for (int i = 0; i < h; i++) cin >> mp[i];
  vector<vector<ll>> r(h), l(h), u(w), d(w);
  for (int i = 0; i < h; i++) {
    r[i].resize(w + 1);
    l[i].resize(w + 1);
    for (int j = 0; j < w; j++) {
      if (mp[i][j] == '.') r[i][j + 1] = r[i][j] + 1;
      if (mp[i][w - 1 - j] == '.') l[i][j + 1] = l[i][j] + 1;
    }
  }
  for (int i = 0; i < w; i++) {
    u[i].resize(h + 1);
    d[i].resize(h + 1);
    for (int j = 0; j < h; j++) {
      if (mp[j][i] == '.') d[i][j + 1] = d[i][j] + 1;
      if (mp[h - 1 - j][i] == '.') u[i][j + 1] = u[i][j] + 1;
    }
  }
  ll ans = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      if (mp[i][j] == '.') {
        ans = max(ans, r[i][j] + l[i][w - j - 1] + d[j][i] + u[j][h - i - 1] + 1);
      }
    }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int a,b; cin>>a>>b;
	if(a+b>=10) cout<<"error"<<endl;
	else cout<<a+b<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int ans_1=0,ans_2=0;

    ans_1 = (a*(a-1))/2;
    ans_2 = (b*(b-1))/2;

    cout << ans_1 + ans_2 << endl;
    
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define rank _rank
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}



int main(){
    int T,i,j,k,n,m=0;
    scanf("%d%d",&i,&j);
    if(j>=0&&i<=0){
    	puts("Zero");return 0;
    }
    k=j-i+1;
    if(i>0)puts("Positive");
    else{
    	k=j-i+1;
    	puts(k&1?"Negative":"Positive");
    }
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int Partition(int*,int,int);

int main(){
    
    int n,i,q;
    int A[100001];

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    q=Partition(A,0,n-1);

    for(i=0;i<q;i++){
        printf("%d ",A[i]);
    }
    printf("[%d] ",A[q]);
    
    for(i=q+1;i<n-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    
    return 0;
}

int Partition(int *A,int p,int r){
    int i,j,x,tmp;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    
    return i+1;
}

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

using namespace std;
int main (){
    int a,b,c,d,e;
    cin >> e;
    d = e%10;
    e/=10;
    c = e%10;
    e/=10;
    b = e%10;
    e/=10;
    a=e;
    if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7\n";
    else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << "=7\n";
    else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << "=7\n";
    else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << "=7\n";
    else if(a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d << "=7\n";
    else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << "=7\n";
    else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << "=7\n";
    else if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7\n";

}

Measured memory_bytes: 256
import sys
S=input()
T=input()
SL=[]
TL=[]
Ans="Yes"
for s in S:
  SL.append(s)
for t in T:
  TL.append(t)
if len(TL)-1 != len(SL):
  Ans="No"
  print(Ans)
  sys.exit()
for i in range(len(SL)):
  if SL[i] != TL[i]:
    Ans="No"
print(Ans)

Measured memory_bytes: 61672
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}
int main()
{
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

ll dp[401][201][201];
int A[201][201];

bool same(int ay, int ax, int by, int bx) {
    return ay == by&&ax == bx;
}

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

    int H, W;
    while(cin >> H >> W) {
        rep(y, H)rep(x, W)cin >> A[y][x];

        MEM(dp, -1);
        dp[0][0][0] = A[0][0];

        rep(s, H + W - 2) {
            rep(ay, H) {
                if(ay > s)continue;
                int ax = s - ay;
                if(ax < 0 || ax >= W)continue;
                rep(by, H) {
                    if(by > s)continue;

                    int bx = s - by;
                    if(bx < 0 || bx >= W)continue;

                    ll z = dp[s][ay][by];
                    if(z == -1)continue;

                    // 下,下
                    if(ay < H - 1 && by < H - 1) {
                        int nay = ay + 1;
                        int nby = by + 1;
                        ll w = z + A[nay][ax] + A[nby][bx];
                        if(same(nay, ax, nby, bx)) {
                            w -= A[nay][ax];
                        }
                        smax(dp[s + 1][nay][nby], w);
                    }

                    // 下,右
                    if(ay < H - 1 && bx < W - 1) {
                        int nay = ay + 1;
                        int nbx = bx + 1;
                        ll w = z + A[nay][ax] + A[by][nbx];
                        if(same(nay, ax, by, nbx)) {
                            w -= A[nay][ax];
                        }
                        smax(dp[s + 1][nay][by], w);
                    }

                    // 右,下
                    if(ax < W - 1 && by < H - 1) {
                        int nax = ax + 1;
                        int nby = by + 1;
                        ll w = z + A[ay][nax] + A[nby][bx];
                        if(same(ay, nax, nby, bx)) {
                            w -= A[ay][nax];
                        }
                        smax(dp[s + 1][ay][nby], w);
                    }

                    // 右,右
                    if(ax < W - 1 && bx < W - 1) {
                        int nax = ax + 1;
                        int nbx = bx + 1;
                        ll w = z + A[ay][nax] + A[by][nbx];
                        if(same(ay, nax, by, nbx)) {
                            w -= A[ay][nax];
                        }
                        smax(dp[s + 1][ay][by], w);
                    }
                }
            }
        }

        cout << dp[H+W-2][H - 1][H - 1] << endl;
    }
}

Measured memory_bytes: 126976
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		int score_t = 0;
		int score_h = 0;
		while (n-- > 0) {
			String word_t = sc.next();
			String word_h = sc.next();

			int result = word_t.compareTo(word_h);
			if (result == 0) {
				score_t += 1;
				score_h += 1;
			} else if (result > 0) {
				score_t += 3;
			} else {
				score_h += 3;
			}
		}

	    System.out.println(score_t + " " + score_h);
	}
}

Measured memory_bytes: 29668
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.05.19 20:58:30
 */

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */
int n, k;
string s;

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

    /* アルファベットの大文字なら変換 */
    if (s[k - 1] >= 65 && s[k - 1] <= 90)
        s[k - 1] = s[k - 1] + 32;

    cout << s << '\n';

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  vector<int>A;
  int a;
  fol(i,3){
    cin>>a;
    A.pb(a);
  }
  sort(A.rbegin(),A.rend());
  cout << abs(A[0]-A[1])+abs(A[2]-A[1])<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>
 
using namespace std;
 
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL LLONG_MAX
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define RMAX 4294967295
#define equals(a,b)(fabs((a)-(b))<EPS)
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef complex<double> comp;
typedef vector<complex<double>> vcomp;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef string::const_iterator State;
class ParseError {};
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int N;
	cin >> N;
	vi h(N), p(N);
	vector<tuple<int,int,int>> ph(N);
	rep(i, N) {
		cin >> h[i] >> p[i];
		ph[i] = mt(p[i]+h[i], p[i], h[i]);
	}
	sort(all(ph));
 
	vvll dp(N + 1, vll(N + 1, INFL));
	rep(i, N + 1)dp[i][0] = 0;
 
	rep(i, N) {
		rep(j, N) {
			if (dp[i][j] <= get<2>(ph[i])) {
				dp[i + 1][j + 1] = min(dp[i][j] + get<1>(ph[i]), dp[i][j + 1]);
			}
			else {
				dp[i + 1][j + 1] = dp[i][j + 1];
			}
		}
	}
	/*
	rep(j, N + 1) {
		rep(i, N + 1) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	//*/
	int ans = 0;
	rep(j, N + 1) {
		if (dp[N][j] < INFL)ans = j;
	}
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 196096
import java.io.*;
import java.util.*;
// i want to become the best
class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		//int n = Integer.parseInt(reader.readLine());
		int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	    //System.out.println(list[1]*list[2]>=list[0]?"Yes":"No");
		int N = list[0];
		int M = list[1];
		HashSet<Integer>[] graph = new HashSet[N+1];
		for(int i = 1;i<=N;i++) graph[i] = new HashSet<Integer>();
		for(int i = 0;i<M;i++){
			String[] lo = reader.readLine().split(" ");
			int u = Integer.parseInt(lo[0]);
			int v = Integer.parseInt(lo[1]);
			graph[u].add(v);
			graph[v].add(u);
		}
		boolean[] visited = new boolean[N+1];
		Queue<Integer> q = new LinkedList<Integer>();
		int ans = 0;
		for(int i = 1;i<=N;i++){
			if(visited[i]) continue;
			q.add(i);
			int cand = 0;
			visited[i] = true;
			while(!q.isEmpty()){
				int src = q.remove();
				//visited[src] = true;
				cand++;
				for(int o:graph[src]) if(!visited[o]){
					q.add(o);
					visited[o] = true;
				}
			}
			ans = Math.max(ans,cand);
		}
		System.out.println(ans);
	}
}
class pair implements Comparable<pair>{
		long a = 0;
		int b = 0;
		public pair(long a,int b){
			this.a = a;
			this.b = b;
		}
		@Override
		public int compareTo(pair p){
			if(this.a == p.a) return -(Integer.compare(this.b,p.b));
			else return -(Long.compare(this.a,p.a));
		}
		@Override
		public String toString(){
			return a+" "+b;
		}
	}


Measured memory_bytes: 109976
n = gets.chop.to_i

cnt = Array.new(10) { Array.new(10, 0) }

1.upto(n) do |i|
  a = i.to_s[0].to_i; z = i % 10
  cnt[a][z] += 1
end

sum = 0
0.upto(9) do |a|
  0.upto(9) do |z|
    sum += cnt[a][z] * cnt[z][a]
  end
end
puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 1e+9
typedef pair<int,int> P;
struct edge{
    int to,cost;
};
int c,n,m,s,end;
vector<edge> G[101];
int d[11][101];

void dijkstra(int s,int a){
    priority_queue<P, vector<P>, greater<P> >Q;
    for(int i=0;i<n;i++)d[a][i] = INF;
    d[a][s] = 0;
    Q.push(P(0,s));
    
    while(!Q.empty()){
        P p=Q.top();
        Q.pop();
        int v = p.second;
        
        if(d[a][v] < p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            int dm;
            if(a==0)dm=d[a][v]+e.cost;
            else dm=min(d[a][v]+e.cost,d[a-1][v]+e.cost/2);
            if(d[a][e.to] > dm){
                d[a][e.to] = dm;
                Q.push(P(d[a][e.to],e.to));
            }
        }
    }
}

int main() {
    while(1){
     cin>>c>>n>>m>>s>>end;
     s--;
     end--;
     if(!c)break;
     
     for(int i=0;i<m;i++){
         int a,b,f;
         cin>>a>>b>>f;
         a--;
         b--;
         G[a].push_back((edge){b,f});
         G[b].push_back((edge){a,f});
     }
     int ans = INF;
     for(int i=0;i<=c;i++){
         dijkstra(s,i);
	 }
        
     cout<<d[c][end]<<endl;
     
     for(int i=0;i<100;i++)G[i].clear();
	}
	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int n;
int s[1000010];
void solve(){
    rep(i,1000000) s[i] = 0;
    rep(i,n){
        int sh,sm,ss;
        int eh,em,es;
        scanf("%d:%d:%d", &sh,&sm,&ss);
        scanf("%d:%d:%d", &eh,&em,&es);
        int sta = sh * 3600 + sm * 60 + ss;
        int end = eh * 3600 + em * 60 + es;
        s[sta] += 1;
        s[end] -= 1;
    }
    rep(i,1000000) s[i+1] += s[i];
    cout << *max_element(s, s+1000000) << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    while(scanf("%d", &n), n){
        solve();
    }
    return 0;
}


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

int H, W, a[30][30], minx = (1 << 30);

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> a[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			int sum = 0;
			for (int k = 1; k <= H; k++) {
				for (int l = 1; l <= W; l++) sum += a[k][l] * min(abs(k - i), abs(l - j));
			}
			minx = min(minx, sum);
		}
	}
	cout << minx << endl;
	return 0;
}


Measured memory_bytes: 3096