akhauriyash/Code-Regression huggingface dataset:
N,M,C=map(int,input().split())
B=[int(i) for i in input().split()]
A=[[int(i) for i in input().split()] for j in range(N)]
cnt=0
for a in A:
    tot=C
    for i in range(M):
        tot+=a[i]*B[i]
    if tot>0:
        cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include<stdio.h>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head]; 
  head=(head+1)%LEN;
  return x;
}
int min(int a, int b){
  if(a<b)return a;
  else return b;
}
int main(){
  int elaps = 0,c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,j,d;
string s;
int main()
{
  cin>>a>>b>>s;
  if(s[a]!='-')return cout<<"No"<<endl,0;
  for(;i<a;i++)if(s[i]=='-')return cout<<"No"<<endl,0;
  for(i=s.size()-b;i<s.size();i++)if(s[i]=='-')return cout<<"No"<<endl,0;
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
long int a,b,c=0,d=0,w=0,i,str1=0,str2=0,flag,j,count=0,k,n,sum=0;
char s[101][101];
scanf("%ld%ld\n",&a,&b);
for(i=0;i<a;i++)
{
gets(s[i]);

}
for(i=0;i<a;i++)
{
    k=2;
    while(k--)
    {
        printf("%s\n",s[i]);
    }
}
 return 0;
}

Measured memory_bytes: 128
# 2020/06/21
# AtCoder Beginner Contest 171 - B

# Input
n, k = map(int,input().split())
p = list(map(int,input().split()))

# Calc
p.sort()

ans = 0
for i in range(k):
    ans = ans + p[i]

# Output
print(ans)


Measured memory_bytes: 9272
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;


int n,K,a;
ll ans,b[256][101];
int xr(int x,int y){
	int z=0;
	lp(8){
		if(x%2!=y%2)
			z+=1<<i;
		x/=2;
		y/=2;
	}
	return z;
}
int main(){
	cin>>n>>K;
	lp(256)
		LP(n,j)
			b[i][j]=0;
	b[0][0]=1;
	lp(n){
		cin>>a;
		for(int j=n-1;j>=0;j--)
			LP(256,k){
				b[xr(a,k)][j+1]+=b[k][j]*(j+1);
				b[xr(a,k)][j+1]%=mod;
			}
	}
	ans=0;
	lp(n+1)
		ans+=b[K][i];
	cout<<ans%mod<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, l, p[100], t[100], v[100];
double dp[100][52], sum[100][52];

int main(){
	cin >> n >> m >> l;
	rep(i, n) cin >> p[i] >> t[i] >> v[i];
	rep(i, n){
		dp[i][0] = 1;
		rep(j, m) for(int k = m; k >= 0; k--){
			dp[i][k + 1] += dp[i][k] * p[i] / 100.0;
			dp[i][k] *= 1 - p[i] / 100.0;
		}
		sum[i][m] = dp[i][m];
		for(int j = m - 1; j >= 0; j--) sum[i][j] = sum[i][j + 1] + dp[i][j];
		/*
		rep(j, m + 1) cerr<<dp[i][j]<<(j==m?"\n":" ");
		rep(j, m + 1) cerr<<sum[i][j]<<(j==m?"\n":" ");
		*/
	}
	
	rep(i, n){
		double s = 0;
		if(v[i]) rep(j, m + 1){
			double e = dp[i][j];
			rep(k, n) if(k != i){
				int tm = (int)ceil((l * 1.0 / v[i] - l * 1.0 / v[k] + t[i] * j) / t[k] + EPS);
				
				tm = max(tm, 0);
				if(t[k] == 0) tm = l * 1.0 / v[i] - l * 1.0 / v[k] + t[i] * j < - EPS ? 0 : m + 1;
				if(v[k] == 0) tm = 0;
				if(tm <= m) e *= sum[k][tm];
				else e = 0;
			}
			s += e;
		}
		printf("%.9f\n", s);
	}
	
	return 0;
}

Measured memory_bytes: 1272
def func():
    S = input()

    ans = 'Yes'
    for i in range(len(S)):
        if (i+1) % 2 != 0 and S[i] == 'L':
            ans = 'No'
            break

        if (i+1) % 2 == 0 and S[i] == 'R':
            ans = 'No'
            break
    
    print(ans)

if __name__ == '__main__':
    func()


Measured memory_bytes: 38256
//ABC118B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
using namespace std;

int main(){
	int n, m;
	int k;
	int a;
	cin >> n >> m;
	vector<int> count(m,0);
	for(int i=0;i<n;i++){
		cin >> k;
		for(int j=0;j<k;j++){
			cin >> a;
			a--;
			count.at(a)++;
		}
	}
	int ans = 0;
	for(int i=0;i<m;i++){
		if(count.at(i) == n){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def main():
  n,m=map(int,input().split())
  inf=10**9
  cost=[inf for i in range(m)]
  for i in range(m):
    a,b=map(int,input().split())
    c=[int(x)-1 for x in input().split()]
    s=0
    for j in c:
      s|=1<<j
    cost[i]=[s,a]
  #print(cost)

  dp=[inf]*(1<<n)
  dp[0]=0
  for s in range(1<<n):
    for bit,c in cost:
      dp[s|bit]=min(dp[s|bit], dp[s]+c)
  #print(dp)
  print(-1 if dp[-1]==inf else dp[-1])

if __name__=='__main__':
  main()

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

char trans(char c,int t){
  if(c=='1'){
    if(t%5==1)return '\'';
    if(t%5==2)return ',';
    if(t%5==3)return '.';
    if(t%5==4)return '!';
    return '?';
  }
  if(c=='2'){
    if(t%6==1)return 'a';
    if(t%6==2)return 'b';
    if(t%6==3)return 'c';
    if(t%6==4)return 'A';
    if(t%6==5)return 'B';
    return 'C';
  }
  if(c=='3'){
    if(t%6==1)return 'd';
    if(t%6==2)return 'e';
    if(t%6==3)return 'f';
    if(t%6==4)return 'D';
    if(t%6==5)return 'E';
    return 'F';
  }
  if(c=='4'){
    if(t%6==1)return 'g';
    if(t%6==2)return 'h';
    if(t%6==3)return 'i';
    if(t%6==4)return 'G';
    if(t%6==5)return 'H';
    return 'I';
  }
  if(c=='5'){
    if(t%6==1)return 'j';
    if(t%6==2)return 'k';
    if(t%6==3)return 'l';
    if(t%6==4)return 'J';
    if(t%6==5)return 'K';
    return 'L';
  }
  if(c=='6'){
    if(t%6==1)return 'm';
    if(t%6==2)return 'n';
    if(t%6==3)return 'o';
    if(t%6==4)return 'M';
    if(t%6==5)return 'N';
    return 'O';
  }
  if(c=='7'){
    if(t%8==1)return 'p';
    if(t%8==2)return 'q';
    if(t%8==3)return 'r';
    if(t%8==4)return 's';
    if(t%8==5)return 'P';
    if(t%8==6)return 'Q';
    if(t%8==7)return 'R';
    return 'S';
  }
  if(c=='8'){
    if(t%6==1)return 't';
    if(t%6==2)return 'u';
    if(t%6==3)return 'v';
    if(t%6==4)return 'T';
    if(t%6==5)return 'U';
    return 'V';
  }
  if(t%8==1)return 'w';
  if(t%8==2)return 'x';
  if(t%8==3)return 'y';
  if(t%8==4)return 'z';
  if(t%8==5)return 'W';
  if(t%8==6)return 'X';
  if(t%8==7)return 'Y';
  return 'Z';
}

int main(){
  string str;

  while(cin >> str){
    int cnt = 1;
    int s = str.size();

    for(int i=1;i<s;i++){
      if(str[i]=='0'){
	if(str[i-1] == str[i])putchar(' ');
	else{
	  putchar(trans(str[i-1],cnt));
	  cnt = 0;
	}
      }else{
	if(str[i-1] == str[i])cnt++;
	else{
	  if(str[i-1]=='0')cnt = 1;
	  else{
	    putchar(trans(str[i-1],cnt));
	    cnt = 1;
	  }
	}
      }
    }

    if(str[s-1]!='0' && cnt>=1)putchar(trans(str[s-1],cnt));
    putchar('\n');
  }
}

Measured memory_bytes: 0
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::{HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        a: i128,
        b: f64,
    }
    let c = match b {
        0.19 | 0.29 | 0.39 | 0.49 | 0.59 | 0.69 | 0.79 | 0.89 | 0.99 | 1.19 | 1.29 | 1.39
        | 1.49 | 1.59 | 1.69 | 1.79 | 1.89 | 1.99 | 2.19 | 2.29 | 2.39 | 2.49 | 2.59 | 2.69
        | 2.79 | 2.89 | 2.99 | 3.19 | 3.29 | 3.39 | 3.49 | 3.59 | 3.69 | 3.79 | 3.89 | 3.99
        | 4.19 | 4.29 | 4.39 | 4.49 | 4.59 | 4.69 | 4.79 | 4.89 | 4.99 | 5.19 | 5.29 | 5.39
        | 5.49 | 5.59 | 5.69 | 5.79 | 5.89 | 5.99 | 6.19 | 6.29 | 6.39 | 6.49 | 6.59 | 6.69
        | 6.79 | 6.89 | 6.99 | 7.19 | 7.29 | 7.39 | 7.49 | 7.59 | 7.69 | 7.79 | 7.89 | 7.99
        | 8.19 | 8.29 | 8.39 | 8.49 | 8.59 | 8.69 | 8.79 | 8.89 | 8.99 | 9.19 | 9.29 | 9.39
        | 9.49 | 9.59 | 9.69 | 9.79 | 9.89 | 9.99 => (b * 100.0).ceil() as i128,
        _ => (b * 100.0) as i128,
    };

    println!("{}", (a * c) / 100);
}


Measured memory_bytes: 2664
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	string s,t;
	cin>>s>>t;
	t.erase(t.length()-1,1);
	if(s==t)
		cout<<"Yes";
	else
		cout<<"No";
}












Measured memory_bytes: 3620
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ll a, b, c, k; cin >> a >> b >> c >> k;
    if (k <= a)print(k);
    else if (k <= a + b)print(a);
    else print(a - (k - a - b));
}

Measured memory_bytes: 3652
import sys
cnt = {}
for line in sys.stdin:
    for l in line:
        if l.isalpha():
            c = l.lower()
            cnt[c] = cnt.get(c,0)+1

for i in range(26):
    c = chr(ord('a')+i)
    print( c, " : ", cnt.get(c,0), sep = '' )



Measured memory_bytes: 5572
import java.util.Scanner;
public class Main{
	public static void main(String args[]) {
		AtCoder1();
	}

	public static void AtCoder1(){
		 Scanner scanner = new Scanner(System.in);
		int shopNum = Integer.parseInt(scanner.next());
		int isOpen[][] = new int[shopNum][10];
		boolean myOpen[] = new boolean[10];
		int matchNum[] = new int[shopNum];
		int profit[][] = new int[shopNum][11];
		int max=0;
		for(int i=0;i<shopNum*10;i++){
			isOpen[i/10][i%10] = Integer.parseInt(scanner.next());
		}
		System.out.println();
		for(int i=0;i<shopNum*11;i++){
			profit[i/11][i%11] = Integer.parseInt(scanner.next());
		}
		for(int i=1;i<1024;i++){
			int sum=0;
			for(int j=0;j<shopNum;j++){
				matchNum[j]=0;
			}
		        int by = i;
			for(int j=9;j>=0;j--){
				if(by>=((int)(Math.pow(2, j)))){
					by = by - (int)(Math.pow(2, j));
					myOpen[j] = true;
				}
				else{
					myOpen[j] = false;
				}
			}
			for(int j=0;j<shopNum;j++){
				for(int k=0;k<10;k++){
					if(myOpen[k])
						matchNum[j] += isOpen[j][k];
				}
			}
			for(int j=0;j<shopNum;j++){
				sum += profit[j][matchNum[j]];
			}
			if(i==1){
				max = sum;
			}
			if(max<sum){
				max = sum;
			}
		}
		System.out.println(max);

	}
}

Measured memory_bytes: 25236
n = gets.to_i
hats = gets.split.map(&:to_i)
nums = [0, 0, 0]
answers = []
hats.each do |hat|
  index = nums.find_index { |i| i == hat }
  if !index
    puts 0
    exit
  else
    answers << nums.count(hat)
    nums[index] += 1
  end
end
puts answers.inject(1) { |res, n| res * n % 1000000007 }


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

int main() {
  int N=0;
  vector<int> szamok;
  int seged=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin >>seged;
    szamok.push_back(seged);
  }
  
  int maxi=0;
  int max=szamok[0];
  for(int i=1; i<N; i++){
    if(max<szamok[i]){
      max=szamok[i];
      maxi=i;
    }
  }

  int osszeg=0;
  for(int i=0; i<N; i++){
    if(i!=maxi){
      osszeg+=szamok[i];
    }
  }
  
  if(osszeg>max){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, X;
    cin >> N >> X;
    int ans = 1, sum = 0;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        sum += a;
        if (sum <= X) ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>

using std::vector;

class Dice
{
public:
    Dice();
    void AssignPips();
    int  GetTopPip() { return pip[0]; };
    void Roll(char dir);
    void ShowAllPip();
    int  GetRight(int top, int front);

private:
    int pip[6];
};

int main()
{
    Dice dice;
    dice.AssignPips();
    int n,top,front;
    std::cin>>n;
    for(int i = 0; i < n;i++)
    {
        std::cin>>top>>front;
        std::cout<<dice.GetRight(top,front)<<std::endl;
    }

    return 0;
}

Dice::Dice() : pip{}
{
}

void Dice::AssignPips()
{
    for(int i = 0; i < 6; i++)
    {
        std::cin>>pip[i];
    }
}

void Dice::Roll(char dir)
{
    int hoge;
    if(dir == 'N')
    {
        hoge   = pip[0];
        pip[0] = pip[1];
        pip[1] = pip[5];
        pip[5] = pip[4];
        pip[4] = hoge;
    }else if(dir == 'S')
    {
        hoge   = pip[1];
        pip[1] = pip[0];
        pip[0] = pip[4];
        pip[4] = pip[5];
        pip[5] = hoge;
    }else if(dir == 'W')
    {
        hoge = pip[0];
        pip[0] = pip[2];
        pip[2] = pip[5];
        pip[5] = pip[3];
        pip[3] = hoge;
    }else
    {
        hoge = pip[2];
        pip[2] = pip[0];
        pip[0] = pip[3];
        pip[3] = pip[5];
        pip[5] = hoge;
    }
}

void Dice::ShowAllPip()
{
    for(int i = 0; i < 6; i++)
    {
        std::cout<<i+1<<": "<<pip[i]<<std::endl;
    }
}

int Dice::GetRight(int top, int front)
{
    //これはもう脳みそがない人のやり方
    if(top==pip[0]&&front==pip[1]) return pip[2];
    else if(top==pip[0]&&front==pip[2])return pip[4];
    else if(top==pip[0]&&front==pip[3])return pip[1];
    else if(top==pip[0]&&front==pip[4])return pip[3];
    else if(top==pip[1]&&front==pip[0])return pip[3];
    else if(top==pip[1]&&front==pip[2])return pip[0];
    else if(top==pip[1]&&front==pip[3])return pip[5];
    else if(top==pip[1]&&front==pip[5])return pip[2];
    else if(top==pip[2]&&front==pip[0])return pip[1];
    else if(top==pip[2]&&front==pip[1])return pip[5];
    else if(top==pip[2]&&front==pip[4])return pip[0];
    else if(top==pip[2]&&front==pip[5])return pip[4];
    else if(top==pip[3]&&front==pip[0])return pip[4];
    else if(top==pip[3]&&front==pip[1])return pip[0];
    else if(top==pip[3]&&front==pip[4])return pip[5];
    else if(top==pip[3]&&front==pip[5])return pip[1];
    else if(top==pip[4]&&front==pip[0])return pip[2];
    else if(top==pip[4]&&front==pip[2])return pip[5];
    else if(top==pip[4]&&front==pip[3])return pip[0];
    else if(top==pip[4]&&front==pip[5])return pip[3];
    else if(top==pip[5]&&front==pip[1])return pip[3];
    else if(top==pip[5]&&front==pip[2])return pip[1];
    else if(top==pip[5]&&front==pip[3])return pip[4];
    else if(top==pip[5]&&front==pip[4])return pip[2];
}



Measured memory_bytes: 3048
// In The Name OF Allah
// Mehrkish Makuei
// Islamic Republic Of Iran

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

typedef long long ll;
#define Mehrkish ios::sync_with_stdio(false),		cin.tie(0),		cout.tie(0)
#define pb push_back

const int maxx = 2e5 + 19;
int n, m, a[maxx], c[maxx], b[maxx], ans, jvb, sum, z, l, x, y, k, minn = 99999999;
string s[119], t, w;
bool flag = true;
vector <ll> v;

void Input(){
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
}

void Solve(){
	for ( int i = 0; i < 5; i++ ){
		for ( int j = 0; j < 5; j++ ){
			if ( abs( a[i] - a[j] ) > k )
				ans++;
		}
	}
	if ( ans > 0 ) cout << ":(" << endl;
	else cout << "Yay!" << endl;
}


int main(){
	Mehrkish;
	Input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int two(int counter, int val){
    int res;
    res = val % 2;
    if(res == 0){
        int new_val;
        new_val = val / 2;
        return two(counter + 1, new_val);
    }else{
        return counter;
    }
}

int main(){
    int i;
    int N;
    scanf("%d", &N);

    int *a;
    a = (int *)malloc(sizeof(int) * N);
    for(i=0; i<N; i++){
        scanf("%d", &a[i]);
    }

    int counter;
    counter = 0;
    
    for(i=0; i<N; i++){
        counter += two(0, a[i]);
    }

    printf("%d\n", counter);

    free(a);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);

	ll N; cin >> N;

	vl hs(N); FOR(i, 0, N) cin >> hs[i];

	vl ans(hs);
	
	ans[N-1] = 0;
	FORD(i, 0, N-1) {
		if (hs[i+1] > hs[i]) {
			ans[i] = 0;
		} else {
			ans[i] = ans[i+1] + 1;
		}
	}


	cout << *max_element(all(ans)) << endl;
} //cin.tie(0) bei schnellem Wechseln


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	std::vector<int> a;
	for (int i = 0; i < n; i++) a.push_back(ri());
	std::vector<std::pair<int, int> > b;
	for (int i = 0; i < m; i++) {
		int l = ri();
		int r = ri();
		b.push_back({r, l});
	}
	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end(), std::greater<>());
	int cur = 0;
	int64_t res = 0;
	for (int i = 0; i < m; i++) {
		if (cur >= n) break;
		int next = std::lower_bound(a.begin(), a.end(), b[i].first) - a.begin();
		if (cur > next) break;
		if (next - cur > b[i].second) next = cur + b[i].second;
		// std::cerr << cur << ";" << next << std::endl;
		if (next >= n) next = n;
		if (next > cur) {
			res += (next - cur) * (int64_t) b[i].first;
		}
		cur = next;
	}
	if (cur < n) for (int i = cur; i < n; i++) res += a[i];
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 1784
/***********************
*  Date: 2018.11.28    *
*  Problem:            *
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,q,appe[100010][20],coap[100010],len=0;//appe:appearance
int list_top[200010],val[200010],nxt[200010];

void add(int x,int y)
{
	val[++len]=y;
	nxt[len]=list_top[x];
	list_top[x]=len;
}

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	cin>>q;
	repn(i,q)
	{
		int x,y;
		scanf("%d%d%d",&x,&y,&coap[i]);
		appe[x][y]=i;
	}
	for(int i=9;i>=0;i--)//算能不能覆盖appe[j][i]之前要先算出appe[p][i+1]会不会被覆盖，所以i要倒着循环 
	{
		repn(p,n)
		{
			for(int k=list_top[p];k!=0;k=nxt[k])//i在这里代表可以控制的范围
			{
				int j=val[k];
				appe[j][i]=max(appe[j][i],appe[p][i+1]);/*远一条边距离就要加1，这里是看后者可不可以覆盖前者，
				可以说是一种dp，一个类似递归的过程，如果再之前的点把后者覆盖了，也会在前者上体现出来*/
			}	
		}	
	} 
	repn(i,n)
	{
		int lst=0;
		rep(j,11) lst=max(lst,appe[i][j]);
		cout<<coap[lst]<<endl;
	}
	rt0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#define MAX_N 300000

int max(int a, int b) {
    return (a > b) ? a : b;
}

int t[MAX_N];
int main() {
    int a;
    scanf("%d", &a);
    for (int i=0;i<a;i++) scanf("%d", t+i);
    int x = t[0];
    for (int i=1;i<a;i++) x = (x-10 < 0) ? 0 : max(x-10, t[i]);
    int y = t[a-1];
    for (int i=a-2;i>=0;i--) y = (y-10 < 0) ? 0 : max(y-10, t[i]);
    if (x>0&&y>0) puts("yes"); else puts("no");
}



Measured memory_bytes: 2844
#include<bits/stdc++.h>
using namespace std;
int taka(int m,int d){
  if(m<4||d<22) return 0;
  int i=22, prod, count = 0;
  while(i<=d){
    if(i%10 >=2){
      prod = (i/10)*(i%10);
      if(prod<=m) count++;
    }
    ++i;
  }
  return count;
}
int main(){
  int m,d,ans;
  cin>>m>>d;
  ans = taka(m,d);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
  
  
       int n,p;
       cin>>n>>p;
       int a[n];
       for(int i=0;i<n;i++)cin>>a[i];
       int ans[2][n];
       if(a[0]%2){
         ans[0][0]=1;ans[1][0]=1;
       }else{
         ans[0][0]=2;ans[1][0]=0;
       }
       for(int i=1;i<n;i++){
         if(a[i]%2){
           ans[0][i]=ans[0][i-1]+ans[1][i-1];
           ans[1][i]=ans[0][i-1]+ans[1][i-1];
         }else{
           ans[0][i]=ans[0][i-1]*2;
           ans[1][i]=ans[1][i-1]*2;
         }
       }
       cout<<ans[p][n-1]<<endl;
    


}


        


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;

int main()
{
    int n;
    cin >> n;
    int c=0;
    bool shown=false;
    for(int i=0;i<n;i++)
    {
        int d1,d2;
        cin >> d1 >> d2;
        if(d1==d2)
        {
            c++;
        }
        else
        {
            if(c>=3)
                shown=true;
            c=0;
        }
    }
    if(c>=3)
        shown=true;
    if(shown)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ios       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,a,n) for (ll i = a; i < (ll)(n); i++)
#define fon(i,n) for (ll i = (ll)n-1; i >=0; i--)
#define vi          vector<ll>
#define vii vector<pair<ll,ll>>
#define all(a)      (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ciin(v) forn(i,0,v.size()) cin>>v[i]
#define coutt(v) forn(i,0,v.size()) cout<<v[i]<<" "
using namespace std;
ll mod=1e9+7;
int main(){
    ios
    ll test;
    test=1;
    // cin>>test;
    while(test--){
        ll n,w;
        cin>>n>>w;
        vi wei(n),v(n);
        forn(i,0,n) cin>>wei[i]>>v[i];
        ll sum=0;
        forn(i,0,n) sum+=v[i];
        vi dp(sum+1,1e18);
        dp[0]=0;
        forn(i,0,n){
            for(int j=sum-v[i];j>=0;j--){
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+wei[i]);
            }
        }
        ll fin=0;
        forn(i,0,sum+1){
            if(dp[i]<=w) fin=i;
        }
        cout<<fin;
       


 
 }}

Measured memory_bytes: 3984
N, INF = 10, 1 << 40
M = [[INF for j in range(N)] for i in range(N)]
dist = [[INF for l in range(N)] for m in range(N)]


def dijkstra(s):
    check = [0 for i in range(N)]
    dist[s][s] = 0

    while True:
        min_cost, u = INF, -1
        for i in range(N):
            if check[i] != 2 and dist[s][i] < min_cost:
                min_cost = dist[s][i]
                u = i

        if min_cost == INF:
            break

        check[u] = 2

        for v in range(N):
            if check[v] != 2 and M[u][v] != INF:
                if dist[s][u] + M[u][v] < dist[s][v]:
                    dist[s][v] = dist[s][u] + M[u][v]
                    check[v] = 1


def main():
    h, w = map(int, input().split())
    for i in range(N):
        low = list(map(int, input().split()))
        for j in range(N):
            if low[j] != 0:
                M[i][j] = low[j]

    grid = []
    for i in range(h):
        grid.append(list(map(int, input().split())))

    for i in range(N):
        dijkstra(i)

    cost = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] != -1:
                num = grid[i][j]
                cost += dist[num][1]

    print(cost)


if __name__ == '__main__':
    main()


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

int main(){
	string s;
	int num[256];
	num['I']=1;
	num['V']=5;
	num['X']=10;
	num['L']=50;
	num['C']=100;
	num['D']=500;
	num['M']=1000;
	while(cin>>s){
		int ans=num[s[0]];
		for(int i=1;i<s.size();i++){
			if(num[s[i-1]]<num[s[i]])ans+=num[s[i]]-2*num[s[i-1]];
			else ans+=num[s[i]];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split;
	auto N = data[0].to!int, M = data[1].to!int, C = data[2].to!int;
	auto B = readln.split.to!(int[]);
	
	int ans = 0;
	foreach (i; 0 .. N) {
		auto row = readln.split.to!(int[]);
		M.iota.each!(i => row[i] *= B[i]);
		if (row.sum + C > 0) { ans++; }
	}
	writeln(ans);
	
}

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

int main()
{
	vector<int> a;
	int n;

	cin >> n;

	int t;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		a.push_back(t);
	}

	int b[1000001] = {0};

	for (int i = 0; i < n; i++){
		b[a[i] - 1]++;
		b[a[i]]++;
		b[a[i] + 1]++;
	}

	int maxi = 0;
	for (int i = 0; i < 100001; i++){
		if(maxi<b[i])
			maxi = b[i];
	}

	cout << maxi << endl;
}

Measured memory_bytes: 4728
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[520][520] = {};
int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	int onazi = 0;
	for (int i = 0; i < min(s.size(), t.size()); i++) {
		if ((t[i] - 'a') > (s[i] - 'a')) {
			break;
		}
		if (t[i] == s[i]) {
			onazi = onazi + 1;
		}
		if ((t[i] - 'a') < (s[i] - 'a')) {
			cout << "No";
			return 0;
		}
	}
	if (onazi == min(t.size(), s.size())) {
		if (t.size() > s.size()) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else {
		cout << "Yes";
	}
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> c(13);
    for (auto i : irange(0L, n)) {
        int64_t d;
        cin >> d;
        ++c[d];
    }

    if (c[0] >= 1 || c[12] >= 2) {
        cout << 0 << endl;
        return 0;
    }

    vector<int64_t> h, h1;
    h1.push_back(0L);

    for (auto i : irange(1L, 13L)) {
        if (c[i] >= 3) {
            cout << 0 << endl;
            return 0;
        }

        if (c[i] == 2) {
            h1.push_back(i);
            h1.push_back(24 - i);
        }

        if (c[i] == 1) {
            h.push_back(i);
        }
    }

    int64_t ans = 0;
    for (auto bs0 : irange(0uL, 1uL << h.size())) {
        bitset<12> bs(bs0);
        auto h2 = h1;

        for (auto i : irange(0uL, h.size())) {
            if (bs[i]) {
                h2.push_back(h[i]);
            } else {
                h2.push_back(24 - h[i]);
            }
        }

        int64_t s = 24;
        for (auto i : irange(0uL, h2.size())) {
            for (auto j : irange(0uL, h2.size())) {
                if (i != j) {
                    auto d = abs(h2[i] - h2[j]);
                    s = min(s, min(d, 24 - d));
                }
            }
        }

        ans = max(ans, s);
    }

    cout << ans << endl;
}

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

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  VI a(5);
  REP(i,5) cin >> a[i];
  int ans=0;
  auto last=a.begin();
  EACH(i,a){
    if(*i%10!=0&&(*i)%10<(*last)%10) last = i;
  }
  EACH(i,a){
    if(i==last) continue;
    ans += ceil(((double)*i*0.1));
  }
  ans *= 10;
  ans += *last;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  int a[12][12]={};
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int ans=1001001001;
  for(int bit=0;bit<(1<<n);bit++){
    int cost=0;
    int d[m]={};
    for(int i=0;i<n;i++){
      if(bit>>i&1){
        cost+=c[i];
        for(int j=0;j<m;j++) d[j]+=a[i][j];
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++) if(d[j]<x) ok=false;
    if(ok) ans=min(ans,cost);
  }
  if(ans==1001001001) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3600
from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))

ans = 0
for x,y in a.items():
  cnt = y
  if x-1 in a: cnt += a[x-1]
  if x+1 in a: cnt += a[x+1]
  if cnt > ans: ans = cnt
print(ans)

Measured memory_bytes: 14564
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!string;
	long cnt;
	foreach (c; N)
	{
		cnt += [c].to!long;
	}

	writeln(N.to!long % cnt == 0 ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

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

const int MAXN = 112345;

string s, t;
int sums[MAXN][2], sumt[MAXN][2];

// 0 -> Da pra transformar em ''
// 1 -> Da pra transformar em A
// 2 -> Da pra transformar em B
int getState (int a, int b) {
	// cout << a << " e " << b << endl;
	int d = a - b;
	d %= 3;
	d += 3;
	
	return d % 3;
}

int main () {

	ios :: sync_with_stdio (false); cin.tie (0);
	
	cin >> s >> t;
	
	for (int i = 1; i <= s.size(); ++i) {
		int c = s[i - 1] - 'A';
		sums[i][c] = 1 + sums[i - 1][c];
		sums[i][c ^ 1] = sums[i - 1][c ^ 1];
	}
	
	for (int i = 1; i <= t.size(); ++i) {
		int c = t[i - 1] - 'A';
		sumt[i][c] = 1 + sumt[i - 1][c];
		sumt[i][c ^ 1] = sumt[i - 1][c ^ 1];
	}
	
	
	int q;
	cin >> q;
	while (q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a > b) swap (a, b);
		if (c > d) swap (c, d);
		int s1 = getState (sums[b][0] - sums[a - 1][0], sums[b][1] - sums[a - 1][1]);
		int s2 = getState (sumt[d][0] - sumt[c - 1][0], sumt[d][1] - sumt[c - 1][1]);
		
		// cout << s1 << " " << s2 << endl;
		if (s1 == s2)
			printf ("YES\n");
		else
			printf ("NO\n");
	}

	return 0;
}

Measured memory_bytes: 2512
#include <stdio.h>

int main(void) {

  while (1) {
    int a, b;
    char op;

    scanf("%d %c %d", &a, &op, &b);

    if (op == '?')
      break;

    if (op == '+')
      printf("%d\n", a + b);
    else if (op == '-')
      printf("%d\n", a - b);
    else if (op == '*')
      printf("%d\n", a * b);
    else if (op == '/')
      printf("%d\n", a / b);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    ll ans = 0;
    repf(i,1,n+1) {
        if (i%3!=0 && i%5!=0) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
struct Point{double x,y;};
double dist(Point a,Point b) {return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));}
#define eps 0.0001

int main(void){
    int N;
    while(cin>>N,N){
        vector<Point> p(N);
        int maxcnt=1;
        rep(i,N)cin>>p[i].x>>p[i].y;
        rep(i,N){
            for(int j=i+1;j<N;j++){
                double d = dist(p[i],p[j]);
                if(d>2.0)continue;
                Point C1,C2;
                C1.x = p[i].x + cos(atan2(p[j].y-p[i].y,p[j].x-p[i].x) + acos(d/2.0));
                C1.y = p[i].y + sin(atan2(p[j].y-p[i].y,p[j].x-p[i].x) + acos(d/2.0));
                C2.x = p[i].x + cos(atan2(p[j].y-p[i].y,p[j].x-p[i].x) - acos(d/2.0));
                C2.y = p[i].y + sin(atan2(p[j].y-p[i].y,p[j].x-p[i].x) - acos(d/2.0));
                int cnt=0;
                rep(k,N){
                    if(pow(C1.x-p[k].x,2) + pow(C1.y-p[k].y,2) <= 1.0+eps)cnt++;
                }
                if(maxcnt<cnt)maxcnt=cnt;
                cnt=0;
                rep(k,N){
                    if(pow(C2.x-p[k].x,2) + pow(C2.y-p[k].y,2) <= 1.0+eps)cnt++;
                }
                if(maxcnt<cnt)maxcnt=cnt;
            }
        }
        cout<<maxcnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 1392
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool srt(ll a,ll b)
{
	return a>b;
}
int main()
{
	ll i,j,k,x,y,m,n,t,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<ll> v,v1;
	for(i=0;i<a;i++)
	{
		cin>>j;
		v1.push_back(j);
	}
	sort(v1.begin(),v1.end(),srt);
	for(i=0;i<x;i++)
	v.push_back(v1[i]);
	v1.clear();
	for(i=0;i<b;i++)
	{
		cin>>j;
		v1.push_back(j);
	}
	sort(v1.begin(),v1.end(),srt);
	for(i=0;i<y;i++)
	v.push_back(v1[i]);
	v1.clear();
	for(i=0;i<c;i++)
	{
		cin>>j;
		v1.push_back(j);
	}
	sort(v1.begin(),v1.end(),srt);
	sort(v.begin(),v.end());
	ll ans=0;
	j=0;
	for(i=0;i<x+y;i++)
	{
		if(j>=c)
		ans+=v[i];
		else
		{
			if(v1[j]>v[i])
			{
				ans+=v1[j];
				j++;
			}
			else ans+=v[i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
	int x, y, u;
	scanf("%d", &x);
	u = (x / 500) * 1000;
	y = x - (x / 500) * 500;
	u = u + (y / 5) * 5;
	printf("%d", u);
	return 0;
}


Measured memory_bytes: 128
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn travel(pos: usize, mat: &Vec<Vec<usize>>, visited: &mut Vec<bool>) {
    if visited[pos] {
        return;
    }
    visited[pos] = true;
    for i in 0..mat[pos].len() {
        let next = mat[pos][i];
        travel(next, mat, visited);
    }
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let m = line[1];

    let mut l: Vec<Vec<usize>> = Vec::with_capacity(n);
    let mut mat = vec![Vec::new(); n + m];
    for i in 0..n {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        l.push(Vec::from(line.split_at(1).1));
        for j in 1..line.len() {
            let lan = line[j] - 1;
            mat[lan].push(m+i);
            mat[m+i].push(lan);
        }
    }

    let mut visited = vec![false; n+m];
    travel(m, &mat, &mut visited);

    let mut ans = true;
    for i in 0..n {
        if !visited[i+m] {
            ans = false;
            break;
        }
    }
    if ans {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int k=ceil(sqrt(2*n));
  if(k*(k-1)!=2*n){
    cout << "No" << endl;
    return 0;    
  }
  cout << "Yes" << endl;
  int s[k][k-1];
  int unuse=1;
  rep(i,k){
    rep(j,k-1){
      if(j>=i){
	s[i][j]=unuse;
	unuse++;
      }
      else{
	s[i][j]=s[j][i-1];
      }
    }
  }
  cout << k << endl;
  rep(i,k){
    cout << k-1 << " ";
    rep(j,k-1){
      cout << s[i][j] << " ";
    }
    cout << "" <<endl;
  }

  
  
  return 0;
    

}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string s,t;
	cin>>s>>t;
	int r[26]={};
	for(int i=0;i<26;i++)r[i]=-1;
	for(int i=0;i<s.size();i++){
		if(r[s[i]-'a']<0) r[s[i]-'a']=t[i]-'a';
		else {
			if(r[s[i]-'a']!=t[i]-'a'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<26;i++)r[i]=-1;
	for(int i=0;i<t.size();i++){
		if(r[t[i]-'a']<0) r[t[i]-'a']=s[i]-'a';
		else {
			if(r[t[i]-'a']!=s[i]-'a'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int> A(n);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A.begin(), A.end(), greater<int>());
	double j = sum / (4.0 * m);
	bool ok = true;
	if (A[m - 1] < j) ok = false;
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code, unused_imports, deprecated)]
 
use std::collections::HashMap;
use std::cmp::Reverse;
 
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

use maplit::*;

#[fastout]
fn main() {
  input!{
    n: usize,
    s: Bytes,
  };

  let mut res = 0;
  if n > 3 {
    let mut cnt = maplit::hashmap!{
      b'R' => 0usize,
      b'G' => 0usize,
      b'B' => 0usize,
    };
    for c in s.iter().copied() {
      cnt.entry(c)
        .and_modify(|e| *e += 1 )
        .or_insert(1);
    }

    res = cnt.get(&b'R').unwrap() * cnt.get(&b'G').unwrap() * cnt.get(&b'B').unwrap();

    for i in 0..(n - 1) {
      for j in (i + 1)..n {
        if s[i] == s[j] { continue; }
        let k = 2 * j - i;
        if k >= s.len() || s[k] == s[i] || s[k] == s[j] { continue; }
        res -= 1;
      }
    }
  }
  
  println!("{}", res);
}

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

using namespace std;

int interval_scheduling(int N, vector<int>& vs, vector<int>& vt) {
  vector<pair<int, int>> itv;
  for (int i = 0; i < N; i++) {
    itv.push_back(make_pair(vt[i], vs[i]));
  }
  sort(itv.begin(), itv.end());

  int ans = 0, t = 0;
  for (int i = 0; i < N; i++) {
    if (t <= itv[i].second) {
      ans++;
      t = itv[i].first;
    }
  }
  return ans;
}

int main()
{
  int N, M; cin >> N >> M;
  vector<int> s(M), t(M);
  for (int i = 0; i < M; i++) cin >> s[i] >> t[i];
  cout << interval_scheduling(M, s, t) << endl;
  return 0;
}


Measured memory_bytes: 2296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
        int n, a, b;
        scanf("%d%d%d", &n, &a, &b);
        int ans = 0;
        for (int i = 1; i <= n; i ++) {
                string s = to_string(i);
                int cnt = 0;
                for (int i = 0; i < s.size(); i ++) {
                        cnt += s[i] - '0';
                }
                if (a <= cnt && cnt <= b) ans += i;
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007


ll s[100][100]={0};
//kiwa wo kanngaeru noga menndoikara
//waku wo zero de umeru

int main(){
  ll h,w;
  cin >> h >> w;
  char c;
  bool flag=true;
  rep1(i,h){
    rep1(j,w){
      cin >> c;
      if(c=='#')s[i][j]=1;
    }
  }
  rep1(i,h){
    rep1(j,w){
      if(s[i][j]==1){
        if(s[i][j-1]==0&&s[i][j+1]==0&&s[i-1][j]==0&&s[i+1][j]==0){
          flag=false;
          break;
        }
      }
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#define endl "\n"

using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//int  frq[100007];
int main(){
	Lancer();
	//cout << fixed << setprecision(12);
	
	long long  a, b, r;
	cin >> a >> b;
	r = a/b;
	r *= b;
	a -= r;
	cout << min(a, abs(a - b));
	cout << endl;
	return 0;
}


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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	const int N = 256;
	char m[N] = {};
	bool used[N] = {};
	string s,t;
	cin >> s >> t;
	bool valid = true;
	for(int i = 0;i < s.length(); ++i){
		if(m[s[i]] == '\0'){
			if(used[t[i]])valid = false;	
			else {
				m[s[i]] = t[i];
				used[t[i]] = 1;
			}
		}
		else{
			if(t[i] != m[s[i]])valid = false;
		}
	}
	cout << (valid?"Yes":"No") << '\n';
}


Measured memory_bytes: 916