akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
int main()
{
	int k,s;
	scanf("%d %d",&k,&s);
	int ans=0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(s-i-j<=k&&s-i-j>=0){
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	ll n,cnt=0;
	cin >> n;
	map<pair<ll, ll>, ll>mp;
	pair<ll, ll>p,pp;
	for (ll i = 1; i <= n; i++) {
		ll head = i / pow(10, (ll)log10(i));
		ll tail = i % 10;
		p = make_pair(head,tail);
		mp[p]++;
	}
	for (ll i = 1; i <= n; i++) {
		ll head = i / pow(10, (ll)log10(i));
		ll tail = i % 10;
		pp = make_pair(tail,head);
		cnt += mp[pp];
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n >> k;
  
  ll m=0;
  vector<vector<ll>> v;
  
  if(k>(n-2)*(n-1)/2)cout << -1 << endl;
  else{
    queue<vector<ll>> G;
    for(int i=2;i<n;i++){
      for(int j=i+1;j<=n;j++)G.push({i,j});
    }
    for(int i=2;i<=n;i++){
      v.push_back({1,i});
      m++;
    }
    for(int i=0;i<(n-1)*(n-2)/2-k;i++){
      vector<ll> u=G.front();
      G.pop();
      v.push_back(u);
      m++;
    }
    cout << m << endl;
    for(int i=0;i<m;i++)cout << v[i][0] << " " << v[i][1] << endl;
  }

}

Measured memory_bytes: 3984
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
 
    int x = chain(iota(1, n + 1), a).reduce!"a ^ b";
    int L = a.countUntil(x).to!int, R = a.retro().countUntil(x).to!int;
 
    auto c = ModCombo(n + 1);
 
    foreach (k ; 1 .. n + 2) {
        long ans = c.binom(n + 1, k);
 
        if (k - 1 <= L + R) ans -= c.binom(L + R, k - 1);
        if (ans < 0) ans += c.mod;
 
        writeln(ans);
    }
}


struct ModCombo {
    private {
        immutable long _mod;
        long[] _f;
        long[] _finv;

        long _powmod(long x, long y, long mod) {
            return y > 0 ? _powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
        }
    }

    @property {
        long mod() {return _mod;}
        long f(int n) {return _f[n];}
        long finv(int n) {return _finv[n];}
    }

    this (int N, long mod = 10^^9 + 7) {
        _mod = mod;
        _f = new long[](N + 1);
        _finv = new long[](N + 1);
        _f[0] = _finv[0] = 1L;

        foreach (i ; 1 .. N + 1) {
            _f[i] = i * _f[i - 1] % _mod;
        }

        _finv[N] = _powmod(_f[N], _mod - 2, _mod);

        foreach_reverse (i ; 1 .. N) {
            _finv[i] = (i + 1) * _finv[i + 1] % _mod;
        }
    }

    long perm(int n, int k) {
        return _f[n] * _finv[k] % _mod;
    }

    long binom(int n, int k) {
        return _f[n] * _finv[k] % _mod * _finv[n - k] % _mod;
    }

    long H(int n, int k) {
        if (n == 0 && k == 0) return 1L;
        return _f[n + k - 1] * _finv[k] % _mod * _finv[n - 1] % _mod;
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 6972
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextUint64() uint64 {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.ParseUint(sc.Text(), 0, 64)
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func GCD(a, b uint64) uint64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func primeFactors(n uint64) (pfs map[uint64]uint64) {
	pfs = make(map[uint64]uint64)
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}

	var i uint64
	for i = 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}

	if n > 2 {
		pfs[n]++
	}
	return
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	a := nextUint64()
	b := nextUint64()

	g := GCD(a, b)
	debugf("%v\n", g)
	pf := primeFactors(g)
	debugf("%v\n", pf)
	ans := len(pf) + 1

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    cout << n * n << EOL;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[101],b,c,i,j,d;
scanf("%d %d\n",&b,&c);
for(i=0;i<b;i++){
scanf("%d\n",&a[i]);
}
for(i=1;i<c+1;i++){
for(j=0;j<b-1;j++){
if(a[j]%i>a[j+1]%i){
d=a[j];
a[j]=a[j+1];
a[j+1]=d;
}
}
}
for(i=0;i<b;i++){
printf("%d\n",a[i]);
}
return 0;
}



Measured memory_bytes: 2048
from bisect import bisect_left as bl, bisect_right as br
n = input()
a = sorted([int(x) for x in raw_input().split()])
b = sorted([int(x) for x in raw_input().split()])
c = sorted([int(x) for x in raw_input().split()])
ans = 0
for bi in b:
	ans += (bl(a, bi) * (n - br(c, bi)))
print ans


Measured memory_bytes: 18340
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
string hands[] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge","Paper","Air","Water","Dragon", "Devil","Lightning","Gun"};
int check(string s)
{
	for(int i = 0; i < 15; i++)
		if(hands[i] == s)
			return i;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		int table[15][15];
		int flag[15] = {};
		memset(table, -1, sizeof(table));
		for(int i = 0; i < 15; i++)
		{
			bool flag = false;
			for(int j = 0; j < 15; j++)
			{
				int cnt = 7;
				if(i == j) 
				{
					table[i][j] = 0;
					int x = j;
					while(cnt--)
					{
						x++;
						table[i][x % 15] = 1;
					}
				}
			}
		}
		string str[n + 1];
		for(int i = 0; i < n; i++)
			cin >> str[i];
		int num[n + 1] = {};
		int max_p = 0, p;
		for(int i = 0; i < n; i++)
		{
			int y = check(str[i]);
			for(int j = 0; j < n; j++)
			{
				int x = check(str[j]);
				if(table[y][x] == -1)
				{
					num[i] = -1;
					break;
				}
				else 
					num[i] += table[y][x];
			}
			if(num[i] > max_p)
			{
				max_p = num[i];
				p = i;
			}
		}
		if(max_p == 0)
			cout << "Draw" << endl;
		else	
			cout << str[p] << endl;
	}
	return 0;
}





Measured memory_bytes: 3068
use std::collections::HashSet;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let vs = scan!(i64;;);
    let unique: HashSet<_> = vs.iter().collect();
    println!("{}", unique.len())
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

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

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

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

int main(){
	static ll n,m,x;
	static ll h[100010];
	static ll a[300010],b[300010],t[300010];
	scanf("%lld%lld%lld",&n,&m,&x);
	rep1(i,n){
		scanf("%lld",&h[i]);
	}
	rep(i,m){
		scanf("%lld%lld%lld",&a[i],&b[i],&t[i]);
	}
	
	static vector<P> G[100010];
	rep(i,m){
		if(h[a[i]] >= t[i])G[a[i]].pb(P(b[i],t[i]));
		if(h[b[i]] >= t[i])G[b[i]].pb(P(a[i],t[i]));
	}
	static ll dist[100010];
	static bool used[100010];
	static priority_queue<P,vector<P>,greater<P>> que;
	rep1(i,n){
		dist[i] = INF;
		used[i] = false;
	}
	dist[1] = 0;
	que.push(P(dist[1],1));
	
	while(!que.empty()){
		P p = que.top(); que.pop();
		if(!used[p.sc]){
			rep(i,G[p.sc].size()){
				P ed = G[p.sc][i];
				if(dist[ed.fr] > max(x-h[ed.fr],dist[p.sc]+ed.sc) ){
					dist[ed.fr] = max(x-h[ed.fr],dist[p.sc]+ed.sc);
					que.push(P(dist[ed.fr],ed.fr));
				}
			}
			used[p.sc] = true;
		}
	}
	
	if(dist[n] == INF)puts("-1");
	else cout << dist[n] + h[n]-(x-dist[n]) << endl;
}

Measured memory_bytes: 29576
/*#include<stdio.h>

int n, a[200002],ans;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 1; i < n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (j - i == a[j] + a[i])
				ans++;
		}
	}
	printf("%d", ans);
}*/
#include<stdio.h>
#include<math.h>
int main()
{
	int x;
	scanf("%d", &x);
	if (x > 0)
	{
		for (int t = 1; t <= x; t++)
		{
			if (x % t == 0)
			{				
				for (int b = -t / 2;; b--)
				{
					if ((int)(pow(b + t, 5) - pow(b, 5)) == x)
					{
						printf("%d %d", b + t, b);
						return 0;
					}
					if ((int)(pow(b + t, 5) - pow(b, 5)) > x)
						break;
				}
				for (int b = -t / 2;; b++)
				{
					if ((int)(pow(b + t, 5) - pow(b, 5)) == x)
					{
						printf("%d %d", b + t, b);
						return 0;
					}
					if ((int)(pow(b + t, 5) - pow(b, 5)) > x)
						break;
				}
			}
		}
	}
	if (x == 0)
	{
		printf("0 0");
	}
	if (x < 0)
	{
		for (int t = -1; t >= x; t--)
		{
			if (x % t == 0)
			{
				for (int b = -t / 2;; b--)
				{
					if ((int)(pow(b + t, 5) - pow(b, 5)) == x)
					{
						printf("%d %d", b + t, b);
						return 0;
					}
					if ((int)(pow(b + t, 5) - pow(b, 5)) < x)
						break;
				}
				for (int b = -t / 2;; b++)
				{
					if ((int)(pow(b + t, 5) - pow(b, 5)) == x)
					{
						printf("%d %d", b + t, b);
						return 0;
					}
					if ((int)(pow(b + t, 5) - pow(b, 5)) < x)
						break;
				}
			}
		}
	}
}

Measured memory_bytes: 2520
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = readline().decode('utf-8').strip()
    if S.count('o') + (15-len(S)) >= 8:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9040
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,n,a[100010];
  map<int,int> mp;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  int ans=0;
  for(i=0;i<n;i++){
    if(mp[a[i]]==0){
      continue;
    }
    if(a[i]>mp[a[i]]){
      ans+=mp[a[i]];
    }
    else{
      ans+=mp[a[i]]-a[i];
    }
    mp[a[i]]=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8436
#include<stdio.h>
int main(int argc, const char *argv[])
{
  int n;
  scanf("%d", &n);
  switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      puts("hon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      puts("pon");
      break;
    case 3:
      puts("bon");
      break;
  }
  return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>

long long min(long long a, long long b){
  return a<b ? a:b;
}

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  
  for(int i=1;i<2000;i++)
    if(a*25 <= 2*i & (a+1)*25 > 2*i)
      if(b*10 <= i & (b+1)*10 > i){
        printf("%d\n",i);
        return 0;
      }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <queue>
using namespace std;
 
int main() {
  int n, q; scanf("%d %d", &n, &q);
  vector< priority_queue<int> > nums(n);
   
  while (q--) {
    int command, t; scanf("%d %d", &command, &t);
     
    switch (command) {
      case 0:
        int x; scanf("%d", &x);
        nums[t].push(x);
        break;
         
      case 1:
        if (!nums[t].empty()) printf("%d\n", nums[t].top());
        break;
         
      case 2:
        if (!nums[t].empty()) nums[t].pop();
        break;
    }
  }
}


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

using namespace std;

int main ()
{
    int i, c = 0;
    string s;

    cin >> s;

    int len = s.size();

    for (i = 1; i < len; i++){
        if (s[i] == s[i-1] && s[i] == '0'){
            c++;
            s[i] = '1';
        }


        else if (s[i] == s[i-1] && s[i] == '1'){
            c++;
            s[i] = '0';
        }
        else{
            continue;
        }

    }
    cout << c;

    return 0;

}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vp = vector<pair<ll,ll>>;

int main() {
  ll n;
  cin >> n;
  vp d(n);
  rep(i,n) cin >> d[i].first >> d[i].second;
  string ok = "No";
  rep(i,n-2) {
    if (d[i].first == d[i].second && d[i+1].first == d[i+1].second && d[i+2].first == d[i+2].second)
      ok = "Yes";
  }
  cout << ok << endl;
}

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

int main(){
  ll n;
  cin >> n;
  vector<vector<ll>>f(n,vector<ll>(10));
  for(int i=0; i<n; i++){
   for(int j=0; j<10; j++) cin >> f[i][j]; 
  }
  vector<vector<ll>>p(n,vector<ll>(11));
  for(int i=0; i<n; i++){
   for(int j=0; j<11; j++) cin >> p[i][j]; 
  }
  
  ll ans=-10e9;
  for(int i=1; i<pow(2,10); i++){
    vector<ll>count(n,0);
    ll x=i;
    ll y=9;
    while(x>0){
     if(x & 1){
      for(int j=0; j<n; j++){
        if(f[j][y]==1)count[j]++;
      }
     }
      y--;
      x>>=1;
    }
    
    
    ll z=0;
    for(int j=0; j<n; j++){
      z+=p[j][count[j]];
    }
    ans=max(ans,z);
  }
  
  cout << ans << endl;
  
}
  
  


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

int main() {
  int N,K;
  cin >> N>>K;
  vector<int> d(K);
  vector<int> e(K);
  for(int i=0;i<K;i++) cin>>d[i];

  for(int i=N;i<=100000;i++){
    int tmp=i;
    vector<int> e(K,0);
    bool exist=false;
    while(tmp>0){
      exist=false;
      int num = tmp%10;
      for(int j=0;j<K;j++){
        if(num==d[j]) exist=true;
      }
      if(exist) break;
      tmp /=10;
    }

    if(exist) continue;
    else{
      cout<<i<<endl;
      return 0;
    }

  }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
 string a,b;
 int x;
 int z(string s);
 cin>>a>>b;
  x=z(a+b);
  
  if(int (sqrt(x))==sqrt(x))
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  return 0;
}
 int z(string s)
 {
 int t=0;
 
 for(int i=0;i<s.size();i++)
   t=t*10+(s[i]-'0');
   return t; 
 } 

Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
		string A,B,C;
		char card;
		 
		cin >> A >> B >> C;

		int a=A.size();
		int b=B.size();
		int c=C.size();

		int i=0;
		int j=0;
		int k=0;

		card=A[0];
		i++;
		while(i<=a&&j<=b&&k<=c){
			if(card=='a'){
				if(i!=a){
					card=A[i];
				}
				i++;
			}else if(card=='b'){
				if(j!=b){
					card=B[j];
				}
				j++;
			}else if(card=='c'){
				if(k!=c){
					card=C[k];
				}
				k++;
			}
		}

		if(i>a){
			cout << 'A' << endl;
		}else if(j>b){
			cout << 'B' << endl;
		}else if(k>c){
			cout << 'C' << endl;
		}

		return 0;
    }

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    String b = sc.next();

    char[] bChar = b.toCharArray();
    int length = bChar.length;
    String bStr = "";
    for(int i=0; i<length; i++){
      if(bChar[i] != '.'){
        bStr += bChar[i];
      }
    }

    int bInt = Integer.parseInt(bStr);

    long result = (a * bInt) / 100;
    System.out.println(result);
  }
}

Measured memory_bytes: 39160
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for i, d in enumerate(B):
    l = min(A[i], d)
    r = min(A[i+1], d - l)
    A[i+1] -= r
    ans += l + r
    
print(ans)

Measured memory_bytes: 18468
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string a, b, c; cin >> a >> b >> c;
  char turn = 'a';
  int n,m,l;
  n = m = l = 0;
  while(1){
    switch (turn)
    {
    case 'a':
      turn = a[n];n++;
      
      break;
    case 'b':
      turn = b[m];m++;
      
      break;
    case 'c':
      turn = c[l];l++;
      
      break;
    default:
      break;
    }
    if(n-1 == a.size()){
      cout << "A" << endl;
      break;
    }
    else if(m-1 == b.size()){
      cout << "B" << endl;
      break;
    }
    else if(l-1 == c.size()){
      cout << "C" << endl;
      break;
    }
  }
  system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n=5;
ll a[6];
int main(){
	ios::sync_with_stdio(false);
	ll mn=1e18;
	ll k;cin >> k;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
		mn=min(mn,a[i]);
		
		//cout << (10-(a[i])%10)%10 << endl;
		
	}
	//cout << mx << endl;
	cout << (k+mn-1)/mn+4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long int
#define mod 1000000007
#define fast_input() ios:base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
int32_t main()
{
    
    string str;
    cin>>str;
    int answer=0;
    string prev="";
    prev+=str[0];
    answer++;
    int j;
    int n=str.size();
    for(j=1;j<n;j++)
    {
		if(j+1<n)
		{
			string curr="";
			curr+=str[j];
			if(curr!=prev)
			{
				answer++;
				prev=curr;
			}
			else
			{
				answer++;
				curr+=str[j+1];
				prev=curr;
				j++;
			}
		}
		else
		{
			string curr="";
			curr+=str[j];
			if(curr==prev)
			{
				break;
			}
			else
			{
				answer++;
				break;
			}
		}
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 640
# include <iostream>
# include <vector>
# include <string>
# include <algorithm>
using namespace std;
int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n > k) {
		cout << k * x + (n - k)*y << endl;
	}
	else {
		cout << n*x << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
int N;
priority_queue<double> q;
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		double v;
		cin >> v;
		q.push(-1*v);
	}
	while(q.size()>1){
		double x=q.top();
		q.pop();
		double y=q.top();
		q.pop();
		q.push( (x+y)/2.0);
	}
	cout << -1*q.top() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    long long sm = accumulate(a.begin(), a.end(), 0LL);

    long long x = 0;
    long long y;
    long long mn = 1LL << 60;

    for(int i=0; i<N-1; i++){
        x += a[i];
        y = sm - x;
        mn = min(mn, abs(x-y));
    }
    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 1792
s = input()
n = len(s)

def dfs(i, t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    return dfs(i+1, t+s[i+1]) + dfs(i+1, t + '+' + s[i+1])

print(dfs(0, s[0]))

Measured memory_bytes: 3060
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

    int count,box,random,a=0,b=0,i,j,k,n,dice[100][6];

    cin >> n;

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

    for(k=1;k<n;k++){
        if(b==1){
            break;
        }
         for(i=0;i<10000;i++){
             count=0;
             if(a==1){
                 b=1;
                 break;
             }
             for(int j=0;j<6;j++){
                 if(dice[0][j] == dice[k][j]){
                     count++;
                 }
             }
             if(count==6){
                 cout << "No" << endl;
                 a=1;
                 break;
             }
             
             random = rand() % 4 + 1;
             
             if(random == 1){
                 box=dice[k][0];
                 dice[k][0]=dice[k][4];
                 dice[k][4]=dice[k][5];
                 dice[k][5]=dice[k][1];
                 dice[k][1]=box;
             }
             else if(random == 2){
                 box=dice[k][0];
                 dice[k][0]=dice[k][1];
                 dice[k][1]=dice[k][5];
                 dice[k][5]=dice[k][4];
                 dice[k][4]=box;
             }
             else if(random == 3){
                 box=dice[k][0];
                 dice[k][0]=dice[k][2];
                 dice[k][2]=dice[k][5];
                 dice[k][5]=dice[k][3];
                 dice[k][3]=box;
             }
             else if(random == 4){
                 box=dice[k][0];
                 dice[k][0]=dice[k][3];
                 dice[k][3]=dice[k][5];
                 dice[k][5]=dice[k][2];
                 dice[k][2]=box;
             }
         }
    }
    
         if(a!=1){
             cout << "Yes" << endl; 
         }
    
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
main(void){
    int a,b,c=0;
    cin>>a>>b;
    char s[a+b+1];
    cin>>s;
    if(s[a]!='-'){
            cout<<"No";
            return 0;
    }
    for(int i=0;i<a+b+1;i++){
        if(s[a]==i) continue;
        if(s[i]=='0'|| s[i]=='1'|| s[i]=='2'|| s[i]=='3'|| s[i]=='4'|| s[i]=='5'|| s[i]=='6'|| s[i]=='7'|| s[i]=='8'|| s[i]=='9' ){
            c++;
        }
    }
    cout<<(c==a+b?"Yes":"No");
}


Measured memory_bytes: 256
s=list(raw_input().split("T"))
x,y=map(int,raw_input().split())
lx=[len(_) for _ in s[2::2]]
ly=[len(_) for _ in s[1::2]]

dpx=set()
dpx.add(len(s[0]))
for i in lx:
	tmp=set()
	for j in dpx:
		tmp.add(j+i)
		tmp.add(j-i)
	dpx=tmp


dpy=set()
dpy.add(0)
for i in ly:
	tmp=set()
	for j in dpy:
		tmp.add(j+i)
		tmp.add(j-i)
	dpy=tmp

print "Yes" if x in dpx and y in dpy else "No"


Measured memory_bytes: 3480
s = input().split()

N = int(s[0])
M = int(s[1])
X = int(s[2])

C = []
A = []

for i in range(N):
  t = input().split()
  C.append(int(t[0]))
  A_each = []
  for j in range(M):
    A_each.append(int(t[j+1]))
  A.append(A_each)
  
mini = -1
  
for i in range(2 ** N):
  bina = bin(i)[2:]
  money = 0
  result = []
  for x in range(M):
  	result.append(0)
  while(len(bina) < N):
    bina = "0" + bina
  for k in range(N):
    if bina[k] == "1":
      money += C[k]
      for j in range(M):
        result[j] += A[k][j]
  test = 0
  #print(str(result), str(money))
  for n in range(M):
    if result[n] >= X:
    	test += 1
  if test == M:
    if money < mini or mini == -1:
      mini = money
      
print(mini)

Measured memory_bytes: 9280
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound


using namespace std;

vector<ll> dp ;
ll solve(ll n)
{
    if(n==0) return 1;
    if(n<=2 ) return 0;

    if(dp[n]!=-1) return dp[n];
    ll s=0;
    for(ll i=3 ;i<=n;i++)
    {

        s= s%mod+ solve(n-i)%mod ;
        s=s%mod;
    }
    dp[n]=s;
    return s ;

}



int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    ll n ;

        cin >> n ;
        dp.clear() ;
        dp.resize(n+1,-1);
        ll ans= solve(n)%mod ;
        cout << ans << endl;

}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}

int main()
{

  IOS
  ll a,b,c,d;
  cin>>a>>b>>c;
  ll check =0;
  if(a==b&&a!=c)
  check = 1;
  else if(a==c&&a!=b)
    check =1;
  else if(b==c&&b!=a)
  {
    check =1;
  }
  if(check)
    cout<<"Yes"<<endl;
  else
  {
    cout<<"No"<<endl;
  }
  
  
  
  
  
  

}

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

int main() {
  int N, Q=0, D=0;
  long A;
  cin >> N;
  rep(i, N){
    cin >> A;
    if(A%4==0) Q++;
    else if(A%2==0) D++;
  }
  if(N/2<=Q) cout << "Yes" << endl;
  else if(N-Q*2<=D) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = 100000 + 5;
vector<int> g[N];
int v[N],vis[N];

int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int u,v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue<int> q;
	q.push(1);
	vis[1] = 1;
	while(!q.empty()){
		int z = q.front();
		q.pop();
		for(int i = 0; i < g[z].size(); i++){
			if(vis[g[z][i]] == 0){
				vis[g[z][i]] = 1;
				q.push(g[z][i]);
				v[g[z][i]] = z;
			}
		}
	}
	cout << "Yes" << endl;
	for(int i = 2; i <= n; i++){
		cout << v[i] << endl;
	}
    return 0;
} 

Measured memory_bytes: 10856
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        String S = sc.next();
        String T = sc.next();
        boolean a = false;
        if(S.equals(T.substring(0,S.length())))
            a = true;
        if(a) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35744
// Lec11-A Dice I
#include<iostream>
class Dice{
public:
  int d[6], tmp;
  Dice(int *in){
    for(int i=0; i<6; i++) d[i] = in[i];
  }
  int Rolling(std::string str){
    for(int i=0; i<str.length(); i++){
      switch(str[i]){
        case 'N':
        tmp=d[0],d[0]=d[1],d[1]=d[5],d[5]=d[4],d[4]=tmp;
        break;
        case 'S':
        tmp=d[0],d[0]=d[4],d[4]=d[5],d[5]=d[1],d[1]=tmp;
        break;
        case 'E':
        tmp=d[0],d[0]=d[3],d[3]=d[5],d[5]=d[2],d[2]=tmp;
        break;
        case 'W':
        tmp=d[0],d[0]=d[2],d[2]=d[5],d[5]=d[3],d[3]=tmp;
        break;
      }
    }
    return d[0];
  }
};
int main(){
  int in[6];
  std::string str;
  for(int i=0; i<6; i++) std::cin >> in[i];
  std::cin >> str;
  Dice sample(in);
  std::cout << sample.Rolling(str) << std::endl;
  return 0;
}

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


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

    ll a,b,c,d,temp,temp1,temp2,temp3,temp4;
    cin>>a>>b>>c>>d;
    temp1 = a*c;
    temp2 = a*d;
    temp3 = b*c;
    temp4 = b*d;
    temp = max(max(temp1,temp2),max(temp3,temp4));
    
    cout<<temp<<endl;

}

Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b; cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1e18;;

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

	int n;
	ll x;
	cin >> n >> x;

	ll need = 0;
	vector<ll> bs(n);
	vector<ll> ls(n);
	vector<ll> rs(n);
	vector<pair<ll, int>> score(n);
	for (int i = 0; i < n; ++i) {
		cin >> bs[i] >> ls[i] >> rs[i];
		score[i].first = (ll)bs[i] * ls[i] + (ll)(x - bs[i]) * rs[i];
		score[i].second = i;
		need += (ll)bs[i] * ls[i];
	}
	sort(score.begin(), score.end());

	vector<int> rev(n);
	for (int i = 0; i < n; ++i) rev[score[i].second] = i;

	// Minimum number of hours so that we score at least \sum_{i} bs[i]ls[i]
	// [0, bs[i]]: t * ls[i]
	// [bs[i+1], x]: t * rs[i]
	// rs[i] >= ls[i]

	vector<ll> suff_sum(n+1, 0);
	for (int i = n-1; i >= 0; --i) suff_sum[i] = suff_sum[i+1] + score[i].first;

	ll res = (ll)x*n;
	for (int i = 0; i < n; ++i) {
		ll low = 0;
		ll high = (ll)x*n;
		while(low != high) {
			ll mid = (low + high) >> 1;
			ll offer = 0;

			// Case 1: We fill this up
			{
				ll rem = min(x, mid);
				ll cou = (mid - rem) / x;

				ll base = suff_sum[n-cou];
				if (rev[i] >= n-cou) {
					base += score[n-cou-1].first;
					base -= score[rev[i]].first;
				}
				ll add = min(rem, bs[i]) * ls[i] + max((ll)0, rem-bs[i]) * rs[i];
				offer = max(offer, base + add);
			}
			// Case 2: We don't fill this up
			{
				ll cou = mid / x;
				ll rem = mid % x;

				ll base = suff_sum[n-cou];
				if (rev[i] >= n-cou) {
					base += score[n-cou-1].first;
					base -= score[rev[i]].first;
				}
				ll add = min(rem, bs[i]) * ls[i] + max((ll)0, rem-bs[i]) * rs[i];
				offer = max(offer, base + add);
			}	

			if (offer >= need) high = mid;
			else low = mid + 1;
		}
		res = min(res, high);
	}
	cout << res << '\n';
}


Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String line = lines[0];
        String[] a = line.split(" ");
        int N = Integer.parseInt(a[0]);
        int M = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);
        

        int total = 0;
        int[] numvote = new int[b.length];
        for (int i = 0; i < b.length; i++){
            int vote = Integer.parseInt(b[i]);
            numvote[i] = vote;
            total += vote;
        }
    
        int count = 0;
        for (int j = 0; j < b.length; j++){
            int rank = numvote[j];
            if(rank >= total * (1.0/(4.0 * (double)M))){
                count++;
            }
        }
        if (count >= M){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        
    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


Measured memory_bytes: 35720
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),d,t[]=new int[100],s=0,i;
		for(i=0;i<n;i++) {
			d=stdIn.nextInt();
			t[d-1]++;
		}
		for(i=0;i<100;i++) if(t[i]>0) s++;
		System.out.print(s);
	}
}

Measured memory_bytes: 23124
s = input()
t = input()
length_s = len(s)
length_t = len(t)

# dp[i+1][j+1] --> sのi文字目までとtのj文字までのLCSの長さ
dp = [[0] * 3005 for _ in range(3005)]

# DPループ
# LCSの長さを記録
for i in range(length_s):
    for j in range(length_t):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])

# DPテーブルからLCSの文字列を復元
res = ""
i = length_s
j = length_t
while i > 0 and j > 0:
    # (i-1, j) -> (i, j)と更新されていた場合
    if dp[i][j] == dp[i-1][j]:
        i -= 1 # DPの遷移を遡る
    
    # (i, j-1) -> (i, j)と更新されていた場合
    elif dp[i][j] == dp[i][j-1]:
        j -= 1 # DPの遷移を遡る

    # (i-1, j-) -> (i, j)と更新されていた場合
    else:
        # この時s[i-1] == t[j-1]なのでt[i-1] + resでも可
        res = s[i-1] + res
        i -= 1
        j -= 1

print(res)


Measured memory_bytes: 144992
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁DP, Lを超えないものと保留のもの
MOD = 10 ** 9 + 7
L = sr()
dp_dec = 1 # decide
dp_res = 2 # reserve
length = len(L)
for i in range(1, length):
    x, y = dp_dec, dp_res
    if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y

answer = dp_dec + dp_res
print(answer % MOD)


Measured memory_bytes: 45660
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;
        vll n(4);
        for (int i = 0; i < 4; i++) {
            n[i] = s[i] - '0';
        }
        bool ok = false;
        for (int i = +1; i >= -1; i -= 2) {
            for (int j = +1; j >= -1; j -= 2) {
                for (int k = +1; k >= -1; k -= 2) {
                    if (n[0] + i*n[1] + j*n[2] + k*n[3] == 7) {
                        out << n[0] << (i > 0 ? '+' : '-') << n[1] << (j > 0 ? '+' : '-') << n[2] << (k > 0 ? '+' : '-') << n[3] << "=7" << endl;
                        ok = true;
                        break;
                    }
                }
                if (ok) { break; }
            }
            if (ok) { break; }
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    loop {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s = s.trim().to_string();

        if s.find("-") != None {
            break;
        }

        let mut n = String::new();
        io::stdin().read_line(&mut n).unwrap();
        let n: i32 = n.trim().parse().unwrap();

        for _ in 0..n {
            let mut h = String::new();
            io::stdin().read_line(&mut h).unwrap();
            let h: usize = h.trim().parse().unwrap();

            let f = s[0..h].to_string();
            let t = s[h..].to_string();

            s = t + &f;
        }

        println!("{}", s);
    }
}



Measured memory_bytes: 5032
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gim() gets.split.map(&:to_i) end
def gsm() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end

#####
s = gs
YesNo1(s[2] == s[3] &&s[4] == s[5])

Measured memory_bytes: 1912
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String str[] = s.split("");
        int count = 0;

        for (int i = 0; i < 3; i++) {
            if (str[i].equals("1")) {
                count++;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(count);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 22612
#include<stdio.h>

#define INF 100000000

int n, r[101];

void matrixMultiplication();
int min(int, int);

int main()
{
  int i, j;
  
  
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%d%d",&r[i] ,&r[i+1]);
    }
  
  matrixMultiplication();
  
  return 0;
}

void matrixMultiplication()
{
  int i, j, l, k, q;
  int m[101][101];
  
  for(i=0;i<101;i++)
   {
     for(j=0;j<101;j++)
       {
	 m[i][j] = INF;
       }
   }
  
  for(i = 1;i <= n; i++)
    {
      m[i][i] = 0;
    }
  for(l = 2; l <= n; l++)
    {
      for( i = 1;i <= n-l+1; i++)
	{
	  j = i+l-1;
	  m[i][j] = INF;
	  
	  for(k = i; k <= j-1; k++)
	    {
	      m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + r[i-1]*r[k]*r[j]);
	    }
	}
    }
  
  printf("%d\n", m[1][n]);
  
  return;  
}

int min(int x, int y)
{
  if(x > y)return y;
  else return x;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    for (int i = 1; i <= B; i++) {
        if (A*i % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 vector<ll> a(n);
 bool f = false;
 for(ll i=0;i<n;i++)cin>>a[i];
 ll ans = 1;
 sort(a.begin(),a.end());
 if( a[0] == 0){
  cout<<0<<endl;
  return 0;
 }
 double sum = 0;
 /*
 for(ll i=0;i<n;i++){
  ll b;
  cin>>b;
  a*= b;
  
  if( log(a)
  if( a > 1000000000000000000 ){
  // f = true;
   cout<<-1<<endl;
   return 0;
  }
 }*/
 for(ll i=0;i<n;i++) sum += log(a[i]);
 if( sum > log(1e18)+1 ){
  cout<<-1<<endl;
  return 0;
 }
 for(ll i=0;i<n;i++){
  ans *= a[i];
 }
 if( ans > 1000000000000000000 ){
  cout<<-1<<endl;
 }else cout<<ans<<endl;
 
    return 0;
}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	//读入数据
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	//迷宫描述
	char maze[h][w];
	//距离描述
	int dis[h][w];
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			scanf(" %c", &maze[i][j]);
			dis[i][j] = INT_MAX;
		}
	}
 
	//数据处理
	//由于我们是从0开始
	x1--;
	y1--;
	x2--;
	y2--;
 
	const int dir[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};//方向定义次序无所谓
	queue<pair<int, int> > q;
	//插入起点
	dis[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		//获取队首数据
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
 
		//按照规定方向移动
		for (int i=0; i<4; i++) {
			//新坐标和距离 
			int nx = x;
			int ny = y;
			int nd = dis[x][y]+1;
			//1 ~ k步
			for (int j=1; j<=k; j++) {
				//计算新的坐标
				nx += dir[i][0];
				ny += dir[i][1];
 
				//合法性判断
				if (nx<0 || nx>=h || ny<0 || ny>=w || '@'==maze[nx][ny] || dis[nx][ny]<nd) {
					break;
				}
				if (dis[nx][ny]>nd) {
					dis[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}
 
	int ans = dis[x2][y2];
	printf("%d\n", (INT_MAX==ans ? -1 : ans));
 
	return 0;
}

Measured memory_bytes: 9244
from operator import itemgetter

N = int(input())
R = {}
for i in range(N):
    s, p = input().split()
    p = int(p)
    if s in R:
        R[s].append([p, i + 1])
    else:
        R[s] = [[p, i + 1]]

for c in sorted(R):
    R[c].sort(reverse = True, key = itemgetter(0))
    for r in R[c]:
        print(r[1])


Measured memory_bytes: 3060
// choices and belief 

#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define whatis(x) cout << #x << " is " << x << endl;
#define inf 1e18

vector<int>g[N];
int col[N],vis[N];

int main()
{
    ios_base:: sync_with_stdio(false); cin.tie(0);
    // freopen ("inp","r",stdin);
    // freopen ("out","w",stdout);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    queue<int>q;
    q.push(1);
    vis[1]=1;
    col[1]=1;
    while(!q.empty())
    {
        int front = q.front();q.pop();
        for(int next :g[front])
        {
            if(!vis[next])
            {
                vis[next]=1;
                col[next]=!col[front];
                q.push(next);
            }
            else
            {
                if(col[front]==col[next])
                {
                    cout<<1ll*n*(n-1)/2-m<<endl;return 0;
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=col[i];
    }
    cout<<1ll*ans*(n-ans)-m<<endl;
    return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  if (b.substr(0, b.size() - 1) == a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}


Measured memory_bytes: 3532