akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
#define F first
#define S second
#define pll pair<ll, ll>
typedef long long int LL;
typedef long long int ll;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
    //input
    LL N,M,a,b;cin >> N >> M;
    vector<pll> G(M);             // 無向グラフ
    rep(i,M){
        cin >> a >> b;
        a--,b--;
        G[i].F = a;
        G[i].S = b;
    }

    //calc
    UnionFind uf(N);
    ll res = 0;
    rep(i,M){
        uf.init(N);     //初期化
        rep(j,M){               // これでuf形成。
            if(i == j)continue;     // この条件分岐で 特定の辺 の形成をスキップしている。
            uf.merge(G[j].F,G[j].S);    
        }
        if(uf.size(0) < N)res++;    // どこでもいいから集合のサイズをチェックして、一か所でも区切れているときカウント
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = II()
    S = list(input())

    R = []
    G = []
    B = []
    for idx, s in enumerate(S):
        if s == 'R':
            R.append(idx)
        elif s == 'G':
            G.append(idx)
        else:
            B.append(idx)
    ans = len(R) * len(G) * len(B)

    for i in range(n):
        for j in range(i+1, n):
            k = 2 * j - i
            if k >= n:
                continue
            # print(i, j ,k)
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9304
import math

def divisor(num):
    if num < 0:
        return 0
    if num == 1:
        return [1, ]

    divisor_list = [1, ]
    divisor_list_r = [num, ]

    i = 2
    while i * i <= num:
        if num % i == 0:
            divisor_list.append(i)
            # divisor_list_r.append(num//i)
        i += 1
    return divisor_list
    #return divisor_list+divisor_list_r[::-1]


N = int(input())
div_list = divisor(N)
ans = div_list[-1] + N // div_list[-1] - 2
print(ans)


Measured memory_bytes: 39152
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL
#define N 500000

struct node{
  struct node *parent;
  struct node *right;
  struct node *left;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node find(Node,int);
Node getMinimum(Node);
Node getSuccessor(Node);
void deleteNode(Node);

int main(void){
  int n,x;
  int i;
  char com[20];
  Node t;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf(" %s",com);
    if(com[0] == 'i'){
      scanf(" %d",&x);
      insert(x);
    }
    else if(com[0] == 'f'){
      scanf(" %d",&x);
      t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'd'){
      scanf(" %d",&x);
      deleteNode(find(root,x));
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node find(Node u, int k){
  while(u != NIL && u->key != k){
    if(k < u->key){
      u = u->left;
    }
    else{
      u = u->right;
    }
  }
  return u;
}

Node getMinimum(Node u){
  while(u->left != NIL) u = u->left;
  return u;
}

Node getSuccessor(Node u){
  Node y;
  
  if(u->right != NIL) return getMinimum(u->right);

  y = u->parent;
  while(y != NIL && u == y->right){
    u = y;
    y = y->parent;
  }
  return y;
}

void deleteNode(Node u){
  Node x,y;
  
  if(u->left == NIL || u->right == NIL){
    y = u;
  }
  else{
    y = getSuccessor(u);
  }

  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }
  else if(y == y->parent->left){
    y->parent->left = x;
  }
  else{
    y->parent->right = x;
  }

  if(y != u){
    u->key = y->key;
  }
}



Measured memory_bytes: 20500
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    if (B - A <= 1 || A >= K) {
        cout << K + 1 << endl;
        return 0;
    }

    ll ans = 0;
    ans = A + (B - A) * ((K - A + 1) / 2);
    if ((K - A + 1) % 2 != 0)
        ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll p[20], c[20];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int d,g;cin>>d>>g;
  REP(i,d){
    cin>>p[i]>>c[i];
  }
  ll ans=LINF;
  for(int bit=0;bit < (1<<d);++bit){
    ll sum=0;
    ll solves=0;
    for(int i=0;i<d;++i){
      if(bit & (1<<i)){
        sum+=100*(i+1)*p[i]+c[i];
        solves+=p[i];
      }
    }
    if(sum>=g){
      ans=min(ans, solves);
    }else{
      ll last=g-sum;
      for(int i=d-1;i>=0;i--){
        if(bit & (1<<i))continue;
        for(int j=1;j<=p[i];j++){
          last-=100*(i+1);
          solves++;
          if(last<=0){
            ans=min(ans, solves);
            goto E;
          }
        }
      }
    }
    E:;
  }
  P(ans);

  return 0;
}


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

using namespace std;

#define ll long long int
#define inf 1e16

const int N=300005;

vector<int>g[N];

void dfs(int src,int par,int cnt,int a[]) {
     a[src]=cnt;
     for(int i=0;i<g[src].size();i++) {
        int nxt=g[src][i];
        if(nxt!=par) dfs(nxt,src,cnt+1,a);
     }
}

int main() {
   int n;
   cin>>n;
   for(int i=1;i<n;i++) {
      int u,v;
      cin>>u>>v;
      g[u].push_back(v);
      g[v].push_back(u);
   }
   int a1[n+1];
   int a2[n+1];
   dfs(1,0,0,a1);
   dfs(n,0,0,a2);
   int mask=0;
   for(int i=1;i<=n;i++) {
       if(a1[i]<=a2[i]) mask++;
       else mask--;
   }
   if(mask>0) cout<<"Fennec\n";
   else cout<<"Snuke\n";

   return 0;
}


Measured memory_bytes: 18944
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll GCD(ll a, ll b){
	if(b==0) return a;
	else return GCD(b,a%b);
}

ll LCM(ll a, ll b){
	return a/GCD(a,b)*b;
}

int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n) cin >> a[i];
	ll lc = a[0];
	rep(i,n) lc = LCM(lc,a[i]);
	rep(i,n){
		if((lc/a[i])%2==0){
			cout << 0 << endl;
			return 0;
		}
	}
	lc/=2;
	ll ans = m / lc;
	cout << (ans+1)/2 << endl;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.length();i++){
    string k = s.substr(i,1);
    if( (k == "L") && (i % 2 == 0) ){
      cout << "No" << endl;
      return 0;
    }
    if( (k == "R") && (i % 2 == 1) ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

class State{
public:
  int x, y, cost;

  State(int _x, int _y, int _cost){
    x = _x;
    y = _y;
    cost = _cost;
  }
};

int h, w, n;
int cx[12], cy[12];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool closed[1002][1002];
char t[1002][1002];

int bfs(int sx, int sy, int gx, int gy){
  queue<State> open;
  open.push(State(sx, sy, 0));
  memset(closed, 0, sizeof(closed));

  while(!open.empty()){
    State st = open.front();
    open.pop();

    if(closed[st.y][st.x]) continue;
    closed[st.y][st.x] = true;

    if(st.x == gx && st.y == gy){
      return st.cost;
    }

    for(int i = 0; i < 4; i++){
      int nx = st.x + dx[i];
      int ny = st.y + dy[i];

      if(0 <= nx && nx < w && 0 <= ny && ny < h && t[ny][nx] == '.'){
        open.push(State(nx, ny, st.cost + 1));
      }
    }
  }

  return 99999999;
}

int main(){
  while(cin >> h >> w >> n){
    for(int i = 0; i < h; i++){
      cin >> t[i];

      for(int j = 0; j < w; j++){
        if(t[i][j] == 'S'){
          cx[0] = j;
          cy[0] = i;
          t[i][j] = '.';
        }
        else if('0' <= t[i][j] && t[i][j] <= '9'){
          int idx = t[i][j] - '0';
          cx[idx] = j;
          cy[idx] = i;
          t[i][j] = '.';
        }
      }
    }

    int ans = 0;

    for(int i = 1; i <= n; i++){
      ans += bfs(cx[i - 1], cy[i - 1], cx[i], cy[i]);
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 2844
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    ll hoge[n];
    ll a[q];
    rep(i,0,q-1){
        cin>>a[i]; 
    }
    rep(i,0,n-1) hoge[i] = k - q;
    rep(i,0,q-1){
        hoge[a[i]-1]++;
    }
    rep(i,0,n-1){
        if(hoge[i]>=1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            log = [0 for _ in xrange(24 * 60 * 60 + 1)]
            for i in range(n):
                dept, arr = raw_input().split()
                dept = dept.split(':')
                arr = arr.split(':')
                dept = 60 * 60 * int(dept[0]) + 60 * int(dept[1]) + int(dept[2])
                arr = 60 * 60 * int(arr[0]) + 60 * int(arr[1]) + int(arr[2])
                log[dept+1] += 1
                log[arr+1] -= 1
            # print log[:100]
            # print log[1801]
            for i in range(len(log)-1):
                log[i+1] += log[i]
            # print log[:100]
            # print log[1801]
            print max(log)
            
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

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

int main()
{
    int T ;
    cin >> T ;
    vector <int> B1[5] ;
    vector <int> B2[5] ;
    vector <int> B3[5] ;
    vector <int> B4[5] ;
    for(int i = 0 ; i < 3 ; i++)
    {
        for(int j = 0 ; j < 10 ; j++)
        {
            B1[i].push_back(0) ;
            B2[i].push_back(0) ;
            B3[i].push_back(0) ;
            B4[i].push_back(0) ;
        }
    }
    while(T--)
    {
        int b , f , r , v ;
        cin >> b >> f >> r >> v ;
        if(b == 1)
        {
            B1[f - 1][r - 1] += v ;
        }
        else if(b == 2)
        {
            B2[f - 1][r - 1] += v ;
        }
        else if(b == 3)
        {
            B3[f - 1][r - 1] += v ;
        }
        else if(b == 4)
        {
            B4[f - 1][r - 1] += v ;
        }
    }
    for(int i = 0 ; i < 3 ; i++)
    {
        for(int j = 0 ; j < 10 ; j++) cout << " " << B1[i][j] ;
        cout << endl ;
    }
    for(int i = 0 ; i < 20 ; i++) cout << '#' ;
    cout << endl ;
    for(int i = 0 ; i < 3 ; i++)
    {
        for(int j = 0 ; j < 10 ; j++) cout << " " << B2[i][j] ;
        cout << endl ;
    }
    for(int i = 0 ; i < 20 ; i++) cout << '#' ;
    cout << endl ;
    for(int i = 0 ; i < 3 ; i++)
    {
        for(int j = 0 ; j < 10 ; j++) cout << " " << B3[i][j] ;
        cout << endl ;
    }
    for(int i = 0 ; i < 20 ; i++) cout << '#' ;
    cout << endl ;
    for(int i = 0 ; i < 3 ; i++)
    {
        for(int j = 0 ; j < 10 ; j++) cout << " " << B4[i][j] ;
        cout << endl ;
    }
    return 0 ;
}


Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 100008
int n, q;

class BIT {
  int n;
  ll data[N];

public:
  BIT(int n) : n(n) {
    for(int i = 0; i < n+2; ++i) data[i] = 0;
  }
  void add(int k, ll x) {
    while(k <= n) {
      data[k] += x;
      k += k & -k;
    }
  }

  ll get(int k) {
    ll s = 0;
    while(k) {
      s += data[k];
      k -= k & -k;
    }
    return s;
  }
};

int main() {
  cin >> n >> q;
  BIT bit(n);
  rep(_, q) {
    int c, s, t, x, i;
    cin >> c;
    if(c) {
      cin >> i;
      cout << bit.get(i) << endl;
    } else {
      cin >> s >> t >> x;
      bit.add(s, x);
      bit.add(t+1, -x);
    }
  }
  return 0;
}



Measured memory_bytes: 3896
S = input()

N = len(S)
RLLR = []
ans = [0] * N
for i in range(N-1):
    if S[i] == "R" and S[i + 1] == "L":
        RLLR.append(i)
    if S[i] == "L" and S[i+1] == "R":
        RLLR.append(i)
Lchild = 0
Rchild = 0
for i in range(len(RLLR) // 2):
    Lchild = RLLR[2*i+1] - RLLR[2*i]
    ans[RLLR[2*i]] += Lchild // 2
    ans[RLLR[2*i] + 1] += (Lchild - 1) // 2 + 1

    Rchild = RLLR[2*i+2] - RLLR[2*i+1]
    ans[RLLR[2*i+2]] += (Rchild - 1) // 2 +1
    ans[RLLR[2*i+2]+1] += Rchild // 2

Rchild = RLLR[0] + 1
ans[RLLR[0]] += (Rchild - 1) // 2 + 1
ans[RLLR[0]+1] += Rchild // 2

Lchild = (N - 1) - RLLR[-1]
ans[RLLR[-1]] += Lchild // 2
ans[RLLR[-1]+1] += (Lchild - 1) // 2 + 1

print(*ans)

Measured memory_bytes: 48476
// https://atcoder.jp/contests/abc126/tasks/abc126_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x])
                swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
};

// X, Yのグループが何個あるか調べればいい
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    UnionFind tree(n);
    set<int> st;
    int k = n;

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        k -= tree.unionSet(--x, --y);
    }
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 200003;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7

int main(){_
	lli n,k,d; cin>>n>>k>>d;
	n = abs(n);
	lli l = 0, r = INF, last = r;
	auto f=[&](lli x){
		lli h=abs(n-x)/d;
		h = min(h,k);
		if((k-h)&1){
			lli a = 0,b=0;
			a = abs(n- (h+1)*d)<=abs(x);
			if(h)b = abs(n- (h-1)*d)<=abs(x);
			return a or b;
		}
		return abs(n- h*d)<=abs(x);
	};
	while(l<=r){
		lli mid = (l+r)/2;
		if(f(mid) or f(-mid))r=mid-1,last=mid;
		else l = mid+1;
	}
	cout<<last<<ENDL;


}


Measured memory_bytes: 3604
N = int(input())
A = list(map(int, input().split()))
k = 1+N%2 # 余分なxを入れる個数
INF = 10**18
# dp: i番目まで見たときに、j個の余分なxを入れた時の、和の最大値
dp = [[-INF for _ in range(4)] for _ in range(202020)]
dp[0][0] = 0
for i in range(N):
    for j in range(k+1):
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]) # xを一つ挿入する=>今見てる数字をスキップする
        now = dp[i][j]
        if (i+j)%2==0:
            now += A[i]
        dp[i+1][j] = max(dp[i+1][j], now)
print(dp[N][k])

Measured memory_bytes: 78884
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let S: String = sc.read();
    let w: usize = sc.read();
    for i in (0..S.len()).step_by(w) {
        print!("{}", S.chars().nth(i).unwrap());
    }
    println!("");
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int N,M;
int a,b,c,d,e;
int main(){
    cin >> N >> M;
    vector<P> X, Y;
    rep(i,N) cin >> a >> b, X.pb(mp(a,b));
    rep(i,M) cin >> c >> d, Y.pb(mp(c,d));
    rep(i,N){
        int m = 1e9;
        int k = -1;
        rep(j,M){
            e = abs(X[i].first-Y[j].first) + abs(X[i].second-Y[j].second);
            if(e < m) k = j, m = e;
        }
        cout << k + 1 << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_Q=1010,MAX_M=1010,MAX_N=37;

int N,M,Q;
string S[MAX_Q],B[MAX_Q];
string base,ans;
int check[MAX_M][MAX_N];

void solve(){
    for (int i=0;i<M;++i)
        for (int j=0;j<N;++j)
            check[i][j]=1;
    string now="";
    for (int i=0;i<N;++i) now+='0';
    for (int i=0;i<Q;++i){
        for (int j=0;j<N;++j)
            if (S[i][j]=='1')
                now[j]=(now[j]=='0'?'1':'0');
        for (int j=0;j<M;++j)
            for (int k=0;k<N;++k)
                if (B[i][j]!=now[k])
                    check[j][k]=0;
    }
    ans="";
    for (int i=0;i<M;++i){
        int button=-1;
        for (int j=0;j<N;++j) if (check[i][j]){
            if (button==-1) button=j;
            else button=-2;
        }
        ans+=(0<=button?base[button]:'?');
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i=0;i<10;++i) base+='0'+i;
    for (int i=0;i<26;++i) base+='A'+i;
    while(cin >> N >> M >> Q,N){
        for (int i=0;i<Q;++i) cin >> S[i] >> B[i];
        solve();
    }
}


Measured memory_bytes: 4544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }
const long long INF = 1LL << 60;

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> xy(15,vector<int>(15, -1));

    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
        REP(j,A[i]){
            int x, y;
            cin >> x>>y;
            x--;
            xy[i][x] = y;
        }
    }

    // 正直者を仮定する
    int max_cnt = 0;
    REP(bit, 1<<N){
        //cout << bitset<3>(bit)<<endl;
        bool flg = true;
        // 一人ずつ言っていることに矛盾がないか確認する
        int cnt=0;
        REP(i, N){
            if(!(bit&1<<i)) continue;   // 正直者ではない人はスルー
            // 証言を確認
            REP(j, N){
                //printf("%d:%2d ", bit&(1<<j), xy[i][j]);
                if(xy[i][j]==-1) continue;  // 証言していない場合
                if((bit&(1<<j))&&xy[i][j]==0){
                    flg=false;
                    break;
                }
                if(!(bit&(1<<j))&&xy[i][j]==1) {
                    flg=false;
                    break;
                }
            }
        }
        if(flg){
            //cout<<bitset<3>(bit)<<endl;
            int cnt=0;
            REP(c, N){
                if(bit&1<<c) cnt++;
            }
            if(max_cnt< cnt) max_cnt=cnt;
        }
    }


    cout << max_cnt << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        ab = a%b
        a = b
        b = ab
    return a


def main():
    K = int(input())

    ans = 0
    for a in range(1,K+1):
        for b in range(a,K+1):
            ab = gcd(b,a)
            for c in range(b,K+1):
                n = 6
                if a==b or b==c: n = 3
                if a==b and b ==c : n=1
                ans += gcd(c,ab)*n

    print(ans)


    return

if __name__ == "__main__":
    main()



Measured memory_bytes: 9144
#include <iostream>
#include <bitset>

using namespace std;

int main() {
    long n;
    long s = 0, even = 0;

    cin >> n;
    int a[n+1], x[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];    
        s += a[i];
        if (i % 2 == 0) even += 2 * a[i];
    }
    x[1] = s - even;
    //cout << "s:" << s << " even:" << even << endl;

    for (int i = 2; i <= n; i++) {
        x[i] = 2 * a[i-1] - x[i-1];
    }

    for (int i = 1; i <= n; i++) {
        cout << x[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2048
#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(){
    int a,b,h,m;
    static const double pi = 3.141592653589793;

    cin>>a>>b>>h>>m;
    double theta;
    double A,B;
    double w1,w2;
    w1=2*pi/12/60;
    w2=2*pi/60;
    h%=12;
    A=w1*(h*60+m);
    B=w2*m;
    theta=A-B;
    double ans=a*a+b*b-2*b*a*cos(theta);
    cout << fixed << setprecision(20) <<sqrt(ans) << endl;
    return 0;
}

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

int main() {
	int n;
	while ( cin >> n ) {
		int bi[ n+5 ];
		stack<int> stk;
		
		for (int i = 1; i <= n; ++i) cin >> bi[i];
		
		while ( n ) {
			for (int i = n; i >= 1; --i) {
				if ( bi[i] == i ) {
					stk.push(i);
					n-- ;
					for (int j = i; j <= n; ++j) {
						bi[j] = bi[ j+1 ];
					}
					break;
				}
				
				if ( i == 1 ) {
					stk.push(-1);
					n = 0;
				}
			}
		}
		
		while ( !stk.empty() ) {
			cout << stk.top() << '\n';
			if ( stk.top() == -1 ) break;
			stk.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s == "Sunny"){
    	cout<<"Cloudy"<<endl;
    } else if(s == "Cloudy"){
    	cout<<"Rainy"<<endl;
    } else {
    	cout<<"Sunny"<<endl;
    }
    return 0;
}






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

int main(){
  int n,t;
  cin >> n >> t;
  int x=10000;
  for(int i=0; i<n; i++){
    int c, T;
    cin >> c >> T;
    if(t>=T){
      if(x>c){
        x = c;
      }
    }
  }
  if(x == 10000){
    cout << "TLE" << endl;
  }else{
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n; cin>>n;
    vector<long> l(n);
    for(int i=0;i<n;i++)
        cin>>l[i];
    auto max_it=max_element(begin(l),end(l));
    long max=*max_it;
    l.erase(max_it);
    long sum=accumulate(begin(l),end(l),0);
    if(max<sum)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

void counting_sort(int A[], int B[], int k,int n)
{
	int C[10001];

	int i;

	for (i = 0; i <= k; i++)
		C[i] = 0;

	for (i = 0; i < n; i++)
		C[A[i]]++;

	for (i = 0; i < k; i++)
		C[i + 1] += C[i];

	for (i = n - 1; i >= 0; i--)
		B[--C[A[i]]] = A[i];
}

int main()
{
	int n;
	int A[2000000];
	int B[2000000];

	scanf("%d", &n);

	int i;

	for (i = 0; i < n; i++)
		scanf("%d", &A[i]);

	counting_sort(A, B, 10000,n);

	for (i = 0; i < n-1; i++)
		printf("%d ", B[i]);
	printf("%d\n", B[n - 1]);

	return 0;
}


Measured memory_bytes: 17392
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;
int solve();

int main(void) {
	
	while(solve()){}

	return 0;
}

int solve() {

	int m, nmin, nmax;
		cin >> m >> nmin >> nmax;
	if( !(m|nmin|nmax) ) { return 0; }

	vector<int> p(m);
	for( int i = 0; i < m; i++)
		cin >> p[i];

	sort(p.begin(),p.end());

	int ans, gap = 0;
	for( int n = nmax; n >= nmin; n-- ) {
		int j = m - n;
		if( gap < p[j] - p[j-1] ) {
			gap = p[j]-p[j-1];
			ans = n;
		}
	}
	
	cout << ans << endl;

	return 1;

}

Measured memory_bytes: 3048
a, b, h, m = gets.split.map(&:to_f)

a_kakudo = 30.0 * h + 30.0 * (m/60.0)
b_kakudo = 6.0*m

kakudo = (a_kakudo - b_kakudo).abs
kakudo = [kakudo, 360-kakudo].min

puts (a**2+b**2 - 2*a*b*Math.cos(kakudo/180.0 * Math::PI))**0.5

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

int n;
long long ta = 1, tb;

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%lld", &tb);
		ta = ta / gcd(ta, tb) * tb;
	}
	printf("%lld\n", ta);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5005;
char s[maxn];
int K, n;
int main()
{
    scanf("%s", s);
    cin >> K;
    int KK = K;
    n = strlen(s);
    vector<int> ss[28];
    set<string> st;
    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i < n; i++) {
            if (s[i] == c) {
                ss[c - 'a'].push_back(i);
            }
        }
    }
    for (int i = 0; i < 27; i++) {
        if (K <= 0) {
            set<string>::iterator birch = st.begin();
            while(KK-1){
                birch++;
                KK--;
            }
                cout << *birch << endl;
            break;
        }
        for (int j = 0; j < ss[i].size(); j++) {
            string fuck;
            for (int k = 0; k < 5; k++) {
                if (ss[i][j] + k < n) {
                    fuck.push_back(s[ss[i][j] + k]);
                    pair<set<string>::iterator, bool> pr;
                    pr = st.insert(fuck);
                    if (pr.second)
                        K--; 
                } else
                    break;
            }
        }
    }
}

Measured memory_bytes: 384
S = input()

def check(t):
  if len(t) >= 5 and (t[-5:] == 'dream' or t[-5:] == 'erase'):
    return True,t[:-5]
  elif len(t) >=6 and t[-6:] == 'eraser':
    return True,t[:-6]
  elif len(t) >= 7 and t[-7:] == 'dreamer':
    return True,t[:-7]
  else:
    return False,t

while(len(S) > 0):
  flag,S = check(S)
  if not flag:
    print('NO')
    exit()
print('YES')


Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll a[n], b[n], c[n];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) cin >> c[i];

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    ll ans = 0;

    for(ll i=0; i<n; i++){
        ll u = upper_bound(a, a+n, b[i]-1) - a;
        ll l = lower_bound(c, c+n, b[i]+1) - c;

        ans += u * (n-l);
    }
    cout << ans << endl;

}

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

struct point {
	double x;
	double y;
};

double theta(point p0, point p1){
	double dx = p1.x - p0.x, ax = max(dx, -dx);
	double dy = p1.y - p0.y, ay = max(dy, -dy);
	double t = (ax + ay == 0) ? 0 : dy / (ax + ay);
	if(dx < 0) t = 2 - t;
	else if(dy < 0) t = 4 + t;
	return t * 90.0;
}

void swap(point ps[], int i, int j){
	double tx = ps[i].x, ty = ps[i].y;
	ps[i].x = ps[j].x; ps[i].y = ps[j].y;
	ps[j].x = tx; ps[j].y = ty;
}


int wrap(point ps[], int n){
	int i, min, M;
	double th, v;
	for(min = 0, i = 1; i < n; i++)
		if(ps[i].y < ps[min].y) min = i;
	ps[n] = ps[min]; th = 0.0;
	for(M = 0; M < n; M++){
		swap(ps, M, min);
		min = n; v = th; th = 360.0;
		for(i = M+1; i <= n; i++)
			if(theta(ps[M], ps[i]) > v)
				if(theta(ps[M], ps[i]) < th)
				{
					min = i; th = theta(ps[M], ps[min]); 
				}
		if ( min == n) return M + 1;
	}
}

int main(){
	int n;
	char c;
	point ps[101];
	while(cin >> n){
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> ps[i].x >> c >> ps[i].y;
		}
		cout << n - wrap(ps, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		long k = sc.nextLong();
		sc.close();

		if (k % 2 == 0) {
			System.out.println(a - b);
		} else {
			System.out.println(b - a);
		}
	}
}


Measured memory_bytes: 22356
n = int(input())
b = list(map(int, input().split()))

ans = []

while b:
    f = True
    for i in range(len(b)-1, -1, -1):
        if b[i] == i+1:
            b.remove(i+1)
            ans.append(i+1)
            f = False
            break
    if f: # 実行できない
        ans = '-1'
        break
if ans == '-1':
    print(ans)
else:
    for a in ans[::-1]:
        print(a)
           

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[4];
    cin>>s;
    sort(s,s+4);
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <atcoder/all>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>

#define BIT(nr) (1UL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;
using namespace atcoder;

int op(int a, int b) {
	return max(a, b);
}
int e() {
	return -LL_HALFMAX;
}

signed main() {
	int N, Q;
	cin >> N >> Q;
	
	vector<int> A(N + 1);
	REPS(i, N) {
		cin >> A[i];
	}


	segtree<int, op, e> seg(A);
	vector<int> T(Q), f(Q), s(Q);

	rep(i, Q) {
		cin >> T[i] >> f[i] >> s[i];
	}

	rep(i, Q) {
		if (T[i] == 1) {
			int X = f[i], V = s[i];
			seg.set(X, V);

		}
		else if(T[i] == 2){
			int L = f[i], R = s[i] + 1;
			int ans = seg.prod(L, R);
			cout << ans << "\n";
		}
		else {
			int X = f[i], V = s[i];
			int ans = seg.max_right(X, [&](int S) {
				if (S <= V - 1) {
					return true;
				}
				return false;
			});

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

	return 0;
}

Measured memory_bytes: 13500
n=int(input())
dots=[]
for i in range(n):
    x,y=map(int,input().split())
    dots.append((x,y))
dots=sorted(sorted(dots, key=lambda x:x[1]))
#print(dots)
from itertools import combinations

combs=combinations(dots,r=2)
tmp=0
for c in combs:
    c=sorted(c)
    dx=c[1][0]-c[0][0]
    dy=c[1][1]-c[0][1]
    cnt=0
    for i in range(n):
        subdot=(dots[i][0]+dx,dots[i][1]+dy)
        if subdot in dots:
            cnt+=1
    tmp=max(tmp,cnt)
print(n-tmp)

Measured memory_bytes: 41452
#include<bits/stdc++.h>
using namespace std;
int main()
{int m,n;
cin>>m>>n;
for(int i=0;i<=m;i++)
for(int j=0;j<=m;j++)
for(int k=0;k<=m,i+j+k<=m;k++)
{if(i+j+k==m&&i*1000+j*5000+k*10000==n)
{cout<<k<<" "<<j<<" "<<i;
return 0;}}
cout<<"-1 -1 -1";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N=2e5+3;
string s,p;
int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>s;
    if(s=="Sunny")
    {
        cout<<"Cloudy\n";
    }
    else if(s=="Cloudy")
    {
        cout<<"Rainy\n";
    }
    else
    {
        cout<<"Sunny\n";
    }
    return 0;
}

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

int main()
{
	int n, ans = 0;
	cin >> n; n <<= 1;
	vector<int> l(n); for (auto& e : l) cin >> e;

	sort(l.begin(), l.end());
	for (int i = 0; i < n; i += 2) ans += l[i];

	cout << ans << endl;
}


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

inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    string s;
    cin >> s;
    cout << "2018/01/" << s[8] << s[9] << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
	int m, n;
	int x;
	int i;
	int cnt;
	
	while (1){
		scanf("%d %d", &m, &n);
		if (m == 0){
			break;
		}
		
		cnt = 0;
		
		for (i = m; i <= n; i++){
			x = i;
			
			while (x % 2 == 0){
				x /= 2;
			}
			
			while (x % 3 == 0){
				x /= 3;
			}
			
			while (x % 5 == 0){
				x /= 5;
			}
			
			if (x == 1){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 600
// テンプレ
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  string s; cin >> s;
  int sum_div = 0;
  for(int i = 0; i < s.size(); ++i) {
    sum_div += s[i] - '0';
    sum_div %= 9;
  }
  if(sum_div) {
    cout << "No";
  } else {
    cout << "Yes";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3692
from heapq import *
# from itertools import permutations
# from math import pi
# from operator import itemgetter
# from operator import mul
# from operator import xor
# from os import linesep


# def isprime(n: int) -> bool:
#     if n <= 1:
#         return False
#     if n in (2, 3, 5):
#         return True
#     if n % 2 == 0:
#         return False
#     if n % 3 == 0:
#         return False
#     lst = int(n**0.5)
#     f = 5
#     while f <= lst:
#         if n % f == 0:
#             return False
#         if n % (f + 2) == 0:
#             return False
#         f += 6
#     return True


# def strmat(matrix, lnsep: str = linesep, fieldsep: str = ' ') -> str:
#     return lnsep.join(map(lambda row: fieldsep.join(map(str, row)), matrix))


# def strbool(boolval: int) -> str:
#     return ['No', 'Yes'][boolval]


def solve() -> None:
    # read here
    n, m, *t = map(int, open(0).read().split())

    # solve here
    d = [[] for i in range(m+1)]
    for i in range(n):
        a, b = t[2*i], t[2*i+1]
        if a > m:
            continue
        d[a].append(b)

    ans = 0
    tasks = []
    for t in range(m + 1):
        # from (m days after) to today
        for tasksize in d[t]:
            heappush(tasks, -tasksize)
        if tasks:
            # do task
            ans -= heappop(tasks)

    # print here
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 24932
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

long long int h[1500] = {}, L[1500], R[1500];

int main(){
	
	int H, N;
	cin >> H >> N;
	
	long long int ans = 0;
	
	for(int loop = 0; loop < H; loop++){
		for(int j = 0; j < N; j++){
			int num;
			cin >> num;
			if(num){
				h[j] = 0;
			}else{
				h[j]++;
			}
		}
		
		stack<int> sta;
		
		for(int i = 0; i < N; i++){
			while(sta.size() > 0 && h[sta.top()] >= h[i]){
				sta.pop();
			}
			if(sta.empty()){
				L[i] = 0;
			}else{
				L[i] = sta.top() + 1;
			}
			sta.push(i);
		}
		
		while(!sta.empty()){
			sta.pop();
		}
		
		for(int i = N - 1; i >= 0; i--){
			while(sta.size() > 0 && h[sta.top()] >= h[i]){
				sta.pop();
			}
			if(sta.empty()){
				R[i] = N;
			}else{
				R[i] = sta.top();
			}
			sta.push(i);
		}
		
		while(!sta.empty()){
			sta.pop();
		}
		
		for(int i = 0; i < N; i++){
			ans = max(ans, h[i] * (R[i] - L[i]));
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
string l = "qwertasdfgzxcvb";
int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "#")
      break;
    int ans = -1;
    int now = -1;
    for (int i = 0; i < s.size(); i++) {
      bool ok = false;
      for (auto c : l)
        if (s[i] == c) {
          ok = true;
        }
      if (ok) {
        if (now != 1)
          ans++;
        now = 1;
      } else {
        if (now != 0) {
          ans++;
        }
        now = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	static String[] defDice;

	public static void main(String[] args) throws IOException{


		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		//????????????????????????????????????
		defDice = insBR.readLine().split(" ");
		//????§????????????????????????\???str[]???????´?
		String[] direction = insBR.readLine().split("");

		/*
		 * Dice??????????????????????????????????????°?????????
		 * Dice???????????????????§????direction?????°????????°?????????
		 * Dice???????????????????????????????????¨?????????[0]???get??????*/


		//for?????§direction?????°?????????????????????????????????
		for(int i = 0; i < direction.length; i++){

			roll(direction[i]);
		}
		//??????????????????[0]?????¨?????????
		System.out.println( defDice[0]);
	}


	//???????????????????§?????????????????????????????????????????????´??????
	public static void roll(String direction){

		if("S".equals(direction)){

			String temp = defDice[0];
			defDice[0] = defDice[4];
			defDice[4] = defDice[5];
			defDice[5] = defDice[1];
			defDice[1] = temp;
		}else if("E".equals(direction)){

			String temp = defDice[0];
			defDice[0] = defDice[3];
			defDice[3] = defDice[5];
			defDice[5] = defDice[2];
			defDice[2] = temp;
		}else if("W".equals(direction)){

			String temp = defDice[0];
			defDice[0] = defDice[2];
			defDice[2] = defDice[5];
			defDice[5] = defDice[3];
			defDice[3] = temp;
		}else if("N".equals(direction)){

			String temp = defDice[0];
			defDice[0] = defDice[1];
			defDice[1] = defDice[5];
			defDice[5] = defDice[4];
			defDice[4] = temp;
		}

	}

}

Measured memory_bytes: 17060