akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ll> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    ll ans = 0;

    for (int i = 1; i < N; ++i)
    {
        if (xs[i] < xs[i - 1])
        {
            auto diff = xs[i - 1] - xs[i];
            xs[i] += diff;
            ans += diff;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4784
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
int en,front[10],cnt;
struct edge{
	int v,nex;
}e[10];
bool vis[10],flag;
il void addedge(int u,int v){
	en++;
	e[en].v=v;
	e[en].nex=front[u];
	front[u]=en;
}
void dfs(int u){
	vis[u]=1;
	cnt++;
	bool f=0;
	for(int i=front[u];i;i=e[i].nex){
		int v=e[i].v;
		if(vis[v]) continue;
		f=1;
		dfs(v);
	}
	if(!f&&cnt<4) flag=1;
}
int main(){
	int a,b;
	for(int i=1;i<=3;i++){
		in2(a,b);
		addedge(a,b);
		addedge(b,a);
	}
	for(int i=1;i<=4;i++){
		memset(vis,0,sizeof(vis));
		cnt=0;
		flag=0;
		dfs(i);
		if(!flag){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
n, c, k = gets.split.map(&:to_i)
ts = []
n.times do
  ts << gets.to_i
end
ts.sort!

# puts ts.inspect

ans = 0
cur = 0
while cur < n
  cur_t = ts[cur]
  a = ts.bsearch_index { |t| t > cur_t + k } || 10 ** 20
  # puts a
  cur = [cur+c, a].min
  # puts "#{a} #{cur}"
  ans += 1
end
puts ans

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long int n,a,b,p;
    double t;
    cin>>n>>a>>b;
    if(a==0)
    cout<<0;
    else
    {
    if(n%(a+b)==0)
    cout<<(n/(a+b)*a);
    else
    {
        if(n%(a+b)>=a)
       cout<<(n/(a+b))*a+a;
    else
    cout<<(n/(a+b))*a+n%(a+b);
    }
    }
}

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

#define db double
#define ll long long
ll n, m, x, y;

int main() {
	while (scanf("%lld%lld%lld%lld", &n, &m, &x, &y) != EOF) {
		db res = 1ll * n * m * 1.0 / 2;
		bool F = 0;
		if (n % 2 == 0 && m % 2 == 0 && x == n / 2 && y == m / 2) {
			F = 1;
		}
		printf("%.15f %d\n", res, F); 
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    x, y = map(int, input().split())
    l = list()
    l.append(2*x)
    for i in range(1, x+1):
        l.append(2*x + i*2)
    if y in l:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}


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

int main(){
    int n, cnt = 0;
    scanf("%d", &n);
    bool ok = 0;
    for(int i=0;i<n;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        if(a == b) cnt++;
        else cnt = 0;
        if(cnt >= 3) ok = 1;
    }
    if(ok) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 3756
N,K = map(int,input().split())

a = [ [0]*2 ] * N
count = 0

for i in range(N):
    a[i] = list(map(int,input().split()))


a.sort(key=lambda x:x[0])


for i in range(N):
    count += a[i][1]
    if count >= K:
        print(a[i][0])
        break
    


Measured memory_bytes: 29144
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll l,r;
  cin >> l >> r;

  if((l/2019L) < (r/2019L)){
    cout << 0 << endl;
  }else{
    l %= 2019; r %= 2019;
    ll ans = 2019*2019;
    for(ll i=l; i<r; ++i) for(ll j=i+1; j<=r; ++j) ans = min(ans,((i*j)%2019));
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e6 + 5;

ll fac[nax], iv[nax], k, n;
string s;

ll pangkat(ll x, ll y){
	if(y == 0){
		return 1;
	}
	ll temp = pangkat(x, y / 2);
	if(y & 1){
		return temp * temp % mod * x % mod;
	}
	else{
		return temp * temp % mod;
	}
}

ll c(ll x, ll y){
	return fac[x] * iv[y] % mod * iv[x-y] % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	fac[0] = 1ll;
	for(ll i = 1; i < nax; i++){
		fac[i] = (fac[i-1] * i) % mod;
	}
	iv[0] = 1ll;
	for(ll i = 1; i < nax; i++){
		iv[i] = pangkat(fac[i], mod - 2);
	}
	
	cin >> k >> s;
	n = s.size();
	
	ll ans = 0;
	for(ll i = 0; i <= k; i++){
		ans = ans + (pangkat(26, i) * pangkat(25, k - i) % mod * c(k-i+n-1, n-1) % mod);
		ans %= mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 35508
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main(void) {
  int n, r;
  int c, p;
  int yama[51];
  queue<int> s;

  while (1) {
	cin >> n >> r;
	if (n == 0 && r == 0) break;

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

	for (int i = 0; i < r; i++) {
	  cin >> p >> c;

	  for (int j = 0; j < c; j++) {
		s.push(yama[n - p - j]);
	  }

	  for (int j = n - p + 1; j < n; j++) {
		yama[j - c] = yama[j];
	  }

	  for (int j = 1; j <= c; j++) {
		yama[n - j] = s.front();
		s.pop();
	  }
	}
	cout << yama[n - 1] << endl;
  }
}

Measured memory_bytes: 3056
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine((s[0] == s[2] ? "=" : (s[0] < s[2] ? "<" : ">")));
    }
}

Measured memory_bytes: 13140
using System;
using System.Linq;

namespace dotnet_test
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var hw =
                Console.ReadLine()
                .Split(' ')
                .Select(Int64.Parse)
                .ToArray();
            Int64 H = hw[0], W = hw[1];

            Int64 ret;
            if (H == 1 || W == 1)
            {
                ret = 1;
            }
            else
            {
                ret =
                ((W + 1) / 2) * ((H + 1) / 2)
                + (W / 2) * (H / 2);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main()
{
    int k,s;
    int x,y,z,count=0;
    scanf("%d%d",&k,&s);
    for(x=0;x<=k;x++)
    {
        for(y=0;y<=k;y++)
        {
            z=s-x-y;
            if(z>=0 && z<=k)
            {
                count++;
            }
        }
    }
    printf("%d\n",count);
}


Measured memory_bytes: 128
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

using std::cin;
using std::cout;
using std::endl;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100000 + 5;
const int M = 3000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, m, q;
ll a[N], b[N];

int main() {
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= m; i++) scanf("%lld", &b[i]);
    while (q--) {
        ll x;
        scanf("%lld", &x);
        int ua, ub, da, db;
        ll u, d, ans = LLONG_MAX;
        ua = std::lower_bound(a + 1, a + n + 1, x) - a;
        ub = std::lower_bound(b + 1, b + m + 1, x) - b;
        // if (ua != 1) da = ua - 1;
        // if (ub != 1) db = ub - 1;
        da = ua - 1;
        db = ub - 1;
        if (ua != n + 1 && ub != m + 1) {
            u = std::max(a[ua], b[ub]) - x;
        } else {
            u = LLONG_MAX;
        }
        if (da != 0 && db != 0) {
            d = x - std::min(a[da], b[db]);
        } else {
            d = LLONG_MAX;
        }

        ans = std::min(u, d);

        if (da != 0 && ub != m + 1) {
            ll t1 = (x - a[da]) * 2 + b[ub] - x;
            ll t2 = (b[ub] - x) * 2 + x - a[da];
            ans = std::min(ans, std::min(t1, t2));
        }

        if (db != 0 && ua != n + 1) {
            ll t1 = (x - b[db]) * 2 + a[ua] - x;
            ll t2 = (a[ua] - x) * 2 + x - b[db];
            ans = std::min(ans, std::min(t1, t2));
        }
        
        printf("%lld\n", ans);
    }
    return 0;
}

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

bool check(string &a,int i){
  return i+3<=a.size()&&a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C';
}

string ABC="ABC"; 
bool dfs(string sta){
  if(sta.size()<=3)return sta==ABC;
  
  bool used[3]={1,1,1};
  for(int i=0;i<sta.size();)
    check(sta,i)? i+=3:used[sta[i++]-'A']=0;
  
  
  for(int i=0;i<3;i++){
    string nx;
    int j=0;
    while(used[i]&&j<sta.size())
      if(check(sta,j))nx+=ABC[i],j+=3;
      else nx+=sta[j++];
    
    if(nx.size()==sta.size())return 0;
    if(dfs(nx))return 1;
  }
  return 0;
}

int main(){
  string str;
  cin>>str;
  cout<<(dfs(str)? "Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 21792
#include<stdio.h>
int main(void)
{
 int a=0;
 int W,H,x,y,r=0;
 scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W){
    if(y-r>=0&&y+r<=H){
     a=1;
    }
  }
  else{
  a = 0;
 }
  if(a == 1){
  printf("Yes\n");
 }
 else if(a == 0){
 printf("No\n");
}

 return 0;
}

Measured memory_bytes: 584
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

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

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

func main() {
	N := nextInt()
	all, even := 1, 1
	for i := 0; i < N; i++ {
		all *= 3
		if nextInt()%2 == 0 {
			even *= 2
		}
	}
	fmt.Println(all - even)
}

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

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> count(m);
  for(int i = 0;i < n;i++) {
    int k;
    cin >> k;
    for(int j = 0;j < k;j++) {
      int a;
      cin >> a;
      count.at(a - 1)++;
    }
  }
  int count1 = 0;
  for(int i = 0;i < m;i++) {
    if(count.at(i) == n) {
      count1++;
    }
  }
  cout << count1 << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
 int a,b;
  string c;
  cin>>a>>b>>c;
  c[b-1]+=32;
  out(c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int expr(auto& itr) {
  if (isdigit(*itr)) return *itr++ - '0';
  if (*itr == '-') return 2 - expr(++itr);
  int l = expr(++itr);
  if (*itr++ == '*') {
    int r = expr(itr);
    ++itr;
    return min(l, r);
  } else {
    int r = expr(itr);
    ++itr;
    return max(l, r);
  }
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    string s; cin >> s;
    if (s == ".") break;
    int res = 0;
    for (int p = 0; p < 3; ++p) for (int q = 0; q < 3; ++q) for (int r = 0; r < 3; ++r) {
      auto t = s;
      for (auto&& e : t) {
        if (e == 'P') e = '0' + p;
        if (e == 'Q') e = '0' + q;
        if (e == 'R') e = '0' + r;
      }
      auto itr = begin(t);
      res += expr(itr) == 2;
    }
    cout << res << '\n';
  }
}


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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
	int N; cin>>N;
	vector<long> caps(N);
	for (auto&a : caps)
	    cin>>a;

	vector<long> difskip(N);
    long sum = 0;
	for (int i = 0; i < N; i++) {
	    sum += caps[i];
	    difskip[i] = (caps[(i+1)%N] - caps[i]) * 2;
	}
	long minh = 0;
	int mini = 0;
	long height = 0;
	for (int i = 0, c = 0; c < N; i=(i+2)%N, c++) {
	    if (height  < minh) {
	        minh = height;
	        mini = i;
	    }
        height += difskip[i];
	}
	vector<long> weights(N);
	long weight = 0;
    for (int i = mini, c = 0; c < N; i=(i+2)%N, c++) {
        weights[i] = weight;
        sum -= weight;
        weight += difskip[i];
    }
    for (int i = 0; i < N; i++) {
        cout << weights[i]+sum/N << " ";
    }
    cout << endl;
	
    return 0;
}


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

int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;

    long long ans;
    // if(b*d < 0){
    //     ans = min(b*c, a*d);
    // }else{
    //     ans = max(b*c)
    // }

    ans = max( max(a*c, a*d), max(b*d, b*c) );

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

Measured memory_bytes: 3628
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
/*
      for{
        i <- 0 to sqrtLimit
        if isPrime(i)
        j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))
      } notPrime(j)
      */
      /*
      (0 to sqrtLimit).map{ i =>
        val p = 2 * i + 3
        if(isPrime(i))Range((p*p-3)/2, top, p).map{notPrime}
      }
      */

      (0 to sqrtLimit).withFilter(isPrime).map { i =>
          Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3)).map(notPrime)
      }


      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 306332
# https://atcoder.jp/contests/abc178/submissions/16722764
MOD=10**9+7

S=int(input())
dp=[0]*2001
dp[0]=dp[1]=dp[2]=0
dp[3]=1
#書き出せば漸化式に気づけたかも
for s in range(4,S + 1):
    dp[s]=dp[s-1]+dp[s-3]
    dp[s]%=MOD
    #print(s, dp[s], dp[s-1], dp[s-3])
print(dp[S])



Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int a = 0;
  
  for(int i; i < 4; i++){
    if (S[i] == '+'){
      a++;
    }
    if(S[i] == '-'){
      a--;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
   int a,b,c,x,y;
   cin >> a >> b >> c >> x >> y;
   if(a+b <= 2*c){
       cout << a*x+b*y << endl;
   }else{
       if(x >= y){
           if(a <= 2*c){
               cout << y*2*c + (x-y)*a << endl;
           }else{
               cout << x*2*c << endl;
           }
       }else{
           if(b <= 2*c){
               cout << x*2*c + (y-x)*b << endl;
           }else{
               cout << y*2*c << endl;
           }
       }
   }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5,inf=0x3f3f3f3f,mo=1e9+7;
int a[N],b[N],mn[N],cnt[N],fac[N],inv[N];
poly v[N];
bool used[N];
int ksm(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mo){
		if(p&1) res=(ll)res*x%mo;
	}
	return res;
}
int main(){
	For(i,fac[0]=1,N-1) fac[i]=(ll)fac[i-1]*i%mo;
	inv[N-1]=ksm(fac[N-1],mo-2);
	Rep(i,N-2,0) inv[i]=(ll)(i+1)*inv[i+1]%mo;
	int n=read(),X=read(),Y=read(),zx=inf,cx=inf;
	For(i,1,n) mn[i]=inf;
	For(i,1,n){
		a[i]=read();b[i]=read();
		v[a[i]].pb(i);mn[a[i]]=min(mn[a[i]],b[i]);
	}
	For(i,1,n){
		if(mn[i]<zx) cx=zx,zx=mn[i];
		else if(mn[i]<cx) cx=mn[i];
	}
	For(i,1,n){
		if(mn[i]+zx>Y){
			for(auto x:v[i]) used[x]=1;
		}
		if(b[i]+mn[a[i]]>X&&b[i]+(mn[a[i]]==zx?cx:zx)>Y) used[i]=1;
	}
	int sum=0,ans;
	For(i,1,n) if(!used[i]) cnt[a[i]]++,sum++;
	ans=fac[sum];
	For(i,1,n) ans=(ll)ans*inv[cnt[i]]%mo;
	cout<<ans;
}

Measured memory_bytes: 17640
import sys
import math
import bisect

def solve(a, b, k):
    ans = []
    for i in range(k):
        if a + i <= b:
            ans.append(a + i)
        if b - i >= a:
            ans.append(b - i)
    ans = list(sorted(set(ans)))
    return ans

def main():
    a, b, k = map(int, input().split())
    for a in solve(a, b, k):
        print(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38704
#include<stdio.h>
#include<algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

struct xy{
  int x;
  int y;
};

struct xy to{0,0};
int ign_cnt;
struct xy ign_point[40] = {0,0};
int anser;

void serch( int x, int y){
  if(x == to.x && y == to.y){
    anser++;
    return;
  }

  rep( i, ign_cnt )
    if(x == ign_point[i].x && y == ign_point[i].y) return; 

  if(x + 1 <= to.x) serch( x + 1, y ); 

  if(y + 1 <= to.y) serch( x, y + 1 ); 
 
  return;
}

int main(){
  int ansers[5];
  rep( ds, 6 ){
    scanf( "%d%d", &to.x, &to.y );
    if( to.x == 0 && to.y == 0 ) {
      rep( i, ds) printf( "%d\n", ansers[i] );
      return 0;    
    }
    scanf( "%d", &ign_cnt );
    rep( i, ign_cnt )
      scanf( "%d%d",  &ign_point[i].x, &ign_point[i].y );
    anser = 0; 
    serch(1,1);
    ansers[ds] = anser; 
  }
  return 0;
}

Measured memory_bytes: 2576
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
struct P{
	int v,w,x,y;
};
bool pr(int* p,int* q){
	return *p<*q;
}
P a[1000];
int* x[2002],* y[2002];
char b[2003][2003];
void fi(int x,int y){
	static int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
	int i;
	b[x][y]=-1;
	for(i=0;i<4;++i){
		if(!b[x+dx[i]][y+dy[i]])
			fi(x+dx[i],y+dy[i]);
	}
}	
int main(){
	int i,j,k;
	int w,h;
	while(scanf("%d%d",&w,&h),w||h){
		int n;
		scanf("%d",&n);
		for(i=0;i<n;++i){
			scanf("%d%d%d%d",&a[i].v,&a[i].w,&a[i].x,&a[i].y);
			x[i*2]=&a[i].v;
			x[i*2+1]=&a[i].x;
			y[i*2]=&a[i].w;
			y[i*2+1]=&a[i].y;
		}
		int z=0;
		x[i*2]=&z;
		x[i*2+1]=&w;
		y[i*2]=&z;
		y[i*2+1]=&h;
		sort(x,x+n*2+2,pr);
		sort(y,y+n*2+2,pr);
		for(i=1;i<n*2+2&&*x[0]==*x[i];++i);
		for(;i<n*2+2;i=j){
			for(j=i+1;j<n*2+2&&*x[i]==*x[j];++j);
			for(k=i;k<j;++k)
				*x[k]=*x[i-1]+1;
		}
		for(i=1;i<n*2+2&&*y[0]==*y[i];++i);
		for(;i<n*2+2;i=j){
			for(j=i+1;j<n*2+2&&*y[i]==*y[j];++j);
			for(k=i;k<j;++k)
				*y[k]=*y[i-1]+1;
		}
		memset(b,-1,sizeof(b));
		for(i=1;i<=w;++i)
			memset(b[i]+1,0,sizeof(char)*h);
		for(i=0;i<n;++i)
			for(j=a[i].v+1;j<=a[i].x;++j)
				memset(b[j]+a[i].w+1,-1,sizeof(char)*(a[i].y-a[i].w));
		int ct=0;
		for(i=1;i<=h;++i){
			for(j=1;j<=w;++j){
				if(b[j][i])
					continue;
				fi(j,i);
				++ct;
			}
		}
		printf("%d\n",ct);
	}
	return 0;
}

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

int main(void){
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> c;
    rep(i,H){
        string s;
        cin >> s;
        c.push_back(s);
    }
    ll ans=0;
    for(int maskR = 0;maskR < (1<<H);maskR++){
        for(int maskC = 0;maskC < (1<<W);maskC++){
            int black =0;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if( ((maskR >> i)&1) && ((maskC >> j)&1)){
                        if(c[i][j] == '#') black += 1;
                    } 
                }
            }
            if(black == K) ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VVI egs,egl;
in sm=0;
bool fnd=0;
in n;
in tmg;
in dfs(in u, in pr){
  in tbl=1;
  in tc;
  bool iscent=1;
  in mng=1e18;
  forv(i,egs[u]){
    if(egs[u][i]==pr)
      continue;
    mng=min(mng,egl[u][i]);
    tc=dfs(egs[u][i],u);
    if(tc==n-tc){
      fnd=1;
      sm+=egl[u][i]*(2*tc-1);
    }
    else
      sm+=egl[u][i]*2*min(tc,n-tc);
    if(tc*2>=n)
      iscent=0;
    tbl+=tc;
  }
  if(tbl*2<=n)
    iscent=0;
  if(iscent)
    tmg=mng;
  return tbl;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  egs.resize(n);
  egl.resize(n);
  in ta,tb,tc;
  forn(zz,n-1){
    cin>>ta>>tb>>tc;
    --ta;
    --tb;
    egs[ta].PB(tb);
    egl[ta].PB(tc);
    egs[tb].PB(ta);
    egl[tb].PB(tc);
  }
  assert(dfs(0,0)==n);
  if(!fnd)
    sm-=tmg;
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 19328
import java.io.*;
import java.util.*;

class Main{
	public void run(){
		int N = ni();
		int M = ni();
		int K = ni();
		String ans = "No";
		for(int n=0;n<=M;n++){
			for(int m=0;m<=N;m++){
				int k = N * n + M * m - 2 * (n * m);
				if(k == K){
					ans = "Yes";
					break;
				}
			}
		}
        out.printf("%s\n", ans);
	}
/*
n=0:
K=0, M, 2M, ...
n=1
K=N, N-1+M-1, N-2+2M-2, N-3+3M-3
N=2
K=
*/
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 23252
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3 = x2 - (y2 - y1);
  int y3 = y2 + (x2 - x1);
  cout << x3 << " " << y3 << " ";

  int x4 = x3 - (x2 - x1);
  int y4 = y3 - (y2 - y1);
  cout << x4 << " " << y4 << endl;

  return 0;
}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  char t = 'a';
  int an = 0,bn = 0,cn = 0;
  
  while(true){
    if(t == 'a'){
      if(an == a.size()){
        cout << "A" << endl;
        break;
      }
      t = a[an];
      an++;
    }else if(t == 'b'){
      if(bn == b.size()){
        cout << "B" << endl;
        break;
      }
      t = b[bn];
      bn++;
    }else if(t == 'c'){
      if(cn == c.size()){
        cout << "C" << endl;
        break;
      }
      t = c[cn];
      cn++;
    }else{
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x) for(int i=0; i<x; i++)
typedef long long ll;

using namespace std;

int N;
int h[200002];
ll BIT[200002];

void update(int x, ll value){
  for(; x<=N; x+= x&-x){
    BIT[x] = max(BIT[x], value);
  }
}

ll query(int a){
  ll res = 0;
  for(; a>0; a-= a&-a){
    res = max(res, BIT[a]);
  }
  return res;
}



int main(){
  cin>>N;
  rep(i,N) cin>>h[i];
  rep(i,N){
    ll a;
    cin>>a;

    update(h[i],query(h[i])+a);
  }
  cout<<query(N);  
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int tscore = 0;
		int hscore = 0;
		for (int i = 0; i < n; i++) {
			String tcard = scan.next();
			String hcard = scan.next();
			if (tcard.compareToIgnoreCase(hcard) > 0) {
				tscore += 3;
			} else if (tcard.compareToIgnoreCase(hcard) < 0) {
				hscore += 3;
			} else {
				tscore += 1;
				hscore += 1;
			}
		}
		System.out.printf("%d %d\n", tscore, hscore);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 30744
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,i;
  cin >> n;
  vector<P> x(n);
  for(i=0;i<n;i++){
    cin >> x[i].second >> x[i].first;
  }
  sort(x.begin(),x.end());
  int t=0;
  for(i=0;i<n;i++){
    t+=x[i].second;
    if(t>x[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 305;
#define EPS 1e-9
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
double top;

double dp[305][305][305];
ll zer, fir, tir, sec;




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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    ll sum = 0;
    
    for(int i = 0; i < n; i++){
        int a;
        cin>>a;
        if(a == 1) fir++;
        if(a == 2) sec++;
        if(a == 3) tir++;
    }
    double a = 1.0;
    top = a / (fir + sec + tir);
    for(int i = 0; i <= tir; i++){
        for(int j = 0; j <= tir + sec; j++){
            for(int k = 0; k <= tir + sec + fir; k++){
                if(i == 0 && j == 0 && k == 0) continue;
                double p1 = top*i, p2 = j*top, p3 = k*top;
                double p4 = 1.0 - p1 - p2 - p3;
                double alp = 0;
                if(i){
                    alp += p1*(1 + dp[i - 1][j + 1][k]);
                }
                if(j){
                    alp += p2*(1 + dp[i][j - 1][k + 1]);
                }
                if(k){
                    alp += p3*(1 + dp[i][j][k - 1]);
                }
                dp[i][j][k] = (alp + p4)/(1 - p4);
            }
        }
    }
    cout<<fixed<<setprecision(15)<<dp[tir][sec][fir]<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 219392
#include <iostream>
using namespace std;
int main(){
    int A,B,C,X;//A500,B100,C50,Xmoney
    int g=0;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    for(int i=0;i<=C;i++){
        for(int k=0;k<=B;k++){
            for(int t=0;t<=A;t++){
                if(50*i+100*k+500*t==X){
                    g++;
                }
            }
        }
    }
    cout << g << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int H,W,N,max,kai;

    scanf("%d", &H);
    scanf("%d", &W);
    scanf("%d", &N);

    max=(H>W)?H:W;
    kai=N/max;
    kai+=(N%max==0)?0:1;

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

    return 0;
}


Measured memory_bytes: 128
N = int(input())

infs = []

for i in range(N):
    infs.append(list(map(int, input().split())))

for i in range(101):
    for j in range(101):
        min_dis = 300
        pre_h = 0
        ans = True
        for k in range(N):
            # 一番近いところは大丈夫
            x, y, h = infs[k]
            dx = abs(x - i)
            dy = abs(y - j)
            if min_dis > dx + dy:
                min_dis = dx + dy
                pre_h = h + dx + dy
        for k in range(N):
            # k番目大丈夫か
            x, y, h = infs[k]
            dx = abs(x - i)
            dy = abs(y - j)
            if max(pre_h - dx - dy, 0) != h:
                ans = False
                break

        if ans:
            print(i, j, pre_h)
            break

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i = 0;i<length;i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    System.out.print(Character.toUpperCase(ch));
                }else{
                    System.out.print(Character.toLowerCase(ch));
                }

            }
            System.out.println(answer);
        }
    }
}



Measured memory_bytes: 26716
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll t,n,m,k,z,x,c,s;
int main()
{
    fast;
    cin>>n>>m>>k;
    z=max(n,m);
    c=min(n,m);
    x=0;
    for(int i=1; i<=c; i++)
    {
        x+=z;
        if(i>1)
        {
            t=z/i;
           // x+=t;
        }
        //cout<<x<<" "<<i<<endl;
        if(x>=k)return cout<<i<<endl,0;
    }
}


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

int main() {
	string S;
	cin >> S;
	if(S[S.size()-1] == 's'){
		S = S + "es";
	}else{
		S = S + "s";
	}


	cout << S << endl;
	return(0);
}


Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        public static char[] kaiten(char[] str)
        {
            var tmp = new char[str.Length];
            for (int i = 0; i < str.Length-1; i++)
            {
                tmp[i] = str[i + 1];
            }
            tmp[str.Length - 1] = str[0];
            return tmp;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var f = false;
            for (int i = 0; i <s.Length; i++)
            {
                var tt=t.ToCharArray();
                tt=kaiten(tt);
                t = new string(tt);
                if (s == t)
                    f = true;
              
            }
            if (f)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
     
            


            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <stack>
#include <cmath>
using namespace std;
long long n ,a[200005], l[200005],r[200005], pos[200005], ans = 0;
stack <int> st , stt;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n; ++i){
		cin >> a[i];
		pos[a[i]] = i;
    }
    for(int i = 1; i <= n; i++){
        while(!st.empty() && a[st.top()] >= a[i]){
            st.pop();
        }
        if (st.empty()){
            l[i] = 0;
        }
        else{
            l[i] = st.top();
        }
        st.push(i);
    }
    for(int i = n; i >= 1; i--){
        while(!stt.empty() && a[stt.top()] >= a[i]){
            stt.pop();
        }
        if (stt.empty()){
            r[i] = n + 1;
        }
        else{
            r[i] = stt.top();
        }
        stt.push(i);
    }
    for(int i = 1; i <= n; i++){
		ans += (r[i] - i) * (i - l[i]) * a[i];
    }
    cout << ans;
    return 0;
}


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

/*3のつく数字ならtrue*/

bool has3(int x) {
	while (x) {
		if (x % 10 == 3)return true;
		x /= 10;
	}
	return false;
}

void call(int n) {
	for (int x = 1; x <= n; x++) {
		if (x % 3 == 0 || has3(x)) {
			cout << " " << x;
		}
	}
	cout << endl;
}

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

	return 0;
}


Measured memory_bytes: 3124
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
using namespace std;
 
#pragma region
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)
 
const double PI = acos(-1.0);
 
using ll = long long;
using P = pair<int, int>;
 
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; }
 
template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}
 
template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}
 
template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }
 
template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }
 
#pragma endregion
 
template<class T>
struct BIT {
    int n;
    vector<T> dat;
 
    //[1, n]
    BIT(int n): n(n), dat(n + 1) {}
 
    void init(int _n) {
        n = _n;
        dat.assign(_n);
    }
 
    //[1, i]
    T sum(int i) const {
        T s = 0;
        while (i > 0) {
            s += dat[i];
            i -= i & -i;
        }
        return s;
    }
 
    //[l, r]
    T sum(int l, int r) const {
        return sum(r) - sum(l - 1);
    }
 
    //1-indexed
    void add(int i, T x) {
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};
 
struct Query {
    int l, r, idx;
    bool operator <(const Query &q) { return r < q.r; }
};
 
int main() {
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    //cin >> c;
    rep(i, n) scanf("%d", &c[i]);
 
    vector<Query> querys(q);
    rep(i, q) {
        int l, r;
        //cin >> l >> r;
        scanf("%d %d", &l, &r);
        querys[i] = Query{l, r, i};
    }
 
    sort(querys.begin(), querys.end());
    
    BIT<int> bit(n);
    vector<int> last(n + 1, -1);
    vector<int> ans(q);
 
    int p = 0;
    rep(i, q) {
        auto [l, r, idx] = querys[i];
        while (p < n && p < r) {
            bit.add(p + 1, 1);
            if (last[c[p]] != -1) bit.add(last[c[p]] + 1, -1);
            last[c[p]] = p;
            p++;
        }
 
        ans[idx] = bit.sum(l, r);
    }
 
    //print(ans, "\n");
    rep(i, q) printf("%d\n", ans[i]);
}

Measured memory_bytes: 17400
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int a[n];
    int p = 1;
    int flag = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {flag = 2; break;}
        if ((int)((double)1e18 / p) < a[i]) flag = 1;
        p = p * a[i];
    }
    if (flag == 1) cout << -1 << endl;
    else if (flag == 2) cout << 0 << endl;
    else if (p <= (int)1e18) cout << p << endl;
    else cout << -1 << endl;

    return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

int get_int(){int x;scanf("%d",&x);return x;}
LL get_long(){LL x;scanf("%lld",&x);return x;}

const int maxn = 100005;
const int maxp = 317;
int prime[maxn];
int sum[maxn];

void creat_prime(){
    _for(i,0,maxn) prime[i] = 1;
    prime[1] = prime[0] = 0;
    _rep(i,2,maxp) if(prime[i]){
        for(int j = i*i;j < maxn;j += i){
            prime[j] = 0;
        }
    }
    sum[0] = sum[1] = 0;
    for(int i = 3; i < maxn;i += 2){
        sum[i] = sum[i-2];
        if(prime[i] && prime[(i+1)/2]) sum[i]++;
    }
}

int main()
{
    creat_prime();
    int Q = get_int();
    //_for(i,0,10) printf("%d ",prime[i]);
    _for(i,0,Q){
        int l = get_int();
        int r = get_int();
        if(l == 1) l = 3;
        printf("%d\n",sum[r]-sum[l-2]);
    }
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <limits.h>

#define LENGTH 50005

typedef struct queue {
    char name[100];
    int value;
} Queue;

Queue q[LENGTH];
int front;
int tail;

Queue pop()
{
    Queue tmp = q[front];
    front = (front + 1) % LENGTH;
    return tmp;
}

void push(Queue x)
{
    q[tail] = x;
    tail = (tail + 1) % LENGTH;
}

int main()
{
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    int num, period;
    scanf("%d %d", &num, &period);
    Queue tmp;
    for (int i = 0; i < num; ++i) {
        scanf("%s %d", tmp.name, &tmp.value);
        push(tmp);
    }

    int cnt = 0;
    int time = 0;
    while (cnt < num) {
        Queue tmp = pop();
        if (tmp.value <= period) {
            time += tmp.value;
            cnt++;
            printf("%s %d\n", tmp.name, time);
        } else {
            time += period;
            tmp.value -= period;
            push(tmp);
        }

    }

    return 0;
}



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

int BIT[1000010]={0},bit_size;

void bit_init(int n){
    fill(BIT,BIT+n,0);
    bit_size=n;
}

int bit_sum(int n){
    int ans=0;
    while(n>0){
        ans += BIT[n];
        n&=n-1;
    }
    return ans;
}

void bit_add(int n, int v){
    while(n<=bit_size){
        BIT[n]+=v;
        n+=n&(-n);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    bit_init(n);
    int which,id,num,s,t;
    for(int i=0;i<q;++i){
        cin>>which;
        switch(which){
            case 0:
                cin>>id>>num;
                bit_add(id,num);
                break;
            case 1:
                cin>>s>>t;
                //err<<bit_sum(t)<<" "<<bit_sum(s-1)<<"\n";
                int ans1=bit_sum(t);
                int ans2=bit_sum(s-1);
                //cout<<ans1<<" "<<ans2<<"\n";
                int ans=ans1-ans2;
                cout<<ans<<"\n";
                break;

        }
    }
    /*for(int i=1;i<=n;++i){
            cerr<<BIT[i]<<"\n";
    }*/
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';
#define rep(i, begin, end) \
	for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int area1 = a * b;
	int area2 = c * d;
	if (area1 > area2)
		cout << area1;
	else
		cout << area2;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define Maxn 200007
using namespace std;
int n;
long long c,dis[Maxn],sum1[Maxn],sum2[Maxn];
long long mx1[Maxn],mx2[Maxn];
int a[Maxn];
long long ans=0;
int main()
{
	scanf("%d",&n);
	scanf("%lld",&c);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&dis[i]);
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
		sum1[i]=sum1[i-1]+a[i];
	for (int i=n;i;i--)
		sum2[i]=sum2[i+1]+a[i];
	for (int i=1;i<=n;i++)
		mx1[i]=max(mx1[i-1],sum1[i]-dis[i]);
	for (int i=n;i;i--)
		mx2[i]=max(mx2[i+1],sum2[i]-c+dis[i]);
	for (int i=1;i<=n;i++)
	{
		ans=max(ans,sum1[i]-dis[i]);
		ans=max(ans,sum2[i]-c+dis[i]);
	}
	for (int i=1;i<=n;i++)
		ans=max(ans,sum1[i]-dis[i]-dis[i]+mx2[i+1]);
	for (int i=n;i;i--)
		ans=max(ans,sum2[i]-c+dis[i]-c+dis[i]+mx1[i-1]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7552