akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }

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

const int N = 1e5 + 20, M = 2e1 + 2;

int32_t main() {

    sync;
    
    int a, b; cin >> a >> b;
    cout << (b % a == 0 ? a + b : b - a) << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var read = Console.ReadLine();
                var temp_string = read.Split(' ');

                int H = int.Parse(temp_string[0]), W = int.Parse(temp_string[1]);

                if (H == 0 && W == 0)
                    break;

                for(int i=0;i<H;i++)
                {
                    for(int l=0;l<W;l++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }

        }
    }
}

Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

bool is_prime(int x){if(x<2)return false;for(int i=2;i*i<=x;++i)if(x%i==0)return false;return true;}

void solve() {
  VAR(int, Q);
  vi l(Q), r(Q);
  rep(i, 0, Q) {
    in(l[i], r[i]);
  }

  int minl = *min_element(all(l));
  int maxr = *max_element(all(r));

  vi v(maxr + 1);

  rep(i, minl, maxr + 1) {
    v[i] = v[i - 1];
    if (is_prime(i) && is_prime((i + 1) / 2)) {
      v[i]++;
    }
  }

  rep(i, 0, Q) {
    print(v[r[i]] - v[l[i] - 1]);
  }
}


Measured memory_bytes: 1792
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i!=j and j!=k and k!=i:
                if l[i]!=l[j] and l[k]!=l[j] and l[k]!=l[i]:
                    if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[k]+l[j]>l[i]:
                        ans+=1
print(ans//6)

Measured memory_bytes: 68340
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int n, k, to;

/*

map<vector<int>, int> memo;

int search(const vector<int> &a) {
  for (auto x : a) {
    cerr << x;
  }
  cerr << endl;
  auto m = memo.find(a);
  if (m != memo.end()) {
    return m->second;
  }
  if (count(a.begin(), a.end(), a[0]) == static_cast<int>(a.size())) {
    return 0;
  }
  int result = numeric_limits<int>::max();
  for (int i = 0; i + k <= n;) {
    vector<int> c = a;
    auto first = c.begin() + i;
    auto last = first + k;
    fill(first, last, to);
    if (a != c) {
      result = min(result, search(c) + 1);
    }
    if (i + (k - 1) + k <= n) {
      i += k - 1;
    } else {
      ++i;
    }
  }
  memo.insert(make_pair(a, result));
  return result;
}
*/

int main() {
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  cout << ((n - 1) + (k - 2)) / (k - 1) << endl;
  return 0;
}


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

class Combination{
	private:
		const static long long MOD = 1e9+7;
		const static long long MAX = 200100;
		vector<long long> fact;
		vector<long long> finv;
		vector<long long> inv;
	public:
		Combination() : fact(MAX),finv(MAX),inv(MAX){
			fact[0] = fact[1] = 1;
			finv[0] = finv[1] = 1;
			inv[1] = 1;
			for(int i=2;i<MAX;i++){
				fact[i] = fact[i-1] * i % MOD;
				inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
				finv[i] = finv[i-1] * inv[i] % MOD;
			}
		}

		long long nCk(long long n,long long k){
			if(n<k) return 0;
			if(n<0 || k<0) return 0;
			return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
		}

        long long com[200010];
        long long NnCk(long long n){
            com[0] = 1;
            com[1] = n;
            for(long long i=2;i<200010;i++){
                com[i] = (com[i-1] * (n-(i-1)) % MOD) * inv[i] % MOD;
            }
        }
};

long long modpow(long long a,long long n,long long p = 1e9+7){
    long long result = 1;
    while(n > 0){
        if(n & 1) (result *= a) %= p;
        (a*=a) %= p;
        n >>= 1;
    }
    return result;
}
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll mod = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    Combination C;
    C.NnCk(n);
    ll ans=modpow(2,n)-1;
    ans = ans - C.com[a] - C.com[b];
    while(ans<0) ans += mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int a = sc.nextInt();
        int p = sc.nextInt();

        Console.WriteLine((a * 3 + p) / 2);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
N = int(input())
L = [int(i) for i in input().split()]
import sys

if(0 in L):
    print(sum(list(map(abs,L))))
    sys.exit()

count=0
min=abs(L[0])
for i in range(N):
    if(L[i]<0):
        count+=1
    if(abs(L[i])<min):
        min=abs(L[i])

#print(count,min)

if(count%2==0):
    print(sum(list(map(abs,L))))
else:
    print(sum(list(map(abs,L)))-(2*min))

Measured memory_bytes: 14468
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if((a==b && b==c && c==a) || (a!=b && b!=c && c!=a))System.out.println("No");
        else System.out.println("Yes");
        sc.close();

    }

}


Measured memory_bytes: 23764
def calc_shift_count(num):
    shift_count = 0
    while True:
        if num % 2 == 0:
            num >>= 1
            shift_count += 1
        else:
            return shift_count


N = int(input())
num_list = [int(n) for n in input().split()]

shift_count = -1
for num in num_list:
    if shift_count == -1:
        shift_count = calc_shift_count(num)
    else:
        if num % (2 << shift_count) == 0:
            continue
        else:
            shift_count = min(shift_count, calc_shift_count(num))
    if shift_count == 0:
        break

print(shift_count)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	char str[500];
	int i,n;
	gets(str);
	for(i=0;str[i]!='\0';i++);
	for(n=0;n!=i/2;n++){
		if(str[n]!=str[i-n-1]) break;
	}
if(n==i/2)
	printf("Yes");
	else printf("No");
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
vector <int> a[MAXN];
int depth[MAXN], father[MAXN];
int n, m, tot, ans, x[MAXN], y[MAXN];
bool used[MAXN], ok[MAXN], res[MAXN];
int nowx[MAXN], nowy[MAXN], f[MAXN], g[MAXN];
void dfs(int pos, int fa) {
	depth[pos] = depth[fa] + 1;
	father[pos] = fa;
	for (auto x : a[pos])
		if (x != fa) dfs(x, pos);
}
void mark(int a, int b, int c, int d) {
	static int cnt[MAXN];
	memset(cnt, 0, sizeof(cnt));
	while (a != b) {
		if (depth[a] < depth[b]) swap(a, b);
		cnt[a]++, a = father[a];
	}
	while (c != d) {
		if (depth[c] < depth[d]) swap(c, d);
		cnt[c]++, c = father[c];
	}
	for (int i = 1; i <= n; i++)
		ok[i] |= cnt[i] >= 2;
}
void work(int pos, int fa) {
	for (int t=a[pos].size()-1;t>=0;--t)
		if (a[pos][t] != fa)work(a[pos][t], pos);
	if (pos != 1) {
		int cnt = 0;
		for (int i = 1; i <= tot; i++)
			if (!used[i]) cnt += (nowx[i] == pos) ^ (nowy[i] == pos);
		ans += min(max(cnt, ok[pos] * 2), 2);
		if (cnt <= 1 || ok[pos]) {
			for (int i = 1; i <= tot; i++)
				if (!used[i]) {
					if (nowx[i] == pos) nowx[i] = fa;
					if (nowy[i] == pos) nowy[i] = fa;
				}
			return;
		}
		vector <int> points;
		for (int i = 1; i <= tot; i++)
			if (!used[i] && ((nowx[i] == pos) ^ (nowy[i] == pos))) {
				points.push_back(i);
			}
		int a = points[0], b = points[1];
		mark(nowx[a], nowy[a], nowx[b], nowy[b]);
		used[a] = used[b] = true;
		tot++, f[tot] = -a, g[tot] = -b;
		if (nowx[a] == pos)x[tot] = y[a], nowx[tot] = nowy[a];
		else x[tot] = x[a], nowx[tot] = nowx[a];
		if(nowx[b] == pos)y[tot] = y[b], nowy[tot] = nowy[b];
		else y[tot] = x[b], nowy[tot] = nowx[b];
		for (int i = 1; i <= tot; i++)
			if (!used[i]) {
				if (nowx[i] == pos) nowx[i] = fa;
				if (nowy[i] == pos) nowy[i] = fa;
			}
	}
}
int main() {
	read(n), read(m), tot = m;
	for (int i = 1; i <= n - 1; i++) {
		int x, y; read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= m; i++) {
		read(x[i]), read(y[i]);
		nowx[i] = x[i];
		nowy[i] = y[i];
	}
	dfs(1, 0);
	work(1, 0);
	writeln(ans);
	for (int i = tot; i >= 1; i--) {
		if (!used[i]) res[i] = true;
		if (i > m) {
			int a = abs(f[i]), b = abs(g[i]);
			res[a] = res[i] ^ (x[i] != x[a]);
			res[b] = res[i] ^ (y[i] != y[b]);
		}
	}
	for (int i = 1; i <= m; i++)
		if (res[i]) printf("%d %d\n", x[i], y[i]);
		else printf("%d %d\n", y[i], x[i]);
	return 0;
}


Measured memory_bytes: 768
extern crate core;
use core::cmp::Ordering;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let si:String = read();
    let ti:String = read();
    let mut s:Vec<char> = si.chars().collect();
    let mut t:Vec<char> = ti.chars().collect();
    s.sort();
    t.sort();
    t.reverse();
    match s.cmp(&t) {
        Ordering::Less => println!("Yes"),
        _ => println!("No"),
    };
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <queue>

using namespace std;


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

	long long int sum = 0;
	for (int i = 1; i < N; i++)
	{
		sum += i;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
all_sum=sum(A)
tmp=0
tmp1=0
for i in A:
  if all_sum//2>tmp:
    tmp+=i
    tmp1=i
  else:
    break
if all_sum-tmp<(tmp-tmp1):
  print(abs(tmp1+all_sum-tmp-(tmp-tmp1)))
else:
  print(abs(tmp-abs(all_sum-tmp)))
  

Measured memory_bytes: 26220
#include<bits/stdc++.h>
using namespace std;
#define OUT(x) cout<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int c[51][51];
int memo[51][51];
int w,h;
int del(int x,int y){
  if(memo[x][y] != -1)return memo[x][y];
  else if(x<0 || y<0 || x==w || y== h)return 0;
  else if(c[x][y]){
    c[x][y] = 0;
    return memo[x][y] = del(x+1,y)+del(x,y+1)+del(x+1,y+1)+
      del(x-1,y-1)+del(x-1,y)+del(x,y-1)+del(x+1,y-1)+del(x-1,y+1);
    
  }
  else return 0;
}

int solve(int x,int y){
  if(x==0 && y == h)return 0;
  else if(x==w){
    return solve(0,y+1);
  }
  else if(c[x][y]){
    del(x,y);
    return solve(x+1,y)+1;
  }
  else return solve(x+1,y);
}

int main(){
  while(cin>>w>>h&&w&&h){
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> c[j][i];
      }
    }
    
    cout << solve(0,0) << endl;
  }
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
vector<ll> a(52),p(52);
ll k(int N,ll X){
    if(X==0) return 0;
    if(X==1) return (N==0)? 1:0;
    if(a[N]==X) return p[N];
    else if((a[N]+1)/2<X){
        ll res = p[N-1]+1;
        ll buf = X-a[N-1]-2;
        res+=k(N-1,buf);
        return res;
    }
    else if((a[N]/2)+1==X) return p[N-1]+1;
    else if(a[N]/2==X) return p[N-1];
    else return k(N-1, X-1);
}

int main(){
    int n;ll x;cin>>n>>x;
    a.resize(n+1),p.resize(n+1);
    a[0]=p[0]=1;//aはバーガーの総数 pはばてぃの総数
    rep(i,n){
        a[i+1]=2*a[i]+3;
        p[i+1]=2*p[i]+1;
    }
    ll res=k(n,x);
    cout<<res<<endl;
}



Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split())) 

S1 = 0
S2 = 0
ans = 10**18

for i in range(N):
    S1 = W[:i+1]
    S2 = W[i+1:]
    ans = min(ans, abs(sum(S1)-sum(S2)))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int v=1000;int n,m,a,b,s,q[v][v];
int main()
{
	cin>>n>>m>>a>>b;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;s+=q[i][j]=(i%a||j%b)?v:-(a*b-1)*v-1,j++);
	if(s<=0)return 0&puts("No");puts("Yes");
	for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)cout<<q[i][j]<<" ";puts("");
	}
}


Measured memory_bytes: 3584
//dwango5_b.cpp
//Sat Sep 21 09:19:23 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
	}

	vector<ll> beaut;
	for (int i=0;i<n;i++){
		ll tempsum = 0;
		for (int j=i;j<n;j++){
			tempsum = tempsum+a[j];
			beaut.push_back(tempsum);
		}
	}

	ll ans = 0;
	for (int i=40;i>=0;i--){
		int count = 0;
		ll check = 1LL<<i;
		for (int j=0;j<beaut.size();j++){
//			cout << (beaut[j] & (ans+check)) << endl;
			if ((beaut[j] & (ans+check)) == (ans+check)){
				count++;
				if (count == k){
					ans += check;
					break;
				}
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 6384
#include<iostream>                          
#include<vector>                    
 #include<bits/stdc++.h>

#define mod 998244353
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p; 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int
using namespace std;
ll z;
ll a[500005],n;
vector<ll>v; 
// cout<<"CASE #"<<z<<": "<<""<<endl;
void solve() 
{ 
  ll s,d,t;
  cin>>d>>t>>s;
  if(s*t>=d)
  cout<<"Yes";
  else
  cout<<"No";
}
 
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=1;
//cin>>t;
for(z=1;z<=t;z++)
solve();
 
return 0;
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, r := nextInt(), nextInt()
	if n >= 10 {
		fmt.Println(r)
		return
	} else {
		fmt.Println(r + 100*(10-n))
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll h;
  cin >> h;

  ll ans = 0;
  ll cnt = 1;
  while (h > 1) {
    h /= 2;
    ans += cnt;
    cnt *= 2;
  }
  ans += cnt;
  cout << ans << endl;
}


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

const ll mod = 1e9 + 7;
const int Inf = 1e9 + 5;
vector<int> phi;

void phi_1_to_n(int n) {
    phi[0] = 0;
    phi[1] = 1;
    for (int i = 2; i <= n; i++)
        phi[i] = i - 1;

    for (int i = 2; i <= n; i++)
        for (int j = 2 * i; j <= n; j += i)
              phi[j] -= phi[i];
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int m = n / i;
        ans += 1LL * i * m * (m + 1) / 2LL;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if(a>b)
        cout << 0 << endl;
        else if(n==1&&a!=b)
            cout << 0 << endl;
            else{
                cout << (a + b * (n - 1)) - (a * (n - 1) + b) + 1 << endl;
            }
            return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int read()
{  int f=1,x=0;
   char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x = x * 10 + ch - '0';
   return x*f;
}
int n,a[200005],x;
map<int,int>m;
int main()
{     cin>>x>>n;
      for(int i=1;i<=n;i++)
        {  int y;
           cin>>y;
           m[y]=1;
        }
      int i=0,ans;
      while(1)
      {   if(m[x-i]==0)
          {  ans=x-i;
              break;
          }
          if(m[x+i]==0)
          {  ans=x+i;
              break;
          }
          i++;
      }
      cout<<ans;
      return 0;
}

Measured memory_bytes: 3644
/*
    Problem 11
    https://atcoder.jp/contests/abc128/tasks/abc128_c
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = 10;
/* global variables */
vector< vector<int> > swiches(MAX, vector<int>(MAX, 0));
vector<bool> on(MAX);
vector<int> reminder(MAX);
/* function */
void init_light() { for (int i = 0; i < MAX; i++) on[i] = false; }
/* main */
int main(){
    int N, M, K, s;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> K;
        for (int j = 0; j < K; j++) {
            cin >> s;
            s--;
            swiches[i][s] = 1;
        }
    }
    for (int i = 0; i < M; i++) cin >> reminder[i];

    int ans = 0;
    int cnt_on, cnt_light;
    int upper = pow(2, N);
    for (int b = 0; b < upper; b++) {
        bitset<10> bs(b);
        init_light();
        for (int i = 0; i < N; i++) {
            if ((bs >> i)[0]) on[i] = true;
        }
        cnt_light = 0;
        for (int i = 0; i < M; i++) {
            cnt_on = 0;
            for (int j = 0; j < N; j++)
                if (on[j] && swiches[i][j]) cnt_on++;
            cnt_on %= 2;
            if (cnt_on == reminder[i]) cnt_light++;
        }
        if (cnt_light == M) ans++;
    }

    cout << ans << '\n';
}

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

abc = list('abcdefghijk')


def solve(ans):
    if len(ans) == n:
        print(*ans, sep='')
    else:
        idx = max([abc.index(ans[i]) for i in range(len(ans))])
        for i in range(idx+2):
            nans = ans + [abc[i]]
            solve(nans)


solve(['a'])

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

vector<int> A,B;
map<tuple<int,int,int,int,bool,int>,int > dp;
int N,M;

//-1が連続しているときに対応できてない気がする

//aのindex, bのindex, スタックに積まれたaのsum, スタックに積まれたbのsum, Aのターンか, 何回パスしたか
int dfs(int a, int b, int a_sum, int b_sum, bool aturn, int passed){
		if( dp.count(make_tuple(a,b,a_sum,b_sum,aturn,passed)) ){
				return dp[make_tuple(a,b,a_sum,b_sum,aturn,passed)];
		}

		//passed==2になった時点でゲーム終了(連続して二人がパスする)

		//現在のターンの者はpassするか, カードをスタックに積むか選べる
		int passed_score = 0, piled_score = 0;


		if(aturn){
				if(passed == 2){
						//ゲーム終了するか取るか選べる
						passed_score = 0;

				}else{
						//パスした場合
						passed_score = dfs(a,b,0,0,false,passed+1) + (a_sum-b_sum);
				}
				//スタックに積んだ場合
				if(a<N){
						if(A[a]==-1){
								piled_score = dfs(a+1, b, a_sum, 0, false, 0);
						}else{
								piled_score = dfs(a+1, b, a_sum+A[a], b_sum, false, 0);
						}
				}else{//a==Nのとき、パスしかできねえ
						piled_score = passed_score;
				}


		}else{
				if(passed == 2){
						//ゲーム終了するか取るか選べる
						passed_score = 0;
				}else{
						//パスした場合
						passed_score = dfs(a,b,0,0,true,passed+1) + (a_sum-b_sum);
				}
				//スタックに積んだ場合
				if(b<M){
						if(B[b]==-1){
								piled_score = dfs(a, b+1, 0, b_sum, true, 0);
						}else{
								piled_score = dfs(a, b+1, a_sum, b_sum+B[b], true, 0);
						}
				}else{//b==Mのとき、パスしかできねえ
							piled_score = passed_score;
				}

		}
		//cout << passed_score << " " << piled_score << endl;
		if(aturn) return dp[make_tuple(a,b,a_sum,b_sum,aturn,passed)] = max(passed_score, piled_score);
		else return dp[make_tuple(a,b,a_sum,b_sum,aturn,passed)] = min(passed_score, piled_score);
}

signed
main(){
		cin >> N >> M;
		A = vector<int>(N);
		B = vector<int>(M);

		for(int i=0;i<N;i++)
				cin >> A[i];
		for(int i=0;i<M;i++)
				cin >> B[i];

		cout << dfs(0, 0, 0, 0, true, 0) << endl;

}


Measured memory_bytes: 17536
let counter = ref 0

let merge (array : int array) left mid right =
  let init n p = Array.init (n+1) (fun i -> if i=n then max_int else array.(p+i)) in
  let xs = init (mid-left) left in
  let ys = init (right-mid) mid in
  let rec loop i j k =
    if k < right then
      (incr counter;
       if xs.(i) <= ys.(j) then (array.(k) <- xs.(i); loop (i+1) j (k+1))
       else (array.(k) <- ys.(j); loop i (j+1) (k+1)) )
  in loop 0 0 left
          
let rec msort (array : int array) left right =
  if left+1 < right then
      let mid = (left+right)/2 in
      msort array left mid;
      msort array mid right;
      merge array left mid right
            
let () =
    let n = (read_int ()) - 1 in
    let (l : int array) = Array.init (n+1) (fun _ -> Scanf.scanf "%d " (fun x -> x)) in
    msort l 0 (n+1);
    Array.iteri (fun i v -> Printf.printf (if i = n then "%d\n" else "%d ") v) l;
    Printf.printf "%d\n" !counter

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

struct node {
  int key;
  struct node *next;
};
typedef struct node * NodePointer;

void listinitialize(void);
void push(int);
int pop(void);
void print_stack(void);
int isempty(void);

NodePointer head, tail;

int main(){
  
  char s[1000];
  int temp1,temp2;
  int x;
  
  listinitialize(); 
  
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      temp1=pop();
      temp2=pop();
      push(temp1+temp2);
    }else if(s[0] == '-'){
      temp1=pop();
      temp2=pop();
      push(temp2-temp1);
    }else if(s[0] == '*'){
      temp1=pop();
      temp2=pop();
      push(temp1*temp2);
    }else{
      x=atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

void listinitialize(void){
  head = malloc(sizeof(struct node));
  tail = malloc(sizeof(struct node));

  head->next = tail;
  tail->next = tail;
}

void push(int key){
    NodePointer x;
  
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = head->next;
  head->next = x;  
}
int pop(){

  int x;
  NodePointer n;

  if(!isempty()){
    x=head->next->key;
    n=head->next;
    head->next = n->next;
    free(n);
  }else{
    printf("stack is empty\n");
    exit(1);
  }
  
  return x;
}
int isempty(){
  if(head->next == tail){
    return 1;
  }else{
    return 0;
  }
}
void print_stack(){
    NodePointer n;

  n = head->next;
  while (n != tail) {
    printf("%d ", n->key);
    n = n->next;
  }
  printf("\n");
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>

using namespace std;

int ds(int x, int y) {
	for (int i = 1; i < y;i++) {
		x /= 10;
	}

	int digit = x % 10;

	return digit;
}

int main() {


	int a, b;
	cin >> a >> b;
	int count = 0;

	for (int i = a; i <= b; i++) {

		if (ds(i, 1) == ds(i, 5) && ds(i, 2) == ds(i, 4)) {
			count++;
		}


	}

	cout << count << endl;

return 0;
}




Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right 

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

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

result = 0
for i in range(N+1):
  if a[i]>K:
    break
  j = bisect_right(b, K-a[i])
  result = max(result, i + j -1)
print(result)

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

const int maxN = 1e5 + 5;
int a[maxN], N;
int myabs(int val) {
	return (val < 0) ? -val : val;
}
int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + N);
	int val = a[1], mid = (a[N] + 1) / 2;
	for(int i = 2; i < N; ++i) 
		if(abs(mid - val) > abs(mid - a[i])) val = a[i];
	printf("%d %d\n", a[N], val);
	return 0;
}

Measured memory_bytes: 640
a,b,c = map(int,input().split())
count = 0
temp_a = 0
temp_b = 0
temp_c = 0
init_a = a
init_b = b
init_c = c
while True:
    if a==init_a and b==init_b and c==init_c and count!=0:
        count = -1
        break
    elif a%2==0 and b%2==0 and c%2==0:
         temp_a = a/2
         temp_b = b/2
         temp_c = c/2
         a = temp_b+temp_c
         b = temp_a+temp_c
         c = temp_a+temp_b
         count += 1
    else:
        break
print(count)


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

int main(){
	int n,a[25],i,b,c,on;
	while(cin >> n && n){
		for(i = 0;i < n;i++){
			cin >> b;
			a[i] = b;
		}
		b = c = 0;
		on = 32;
		while(1){
			on -= ((on - 1) % 5);
			cout << on << endl;

			if(a[c] < on) {
				on -= a[c];
				cout << on << endl;
			}
			else {
				on = 0;
				cout << on << endl;
			}
			c++;
			if(c == n) c = 0;
			if(on == 0) break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
n, y =map(int, input().split())
for a in range(min(n + 1 , y // 10000 + 1)):
    b = (-9000 * a + y -1000 * n) / 4000
    if (b >=0 and a + b <= n and b.is_integer()):
        print(a,int(b),int(n-a-b))
        break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll = pair<ll,ll>;
using Graph = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
#define dup(x,y) (((x)+(y)-1)/(y)) // x/yの除算の切り上げ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007; //1000000007
const ld pi = acos(-1);
 
//xor演算
//a^b=b^a
//a^(b^c)=(a^b)^c
//a^a=0
//a+b=a^b + 2(a&b)
//(4a)^(4a+1)^(4a+2)^(4a+3)=0
 
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i];
    }
    ll ans=0;
    for(int i=0; i<n-m+1; i++){
        for(int j=0; j<n-m+1; j++){
            ll x=0;
            rep(k,m){
                if(b[k]==a[j+k].substr(i,m)){
                    x++;
                }
                else{
                    break;
                }
            }
            if(x==m){
                ans=1;
                break;
            }
        }
        if(ans==1) break;
    }
    if(ans==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main{
    class Card{
        int a;
        int b;
        Card(int a, int b){
            this.a = a;
            this.b = b;
        }
    }
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int[] card_num = new int[101];
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            Card[] cards = new Card[m];
            for(int i = 0; i < m; i++){
                cards[i] = new Card(sc.nextInt(), sc.nextInt());
            }
            int ub = 7*100*10;
            int[] dp = new int[ub];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 7 * 100 * 10 - cards[i].a -1; ii >= 0; ii--){
                    for(int iii = 1; iii <= cards[i].b; iii++){
                        if(ii + cards[i].a*iii < ub-1){
                            dp[ii + cards[i].a*iii] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

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

int main(){

    int a;
    char buf[30];
    
    fgets(buf,sizeof(buf),stdin);
    a=atoi(buf);

    if(a<1 || a>10){
        return 1;
    }
    printf("%d\n",a+a*a+a*a*a);

    return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define each(i,a) for(auto&&i:a)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const vector<ll> four={0,1,0,-1,0};
using tuplis=pair<ll,pair<ll,ll>>;
template<class T>using pq=priority_queue<T,vector<T>,greater<T>>;
template<class T>inline constexpr bool update_min(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline constexpr bool update_max(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}





signed main(){
    int n;
    cin>>n;
    vector<int> bits(n);
    vector<vector<ll>> f(n,vector<ll>(10)),p(n,vector<ll>(11));//p(n,vector<ll>(10));
    ll ans=-1e18;
    rep(i,0,n){
        rep(j,0,10){
            cin>>f[i][j];
        }
    }
    rep(i,0,n){
        //rep(j,0,10){
        rep(j,0,11){
            cin>>p[i][j];
        }
    }
    rep(i,0,n) rep(j,0,10) bits[i] |= (f[i][j]<<(9-j));
    //rep(bit,0,(1<<n)){
    rep(bit,1,1<<10){
        ll cnt=0;
        rep(i,0,n){
            ll k=bit;
            k&=bits[i];
            cnt+=p[i][ __builtin_popcount(k) ];
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}





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

using namespace std;

struct Data {
    int x, y, z;
};

vector<Data> v;

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

    int l;
    cin >> l;
    int r;
    for(int bit = 19; bit >= 0; bit --) {
        if(l & (1 << bit)) {
            r = bit;
            break;
        }
    }

    int n = r + 1;
    for(int i = 2; i <= n; i ++) {
        v.push_back({i - 1, i, 0});
        v.push_back({i - 1, i, (1 << (i - 2))});
    }

    l -= (1 << r);
    int oldsum = 1 << r;
    for(int bit = 19; bit >= 0; bit --) {
        if(l & (1 << bit)) {
            v.push_back({bit + 1, n, oldsum}); /// de verificat de ce pana la n
            oldsum += (1 << bit);
        }
    }

    cout << n << " " << v.size() << "\n";
    for(auto it : v)
        cout << it.x << " " << it.y << " " << it.z << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int s,cnt=1;
    cin >> s;
    map <int,int> m;
    while(true){
        m[s]++;
        if(m[s]==2) break;
        s=(s%2==0?s/2:3*s+1);
        cnt++;
    }
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector <long long> sum(10000009);
  sum[1]=1;
  for(int i=2;sum[i]<=10000000;i++){sum[i]=sum[i-1]+i;}
  int cnt;
  for(int i=2;sum[i]<=10000000;i++){
    if(sum[i]>=N){cnt=i; break;}
  }
  for(int i=cnt;i>=1;i--){
    if(N>=i){N-=i; cout << i << endl;}
    if(N==0){break;}
  }
}

Measured memory_bytes: 78336
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n; cin>>n;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    int m;
    cin >> m;
    rep(i, m){
        int p, x;
        cin >> p >> x;
        p--;
        int res = 0;
        rep(i,n){
            if(i==p)
                res += x;
            else
                res += t[i];
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
#define ll long long
#define inf 0x3f3f3f3f

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int unsigned long long

using namespace std;

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

    auto v = vector<int>();

    for (size_t i = 1; i < sqrt(n) + 1; i++)
    {
        if (n % i == 0)
        {
            v.push_back(i + (n / i) - 2);
        }
    }

    cout << *min_element(v.begin(), v.end()) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
ll gcd(ll a, ll b) {
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
int main(){
	ll W, a, b;
	cin >> W >> a >> b;
	ll ans;
	if(b - a - W > 0 || a - b - W > 0){
		ans = min((abs)((int)(b - a - W)),(abs)((int)(a - b - W)));
		cout << ans << endl;
	} else {
		cout << 0 << endl;
	}
}

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

int main()
{
 string s,t;
  cin>>s>>t;
  int n= s.size();
  int cnt=0;
  for(int i=0;i<n;i++)
  {
   if(s[i]!=t[i]) cnt++;
  }
  cout<<cnt;
  return 0;
}

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

int main(){
    int n, k;
    cin>>n>>k;
    vector<int> in(n);
    for(int i=0; i<n; i++){
        cin>>in[i];
    }
    sort(in.begin(), in.end());
    int sum=0;
    for(int i=0; i<k; i++){
        sum+=in[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef long long ll;

int main()
{
	int A, B, flag = 0;
	char S[21];
	scanf("%d %d", &A, &B);
	scanf("%s", S);

	for (int i = 0; i <= A + B; i++) {
		if (i == A) {
			if (S[i] != '-') {
				flag = 1;
				break;
			}
		} else {
			if (!isdigit(S[i])) {
				flag = 1;
				break;
			}
		}
	}

	if (flag == 0)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
// Original: https://github.com/tanakh/competitive-rs
#[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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        a:i64,
        s:String
    }

    println!("{}", if a >= 3200 { s } else { "red".to_string() })
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
struct P{string a;int t,xh;}z,lins;
int op[]={1,4,-1,-4},sz[9];
map <string,int> dp;
bool qianj(P &zt,int f)
{

	return 1;
}
void bfs(){
	queue <P> que;
	que.push(z);
	while (!que.empty()){
		for (int i=0;i<4;i++){
			lins=que.front();
			int j,xh=lins.xh+op[i],sum=0;
			if (xh<0||xh>7||(lins.xh==3&&op[i]==1)||(lins.xh==4&&op[i]==-1)) continue ;
			swap(lins.a[lins.xh],lins.a[xh]);
//			cout<<lins.a<<endl;
			map <string,int>::iterator it=dp.find(lins.a);
			if (it != dp.end()) continue;//dp.count(lins.a)!=0
			lins.xh=xh;
			lins.t++;
			dp[lins.a]=lins.t;			
			que.push(lins);
		}
		que.pop();
	}
}
int main()
{
	int i,j;
	char c[9];
	z.a="01234567",z.xh=0,z.t=0;
	bfs();
//	printf("%d\n",dp.size());
	while (~scanf("%d",&sz[0]))
	{
		for (i=1;i<8;i++)
			scanf("%d",&sz[i]);
		for (i=0;i<8;i++)
			c[i]=sz[i]+'0';
		c[8]='\0';
		string S=c;
		printf("%d\n",dp[S]);
	}
	return 0;
}

Measured memory_bytes: 3476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		switch(n) {
		case 25 : System.out.println("Christmas");
		break;
		case 24 : System.out.println("Christmas Eve");
		break;
		case 23 : System.out.println("Christmas Eve Eve");
		break;
		case 22 : System.out.println("Christmas Eve Eve Eve");
		break;
		}
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	
	static Scanner scan;
	
	private static String[] arrayBubble;
	private static String[] arraySelect;
	private static int[] keyBubble;
	private static int[] keySelect;
	private static boolean stateBubble = true;
	private static boolean stateSelect = true;
	
	public static void BubbleSort(int[] key, int length) {
		for(int i = 0; i < length - 1; i++) {
			for(int j = length - 1; j >= i + 1; j--) {
				if(key[j] < key[j-1]) {
					swap(keyBubble, arrayBubble, j, j-1);
					if(key[j] == key[j-1]) stateBubble = false;
				}
			}
		}
	}
	
	private static void SelectionSort(int[] key, int length) {
		for(int i = 0; i < length - 1; i++) {
			int min = i;
			for(int j = i; j < length; j++) {
				if(key[j] < key[min]) min = j;
			}
			swap(keySelect, arraySelect, i, min);
			for(int j = 0; j < min; j++) {
				if(key[j] == key[min]) stateSelect = false;
			}
		}
	}
	
	public static void swap(int[] intArray, String[] stringArray, int i, int j) {
		int tmpi = intArray[i];
		String tmps = stringArray[i];
		intArray[i] = intArray[j];
		stringArray[i] = stringArray[j];
		intArray[j] = tmpi;
		stringArray[j] = tmps;
	}
	
	public static void printArray(String[] input) {
		for(int i = 0; i < input.length - 1; i++) {
			System.out.print(input[i] + " ");
		}
		System.out.println(input[input.length - 1]);
	}
	
	public static void printArray(int[] input) {
		for(int i = 0; i < input.length - 1; i++) {
			System.out.print(input[i] + " ");
		}
		System.out.println(input[input.length - 1]);
	}
	
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		
		// Get the value of input arrya's length
		final int length = scan.nextInt();
		final String[] array = new String[length];
		
		for(int i = 0; i < length; i++) {
			array[i] = scan.next();
		}
		
		// Get the input array, and copy to array "key" without character
		arrayBubble = new String[length];
		arraySelect = new String[length];
		keyBubble = new int[length];
		keySelect = new int[length];
		
		for(int i = 0; i < length; i++) {
			arrayBubble[i] = array[i];
			arraySelect[i] = array[i];
			keyBubble[i] = arrayBubble[i].charAt(1) - 48;
			keySelect[i] = arraySelect[i].charAt(1) - 48;
		}
		
		// Debug : output the array of elements
		BubbleSort(keyBubble, length);
		printArray(arrayBubble);
		if(stateBubble) System.out.println("Stable");
		else System.out.println("Not stable");
		SelectionSort(keySelect, length);
		printArray(arraySelect);
		if(stateSelect) System.out.println("Stable");
		else System.out.println("Not stable");
		
	}

}



Measured memory_bytes: 26424