akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		LinkedHashMap<String, Integer> map = new LinkedHashMap<>();
		map.put("AC", 0);
		map.put("WA", 0);
		map.put("TLE", 0);
		map.put("RE", 0);
		while (n-- > 0) {
			String s = sc.next();
			map.put(s, map.get(s) + 1);

		}
		for (Map.Entry<String, Integer> m : map.entrySet()) {
			System.out.println(m.getKey() + " x " + m.getValue());
		}
	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

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

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

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

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

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

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

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

signed main(void)
{
	int a, b;
	cin >> a >> b;
	if (a == 1) a+=13;
	if (b == 1) b+=13;
	if (a > b)
		cout << "Alice" << endl;
	else if (a < b)
		cout << "Bob" << endl;
	else
		cout << "Draw" << endl;
	return 0;
}


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


int main() {
int N;
cin >> N;
set<int> se;
bool ans = true;
rep(i,N) {
    ll a;
    cin >> a;
    if (se.count(a)) ans = false;
    else se.insert(a);
}
if (ans) cout << "YES" << endl;
else cout << "NO" << endl;


return 0;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
ll dis[100005], val[100005], mx[100005], mx2[100005]; 
int main()
{
	// freopen("ARC096-D.in", "r", stdin); 
	int n;
	ll c; 
	scanf("%d%lld", &n, &c); 
	for (int i = 0; i < n; i++)
		scanf("%lld%lld", dis + i, val + i); 
	ll sum = 0, ans = 0; 
	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			mx[i] = mx[i - 1]; 
			mx2[i] = mx2[i - 1]; 
		}
		sum += val[i]; 
		mx[i] = std::max(mx[i], sum - dis[i]); 
		mx2[i] = std::max(mx2[i], sum - dis[i] * 2); 
		ans = std::max(ans, mx[i]); 
	}
	sum = 0; 
	for (int i = n - 1; i >= 0; i--)
	{
		sum += val[i]; 
		ans = std::max(ans, sum - (c - dis[i])); 
		if (i)
		{
			ans = std::max(ans, sum - (c - dis[i]) * 2 + mx[i - 1]); 
			ans = std::max(ans, sum - (c - dis[i]) + mx2[i - 1]); 
		}
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int a = kbd.nextInt();
        int b = kbd.nextInt();
        int c = kbd.nextInt();

        if (a < b) {
            if (a < c && c < b) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }else{
        if (a > c && c > b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;
int main()
{
  int n;
  cin >> n;

  int A[n];
  long long sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> A[i];
  }

  for (int i = 0; i < n; i++)
  {
    if (i > 0 && A[i] < A[i - 1])
    {
      sum += A[i - 1] - A[i];
      A[i] = A[i - 1];
    }
  }
  cout << sum << endl;

  return 0;
}


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

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

  for (int i=0 ; i < N ; i++){
    char S;
    cin >> S;
    if(S == 'Y'){
      cout << "Four" << endl;
      break;
    }
    if(i == N-1){
      cout << "Three" << endl;
    }
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n0 = count(s.cbegin(), s.cend(), '0');
    int n1 = count(s.cbegin(), s.cend(), '1');
    cout << 2 * min(n0, n1) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}
const ll MOD = 1000000007;

int main()
{
    int MAX = 100010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for(int i = 2; i < MAX; i++){
        if(!is_prime[i])continue;
        for(int j = i*2; j < MAX; j += i){
            is_prime[j] = 0;
        }
    }
    vector<int> a(MAX, 0);
    for(int i = 0; i < MAX; i++){
        if(i % 2 == 0)continue;
        if(is_prime[i] && is_prime[(i+1)/2])a[i] = 1;;
    }
    
    vector<int> s(MAX+1, 0);
    for(int i = 0; i < MAX; i++){
        s[i+1] = s[i]+a[i];
    }
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        int l, r;
        cin >> l >> r;
        ++r;
        cout << s[r]-s[l] << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

bool Solve() {
    int n, a;
    cin >> n;

    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        int p = 0;
        while (a % 2 == 0) {
            ++p;
            a /= 2;
        }
        t[i] = p;
    }

    if (n == 2) return (2 <= t[0] + t[1]);

    sort(t.begin(), t.end());

    const int size = t.size(), half = (size - 1) / 2;
    if (size % 2 == 0 && t[size - half - 1] + t[size - half - 2] < 2)
        return false;
    for (int i = 0; i < half; ++i) {
        int idx = size - i - 1;
        if (t[idx] + t[i] < 2) return false;
        if (t[idx] + t[i + 1] < 2) return false;
    }

    return true;
}

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

    if (Solve()) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	private static final int BIG_NUM  = 2000000000;
	private static final int MOD  = 1000000007;

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input_str[] = new String[2];

		Set<String> Dictionary = new HashSet<String>();
		StringBuilder ans = new StringBuilder();

		try {
			int Q = Integer.parseInt(br.readLine());

			for(int loop = 0; loop < Q; loop++){

				input_str = br.readLine().split("\\s+");

				if(input_str[0].equals("insert")){
					Dictionary.add(input_str[1]);
				}else{ //find
					if(Dictionary.contains(input_str[1])){
						ans.append("yes\n");
					}else{
						ans.append("no\n");
					}
				}
			}

			System.out.print(ans.toString());

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 324604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = n; i >= 0; i--)
#define For(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
template <class T = int> T in(){T x; cin >> x; return (x);}

int main(void){
    ll result = 0;
    
    vector<ll> antena;
    rep(i, 5){
        ll x = in();
        antena.push_back(x);
    }
    
    ll k = in();
    ll max = *max_element(ALL(antena));
    ll min = *min_element(ALL(antena));
    
    if(max - min > k){
        cout << ":(";
    }else{
        cout << "Yay!";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define forlist(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    cill(m);
    VVL table(10, VL(10));
    VI order;
    rep(i, m){
        cill(a);
        cill(b);
        table[a][b] = 1;
        table[b][a] = 1;
    }
    rep1(i, n+1) order.pb(i);
    LL ans=0;
    do {
        if(order[0]!=1) break;
        rep(i, n-1){
            if(table[order[i]][order[i+1]]==0){
                break;
            }
            if(i==n-2){
                ans++;
            }
        }
    } while (std::next_permutation(order.begin(), order.end()));
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
#define pb push_back
int n, k;
const int MAX_N = 1120, MAX_K = 14;
vector<int> primes;
int dp[MAX_N+1][MAX_K+1][200];

int rec(int an, int ak, int pidx) {
  if (an == 0 && ak == 0) return 1;
  if (an == 0 || ak == 0) return 0;
  
  if (dp[an][ak][pidx] >= 0) return dp[an][ak][pidx];
  
  // ツ素ツ青板づーツ使ツつ、
  int cnt = 0;
  for (int i = pidx; i < primes.size(); i += 1) {
    if (primes[i] > an) break;
    
    cnt += rec(an - primes[i], ak - 1, i+1);
  }
  return dp[an][ak][pidx] = cnt;
}

void solve() {
  memset(dp, -1, sizeof dp);
  cout<<rec(n, k, 0)<<endl;
}

void set_prime_list() {
  bool sieve[MAX_N];
  memset(sieve, true, sizeof sieve);
  
  for(int i=2;i<MAX_N;i++)
  if (sieve[i]) {
    primes.pb(i);
    for(int j=i+i;j<MAX_N;j+=i)
    sieve[j] = false;
  }
}

int main (int argc, char const* argv[]) {
  set_prime_list();
  
  while (cin>>n>>k, n||k) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL n;
    cin >> n;
    unordered_map<LL, LL> m_a;
    REP(i, n-1)
    {
        LL temp;
        cin >> temp;
        m_a[temp]++;
    }

    FOR(i, 1, n+1)
    {
        if(m_a.count(i) == 0)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << m_a.at(i) << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 11424
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

const int maxn = (int)1e5 + 555;

int n;
li l[maxn], r[maxn], b[maxn], X;
bool used[maxn];

void solve(bool __attribute__((unused)) read) {
    cin >> n >> X;
    set <pair <li, int> > q;
    li B = 0;
    for (int i = 0; i < n; ++i) {
        cin >> b[i] >> l[i] >> r[i];
        // b[i] = 0;
        B += l[i] * b[i];
        q.insert({-(r[i] * X - r[i] * b[i] + l[i] * b[i]), i});
    }
    li ans = 0;
    memset(used, 0, sizeof used);
    while (1) {
        int id = q.begin()->second;
        li val = (r[id] * X - r[id] * b[id] + l[id] * b[id]);
        if (val >= B)
            break;
        // cout << val << " " << id << endl;
        q.erase(q.begin());
        used[id] = 1;
        B -= val;
        ans += X;
    }
    li best = 1e9;
    for (int i = 0; i < n; ++i) {
        if (used[i])
            continue;
        li y = B / l[i] + (B % l[i] > 0);
        if (y <= b[i]) {
            best = min(y, best);
            continue;
        }

        li C = B - l[i] * b[i];
        y = C / r[i] + (C % r[i] > 0) + b[i];
        if (y <= X)
            best = min(y, best);
    }
    li ans1 = ans + best;

    int id = q.begin()->second;
    li val = (r[id] * X - r[id] * b[id] + l[id] * b[id]);
    q.erase(q.begin());
    used[id] = 1;
    B -= val;
    ans += X;

    // cout << B << endl;
    best = -1e9;
    li ans2 = ans1;
    for (int i = 0; i < n; ++i) {
        if (!used[i])
            continue;
        li C = -B;
        li y = C / r[i];
        if (y <= X - b[i])
            best = max(y, best);
        C = B + (r[i] * X - r[i] * b[i] + l[i] * b[i]);

        y = C / l[i] + (C % l[i] > 0);
        if (y <= b[i] && C >= 0) {
            ans2 = min(ans2, ans - X + y);
            continue;
        }     
    }
    ans2 = min(ans2, ans - best);



    cout << min(ans1, ans2) << "\n";
}

Measured memory_bytes: 8960
num = int(input())
list_i = list(map(int, input().split())) 
#b=min(i)-num
#b=max(i)-1
for j in range(num):
  list_i[j]=list_i[j]-j-1
list_i.sort()
b=list_i[int(num/2)]
sum=0
for i in range(num):
  sum +=abs(list_i[i]-b)
print(sum)

Measured memory_bytes: 26180
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,j,a[500005]={};
  string s;
  
  cin >> s;
  
  n=s.size()+1;
  
  for (i=0;i<n;i++){
    if ((i==0 || s[i-1]=='>') && (i==n-1 || s[i]=='<')){
      a[i]=0;
      j=i;
      while (j>0 && s[j-1]=='>' && a[j-1]<=a[j]){
        a[j-1]=a[j]+1;
        j--;
      }
      j=i;
      while (j<n-1 && s[j]=='<' && a[j+1]<=a[j]){
        a[j+1]=a[j]+1;
        j++;
      }
    }
  }
  
  ll sum=0;
  for (i=0;i<n;i++) sum+=a[i];
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 2820
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
 
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
 
ll power(ll x, unsigned long long y)
{
    ll res = 1;     // Initialize result
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x);
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}
 
void solve()
{
    ll n;
    cin >> n;
    for(ll i = -1000 ; i <= 1000; i++)
    {
        for(ll j = -1000 ; j <= 1000; j++)
        {
            if(power(i,5) - power(j,5) == n)
            {
                cout << i << " " << j << endl;
                return;
            }
//            else if(power(i,5) - power(-j,5) == n)
//            {
//                cout << i << " -" << j << endl;
//                return;
//            }
//            else if(power(-i,5) - power(j,5) == n)
//            {
//                cout << "-" << i << " " << j << endl;
//                return;
//            }
//            else if(power(-i,5) - power(-j,5) == n)
//            {
//                cout << "-" << i << " -" << j << endl;
//                return;
//            }
        }
    }
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

struct UnionFind {
    vector<int> ig;
    vector<vector<int>> gi;
    int gn;
    UnionFind(int N) {
        ig.resize(N); gi.resize(N);
        for (int i = 0; i < N; i++) {
            ig[i] = i; gi[i] = {i};
        }
        gn = N;
    }
    void merge(int a, int b) {
        if (same(a, b)) return;
        gn--;
        int x = ig[a], y = ig[b];
        if (gi[x].size() < gi[y].size()) swap(x, y);
        for (int j: gi[y]) {
            ig[j] = x;
        }
        gi[x].insert(gi[x].end(), gi[y].begin(), gi[y].end());
        gi[y].clear();
    }
    bool same(int a, int b) {
        return ig[a] == ig[b];
    }
};

int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n, q;
    cin >> n >> q;
    using T = tuple<ll, int, int, bool>;
    priority_queue<T, vector<T>, greater<T>> que;
    for (int i = 0; i < q; i++) {
        int a, b; ll c;
        cin >> a >> b >> c;
        que.push(T(c, a, b, false));
    }

    UnionFind uf(n);
    ll ans = 0;
    while (uf.gn > 1) {
        if (que.size() == 0) break;
        int a, b; ll c; bool f;
        tie(c, a, b, f) = que.top(); que.pop();
//        cout << a << " " << b << " " << c << endl;
        if (!uf.same(a, b)) {
            uf.merge(a, b);
            ans += c;
            que.push(T(c+1, b, (a+1)%n, false));
        } else {
            if (!f) {
                que.push(T(c+1, b, (a+1)%n, true));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19436
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef __int128_t ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long A, long double B) {
  ll b = (ll)((B * 100) + 0.0001);
  cout << (long long)(A * b / 100) << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long double B;
  scanf("%Lf", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  bool dm[10];
  for (int i = 0; i < 10; i ++) dm[i] = false;
  for (int i = 0; i < K; i ++) {
    int a;
    cin >> a;
    dm[a] = true;
  }
  vector<int>ca;
  for (int i = 0; i < 10; i ++) {
    if (!dm[i]) ca.push_back(i);
  }
  ca.push_back(100);
  int use[10];
  if (dm[9]) use[9] = -1;
  else use[9] = 9;
  for (int i = 8; i >= 0; i --) {
    if (dm[i]) {
      use[i] = use[i + 1];
    }
    else use[i] = i;
  }
  vector<int>num;
  int kj = N;
  while (kj) {
    num.push_back(kj % 10);
    kj /= 10;
  }
  int n = (int)num.size();
  bool c_1 = true;
  if (use[num[n - 1]] == -1) {
    //cout << 0 << ' ';
    cout << (ca[0] == 0 ? ca[1] : ca[0]);
    for (int i = 0; i < n; i ++) cout << ca[0];
    cout << endl;
    return 0;
  }
  if (use[num[n - 1]] != num[n - 1]) {
    //cout << 1 << ' ';
    cout << use[num[n - 1]];
    for (int i = 0; i < n - 1; i ++) cout << ca[0];
    cout << endl;
    return 0;
  }
  for (int i = 0; i < n; i ++) {
    if (use[num[i]] == -1) c_1 = false;
  }
  if (c_1) {
    //cout << 2 << ' ';
    for (int i = n - 1; i >= 0; i --) {
      cout << use[num[i]];
    }
    cout << endl;
    return 0;
  }
  if (use[num[n - 1] + 1] == -1) {
    //cout << 3 << ' ';
    cout << (ca[0] == 0 ? ca[1] : ca[0]);
    for (int i = 0; i < n; i ++) cout << ca[0];
    cout << endl;
    return 0;
  }
  //cout << 4 << ' ';
  cout << use[num[n - 1] + 1];
  for (int i = 0; i < n - 1; i ++) cout << ca[0];
  cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool C=false;
string s;
int main(){
    cin>>s;
    int len=s.size();
    for(int i=0;i<len;i++){
        if(s[i]=='C')C=true;
        if(C&&s[i]=='F'){
            printf("Yes\n");
            exit(0);
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int a1 = (a / 10) * 10;
    if((a % 10) != 0) a1 = (a / 10) * 10 + 10;
    int a2 = a1 - a;

    int b = sc.nextInt();
    int b1 = (b / 10) * 10;
    if((b % 10) != 0) b1 = (b / 10) * 10 + 10;
    int b2 = b1 - b;

    int c = sc.nextInt();
    int c1 = (c / 10) * 10;
    if((c % 10) != 0) c1 = (c / 10) * 10 + 10;
    int c2 = c1 - c;

    int d = sc.nextInt();
    int d1 = (d / 10) * 10;
    if((d % 10) != 0) d1 = (d / 10) * 10 + 10;
    int d2 = d1 - d;

    int e = sc.nextInt();
    int e1 = (e / 10) * 10;
    if((e % 10) != 0) e1 = (e / 10) * 10 + 10;
    int e2 = e1 - e;

    int s = Math.max(a2, Math.max(b2, Math.max(c2, Math.max(d2, e2))));
    int ans = a1 + b1 + c1 + d1 + e1 - s;
    
    System.out.println(ans);
  }
}

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

[A, B, K] = [int(i) for i in input().split()]

divisor = [1]
for i in range(2, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        divisor.append(i)


#print(divisor)
print(divisor[len(divisor) - K])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	int n;
	cin >> n;
	double *a = new double[n];
	double total, ave;
	REP(i, n){
		cin >> a[i];
		total += a[i];
	}
	ave = total/(double)n;
	int x = (int)ave;
	int ans1=0, ans2=0;
	REP(i, n){
		ans1+=pow(x-a[i], 2);
		ans2+=pow(x+1-a[i], 2);
	}
	cout << min(ans1, ans2) << '\n';


	delete[] a;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef int Data;
typedef vector<Data> Array;
typedef vector<Array> Matrix;

bool is_zero(Data dat) { return (abs(dat) < EPS); }

Matrix operator-(Matrix mat) {
	REP(i, mat.size()) REP(j, mat[0].size()) mat[i][j] = -mat[i][j];
	return mat;
}

Matrix operator+(Matrix lhs, const Matrix &rhs) {
	REP(i, lhs.size()) REP(j, lhs[0].size()) lhs[i][j] = lhs[i][j] + rhs[i][j];
	return lhs;
}

Matrix operator-(Matrix lhs, const Matrix &rhs) {
	REP(i, lhs.size()) REP(j, lhs[0].size()) lhs[i][j] = lhs[i][j] - rhs[i][j];
	return lhs;
}

Matrix operator*(const Matrix &lhs, const Matrix &rhs) {
	Matrix res(lhs.size(), Array(rhs[0].size(), 0));
	REP(i, lhs.size()) REP(j, rhs[0].size()) REP(k, rhs.size())
		res[i][j] = fma(lhs[i][k], rhs[k][j], res[i][j]);
	return res;
}

Array operator+(const Array &lhs, const Array &rhs) {
	Array res = lhs;
	REP(i, rhs.size()) res[i] = res[i] + rhs[i];
	return res;
}

Array operator*(const Matrix &lhs, const Array &rhs) {
	Array res(lhs.size());
	REP(i, lhs.size())
		res[i] = inner_product(begin(lhs[i]), end(lhs[i]), begin(rhs), Data(0));
	return res;
}

Array operator*(Data scalar, const Array &rhs) {
	Array res(rhs.size());
	REP(i, rhs.size())
		res[i] = scalar * rhs[i];
	return res;
}

bool gauss_jordan(const Matrix& A, const Array& b)
{
	int n = A.size();
	Matrix B(n, Array(n + 1));
	REP(i, n)REP(j, n) B[i][j] = A[i][j];
	REP(i, n) B[i][n] = b[i];
	REP(i, n)
	{
		int pivot = i;
		FOR(j, i + 1, n)
		{
			if (abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
		}
		swap(B[i], B[pivot]);

		REP(j, n)
		{
			if (i != j && B[j][i])
			{
				FOR(k, i + 1, n + 1) B[j][k] = (B[j][k] + B[i][k]) % 2;
			}
		}
	}
	Array x(n);
	REP(i, n) x[i] = B[i][n];
	REP(i, n)
	{
		int p = 0;
		REP(j, n)
		{
			if (A[i][j]) p = (p + x[j]) % 2;
		}
		if (p != b[i]) return false;
	}
	return true;
}

int main()
{
	int m, n, d;
	while (cin >> m >> n >> d, n)
	{
		Array s(n*m);
		Matrix mat(n*m, Array(n*m));
		REP(i, n*m)
		{
			int a; cin >> a;
			s[i] = a;
		}
		REP(i, n)REP(j, m)
		{
			int p = i*m + j;
			REP(k, n)REP(l, m)
			{
				int q = k*m + l;
				if (p == q || abs(i - k) + abs(j - l) == d) mat[p][q] = 1;
				else mat[p][q] = 0;
			}
		}
		if (gauss_jordan(mat, s)) puts("1");
		else puts("0");
	}
	return 0;
}

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

int main() {
    int n, m;
    int ml = 0, mr = 1000000;
    cin >> n >> m;
    //vector<pair<int,int>> l(m);

    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        //l.at(i) = make_pair(a,b);
        ml = max(ml,a);
        mr = min(mr,b);
    }

    //sort(l.begin(),l.end());
/*
    for(int i = l.at(m-1).first; i <= l.at(0).second; i++){
        cnt++;
    }
*/
    cout << max(mr-ml+1,0) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;
using Pll = pair<ll, ll>;

ll INF = 1LL << 60;

ll division(ll a, ll b) {
    if(a < 0) {
        return - ((-a + b - 1) / b);
    }
    return a / b;
}

ll modulo(ll a, ll b) {
    return ((a % b) + b) % b;
}

int main() {
    ll n, x, d;
    cin >> n >> x >> d;

    if(d == 0) {
        cout << ((x == 0) ? ll(1) : n+1) << endl;
        return 0;
    } else if(d < 0) {
        x *= -1;
        d *= -1;
    }

    map<ll, vector<Pll>> mp;
    for(ll i=0;i<=n;++i) {
        ll l = (i-1) * i / 2, r = (n-i) * i + l;
        mp[modulo(i*x, d)].emplace_back(division(i*x, d) + l, r - l + 1);
    }

    ll ans = 0LL;
    for(auto itr=mp.begin();itr!=mp.end();++itr) {
        vector<Pll> v(itr->second);
        sort(v.begin(), v.end());

        ll max_r = -INF;
        for(Pll p: v) {
            if(max_r < p.first) {
                ans += p.second;
            } else {
                ans += max(0LL, p.second - (max_r - p.first + 1));
            }
            max_r = max(max_r, p.first + p.second - 1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 22144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		for(double d = N;d > 0;d--){
			if((int)(d * 1.08) == N){
				System.out.println((int)d);
				return;
			}
		}
		System.out.println(":(");
	}
}

Measured memory_bytes: 21844
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<climits>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<string.h>
#include<algorithm>
#include<unordered_map>
#pragma GCC optimize "trapv"
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)
#define pp pair<int,pair<int,int>>
#define ppp pair<pair<int,int>,pair<int,int>>

const ll M=1e9,N=2e5+2;

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

void sieve(){
	bool prime[N+1];
	memset(prime,true,sizeof(prime));
	for(ll p=2;p*p<=N;p++){
		if(prime[p] == true){
			for(ll i=p*p;i<=N;i+=p)
				prime[i] = false;
		}
	}
}

ll power(ll x,ll y,ll p){
	ll res = 1;
	x = x%p;
	while(y > 0){
		if(y&1)
			res = (res*x)%p;
		y = y>>1;
		x = (x*x)%p;
	}
	return res;
}

int root(int i,int A[]){
	while(A[i] != i){
		A[i] = A[A[i]];
		i = A[i];
	}
	return i;
}

void unite(int a,int b,int A[],int B[]){
	int c = root(a,A);
	int d = root(b,A);
	if(c == d)
		return;
	if(B[c] < B[d]){
		A[c] = d;
		B[d] += B[c];
	}
	else{
		A[d] = c;
		B[c] += B[d];
	}
}

inline ll in()
{
	ll n=0;
	bool check=0;
	register char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-')
			check=1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		n = (n<<1)+(n<<3)+c-'0';
		c=getchar();
	}
	return n-2*n*check;
}

string ip()
{
    string i="";
    int temp=getchar();
    while(temp<'a'||temp>'z')
        temp=getchar();
    while(temp>='a'&&temp<='z')
    {
        i+=(char)temp;
        temp=getchar();
    }
    return i;
}

vector<int> V[N];
int P[N],H[N];
unordered_map<int,bool> U;
vector<pair<int,int>> B;

bool compare(pair<int,int> a,pair<int,int> b){
	return a.first > b.first;
}

int A[N];

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


	int k,n,maxi=0;
	cin>>k>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	A[n] = A[0]+k;
	for(int i=0;i<n;i++)
		maxi = max(maxi,A[i+1]-A[i]);
	cout<<k-maxi<<"\n";

	return 0;
}

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

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

const int MOD = 1e9+7;
const int MAX = 2e5+10;

int pow_(ll n, ll k) {
    ll res = 1;
    while (k) {
        if (k&1) res = (res * n) % MOD;
        n = n * n % MOD;
        k >>= 1;
    }
    return res;
}

int inv(int n) {
    return pow_(n, MOD-2);
}

int N;
vi edge[MAX], adj[MAX];

int make_tree(int n, int p) {
    int count_children = 0;
    FORE (c, edge[n]) if (c != p) {
        int cnt = make_tree(c, n);
        if (cnt > 0) adj[n].push_back(cnt);
        count_children += cnt;
    }
    if (N - count_children - 1 > 0) adj[n].push_back(N - count_children - 1);
    return count_children + 1;
}

int sub(int idx) {
    vi ad = adj[idx];
    if (ad.size() == 1) return 0;
    ll ret = (MOD + pow_(2, N-1) - 1) % MOD;
    FORE (a, ad) ret = (ret + MOD - pow_(2, a) + 1) % MOD;
    return ret;
}

int solve() {
    make_tree(0, -1);
    ll ans = 0;
    REP (i, N) ans = (ans + sub(i)) % MOD;
    return ans * inv(pow_(2, N)) % MOD;
}

int main() {
    cin >> N;
    REP (i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    cout << solve() << endl;
}

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

#define INF 0x7fffffff
#define ll  long long

int main() {
  int n;
  cin >> n;
  vector<ll> dpA(n+1),dpB(n+1),dpC(n+1);
  vector<ll> a(n+1), b(n+1), c(n+1);

  for(int i=1;i<=n;i++) {
    cin >> a[i] >> b[i] >> c[i]; 
  }

  dpA[1] = a[1];
  dpB[1] = b[1];
  dpC[1] = c[1];
  for(int i=2;i<=n;i++) {
    dpA[i] = max(dpB[i-1],dpC[i-1]) + a[i];
    dpB[i] = max(dpA[i-1],dpC[i-1]) + b[i];
    dpC[i] = max(dpA[i-1],dpB[i-1]) + c[i];
  }
  ll ans = max( max(dpA[n],dpB[n]) , dpC[n]);
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i = 0; i <= 3000; i++)
    for (int j = 0; j <= 3000; j++) {
      int v = i * R + j * G;
      if (N >= v && (N - v) % B == 0) ans++;
    }
  cout << ans << endl;
  return 0;
}


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

const int P = 1000000007;
const int N = 3200;
long long f[N][N];
long long inv2;
int n,q,a[N];
long long power(long long x,int k){
	long long ans=1;
	while(k){
		if(k&1)(ans*=x)%=P;
		(x*=x)%=P;
		k>>=1;
	}
	return ans;
}
int main(){
	inv2=power(2,P-2);
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(a[i]==a[j])continue;
			if(a[i]<a[j])f[i][j]++;
			if(a[j]<a[i])f[j][i]++;
		}
	}
	for(int i=1;i<=q;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==y)continue;
		long long tmp=(f[x][y]+f[y][x])*inv2%P;
		f[x][y]=tmp;
		f[y][x]=tmp;
		for(int i=1;i<=n;i++){
			if(i==x||i==y)continue;
			long long tmp=(f[x][i]+f[y][i])*inv2%P;
			f[x][i]=tmp;
			f[y][i]=tmp;
			tmp=(f[i][x]+f[i][y])*inv2%P;
			f[i][x]=tmp;
			f[i][y]=tmp;
		}
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)(ans+=f[i][j])%=P;
	cout << ans*power(2,q)%P << endl;
	return 0;
} 

Measured memory_bytes: 76032
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll n; cin >> n;
  int len = 1;
  ll prev = 26, lb = 1, ub = 26;
  while (n > ub) {
    ++len;
    prev *= 26;
    lb = ub + 1;
    ub += prev;
  }
  n -= lb;
  string ans = "";
  REP(_, len) {
    ans += 'a' + (n % 26);
    n /= 26;
  }
  reverse(ALL(ans));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3648
/*
AizuOnline A0175
A king in hawaii
*/
#include <stdio.h>


main()
{
  long int n;
  char buf[6];

  int i;
  char c;
  char *p;

  while(scanf("%ld",&n),n != -1)
    {
      for(i=0;i<6;i++)
	buf[i]=0;
      sprintf(buf,"%lx",n);
#ifdef DEBUG
      printf("%s\n",buf);
#endif

      p=buf;
      while(c = *p)
	{
	  if (p!=buf && c < '4')
	    printf("0");

	  if(c=='0')
	    printf("0");
	  else if(c=='1')
	    printf("1");
	  else if(c=='2')
	    printf("2");
	  else if(c=='3')
	    printf("3");
	  else if(c=='4')
	    printf("10");
	  else if(c=='5')
	    printf("11");
	  else if(c=='6')
	    printf("12");
	  else if(c=='7')
	    printf("13");
	  else if(c=='8')
	    printf("20");
	  else if(c=='9')
	    printf("21");
	  else if(c=='a')
	    printf("22");
	  else if(c=='b')
	    printf("23");
	  else if(c=='c')
	    printf("30");
	  else if(c=='d')
	    printf("31");
	  else if(c=='e')
	    printf("32");
	  else if(c=='f')
	    printf("33");

	  p++;
	}
      printf("\n");
    }


       


return(0);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,s;
  vector<vector<vector<ll>>> dp(102,vector<vector<ll>>(11,vector<ll>(1001,0)));
  dp[0][0][0] = 1;
  dp[0][1][0] = 1;
  REP(i,1,101){
    REP(j,0,10){
      REP(k,0,1001){
        if(i)
          dp[i][j][k] = dp[i-1][j][k];
        if(i && j && k-i >= 0)
          dp[i][j][k] += dp[i-1][j-1][k-i];
      }
    }
  }
  while(cin >> n >> s && n+s){
    cout << dp[100][n][s]  << endl;
  }
  return 0;
}

Measured memory_bytes: 11904
#include<stdio.h>??
int a[100000];
int main(void){
int n, s;
scanf("%d%d", &n, &s);
for(int i = 0;i < n;++i)scanf("%d", &a[i]);
int res = n + 1, sum = 0, l = 0, r = 0;
for(;l < n;){
if(l == r)sum = a[r++];
else{
if(sum >= s)sum -= a[l++];
else if(r < n)sum += a[r++];
else break;
}
if(sum >= s && res > r - l)res = r - l;
}
if(res <= n)printf("%d\n", res);
else puts("0");
return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> a;
vector<int> b;
int n,m,ans1=0, ans2=0;
vector<bool> ca(9,0);
vector<bool> cb(9,0);
int fact(int x){
	int ans=1;
	for(int i=2; i<=x; i++) ans*=i;
	return ans;
}
int fa(int x){
	int y=0;
	for(int i=1; i<x; i++)
		if(!ca[i]) y++;
	return y;
}
int fb(int x){
	int y=0;
	for(int i=1; i<x; i++)
		if(!cb[i]) y++;
	return y;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>m;
		a.pb(m);
	}
	for(int i=0; i<n; i++){
		cin>>m;
		b.pb(m);
	}
	for(int j=0; j<n-1; j++){
		ca[a[j]] = true;
		ans1 += fa(a[j]) * fact(n-1-j);
		//cout<<ans1<<" ";
	}
	for(int j=0; j<n-1; j++){
		cb[b[j]] = true;
		ans2 += fb(b[j]) * fact(n-1-j);
		//cout<<ans2<<" ";
	}
	cout<<abs(ans1-ans2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
signed main(){
	IOS;
	int n ;
	cin >> n ;
	vector<int>arr(n);
	for(int& i : arr) cin >> i ;
	int dist = INT_MAX , cur = 0 ;
	for(int i = 0 ; i<= 100 ; i++ ){
		cur = 0 ;
		for(int j =0 ;j<n;j++){
			cur+=(arr[j]-i)*(arr[j]-i);
		}
		dist = min(dist,cur);
	}
	cout << dist << endl ;	
	return 0;
}




Measured memory_bytes: 256
from collections import defaultdict

def twosum(n):
  now = 1
  while n >= now:
    now *= 2
  return now - n
n=int(input())
a=sorted(list(map(int,input().split())))
d = defaultdict(int)
for i in a:
    d[i] += 1
ans = 0
for i in a[::-1]:
    d[i] -= 1
    find = twosum(i)
    if d[find] > 0 and d[i] >= 0:
        ans += 1
        d[find] -= 1
    else:
        d[i] += 1
print(ans)

Measured memory_bytes: 113492
X, Y = map(int, input().split())
A = [2]
B = [4, 6, 9, 11]
C = [1, 3, 5, 7, 8, 10, 12]
print(["No", "Yes"][(X in A and Y in A)or(X in B and Y in B)or(X in C and Y in C)])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  bool ok = true;
  rep(i, H) rep(j, W) {
    if(S[i][j] == '#') {
      int dx[] = {-1, 0, 1, 0};
      int dy[] = {0, 1, 0, -1};
      bool ok2 = false;
      rep(k, 4) {
        int nx = i+dx[k], ny = j+dy[k];
        if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        ok2 |= (S[nx][ny]=='#');
      }
      ok &= ok2;
    }
  }
  cout << (ok ? "Yes" : "No") << "\n";
  return 0;
}


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

int main() {
  string s;
  cin>>s;
  int ans=0;
  for(int i=0; i<s.size(); i++){
    int now_ans=0;
    if(s[i]!='A'&&s[i]!='G'&&s[i]!='C'&&s[i]!='T')continue;
    now_ans++;
    for(int j=i+1; j<s.size(); j++){
      if(s[j]!='A'&&s[j]!='G'&&s[j]!='C'&&s[j]!='T')break;
      now_ans++;
    }
    ans=max(ans,now_ans);
  }
  cout<<ans<<endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m,a,b,ans[100000],memo[100000];
vector<int> v[100000];

void kr(int a) {
    rep(i,v[a].size()) {
        memo[v[a][i]]--;
        if (!memo[v[a][i]]) ans[v[a][i]] = a;
    }
    rep(i,v[a].size()) {
        if (!memo[v[a][i]]) {
            kr(v[a][i]);
        }
    }
}

signed main() {
    cin >> n >> m;
    rep(i,n+m-1) {
        cin >> a >> b;
        v[a].pb(b);
        memo[b]++;
    }
    int hoge=0;
    rep1(i,n) if (!memo[i]) hoge=i;
    kr(hoge);
    rep1(i,n) cout << ans[i] << endl;

}



Measured memory_bytes: 11008
N = gets.to_i
cards =  gets.strip.split.map(&:to_i).sort { |a, b| b <=> a }

alice = 0
bob = 0
i = 0
cards.each do |card|
  if i == 0
    alice += card
    i += 1
  else
    bob += card
    i-= 1
  end
end
puts alice - bob


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

using ll = long long;

int main() {
      	int ans = 0;
	for (int i = 0; i < 6; i++) {
		char c;
		cin >> c;
		if (c == '1') {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int t = 0;
        int a[26] = {}, b[26] = {};
        for (int j = 0; j < i; j++) {
            a[s[j] - 'a']++;
        }
        for (int j = i; j < n; j++) {
            b[s[j] - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            if (a[j] && b[j]) t++;
        }
        ans = max(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0296>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    vector<ll> c(6); for(auto& in:c) cin >> in;
    cout << (c[0] + 5*c[1] + 10*c[2] + 50*c[3] + 100*c[4] + 500*c[5] >= 1000) << endl;
    return 0;
}



Measured memory_bytes: 3120