akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
#define ll long long

int get_num();

string s;
vector<map<int,int> > a;
vector<int> b;
vector<int> c;
int t;


void pr(vector<int> k){
  cout <<  "x ";
  for(int i=0;i<k.size();i++){
    cout << k[i] << " ";
  }
  cout << endl;
}

int main(){
  vector<int> z;
  map<int,int> m;
  cin >> s;
  while(s!="."){
    int ans=0;
    int an=0;
    a.assign(52,m);
    c.assign(52,0);
    while(s!="."&&ans==0){
      b.assign(0,0);
      an++;
      int f=0;
      int e=0;
      t=0;
      for(int i=0;i<(int)s.size();i++){
        if(s[i]=='['){
          b.push_back(-64);
        }
        else if(s[i]==']'){
          b.push_back(-65);
          f=0;
        }
        else if(s[i]=='='){
          b.push_back(-66);
          e++;
        }
        else if('a'<=s[i]&&s[i]<='z'){
          b.push_back(-1-(s[i]-'a'));
        }
        else if('A'<=s[i]&&s[i]<='Z'){
          b.push_back(-1-(s[i]-'A'+26));
        }
        else if('0'<=s[i]&&s[i]<='9'){
          if(f==0){
            b.push_back(s[i]-'0');
            f++;
          }
          else{
            b[b.size()-1]*=10;
            b[b.size()-1]+=s[i]-'0';
          }
        }
      }
      if(e==0){
        int ra,rb;
        ra=-b[t]-1;
        t++;
        t++;
        rb=get_num();
        t++;
        if(rb>=0){
          //a[ra].assign(rb,-1);
          c[ra]=rb;
        }
        else{
          ans=an;
        }
      }
      else{
        int ra,rb,rc;
        ra=-b[t]-1;
        t++;
        t++;
        rb=get_num();
        t++;
        t++;
        rc=get_num();
        t++;
        if(rb<(int)c[ra]&&rc>=0){
          a[ra][rb]=rc+1;
        }
        else{
          ans=an;
        }
      }
      cin >> s;
    }
    cout << ans << endl;
    while(s!="."){
      cin >> s;
    }
    cin >> s;
  }
}

int get_num(){
  if(b[t]>=0){
    t++;
    return b[t-1];
  }
  else{
    int ra,rb;
    ra=-b[t]-1;
    t++;
    t++;
    rb=get_num();
    t++;
    if(rb<c[ra]){
      return a[ra][rb]-1;
    }
    else{
      return -1;
    }
  }
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//

int main(){
        string s;
        cin>>s;
        while(s.length()>1) {
                string t=s.substr(0,1);
                for(int j=1; j<s.length(); j++) {
                        if(t==s.substr(j,1)) {
                                s=s.substr(1,j-1)+s.substr(j+1,s.length()-j-1);
                                break;
                        }
                        if(j==s.length()-1) {
                                cout<<"No"<<endl;
                                return 0;
                        }
                }

        }
        if(s.length()==0) {
                cout<<"Yes"<<endl;
                return 0;
        }else{
                cout<<"No"<<endl;
                return 0;
        }

}


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

using namespace std;

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

    int n, x;
    cin >> n;
    int a[n + 1];
    memset(a, 0, sizeof(a));
    for (int i = 1; i * i < n; i++) {
        for (int j = 1; j * j < n; j++) {
            for (int k = 1; k * k < n; k++) {
                x = i * i + j * j + k * k + i * j + j * k + k * i;
                if (x <= n) a[x]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) cout << a[i] << "\n";
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  string S;
  cin >> S;
  vector<bool> a(26,false);
  for(int i=0;i<S.size();i++){
    int x = S.at(i)-'a';
    if(a.at(x)==true){
      cout << "no" << endl;
      return 0;
    }
    a.at(x) = true;
  }

  cout << "yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

V = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(int,input().split())
    a = a-1
    b = b-1
    V[a].append(b)
    V[b].append(a)

from collections import deque

q = deque([0])

ans = [-1]*N
ans[0] = 0

while q:
    v = q.popleft()
    for nv in V[v]:
        if ans[nv] == -1:
            ans[nv] = v + 1
            q.append(nv)

print("Yes")
print(*ans[1:],sep="\n")


Measured memory_bytes: 38452
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    var A = Array.fill(N)(sc.nextInt).sorted.distinct

    while (A.length > 1) {
      val a = A.head
      A = (a +: A.tail.map(_ % a).filter(_ > 0)).sorted.distinct
//      println(A.mkString(","))
    }

    A.head.toString
  }
}


Measured memory_bytes: 67472
import math
N = int(input())
# A, B = [i for i in input().split()]


def prime_factorization(n):
    # n = p1**e1 * p2**e2... pm**emのように素因数分解を行う。リストが空の場合は素数ということ
    fact_list = []
    for p in range(2, int(math.sqrt(n)) + 1):
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        if e > 0:
            fact_list.append((p, e))
    if n != 1:
        fact_list.append((n, 1))
    return fact_list


prime_list = prime_factorization(N)
if len(prime_list) == 0:
    print(0)
else:
    count = 0
    for p, e in prime_list:
        a = 1
        sum_a = 0
        while True:
            sum_a += a
            if e < sum_a:
                break
            a += 1
        count += a - 1
    print(count)





Measured memory_bytes: 63208
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    ll k,num=0;
    cin>>k;
    for(ll i=1;i<=(ll)1e7;i++) {
        num=(num*10+7)%k;
        if(num==0) {
            cout<<i;
            return;
        }
    }
    cout<<"-1";
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3692
N, K, Q = map(int, input().split())
win_border = Q - K
get_point = [0] * N
for _ in range(Q):
    a = int(input())
    get_point[a - 1] += 1
for point in get_point:
    if point > win_border:
        print("Yes")
    else:
        print("No")


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n,K;
	cin >> n >> K;
	vi x(n),y(n);
	rep(i,n) cin >> x[i] >> y[i];
	unsigned long long ans = (1LL<<63);
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(K == 2){
				ans = min(ans,(unsigned long long)abs(x[i]-x[j])*abs(y[i]-y[j]));
			}else{		
				for(int k = j+1; k < n; k++){
					if(K == 3){
						int maxX = max({x[i],x[j],x[k]}),
							maxY = max({y[i],y[j],y[k]}),
							minX = min({x[i],x[j],x[k]}),
							minY = min({y[i],y[j],y[k]});
						ans = min(ans,(unsigned long long)abs(maxX-minX)*abs(maxY-minY));
					}else{
						for(int l = k+1; l < n; l++){
							int maxX = max({x[i],x[j],x[k],x[l]}),
								maxY = max({y[i],y[j],y[k],y[l]}),
								minX = min({x[i],x[j],x[k],x[l]}),
								minY = min({y[i],y[j],y[k],y[l]});
							int cnt = 0;
							for(int m = 0; m < n; m++){
								if(maxX < x[m] || x[m] < minX) continue;
								if(maxY < y[m] || y[m] < minY) continue;
								cnt++;
							}
							if(cnt < K) continue;
							ans = min(ans,(unsigned long long)abs(maxX-minX)*abs(maxY-minY));
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    reverse(all(S));
    n = S.length();
    vl amari[2019];
    b = 1;
    amari[a].push_back(0);
    rep(i, n) {
        a = (a + b * (S[i] - '0')) % 2019;
        b = b * 10 % 2019;
        amari[a].push_back(0);
        // cout << a << endl;
    }

    rep(i, 2019) { ans += (amari[i].size()) * (amari[i].size() - 1) / 2; }

    cout << ans << endl;
}

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

using namespace std;

bool solve(vector<int> &a, vector<int> &b) {
  int n = a.size();

  vector<int> oa(n);
  iota(oa.begin(), oa.end(), 0);
  sort(oa.begin(), oa.end(), [&](int i, int j) { return a[i] < a[j]; });

  vector<int> ob(n);
  iota(ob.begin(), ob.end(), 0);
  sort(ob.begin(), ob.end(), [&](int i, int j) { return b[i] < b[j]; });
  
  for (int i = 0; i < n; i++) {
    if (a[oa[i]] > b[ob[i]]) {
      return false;
    }
  }

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[oa[i]] = ob[i];
  }

  { // cycle
    int cnt = 0, now = 0;
    vector<bool> was(n);
    while (!was[now]) {
      cnt++;
      was[now] = true;
      now = p[now];
    }
    if (cnt < n) return true;
  }

  for (int i = 0; i < n - 1; i++) {
    if (a[oa[i + 1]] <= b[ob[i]]) {
      return true;
    }
  }

  return false;
}

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

  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  
  cout << (solve(a, b) ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 5312
#include <stdio.h>

int main() {
	int a;
	int b[20];
	int answer = 0;

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

	int max = 0;
	for (int i = 0; i < a; i++) {
		if (b[i] >= max) {
			answer++;
			max = b[i];
		}
	}
	printf("%d", answer);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
	int n, t, a;
	vector<int> h;
	int input;
	double res;
	int i;
	int index = 0;
	double min;

	scanf("%d %d %d",&n,&t,&a);

	scanf("%d", &input);

	min = abs((double)t - (double)input*0.006 - (double)a);
	
	for (i = 1; i < n; i++)
	{
		scanf("%d", &input);

		if (abs((double)t - (double)input*0.006 - (double)a) < min)
		{
			min = abs((double)t - (double)input*0.006 - (double)a);

			index = i;
		}
	}

	printf("%d\n", index + 1);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#define INF 9999999
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int prime[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 3; i <= N; i += 2) {
		int tmp = 1;
		for (int k = 0; k < 25; k++) {
			int tmp2 = 0;
			int i2 = i;
			while (1) {
				if (i2 % prime[k] == 0) {
					tmp2++;
					i2 /= prime[k];
				}
				else {
					break;
				}
			}
			tmp *= (tmp2 + 1);
		}
		if (tmp == 8)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)

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


class node_t {
public:
  node_t(int xx, int yy, int dd) : x(xx), y(yy), d(dd) {};

public:
  bool operator<(const node_t& n) const {
    if (d < n.d)
      return true;

    if (x < n.x)
      return true;

    return y < n.y;
  };

  bool operator>(const node_t& n) const {
    return ! (*this < n);
  };
      
public:
  int x;
  int y;
  int d;
};
  

int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W, Ch, Cw, Dh, Dw;

  std::cin >> H >> W >> Ch >> Cw >> Dh >> Dw;

  Ch --;
  Cw --;
  Dh --;
  Dw --;

  std::vector<std::string> S(H);

  for (auto& s : S)
    std::cin >> s;

  std::stack<node_t> stack;

  stack.emplace(Cw, Ch, 0);
  
  int dist[1111][1111];

  memset(dist, 0x3f3f, sizeof(dist));

  dist[Ch][Cw] = 0;

  std::set<node_t> set;
  
  for (int d = 0; d < 1111111; d ++) {
    for (const auto& n : set) {
      for (int i = -2; i <= 2; i ++)
        for (int j = -2; j <= 2; j ++) {
          int xx = n.x + j, yy = n.y + i, dd = n.d + 1;
          
          if (xx < 0 || xx >= W || yy < 0 || yy >= H)
            continue;
          
          if (S[yy][xx] == '#')
            continue;
          
          if (dd < dist[yy][xx]) {
            dist[yy][xx] = dd;

            stack.emplace(xx, yy, dd);
          }
        }
    }

    set.clear();

    while (! stack.empty()) {
      node_t n = stack.top(); stack.pop();

      set.insert(n);

      for (int k = 0; k < 4; k ++) {
        int xx = n.x + dx[k], yy = n.y + dy[k], dd = n.d;
      
        if (xx < 0 || xx >= W || yy < 0 || yy >= H)
          continue;
      
        if (S[yy][xx] == '#')
          continue;

        if (dd < dist[yy][xx]) {
          dist[yy][xx] = dd;

          stack.emplace(xx, yy, dd);
        }
      }
    }
  }

  std::cout << (dist[Dh][Dw] < 1111111 ? dist[Dh][Dw] : -1) << std::endl;
  
  return 0;
}


Measured memory_bytes: 10180
#include <iostream>
#include <vector>
#include <functional>
#include <utility>
#include <limits>
#include <numeric>

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f)
{
  if (rest == 0)
  {
    f(indexes);
  }
  else
  {
    if (s < 0)
      return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f)
{
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

struct book
{
  int C;
  std::vector<int> A;
};

int main()
{
  int n, m, x;
  std::vector<book> b;
  std::cin >> n >> m >> x;
  for (int i = 0; i < n; i++)
  {
    book tmp;
    std::cin >> tmp.C;
    int tmp2;
    for (int j = 0; j < m; j++)
    {
      std::cin >> tmp2;
      tmp.A.emplace_back(std::move(tmp2));
    }
    b.emplace_back(std::move(tmp));
  }

  std::vector<book> buy;
  std::pair<int, std::vector<int>> minimum = {std::numeric_limits<int>::max(), {}};
  bool found = false;
  for (int num = 1; num <= n; num++)
  {
    found = false;
    std::pair<int, std::vector<int>> current_minimum = {std::numeric_limits<int>::max(), {}};
    foreach_comb(n, num, [&](int *indices) {
      std::pair<int, std::vector<int>> current = {0, {}};
      current.second.resize(m, 0);
      for (int i = 0; i < num; i++)
      {
        current.first += b[indices[i]].C;
        for (int j = 0; j < m; j++)
        {
          current.second[j] += b[indices[i]].A[j];
        }
      }
      if (current.first < current_minimum.first &&
          std::all_of(current.second.cbegin(), current.second.cend(), [&](const int sum) {
            return sum >= x;
          }))
      {
        current_minimum = std::move(current);
      }
    });
    if (minimum.first > current_minimum.first)
    {
      minimum = std::move(current_minimum);
      found = true;
    }
    // if (!found && minimum.first != std::numeric_limits<int>::max())
    // {
    //   break;
    // }
  }

  if (minimum.first == std::numeric_limits<int>::max())
  {
    std::cout << -1 << std::endl;
  }
  else
  {
    std::cout << minimum.first << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main() {

  	// 入力
	string S, ans = "Good";
	int i;

  	cin >> S;

	REP(i, S.length()-1){
		if(S[i] == S[i+1]){
			ans = "Bad";
		} 
	}

  	cout << ans << endl;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M, K;
vector<int>par;
void init() {
	par.clear();
	for (int i = 0; i < N + M; ++i) {
		par.push_back(i);
	}
}
int getpar(int x) {
	if (x == par[x])return x;
	return par[x] = getpar(par[x]);
}
bool unite(int a, int b) {
	a = getpar(a);
	b = getpar(b);
	if (a == b)return true;
	if (a >= N && b >= N)return false;
	if (a >= N) {
		par[b] = a;
	}
	else {
		par[a] = b;
	}
	return true;
}
bool unite2(int c, int x) {
	c = getpar(c);
	x = getpar(x);
	if (c == x)return true;
	if (c >= N)return false;
	par[c] = x;
	return true;
}

int main(void)
{
	cin >> N >> M >> K;
	init();
	for (int i = 0; i < K; ++i) {
		int t, v1, v2;
		cin >> t >> v1 >> v2;
		--v1; --v2;
		if (t == 1) {
			if (!unite(v1, v2)) {
				cout << i + 1 << endl;
				return 0;
			}
		}
		else {
			if (!unite2(v1, v2 + N)) {
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}




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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)





void solve() {

	int x, y;
	cin >> x >> y;
	cout << ceil(x / double(y)) << "\n";




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

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

int main() {
  int n, m, s, t;  cin >> n >> m >> s >> t;
  vector<vector<P>> direc_y(n + 1), direc_s(n+1);
  rep(i, m) {
    int u, v; ll a, b;
    cin >> u >> v >> a >> b;
    direc_y[u].push_back(make_pair(v, a));
    direc_y[v].push_back(make_pair(u, a));
    direc_s[u].push_back(make_pair(v, b));
    direc_s[v].push_back(make_pair(u, b));
  }
  
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(make_pair(0, s));
  ll fare_y[n+1];
  rep(i, n+1) {
    fare_y[i] = -1;
  }
  
  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    ll fi = p.first, se = p.second;
    if (fare_y[se] != -1) continue;
    
    fare_y[se] = fi; 
//    cout << se << " " << fi << endl;
    for(auto nv: direc_y[se]) {
//      cout << nv.first << endl;
      pq.push(make_pair(nv.second + fi, nv.first));
    }
  }
  
  pq.push(make_pair(0, t));
  ll fare_s[n+1]; memset(fare_s, -1, sizeof(fare_s));
  
  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    ll fi = p.first, se = p.second;
    if (fare_s[se] != -1) continue;
    
    fare_s[se] = fi; 
    for(auto nv: direc_s[se]) {
      pq.push(make_pair(nv.second + fi, nv.first));
    }
  }
  
  ll sum[n+1];
  rep(i, n) {
    sum[i+1] = fare_y[i+1] + fare_s[i+1];
  }
  
  ll kari = sum[n];
  rep(i, n) {
    if (sum[n-i] < kari) {
      kari = sum[n-i];
    }
    else {
      sum[n-i] = kari;
    }
  }
  
  rep(i, n) {
    cout << 1000000000000000 - sum[i+1] << endl;
  }
}

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

int main(){
    int h,w;
    cin>>h>>w;
    
    vector<string> vs(h);
    
    rep(i,h)cin>>vs[i];
    
    
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(i==0)continue;
            if( (j==0 && vs[i][j+1]=='o') || (j==w-1 && vs[i][j-1]=='o') || ( vs[i][j+1]=='o' || vs[i][j-1]=='o' ) )continue;
            if(vs[i][j]!='-')continue;
            int dy[] = {-1,-1,-1,0,1,1,1,0};
            int dx[] = {-1,0,1,1,1,0,-1,-1};
            bool f = false;
            rep(k,8){
                int ddy = dy[k]+i;
                int ddx = dx[k]+j;
                if( ddx>=0 && ddy>=0 && ddx<w && ddy<h && vs[ddy][ddx]=='x' )f=true;
            }
            if(f)continue;
            ans++;

        }
    }
    cout<<ans<<endl;
}

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

int main() {
  string s;  cin >> s;
  rep(x,1<<4-1) {
    int sum = s[0]-'0';
    rep(i,3) {
      if(x&1<<i) sum += s[i+1]-'0';
      else sum -= s[i+1]-'0';
    }
    if(sum==7){
      string ans;
      cout << s[0];
      rep(i,3){
        if(x&1<<i) cout << '+';
        else cout << '-';
        cout << s[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

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

int main(){
        int x1, x2;
        cin >> x1;
        cin >> x2;
        cout << x1 * x2 << " " << 2 * (x1 + x2) << endl;
//      cout << x1 << "," << x2 << endl;
        return 0;
}



Measured memory_bytes: 3072
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

constexpr intmax_t mod = 1e9+7;

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

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

  size_t D;
  scanf("%zu", &D);

  size_t N = K.length();
  auto dp = make_vector(N+1, 2, D, intmax_t(0));

  dp[0][1][0] = 1;
  for (size_t i = 0; i < N; ++i) {
    for (size_t j = 0; j <= 1; ++j) {
      for (size_t k = 0; k < D; ++k) {
        for (size_t d = 0; d <= 9; ++d) {
          char cd = d + '0';
          if (j && K[i] < cd) break;
          size_t nj = (j && K[i] == cd);
          size_t nk = (k + d) % D;
          (dp[i+1][nj][nk] += dp[i][j][k]) %= mod;
        }
      }
    }
  }

  intmax_t res = (dp[N][0][0] + dp[N][1][0] + mod-1) % mod;
  printf("%jd\n", res);
}


Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define all(v) v.begin(),v.end()
#define PB push_back
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define MOD 1000000007
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
ll dp[102][100002];
ll knapsack(ll  W,ll w[],ll v[],ll n){
  if(W==0||n==0){
    return 0;
  }
  if(dp[n][W]!=-1){
    return dp[n][W];
  }
  if(w[n-1]>W)
  return dp[n][W]=knapsack( W,w,v,n-1);

  else{
    return dp[n][W]=max(knapsack( W,w,v,n-1),v[n-1]+knapsack( W-w[n-1],w,v,n-1));
  }
}

int solve(){
  ll N,W;
  cin>>N>>W;
  memset(dp,-1,sizeof(dp));
  // deb2(N,W)
  ll w[N],v[N];
  for(int i=0;i<N;i++){
    cin>>w[i]>>v[i];
  }
  cout<<knapsack(W,w,v,N)<<"\n";
  return 0;
}
int main(){
fast
  int t=1;
  // cin>>t; 
  T(t){
    solve();
  }
  return 0;
}

Measured memory_bytes: 83284
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h , w;
    string s[50] = {};
    cin >> h >> w;
    for( int i = 0 ; i < h ; i++ ) cin >> s[i];
    for( int i = 0 ; i < h ; i++ ) {
    	for ( int j = 0 ; j < w ; j++ ) {
    		if ( s[i][j] == '#' ) {
        		bool y = 0;
        		if ( i && s[i - 1][j] == '#' ) y = 1;
        		if ( i + 1 < h && s[i + 1][j] == '#' ) y = 1;
        		if ( j && s[i][j - 1] == '#' ) y = 1;
        		if ( j + 1 < w && s[i][j + 1] == '#' ) y = 1;
        		if ( !y ) {
					cout << "No";
					return 0;
				}
			}
		}
    }
    cout << "Yes";
}


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

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

Measured memory_bytes: 1156
A, B, C, D, E, F = map(int, input().split())
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = k * C + l * D
                concentration = 100 * b / (a + b)
                if (A * i + B * j) * E >= b and a + b <= F:
                    if concentration > c:
                        c = concentration
                        ans = [a + b, b]
                else:
                    break

print(' '.join(map(str, ans)))

Measured memory_bytes: 3064
from heapq import heappop,heappush
from collections import defaultdict
N,Q = map(int,input().split())
event = []
for _ in range(N):
    s,t,x = map(int,input().split())
    event.append((s-x,1,x))
    event.append((t-x,2,x))

for i in range(Q):
    d = int(input())
    event.append((d,3,i))
event.sort()

memo = defaultdict(int)
nowStop = []
ans = [-1]*Q
for t,e,x in event:
    if e == 1:
        heappush(nowStop,x)
        memo[x] += 1
    if e == 2:
        memo[x] -= 1
    if e == 3:
        while nowStop:
            s = nowStop[0]
            if memo[s] == 0:
                heappop(nowStop)
            else:
                ans[x] = s
                break
for a in ans:
    print(a)

Measured memory_bytes: 197076
from decimal import Decimal
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

A, B, C, D = map(int, input().split())
count = 0
BCcount = B // C
BDcount = B // D
ACcount = (A - 1) // C
ADcount = (A - 1) // D
l = C * D // gcd(C, D)
BCDcount = B // l
ACDcount = (A - 1) // l
Bcount = Decimal(B - (BCcount + BDcount - BCDcount))
Acount = Decimal((A - 1) - (ACcount + ADcount - ACDcount))
print(Decimal(Bcount - Acount))

Measured memory_bytes: 5064
//Built by Sabuj Jana(greenindia) from Jadavpur University,Kolkata,India 
// God is Great------------/////\\\\\\\--------------------------------
 #include <bits/stdc++.h>
 using namespace std;
 #define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 #define endl "\n"
 #define INF LLONG_MAX
 #define pb push_back
 #define mp make_pair
 typedef vector<int> vi;
 typedef long long ll;
 
 	 
 int main() {
 	 
    crap;
                  
     int A,B;
     cin>>A>>B;
     
     if(B%A==0)
		cout<<A+B;
	else
		cout<<B-A;
     
      
    return 0;
 }



Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n; cin >> n;
  ll s=0;
  loop(i,1,n+1) {
    if (i%3==0 or i%5==0) continue;
    s += i;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
N, K = map(int, input().split())

ans = 0
for b in reversed(range(1, N+1)):
    s = N//b
    tmp = ( max([0,b-K]))* s
    tmp2 = max([0,N - b * s - max([0,(K-1)]) ]) 
    ans += tmp + tmp2

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    vector<int> b(N+1);
    for(int i = 0; i < N+1; i++) cin >> a[i];
    for(int i = 1; i <= N; i++) cin >> b[i];
    int pre = a[0];
    ll count = 0;
    for(int i = 1; i <= N; i++){
        if(pre + a[i] <= b[i]) {
            count += pre + a[i];
            pre = 0;
        }
        else{
            count += min(pre,b[i]);
            if(pre < b[i]){
                count += b[i] - pre;
                pre = a[i] - (b[i] - pre);
            }
            else pre = a[i];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

VI v(301010);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    v[0] = 0;
    for (i = 1; i < 301010; i++) {
        int cnt = 0;
        for (j = 0; j < 25; j++) {
            cnt += ((i >> j) & 1);
        }
        v[i] = 1 + v[i % cnt];
        // cout << v[i] << endl;
    }
    int n;
    string x;
    cin >> n >> x;
    int p = 0;
    for (i = 0; i < n; i++) {
        if (x[i] == '1') p++;
    }
    int p1 = p + 1;
    int p2 = p - 1;
    int k1 = 1;
    int k2 = 1;
    int u1 = 0;
    int u2 = 0;
    VI r1(n);
    VI r2(n);
    for (i = n - 1; i >= 0; i--) {
        if (x[i] == '1') {
            u1 += k1;
            u1 %= p1;
            u2 += k2;
            if (p2 != 0) u2 %= p2;
        }
        r1[i] = k1;
        r2[i] = k2;
        k1 *= 2;
        k1 %= p1;
        k2 *= 2;
        if (p2 != 0) k2 %= p2;
    }
    for (i = 0; i < n; i++) {
        if (x[i] == '1') {
            if (p2 == 0) {
                cout << 0 << endl;
            } else {
                int b = (u2 + p2 - r2[i]) % p2;
                cout << 1 + v[b] << endl;
            }
        } else {
            int b = (u1 + r1[i]) % p1;
            cout << 1 + v[b] << endl;
        }
    }
}

Measured memory_bytes: 9128
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  std::cout << (A + B) % 24 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

const int N = 200, INF = 1e18;

int dp[N][N], money[N];

void solve() {
    int n; cin >> n;
    vector <int> a(n + 1);
    loop1(i, n)
        cin >> a[i];
    money[0] = 1000;
    loop1(i, n) {
        money[i] = money[i - 1];
        loop(j, N) {
            money[i] = max(money[i], dp[i - 1][j] * a[i] + j);
            dp[i][j] = max(dp[i - 1][j], (money[i - 1] - j) / a[i]);
        }
    }
    cout << money[n];
}

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

Measured memory_bytes: 3736
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  char c[1024];
  string s;
  c[0]=' ';
  for(;;){
    fgets(c+1,1023,stdin);
    if(strcmp(c+1,"END OF INPUT\n")==0)
      break;
    for(i=0;c[i]!='\n';i=j){
      for(j=i+1;c[j]!='\n'&&c[j]!=' ';j++);
      cout<<j-i-1;
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    multiset<int> s;
    for (int i = 0; i < (1 << n); i++) {
        int c; cin >> c; s.insert(c);
    }
    vector<int> v(1 << n);
    v[0] = *(--(s.end()));
    s.erase(s.find(v[0]));
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < (1 << k); i++) {
            if (*s.begin() >= v[i]) {
                cout << "No" << endl;
                return 0;
            }
            v[i+(1<<k)] = *(--(s.lower_bound(v[i])));
            s.erase(s.find(v[i+(1<<k)]));
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 13568
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????¨???
		//double n = Math.PI;
		//??????r?????????
		double r = sc.nextDouble();
		//????????¢??? ?????????????????????¨???
		double Area = r * r * Math.PI;
		//???????????¨ ??´????? ?????¨???
		double Pi = r * 2 * Math.PI;
		//
		String strArea = String.format("%6f", Area);

		//
		String strPi = String.format("%6f", Pi);

		//???????????¨???
		System.out.println(strArea + " "+ strPi);
	}
}

Measured memory_bytes: 28356
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define mod 1000000007
#define inf 1<<30
#define mp(a,b) make_pair(a,b)
#define len(u,N) u.begin(),u.begin()+N

ll N;
vector<ll> A(100010);
vector<ll> data;
map<ll,ll> S;
set<ll> s;

ll min(ll a, ll b){
    if (a < b) return a;
    else return b;
}

int main() {
    cin >> N;
    rep(i,N){
        cin >> A[i];
        S[A[i]]++;
        s.insert(A[i]);
    }
    for (auto i = s.begin(); i != s.end(); i++){
        ll num = S[*i]/2;
        rep(j,min(2,num)) data.push_back(*i);
    }
    sort(all(data));
    if (data.size() <= 1){
        cout << 0 << endl;
        return 0;
    }
    ll res = data[data.size()-1]*data[data.size()-2];
    cout << res << endl;
    
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int calc(int n){
    if(n == 1)return 1;
    return 1 + calc(n-1) * 2;
}

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

    int n;cin >> n;
    string s;cin >> s;
    vi w(n+1);
    vi e(n+1);
    for(int i=1;i<n+1;i++){
        w[i] = w[i-1];
        e[i] = e[i-1];
        if(s[i-1] == 'W')w[i]++;
        if(s[i-1] == 'E')e[i]++;
    }

    int ans = MINF;
    for(int i=0;i<n+1;i++){
        int tmp = MINF;
        int left = w[i];
        int right = e[n] - e[i];
        tmp = left + right;
        chmin(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2964
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, m, x = Is()
books = []
for _ in range(n):
  xs = Is()
  cost = xs[0]
  skills = xs[1:]
  books.append((cost, skills))

ans = []
stack = [(0, books, [0] * m)]

def doit(cost, books, skills):
  book = books[0]
  books = books[1:]
  
  ns = np.add(skills, book[1])
  if all([n >= x for n in ns]):
    ans.append(cost + book[0])
    
  if books:
    stack.append((cost+book[0], books, ns))
    stack.append((cost, books, skills))

while stack:
  state = stack.pop(0)
  doit(state[0], state[1], state[2])

print(min(ans) if ans else '-1')

Measured memory_bytes: 27488
import sys
import math
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

def solve(n):
    pass

def main():
    a,b = invr()
    print(a * b) 

main()



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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vector<int> schL(1, -1);  // 仕事を前に詰めたときの仕事日
    vector<int> schR(1, 3 * N);       // 仕事を後ろに 〃

    for (int i = 0; i < N; ++i) {
        if ((int)schL.size() == K + 1) break;
        if (S[i] == 'o') {
            schL.push_back(i);
            i += C;
        }
    }

    for (int i = N - 1; i >= 0; --i) {
        if ((int)schR.size() == K + 1) break;
        if (S[i] == 'o') {
            schR.push_back(i);
            i -= C;
        }
    }

    vector<int> flag(3 * N + 1, 0);  // flag[i] > 0 -> 働かなくても良い日

    for (int i = 0; i <= K; ++i) {
        int l = i, r = K - i;
        flag[schL[l] + 1]++;
        flag[schR[r]]--;
    }
    for (int i = 1; i <= 3 * N; ++i) { flag[i] += flag[i - 1]; }

    for (int i = 0; i < N; ++i) {
        if (S[i] == 'o' && flag[i] == 0) cout << i + 1 << endl;
    }

    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  if((a==1&&b==2)||(a==2&&b==1)) {
    cout << 3 << endl;
  }
  else if((a==2&&b==3)||(a==3&&b==2)) {
    cout << 1 << endl;
  }
  else {
    cout << 2 << endl;
  }
}

Measured memory_bytes: 256
<?php
    list($A,$B,$C,$X_sum,$Y_sum)  = array_map('intval',explode(" ",trim(fgets(STDIN))));
    // echo $A,$B,$C,$X,$Y;
    //Cピザを$2k枚買うとすると
    // $X = $X_sum - 2*$k;
    // $Y = $Y_sum - 2*$k;
    $kingaku = INF;
 
    //合計金額は
    for($k=0;$k<=max($X_sum,$Y_sum);$k++){
        if(($Xk = $X_sum - $k)<0){
            $Xk = 0;
        }
        if(($Yk = $Y_sum - $k)<0){
            $Yk = 0;
        }
        $new_kingaku = ($A * ($Xk)) + ($B * ($Yk)) + $C * (2*$k);
        // echo $new_kingaku."\n";
        if($new_kingaku <= $kingaku){
            $sk = $k; 
            $kingaku = $new_kingaku;
        }
    }
    
    echo $kingaku."\n";
?>

Measured memory_bytes: 16268
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,n; cin >> h >> w >> n;
    vector<vector<ll>> table(w);
    rep(i,0,n){
        ll x,y; cin >> x >> y;
        x--;y--;
        table[y].emplace_back(x);
    }
    rep(i,0,w){
        table[i].emplace_back(h);
        sort(all(table[i]));
    }
    ll pos = 0;
    ll ans = INF;
    rep(i,0,w){
        ll m = *upper_bound(all(table[i]), pos);
        chmin(ans, m);
        pos++;
        if(i == w-1)break;
        ll id = lower_bound(all(table[i + 1]), pos) - table[i + 1].begin();
        ll k = table[i+1].size();
        while(id < k && table[i+1][id] == pos){
            pos++;
            id++;
        }
        if(pos >= h)break;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 15236
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.IntSet as Set
import qualified Data.List as L

main :: IO ()
main = do
  [d] <- readInts
  cs <- readInts
  replicateM d readInts >>= output d . solve 0

solve :: Int -> [[Int]] -> [Int]
solve n dss
  | n < 365 = solve' n (dss !! n) : solve (n+1) dss
  | otherwise = []

solve' :: (Num a1, Ord a2, Ord a1, Enum a1) => p -> [a2] -> a1
solve' n dss = 1 + (snd $ maximum $ zip dss [0..] )

output :: Int -> [Int] -> IO ()
output d = mapM_ print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 5196
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
N, M=input().split()
N=int(N)
M=int(M)
#C=int(C)
#K=int(K)
i=0
ID_list=[]
ID_sublist=[]
gate_possible_list=[]
N_dummy=0
M_dummy=0
C_dummy=0
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(N)
#gate_list =  [list(map(int, input().split(" ")))for i in range(M)]
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！

#x=[]
#y=[]
#t, x, y = [0]*(N+1), [0]*(N+1), [0]*(N+1)#N+1個の空のリストを作成(原点を入れて##るから一つ増える)
#delta_t=0
#delta_x=0
#delta_y=0
#l=0
#t[0],x[0],y[0]=[0, 0, 0]
#とりあえず入力までは完成した．
#for i in range(N):
# t[i+1], x[i+1], y[i+1] = map(int, input().split())
#child_i =  list(map(int, input().split()))
#w_len=len(w)
#w_list=list(w)
#print(len(w_list))
#print(w_list)
#child_il=sorted(child_i)
#print(child_il)#リストの右端のほうが大きい
i=0
k=0
s=0
#for k in range (10000):
# s= s+ (1900*M**(k+1))/(2**(M*k)) +100*(N-M)
# if (1900*M**(k+1))/(2**(M*k))<1/10:
#     print(round(s))
#     sys.exit()
# print((1900*M**(k+1))/(2**(M*k)))
#print(s)
#これは数学で考えないと行けない問題だった
#for k in range(10000):
# s=s+((k+1)*(100*(N-M)+1900*M*0.5**(2*(k+1))))
# if (1900*M*0.5**(2*(k+1)))<0.1:
#      print(round(s))
#      sys.exit()

print((1900*M+100*(N-M))*2**M)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K,C; cin >> N >> K >> C;
    string S; cin >> S;
    int A[K],B[K];
    int pos=0;
    rep(i,K) {
        while(S[pos]=='x'){
            pos++;
        }
        A[i]=pos;
        pos+=C+1;
    }
    pos=N-1;
    per(i,K) {
        while(S[pos]=='x'){
            pos--;
        }
        B[i]=pos;
        pos-=C+1;
    }
    rep(i,K){
        if(A[i]==B[i]) cout << A[i]+1 << "\n";
    }
}

Measured memory_bytes: 5012