akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <climits>

long long operate(long long lhs, long long rhs, char op) {
  if (op == '+') return lhs + rhs;
  if (op == '-') return lhs - rhs;
  if (op == '*') return lhs * rhs;

  assert(0);
}

long long parse_expr(
    const std::string &str, size_t &cursor,
    const std::vector<std::string> &ops, size_t preced=0) {

  // Parses as:
  // <expr0> ::= <expr1> [<op0> <expr1>]...
  // <expr1> ::= <expr2> [<op1> <expr2>]...
  // ...
  // <exprN> ::= '('<expr0>')' | <number>

  if (ops[preced].empty())
    // no more operators; now parse integers or parentheses
    if (str[cursor] == '(') {
      long long tmp=parse_expr(str, ++cursor, ops, 0);
      ++cursor;  // ')'
      return tmp;
    } else {
      long long res=0;
      while (str[cursor] >= '0' && str[cursor] <= '9')
        res = res*10 + str[cursor++]-'0';

      return res;
    }

  long long res=parse_expr(str, cursor, ops, preced+1);
  while (cursor < str.length()) {
    char op=str[cursor];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op))
      break;  // lower-precedence operations found

    long long tmp=parse_expr(str, ++cursor, ops, preced+1);
    res = operate(res, tmp, op);
  }

  return res;
}

int main() {
  char buf[256];
  scanf("%s", buf);
  std::string s=buf;

  char oplist[256]={};
  long long res=LLONG_MIN;

  for (int i=0; i<27; ++i) {
    oplist['+'] = i % 3;
    oplist['-'] = (i/3) % 3;
    oplist['*'] = (i/9) % 3;

    std::vector<std::string> ops(4);
    for (int ch: {'+', '-', '*'})
      ops[oplist[ch]].push_back(ch);

    if (ops[0].empty()) continue;
    if (ops[0].length() < 3 && ops[1].empty()) continue;

    size_t index=0;
    res = std::max(res, parse_expr(s, index, ops));
  }

  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 2828
#include <stdio.h>

int main()
{
	int A[3];
	int i, S=0;
	
	for(i=0; i<3; i++){
		scanf("%d", &A[i]);
		S=S+A[i];
	}
	
	if(S<=21){ printf("win\n"); }
	else { printf("bust\n"); }
	
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int a[100];
int main()
{
	int n, m, x, i, j;
	int p = 0;
	int q = 0;
	int temp;
	scanf("%d%d%d", &n, &m, &x);
	for (i = 0; i < m; i++)
		scanf("%d",&a[i]);
	if ((x == n + 1)||(x==0)||(x==n))
	{
		printf("0");
		goto here;
	}
	if (a[m - 1] == n + 1)
	{
		for (i = 0; i < m; i++)
		{
			if (a[i] < x)
				p++;
			else
				break;
		}
		q = m - p - 1;
		temp = q > p ? p : q;
		printf("%d", temp);
	}
	if (a[m - 1] != n + 1)
	{
		p = 0;
		for (i = 0; i < m; i++)
		{
			if (a[i] < x)
				p++;
			else
				break;
		}
		q = m - p;
		temp = q > p ? p : q;
		printf("%d", temp);
	}
	here:
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n[10];
int N;

int main(){
    for (int i =0; i< 10; i++){
        n[i] = 0;
    }
    cin >> N;
    for (int i =0; i< N; i++){
        cin >> n[i];
    }
    sort(n, n+10);
    n[9] /= 2;
    int r = 0;
    for(int i = 0; i<10;i++){
        r += n[i];
    }
    cout << r;
}

Measured memory_bytes: 256
import functools

N = input()
K = int(input())

@functools.lru_cache(maxsize=2048)
def nCk(n, k):
    if k == 0:
        return 0
    elif k == 1:
        return n
    elif k == 2:
        return (n * (n-1)) // 2
    return (n * (n-1) * (n-2)) // 6

def slowsolve(N, K):
    if not N:
        return 0, {}
    ans = 0
    meta = {}
    for i in range(1, int(N) + 1):
        if len(str(i)) - str(i).count("0") == K:
            meta.setdefault(len(str(i)), 0)
            meta[len(str(i))] += 1
            ans += 1
    return ans, meta

def clean(N):
    clean_N = []
    for n in N:
        if n == "0" and not clean_N:
            pass
        else:
            clean_N.append(n)
    if clean_N:
        return "".join(clean_N)
    return ""

@functools.lru_cache(maxsize=2048)
def solve(N, K):
    N = clean(N)

    if len(N) <= 3:
        return slowsolve(N, K)[0]
    elif K == 0:
        return 0
    else:
        m = int(N[0])

        # 一番上を0にする
        ans = solve("9" * len(N[1:]), K)

        if K == 3:
            # 一番上を1 ~ m - 1にする
            # => 下の部分から2か所選び、それぞれ1 ~ 9
            ans += (m - 1) * nCk(len(N[1:]), 2) * 9 * 9
            # 一番上をmにする
            ans += solve(N[1:], K - 1)
        elif K == 2:
            # 一番上を1 ~ m - 1にする
            # => 下の部分から1か所選び、1 ~ 9
            ans += (m - 1) * len(N[1:]) * 9
            # 一番上をmにする
            ans += solve(N[1:], K - 1)
        elif K == 1:
            # 一番上をmにする
            ans += m
        return ans


print(solve(N, K))

Measured memory_bytes: 3808
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

long long A,B,C,D,num1,num2,num3,N;
int main(){
	cin>>A>>B>>C>>D;
	if(C>D) swap(C,D);
	if(__gcd(C,D)==C){
		if(A%C==0)
			cout<<(B-A+1)-(B/C)+(A/C)-1;
		else
			cout<<(B-A+1)-(B/C)+(A/C);
	}
	else if(__gcd(C,D)==1){
		if(A%C==0)
			num1=(B/C)-(A/C)+1;
		else
			num1=(B/C)-(A/C);
		if(A%D==0)
			num2=(B/D)-(A/D)+1;
		else
			num2=(B/D)-(A/D);
		if(A%(C*D)==0)
				num3=(B/(C*D))-(A/(C*D))+1;
		else
				num3=(B/(C*D))-(A/(C*D));
		cout<<(B-A+1)-(num1+num2-num3);
	}
	else{
		N=(C/__gcd(C,D))*D;
		if(A%C==0)
			num1=(B/C)-(A/C)+1;
		else
			num1=(B/C)-(A/C);
		if(A%D==0)
			num2=(B/D)-(A/D)+1;
		else
			num2=(B/D)-(A/D);
		if(A%N==0)
				num3=(B/N)-(A/N)+1;
		else
				num3=(B/N)-(A/N);
		cout<<(B-A+1)-(num1+num2-num3);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7
vector<int>a,b,c;
void max_points(int n,int dp[]){
	    
	       if(n==1){
		    dp[0]=a[0]; dp[1]=b[0]; dp[2]=c[0];
		    return;
		     }
		     int dp1[3];
		  max_points(n-1,dp);
		   for(int i=0; i<3; i++)
		    dp1[i]=dp[i];
		   
		   dp[0]=max(a[n-1]+dp1[1],a[n-1]+dp1[2]);
		   dp[1]=max(b[n-1]+dp1[0],b[n-1]+dp1[2]);
	    dp[2]=max(c[n-1]+dp1[0],c[n-1]+dp1[1]);
		  //  cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<" "<<n<<endl;
		    return ;
		    
	 
	
}

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
         
      int n;
         cin>>n;
         a.resize(n);
         b.resize(n);
         c.resize(n);
         for(int i=0; i<n; i++)
            cin>>a[i]>>b[i]>>c[i]; 
          
         int dp[3];
           max_points(n,dp); 
           
           cout<<max(dp[0],max(dp[1],dp[2]));
           
    }

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    } else if (b == c) {
        cout << a << endl;
    } else if (a == c) {
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * n ????????´??°???????????????????????????????????????????´???°?????°???????????????????????°??????
 * ??\???
 * ??????????????? n ?????????????????????????¶???? n ?????? n ????????´??°????????????????????????
 * <p>
 * ??????
 * ??\???????????????????´???°?????°???????????????????????????????????????
 * <p>
 * ??¶?´?
 * 1 ??? n ??? 10,000
 * 2 ??? ?????????????????´??° ??? 10e8
 */

import java.util.Scanner;

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

		int n = stdIn.nextInt();
		int[] numbers = new int[n];

		for (int i = 0; i < n; i++) {
			numbers[i] = stdIn.nextInt();
		}
		//long start = System.currentTimeMillis();

		int counter = 0;
		int i;

		Outer:
		for (int number : numbers) {

			/*2????´???°*/
			if (number == 2) {
				counter++;
				continue;
			}

			/*1??¨??¶??°????´???°??§?????????*/
			if (number % 2 == 0 || number < 2) {
				continue;
			}

			/*??¶??°?????????????????? ????????°??????????????\????????°?????§???????????°??????*/
			for (i = 3; i <= Math.sqrt(number); i += 2) {
				if (number % i == 0) {
					continue Outer;
				}
			}
			counter++;
		}

		/*long end = System.currentTimeMillis();
		System.out.println((end - start)  + "ms");*/

		System.out.println(counter);
	}



//?¨???¬???????????????????¨???°


}

/**
 * ????????¢?????´????????????????????????????????´??°  ??? 2 ????????? ?????§?????°??§?????????????????????????????????????????????????????§???
 * ?????¨??????????????????????????? ?????¨?????¨?????????  ???????¨?????????????????¨????????????????????????¶?????????????????????????????????????????¨?????§???????????????
 * ????????§??????????????????????????????????????????????????????
 * <p>
 * ?????????2 ??\????????¶??°????´???°??§??????????????¨????????¨????????°?¨????????????????????????????  ??????????????§???????????°????????¨???????????°?????????????????????????????¨?????§????????????
 * ???????????????????????\?????????????????????  ?????¢?????´??????????????????????????????????????????
 * <p>
 * ?´???°????????§?????????????????°  ???  ?????????????´??????? ??????????????¨????????§???????????¨???????????¨?????§????????????
 * ????????§????´???°??§???????????°???????????°??¨?¨?????????????
 * ????????°???31 ????´???°???????????????????????????31 ??? 2 ?????? 6 ?????§?????°??§?????£???????????°????????¨???????????¨??????????????????
 * ?????? 7 ??????30?????§?????°??§ 31 ????????????????????°????????¨???????????§????????°???
 * ?????§???????????? 2 ?????? 6 ?????§?????°??? 31 ????????????????????°??????????????¨???????????§???6 ????¶?????????°????????????????????¨???????§???????????????????
 * <p>
 * ??????????????¨????????¨???2 ?????? ??? ?????§??§????????????2 ??????  ?????§?????????????????????????????????????????????????????°??????????????§??? ?????¢?????´?????????????????????????????¨?????§????????????????????????????????°  ??? 1,000,000 ??¨????????¨ = 1,000 ??¨??????????´???´?????¢?????´?????????????????????????????? 1,000 ????????????????????????
 */

Measured memory_bytes: 42288
/*
      author : nishi5451
      created: 11.08.2020 20:13:54
*/

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


int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(x>=a && x<=a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CADDi_B solver = new CADDi_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class CADDi_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextLong();
            long y = in.nextLong();
            long a, b;
            long ans = 0;
            for (int i = 0; i < n; i++) {
                a = in.nextLong();
                b = in.nextLong();

                if (a >= x && b >= y) {
                    ans++;
                }
            }

            out.print(ans);


        }

    }
}



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

int vis[11];
char a[11];
ll sum;

void digui(int x, int t, int y, int m){
    if(x == y){
     //   ll sum1 = sum;
     //   printf("%lld", sum1);
        ll s = 0;
        for(int i = 0; i < m; i++){
            s = s*10+a[i]-'0';
            if(vis[i]){
                sum += s;
                s = 0;
            }
        }
        sum += s;
     //   printf("  %lld\n", sum-sum1);
        return ;
    }
    for(int i = t; i < m-1; i++){
        if(!vis[i]){
            vis[i] = 1;
           // printf("%d %d %d %d\n", i, x, y, m);
            digui(x+1, i+1, y, m);
            vis[i] = 0;
        }
    }
}

int main(){
    while(~scanf("%s", a)){
        sum = 0;
        int sa = strlen(a);
        for(int i = 0; i < sa-1; i++){
            memset(vis, 0 ,sizeof(vis));
            digui(0,0,i+1, sa);
        }
        ll s = 0;
        for(int i = 0; i < sa; i++) s = s*10+a[i]-'0';
        printf("%lld\n", sum+s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<ll> ALL;
  {
    priority_queue<ll> P;
    rep(i, A) {
      ll p;
      cin >> p;
      P.push(p);
    }
    rep(i, X) {
      ALL.push(P.top());
      P.pop();
    }
  }
  {
    priority_queue<ll> Q;
    rep(i, B) {
      ll q;
      cin >> q;
      Q.push(q);
    }
    rep(i, Y) {
      ALL.push(Q.top());
      Q.pop();
    }
  }
  rep(i, C) {
    ll r;
    cin >> r;
    ALL.push(r);
  }
  ll ans = 0;
  rep(i, X+Y) {
    ans += ALL.top();
    ALL.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6476
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nums = inputs.head.split(" ").map(_.toInt)
  val a = nums(0)
  val b = nums(1)
  val c = nums(2)

  println(solve(a, b, c))

  def solve(a: Int, b: Int, c: Int): String = {
    val num = a * 100 + 10 * b + c

    if (num % 4 == 0) {
      "YES"
    } else {
      "NO"
    }
  }
}

Measured memory_bytes: 54776
abc = map(int, input().split())

c5 = 0
c7 = 0
for x in abc:
    if x == 5:
        c5 += 1
    if x == 7:
        c7 += 1

if c5 == 2 and c7 == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int main(void)
{
    string s,t;
    cin >> s;
    cin >> t;

    bool isplus= s.size() + 1 == t.size();
    if(isplus){
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] != t[i])
        {
            isplus =false;
            break;
        }
    }
    }

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


    return 0;
}

Measured memory_bytes: 3040
#include <iostream>

using namespace std;

bool p[1000001];

void primes() {
    for (int i = 0; i < 1000001; i++) {
        p[i] = true;
    }
    
    p[0] = p[1] = false;
    
    for (int i = 2; i < 1000001; i++) {
        if (p[i]) {
            for (int j = i * 2; j < 1000001; j += i) {
                p[j] = false;
            }
        }
    }
}

int main() {
    int n, x;
    primes();

    while (true) {
        cin >> n >> x;
        if (!n && !x) break;
        
        bool dp[1000001] = {false};
        int dishes[30];

        for (int i = 0; i < n; i++) {
            cin >> dishes[i];
            dp[dishes[i]] = true;
        }

        for (int i = 0; i < 1000001; i++) {
            for (int j = 0; j < n; j++) {
                if (i - dishes[j]  >= 0) {
                    if (dp[i - dishes[j]]) {
                        dp[i] = true;
                        break;
                    }
                }
            } 
        }

        int max = 0;
        for (int i = 0; i <= x; i++) {
            if (p[i] && dp[i]) max = i;
        }

        if (max) {
            cout << max << endl;
        } else {
            cout << "NA" << endl;
        }
        
    }

    return 0;
}

Measured memory_bytes: 3120
import Control.Applicative
import Control.Monad
import Data.List

f :: String -> (Int, Int)
f s = g (0, 0) s

g (x, y) [c] = if x>y then (x+1, y) else (x, y+1)
g (x, y) (_:ds@(d:_))
  | d == 'A' = g (x+1, y) ds
  | d == 'B' = g (x, y+1) ds

main = map f . takeWhile (/="0") . lines <$> getContents >>= mapM_ (\(x, y) -> putStrLn $ show x ++ " " ++ show y)


Measured memory_bytes: 3456
S=input()
L=len(S)
a=1
l=1
t=S[0]
i=1
while i<L:
    if l==1:
        if S[i-1]==S[i] and i!=L-1:
            t=S[i:i+2]
            l=2
            i+=2
        elif S[i-1]!=S[i]:
            t=S[i]
            i+=1
        else:
            break
    else:
        t=S[i]
        l=1
        i+=1
    a+=1
print(a)

Measured memory_bytes: 3500
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,m;cin >> n >> m;
    if(n==2||m==2) cout << 0 << endl;
    else if(n*m==1) cout << 1 << endl;
    else if(n==1||m==1) cout << n*m-2 << endl;
    else cout << (n-2)*(m-2) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << ((n < a + b) ? a + b - n : 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vpll vector<pll>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
 
using namespace std ;


// Returns the maximum value that can be put in a knapsack of capacity W
lli knapsack(lli W, lli wt[], lli val[], lli n)
{
   lli i, w;
   lli K[n+1][W+1];

   // Build table K[][] in bottom up manner
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main()
{
    
    lli n,W;
    cin>>n>>W;

    lli val[n],wt[n];

    loopl(i,0,n)
    cin>>wt[i]>>val[i];

    cout<<knapsack(W, wt, val, n);
    return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,b,c,d=0,e=0;
signed main(){
	cin>>a>>b;
	if(a==2||b==2){
		cout<<"No";
	}else{
		cout<<"Yes";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,lt,d;
char s[500];
int main(){
	scanf("%d%s",&n,s+1);
	fo(i,1,n){
		if (s[i]=='('){
			d++;
		}
		if (s[i]==')'){
			if (d) d--;else lt++;
		}
	}
	fo(i,1,lt) putchar('(');
	printf("%s",s+1);
	fo(i,1,d) putchar(')');
	return 0;
}

Measured memory_bytes: 128
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int k, q; cin >> k >> q;
    vector<int> d(k);
    rep(i, k) {
        cin >> d[i];
    }
    while(q--) {
        int n, x, m; cin >> n >> x >> m;
        vector<int> dmod(k + 1, 0), dz(k + 1, 0);
        rep(i, k) {
            dmod[i + 1] = dmod[i] + (d[i] % m);
        }
        rep(i, k) {
            if(d[i] % m == 0) dz[i + 1] = dz[i] + 1;
            else dz[i + 1] = dz[i];
        }
        x %= m;
        int cnt0 = dz[k] * ((n - 1) / k) + dz[(n - 1) % k];
        int a = x + dmod[k] * ((n - 1) / k) + dmod[(n - 1) % k];
        int cnt1 = a / m;
        //cerr << cnt0 << " " << cnt1 << endl;
        cout << n - 1 - cnt0 - cnt1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import deque


def main():
    N = int(input())
    C = []
    T = [[] for j in range(N + 1)]
    for i in range(N - 1):
        a, b = [int(x) for x in input().split()]
        T[a].append([b, i])
        T[b].append([a, i])
        C.append(a)
        C.append(b)
    

    q = deque()
    q.append([1, 0])

    visited = set()
    ans = [0] * N
    while q:
        i, color = q.popleft()
        visited.add(i)
        now_color = 0
        for v, j in T[i]:
            if not v in visited:
                now_color += 1
                if now_color == color:
                    now_color += 1
                q.append([v, now_color])
                ans[j] = now_color
    
    print(max(ans))
    for i in range(N - 1):
        print(ans[i])



    

    



if __name__ == '__main__':
    main()


Measured memory_bytes: 53640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=20003,INF=1<<30;

vector<pair<int,ll>> G[MAX];
ll dis[MAX];

void dijkstra(int u){
    dis[u]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
    
    PQ.push(make_pair(0,u));
    while(!PQ.empty()){
        ll a=PQ.top().first;
        int b=PQ.top().second;
        PQ.pop();
        if(dis[b]<a) continue;
        for(int i=0;i<G[b].size();i++){
            int c=G[b][i].first;
            ll d=G[b][i].second;
            if(dis[c]>dis[b]+d){
                dis[c]=dis[b]+d;
                PQ.push(make_pair(dis[c],c));
            }
        }
    }
    return;
}//a,dが長さ

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,T,K,M,start,goal;cin>>N>>T>>K>>M>>start>>goal;
        if(N==0) break;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<200;j++){
                dis[i*200+j]=INF;
                G[i*200+j].clear();
            }
        }
        
        for(int i=0;i<K;i++){
            int a;cin>>a;
            for(int j=0;j<T;j++){
                G[a*200+j].push_back({a*200+j+1,1});
            }
        }
        
        for(int i=0;i<M;i++){
            int a,b,c;cin>>a>>b>>c;
            for(int j=0;j+c<=T;j++){
                G[a*200+j+c].push_back({b*200+j,c});
                G[b*200+j+c].push_back({a*200+j,c});
            }
        }
        
        dijkstra(start*200+T);
        
        ll ans=INF;
        
        for(int j=0;j<=T;j++) ans=min(ans,dis[goal*200+j]);
        
        if(ans!=INF) cout<<ans<<endl;
        else cout<<"Help!"<<endl;
    }
}







Measured memory_bytes: 8652
#include<bits/stdc++.h>
#include <unordered_map>
#define int int64_t
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
using namespace std;
const int N=500000;
bool prime[N];
void sieve(){
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    int a=nxt(),b=nxt();
    int arr[a];
    memset(arr,0,sizeof arr);
    for(int i=0;i<b;i++){
        int n=nxt();
        for(int i=0;i<n;i++){
            int num=nxt()-1;
            arr[num]++;
        }
    }
    int cnt=0;
    for(int i=0;i<a;i++)cnt+=(arr[i]==0?1:0);
    cout<<cnt;
    exit
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int N, K;

int x[50], y[50];
vector<int> xlist, ylist;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		xlist.push_back(x[i]), ylist.push_back(y[i]);
	}
	sort(xlist.begin(), xlist.end()), sort(ylist.begin(), ylist.end());
	xlist.erase(unique(xlist.begin(), xlist.end()), xlist.end());
	ylist.erase(unique(ylist.begin(), ylist.end()), ylist.end());
	ll ans = 9000000000000000000;
	for (int i = 0; i < xlist.size(); i++) {
		for (int j = 0; j < ylist.size(); j++) {
			ll sx = xlist[i], sy = ylist[j];
			for (int k = 0; k < xlist.size(); k++) {
				for (int l = 0; l < xlist.size(); l++) {
					ll ex = xlist[k], ey = ylist[l], rsx = sx, rsy = sy;
					if (rsx > ex)swap(rsx, ex);
					if (rsy > ey)swap(rsy, ey);

					int ct = 0;
					for (int m = 0; m < N; m++) {
						if (x[m] >= rsx && x[m] <= ex && y[m] >= rsy && y[m] <= ey)ct++;
					}
					if (ct >= K) {
						ans = min(ans, (ex - rsx) * (ey - rsy));
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = gets.strip.split(" ").map(&:to_i)

b = 1
e = n

m.times do
  l, r = gets.strip.split(" ").map(&:to_i)

  if l <= b && r >= e
    next
  elsif (l >= b && l <= e) || (r >= b && r <= e)
    b = [b, l].max
    e = [e, r].min
  else
    b = -1
    break
  end
end

puts b == -1 ? 0 : (e - b + 1)


Measured memory_bytes: 1788
package main

import (
	"fmt"
	"strconv"
)

type card struct {
	key   string
	value int
}

// 挿入ソート
func main() {

	var num int
	// fmt.Scanは自動で空白区切で読み込む
	fmt.Scan(&num)
	cards := make([]card, num)
	for i := range cards {
		fmt.Scan(&cards[i].key)
		buf, _ := strconv.Atoi(cards[i].key[1:])
		cards[i].value = buf
	}

	cardsForSl := make([]card, num)
	copy(cardsForSl, cards)

	bubleSort(cards)
	output(cards)
	fmt.Println("Stable")

	selectionSort(cardsForSl)
	output(cardsForSl)
	if isStable(cards, cardsForSl) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

}

func bubleSort(cards []card) {
	n := len(cards)
	for i := 0; i <= n-1; i++ {
		for j := n - 1; j >= i+1; j-- {
			if cards[j].value < cards[j-1].value {
				buf := cards[j]
				cards[j] = cards[j-1]
				cards[j-1] = buf
			}
		}
	}
}

func selectionSort(cardsForSl []card) {
	n := len(cardsForSl)
	for i := 0; i <= n-1; i++ {
		minj := i
		for j := i; j <= n-1; j++ {
			if cardsForSl[j].value < cardsForSl[minj].value {
				minj = j
			}
		}
		buf := cardsForSl[minj]
		cardsForSl[minj] = cardsForSl[i]
		cardsForSl[i] = buf
	}
}

func output(cards []card) {
	for i, e := range cards {
		fmt.Print(e.key)
		if i != len(cards)-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}
}

func isStable(cards []card, cardsForSl []card) bool {
	for i := 0; i < len(cards); i++ {
		if cards[i] != cardsForSl[i] {
			return false
		}
	}
	return true
}



Measured memory_bytes: 1132
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] -= (i+1)
A.sort()
if N % 2 == 0:
    M = A[N//2]
else:
    M = A[(N-1)//2]
for i in range(N):
    A[i] = abs(A[i] - M)
print(sum(A))


Measured memory_bytes: 26708
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n;
int arr[100];
// map<pair<int,pair<int,int>>,int>mp;
// int dp(int pos,int st,int mon)
// {
//     print(pos,st,mon);
//     if(pos==n)
//         return mon;
//     if(mp.find({pos,{st,mon}})!=mp.end())
//         return mp[{pos,{st,mon}}];
//     int ans=dp(pos+1,st,mon);
//     int takest=mon/arr[pos];
//     int sell=min(st,takest);
//     ans=max(ans,dp(pos+1,st-sell,mon+sell*arr[pos]));
//     ans=max(ans,dp(pos+1,st+takest,mon-takest*arr[pos]));
//     mp[{pos,{st,mon}}]=ans;
//     return ans;
// }
int32_t main() 
{
    IOS;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int mon=1000,st=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]<arr[i+1])
        {
            int take=mon/arr[i];
            int sell=take*arr[i+1];
            mon=mon-take*arr[i]+sell;
        }
    }
    print(mon);
}   

Measured memory_bytes: 3644
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	c = c - (a - b);
	if (c < 0)
		c = 0;
	cout << c;
	return 0;
}

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

using namespace std;

const int N = 1e5 + 7 ; 
int n; 

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);


        int x ; cin >> x; 
        int ans = 1000 - x % 1000 ; 
        if(ans == 1000) ans = 0  ;
        cout<< ans ; 

        return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

ll dp[200010] = {};
ll dp1[200010] = {};

signed main() {
  ios::sync_with_stdio(false);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  REP(i, 3001) {
    REP(j, 3001) {
      if(n-(i*r+j*g) < 0) break;
      if((n-(i*r+j*g)) % b == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
const long long inf = 1ll<<40;
long long tree[2][maxn<<2], lazy[2][maxn<<2];
void push(int who, int id, int l, int r){
	if(lazy[who][id]){
		tree[who][id] += lazy[who][id];
		if(l != r){
			lazy[who][id<<1] += lazy[who][id];
			lazy[who][id<<1|1] += lazy[who][id];
		}
		lazy[who][id] = 0;
	}
}
void add_to(int who, int id, int l, int r, int x, int y, long long v){
	push(who, id, l, r);
	if(l > y || r < x) return;
	if(x <= l && r <= y){
		lazy[who][id] += v;
		push(who, id, l, r);
		return;
	}
	int mid = (l + r)>>1;
	add_to(who, id<<1, l, mid, x, y, v);
	add_to(who, id<<1|1, mid + 1, r, x, y, v);
	tree[who][id] = min(tree[who][id<<1], tree[who][id<<1|1]);
}
void amin(int who, int id, int l, int r, int x, long long v){
	push(who, id, l, r);
	if(l > x || r < x) return;
	if(x <= l && r <= x){
		tree[who][id] = min(tree[who][id], v);
		return;
	}
	int mid = (l + r)>>1;
	amin(who, id<<1, l, mid, x, v);
	amin(who, id<<1|1, mid + 1, r, x, v);
	tree[who][id] = min(tree[who][id<<1], tree[who][id<<1|1]);
}
long long get(int who, int id, int l, int r, int x, int y){
	push(who, id, l, r);
	if(l > y || r < x) return inf;
	if(x <= l && r <= y) return tree[who][id];
	int mid = (l + r)>>1;
	return min(get(who, id<<1, l, mid, x, y), get(who, id<<1|1, mid + 1, r, x, y));
}
int main(){
	int n, q, A, B; cin >> n >> q >> A >> B;
	vector<int> pos(q + 1);
	pos[0] = B;
	for(int i = 1; i <= q; i++) cin >> pos[i];
	for(int i = 1; i <= n; i++){
		if(i == A){
			add_to(0, 1, 1, n, i, i, -i);
			add_to(1, 1, 1, n, i, i, +i);
		} else {
			add_to(0, 1, 1, n, i, i, inf);
			add_to(1, 1, 1, n, i, i, inf);
		}
	}
	for(int i = 1; i <= q; i++){
		long long best = min(get(0, 1, 1, n, 1, pos[i]) + pos[i], get(1, 1, 1, n, pos[i], n) - pos[i]);
		long long add = abs(pos[i - 1] - pos[i]);
		add_to(0, 1, 1, n, 1, n, add);
		add_to(1, 1, 1, n, 1, n, add);
	       	amin(0, 1, 1, n, pos[i - 1], best - pos[i - 1]);
		amin(1, 1, 1, n, pos[i - 1], best + pos[i - 1]);	
	}
	long long ans = inf;
	for(int i = 1; i <= n; i++){
		ans = min(ans, get(0, 1, 1, n, i, i) + i);
		ans = min(ans, get(1, 1, 1, n, i, i) - i);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

template<int_fast64_t m=MOD>
struct Mcomb{
  using i64=int_fast64_t;
  vector<i64>f;  //$B3,>h(B
  vector<i64>finv; //$B3,>h$N5U85(B
  vector<i64>inv;  //$B5U85(B

  Mcomb(i64 max){
    f.resize(max+1,0);
    finv.resize(max+1,0);
    inv.resize(max+1,0);
    f[0]=f[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(i64 i=2;i<=max;i++){
      f[i]=f[i-1]*i%m;
      inv[i]=m-inv[m%i]*(m/i)%m;
      finv[i]=finv[i-1]*inv[i]%m;
    }
  }

  //nCr=n!/r!(n-r)!
  i64 slove(i64 n,i64 r){
    if(n<r)return 0;
    if(n<0||r<0)return 0;
    return (f[n]*(finv[r]*finv[n-r]%m)%m)%m;
  }
};

template<uint_fast64_t m>
int_fast64_t mpow(int_fast64_t x,int_fast64_t n){
  using i64=int_fast64_t;
  if(n==0)return 1;
  if(n%2)return ((x%m)*(mpow<m>(x,n-1)%m))%m;
  else {
    i64 half=mpow<m>(x,n/2)%m;
    return (half*half)%m;
  }
}

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

  int K;
  string S;
  cin>>K>>S;
  int N=S.size();
  Mcomb<>c(N+K+1);
  ll ans=0;
  for(int i=0;i<=K;i++){
    ans=(ans+((c.slove(i+N-1,N-1)*mpow<MOD>(25,i))%MOD*mpow<MOD>(26,K-i))%MOD)%MOD;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 51124
#include<bits/stdc++.h>
using namespace std;
const int maxn=605;
const int mod=1e9+7;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,a[maxn],b[maxn],t,c[maxn];
int f[2][maxn][maxn];
inline void add(int &a,int b){
	a=a+b;
	if(a>=mod)a=a-mod;
	if(a<0)a=a+mod;
}
signed main(){
	n=read();
	for(int i=1;i<=2*n;i++)a[i]=read();
	int cnt=0;
	for(int i=1;i<=2*n;i+=2){
		if((a[i]!=-1)&&(a[i+1]!=-1))b[a[i]]=b[a[i+1]]=2;
		else if(a[i]!=-1){b[a[i]]=1;}
		else if(a[i+1]!=-1){b[a[i+1]]=1;}
		else cnt++;
	}
	for(int i=1;i<=2*n;i++){
		if(b[i]==1)c[++t]=1;
		else if(b[i]==0)c[++t]=2;
	}
	f[t&1][0][0]=1;
	for(int i=t;i>=1;i--){
		memset(f[(i-1)&1],0,sizeof(f[(i-1)&1]));
		for(int j=0;j<=t&&j<=n;j++){
			for(int k=0;k<=t&&k<=n;k++){
				if(c[i]==1){
					add(f[(i-1)&1][j+1][k],f[i&1][j][k]);
					if(k)add(f[(i-1)&1][j][k-1],f[i&1][j][k]);
				}
				else{
					add(f[(i-1)&1][j][k+1],f[i&1][j][k]);
					if(k)add(f[(i-1)&1][j][k-1],f[i&1][j][k]);
					if(j)add(f[(i-1)&1][j-1][k],(1ll*f[i&1][j][k]*j)%mod);
				}
			}
		}
	}
	int ans=f[0][0][0];
	for(int i=1;i<=cnt;i++)
	ans=1ll*ans*i%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3072
require 'pp'
n, k, q = gets.split.map(&:to_i)
# p n
# p k
play = Array.new(n+1, k) # [0]は使わない
a = [nil]
q.times do
  a << gets.to_i
end
# pp a[1..-1]
a[1..-1].each do |aa|
  play[aa] += 1
end
# pp play[1..-1]
hoge = []
play[1..-1].each_with_index do |aa, i|
  hoge << (aa >= q+1)
end
puts hoge.map{|h|h ? 'Yes' : 'No'}.join("\n")


Measured memory_bytes: 10360
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let mut x: usize = parse!(it);
    let a = x / 500;
    let b = (x - a * 500) / 5;
    println!("{}", 1000 * a + 5 * b);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
class UnionFind:
    def __init__ (self,n):
        self.parent = [i for i in range (n)]
        self.height = [0 for _ in range (n)]

    def get_root(self,i):
        if self.parent[i] == i:
            return i
        else:
            self.parent[i] = self.get_root(self.parent[i])
            return self.parent[i]

    def unite(self,i,j):
        root_i = self.get_root(i)
        root_j = self.get_root(j)
        if root_i != root_j:
            if self.height[root_i] < self.height[root_j]:
                self.parent[root_i] = root_j
            else:
                self.parent[root_j] = root_i
                if self.height[root_i] == self.height[root_j]:
                    self.height[root_i] += 1

    def is_in_group(self,i,j):
        if self.get_root(i) == self.get_root(j):
            return True
        else:
            return False

def main():
    N,M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range (M):
        A,B = map(lambda x: int(x)-1,input().split())
        uf.unite(A,B)

    check = [0]*N
    for i in range(N):
        check[uf.get_root(i)] += 1
    print(max(check))


main()


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

int main() {
    int n,i;cin>>n;
    int a[n],dp[n];
    for(i=0;i<n;i++) cin>>a[i];
    dp[0]=0;
    for(i=1;i<n;i++){
        if(i==1) dp[i]=abs(a[i]-a[i-1]);
        else dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
    }
    cout<<dp[n-1];
    
}


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

#define MAX 30000

signed main(){
    int n;
    cin >> n;
    int cnt = 0;
    int t, sum = 0;
    for(int i = 1; i <= MAX; i++){
        if(cnt == n - 2){
            t = i;
            break;
        }
        if(i % 2 == 0 || i % 3 == 0 || i % 5 == 0){
            printf("%d ", i);
            cnt++;
            sum += i;
        }
    }
    for(int i = t; i <= MAX; i++){
        if(i % 2 == 0 || i % 3 == 0 || i % 5 == 0){
            for(int j = i + 1; j <= MAX; j++){
                if(j % 2 == 0 || j % 3 == 0 || j % 5 == 0){
                    if((sum + i + j) % 30 == 0){
                        printf("%d ", i);
                        printf("%d\n", j);
                        return 0;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
from collections import deque
# from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	E=[[] for i in range(n+1)]
	O=[]
	for i in range(n-1):
		a,b=map(int,input().split())
		E[a].append(b)
		O.append(b)
		
	C=[0]*(n+1)
	q = deque([1])
	while q:
		now = q.popleft()
		cnt=1
		for i in E[now]:
			if cnt==C[now]:
				cnt+=1
			C[i]=cnt
			cnt+=1
			q.append(i)
	print(max(C))
	for i in O:
		print(C[i])
	
	
if __name__ == "__main__":
		main()


Measured memory_bytes: 62384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << (a / b) << " " << (a % b) << " ";
  cout << fixed << setprecision(5) << (a * 1.0 / b) << endl;
  return 0;
}



Measured memory_bytes: 3288
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			
			int[][]	a = new int[n + 1][n + 1];
			for (int i = 0; i < n; i++) {
				int sum = 0;
				for (int j = 0; j < n; j++) {
					a[i][j] = sc.nextInt();
					sum += a[i][j];
				}
				a[i][n] = sum;
			}
			
			for (int j = 0; j <= n; j++) {
				int sum = 0;
				for (int i = 0; i < n; i++) {
					sum += a[i][j];
				}
				a[n][j] = sum;
			}
			
			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n; j++) {
					System.out.printf("%5d", a[i][j]);
				}
				System.out.println();
			}
			
		}
	}
}

Measured memory_bytes: 21992
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	s := readString()
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}


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

int main() {
	int n;cin>>n;
	vector<long long> s(n),a(n);
	long long sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	s[0]=a[0];
	for(int i=1;i<n;i++){
		s[i]=s[i-1]+a[i];
	}
	long long ans=s[0]-(sum-s[0]);
	if(ans<0){
		ans*=-1;
	}
	for(int i=1;i<n-1;i++){
		long long temp=s[i]-(sum-s[i]);
		if(temp<0)temp*=-1;
		if(ans>temp)ans=temp;
	}
	cout<<ans<<endl;

	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int x,n;
    cin>>x>>n;
    vector<int> a(n);
    for(auto & b : a) cin>>b;
    map<int,bool> m;
    for(int i=0;i<n;++i){
         m[a[i]] = true;
    }
    for(int i=0;i<=100;++i){
        if(m.count(x-i) != 1){
            cout << x -i << endl;
            return 0;
        }
        if(m.count(x + i) != 1){
            cout << x + i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
n,k,q = map(int,input().split())
a = [int(input()) for A in range(q)]
ans = [k]*(n+1)
for i in range(1,q+1):
	ans[a[i-1]] += 1
for j in range(1,n+1):
	ans[j] -= q
ans.pop(0)
for h in range(n):
	print("Yes" if ans[h] > 0 else "No")

Measured memory_bytes: 17016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e9+7


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int takahashi = c / b + (c % b != 0 ? 1 : 0);
    int aoki = a / d + (a % d != 0 ? 1 : 0); 
    cout << (takahashi <= aoki ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
  int n,m,i;
  int ansac=0,ansp=0;
  cin>>n>>m;
  vector<int>ac(n);
  vector<int>penalty(n);
  
rep(i,m){
  int p;
  string s;
  cin>>p>>s; 
  p--; 
  if(ac[p])
  continue;
  if(s=="AC")
  ac[p]=1;
  else{
    penalty[p]++;
  }
}
rep(i,n){
  ansac+=ac[i];
  if(ac[i])
  ansp+=penalty[i];
}
cout<<ansac<<" "<<ansp<<endl;
}


Measured memory_bytes: 1024