akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  int M = in();
  int K = in();

  bool ok = false;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= M; ++j) {
      int X = i * (M - j) + (N - i) * j;
      if (X == K) {
        ok = true;
      }
    }
  }

  puts(ok ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void) {

	// 1_6-B Finding Missing Cards

	int i;

	int cid,num,snum,n;
	char suit;
	int cards[52];
	for(i=0; i<52; i++){
		cards[i] = 0;
	}
	scanf("%d\n",&n);

	for(i=0; i<n; i++){
		scanf("%c %d\n",&suit,&num);
		cid = num-1;
		switch(suit){
			case 'S':	break;
			case 'H':	cid = cid + 13;
					break;
			case 'C':	cid = cid + 26;
					break;
			case 'D':	cid = cid + 39;
					break;
		}
		cards[cid] = 1;
	}

	for(i=0; i<52; i++){
		if(cards[i]==0){
			num = (i%13)+1;
			snum = i/13;
			switch(snum){
				case 0:	suit='S';
					break;
				case 1:	suit='H';
					break;
				case 2:	suit='C';
					break;
				case 3:	suit='D';
					break;
			}
			printf("%c %d\n",suit,num);
		}
	}

        return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    ll r, D, x[11];
    cin >> r >> D >> x[0];
    for(int i = 1; i <= 10; i++){
        x[i] = r * x[i-1] - D;
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, S = gets.split.map(&:to_i).tap{|it| it[1] /= 1000 }
# 9x + 4y = S - N
(0 .. N).find(lambda{puts "-1 -1 -1"}) do |y|
  x, d = (S - N - 4 * y).divmod(9)
  if d == 0 && x >= 0 && N - x - y >= 0
    puts [x, y, N - x - y].join(" ")
    true
  end
end


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

int main(){
  int n , m;
  cin >> n >> m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3580
while true
	h, w = gets.split( " " ).map { | val | val.to_i }
	break if 0 == h && 0 == w
	
	h.times { | i |
		if 0 == i%2
			w.times {  | i |
				if 0 == i%2
					print( "#" )
				else
					print( "." )
				end
			}
			print( "\n" )
		else
			w.times {  | i |
				if 0 == i%2
					print( "." )
				else
					print( "#" )
				end
			}
			print( "\n" )
		end
	}
	print( "\n" )
end

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int C2 = max(C - A + B,0);
    cout << C2 << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string s[110];
	int n, l;
	cin >> n >> l;
	REP(i, n) cin >> s[i];
	sort(s, s + n);
	REP(i, n) cout << s[i];
}

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

int main(void){
  int n;
  cin >> n;
  vector<int> arr = vector<int>(n);
  int mid = n / 2;
  for(int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] -= (i + 1);
  }
  sort(arr.begin(), arr.end());

  long result = 0;

  for(int i = 0; i < n; i++) {
    long diff = (long)arr[i] - arr[mid];
    if(diff < 0) diff *= -1;
    result += diff;
  }

  cout << result << endl;
}



Measured memory_bytes: 1024
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl //[l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<endl;out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;

signed main(){
    io();

    in(n);
    for(int i=111;i<=999;i+=111){
        if(n<=i){
            out(i);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int a,b;
int main(){
  cin >> a >> b;
  for (size_t i = 1; i <= 3; i++) {
    if(a != i && b != i) cout << i << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  bool operator>(const mint a) const {
    mint res(*this);
    return res.x > a.x;
  }
  bool operator<(const mint a) const {
    mint res(*this);
    return res.x < a.x;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};





int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<ll> A(N); rep(i,N) std::cin >> A[i];

  std::vector<int> k(64);
  for(int i=0; i<61; i++) {
    int cnt = 0;
    rep(j,N) if ( (A[j] & (1LL<<i)) != 0 ) cnt++;
    k[i] = cnt;
  }
  
  mint ans = 0;
  rep(i,64) {
    mint t = (N-k[i]);
    t *= k[i];
    t *= ((1LL<<i));
    ans += t;
  } 
  std::cout << ans.x << std::endl;
  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>

int main()
{
	for(int i=1; i<=3000; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==0 && y==0){
			break;
		}
		if(x<y){
	printf("%d %d\n",x,y);
		}else{
	printf("%d %d\n",y,x);
		}
	}
}

Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int L,R;

int ans;

signed main()
{
    cin >> L >> R;

    // cout << (L*R)%2019 << endl;

    ans = 2019;

    for(int i=L;i<=R;i++)
    {
        for(int j=i+1;j<=R;j++)
        {
            if((i*j)%2019==0)
            {
                cout << 0 << endl;
                return 0;
            }
            else if(ans>(i*j)%2019)ans=((i*j)%2019);
        }
    }

    cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LS()
    if a > b:
        return '>'
    if a < b:
        return '<'

    return '='


print(main())




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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n;
	cin>>n;

	ll sum =0;

	for(int i=1; i<=n; i++){
		if((i%3!=0) && (i%5 !=0) ){
			sum +=i;
		}
	}

	writeln(sum);
}


Measured memory_bytes: 3620
try:
    while True:
        n = input() 
        J=0
        I=0
        n = list(n)
        for i in range(len(n)):
            m = n[i:i+3]
            m =''.join(m)
            if m=='JOI':
                J+=1
            elif m=='IOI':
                I+=1
            
        print(J)
        print(I)
except EOFError:
    pass



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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
positive
negative
zero
に分ける

k == 1のとき
	最大値を出力
k == 2のとき
	positiveの上二つ、もしくはnegativeの上二つ
	どちらも二つ以上ない場合、0があるなら0を出力、ないならpositive * negative
k == 3のとき

*/

int mod = 1e9 + 7;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    long long res = modpow(x, y / 2);
    return res * res % mod;
}

long long solve_inverse(vector<int> &positive, vector<int>&negative, int k)
{
	vector<int> all;
	for (int i = 0; i < positive.size(); i++) all.push_back(positive[i]);
	for (int i = 0; i < negative.size(); i++) all.push_back(negative[i]);
	sort(all.begin(), all.end());
	long long res = 1;
	for (int i = 0; i < k; i++)
	{
		res *= all[i];
		res %= mod;
	}
	res %= mod;
	res = (mod - res) % mod;
	return (res);
}

int	main(void)
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	if (n == 1) //このとき絶対k=1
	{
		cout << a[0] << endl;
		return (0);
	}
	vector<int> positive;
	vector<int> negative;
	int zero_cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] > 0) positive.push_back(a[i]);
		else if (a[i] < 0) negative.push_back(abs(a[i]));
		else zero_cnt++;
	}
	if (zero_cnt + k > n)
	{
		cout << 0 << endl;
		return (0);
	}
	sort(positive.begin(), positive.end());
	sort(negative.begin(), negative.end());
	int positive_index = (int)positive.size() - 1;
	int negative_index = (int)negative.size() - 1;
	long long ans = 1;
	int cnt = 0;
	while (1)
	{
		if (cnt == k) break ;
		long long positive_max = -1e9;
		long long negative_max = -1e9;
		if (positive_index > 0)
		{
			positive_max = (long long)positive[positive_index] * positive[positive_index - 1];
		}
		if (negative_index > 0)
		{
			negative_max = (long long)negative[negative_index] * negative[negative_index - 1];
		}
		if (positive_max > negative_max)
		{
			ans *= positive[positive_index];
			ans %= mod;
			positive_index -= 1;
			cnt++;
		}
		else if (positive_max < negative_max || negative_max > 0)
		{
			if (cnt + 2 > k) break ;
			ans *= negative_max % mod;
			ans %= mod;
			negative_index -= 2;
			cnt += 2;
		}
		else
		{
			if (cnt + 2 > k) break ;
			/*
			ありうるのは
			pos: 1 nega: 1
			pos: 1 nega: 0
			pos: 0 nega: 1
			pos: 0 nega: 0
			pos: 1 nega: 0
			どの場合もzeroを使うのが最善
			*/
			if (zero_cnt > 0)
			{
				cout << 0 << endl;
				return (0);
			}
			ans *= positive[positive_index];
			ans %= mod;
			ans *= (mod - negative[negative_index]) % mod;
			ans %= mod;
			positive_index = -1;
			negative_index = -1;
			cnt += 2;
		}
	}
	if (cnt != k)
	{
		if (positive_index >= 0)
		{
			ans *= positive[positive_index];
			ans %= mod;
		}
		else if (negative_index > 0 && positive.size() >= 2)
		{
			ans *= negative[negative_index];
			ans %= mod;
			ans *= negative[negative_index - 1];
			ans %= mod;
			ans *= modpow(positive[0], mod - 2) % mod;
			ans %= mod;
		}
		else if (zero_cnt)
		{
			cout << 0 << endl;
			return (0);
		}
		else
		{
			ans = solve_inverse(positive, negative, k) % mod;
		}
	}
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 5072
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	c := make([][]int, 3)
	for i, _ := range c {
		c[i] = make([]int, 3)
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			c[i][j] = nextInt()
		}
	}
	// fmt.Println(c)
	for i := 0; i <= 100; i++ {
		a := make([]int, 3)
		b := make([]int, 3)
		a[0] = i
		ok := true
		for j, _ := range c[0] {
			// fmt.Println(c[0][j])
			if c[0][j] >= i {
				b[j] = c[0][j] - i
			} else {
				ok = false
				break
			}
		}
		if ok != true {
			break
		}
		a[1] = c[1][0] - b[0]
		for j, _ := range c[1] {
			// fmt.Println(c[1][j])
			if c[1][j]-b[j] != a[1] {
				ok = false
				break
			}
		}
		if ok != true {
			break
		}
		a[2] = c[2][0] - b[0]
		for j, _ := range c[2] {
			// fmt.Println(c[2][j])
			if c[2][j]-b[j] != a[2] {
				ok = false
				break
			}
		}
		if ok != true {
			break
		}
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

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


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll w,a,b;
    cin>>w>>a>>b;
    if(b>a)
       cout<<max(0ll,b-(a+w));
     else
     {
      cout<<max(0ll,a-(b+w));
     }
}
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    ll a, b;
    cin >> a >> b;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        cout << a*b << '\n';
    } else {
        cout << -1 << '\n';
    }

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
sum_=[a[0]]
num=a[0]
for i in range(1,n):
    num=num+a[i]
    sum_.append(num)
count={0:1}
for i in range(n):
    if sum_[i] in count:
        count[sum_[i]]+=1
    else:
        count[sum_[i]]=1
ans=0
for i in count.values():
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 111688
import std.stdio, std.range, std.conv, std.string, std.array, std.functional;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;

void main()
{

    char input;
    scanf("%c", &input);
    if(input == 'A')
    {
        writeln("T");
    }
    if(input == 'T')
    {
        writeln("A");
    }
    if(input == 'G')
    {
        writeln("C");
    }
    if(input == 'C')
    {
        writeln("G");
    }
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    B0 = ans = 0

    for i in range(len(A) - 1):
        count = 0
        for j in range(i + 1, len(A)):
            if A[i] > A[j]:
                B0 += 1

    ans += (B0 * K)

    for i in range(len(A)):
        count = 0
        for j in range(len(A)):
            if A[i] > A[j]:
                count += 1
        
        ans += (count * (K - 1) * K // 2)

    print(ans % (10**9 + 7))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	string S;
	cin >> S;
	if (S.size() == 2)
	{
		cout << S << endl;
	}
	else
	{
		reverse(S.begin(), S.end());
		cout << S << endl;
	}
}

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

Measured memory_bytes: 256
import java.util.Arrays;
//Java8(OpenJDK 1.8.0)
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();
	}

}
class Solve{
	 Scanner sc = new Scanner(System.in) ;
	 void solve() {
		
		 int N =sc.nextInt();
		 int[] A = new int[N];
		 int[] A_sort = new int[N];
		 
		 for(int i = 0;i<N;i++) {
			 int temp = sc.nextInt();
			 A[i] = temp;
			 A_sort[i] = temp;
		 }
		 
		 Arrays.sort(A_sort);
		 
		 for(int i = 0; i<N;i++) {
			 boolean jufuku = false;
			 
			 for(int j=N-1;j>=0;j--) {
				 if(A[i]!=A_sort[j]) {
					 System.out.println(A_sort[j]);
					 break;
				 }else if(A[i]==A_sort[j]&&jufuku==true){
					 System.out.println(A_sort[j]);
					 break;
				 }else {
					 jufuku = true;
				 }
			 }
		 }
	 }
}

Measured memory_bytes: 102780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    string S;
    cin >> S;
    if(S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
        cout << "Yes" << endl;
    }
    else if(S.at(1) == S.at(2) && S.at(2) == S.at(3)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//zzzzz
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll x,y,ans=0;
  cin>>x>>y;
  while(x<=y)
  {
    ans++;
    x*=2;
  }
  cout<<ans<<endl;
  return 0;
}

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

const int m = 2019;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());//10^xとaxを一致させるため
  int x = 1, tot = 0;//totは累積和Si
  vector<int> cnt(m);
  ll ans = 0;
  rep(i,n) {
    cnt[tot]++;
    tot += (s[i]-'0')*x;
    tot %= m;
    ans += cnt[tot];
    x = x*10%m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){

  int H, W, N; cin >> H >> W >> N;
  int sr, sc; cin >> sr >> sc;

  string S, T; cin >> S >> T;

  int U = 1, D = H;
  for (int i = N - 1; i >= 0; i--){
    if (T[i] == 'U') D = min(H, D + 1);
    else if (T[i] == 'D') U = max(1, U - 1);

    if (S[i] == 'U') U++;
    else if(S[i] == 'D') D--;

    if (U > D || U > H || D < 1){
      cout << "NO" << endl;
      return 0;
    } 
  }
  if (sr < U || D < sr){
    cout << "NO" << endl;
    return 0;
  }
  

  int L = 1, R = W;
  for (int i = N - 1; i >= 0; i--){
    if (T[i] == 'L') R = min(W, R + 1);
    else if(T[i] == 'R') L = max(1, L - 1);

    if (S[i] == 'L') L++;
    else if (S[i] == 'R') R--;

    if (L > R || L > W || R < 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  if (sc < L || R < sc){
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 776
n = int(input())
d,x = map(int, input().split())
a = [int(input()) for i in range(n)]
co = 0
for i in range(1, d + 1):
  for j in a:
    for k in range(d + 1):
      if i ==  k * j + 1:
        co += 1
co += x
print(co)


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.*;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();
		int m = in.nextInt();

		if(n==1) n*=100;
		if(m==1) m*=100;

		if(n ==m) {
			out.println("Draw");
		}else if (n<m){
			out.println("Bob");
		} else {
			out.println("Alice");
		}
		out.flush();

	}

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

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int next() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public char nextChar() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
				return (char) c;
			}
			throw new InputMismatchException();
		}

		public String nextToken() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = next();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public int nextInt() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c-'0';
				c = next();
			} while (!isSpaceChar(c));
			return res*sgn;
		}

		public long nextLong() {
			int c = next();
			while (isSpaceChar(c))
				c = next();
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = next();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c-'0';
				c = next();
			} while (!isSpaceChar(c));
			return res*sgn;
		}

		public double nextDouble() {
			return Double.valueOf(nextToken());
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		//public interface SpaceCharFilter {
		//	public boolean isSpaceChar(int ch);
		//}
	}
	// template
	static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r);  }
	static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r);  }

	static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t;  }
	static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t;  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h> 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : P - Independent Set
*/
 
int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vvi g(n);
  for(int i = 0; i < n - 1; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  const int MOD = 1e9 + 7;
  vvi memo(2, vi(n, -1));
  function<int(int, int, int)> dp = [&](int i, bool b, int prev){
    // base case
    if(g[i].size() == 0 || g[i].size() == 1 && g[i].front() == prev) return 1;
    int &ans = memo[b][i];
    if(ans != -1) return ans;
    ans = 1;
    for(int x : g[i]) if (x != prev){
      // place white
      int white = dp(x, 0, i);
      int black = b ? 0 : dp(x, 1, i);
      ans = (ans * (ll)(white + black)) % MOD;
    }
    return ans;
  };

  cout << (dp(0, 0, -1) + dp(0, 1, -1)) % MOD;

  return cout << endl, 0;
}

Measured memory_bytes: 16248
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int gcd ( int a, int b )
{
	return (b ? gcd(b, a % b) : a);
}

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

int lcm3 ( vector<int> v )
{
	for ( int i = 1; i < v.size(); ++i ) {
		v[0] = lcm( v[0], v[i] );
	}
	return v[0];
}

int main() {
	int n;
	while ( cin >> n ) {
		vector<int> v( n );
		for ( int i = 0; i < n; ++i ) {
			cin >> v[i];
		}
		cout << lcm3( v ) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int64_t s;
  cin >> s;

  constexpr int64_t d = 1'000'000'000;
  cout << 0 << " " << 0 << " " << 1 << " " << d << " " << (s - 1 + d) / d << " "
       << (d - s % d) % d << endl;

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a.at(i);
    }

    int j = 1;
    rep(i, N){
        if (a.at(i) == j){
            j++;
        }
    }

    if (j == 1){
        cout << -1 << endl;
        return 0;
    }

    cout << N - j + 1 << endl;
}


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

const ll mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int n;
mint ans;
vector<int> adj[200200];

int dfs(int cur, int prev = -1) {
    int sz = 1;
    mint score = mint(2).pow(n - 1) - 1;
    for (int to : adj[cur]) {
        if (to == prev) continue;
        int t = dfs(to, cur);
        sz += t;
        score -= mint(2).pow(t) - 1;
    }
    if (prev != -1) {
        score -= mint(2).pow(n - sz) - 1;
    }
    ans += score;
    return sz;
}

int main() {
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(0);
    ans /= mint(2).pow(n);
    cout << ans.x << endl;
}

Measured memory_bytes: 27888
import math

l = list(map(int, input().split()))

s = l[0] * l[1] * math.sin(math.radians(l[2])) / 2

L = l[0] + l[1] + (l[0]**2 + l[1]**2 - 2*math.cos(math.radians(l[2]))*l[0]*l[1]) ** (1/2)

h = 2 * s / l[0]

print(s)
print(L)
print(h)



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

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    vector<vi> c(h, vi(w, 0));
    rep(i, h)  {
        int k = 0;
        int size = 0;
        rep(j, w) {
            if (s[i][j]!='.') {
                if (k < j) {
                    while (k < j) {
                        c[i][k] = size;
                        ++k;
                    }
                    size = 0;
                }
                ++k;
                continue;
            }
            ++size;
        }
        while (k < w) {
            c[i][k] = size;
            ++k;
        }
    }
    int ans = 0;
    rep(j, w)  {
        int k = 0;
        int size = 0;
        rep(i, h) {
            if (s[i][j]!='.') {
                if (k < i) {
                    while (k < i) {
                        ans = max(ans, c[k][j]+size-1);
                        ++k;
                    }
                    size = 0;
                }
                ++k;
                continue;
            }
            ++size;
        }
        while (k < h) {
            ans = max(ans, c[k][j]+size-1);
            ++k;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,t=0;
  int k=1;
  string name;
  cin >> n;
  n-=1;
  while(true) {
      if(n >= pow(26,k)) {
          n-=pow(26,k);
          k++;
      } else {
        while(k--){
          name+=char(97+n/pow(26,k));
          n-=(int)(n/pow(26,k))*pow(26,k);
        }
        break;
      }
  }
  cout << name;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mer make_pair
using namespace std;

int n,m;
int a[110000];
bool vis[110000],vis2[110000];
vector<pair<int,int> > v[110000];

void dfs(int now,int sum){
	if(vis[now]){
		if(sum!=a[now]){
			//cout<<sum<<' '<<now<<' '<<a[now]<<endl;
			cout<<"No";
			exit(0);
		}
		return;
	}
	a[now]=sum;
	//cout<<now<<' '<<sum<<endl;
	vis[now]=true;
	for(int i=0;i<v[now].size();i++)
		dfs(v[now][i].fi,sum+v[now][i].se);
}

int main(){
	//my new name is Veex
	memset(a,-1,sizeof(a));
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		v[l].pb(mer(r,d));
		v[r].pb(mer(l,-d));
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			dfs(i,0);
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 12288
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int32();
            var a = consoleReader.SplitInt32();

            var gcd = Gcd(a[0], a[1]);
            for (int i = 2; i < a.Length; i++)
            {
                gcd = Gcd(gcd, a[i]);
            }
            return gcd;
        }
        int Gcd(int a, int b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b != 0)
            {
                var amari = a % b;
                a = b;
                b = amari;
            }
            return a;
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


Measured memory_bytes: 21728
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  string s;
  cin>>s;
  int m=0,l=0,n,nn;
  cin>>nn;
  stack<int>q;
  q.push(s[0]-'0');
  for(int i=1;i<s.size();i+=2){
    if(s[i]=='*'){
      n=q.top();
      q.pop();
      q.push(n*(s[i+1]-'0'));
    }
    else{
      q.push(s[i+1]-'0');
    }
  }
  while(!q.empty()){
    n=q.top();
    m+=n;
    q.pop();
  }
  q.push(s[0]-'0');
  for(int i=1;i<s.size();i+=2){
    if(s[i]=='*'){
      n=q.top();
      q.pop();
      q.push(n*(s[i+1]-'0'));
    }
    else{
      n=q.top();
      q.pop();
      q.push(n+(s[i+1]-'0'));
    }
  }
  l=q.top();
  if(nn==m){
    if(nn==l) cout<<'U'<<endl;
    else cout<<'M'<<endl;
  }
  else{
    if(nn==l) cout<<'L'<<endl;
    else cout<<'I'<<endl;
  }
    
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll x = 0;
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
    x ^= A.at(i);
  }

  ll ans = 0;
  for (ll k = 40; k >= 1; k--)
  {
    for (ll i = 0; i < N; i++)
    {
      ll a = A.at(i);
      if ((a ^ (a - 1)) == (1LL << k) - 1 && (x & (1 << (k - 1))))
      {
        //cerr << k << " " << i << " " << x << endl;
        x ^= (a ^ (a - 1));
        ans++;
        break;
      }
    }
  }

  if (x != 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch IntervalRunning | diff IntervalRunning.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address IntervalRunning.cpp && ./a.out

/*
 
 12/1/2019
 
 5:07-5:40 give up
 10:20-11:30 read editorial and got AC
 
 */

LL T[2],A[2],B[2];

string solve() {
  LL P=(A[0]-B[0])*T[0],Q=(A[1]-B[1])*T[1];
  if(P>0) P*=-1,Q*=-1;
  if(P+Q<0) return "0";
  if(P+Q==0) return "infinity";
//  dump(P,Q,P+Q);
  LL k=-P/(P+Q);
  LL res=2LL*k;
//  if((__int128)(P+Q)*k!=(__int128)P) ++res;
  if(-P%(P+Q)!=0) ++res;
  return to_string(res);
}

void solve_wrong() {
  int res=0;
  LL a=0,b=0;
  int sign=-100;
  FOR(i,0,1e6) {
    a+=T[i%2]*A[i%2];
    b+=T[i%2]*B[i%2];
    LL x=min(a,b);
    a-=x,b-=x;
    int sign2=a==b?0:a>b;
    if(sign2==0||sign2!=sign) ++res;
    sign=sign2;
  }
  if(res>1e5) cout<<"infinity"<<endl;
  else cout<<res-1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>T[0]>>T[1]>>A[0]>>A[1]>>B[0]>>B[1];
  cout<<solve()<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int K,X;
    cin >> K >> X;
    
    int res = X - K + 1;
    rep(i,2*K -1){
        if(res + i >= -1000000 && res + i <= 1000000){
        cout << res + i << endl;
        }
    }
    
}


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

pre = A
for i in range(0,K,1):
    now = [0]*N

    kuiL = [0]*N
    kuiR = [0]*N
    for j in range(0,N,1):
        #for k in range(max(0,j-pre[j]),min(N,j+pre[j]+1),1):
        #    now[k]+=1
        kuiL[max(0,j-pre[j])]+=1
        kuiR[min(N-1,j+pre[j])]+=1
    tmp = 0
    for j in range(0,N,1):
        if j!=0:
            tmp = tmp + kuiL[j]-kuiR[j-1]
        else:
            tmp = tmp + kuiL[j]
        now[j]+=tmp

    owari = True
    for j in range(0,N,1):
        if now[j]!=N:
            owari = False
        pre[j]=now[j]
    if owari:
        break
print(" ".join(list(map(str,now))))

Measured memory_bytes: 169784