akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    string w[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    int i = find(w, s) - w;
    show(7 - i);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.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; }
using namespace std;
typedef long long ll;
const ll inf = 100000000000000;

int main(){

    int n, m;
    cin >> n >> m;

    vector<ll> a(n);
    rep(i, n){ cin >> a[i]; a[i]--; }

    ll now = 0, cnt = 0, sum = 0;
    vector<int> start(m, 0), end(m, 0);
    vector<ll> plus(m, 0);
    rep(i, n - 1){
        a[i + 1] += sum;
        if(a[i + 1] <= a[i]){ a[i + 1] += m; sum += m; }
        if(a[i + 1] - a[i] <= 1){ now++; continue; }
        start[(a[i] + 1) % m]++;
        end[a[i + 1] % m]++;
        plus[a[i + 1] % m] += a[i + 1] - a[i] - 1;
        if(m - a[i] % m <= a[i + 1] - a[i]){ now += a[i + 1] % m + 1; cnt++; } 
        else now += a[i + 1] - a[i]; 
    }

    ll ans = inf;
    rep(i, m){
        chmin<ll>(ans, now);
        if(i)cnt += start[i];
        cnt -= end[i];
        now += plus[i];
        now -= cnt;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	string s;
	cin >> s;
	int a = 0;
	for (int i = 0; i < 4; i++) {
		if (s.at(i) == '+') a++; else a--;
	}
	cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q;
    string s;
    cin>>n>>q;
    cin>>s;
    int moji[100001]={};
    for(int i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C'){
            moji[i-1]++;
        }
        moji[i]=moji[i-1];
        //cout<<moji[i-1]<<endl;
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        if(l==0) l=0;
        else if(moji[l]==moji[l-1]) l = moji[l];
        else l = moji[l-1];
        if(r==n-1 || moji[r]==moji[r-1]) r = moji[r];
        else r = moji[r-1];
        cout<<r-l<<endl;
    }
    return 0;
    
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M,X;
    cin>>N>>M>>X;
    vector<int> A(N,0);
    rep(m,0,M){
        int a;
        cin>>a;
        A.at(a)=1;
    }

    int x=0,y=0;
    rep(i,1,A.size()){
        if(A.at(i)){
            if(i<X) x++;
            else y++;
        }
    }

    cout<<min(x,y)<<endl;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

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

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

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

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

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

fn main() {
    input! {
            n: usize,
            numbers: [i32; n],
        }

    use std::iter::FromIterator;

    let mut sorted_numbers = Vec::from_iter(numbers.iter().cloned());
    sorted_numbers.sort();
    sorted_numbers.reverse();
    let head: Vec<i32> = vec![sorted_numbers[0], sorted_numbers[1]];

    for i in 0..n {
        if numbers[i] == head[0] {
            println!("{}", head[1]);
        } else {
            println!("{}", head[0]);
        }
    }
}


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

int main(){
	int N, K, Result;
  	Result = 1;
  	cin >> N >> K;
  
  	//加算
  	for(int i = 0; i < N; i++){
		int cal_a = Result * 2;
      	int cal_b = Result + K;
      
       	if(cal_a < cal_b)
          	Result = cal_a;
      	else
			Result = cal_b;
    }
	
  	//結果出力
  	cout << Result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    set<string>arr;
    string temp;
   for(int i=0;i<n;i++)
   {
       cin>>temp;
       arr.insert(temp);
   }
   cout<<arr.size();
}

Measured memory_bytes: 19060
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Dice dice = new Dice(sc);
        char[] point = sc.next().toCharArray();
        for(char p:point){
            dice.roll(p);
        }
        System.out.println(dice.dice.get(0));
    }
}

class Dice{
    static ArrayList<String> dice = new ArrayList<>();
    static final int[] EAST = {2,5,3,0};
    static final int[] WEST = {3,5,2,0};
    static final int[] SOUTH = {1,5,4,0};
    static final int[] NORTH = {4,5,1,0};
    static String g;
    
    public Dice(Scanner sc){
        for(int i = 0; i < 6; i++){
            dice.add(sc.next());
        }
    }
    public static void roll(char point){
        g = dice.get(0);
        switch(point){
            case 'E':
                for(int i:EAST){
                    g = dice.set(i,g);
                } break;
            case 'W':
                for(int i:WEST){
                    g = dice.set(i,g);
                } break;
            case 'S':
                for(int i:SOUTH){
                    g = dice.set(i,g);
                } break;
            case 'N':
                for(int i:NORTH){
                    g = dice.set(i,g);
                } break;
            default:
        }
    }
}

Measured memory_bytes: 26104
MOD = 10**9 + 7

count = Array.new(61,0)
n = gets.chomp.to_i
a = gets.chomp.split.map{ |ai| ai.to_i }
61.times do |j|
  count[j] = a.count{ |ai| ai[j] == 1 }
end

ans = 0
61.times do |i|
  ans += 2**i * (n - count[i]) * count[i]
end

puts(ans % MOD)

Measured memory_bytes: 40324
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    long long n,a,b;cin >>n>>a>>b;
    if(n==1){
        (a==b)?cout<<1:cout<<0;
        return 0;
    }
    else{
        (a<=b)?cout<<(b-a)*(n-2)+1:cout << 0;return 0;
    }
}

Measured memory_bytes: 3576
($N,$C)=glob<>;
($x[@x],$v[@v])=split$",<>for 1..$N;
$z=0;
 
$x=$C;
$d=$d[$N]=0;
$s=0;
for(reverse 0..$N-1){
	$d=$d[$_]=($s+=$v[$_]-($x-$x[$_]))>$d?$s:$d;
	$z=$d if$d>$z;
	$x=$x[$_]
}
$x=0;
$s=0;
for(0..$N-1){
	$t=($s+=$v[$_]-($x[$_]-$x)*2)+$d[$_+1];
	$z=$t if$t>$z;
	$x=$x[$_]
}
 
$x=0;
$d=$d[$N]=0;
$s=0;
for(0..$N-1){
	$d=$d[$_]=($s+=$v[$_]-($x[$_]-$x))>$d?$s:$d;
	$z=$d if$d>$z;
	$x=$x[$_]
}
$x=$C;
$s=0;
for(reverse 0..$N-1){
	$t=($s+=$v[$_]-($x-$x[$_])*2)+$d[$_-1];
	$z=$t if$t>$z;
	$x=$x[$_]
}
 
print$z


Measured memory_bytes: 28416
import java.util.*; 
class Main {
   public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
       int sam = sc.nextInt();
       String ss = sc.next();
       
       int cnt = 0;
       char cc = '0';
       char hh = '0';
       for(int i = 0; i < sam; i++){
           hh = ss.charAt(i);
           if(cc != hh){
               cnt++;
               cc = hh;
           }
       }
     System.out.print(cnt);
   }
}

Measured memory_bytes: 25428
#include<bits/stdc++.h>
#define ll long long
#define inf 999999999999
#define F first
#define S second
#define pb push_back
#define read(x)  freopen("input.txt","r",stdin);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 200009
using namespace std;

int main(){//read(x);
fast;
ll a,b,c,d,e,f,g,h,i,j,k,l,n,t;
cin>>a>>b>>c;
d=0;
if(a%c==0)d++;
cout<<(b/c)-(a/c)+d<<endl;
}















Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
namespace
{
bool Chk( const char *S, const int iNum )
{
int i;
char C;
    for( i = 0; i < iNum; i++ )
	{
		C = S[ i ];
		if( C == '\0' || C != S[ i + iNum ] ) return false;
	}
    return true;
}
}
int main()
{
int i;
int iLen;
char S[ 210 ];
 
	cin >> S;
	iLen = strlen( S );
	for( i = iLen / 2 - 1; i > 0; i-- )
	{
		if( Chk( S, i ) )
		{
			cout << i * 2 << endl;
            return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 200005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int fact[N], ifact[N];

int powmod(int a, int b, int c){
    int ans = 1;
    while(b){
        if(b&1){
            ans = (ans*a)%c;
        }
        a = (a*a)%c;
        b >>= 1;
    }
    return ans;
}

void precompute(){
    fact[0]=1;
    ifact[0]=1;
    for(int i=1; i<N; i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=MOD;
        ifact[i]=powmod(fact[i], MOD-2, MOD);
    }
}

int ncr(int x, int y){
    int ans = (fact[x]*ifact[y])%MOD;
    ans = ans * ifact[x-y] % MOD;
    return ans;
}

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    precompute();
    int h, w, n; cin>>h>>w>>n;
    pii arr[n];
    For(i, 0, n){
        cin>>arr[i].F>>arr[i].S;
    }
    sort(arr, arr+n);
    vector<int> dp(n, 0);
    int ans = ncr(h-1+w-1, h-1);
    for(int i=0; i<n; i++){
        int x = arr[i].F, y = arr[i].S;
        int ways = ncr(x+y-2, y-1);
        for(int j=0; j<i; j++){
            int x1 = arr[j].F;
            int y1 = arr[j].S;
            if(y1 > y)
                continue;
            int red = ncr(x-x1+y-y1, x-x1)*dp[j]%MOD;
            ways = (ways-red+MOD)%MOD;
        }
        dp[i]=ways;
        int loss = ways*ncr(h-x+w-y, h-x)%MOD;
        ans = (ans-loss+MOD)%MOD;
    }
    cout<<ans;
    return 0;
}




Measured memory_bytes: 3456
# 入力
A,B,C=map(int,input().split())

# 余りの出現回数を保存する配列
l=[0]*100

# Aに掛ける係数
t=1

while True:
  # 余りを求める
  x=t*A%B

  # 余りがCと一致したら終了
  if x==C:
    print('YES')
    exit()

  # 余りが2回以上出現したら終了
  elif l[x]>0:
    print('NO')
    exit()

  # 余りの出現回数をインクリメント
  else:
    l[x]+=1

  # Aに掛ける係数を+1する（次のAの倍数へ）
  t+=1

Measured memory_bytes: 2940
import math

n = int(input())


def make_divisors(n):
    min_sum = 10**12
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            a = i
            #if i != n // i:
            #    divisors.append(n//i)
            b = n//i
        if a+b < min_sum:
            min_sum = a+b
    # divisors.sort()
    # return divisors 
    return min_sum

print(make_divisors(n)-2)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

constexpr long long int mod = 1000000007LL;

long long int f(const int current, const int free, const int confirmed, std::vector<std::vector<std::vector<long long int>>>& memo) {
	if (free < 0 || confirmed < 0) return 0;
	if (current == -1)
		return (free == 0 && confirmed == 0) ? 1 : 0;
	if (memo[current][free][confirmed] >= 0) return memo[current][free][confirmed];
	else {
		return memo[current][free][confirmed] = ((free * 2 + 1) * f(current - 1, free, confirmed - free * 2, memo) % mod + f(current - 1, free - 1, confirmed - free * 2, memo) + (free + 1) * (free + 1) * f(current - 1, free + 1, confirmed - free * 2, memo)) % mod;
	}
}

int main() {
	int n, k; std::cin >> n >> k;
	std::vector<std::vector<std::vector<long long int>>> memo(n, std::vector<std::vector<long long int>>(n, std::vector<long long int>(k + 1, -1)));
	std::cout << f(n - 1, 0, k, memo) << std::endl;
}

Measured memory_bytes: 50176
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		boolean[] flag = new boolean[31];
		for(int i = 0; i < flag.length; ++i)
		{
			flag[i] = false;
		}
		for(int i = 0; i < 28; ++i)
		{
			int a = stdIn.nextInt();
			flag[a] = true;
		}
		for(int i = 1; i < flag.length; ++i)
		{
			if(!flag[i])
			{
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 12000
using System.IO;
using System;

class Program
{
    static void Main()
    {
        string[] c = Console.ReadLine().Split();
        var a = int.Parse(c[0]);
        var b = int.Parse(c[1]);
        var area = a * b;
        var outline = 2 * (a + b);
        Console.WriteLine("{0} {1}", area, outline);
    }
}


Measured memory_bytes: 9120
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
//include<kyawa>


//--------------------

int main() {

	string res = "No";
	long N; cin >> N;
	long A[100009]; for (int i = 1; i <= N; i++) cin >> A[i];
	long a = A[1];

	for (int i = 2; i <= N; i++) a ^= A[i];

	if (a == 0) res = "Yes";

	cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    string s;
    cin >> s;
    if (s[s.size() - 1] != 's')
        cout << s + "s"
             << "\n";
    else
    {
        cout << s + "es"
             << "\n";
    }
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>

const double s[] = { 48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0 };
const char cls[][30] = { "light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy" };

int main()
{
	double f;
	
	while( std::cin >> f ){
		if( f <= 48.0 ){
			std::cout << "light fly" << std::endl;
		}
		else if( f > 91.0 ){
		 	std::cout << "heavy" << std::endl;
		}
		else{
		 	for( int i = 8; i >= 0; i-- ){
				if( s[i] < f && f <= s[i+1] ){
					std::cout << cls[i+1] << std::endl;
				}
			}
		}
	}

 	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second

int m, n, dp[1001][1001];   // B

int edit(int i, int j, string &s, string &t) {
    if(j == n) return 0;
    if((m - i) < (n - j)) return 1001;

    if(dp[i][j] != -1) return dp[i][j];

    if(s[i] == t[j]) return dp[i][j] = min(edit(i + 1, j + 1, s, t), edit(i + 1, 0, s, t));

    return dp[i][j] = min(1 + edit(i + 1, j + 1, s, t), edit(i + 1, 0, s, t));
}

int main() {
    string s, t; cin>>s>>t;
    m = s.length(), n = t.length();

    for(int i=0; i<m; i++) for(int j=0; j<n; j++) dp[i][j] = -1;

    printf("%d\n", edit(0, 0, s, t));
    return 0;
}

Measured memory_bytes: 7616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(b%a == 0 ? a + b : b - a);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int d;
    cin >> d;
    cout << d * (d+1) / 2 << endl;
    return 0;
}



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

#define NIL NULL

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

typedef struct node * Nodep;

void insert(int);
void preorder(Nodep);
void inorder(Nodep);
int find(Nodep, int);

Nodep root;


int main(){

  Nodep z;
  int key,n,i,x,tf;
  char op[7];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",op);

      if ( op[0] == 'i' ){
	scanf("%d",&key);
	insert(key);
      } 
      else if ( op[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
      else if ( op[0] == 'f' ){
	scanf("%d",&key);
	tf = find(root,key);

	if(tf == 1) printf("yes\n");
	else if(tf == 0) printf("no\n");
      }
  }
      
  return 0;
  
}



void insert(int k){
  Nodep y = NIL;
  Nodep x = root; 
  Nodep z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent= y;
  if(y==NIL){
    root = z;
  }
  else if(z->key<y->key){
    y->left =z;
  }
  else{
    y->right =z;
  }
}

void inorder(Nodep A){
  if(A != NIL){
    inorder(A->left);
    printf(" %d",A->key);
    inorder(A->right);
  }
}
   
void preorder(Nodep A){
  if(A!=NIL){
    printf(" %d",A->key);
    preorder(A->left);
    preorder(A->right);
  }
}

int find(Nodep A, int key){
 
  if(A == NIL) return 0;
  else if(A->key == key) return 1;
 
  if(key < A->key)  return find(A->left,key);
  else  return find(A->right,key);
 
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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

int main() {
	int H, W; cin >> H >> W;

	vector<vector<char>> a(H + 2, vector<char>(W + 2, '#'));
	int rikuti = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
			if (a[i][j] == '.') {
				rikuti++;
			}
		}
	}

	bool ans_check = false;
	vector<vector<int>> b(H + 2, vector<int>(W + 2, 1000000));
	queue<pair<int, int>> q;
	b[1][1] = 1;
	q.push(make_pair(1, 1));
	while (!q.empty()) {
		int x = q.front().first, y = q.front().second; q.pop();
		for (int A = 0; A < 4; A++) {
			int check_x = x + dx[A];
			int check_y = y + dy[A];
			if (b[check_x][check_y]== 1000000 && a[check_x][check_y] == '.') {
				q.push(make_pair(check_x, check_y));
				b[check_x][check_y] = b[x][y] + 1;
			}
		}
	}

	if (b[H][W]!= 1000000) {
		cout << rikuti - b[H][W]<< endl;
	}
	else {
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void cook()
{
    // start with your recipe
    int h1, m1, h2, m2, k;
    cin>>h1>>m1>>h2>>m2>>k;
    int mins = (h2-(h1+1))*60;
    mins += m2;
    mins += (60-m1);
    cout<<max(0, mins-k);
}

start_cooking
{
    main_ingredient_added
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while(t--)
        cook();
    food_is_ready
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    // 処理
    sort(a, a + 3);

    // 出力
    cout << ((a[0] == 5 && a[1] == 5 && a[2] == 7) ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int main(){
    int N, M; cin >> N >> M;
    vector<set<pair<int, int>>> V(N+1);
    for(int i = 0; i < M; i++){
        int p, y; cin >> p >> y;
        V[p].insert(make_pair(y, i));
    }

    vector<string> ID(M+1);
    for(int i = 1; i <= N; i++){
        int j = 1;
        for(auto x : V[i]){
            int id = x.second;
            string s1 = to_string(i);
            string s2 = to_string(j);
            while(s1.size() < 6) s1.insert(s1.begin(), '0');
            while(s2.size() < 6) s2.insert(s2.begin(), '0');
            ID[id] = s1+s2;
            j++;
        }
    }
    for(int i = 0; i < M; i++) cout << ID[i] << endl;
}

Measured memory_bytes: 16384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll A[100010];
vll p,m,v;
int main(){
  cin>>N;
  rep(i,N){
    cin>>A[i];
  }
  sort(A,A+N);
  ll mx=A[N-1];
  ll mn=A[0];
  rep1(i,N-2){
    if(A[i]>=0) p.pb(A[i]);
    else m.pb(A[i]);
  }
  int ps=p.size(),ms=m.size();
  ll sum=0;
  rep(i,ps) sum+=p[i];
  rep(i,ms) sum-=m[i];
  sum+=mx;
  sum-=mn;
  prin(sum);
  ll y=mn;
  rep(i,ps){
    prin2(y,p[i]);
    y-=p[i];
  }
  ll x=mx;
  rep(i,ms){
    prin2(x,m[i]);
    x-=m[i];
  }
  prin2(x,y);
  return 0;
}


Measured memory_bytes: 3572
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    int heapSize = 0;
    int[] heap = new int[2000000];
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            String op = input.next();
            if ("insert".equals(op)) {
                maxHeapInsert(heap, input.nextInt());
            } else if ("extract".equals(op)) {
                System.out.println(heapExtractMax(heap));
            } else if ("end".equals(op)) {
                break;
            }
        }
    }
    int parent(int i) {
        return i / 2;
    }
    int left(int i) {
        return i * 2;
    }
    int right(int i) {
        return i * 2 + 1;
    }
    void buildMaxHeap(int[] A) {
        for (int i = heapSize/2; i > 0; i--) {
            maxHeapify(A, i);
        }
    }
    void maxHeapify(int[] A, int i) {
        int l = left(i);
        int r = right(i);
        int largest;
        if (l <= heapSize && A[l] > A[i]) {
            largest = l;
        } else {
            largest = i;
        }
        if (r <= heapSize && A[r] > A[largest]) largest = r;
        if (largest != i) {
            swap(A, i, largest);
            maxHeapify(A, largest);
        }
    }
    void maxHeapInsert(int[] A, int key) {
        A[++heapSize] = Integer.MIN_VALUE;
        heapIncreaseKey(A, heapSize, key);
    }
    void heapIncreaseKey(int[] A, int i, int key) {
        if (key < A[i]) throw new RuntimeException("新しいキーは現在のキーより小さい");
        A[i] = key;
        while (i > 1 && A[parent(i)] < A[i]) {
            swap(A, i, parent(i));
            i = parent(i);
        }
    }
    int heapExtractMax(int[] A) {
        if (heapSize < 1) throw new RuntimeException("ヒープアンダーフロー");
        int max = A[1];
        A[1] = A[heapSize--];
        maxHeapify(A, 1);
        return max;
    }
    void swap(int[] A, int x, int y) {
        int temp = A[x];
        A[x] = A[y];
        A[y] = temp;
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,x; cin >> N >> x;
    if(x == 1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }
    else if(N == 2){
        cout << "Yes" << endl;
        cout << 1 << en << 2 << en << 3 << endl;
        return 0;
    }
    cout << "Yes" << endl;
    VI ans(2*N-1);
    if(x != 2){
        ans[N-2] = x-1; ans[N-1] = x; ans[N] = x+1; ans[N+1] = x-2;
        int n = 1;
        REP(i,N-2){
            while(x-2<=n && n<=x+1) n++;
            ans[i] = n++;
        }
        FOR(i,N+2,2*N-1){
            while(x-2<=n && n<=x+1) n++;
            ans[i] = n++;
        }
    }
    else{
        ans[N-2] = x+1; ans[N-1] = x; ans[N] = x-1; ans[N+1] = x+2;
        int n = 1;
        REP(i,N-2){
            while(x-1<=n && n<=x+2) n++;
            ans[i] = n++;
        }
        FOR(i,N+2,2*N-1){
            while(x-1<=n && n<=x+2) n++;
            ans[i] = n++;
        }
    }
    REP(i,2*N-1) cout << ans[i] << en;
    return 0;
}

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = (x2-x1); //xの変化
    int dy = (y2-y1); //yの変化
    int x3,x4,y3,y4;
    x3 = x2-dy;
    y3 = y2+dx; 
    x4 = x1-dy;
    y4 = y1+dx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

}



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

import fileinput
import math

def main():
    for line in fileinput.input():
        a, b = map(int, line.strip().split())

        intD = a / b
        intR = a % b
        floatD = float(a) / float(b)

        print('%d %d %lf' % (intD, intR, floatD))



if __name__ == '__main__':
    main()

Measured memory_bytes: 6508
#include <iostream>

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

void printArray(int *A, int n) {
  rep(i, n) {
    std::cout << A[i];
    if (i == n - 1)
      std::cout << '\n';
    else
      std::cout << ' ';
  }
}

int cnt = 0;

void merge(int *A, int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1], R[n2 + 1];
  rep(i, n1) L[i] = A[left + i];
  rep(i, n2) R[i] = A[mid + i];
  L[n1] = 1 << 30;
  R[n2] = 1 << 30;

  int l = 0, r = 0;
  for (int i = left; i < right; ++i) {
    cnt++;
    if (L[l] < R[r]) {
      A[i] = L[l];
      l++;
    } else {
      A[i] = R[r];
      r++;
    }
  }
}

void mergeSort(int *A, int n, int left, int right) {
  int cnt = 0;

  if (right - left <= 1)
    return;
  int mid = (left + right) / 2;

  mergeSort(A, n, left, mid);
  mergeSort(A, n, mid, right);
  merge(A, n, left, mid, right);
}

int main() {
  int n;
  std::cin >> n;
  int *S = new int[n];
  rep(i, n) std::cin >> S[i];

  mergeSort(S, n, 0, n);
  printArray(S, n);
  std::cout << cnt << '\n';
  return 0;
}



Measured memory_bytes: 6904
#-------------
N = int(input())
#-------------

C_list=[]

for i in range(26):
  for j in range(15):
    C_list.append(4*i + 7*j)

cnt = 0
for i in range(len(C_list)):
  if C_list[i] == N:
    cnt += 1

if cnt >= 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9100
#include <iostream>
#include <sstream>
#include <vector>

int compare_times = 0;

void my_merge(std::vector<int>& A, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    
    // create array L[0...n1], R[0...n2]
    std::vector<int> L(n1+1), R(n2+1);
    for(int i = 0; i < n1; i++){
	L.at(i) = A.at(left + i);
    }
    for(int i = 0; i < n2; i++){
	R.at(i) = A.at(mid + i);
    }
    const int SENTINEL = 1000000002;
    L.at(n1) = SENTINEL;
    R.at(n2) = SENTINEL;
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){
	compare_times++;
	if(L.at(i) <= R.at(j)){
	    A.at(k) = L.at(i);
	    i = i + 1;
	}else{
	    A.at(k) = R.at(j);
	    j = j + 1;
	}
    }
}

void my_merge_sort(std::vector<int>& A, int left, int right){
    if(left + 1 < right){
	int mid = (left + right) / 2;
	my_merge_sort(A, left, mid);
	my_merge_sort(A, mid, right);
	my_merge(A, left, mid, right);
    }
}

int main(int argc, char **argv){

    int n;
    std::cin >> n;

    std::vector<int> A(n);
    for(int i = 0; i < n; i++){
	std::cin >> A.at(i);
    }

    my_merge_sort(A, 0, A.size());

    std::stringstream ss;
    std::string sep = "";
    for(int i = 0; i < n; i++){
	ss << sep << A.at(i);
	sep = " ";
    }
    std::cout << ss.str() << std::endl;
    std::cout << compare_times << std::endl;
    
}



Measured memory_bytes: 15328
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
//
int main(){
    string s;
    cin >> s;
    ll ans = 0;
    for(int i = 0; i < (1 << s.length() - 1); i++){
        ll sum = 0;
        ll cur = 0;
        for(int j = 0; j < s.length(); j++){
            cur = cur * 10 + (s[j] - '0');
            if(i >> j & 1){
                sum += cur;
                cur = 0;
            }
        }
        sum += cur;
        ans += sum;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int n, m, q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A) {
    if (A.size()==n+1) {
        int now=0;
        rep(i,0,q) if (A[b[i]]-A[a[i]]==c[i]) now+=d[i];
        ans=max(ans,now);
        return;
    }

    A.push_back(A.back());
    while (A.back()<=m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a=b=c=d=vector<int> (q);
    rep(i,0,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int arr[n];
  for(int i=0;i<n;++i)
    cin>>arr[i];
  int total=0;
  for(int i=0;i<n;++i)
    total+=arr[i];
 if((total%(4*m))==0)
   total=total/(4*m);
  else 
    total=total/(4*m)+1;
  int cnt=0;
  for(int i=0;i<n;++i)
    if(arr[i]>=total)
      ++cnt;
  if(cnt>=m)
    cout<<"Yes";
  else cout<<"No";
  
  return 0;
}

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

#define int long long

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

//ダイクストラ法を用いて単一始点最短路問題を解く
const int MAX_V = 1100;
const double INF = 1e11;

struct edge {
    int to;
    double cost;
};
typedef pair<double, int> P;

int V;
vector<edge> G[MAX_V];
double d[MAX_V];
int xs, ys, xt, yt;
int N;
int x[1100], y[1100], r[1100];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

double dist(int x1, int y1, int x2, int y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

signed main() {
    cin >> xs >> ys >> xt >> yt >> N;
    V = N + 2;
    x[0] = xs, y[0] = ys, x[V - 1] = xt, y[V - 1] = yt;
    r[0] = r[V - 1] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            double d = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]);
            G[i].push_back({j, d});
            G[j].push_back({i, d});
        }
    }
    dijkstra(0);
    cout << setprecision(15) << d[V - 1] << endl;
}

Measured memory_bytes: 38964
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define mod 1000000007
typedef long long ll;
using namespace std;
int d[8][3]={
  {0,0,0},
  {0,0,255},
  {0,255,0},
  {0,255,255},
  {255,0,0},
  {255,0,255},
  {255,255,0},
  {255,255,255}
};
string ans[8]={
  "black",
  "blue",
  "lime",
  "aqua",
  "red",
  "fuchsia",
  "yellow",
  "white"
};
int F(char z){
  if('0'<=z&&z<='9')return z-'0';
  return 10+z-'a';
}
int main(){
  string s;
  while(cin>>s&&s!="0"){
    int a=F(s[1])*16+F(s[2]);
    int b=F(s[3])*16+F(s[4]);
    int c=F(s[5])*16+F(s[6]);
    int mini=mod,pnt;
    for(int i=0;i<8;i++){
      int dis=(d[i][0]-a)*(d[i][0]-a);
      dis+=(d[i][1]-b)*(d[i][1]-b);
      dis+=(d[i][2]-c)*(d[i][2]-c);
      if(dis<mini)mini=dis,pnt=i;
    }
    cout<<ans[pnt]<<endl;
  }
  return 0;
}

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

  int main() {
    int answer = 0;
    string S;
    cin >> S;
    if (S.at(0) == '1') {answer++;}
    if (S.at(1) == '1') {answer++;}
    if (S.at(2) == '1') {answer++;}
    cout << answer << endl;
  }

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100002];
  scanf("%s",s);
  int len=strlen(s);
  while(len>0){
    if(len>=6 && s[len-6]=='e' && s[len-5]=='r' && s[len-4]=='a' && s[len-3]=='s' && s[len-2]=='e' && s[len-1]=='r')
      len-=6;
    else if(len>=5 && s[len-5]=='e' && s[len-4]=='r' && s[len-3]=='a' && s[len-2]=='s' && s[len-1]=='e')
      len-=5;
    else if(len>=5 && s[len-5]=='d' && s[len-4]=='r' && s[len-3]=='e' && s[len-2]=='a' && s[len-1]=='m')
      len-=5;
    else if(len>=7 && s[len-7]=='d' && s[len-6]=='r' && s[len-5]=='e' && s[len-4]=='a' && s[len-3]=='m' && s[len-2]=='e' && s[len-1]=='r')
      len-=7;
    else{
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


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


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, l, t;
    bool first = 1;
    while (scanf("%d%d%d", &n, &l, &t) == 3) {
        if (first) first = 0;
        else printf("\n");

        vector<int> x(n), w(n);
        for (int i = 0; i < n; i++) {
            scanf("%d%d", &x[i], &w[i]);
            if (w[i] == 2) w[i] = -1;
        }

        int who = 0;
        for (int i = 1; i < n; i++) {
            if (w[i] != w[0]) {
                int full = t / l;
                who = (who + 2 * full * w[0] % n + n) % n;
                int dist = w[0] == 1 ? x[i] - x[0] : x[0] - x[i];
                if (dist < 0) dist += l;
                if (dist <= t % l * 2) who = (who + w[0] + n) % n;
                if (t % l * 2 >= dist + l) who = (who + w[0] + n) % n;
            }
        }
        for (int i = 0; i < n; i++) {
            x[i] = ((ll)x[i] + w[i] * t % l + l) % l;
        }
        int pos = x[0];
        sort(x.begin(), x.end());

        int id = lower_bound(x.begin(), x.end(), pos) - x.begin();
        if (id + 1 < n && x[id + 1] == pos && w[0] == 1) id++;

        vector<int> ans(n);
        for (int i = 0; i < n; i++) ans[(who + i) % n] = x[(id + i) % n];

        for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
    }


    return 0;
}

Measured memory_bytes: 2304
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll MOD = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

void print(vector<pair<ll, ll> > v) {
    ll i;
    fo(i, v.size()) {
        cout << v[i].first << " " << v[i].second << "\n";
    }
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t = 1;
//    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;
        ll h;
        cin>>h>>a;
        cout<<(ll)ceil(db(h)/a);

    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    solve();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 3648
n,a,b = gets.split.map(&:to_i)
ans = 0

for num in 1..n do
c = num.to_s.split("").map(&:to_i)
s = 0
c.each{ |i| s += i }
  if s >=a  && s <=b
    ans += num
  end
end
p ans

Measured memory_bytes: 2044