akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

static const ll INF = 1e15;

static const ll mod = 1e9 + 7;

int main() {
	ll n;
	cin >> n;
	map<ll, ll> ms;
	ll sum = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		sum += a;
		ms[a]++;
	}
	int q;
	cin >> q;
	vector<ll> ans;
	rep(i, q) {
		ll b, c;
		cin >> b >> c;
		ll has = ms.count(b);
		if (has) {
			ll cs = ms[b];
			ms[c] += cs;
			ms.erase(b);
			sum += (c - b) * cs;
		}
		ans.push_back(sum);
	}
	rep(i, q) {
		cout << ans[i] << endl;
	}
	return 0;
}
	

Measured memory_bytes: 8100
inp = input().split()
max = int(inp[0])
mink = int(inp[1])
maxk = int(inp[2])
result = 0

for i in range(1,max+1):
    man = i // 10000
    sen = i % 10000 // 1000
    hyaku = i %1000 // 100
    ju = i % 100 // 10
    ichi = i % 10 
    keta = man + sen + hyaku + ju + ichi
    if mink <= keta:
    	if maxk >= keta:
    		result += i
print(result)
    

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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define MOD 1000000007

int main()
{
    speed;
    ll a,b;
    cin>>a>>b;
    cout<<max(a-b,max(a+b,a*b))<<endl;
    return 0;
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000000, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

bool ispali(string s)
{
    int n=s.size();
    //cout<<s<<"\n";
    for(int i=0;i<n;i++)
    {
        if((n-1-i)<=i)
        return true;
        if(s[i]!=s[n-1-i])
        return false;
    }
    return true;
}
int32_t main()
{
    IOS;
    string s;
    cin>>s;
    int n=s.size();
    string b="",a="";
    for(int i=0;i<((n-1)/2);i++)
    a+=s[i];
    for(int i=((n+1)/2);i<n;i++)
    b+=s[i];
    if(ispali(a)&&ispali(b)&&ispali(s))
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    int n, l;
    cin >> n >> l;
    vector<pair<int, int>> ps(n);
    for (auto &p : ps)
    {
        cin >> p.first >> p.second;
        p.first--;
    }
    sort(ps.begin(), ps.end());
    //i番目以降を全て右に寄せた時のスコア
    vector<long> rs(n + 1);
    for (int i = n - 1; i >= 0; i--)
    {
        int rbound = l - (n - 1 - i) - 1;
        if (ps[i].second)
        {
            rs[i] = rs[i + 1] + rbound - ps[i].first;
        }
        else
        {
            rs[i] = rs[i + 1] - rbound + ps[i].first;
        }
        //cout << rs[i] << ' ';
    }
    //cout << endl;
    long ans = max(0L, rs[0]), lscore = 0;
    for (int i = 0; i < n; i++)
    {
        if (ps[i].second)
        {
            lscore -= ps[i].first - i;
        }
        else
        {
            lscore += ps[i].first - i;
        }
        ans = max(ans, rs[i + 1] + lscore);
        //cout << lscore << ' ';
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem{

    void Solve() {
        UL N, M; cin >> N >> M;
        UL X; cin >> X;
        UL C[12];
        UL A[12][12];
        rep(i, N) {
            cin >> C[i];
            rep(j, M) cin >> A[i][j];
        }
        UL ans = 100000000;
        for (UL i = 0; i < (1 << N); i++) {
            UL buf[12] = {};
            UL tmp = 0;
            rep(j, N) {
                if (i & (1 << j)) {
                    tmp += C[j];
                    rep(k, M) buf[k] += A[j][k];
                }
            }
            bool ok = true;
            rep(j, M) if (buf[j] < X) ok = false;
            if (ok) { ans = min(ans, tmp); }
        }
        if (ans == 100000000) cout << -1 << endl;
        else cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
public class Main
{
	public static void main(String args[]) throws IOException{
		BufferedReader in = new BufferedReader();
		out(2*Math.PI*in.nextDouble()+"");
		
	}
	static void out(String s){
		System.out.print(s);
	}
}



class BufferedReader 
{ 
    java.io.BufferedReader br; 
    StringTokenizer st; 

    public BufferedReader() 
    { 
        br = new java.io.BufferedReader(new
                    InputStreamReader(System.in)); 
    } 

    public String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 

    public int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 

    public long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 

    public double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 

    public String nextLine() 
    { 
        String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}

Measured memory_bytes: 37176
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

const MOD: i64 = 1_000_000_007;

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b != 0 {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    } else {
        *x = 1; *y = 0;
    }
    d
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x = 0;
    let mut y = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

fn mod_fact(n: i64, p: i64, e: &mut i64, fact: &Vec<i64>) -> i64 {
    *e = 0;
    if n == 0 {
        return 1;
    }

    let res = mod_fact(n/p, p, e, fact);
    *e += n/p;
    if (n/p %2 != 0) {
        return res * (p - fact[(n%p) as usize]) % p;
    }
    res * fact[(n%p) as usize] % p
}

fn mod_comb(n: i64, k: i64, memo: &Vec<i64>) -> i64 {
    if n < 0 || k < 0 || n < k {
        return 0;
    }
    let a1 = memo[n as usize];
    let a3 = memo[(n-k) as usize];
    a1 * mod_inverse(a3, MOD) % MOD
}



fn dfs(graph: &Vec<Vec<usize>>, tar: usize, par: usize, k: usize, memo: &Vec<i64>) -> i64 {
    if graph[tar].len() > k-1 {
        return 0;
    }

    let mut result = mod_comb((k-2) as i64, (graph[tar].len()-1) as i64, memo);

    for x in graph[tar].iter() {
        if *x == par {
            continue;
        }
        result *= dfs(graph, *x, tar, k, memo);
        result %= MOD;
    }
    result
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let k = line[1];
    let mut graph = vec![Vec::new(); n];
    for i in 0..n-1 {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let a = line[0]-1;
        let b = line[1]-1;

        graph[a].push(b);
        graph[b].push(a);
    }
    let mut memo = vec![0i64; k+10];
    memo[0] = 1;
    memo[1] = 1;
    for i in 2..memo.len() {
        memo[i] = (memo[i-1] * (i as i64)) % MOD;
    }

    let mut ans = 1;
    if graph[0].len() > k-1 {
        ans = 0;
    } else {
        ans = (k as i64) * mod_comb((k-1) as i64, graph[0].len() as i64, &memo) % MOD;
        for x in graph[0].iter() {
            ans *= dfs(&graph, *x, 0, k, &memo);
            ans %= MOD;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 16252
import sys
input = sys.stdin.readline

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)


A, B = (int(i) for i in input().split())  
#a = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 

print(lcm(A, B))


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

int a, b, c;

int hantei(int i, int j, int k){
    if(a+b==c || a+c==b ||b+c==a){
        return 1;
    }else{
        return 0;
    }
}

int main (){
    cin >> a >> b >> c;
    if(hantei(a,b,c)==1){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,i,n;
	cin>>n;
	for(a=n;a<=100004;a++)
	{   bool flag=true;
		for(i=2;i*i<=a;i++)
		  if(a%i==0) {flag=false;break;}
		if(flag){cout<<a<<" ";return 0;}
	} 
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// @formatter:on


class ELogs {
public:
  
  bool ok(vi& a, double x, int k) {
    for (int d: a) {
      int curr = ceil(d / x) - 1;
      if (round(d / (k + 1)) > x) {
        curr++;
      }
      k -= curr;
    }
    return k >= 0;
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int low = 0, high = 1e9 + 1;
    int m;
    while (high - low > 1) {
      m = (low + high) / 2;
      if (ok(a, m, k)) {
        high = m;
      } else {
        low = m;
      }
    }
    cout << high << '\n';
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	ELogs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int x, y, z;
	cin >> x >> y >> z;

	cout << z << ' ' << x << ' ' << y;

	return 0;
}

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n, x, i, j, k;
            int total = 0;
            int cou = 0;

            while (true)
            {
                //整数受け取り
                string[] str = Console.ReadLine().Split(' ');
                n = int.Parse(str[0]);
                x = int.Parse(str[1]);
                
                //n, xが0の場合終了
                if (n == 0 && x == 0)
                {
                    break;
                }

                //判定
                for (i = 1; i <= n; i++)
                {
                    for (j = i + 1; j <= n; j++)
                    {
                        for (k = j + 1; k <= n; k++)
                        {
                            total = i + j + k;

                            if (total == x)
                            {
                                //Console.WriteLine(i + "+" + j + "+" + k + "=" + total);
                                cou++;
                            }
                            else
                            {
                                total = 0;
                            }
                        }
                    }
                }
                Console.WriteLine(cou);
                cou = 0;
            }
        }
    }



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

int main()
{
    int n,m;

    cin >> n;
    
    vector<string> s(n);
    int i;

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

    cin >> m;
    vector<string> t(m);
    for (i = 0; i < m; i++)
    {
        cin >> t[i];
    }
    
    int j;
    string say;
    int ans = 0;
    int count = 0;
    for (i = 0; i < n; i++)
    {
        count = 0;
        say = s[i];
        for (j = 0; j < n; j++)
        {
            if(say == s[j])count++;
        }
        for (j = 0; j < m; j++)
        {
            if(say == t[j])count--;
        }
        ans = max(ans,count);
    }

    cout << ans << endl;
}

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

int main(){
  int X,Y,Z;  cin >> X >> Y >> Z;

  int enb = 0;

  for(int i = 1;;i++){
    if(i * Y + (i + 1) * Z <= X)enb = i;
    else break;
  }

  cout << enb << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (){
   int n, i, j, minj, swap;
   int a[100] = {0};
   int count = 0;


   scanf("%d", &n);

   for(i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }

   for(i = 0; i < n; i++){
      minj = i;
      for(j = i; j < n; j++){
         if(a[j] < a[minj]){
            minj = j;
         }
      }
      if(i != minj){
         swap = a[i];
         a[i] = a[minj];
         a[minj] = swap;
         count++;
      }
   }

   for(i = 0; i < n; i++){
      if(i == n-1){
         printf("%d\n", a[i]);
      } else {
         printf("%d ", a[i]);
      }
   }
  
   printf("%d\n", count);

   return 0;
}

Measured memory_bytes: 1804
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
ans = 0 
mins = arr[0]
for i in arr:
    if i < mins :
        ans += mins - i  
        continue 
    if i > mins:
        mins = i 
print(ans)

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int n2 = (n-1)/2, n3 = (n+3)/2;
  string ret = "Yes";
  rep (i, n/2) {
    if (s.at(i) != s.at(n-1-i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (n!=3) {
  if (n2-1<2) {
    cout << "No" << endl;
    return 0;
  }
  rep (i, n2-1) {
    if (s.at(i) != s.at(n2-1-i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (n-n3<2) {
    cout << "No" << endl;
    return 0;
  }
  rep (i, n-n3) {
    if (s.at(i+n3-1) != s.at(n-1-i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    String S;

    private void solve() {
        S = next();
        S = S.replace("2017","2018");
        out.println(S);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  vector<int> A(N);
  for (auto& a : A) { cin >> a; }

  auto r = std::minmax_element(A.begin(), A.end());
  auto ans = *r.second - *r.first;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
// abc170_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int x,y;
  bool ok=false;
  cin>>x>>y;
  for (int i=0;i<=x;++i) {
    if (i*2+(x-i)*4==y) ok=true;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

void no() {
	cout << "No\n"; exit(0);
}

void yes() {
	cout << "Yes\n"; exit(0);
}


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

	int n, a, b, c, d;
	string s;

	cin >> n >> a >> b >> c >> d;
	cin >> s;
	s = ' ' + s;

	for (int i = b; i < d; ++i) {
		if (s[i] == '#' && s[i+1] == '#') no();
	}
	for (int i = a; i < c; ++i) {
		if (s[i] == '#' && s[i+1] == '#') no();
	}

	if (c < d) {
		yes();
	}

	for (int i = b; i <= d; ++i) {
		if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') yes();
	}

	no();
}

Measured memory_bytes: 720
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

#define MAX_S 10

// 入力
char s[MAX_S];

long long ans = 0;
long long arr[MAX_S] = {1, 11, 112, 1124, 11248, 112496, 1124992, 11249984, 112499968, 1124999936};

int main() {
    cin >> s;

    int le = strlen(s);
    for (int i = 0; i < le; ++i) {
        ans += arr[le - i - 1] * pow(2, i) * (s[i] - '0');
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

long int gcd(long int x,long int y)
{
	if(y==0)return x;
	else {return gcd(y,x%y);}
}

long int lcm(long int x,long int y)
{
	int i,j;
	for(i=1;;i++)
	{
		for(j=1;y*j<=x*i;j++)
		{
			if(x*i==y*j)return x*i;
		}
	}
}

int main()
{
	long int x,y;
	while(scanf("%ld %ld",&x,&y)!=EOF)
        {
	  printf("%ld %ld\n",gcd(x,y),lcm(x,y));
        }
	return 0;
}

Measured memory_bytes: 596
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int n, a, b;
	cin >> n >> a >> b;

	string s;
	cin >> s;

	int total = 0;
	int international = 0;

	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'a'){
			if (total < a + b){
				cout << "Yes" << endl;
				total++;
			} else {
				cout << "No" << endl;
			}
		} else if (s[i] == 'b'){
			if (total < a + b && international < b){
				cout << "Yes" << endl;
				total++;
				international++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}

} 


Measured memory_bytes: 896
def read():
    a, b = list(map(int, input().strip().split()))
    return a, b

def solve(a, b):
    A = str(a) * b
    B = str(b) * a
    return min(A, B)


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 2940
dp=[0]*31
dp[0]=1
for i in range(0,30):
    if i<30 :
        dp[i+1]+=dp[i]
    if i<29 :
        dp[i+2]+=dp[i]
    if i<28 :
        dp[i+3]+=dp[i]
while True:
    n=int(input())
    if n==0:
        break
    print((dp[n]//3650)+1)


Measured memory_bytes: 5600
#include<iostream>
#include<cstring>

int res[50];

void calc(int a, int b){
	if (a == 0){
		for (int i = 1; i < b; i++){
			if (i == b - 1)std::cout << res[i] << std::endl;
			else std::cout << res[i] << " ";
		}
		return;
	}
	for (int i = a; i >= 1; i--){
		if (res[b - 1] >= i){
			res[b] = i;
			calc(a - i, b + 1);
		}
	}
	return;
}


int main(){

	int n;
	while (std::cin >> n, n){
		memset(res, 0, sizeof(res));
		res[0] = 10000000;
		calc(n, 1);
	}

	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
int memo[N][2];
string s;

int solve (int i , bool b) {
    if (i == s.size())
        return 0;

    int &ret = memo[i][b];
    if (~ret)
        return ret;

    ret = 0;

    if (s[i] == 'P' || s[i] == '?')
        ret = solve(i + 1 , 0);

    if (s[i] == 'D' || s[i] == '?')
        ret = max(ret , solve(i + 1 , 1) + 1 + !b);

    return ret;
}

void print(int i , bool b) {
    if (i == s.size())
        return;

    if ((s[i] == 'P' || s[i] == '?') && solve(i + 1 , 0) == solve(i , b)) {
        cout << 'P';
        return print(i + 1 , 0);
    }

    cout << 'D';
    print(i + 1 , 1);
}

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

    cin >> s;

    memset(memo , -1 , sizeof memo);
    print(0 , 1);
}


Measured memory_bytes: 17832
#include<stdio.h>
int main(void){
	int i,hill;
	int max_1=0,max_2=0,max_3=0;
	
	for(i=1;i<=10;i++){
		scanf("%d",&hill);
		if(hill>max_1){
			max_3=max_2;
			max_2=max_1;
			max_1=hill;
		}
		else if(hill>max_2){
			max_3=max_2;
			max_2=hill;
		}
		else if(hill>max_3){
			max_3=hill;
		}
	}
	
	printf("%d\n%d\n%d\n",max_1,max_2,max_3);
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  string sa,sb,sc;cin>>sa>>sb>>sc;
  queue<char> qa,qb,qc;
  int i,j,k;
  for(i=0;i<sa.size();i++) qa.push(sa[i]);
  for(i=0;i<sb.size();i++) qb.push(sb[i]);
  for(i=0;i<sc.size();i++) qc.push(sc[i]);
  char ans='a';
  while(1){
    if(ans=='a'){if(qa.empty()) break;ans=qa.front();qa.pop();}
    if(ans=='b'){if(qb.empty()) break;ans=qb.front();qb.pop();}
    if(ans=='c'){if(qc.empty()) break;ans=qc.front();qc.pop();}
  }
  cout << (char)(ans+'A'-'a') << endl;
  return 0;
}



Measured memory_bytes: 256
INF = 10 ** 100
n = gets.to_i
x = gets.chomp

def popcount(num)
  num.to_s(2).count('1')
end

start_count = x.count('1')
plus = start_count + 1
plus_contribution = [1]
minus = start_count - 1
minus += 1 if minus == 0
minus_contribution = [1]
(n - 1).times do |i|
  plus_contribution.unshift(plus_contribution.first * 2 % plus)
  minus_contribution.unshift(minus_contribution.first * 2 % minus)
end

plus_default = 0
minus_default = 0
x.each_char.with_index do |c, i|
  next if c == '0'
  plus_default += plus_contribution[i]
  minus_default += minus_contribution[i]
end

x.each_char.with_index do |c, i|
  count = 1
  case c
  when '0'
    current = (plus_default + plus_contribution[i]) % plus
  else
    if start_count == 1
      puts 0
      next
    end
    current = (minus_default - minus_contribution[i]) % minus
  end
  until current == 0
    current %= popcount(current)
    count += 1
  end
  puts count
end

Measured memory_bytes: 18836
#include <iostream>

int main() {
  long long N;
  long long x;
  std::cin >> N >> x;
  long long min = x;
  for (int i = 1; i < 5; ++i) {
    std::cin >> x;
    if (x < min) {
      min = x;
    }
  }
  if (N % min == 0) {
    std::cout << N / min + 4 << "\n";
  } else {
    std::cout << N / min + 5 << "\n";
  }
  return 0;
}

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

enum COO{X, Y};

int main(){
	vector<bool> ansvec;

	for(;;){
		int N;
		cin >> N;
		if (N == 0) break;
		
		bool isGem[21][21] {{false}};
		for (int i = 0; i < N; i++){
			int x, y;
			cin >> x >> y;
			isGem[x][y] = true;
		}
		
		int M;
		cin >> M;
		int collect = 0;
		int now[2] = {10, 10}; // (x, y)
		for (int i = 0; i < M; i++){
			string d;
			int l;
			cin >> d >> l;
			for (int j = 1; j <= l; j++){
				if (d == "N" && isGem[now[X]][now[Y] + j]){
					collect++;
					isGem[now[X]][now[Y] + j] = false;
				}
				else if (d == "E" && isGem[now[X] + j][now[Y]]){
					collect++;
					isGem[now[X] + j][now[Y]] = false;
				}
				else if (d == "S" && isGem[now[X]][now[Y] - j]){
					collect++;
					isGem[now[X]][now[Y] - j] = false;
				}
				else if (d == "W" && isGem[now[X] - j][now[Y]]){
					collect++;
					isGem[now[X] - j][now[Y]] = false;
				}
			}

			now[X] += (d == "E" ? l : d == "W" ? -l : 0);
			now[Y] += (d == "N" ? l : d == "S" ? -l : 0);
		}
		ansvec.push_back(collect == N);
	}

	for (bool ans : ansvec){
		cout << ( ans == true ? "Yes" : "No" ) << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
use std::collections::VecDeque;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let s: Vec<Vec<_>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    let white: usize = s
        .iter()
        .map(|x| x.iter().filter(|&&c| c == '.').count())
        .sum();

    let mut queue = VecDeque::new();
    let mut check = vec![vec![false; w]; h];
    queue.push_back((0, 0, 0));

    while let Some((v, x, y)) = queue.pop_front() {
        if check[x][y] {
            continue;
        }
        check[x][y] = true;
        if x == h - 1 && y == w - 1 {
            println!("{}", white - v - 1);
            return;
        }

        for &(dx, dy) in [(-1, 0), (0, -1), (1, 0), (0, 1)].iter() {
            let nx = x as i32 + dx;
            let ny = y as i32 + dy;
            if 0 <= nx && nx < h as i32 && 0 <= ny && ny < w as i32 {
                if s[nx as usize][ny as usize] == '.' {
                    queue.push_back((v + 1, nx as usize, ny as usize));
                }
            }
        }
    }
    println!("-1");
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

const int MAX = 510000;//階乗の配列数
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  int n, a, b;
  cin >> n >> a >> b;
  ll ans=modpow(2, n, MOD)-1;
  COMinit();
  ll comna=finv[a];
  for(int i=n; i>=n-a+1; i--){
    comna*=i;
    comna%=MOD;
  }
  ll comnb=finv[b];
  for(int i=n; i>=n-b+1; i--){
    comnb*=i;
    comnb%=MOD;
  }
  ans+=MOD-comna;
  ans%=MOD;
  ans+=MOD-comnb;
  ans%=MOD;
  cout << ans <<endl;
  return 0;
}


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

#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    int x;
    cin >> x;
    if(x < 600) cout << 8 << endl;
    else if(x < 800) cout << 7 << endl;
    else if(x < 1000) cout << 6 << endl;
    else if(x < 1200) cout << 5 << endl;
    else if(x < 1400) cout << 4 << endl;
    else if(x < 1600) cout << 3 << endl;
    else if(x < 1800) cout << 2 << endl;
    else if(x < 2000) cout << 1 << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
//#define INF 1e9
using namespace std;

//자동 정렬은 ctrl k f
//주석은 ctrl k c
//주석 해제는 ctrl k u
// int gcd(int a, int b){
// 	while(b!=0){
// 		int r= a%b;
// 		a=b;
// 		b=r;
// 	}
// 	return a;
// }
// int lcm(int a, int b){
// 	return a*b/gcd(a,b);
// }
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int d, t, s;
	cin >> d >> t >> s;

	if (t*s >= d) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}



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

const long long mod = 1e9 + 7;

int main() {
	int n, c;
	cin >> n >> c;
	
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	static long long dp[402][402];

	dp[0][0] = 1;

	for (int i = 0; i < n; i++) {
		static long long sum[402];
		memset(sum, 0, sizeof(sum));
		for (int j = a[i]; j <= b[i]; j++) {
			long long prod = 1;
			for (int k = 0; k <= c; k++) {
				(sum[k] += prod) %= mod;
				(prod *= j) %= mod;
			}
		}
		for (int j = 0; j <= c; j++) {
			for (int k = 0; j + k <= c; k++) {
				(dp[i + 1][j + k] += dp[i][j] * sum[k]) %= mod;
			}
		}
	}

	cout << dp[n][c] << endl;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)

using namespace std;

int main() {

  string S;
  string T;
  int cnt = 0;
  cin >> S >> T;

  rep(i, 3) {
    if (S[i] == T[i]) cnt++;
  }

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

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,l = inpl()
s = [input() for i in range(n)]
s.sort()
print(''.join(s))

Measured memory_bytes: 38256
#include<stdio.h>
#include<string.h>

#define MAX_LENGTH 10
#define CHAR_MAX_LENGTH 10

int main(void)
{
        char line[MAX_LENGTH];
        char tmp;
        char ai[CHAR_MAX_LENGTH];
        int minus = 0;
        int i = 0;
        char *tp;
        int a;
        long sum = 0;
        int min = 1000000;
        int max = -1000000;

        fgets(line, sizeof(line), stdin); //skip line

        while (1) {
                tmp = getchar();
                if (tmp == '-') minus = 1;
                else if ( ( tmp == ' ' ) || ( tmp == '\n' ) ) {
                        ai[i] = '\0';
                        sscanf(ai, "%d", &a);
                        if (minus == 1) {
                                a *= -1;
                                minus = 0;
                        }
                        i = 0;
                        sum += a;
                        if( a < min) min = a;
                        if( a > max) max = a;
                        // do process
                } else {
                        ai[i] = tmp;
                        i++;
                }
                if (tmp == '\n') break;
        }
        printf("%d %d %ld\n", min, max, sum);

        return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  sort(all(A), greater<int>());
  ll ans = 0; int cnt = 0;
  REP(i, N / 2) {
    if(i == 0) ans += A[i];
    else ans += A[i] * 2;
  }
  if(N % 2 == 1) {
    ans += A[N / 2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4784
import java.util.*;
import java.lang.*;

/**
 * ExhaustiveSearch
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        boolean[] list = new boolean[20 * 2001];

        for (int i = 0; i < 1 << n; i++) { // 全てのパターン
            int tmp = 0;
            for (int j = 0; j < n; j++) { // j文字目を足し算に入れるかどうか
                if ((i & (1 << j)) != 0) { // j が bit に入るかどうか
                    tmp += a[j];
                }
            }
            list[tmp] = true;
        }

        int q = Integer.parseInt(sc.next());
        for (int i = 0; i < q; i++) {
            int num = Integer.parseInt(sc.next());
            if (list[num]) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }

        sc.close();
    }
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B;
    char c;
    cin >> A >> c >> B;
    cout << (c == '+' ? A+B: A-B) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, n;
    bool ok = false;

    cin >> N;

    for(int i=1; i<10; i++) {
        n = N/i;
        if(N==n*i && n<10) {
            ok = true;
        }
    }

    if(ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const vector<bitset<7> > digit =
{
    bitset<7>("1110111"),
    bitset<7>("0100100"),
    bitset<7>("1011101"),
    bitset<7>("1101101"),
    bitset<7>("0101110"),
    bitset<7>("1101011"),
    bitset<7>("1111011"),
    bitset<7>("0100101"),
    bitset<7>("1111111"),
    bitset<7>("1101111")
};

int getLightNum(int x, int n, vector<bitset<7> >::const_iterator trouble)
{
    int ans = 0;
    for(int i=0; i<n; ++i){

        ans += (digit[x%10] & ~trouble[n-1-i]).count();
        x /= 10;
    }
    return ans;
}

int main()
{

    int n, k;
    cin >> n >> k;
    vector<bitset<7> > trouble(14, 0);
    for(int i=0; i<k; ++i){
        int p, q;
        cin >> p >> q;
        trouble[p][q] = true;
    }

    vector<int> cnt(99);
    for(int h=0; h<24; ++h){
        for(int m=0; m<60; ++m){
            for(int s=0; s<60; ++s){
                int i = getLightNum(h, 2, trouble.begin() + 8 ) +
                        getLightNum(m, 2, trouble.begin() + 10) +
                        getLightNum(s, 2, trouble.begin() + 12);
                ++ cnt[i];
            }
        }
    }

    long long ans = 0;
    for(int y=0; y<10000; ++y){
        vector<int> days = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))
            ++ days[2];
        for(int m=1; m<=12; ++m){
            for(int d=1; d<=days[m]; ++d){
                int i = getLightNum(y, 4, trouble.begin()    ) + 
                        getLightNum(m, 2, trouble.begin() + 4) +
                        getLightNum(d, 2, trouble.begin() + 6);
                if(i <= n)
                    ans += cnt[n-i];
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    vector<vector<int>> x(M, vector<int>(3));

    int ref_min = INT32_MAX;
    rep(i, A)
    {
        cin >> a.at(i);
        if(a.at(i) < ref_min)
        {
            ref_min = a.at(i);
        }
    }
    int range_min = INT32_MAX;
    rep(i, B)
    {
        cin >> b.at(i);
        if(b.at(i) < range_min)
        {
            range_min = b.at(i);
        }
    }
    rep(i, M)
    {
        cin >> x.at(i).at(0) >> x.at(i).at(1) >> x.at(i).at(2);
    }

    int discount_min = INT32_MAX;
    rep(i, M)
    {
        int tmp = a.at(x.at(i).at(0) - 1) + b.at(x.at(i).at(1) - 1) - x.at(i).at(2);
        if(tmp < discount_min)
        {
            discount_min = tmp;
        }
    }

    if(discount_min <= (ref_min + range_min))
    {
        cout << discount_min << endl;
    }
    else
    {
        cout << (ref_min + range_min) << endl;
    }

}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
#define ll long long 
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
const ll mod=1000000007;
const int N=1e5+5;
int d[N],son[N],fa[N],n,k;
ll ans=1;
vector<int>e[N];
int dfs(int x,int f){
	fa[x]=f;
	for(int i=0;i<e[x].size();i++){
		int y=e[x][i];
		if(y==f)continue;
		son[x]++;
		dfs(y,x);
	}
}
int main(){
	n=read(),k=read();
	for(int i=1,u,v;i<n;i++){
		u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		int s=0;
		if(fa[i])s++;
		for(int j=1;j<=son[i];j++)ans=(ans*1ll*(k-j-s))%mod;
	}
	ans=ans*1ll*k;
	if(ans<=0)puts("0");
	else printf("%lld",ans%mod);
}


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

int N;
vector< string > sv;

void f( string a, int len, int m) {
//  cout << a << " " << len << " " << m << endl;
  REP(i,m+1) {
    string rs = a;
    rs += ('a' + i);
    if (len+1 < N ) {
      f(rs, len+1, max(m,i+1));
    } else {
      sv.push_back(rs);
    }
  }
  return;
}

int main(){
  cin >> N;
  string s;
  s = "";
  f( s, 0, 0);
  sort(sv.begin(), sv.end());
  for ( auto a : sv ) 
    cout << a << endl;
}


Measured memory_bytes: 7796