akhauriyash/Code-Regression huggingface dataset:
//
//  Problem Name: Knapsack 1

//  Created by Kushal Warke
//  Copyright © 2018 Kushal Warke. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <vector>
#include <set>
#include <sstream>
#include <stack>
#include <list>
#include <queue>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector< pair<int,int> > vpi;
typedef vector< pair<long long,long long> > vpll;

double EPS = 1e-9; 
int INF = 1000000005;
struct data {
    int v;
    int in;
};
bool cmp(data a, data b) {
    return a.v < b.v;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,p;
    cin>>a>>p;
    int ans;
    a = a*3;
    a = a+p;
    ans = a/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        long ans;
        string[] input = Console.ReadLine().Split();
        long A = long.Parse(input[0]);
        long B = long.Parse(input[1]);

        ans = (A + B) % 24;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<cctype>
int main(){

    int abc[26];
    for(int i=0; i<26; i++){
        abc[i] = 0;
    }
    char alpha;

    while(scanf("%c",&alpha) != EOF){
        if(isupper(alpha)) alpha = tolower(alpha);//小文字に直す
        int num = alpha -'a';
        if((num >= 0) && (num < 26)) abc[num] ++;
    }
    for(int j=0; j<26; j++){
        int n = j + 'a';
        printf("%c : %d\n",n,abc[j]);
    }
    return 0;
}


Measured memory_bytes: 2704
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    // string s; cin >> s;
    vector<char> s(n); cin >> s;
    int q; cin >> q;
    for(int h = 0; h < q; h++){
        int k; cin >> k;
        int ms = 0, cs = 0;
        ll num = 0, ans = 0;
        for(int i = 0; i < k - 1; i++){
            if(s[i] == 'M'){
                ms++;
            }else if(s[i] == 'C'){
                cs++;
                num += ms;
            }
        }
        for(int i = 0; i < n; i++){
            if(i + k - 1 < n){
                if(s[i + k - 1] == 'M'){
                    ms++;
                }else if(s[i + k - 1] == 'C'){
                    cs++;
                    num += ms;
                }
            }
            if(s[i] == 'D'){
                ans += num;
                // printde(i, ans, num);
            }else if(s[i] == 'M'){
                ms--;
                num -= cs;
            }else if(s[i] == 'C'){
                cs--;
            }
        }
        if(num){
            return 1;
        }
        cout << ans << '\n';
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    forn(i, 0, n) forn(j, i, n) if (s[i] == 'C' && s[j] == 'F') {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}


Measured memory_bytes: 764
import math
N=int(input())*2
q=int(math.sqrt(N))
if-~q*q!=N:print("No");exit()
S=[list(range(1,q+1))]
S+=[[j]for j in S[0]]
l=q
for i in range(1,q):
	r=list(range(l+1,l+1+q-i))
	S[i]+=r
	for j in range(q-i):S[i+j+1]+=[r[j]]
	l=r[-1]
print("Yes")
print(len(S))
for s in S:print(len(s)," ".join(map(str,s)))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
  int64_t n, m;
  cin >> n >> m;

  vector<vector<pair<int64_t, int64_t>>> links(n);
  for (auto _ : irange(0L, m)) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    links[a].emplace_back(b, c);
  }

  vector<int64_t> costs(n, numeric_limits<int64_t>::min());
  costs[0] = 0;
  for (auto i : irange(0L, n)) {
    for (auto a : irange(0L, n)) {
      if (costs[a] == numeric_limits<int64_t>::min()) {
        continue;
      }
      for (auto p : links[a]) {
        if (costs[p.first] < costs[a] + p.second) {
          costs[p.first] = costs[a] + p.second;

          if (p.first == n - 1 && i == n - 1) {
            cout << "inf" << endl;
            return 0;
          }
        }
      }
    }
  }

  cout << costs[n - 1] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
	scanf("%d",&n);
	if(n%10==3)
	    puts("bon");
	else if(n%10==0||n%10==1||n%10==6||n%10==8)
	    puts("pon");
	else
	    puts("hon");
}

Measured memory_bytes: 3764
# Date [ 2020-08-15 21:04:37 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_int()
    l = read_int_list()
    cnt = 0

    for i in combinations(l, r=3):
        a, b, c = i
        if a != b and b != c and c != a:
            if a + b > c and b + c > a and c + a > b:
                cnt += 1
    print(cnt)

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 9904
#include <iostream>
using namespace std;
int main(void){

    double a,b;
    cin>>a>>b;
    if(0<b && b<10){
        a=10*a+b;
    }else if(10<=b && b<=99){
        a=100*a+b;
    }else{
        a=1000*a+b;
    }
    
    double c;
    for(int i=4;i<350;i++){
        c=a/i;
        if(c==i){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
four = 0
two = 0
for i in range(N):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 4 == 2:
        two += 1
    else:
        pass

if four == 0:
    if two == N:
        print('Yes')
    else:
        print('No')
else:
    if two <= 1:
        if N <= 2*four+1:
            print('Yes')
        else:
            print('No')
    else:
        if N <= 2*four+two:
            print('Yes')
        else:
            print('No')


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

int main() {
	string s;
	vector<string>sa;
	vector<int>h;
	int z;
	string b,m;
	cin >> b;
	sa.push_back(b);
	h.push_back(1);
	z = b.size();
	m = b;
	while (cin >> s) {
		if (s.size() > z) {
			z = s.size();
			m = s;
		}
		int flg = 0;
		for (int i = 0;i < sa.size();i++) {
			if (sa[i] == s) {
				h[i]++;
				flg = 1;
				break;
			}
		}
		if (flg == 0) {
			sa.push_back(s);
			h.push_back(1);
		}

	}
	int va = 0;
	string xs;
	for (int i = 0;i < sa.size();i++) {
		if (va < h[i]) {
			va = h[i];
			xs = sa[i];
		}
	}
	cout << xs << ' ' << m << endl;
	return 0;
}

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

int main(){
    int n, candy;   cin >> n >> candy;
    vector<int> a(n);
    for(int i=0; i<n; i++)  cin >> a.at(i);
    sort(a.begin(), a.end());
    int cnt=0;
    for(int i=0; i<n; i++){
        if(candy<a.at(i)) break;
        cnt += 1;
        candy -= a.at(i);
        if(n-1==i && 0<candy) cnt -= 1;
    }
    cout << cnt << endl;
}
    

Measured memory_bytes: 256
n,m=map(int,input().split())
v=[[1 for i in range(n)] for i in range(n)]
for i in range(m):	
	x,y=map(int,input().split())
	x-=1
	y-=1
	if v[x][y]:
		v[x][y],v[y][x]=0,0
		for j in range(n):
			if v[x][j]==0:
				v[j][y],v[y][j]=0,0
		for j in range(n):
			if v[y][j]==0:
				v[j][x],v[x][j]=0,0
	else:
		for j in range(n):
			v[j][x],v[x][j],v[j][y],v[y][j]=0,0,0,0
print((sum(map(sum,v))-sum([v[i][i] for i in range(n)]))//2)

Measured memory_bytes: 50392
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;
using P = pair<int, int>;

vector<P> ans;

void even(int n) {
  rep(i,n/2) {
    ans.emplace_back(i+1, n/2*2-i);
  }
}

void odd(int n) {
  rep(i,(n-1)/2) {
    ans.emplace_back(n+i+1, n+(n+1)/2*2-1-i);
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  if (n % 2 == 1) {
    even(n);
  }
  else {
    even(n/2);
    odd(n/2);
  }
  rep(i,m) {
    cout << ans[i].fi << ' ' << ans[i].se << endl;
  }
  return(0);
}


Measured memory_bytes: 4164
$count = 0
def merge(left_array, right_array)
  return_array = []
  left_index, right_index = 0, 0
  left_array << 10**9
  right_array << 10**9
  0.upto(left_array.length + right_array.length - 3) do
    $count += 1
    if left_array[left_index] < right_array[right_index]
      return_array << left_array[left_index]
      left_index += 1
    else
      return_array << right_array[right_index]
      right_index += 1
    end
  end
  return_array
end

def merge_sort(target_array)
  right = target_array.length
  mid = target_array.length / 2
  left_array = target_array[0...mid]
  right_array = target_array[mid...right]
  return target_array if target_array.length == 1
  return merge(merge_sort(left_array), merge_sort(right_array))
end

gets.to_i
input = gets.split(' ').map(&:to_i)
puts merge_sort(input).join(' '), $count


Measured memory_bytes: 56152
#include <stdio.h>
 
int main(void)
{
    int x;
    int y;
    int a;
	int tmp;
     
    scanf("%d %d", &x, &y);
	
	if (y > x){
		tmp = x;
		x = y;
		y = tmp;
	}
	
    a = x % y;
     
    while (a != 0){
        x = y;
        y = a;
        a = x % y;
    }
     
    printf("%d\n", y);
     
    return (0);
}

Measured memory_bytes: 592
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = 1.0*a/b;
    printf ("%d %d %.6f", d, r, f );
    return 0;
}


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

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

  int64_t a, b, c;
  cin >> a >> b >> c;
  if ((a % 2) == 0 || (b % 2) == 0 || (c % 2) == 0) {
    cout << "0\n";
    return 0;
  }
  cout << min(min(a * b, b * c), a * c) << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,s,i;
	int x[7];
	for(i=1;i<=7;i++){
		scanf("%d %d",&a,&b);
		s=a-b;
		printf("%d\n",s);
	}
	

	return 0;
}

Measured memory_bytes: 1028
# coding: utf-8
# Problem B: ?????????????§?

def pair?(a, b)
  if a == '(' &&  b == ')' || a == '[' && b == ']'
    true
  else
    false
  end
end

while true
  line = gets.chomp
  break if line == '.'

  stack = []
  
  line.each_char do |c|
    case c
    when '(', '['
      stack.push(c)
    when ')', ']'
      top = stack.pop

      unless pair?(top, c)
        stack.push('err')
        break
      end
    end
  end

  if stack.size == 0
    puts 'yes'
  else
    puts 'no'
  end
end

Measured memory_bytes: 6124
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    string s; cin>>s;
    ll n=s.size();
    vector<ll> cnt(30, 0);
    for(int i=0; i<n; i++){
        cnt[s[i]-'a']++;
    }

    ll ans=n*(n-1)/2+1;
    for(int i=0; i<26; i++){
        ans-=(cnt[i])*(cnt[i]-1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
l = []
for i in range(n):
    l.append(input())
count = [0, 0, 0, 0]
for i in range(len(l)):
    if l[i] == 'AC':
        count[0] += 1
    elif l[i] == 'WA':
        count[1] += 1
    elif l[i] == 'TLE':
        count[2] += 1
    else:
        count[3] += 1
print('AC x ' + str(count[0]))
print('WA x ' + str(count[1]))
print('TLE x ' + str(count[2]))
print('RE x ' + str(count[3]))

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
 //    fast

    int n,m;
    cin>>n>>m;
    int a[n],sum=0,c=0;
    loop(i,n){
    	cin>>a[i];
    	sum+=a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    c=(sum+(4*m-1))/(4*m);
   
    if(a[m-1]>=c) pt("Yes");
    else pt("No");
    

}


/*

// 

*/

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a%3==0 || b%3==0 || (a+b)%3==0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var a = input.split('\n');
var p = '';
for(i=0;i<a.length;i++){
    var b = a[i].split(' ');
    var x = parseInt(b[0]);
    var y = b[1];
    var z = parseInt(b[2]);
    if(y === "?"){
        break;
    }
    if(y === '+'){
        p+=x+z;
    }
    if(y === '-'){
        p+=x-z;
    }
    if(y === '*'){
        p+=x*z;
    }
    if(y === '/'){
        p+=Math.floor(x/z);
    }
    p+="\n";
}
console.log(p.trim());


Measured memory_bytes: 15364
#![allow(dead_code)]
#![allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let mut o = scan.next::<String>();
    let mut e = scan.next::<String>();

    let mut s = String::from("");

    loop {
        if o.len() != 0 {
            s.push(o.remove(0));
        }
        if e.len() != 0 {
            s.push(e.remove(0));
        }
        if o.len() == 0 && e.len() == 0 {
            break;
        }
    }

    writeln!(out, "{}", s);
}

Measured memory_bytes: 2108
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    char[] ch = in.next().toCharArray();
    ch[5] = ' ';
    ch[13] = ' ';

    System.out.println(ch);

  }
}

Measured memory_bytes: 9676
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
typedef long long ll;
const int xmax=1e5+7;
const int INF=1e9+7;
using namespace std;
int main()
{
    int a,b,k;
        scanf("%d%d%d",&a,&b,&k);
    int cot=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
            cot++;
        if(cot==k)
        {
            printf("%d",i);
            break;
        }
    }
    return 0;
}


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

using namespace std;

string o, e, pass;

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

    cin >> o >> e;

    pass = "";

    for (int i = 0; i < min(o.length(), e.length()); i++) {
        pass += o[i];
        pass += e[i];
    }

    if (o.length() > e.length()) {
        pass += o[o.length() - 1];
    }

    cout << pass << endl;

    return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = list(map(int, input().split()))
if a + b <= 2*c:
  print(a*x + b*y)
else:
  if x < y:
    print(min(2*c*x + b*(y-x), 2*c*y))
  else:
    print(min(2*c*y + a*(x-y), 2*c*x))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 int main(){
   char b;
   cin>>b;
   if(b=='A'){
   cout<<'T'<<endl;
   return 0;
   }
   if(b=='T'){
   cout<<'A'<<endl;
   return 0;
   }
   if(b=='C'){
   cout<<'G'<<endl;
   return 0;
   }
   if(b=='G'){
   cout<<'C'<<endl;
   return 0;
   }
   return 0;
 }

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        l: usize,
        es: [(usize1, usize1, usize); m],
        q: usize,
        qs: [(usize1, usize1); q]
    }
    let inf = 1 << 60;
    let mut d1 = vec![vec![inf; n]; n];
    for &(a, b, c) in &es {
        d1[a][b] = c;
        d1[b][a] = c;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
            }
        }
    }
    let mut d2 = vec![vec![inf; n]; n];
    for i in 0..n {
        for j in 0..n {
            if d1[i][j] <= l {
                d2[i][j] = 1;
            }
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
            }
        }
    }
    for &(s, t) in &qs {
        if d2[s][t] == inf {
            println!("-1");
        } else {
            println!("{}", d2[s][t] - 1);
        }
    }
}


Measured memory_bytes: 8572
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const [n, k]: number[] = input[0].split(' ').map((x: string): number => +x);
const d: number[] = input[1].split(' ').map((x: string): number => +x);

let ans: number = 0;

for(let i = 0; i < n; i++){
    if (d[i] >= k){
        ans++
    }
}
console.log(ans);

Measured memory_bytes: 16588
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));

  const N = s[0];
  const M = s[1];

  let ans = Math.abs(N - 2) * Math.abs(M - 2);
  
  if (ans > Number.MAX_SAFE_INTEGER) {

    // 積がMAX_SAFE_INTEGERを越える場合、配列にして筆算で解く
    const multi_biggerInt = (a, b) => {
      const num1 = String(a).split('').map(n => Number(n)).reverse();
      const num2 = String(b).split('').map(n => Number(n)).reverse();

      // 各桁の配列
      let ans = [...Array(num1.length + num2.length)].fill(0);

      // 桁上がり
      const checkCarry = () => {
        for (let i = 0; i < ans.length; i++) {
          if (ans[i] >= 10) {
            const upper = Number(String(ans[i]).split('')[0]);
            const lower = Number(String(ans[i]).split('')[1]);

            ans[i - 1] += upper;
            ans[i] = lower;
          }
        }
      }

      // 筆算
      for (let i = 0; i < num1.length; i++) {
        for (let j = 0; j < num2.length; j++) {
          const pro   = num1[i] * num2[j];
          const digit = ans.length - (i + j) - 1;

          ans[digit] += pro;
          checkCarry();
        }
      }

      // 有効桁のみ抜き出す
      for (let i = 0; i < ans.length; i++) {
        if (ans[i] !== 0) {
          ans = ans.slice(i);
          break;
        }
      }

      // 文字列として返す
      return ans.join('');
    }

    ans = multi_biggerInt(Math.abs(N - 2), Math.abs(M - 2));
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7608
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))

def solve():
    if not (c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1]): return False
    if not (c1[1]-c1[2] == c2[1]-c2[2] == c3[1]-c3[2]): return False
    if not (c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2]): return False
    if not (c2[0]-c3[0] == c2[1]-c3[1] == c2[2]-c3[2]): return False
    return True
print('Yes' if solve() else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    if(n%2==1){
        return (power((x*x)%M,n/2)*x)%M;
    }
}

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

    ll n;
    cin>>n;
    ll m;
    cin>>m;
    if(n==m){cout<<"Yes";}
    else{cout<<"No";}

    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに
 
//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
// ----- template end ---- //
 
// ------- library ------- //

ll modpow(ll x, ll n){return n < 2 ? x : modpow(x * x, n / 2) * (n % 2 ? x : 1) % MOD;}

//nCk,nPk,nHk(mod MOD)の計算　n!とk!^{MOD-2}を前計算して求める
//n(nHkを使う場合はn+k)の最大値を設定すること（10^7で581ms 236MB, 3*10^7で1496ms 705MB）
ll maxNplsK = 300000; // n+kの最大値を代入(0 < n, k <= maxNplsK) nHkを使わないならmaxNでもいい
vector<ll> fac(maxNplsK+1); //i!(mod MOD) を格納。
vector<ll> inv(maxNplsK+1); //i^-1(iのモジュラ逆数 mod MOD)を格納
vector<ll> finv(maxNplsK+1); //i!^-1(i!のモジュラ逆数 mod MOD)


//aCbをmod計算
ll comb(ll a, ll b){
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  ll tmp = finv.at(a - b)* finv.at(b) % MOD;
  return tmp * fac.at(a) % MOD;
}

// ----- library end ----- //



int main() {
    
  ll H, W, K;
  cin >> H >> W >> K;

  //使う前に置いておく前計算（main()内でok）
  //大した量ではないので，先にfac[i]とifac[i]を全て計算しておく
  fac.at(0) = fac.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inv.at(1) = 1;
  for (int i = 2; i < maxNplsK+1; i++){
    fac.at(i) = fac.at(i - 1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
  }



  ll hwm2Ckm2; //HW-2 C K-2を計算

  if (K==2){
    hwm2Ckm2 = 1;
  }
  else if (K==3){
    hwm2Ckm2 = H*W - 2; //残りコマ1なので、その1つをどこに置くか
  }
  else{
    hwm2Ckm2 = 1;
    rep(i, K-2){ //単純にH*W-2から、1減らしながらK-2回掛ける
      hwm2Ckm2 = hwm2Ckm2 * (H*W-2 -i) % MOD;
    }
    //(K-2)!で割る
    hwm2Ckm2 = hwm2Ckm2 * finv.at(K-2) % MOD;
  }
//  cout << hwm2Ckm2 << endl;


  // |yi-yj|の合計
  ll ymy = 0;
  rep(i, H-1){
    ll d = i + 1;
    ymy += modpow(W, 2) * (H - d) % MOD * d % MOD;
  }

  ll xmx = 0;
  rep(i, W-1){
    ll d = i + 1;
    xmx += modpow(H, 2) * (W - d) % MOD * d % MOD;
  }

  cout << (ymy + xmx) % MOD * hwm2Ckm2 % MOD << endl;


// -- main() end -- //
}


 

Measured memory_bytes: 9344
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    sort(h.begin(), h.end());
    ll ans = LLONG_MAX;
    for (ll i = 0; i <= N - K; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <string.h>
using namespace std;

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (int array[], int l, int r) {
    int pivot = array[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array[j] <= pivot) {
            i++;
            swap(&array[i], &array[j]);
        }
    }
    swap(&array[i + 1], &array[r]);
    return (i + 1);
}

void quickSort(int array[], int l, int r) {
    if (l < r) {
        int pivot = partition(array, l, r);
        quickSort(array, l, pivot - 1);
        quickSort(array, pivot + 1, r);
    }
}

int main(void){
    int n;
    cin >> n;
    int p[n], p1[n], p2[n];
    for( int i = 0; i < n; i++ ){
        cin >> p[i];
    }

    for( int i = 0; i < n; i++ ){
       p1[i] = i + 1;
    }
    
    for( int i = 0; i < n; i++ ){
        p2[i] = p1[i] - p[i];
    }

    int k = 0;
    for( int i = 0; i < n; i++ ){
        if( abs( p2[i] ) == 0 ) {
        } else {
            k++;
        }
    }
    
    if( k == 0 || k == 2 ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
b = [0 for _ in range(N)]
for i in range(N, 0, -1):
    b[i-1] = 0 if sum(b[i-1::i]) % 2 == A[i-1] else 1
ans = [str(i+1) for i, x in enumerate(b) if x == 1]
print(len(ans))
if ans:
    print(' '.join(ans))

Measured memory_bytes: 74588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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;}

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  LL n, m;
  cin >> n >> m;
  vector<LL> a(m), b(m);

  rep(i, m) cin >> a[i] >> b[i];

  vector<vector<LL> > rooms(n+1);
  vector<LL> guide(n+1, -1);

  rep(i, m) {
    rooms[a[i]].push_back(b[i]);
    rooms[b[i]].push_back(a[i]);
  }

  guide[1] = 0;
  queue<LL> q;
  q.push(1);

  while(!q.empty()) {
    LL x = q.front();
    q.pop();

    for (LL j: rooms[x]) {
      if (guide[j] != -1) continue;
      guide[j] = x;
      q.push(j);
    }
  }

  cout << "Yes" << endl;
  rep(i, n-1) cout << guide[i+2] << endl;

  return 0;
}

Measured memory_bytes: 15836
#include <stdio.h>

int main(void){
  int h, w, i, j, sky;
  char c;
  int map[100][100];
  scanf("%d%d", &h, &w);
  //printf("%d %d", h, w);

  for(i = 0; i < h; i++){
    getchar();
    //printf("\n");
    sky = -1;
    for(j = 0; j < w; j++){
      scanf("%c", &c);
      //printf("%c", c);
      if(c == 'c'){
	sky = 0;
      }
      else if(sky >= 0){ sky++; }
      map[i][j] = sky;
    }
  }

  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      if(j != 0){ printf(" "); }
      printf("%d", map[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1072
#include <iostream>
#include <vector>

using namespace std;

int N, M;
vector<int> e[8];
int ans = 0;

void dfs(int pos, int visited) {
		visited |= (1<<pos);
		if (__builtin_popcount(visited) == N) {
				ans++;
				return;
		}

		for (auto itr = e[pos].begin(); itr < e[pos].end(); itr++) {
				if (visited & (1<<(*itr))) continue;
				dfs(*itr, visited);
		}
}

int main() {
		cin >> N >> M;
		for (int i = 0; i < M; i++) {
				int a, b;
				cin >> a >> b;
				a--; b--;
				e[a].push_back(b);
				e[b].push_back(a);
		}

		dfs(0, 0);

		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


N,M = nm()
A  = nl()
ans = max(-1,N - sum(A))
print(ans)



Measured memory_bytes: 10052
public class Main{
  public static void main(String[] args){
 
    int R = new java.util.Scanner(System.in).nextInt();
    
    if ((0 <= R ) && (R < 1200)) {
      System.out.println("ABC");
    } else if ((1200 <= R) && (R < 2800)) {
      System.out.println("ARC");
    } else if ((2800 <= R) && (R <= 4208)) {
      System.out.println("AGC");  
    }
  }
}

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

signed main () {
    int n;
    cin >> n;
    vector < int > a(n), c;
    int cnt_neg = 0;
    for (int &x: a) {
        cin >> x;
        cnt_neg ^= (x < 0);
        c.push_back(abs(x));
    }
    sort(c.begin(), c.end());
    int64_t ans = 0;
    for (int i = 0; i < n; ++i)
        ans += c[i];
    for (int i = 0; i < cnt_neg; ++i)
        ans -= 2 * c[i];
    cout << ans << '\n';
}


Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll n,a,b;

ll ksm(ll a,ll b){
    ll res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return res;
}
ll C(ll n,ll m){
    ll res = 1;
    for(ll i = 1;i<=m;i++) res = res *(n-m+i)%mod*ksm(i,mod-2)%mod;
    return res;
}
int main(){
    cin>>n>>a>>b;
    ll res = ksm(2,n)-1;
    res = (res-C(n,a)+mod)%mod;
    res = (res-C(n,b)+mod)%mod;
    cout<<res<<endl;


    return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	int ans;
	if(s == "SUN")ans = 7;
	else if(s == "MON")ans = 6;
	else if(s == "TUE")ans = 5;
	else if(s == "WED")ans = 4;
	else if(s == "THU")ans = 3;
	else if(s == "FRI")ans = 2;
	else if(s == "SAT")ans = 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int row,col;
vector<string> st;
bool exist(int x,int y){
    if(x >= 0 && x <= row && y >= 0 && y <= col ){
        if(st[x][y]=='#') return 1;
        else return 0;
    }
    else return false;
}
int main()
{
    int cnt;
    cin>>row>>col;

    string s;
    for(int i=0;i<row;i++)
    {
        cin>>s;
        st.push_back(s);
    }

    for(int i=0;i<row-1;i++) {
        for(int j=0;j<col;j++) {
            cnt =0;
            if(st[i][j]=='#') cout<<st[i][j];
            else {
                if(exist(i+1,j+1)) cnt++;//
                if(exist(i+1,j))  cnt++;
                if(exist(i+1,j-1)) cnt++;
                if(exist(i,j+1)) cnt++;
                if(exist(i,j-1)) cnt++;
                if(exist(i-1,j+1)) cnt++;
                if(exist(i-1,j)) cnt++;
                if(exist(i-1,j-1)) cnt++;
                cout<<cnt;
            }
        }
        cout<<endl;
    }
    int i = row-1;
    for(int j=0;j<col;j++) {
        cnt=0;
        if(st[row-1][j]=='#') cout<<st[row-1][j];
        else {
        if(exist(i-1,j-1)) cnt++;
        if(exist(i-1,j)) cnt++;
        if(exist(i-1,j+1)) cnt++;
        if(exist(i,j+1)) cnt++;
        if(exist(i,j-1)) cnt++;
        cout<<cnt;
        }
    }
}


Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    string g[H];
    for (int i = 0; i < H;i++){
        cin >> g[i];
    }

    int dx[8] = {0,0,1,-1,1,1,-1,-1};
    int dy[8] = {1,-1,0,0,1,-1,1,-1};
    for (int i = 0; i < H;i++){
        for (int j = 0; j < W;j++){
            int cnt = 0;
            for (int k = 0; k < 8;k++){
                int nx = i + dx[k];
                int ny = j + dy[k];
                if(nx>=0&&nx<H&&ny>=0&&ny<W&&g[nx][ny]=='#'){
                    cnt++;
                }
            }
            if(g[i][j]=='.'){
                cout << cnt;
            }else{
                cout << g[i][j];
            }
        }
        cout << endl;
    }
}

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

int n;
int a[200005];
long long ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(a[1]>0){
		cout<<-1;
		return 0;
	}
	
	for(int i=2;i<=n;i++){
		if(a[i]>a[i-1]+1){
			cout<<-1;
			return 0;
		}
		if(a[i]<=a[i-1])ans+=a[i-1];
	}
	ans+=a[n];
	printf("%lld",ans);
}

Measured memory_bytes: 1024
import itertools
S = input()
RevS = reversed(S)
L = [0]#左の<
R = [0]#右の>
cur = 0
for s in S:
    if s == "<":
        cur += 1
    else:
        cur = 0
    L.append(cur)
cur = 0
for r in RevS:
    if r == ">":
        cur += 1
    else:
        cur = 0
    R.append(cur)
R.reverse()
ans = 0
for n in range(len(S)+1):
    ans += max(L[n],R[n])
print(ans)

Measured memory_bytes: 78780
#include <iostream>
#include <stdlib.h>
#include <climits>

using namespace std;

int main(){
  int n, k, i, j, t;
  int* stones;
  int* result;

  scanf("%d %d", &n, &k);
  //cin >> n;
  stones = new int[n];
  result = new int[n];
  for(i=0; i<n; i++){
    scanf("%d", &stones[i]);
    //cin >> stones[i];
    result[i] = INT_MAX;
  }
  result[0] = 0;
  //i pietra corrente
  //j pietra dietro
  //t quante pietre dietro ho visto

  for(i=1; i<n; i++){
    j = i-1;
    t = 0;
    while(j >= 0 && t < k){
      result[i] = min(abs(stones[j] - stones[i]) + result[j], result[i]);
      j--;
      t++;
    }
  }
  printf("%d", result[n-1]);
  return 0;
}


Measured memory_bytes: 1024
a,b,c,x,y=map(int,input().split())
ma=min(a,2*c)
mb=min(b,2*c)
mab=min(a+b,2*c)
if(x>=y):
  print(mab*y+ma*(x-y))
else:
  print(mab*x+mb*(y-x))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int N=scanner.nextInt();
        boolean Yes=N/10==9||N%10==9;
        if(Yes){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

#define MAX_V 2000


int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    map<int, int> mp;
    int maxi = max(X, Y);
    int mini = min(X, Y);
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if(i == mini && j == maxi){
                mp[1] += 1;
            }else if(i < mini && maxi < j){
                mp[j - i - (maxi - mini - 1)] += 1;
            }else if(mini < i && j < maxi){
                mp[min(j - i, (i - mini) + (maxi - j) + 1)] += 1;
            }else if(mini <= i && maxi <= j){
                // 回り込み
                mp[min(j - i, (i - mini) + (j - maxi) + 1)] += 1;
            }else if(i <= mini && j <= maxi){
                // 回り込み
                mp[min(j - i, (mini - i) + (maxi - j) + 1)] += 1;
            }else{
                cout << i << " : " << j << endl;
            }
        }
    }

    for(int n = 1; n < N; n++) {
        if (mp.count(n)) {
            cout << mp[n] << endl;
        } else {
            cout << "0" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    string x;
    stack<int> st;
    while (cin >> x)
    {
        if (x == "+")
        {
            int first = st.top();
            st.pop();
            int second = st.top();
            st.pop();
            st.push(first + second);
        }
        else if (x == "-")
        {
            int first = st.top();
            st.pop();
            int second = st.top();
            st.pop();
            st.push(second - first);
        }
        else if (x == "*")
        {
            int first = st.top();
            st.pop();
            int second = st.top();
            st.pop();
            st.push(first * second);
        }
        else
        {
            st.push(atoi(x.c_str()));
        }
    }
    cout << st.top() << endl;
    return 0;
}


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

int main() {
    double a,b,x;
    cin >> a >> b >> x;
    long double answer = 0;
    if(b > x){
        answer = floor(a*x/b);
    } else {
        answer = floor(a*(b-1)/b);
    }
    cout << answer;
}

Measured memory_bytes: 3904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T119a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s =  Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            if(A<=C && C <= B)
            {
                Console.WriteLine("Yes");
            }else if(A>=C && C >= B)
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");

            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
pair<int, int> a[1010];
int mem[10010][1010], p[10010];
int dp(int x, int num){
    if(num<=0){
        return 0;
    }
    if(x<0){
        return 1e9;
    }
    if(mem[num][x]!=-1){
        return mem[num][x];
    }
    int res=dp(x-1, num), tmp;
    res=min(res, a[x].sc+dp(x, num-a[x].fs));
    mem[num][x]=res;
    return res;
}
int main(){
    int n, h;
    while(cin>>h>>n){
        int ans=0;
        int x, y;
        for(int i=0; i<n; ++i){
            scanf("%d%d",&x, &y);
//x=i+1;y=i+2;
            a[i]=mk(x, y);
        }
        sort(a, a+n);
        for(int i=0; i<n; ++i){
            if(a[i].fs==-1){
                continue;
            }
            for(int j=i+1; j<n; ++j){
                if(a[j].fs==-1){
                    continue;
                }
                if(((a[j].fs+a[i].fs-1)/a[i].fs)*a[i].sc<=a[j].sc){
                    a[j].fs=-1;
                }
            }
        }
        for(int i=n-1; i>=0; --i){
            if(a[i].fs==-1){
                continue;
            }
            for(int j=i-1; j>=0; --j){
                if(a[j].fs==-1){
                    continue;
                }
                if(a[i].sc<=a[j].sc){
                    a[j].fs=-1;
                }
            }
        }
        for(int i=0; i<n; ++i){
            if(a[i].fs==-1){
                for(int j=i+1; j<n; ++j){
                    if(a[j].fs!=-1){
                        a[i]=a[j];
                        a[j].fs=-1;
                        break;
                    }
                }
            }
        }
        for(int i=0; i<n; ++i){
            if(a[i].fs==-1){
                n=i;
                break;
            }
        }
        for(int i=0; i+1<n; ++i){
            for(int j=a[i].fs+1; j<=a[i+1].fs; ++j){
                p[j]=i+1;
            }
        }
        for(int i=0; i<=a[0].fs; ++i){
            p[i]=0;
        }
        for(int i=a[n-1].fs; i<=h; ++i){
            p[i]=n-1;
        }
        memset(mem, -1, sizeof mem);
        ans=dp(p[h], h);
        printf("%d\n",ans);
    }
  return 0;
}




Measured memory_bytes: 40320
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/
 
signed main(void){
  char c;
  cin>>c;
  cout<<(char)(c+1)<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>

using namespace std;

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

    int a, b;
    cin >> a >> b;
    if(a%3 == 0 || b % 3 == 0 || (a+b)%3 == 0){
        cout << "Possible\n";
    }else{
        cout << "Impossible\n";
    }

    return 0;
}

Measured memory_bytes: 256