akhauriyash/Code-Regression huggingface dataset:
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  cout << !(m1 == m2) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main (){

  int days,y,d,m,mill,n;
  int i;
  
  mill=(1000/3)*200+(1000-(1000/3)-1)*195;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    days=0;
    
    scanf("%d%d%d",&y,&m,&d);

    if(y%3==0){

      days+=((y-1)/3)*200 + (y-(y/3))*195;
      days+=(m-1)*20;
      days+=d-1;

    }else{

      days+=(y/3)*200 + (y-(y/3)-1)*195;
      days+=((m-1)/2)*20 + ((m-1)/2)*19 + ((m-1)%2)*20;
      days+=d-1;

    }

    printf("%d\n",mill-days);

  }

  return 0;

}

Measured memory_bytes: 596
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n;cin>>n;
    ll num = 0;
    ll ans = 1;
    rep(i, 1, n+1){
        ll v = i;
        ll c = 0;
        while(v%2==0){
            v /= 2;
            c++;
        }
        if (c>num) ans = i, num = c;
    }
    cout << ans << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int T;
int c[100];
int t[100];
int main(){
  int i, res=1073709056;
  rd(N);
  rd(T);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(c[Lj4PdHRW]);
      rd(t[Lj4PdHRW]);
    }
  }
  for(i=0;i<N;i++){
    if(t[i] <= T){
      chmin(res, c[i]);
    }
  }
  if(res==1073709056){
    wt_L("TLE");
    wt_L('\n');
  }
  else{
    wt_L(res);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190714-1

// --- original code ---
// int N, T, c[100], t[100];
// {
//   int i, res = int_inf;
//   rd(N,T,(c,t)(N));
//   rep(i,N) if(t[i] <= T) res <?= c[i];
//   wt( if[res==int_inf, "TLE", res] );
// }


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
		int n,x,t;
		//while(cin >> n >> x >> t)
		//{
		cin >> n >> x >> t;
			int mul = ceil(double(n)/double(x));
			cerr << imie(mul);
			int ans = t*mul;
			cout << ans << endl;
		//}
		return 0;
}  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A,B);
  ll s = g;
  ll ans = 1;
  for(ll i=2; i*i<=s; i++){
    if(g%i==0){
      ans+=1;
      while(g%i==0){
        g/=i;
      }
    }
  }
  if(g>1){
    ans++;
  }
  cout << ans;
  
}


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

const int INF = 1001001001;
vector<int> to[100005];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for(int u : to[v]){
            if(dist[u] != INF) continue;
            dist[u] = dist[v] +1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i,n){
        if(i==0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;

/*

long long n, m;
vector<int> table(100001);
vector<pair<int, int>> input(200001);

void check(int startNum){
    int relNum;
    rep(i,m){
        if(input[i].first == startNum) relNum = input[i].second;
        else if(input[i].second == startNum) relNum = input[i].first;
        else continue;
        if(table[relNum] == -1){
            table[relNum] = table[startNum] + 1;
            check(relNum);
        }
    }
}

int main()
{
    cin >> n >> m;
    for(int i = 2; i <= n; i++){
        table[i] = -1;
    }
    rep(i,m){
        cin >> input[i].first >> input[i].second;
    }
    check(1);
    for(int i = 2; i <= n; i++){
        if(table[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    for(int i = 2; i <= n; i++){
        cout << table[i] << endl;
    }
    */
}

Measured memory_bytes: 10736
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
const int MAX_STUDENT = 10001;
const int MAX_TIME = 1261;
int main(){
  int N,M;
  while(true){
    cin >> N >> M;
    if(!N)break;
    int r;
    cin >> r;
    vector<vector<int>> timeline(MAX_STUDENT,vector<int>(MAX_TIME,0));
    REP(i,r){
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      if(s==0){
	timeline[m][t] -= 1;
      }else{
	timeline[m][t] += 1;
      }
    }
    REP(i,MAX_STUDENT)
      for(int j = 540;j<MAX_TIME;j++){
      timeline[i][j+1] += timeline[i][j];
    }
    int q;
    cin >> q;

    REP(i,q){
      int ct = 0;
      int t1,t2,m;
      cin >> t1 >> t2 >> m;
      for(int j = t1;j<t2;j++){
	if(timeline[m][j]>0)ct++;
      }
      cout << ct << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 52364
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h, a = LI()
print(h // a + bool(h % a))


Measured memory_bytes: 39664
// IlyM

#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
ll a,b,n,k;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a>>b;
	for (int i=0;i<=10000;i++) {
		n=8*i;
		k=10*i;
		n/=100;
		k/=100;
		if (n==a && k==b) {
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        int res = 0;
        if(n == 0){
            System.out.println(x);
            System.exit(0);
        }

        List<Integer> array = new ArrayList<>();
        for(int i = 0; i < n; i++){
            array.add(sc.nextInt());
        }

        int A = x;
        int resA = 0;
        while(A > 0){
            if(!array.contains(A)){
                resA = A;
                break;
            }
            A--;
        }

        int B = x;
        int resB = 101;
        while(B <= 100){
            if(!array.contains(B)){
                resB = B;
                break;
            }
            B++;
        }

        if(Math.abs(resA) == Math.abs(resB)){
            if(resA > resB){
                res = resB;
            }else{
                res = resA;
            }
        }else if(Math.abs(x - resA) > Math.abs(x - resB)){
            res = resB;
        }else{
            res = resA;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35772
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int N,A,B;

    scanf("%d %d %d", &N, &A, &B);
    int ans = 0;
    for( i=1; i<=N; i++)
    {
        int num = i;
        int sum = 0;
        while(num)
        {
            sum += num % 10;
            num /= 10;
        }
        if( A<=sum && sum<=B)
            ans += i;
    }
    printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 256
#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;

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> res(n, 0);
  vector<int> connect[n + 1];
  for (int i = 1; i <= n; i++) {
    if (i - 1 >= 1) connect[i].push_back(i - 1);
    if (i + 1 <= n) connect[i].push_back(i + 1);
    if (x == i) connect[i].push_back(y);
    if (y == i) connect[i].push_back(x);
  }
  for (int i = 1; i < n; i++) {
    queue<int> que;
    int st = i;
    vector<int> pass(n + 1, 0);
    for (auto j : connect[st]) {
      que.push(j);
      pass[j] = pass[st] + 1;
      if (j > i) res[pass[j]]++;
    }
    while(que.size()) {
      st = que.front();
      que.pop();
      for (auto j : connect[st]) {
        if (pass[j] == 0) {
          que.push(j);
          pass[j] = pass[st] + 1;
          if (j > i) {
            res[pass[j]]++;
          }
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    cout << res[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[][][] data=new int[4][3][10];
	for(int i=0;i<n;i++){
	    int b=sc.nextInt();
	    int f=sc.nextInt();
	    int r=sc.nextInt();
	    int v=sc.nextInt();
	    data[b-1][f-1][r-1]+=v;
	}
	for(int k=0;k<4;k++){
	for(int i=0;i<3;i++){
	    for(int j=0;j<10;j++){
		System.out.print(" "+data[k][i][j]);
	    }
	    System.out.println();
	}
	if(k!=3)
	System.out.println("####################");
	}
    
    }
}



Measured memory_bytes: 29336
/*=======================
Author    : Shounak Dey
Filename  : d.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll a,b,c;
	cin >> a >> b >> c;
	ll k = min(a,c);
	a -= k;
	c -= k;
	k = min(b,c);
	b -= k;
	cout << a << " " << b << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[]) {
  int x,y;
  int tmp;
  while (1) {
    std::cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    }
    if (x > y) {
      tmp = x;
      x = y;
      y = tmp;
    }
    std::cout << x << " " << y << '\n';
  }
  return 0;
}

Measured memory_bytes: 3040
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, m;
	map<int,int> mp;
	while(scanf("%d,%d", &n, &m), n || m){
		mp[n] += m;
	}

	vector<int> r;
	for(map<int,int>::iterator it = mp.begin(); it != mp.end(); ++it){
		r.push_back(-it->second);
	}
	sort(r.begin(), r.end());
	r.erase(unique(r.begin(), r.end()), r.end());

	while(scanf("%d", &n) != EOF){
		printf("%d\n", upper_bound(r.begin(), r.end(), -mp[n]) - r.begin());
	}
}

Measured memory_bytes: 1056
import itertools
n,m,q=map(int,input().split())
L=list(itertools.combinations_with_replacement(range(m),n))
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
    a[i],b[i],c[i],d[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
ans=0
for l in L:
    tmp=0
    for i in range(q):
        if l[b[i]]-l[a[i]]==c[i]:
            tmp+=d[i]
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 21292
#include <cstdio>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
int main() {
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i,n) scanf("%d", &a[i]);
    ll ans = 0;
    repeat (i,n) {
        ans += a[i] / 2;
        a[i] %= 2;
        if (i+1 < n) {
            int d = min(a[i], a[i+1]);
            a[i  ] -= d;
            a[i+1] -= d;
            ans    += d;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, i;
    vector <int> v;
    
    scanf("%d", &n);
    
    if (n == 3) {
        v.push_back(2);
        v.push_back(5);
        v.push_back(63);
        n = 0;
    }
    
    for (i = 0; n > 0; i += 12) {
        if (n >= 8) {
            v.push_back(i + 2);
            v.push_back(i + 3);
            v.push_back(i + 4);
            v.push_back(i + 6);
            v.push_back(i + 8);
            v.push_back(i + 9);
            v.push_back(i + 10);
            v.push_back(i + 12);
            n -= 8;
            continue;
        } else if (n == 1) {
            v.push_back(i + 6);
        } else if (n == 2) {
            v.push_back(i + 6);
            v.push_back(i + 12);
        } else if (n == 3) {
            v.push_back(i + 2);
            v.push_back(i + 4);
            v.push_back(i + 6);
        } else if (n == 4) {
            v.push_back(i + 2);
            v.push_back(i + 3);
            v.push_back(i + 4);
            v.push_back(i + 9);
        } else if (n == 5) {
            v.push_back(i + 2);
            v.push_back(i + 3);
            v.push_back(i + 4);
            v.push_back(i + 6);
            v.push_back(i + 9);
        } else if (n == 6) {
            v.push_back(i + 2);
            v.push_back(i + 3);
            v.push_back(i + 4);
            v.push_back(i + 8);
            v.push_back(i + 9);
            v.push_back(i + 10);
        } else {
            v.push_back(i + 2);
            v.push_back(i + 3);
            v.push_back(i + 4);
            v.push_back(i + 6);
            v.push_back(i + 8);
            v.push_back(i + 9);
            v.push_back(i + 10);
        }
        
        n = 0;
    }
    
    for (i = 0; i < v.size(); i++) {
        if (i > 0) putchar(' ');
        printf("%d", v[i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;


ll pow(ll m) {
    if (m == 0) return 1;
    ll res = pow(m/2);
    res *= res;
    if (m%2 == 1) res *= 2;
    return res;
}
 
int main() {
    ll n, m;
    cin >> n >> m;
    ll target = (1LL<<n) - 1;
    vector<ll> A(m);
    vector<ll> B(m);
    vector<ll> C(m);
    for (ll i = 0; i < m; ++i) {
        cin >> A[i] >> B[i];
        for (ll j = 0; j < B[i]; ++j) {
            ll c;
            cin >> c; c--;
            C[i] += 1LL<<c;
        }
    }
    ll inf = 1e10;
    vector<vector<ll>> dp(m+1, vector<ll>(target+1, inf));
    dp[0][0] = 0;
    for (ll i = 1; i <= m; ++i) {
        // cerr << bitset<16>(C[i]) << endl;
        for (ll j = 0; j <= target; ++j) {
            dp[i][j] = dp[i-1][j];
        }
        for (ll j = 0; j <= target; ++j) {
            auto k = j | C[i-1];
            //cerr << i << ": " << bitset<16>(j) << " -> " << bitset<16>(k) << endl;
            dp[i][k] = min(dp[i][k], dp[i-1][j] + A[i-1]);
            //cerr << dp[i][k] << endl;
        }
        //for (ll j = 0; j <= target; ++j) {
        //    cerr << bitset<16>(j) << ": " << dp[i][j] << endl;
        //}
        //cerr << endl;
    }
    if (dp[m][target] < inf) {
        cout << dp[m][target] << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 32384
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toDouble() }.toDoubleArray()

    val dp = Array(n+1){DoubleArray(n+1)}
    dp[0][0] = 1.0
    for (i in 1..n){
        for (j in 0..i){
            if (j == 0){
                dp[i][j] = dp[i - 1][j] * (1 - p[i - 1])
            }else{
                dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1])
            }
        }
    }

    var ans = 0.0
    for (i in (n/2 + 1)..n){
        ans += dp[n][i]
    }
    println(ans)
}

Measured memory_bytes: 131008
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

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

int main(){
    
    int P, Q, R; cin >> P >> Q >> R;
    
    int max = P;
    
    if(max < Q){
        max = Q;
    
    }
    
    if(max < R){
        max = R;
    }
    
    cout << P + Q + R - max << endl;
    
    return 0;

    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0340
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            int[] p = RArInt();

            int res = int.MaxValue;

            for (int k = 0; k <= p[0]; k++)
            {
                res = Math.Min(res, GetTurnCnt(k, (int[])p.Clone()));
            }
            Console.WriteLine(res);
        }

        private static int GetTurnCnt(int k, int[] p)
        {
            int res = k;
            p[0] -= k;

            for (int i = 0; i < p.Length - 1; i++)
            {
                res += p[i] * 2;
                p[i + 1] -= Math.Min(p[i], p[i + 1]);
            }

            res += p[p.Length - 1];
            return res;

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 17976
#include <bits/stdc++.h>
using namespace std;int p[1024][1<<17],v[1<<19],w[1<<19],q,a,l,i;int f(int a,int l){if(l<0)return -1e9;if(!a)return 0;if(a>1023)return max(f(a/2,l),f(a/2,l-w[a])+v[a]);if(~p[a][l])return p[a][l];return p[a][l]=max({f(a/2,l),f(a,l-1),f(a/2,l-w[a])+v[a]});};int main(){memset(p,-1,sizeof(p));cin>>l;for(;i++<l;)cin>>v[i]>>w[i];cin>>q;while(q--){cin>>a>>l;cout<<f(a,l)<<" ";}}

Measured memory_bytes: 537692
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    int sum = 0;
    int i = N;
    while (i > 0) {
        sum += i % 10;
        i /= 10;
    }
    
    cout << (N % sum == 0 ? "Yes" : "No") << endl;

    return 0;
}

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


int main()
{
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N),y(M);
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int j = 0; j < M; j++) cin >> y[j];
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(x[N - 1] < y[0] && X < y[0] && Y >= y[0])
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }

}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a * b % 2 == 0)
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if(A>B){
    cout << B;
  }
  else{
    cout << A;
  }
  cout << " ";
  if(A+B-N>0){
    cout << A+B-N << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 N PIC 99999.
       01 A PIC 99999.
       01 RE PIC ZZZZ9.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT N.
      	ACCEPT A.
      	COMPUTE N=N*N.
      	SUBTRACT A FROM N.
      	MOVE N TO RE.
      	DISPLAY RE.
        STOP RUN.



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

int cnt[11][1000];
void f(bitset<10> used, int d, int s)
{
    cnt[d][s]++;
    for(int i = 0; i < 10; ++i)
    {
        if(!used[i]){
            used.set(i);
            f(used, d + 1, s + i * (d + 1));
            used.reset(i);
        }
    }
}

int main()
{
    f(bitset<10>(), 0, 0);
    int n, s;
    while(cin >> n >> s){
        if(s > 1000) cout << 0 << endl;
        else cout << cnt[n][s] << endl;
    }
}

Measured memory_bytes: 1204
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}


main(){
	int n;cin>>n;int ans=0;
	int ruia[n];
	int ruib[n];
	int a[n];
	
	rep(i,n)cin>>a[i];
	if(n==2){
		dump(max(a[0],a[1]));
		return 0;
	}
	rep(i,n){
		ruia[i]=a[i];
		ruib[i]=a[i];
	}
	for(int i=1;i<n;i++){
		ruia[i]=__gcd(ruia[i],ruia[i-1]);
		ruib[n-i-1]=__gcd(ruib[n-i],ruib[n-i-1]);
		//debug(n-i,n-i-1);
		//cerr<<endl;
	}
	rep(i,n){
		//debug(ruia[i],ruib[i]);
	}
	ans=max({ans,ruib[1],ruia[n-2]});
	//debug(ruib[1],ruia[n-2]);
	rep(i,n-2){
		//debug(i,i+2);
		ans=max(ans,__gcd(ruia[i],ruib[i+2]));
	}
	dans;
}





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

int main(){
    double r;
    cin >> r;
    //cout << r * PI << endl;
    printf("%.9f\n",2*r*PI);
    return 0;
}


Measured memory_bytes: 3784
n = int(input())
a = list(map(int,input().split()))
r = max(a)+1
s = []
t = [0]*r
for i in range(r):
    s.append([])
for i in range(2,r):
    if(s[i] == []):
        for j in range(1,-(-r//i)):
            s[i*j].append(i)
for i in range(n):
    for j in range(len(s[a[i]])):
        t[s[a[i]][j]] += 1
if(max(t) == n):
    print('not coprime')
elif(max(t) <= 1):
    print('pairwise coprime')
else:
    print('setwise coprime')

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

int main()
{
    int h, w;
    cin >> h >> w;
    string s;
    for (int i = 0; i < h + 2; i++)
    {
        if (i == 0 || i == h + 1)
        {
            for (int j = 0; j < w + 2; j++)
                cout << "#";
        }
        else
        {
            cin >> s;
            cout << "#";
            cout << s;
            cout << "#";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3596
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b, c, d; cin >> a >> b >> c >> d;
	int amt1 = c/b, amt2 = a/d;
	if(c%b) amt1++;
	if(a%d) amt2++;
	if(amt1 > amt2) println("No");
	else println("Yes");
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
using namespace std;
#define LL long long
long long a[100000+13];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
	}
	LL l=2,r=2;
	LL tpl,tpr;
	for(int i=n;i>=1;--i){
		tpl=l/a[i]*a[i];
		if(tpl<l)tpl+=a[i];
		tpr=r/a[i]*a[i];
		if(tpl>r||tpr<l){
			printf("-1\n");
			return 0;
		}
		l=tpl;
		r=tpr+a[i]-1;
	}
	printf("%lld %lld\n",l,r);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define max 1000000
int main()
{
    int n;
    cin >> n;
    ll a[n + 5] = {0};
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum = (sum ^ a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        cout << (sum ^ a[i]) << " ";
    }
    return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  vector<int> poles(999);
  poles.at(0)=1;
  for(int i=1;i<999;i++){
    poles.at(i)=poles.at(i-1)+i+1;
  }
  int diff=b-a;
  int origin_b=poles.at(diff-1);
  cout<<origin_b-b<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
for i in range(M):
    a.append(list(map(int, input().split())))
b = [0, float("INF")]
for i in range(M):
    b[0] = max(a[i][0], b[0])
    b[1] = min(a[i][1], b[1])
if b[0] <= b[1]:
    print(b[1] - b[0] + 1)
else:
    print(0)

Measured memory_bytes: 27344
/*
ID: alec3
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }



using namespace std;


int main()
{
    io;
    int n;
    cin >> n;
    vector<ll> a(n);
    for(auto& it : a) cin >> it;

    ll mx = -1;
    ll ans = 0;
    for (int i =0; i < n; i++){
        if (a[i] < mx)
            ans += (mx - a[i]);

        mx = max(mx, a[i]);
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 4764
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,M = LMIIS()
    X = LMIIS()
    X.sort()
    place = [False]*M
    if N>=M:
        print(0)
        return
    
    diff = []
    pre = X[0]

    for i,x in enumerate(X):
        diff.append((x-pre,i))
        pre = x

    
    sorted_d = sorted(diff,reverse=True)
    # print(diff)
    # 答えは絶対にM//N 以下
    N -= 1 #一番左端に一つおく
    place[0] = True
    num = 0
    for d,i in sorted_d:
        if num == N:
            break
        place[i] = True
        num += 1
    # print(place)
    # print(diff)
    sum_l = 0
    for i,b in enumerate(place):
        if b:
            pass
        else:
            d,di = diff[i]
            # print(b,diff[i])
            sum_l += d
    print(sum_l)
        


if __name__ == '__main__':
    main()

Measured memory_bytes: 60712
from itertools import accumulate
N, K = map(int, input().split())
As = list(map(int, input().split()))

subsecs = []
S = [0] + list(accumulate(As))
for f in range(1, N+1):
    for t in range(f, N+1):
        subsecs.append(S[t] - S[f-1])

ans = 0
digit = 1 << 40
for d in range(41):
    nsubsecs = []
    for subsec in subsecs:
        if subsec & digit:
            nsubsecs.append(subsec)
    if len(nsubsecs) >= K:
        ans += digit
        subsecs = nsubsecs
    digit >>= 1
print(ans)


Measured memory_bytes: 29576
#define NDEBUG;
#include <cassert>
#include <cstddef>
#include <utility>
#include <vector>


template <class Abelian> class PotentializedUnionFind {

public:
	using value_type = Abelian;
	using difference_type = std::ptrdiff_t;
	using container_type = std::vector<std::pair<difference_type, value_type>>;
	using const_reference = const value_type &;
	using size_type = typename container_type::size_type;

protected:
	container_type c;

private:
	value_type potential(size_type x) {
		value_type ret = {};
		while (c[x].first >= static_cast<difference_type>(0)) {
			if (c[static_cast<size_type>(c[x].first)].first >=
				static_cast<difference_type>(0)) {
				c[x].second =
					c[static_cast<size_type>(c[x].first)].second + c[x].second;
				c[x].first = c[static_cast<size_type>(c[x].first)].first;
			}
			ret = ret + c[x].second;
			x = static_cast<size_type>(c[x].first);
		}
		return std::move(ret);
	}

public:
	PotentializedUnionFind() : c() {}
	explicit PotentializedUnionFind(const size_type size)
		: c(size, std::make_pair(-1, value_type())) {}

	size_type size() const { return c.size(); }
	bool empty() const { return c.empty(); }

	size_type find(size_type x) {
		assert(x < size());
		while (c[x].first >= static_cast<difference_type>(0)) {
			if (c[static_cast<size_type>(c[x].first)].first >=
				static_cast<difference_type>(0)) {
				c[x].second =
					c[static_cast<size_type>(c[x].first)].second + c[x].second;
				c[x].first = c[static_cast<size_type>(c[x].first)].first;
			}
			x = static_cast<size_type>(c[x].first);
		}
		return x;
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return potential(y) + (-potential(x));
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return static_cast<size_type>(-c[find(x)].first);
	}

	bool unite(size_type x, size_type y, value_type d) {
		assert(x < size());
		assert(y < size());
		d = d + diff(y, x);
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (c[x].first > c[y].first)
			std::swap(x, y), d = -d;
		c[x].first += c[y].first;
		c[y] = std::make_pair(static_cast<difference_type &&>(x), std::move(d));
		return true;
	}
};

#include<cstdio>

int main() {
	using uint = unsigned int;
	uint n, m;
	scanf("%u%u", &n, &m);
	PotentializedUnionFind<int> T(n);
	while (m--) {
		uint l, r;
		int d;
		scanf("%u%u%d", &l, &r, &d);
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stack>
using namespace std;
string s;
int n;
int p;

int getNum(){
  int res=0;
  while('0'<=s[p]&&s[p]<='9'){
    res*=10;
    res+=(s[p]-'0');
    p++;
  }
  return res;
}

int calc(){
  stack<int> st;
  st.push(getNum());
  while(1){
    char ch=s[p++];
    if(ch=='=')break;
    int num=getNum();
    if(ch=='+')st.push(num);
    else if(ch=='*'){
      int x=st.top();st.pop();
      st.push(x*num);
    }
  }
  int res=0;
  while(!st.empty()){
    res+=st.top();
    st.pop();
  }
  return res;
}

int calc2(){
  int res=getNum();
  while(1){
    char ch=s[p++];
    if(ch=='=')break;
    int num=getNum();
    if(ch=='+')res+=num;
    else if(ch=='*')res*=num;
  }
  return res;
}

int main(){
  cin>>s>>n;
  s+="=";
  p=0;
  int a=calc();
  p=0;
  int b=calc2();
  if(a==n&&b!=n)cout<<'M'<<endl;
  else if(a!=n&&b==n)cout<<'L'<<endl;
  else if(a==n&&b==n)cout<<'U'<<endl;
  else cout<<'I'<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
int main(void){
	int i;
	int a,b,c;
	
	for(i=0;i<7;i++){
		scanf("%d %d",&a,&b);
		c=a-b;
		printf("%d\n",c);
	}
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
 
            int A = s[0];
            int B = s[1];
            int X = s[2];
          
          	if( A <= X && X <= A+B ){
              Console.WriteLine("YES");
            }
          	else{
              Console.WriteLine("NO");        
            }
          	//( A <= X || X <= A+B ) ? Console.WriteLine("YES") : Console.WriteLine("NO");
        }
    }
}

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

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



vector<vector<ll>> wsmap;
  ll n, m, r;

vector<ll> rr;

ll minJourney(vector<bool> chk,ll nowc, ll nowid){

  ll cost = LLINF;
  bool isallchk = true;

  for(int i=0;i<r;i++){
    vector<bool> chk2 = chk;

    if (chk[i] == false){
      ll tmpnowc = nowc;
      chk2[i] = true;
      if (nowid!=-1)tmpnowc += wsmap[nowid][rr[i]];
      cost = min(minJourney(chk2,tmpnowc,rr[i]),cost);
      isallchk = false;
    }
  }

  if (isallchk){
    return nowc;
  }


  return cost;

}

int main() {

  cin >> n >> m >> r;

  rr = vector<ll>(r, 0);
  cin >> rr;

  vector<ll> a(m, 0);
  vector<ll> b(m, 0);
  vector<ll> c(m, 0);

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

  ll ans =0;

  vector<vector<ll>> map(n+1,vector<ll>(n+1,LLINF));
  wsmap =  vector<vector<ll>>(n+1,vector<ll>(n+1,LINF));


  for (int i = 0; i < m; ++i){
    // map[a[i]][b[i]] = c[i];
    wsmap[a[i]][b[i]] = c[i];
    wsmap[b[i]][a[i]] = c[i];
  }

  //warshall floid

  for (int i = 1; i <= n; ++i){
    for (int j = 1; j <= n; ++j){
      for (int k = 1; k <= n ; ++k){
        wsmap[j][k] = min(wsmap[j][k], wsmap[j][i] + wsmap[i][k]);
      }
    }
  }
  for (int i = 1; i <= n; ++i){
    for (int j = 1; j <= n; ++j){
      cerr << wsmap[i][j] << ",";
    }
    cerr << endl;
  }

  vector<bool> chk(r,false);

  ans = minJourney(chk,0,-1);



  cout << ans << endl;




}




















Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
	int i, j, k, rank, array[52];
	char moji;
	
	scanf("%d\n", &i);
	for(j = 0; j<=51; j++){
		array[j] = 0;
	}
	for(j=0; j < i; j++){
		scanf("%c %d", &moji, &rank);
		if(j != i-1) scanf("\n");
		if(moji == 'S'){
			array[rank-1] = 1;
		}
		if(moji == 'H'){
			array[rank+12] = 1;
		}
		if(moji == 'C'){
			array[rank+25] = 1;
		}
		if(moji == 'D'){
			array[rank+38] = 1;
		}
	}
	
	for(j=0; j <= 51; j++){
		if(array[j] == 0 && j <= 12)printf("S %d\n", j+1);
		if(array[j] == 0 && j <= 25 && j >= 13)printf("H %d\n", j%13+1);
		if(array[j] == 0 && j <= 38 && j >= 26)printf("C %d\n", j%13+1);
		if(array[j] == 0 && j <= 51 && j >= 39)printf("D %d\n", j%13+1);
	}
	
	return 0;
}

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

int main() {
  string a,b,c,x,y,z;
  cin >> a >> b >> c;

  // ここにプログラムを追記
  x = a.at(0);
  y = b.at(0);
  z = c.at(0);
  cout << x+y+z << endl;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

template<class W>
struct edge{
	int from, to;
	W weight;
	edge(int from, int to, W weight):from(from), to(to), weight(weight){}
};
template<class W> using node = vector<edge<W>>;
template<class W> using graph = vector<node<W>>;
template<class W> void addedge(graph<W> &g, int from, int to, W weight, bool bidirectional = false){
	g[from].emplace_back(edge<W>(from, to, weight));
	if(bidirectional)g[to].emplace_back(edge<W>(to, from, weight));
}


class Solution {
public:
	void solve() {
		using pii = pair<int, int>;
		int n, m, l;
		cin >> n >> m >> l;
		graph<int> g(n);
		vector<vector<int>> d(n, vector<int>(n, 0x3f3f3f3f));
		for(int i=0; i < m; i++){
			int a, b, c;
			cin >> a >> b >> c;
			
			addedge(g, a-1, b-1, c, true);
		}
		for(int i=0; i < n; i++){
			priority_queue<pii> q;
			vector<int> r(n, -1);
			q.push(make_pair(l, i));
			r[i] = l;
			while(!q.empty()){
				int rem, node;
				tie(rem, node) = q.top();
				q.pop();
				d[i][node] = 1;
				for(auto e: g[node]){
					if(r[e.to] < rem - e.weight){
						q.push(make_pair(rem-e.weight, e.to));
						r[e.to] = rem-e.weight;
					}
				}
			}
		}
		for(int k=0; k < n; k++){
			for(int i=0; i < n; i++){
				for(int j=0; j < n; j++){
					updmin(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}

		int Q;
		cin >> Q;
		for(int q=0; q < Q; q++){
			int s, t;
			cin >> s >> t;
			if(d[s-1][t-1] == 0x3f3f3f3f)cout << -1 << "\n";
			else cout << d[s-1][t-1]-1 << "\n";				
		}

	
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main(){
	long long int N, i, j;
	cin >> N;
	string S[N];
	for(i=0; i<N; i++){
		cin >> S[i];
	}

	vector<string> A;
	for(i=0; i<N; i++){
		A.push_back(S[i]);
	}
	
	sort(A.begin(), A.end());

	int ans=1;
	for(i=0; i<N-1; i++){
		if(A[i]!=A[i+1])	ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 17840
#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;

  return i != n;
}

int main() {
  int i, n, A[10001], q, key, sum = 0;

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

  scanf("%d", &q);
  for(i = 0; i < q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }

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



Measured memory_bytes: 2708
program ABC162B
    implicit none
    integer(8)::N,i,ans
    read*,N
    ans=0
    do i=1,N
        if(mod(i,15)/=0.and.mod(i,5)/=0.and.mod(i,3)/=0)ans=ans+i
    end do

    print'(i0)',ans
end program ABC162B

Measured memory_bytes: 2920
(function(stdin) {
'use strict';

  var inputs = stdin.toString().trim().split('\n');
  var lines  = inputs.map(function(v) {
    return v.split(' ').map(Number);
  });
  var result = (function(lines) {

    return lines.map(function(v) {
      return v.reduce(function add(a, b) {
        return a + b;
      });
    }).join('\n');

  })(lines);

  console.log(result);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15800