akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int MAX_N = 55556;
bool isPrime[MAX_N];

void primeCheck() {
    memset(isPrime, true, sizeof(isPrime));
    isPrime[0] = isPrime[1] = false;
    for(int i = 2; i*i < MAX_N; ++i) {
        if(isPrime[i]) {
            for(int j = i*i; j< MAX_N; j+=i) {
                isPrime[j] = false;
            }
        }
    }
}

int main(void) {
	//freopen("in.txt", "r", stdin);
	int n;
    cin >> n;
    primeCheck();
    int cnt = 0;
    vector<int> ret;
    rep(i,3,MAX_N) {
        if(isPrime[i] && i%10 == 3) {
            ret.pb(i);
        }
        if((int)ret.size() == n) {
            break;
        }
    }
    rep(i,0,sz(ret)) {
        cout << ret[i] << ' ';
    }
    cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
 
using namespace std;
 
const int INF = (1<<30) - 1;
 
string table[] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
     
    int T;
    cin >> T;
    string in;
    while(T--){
        cin >> in;
        int i = 0;
        int n = in.length();
         
        while(i<n){
            int s = i;
            while(i<n && in[i]!='0'){
                i++;
            }
            if(0<i && in[i-1]-'0'!=0){
                string st = table[in[i-1]-'0'];
                cout << st[(i-s-1)%st.length()];
            }
            i++;
        }
        cout << endl;
    }
     
    return 0;
}

Measured memory_bytes: 3132
def main():
    n, k = list(map(int, input().split()))
    x = list(map(int, input().split()))
    ans = float('inf')
 
    for i in range(n - k + 1):
        left = x[i]
        right = x[i + k - 1]
 
        if left * right >= 0:
            ans = min(ans, max(abs(left), abs(right)))
        else:
            ans = min(ans, 2 * abs(left) + abs(right), abs(left) + 2 * abs(right))
 
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 14384
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int NMAX=2000;

int main(){
    int N,Y,k;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
           k=N-i-j;
           if(10000*i+5000*j+1000*k==Y){
               cout<<i<<" "<<j<<" "<<k<<endl;
               return 0;
           } 
        }
    }
    k=-1;
    cout<<k<<" "<<k<<" "<<k<<endl;
    return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

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(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
using ll = int64_t; using ull = uint64_t; using ld = long double;

// -----------------------------------------------------------------------------

const int N = 50 + 5;
int a[N], b[N], c[N], d[N];

int main() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> c[i] >> d[i];
    }
    for (int i = 0; i < n; ++i) {
        int idx, best_dis = INT_MAX;
        for (int j = 0; j < m; ++j) {
            int dis = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (dis < best_dis) {
                best_dis = dis;
                idx = j;
            }
        }
        cout << idx + 1 << '\n';
    }
}

Measured memory_bytes: 256
import sys
import os
import math


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    TMP = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    N = int(sys.stdin.readline().rstrip())
    print(TMP[N-1])


if __name__ == '__main__':
    main()


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 2000;
bool grid[MAX][MAX];
int node[MAX][MAX];
int edgev[MAX][MAX];
int edgeh[MAX][MAX];

int getNode(int x1, int x2, int y1, int y2)
{
    int num = node[x2][y2];
    if (x1 > 0) {
        num -= node[x1 - 1][y2];
    }
    if (y1 > 0) {
        num -= node[x2][y1 - 1];
    }
    if (x1 > 0 and y1 > 0) {
        num += node[x1 - 1][y1 - 1];
    }
    return num;
}

int getEdge(int x1, int x2, int y1, int y2)
{
    int num = edgev[x2][y2] + edgeh[x2][y2];
    num -= edgev[x1][y2];
    num -= edgeh[x2][y1];
    if (y1 > 0) {
        num -= edgev[x2][y1 - 1];
        num += edgev[x1][y1 - 1];
    }
    if (x1 > 0) {
        num -= edgeh[x1 - 1][y2];
        num += edgeh[x1 - 1][y1];
    }
    return num;
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    rep(i, n)
    {
        rep(j, m)
        {
            char c;
            cin >> c;
            bool s = static_cast<bool>(c - '0');
            grid[i][j] = s;
            if (i == 0 and j == 0) {
                node[i][j] = s;
            } else if (i == 0) {
                node[i][j] = node[i][j - 1] + s;
                edgeh[i][j] = edgeh[i][j - 1] + (s and grid[i][j - 1]);
            } else if (j == 0) {
                node[i][j] = node[i - 1][j] + s;
                edgev[i][j] = edgev[i - 1][j] + (s and grid[i - 1][j]);
            } else {
                node[i][j] = node[i][j - 1] + node[i - 1][j] - node[i - 1][j - 1] + s;
                edgeh[i][j] = edgeh[i][j - 1] + edgeh[i - 1][j] - edgeh[i - 1][j - 1] + (s and grid[i][j - 1]);
                edgev[i][j] = edgev[i][j - 1] + edgev[i - 1][j] - edgev[i - 1][j - 1] + (s and grid[i - 1][j]);
            }
        }
    }

    rep(i, q)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1--, x2--, y1--, y2--;
        cout << getNode(x1, x2, y1, y2) - getEdge(x1, x2, y1, y2) << endl;
    }
    return 0;
}


Measured memory_bytes: 52608
/****************************************************************************************************
                                        SUBMITTED BY-

                                                AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353

int main()
{
  char ch;

  cin>>ch;

  if(ch>=97&&ch<=122)
  {
      cout<<"a\n";
      return 0;
  }
  else
  {
    cout<<"A\n";
    return 0;
  }

  return 0;

}



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

using namespace std;

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

	int n, m;
	cin >> n >> m;
	
	vector<int> a(n);
	int total = 0;
	for (auto &ai : a) {
		cin >> ai;
		total += ai;
	}
	
	const double f = ((1.0 / 4) * (1.0 / m) * total);
	int cnt = 0;
	for (auto ai : a) {
		if (ai >= f) {
			++cnt;
		}
	}
	
	cout << (cnt >= m ? "Yes" : "No") << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define MAX 1000

using namespace std;

int main() {
	int flg;
	cin >> flg;

	if (flg == 2) {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	else {
		cout << "Hello World\n";
	}
	return 0;
}

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

int main() {
  int A, B; cin >> A >> B;
  int x=0;
  if (A+B > A-B) x=A+B;
  else x=A-B;
  if (A*B > x) x=A*B;
  cout << x << endl;
}

Measured memory_bytes: 256
N=int(input())
now=(0,0,0)
flag=True
for i in range(N):
    t,x,y=map(int,input().split())
    move=abs(x-now[1])+abs(y-now[2])
    if t-now[0]>=move and (move-t+now[0])%2==0:
        continue
    else:
        flag=False
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int y,m,d;
		scanf("%d%d%d",&y,&m,&d);
		int cnt = 0;
		while(y < 1000){
			if(y%3==0){
				if(m == 11){
					y++;
					m = 1;
					d = 1;
					cnt--;
				}
				else if(d == 20){
					m++;
					d = 1;
				}
				else d++;
			}
			else{
				if(m == 11){
					y++;
					m = 1;
					d = 1;
					cnt--;
				}
				else if(d == 19 && m % 2 == 0){
					m++;
					d = 1;
				}
				else if(d == 20 && m % 2 == 1){
					m++;
					d = 1;
				}
				else d++;
			}
			cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1024
S = input()

def f(s):
    y, m, d = [int(i) for i in s.split("/")]
    if y == 2019:
        if m == 4:
            if d == 30:
                return True
            else:
                return d < 30
        else:
            return m < 4
    else:
        return y < 2019

print("Heisei" if f(S) else "TBD")


Measured memory_bytes: 2940
N = int(input())
a = list(map(int, input().split()))

if len(set(a)) == 1:
    if a[0] == 0:
        print("Yes")
    else:
        print("No")
elif len(set(a)) == 2:
    b = list(set(a))
    b.sort()
    if a.count(b[0]) == N//3 and N % 3 == 0:
        print("Yes")
    else:
        print("No")

elif len(set(a)) == 3:
    b = list(set(a))
    b.sort()
    if b[0] ^ b[2] == b[1] and a.count(b[0]) == N//3 and a.count(b[1]) == N//3 and N % 3 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 14832
#include<cstdio>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
int ci(double xa,double ya,double ra,double xb,double yb,double rb){
  double diff2 = (xb-xa)*(xb-xa)+(yb-ya)*(yb-ya);
  if(diff2 > (ra+rb)*(ra+rb)){return 0;}
  if(diff2 > ra*ra && diff2 > rb*rb){return 1;}
  if(ra>=rb){
    if((ra-rb)*(ra-rb)>diff2){return 2;}
    else{return 1;}
  }else{
    if((rb-ra)*(rb-ra)>diff2){return -2;}
    else{return 1;}
  }
}
int main(){
  int n;scanf("%d",&n);
  REP(i,n){
    double xa,ya,ra,xb,yb,rb;
    scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
    printf("%d\n",ci(xa,ya,ra,xb,yb,rb));
  }
}

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

// --------------------------------------------------------------------------------

void solve()
{
    string s;
    cin >> s;
    if (s.back() == 's')
        cout << s + "es" << endl;
    else
        cout << s + "s" << endl;
}

// --------------------------------------------------------------------------------

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<string>
#define N 1000
using namespace std;

int main() {
	char str1[N], str2[N], str3[N];
	cin >> str1;
	cin >> str2;
	strcpy(str3, str1);
	strcat(str1, str3);
	if (strstr(str1, str2) == NULL) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


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

using namespace std;
using lint = long long;

int main(void)
{
    int N;
    cin >> N;
    vector<lint> a(N);
    for(auto &x: a){
        cin >> x;
    }
    vector<lint> ha;
    lint min = 0;
    ha.push_back(a[0]);
    min = a[0];
    for(int i = 1; i < N; i++){
        if(min >= a[i]){
            min = a[i];
            ha.push_back(a[i]);
            continue;
        }

        for(int k = 0; k < ha.size(); k++){
            if(ha[k] < a[i]){
                if(k == ha.size()-1){
                    min = a[i];
                }
                ha[k] = a[i];
                break;
            }
        }
    }

    cout << ha.size() << endl;
    return 0;
}

Measured memory_bytes: 2168
import sys
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())

class UnionFind():
    def __init__(self, N):
        self.nodes = [i for i in range(N)]

    def root(self, x):
        if self.nodes[x] != x:
            self.nodes[x] = self.root(self.nodes[x])
        return self.nodes[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        if self.same(x, y):
            return
        self.nodes[self.root(x)] = self.root(y)

uf = UnionFind(N)

for _ in range(M):
    x, y, z = map(int, input().split())
    uf.unite(x-1, y-1)

group = set()
for node in uf.nodes:
    group.add(uf.root(node))

print(len(group))


Measured memory_bytes: 29872
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string s;
  std::cin >> s;
  const i64 N = s.size();

  std::unordered_map<char, i64> prev;
  for (const char& c : "abcdefghijklmnopqrstuvwxyz") {
    prev.insert(std::make_pair(c, -1));
  }
  std::unordered_map<char, i64> possible_answer_map;

  for (i64 i = 0; i < N; ++i) {
    if (possible_answer_map.find(s[i]) == possible_answer_map.end()) {
      possible_answer_map.insert(std::make_pair(s[i], i - prev[s[i]] - 1));
    } else {
      possible_answer_map[s[i]] = std::max(possible_answer_map[s[i]], i - prev[s[i]] - 1);
    }
    prev[s[i]] = i;
  }
  for (auto& pair : possible_answer_map) {
    pair.second = std::max(pair.second, N - prev[pair.first] - 1);
  }

  std::vector<i64> possible_answers;
  possible_answers.reserve(possible_answer_map.size());
  for (const auto& pair : possible_answer_map) {
    possible_answers.push_back(pair.second);
  }

  std::cout << *std::min_element(possible_answers.begin(), possible_answers.end()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> coins={500,100,50,10,5,1};
    int a;
    while(cin >> a,a){
        a=1000-a;
        int ans=0;
        rep(i,6) ans+=a/coins[i],a%=coins[i];
        cout << ans << endl;
    }
}


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

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

int h,w;  
vector<string> s;
vector<vector<int>> seen;
ll res;
ll res2;

void dfs(int y,int x){
  seen[y][x]=1;
  if(s[y][x]=='.') res++;
  else if(s[y][x]=='#') res2++;
  rep(i,4){
    int nx=x+dx[i]; int ny=y+dy[i];
    if(nx>=w||nx<0||ny>=h||ny<0) continue;
    if(s[y][x]==s[ny][nx]) continue;
    if(seen[ny][nx]!=0) continue;
    dfs(ny,nx);
  }
}

int main(){
  cin>>h>>w;
  s.resize(h);
  rep(i,h) cin>>s[i]; 
  
  ll ans=0;
  seen.assign(h,vector<int>(w));
  rep(i,h)rep(j,w){
    if(seen[i][j]==0){
      res=0;
      res2=0;
      dfs(i,j);
      ans+=res*res2;
    }
  }
  cout<<ans<<endl;
}


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

bool sortFn(pair<int, int> lhs, pair<int, int> rhs) {
  return lhs.first > rhs.second;
}

int getWinHand(int h) {
  if (h == 0) return 2;
  if (h == 1) return 0;
  if (h == 2) return 1;
}

void solver(){
  int n, k, r, s, p;
  vector<pair<int, int> > points(3);
  string ts;
  cin >> n >> k;

  // 0 r, 1 s, 2 p,
  for (int i = 0; i < 3; i++) {
    int a;
    cin >> a;
    points[i] = make_pair(a, i);
  }

  cin >> ts;

  sort(points.begin(), points.end(), sortFn);

  long long ans = 0;
  for (int i = 0; i < k; i++) {
    vector<int> t;
    for (int j = i; j < ts.size(); j=j+k) {
      char c = ts[j];
      if (c == 'r') t.push_back(0);
      if (c == 's') t.push_back(1);
      if (c == 'p') t.push_back(2);
    }

    for (int j = 0; j < points.size(); j++) {
      int point = points[j].first;
      int h = points[j].second;

      int prev = -1;
      for (int k = 0; k < t.size(); k++) {
        if (getWinHand(t[k]) == h) {
          if (prev < 0) {
            ans += point;
            prev = h;
          }else {
            if (prev == h) {
              prev = -1;
            };
          }
        } else {
          prev = -1;
        }
      }
    }
  }

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

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 1020
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
//这里是简单循环，特别的还是手写吧，或者有的循环用的全局变量也要手写
#define fup(i,a,b) for(int i=a; i<=b; ++i)
#define fwn(i,a,b) for(int i=b; i>=a; --i)

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

    int X = (N-M)*100+1900*M;
    
    printf("%d\n", (1<<M)*X);
    
    return 0;
}

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

int main() {
	int H, W;
	bool h[100] = { false }, w[100] = { false };
	cin >> H >> W;
	string S[100];
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') h[i] = true, w[j] = true;
		}
	}
	for (int i = 0; i < H; i++) {
		if (h[i]) {
			for (int j = 0; j < W; j++) {
				if (w[j]) {
					cout << S[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,L,minabs=320958,Taste=0,totalTaste=0,Answer=0;
  string S;
  cin>>N>>L;
  vector<int>Apple(N);
  for(int i=0;i<N;i++){
    Apple[i]=L+i;
    totalTaste+=Apple[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(j!=i)Taste+=Apple[j]; 
    }
    if(abs(totalTaste-Taste)<minabs){
      minabs=abs(totalTaste-Taste);
      Answer=Taste;
    }
    Taste=0;
  }
  cout<<Answer<<endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if Y == 10000 * x + 5000 * y + 1000 * z:
            print(x, y, z)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int r = 0;
	while (b <= a) {
		b *= 2, r++;
	}
	while (c <= b) {
		c *= 2, r++;
	}
	if (r <= x) cout << "Yes";
	else cout << "No";
}


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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 100000, MAX_C = 30;
int N,C;
tuple<int,int,int> stc[MAX_N];

int main()
{
  cin >> N >> C;
  int s,t,c;
  for (int i = 0; i < N; ++i) {
    cin >> s >> t >> c;
    stc[i] = make_tuple(s,t,c);
  }
  sort(stc,stc+N);

  set<pii> use;
  int i = 0, m = 0;
  for (int tm = 0; tm <= 100000; tm++) {
    while (get<0>(stc[i]) == tm) {
      tie(s,t,c) = stc[i];
      use.erase(mp(tm,c));
      use.insert(mp(t,c));
      i++;
    }

    m = max(m, int(use.size()));
    while (!use.empty() && use.begin()->first == tm) {
      use.erase(use.begin());
    }
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;


int main(){
    ll H, W; cin >> H >> W; 
    vector<vector<ll>> A(H, vector<ll>(W)), C(10, vector<ll>(10));
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) cin >> C[i][j];

    map<ll, ll> M;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> A[i][j];
            if(A[i][j] != -1) M[A[i][j]]++;
        }
    }
    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 10; i++){
        ans += M[i] * C[i][1];
    }
    cout << ans << endl;



    

    
}


Measured memory_bytes: 3904
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#define INF INT_MAX
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	int a;
	int sum[200005];
	int cnt = 0;
	int ans = 0;
	for(int i = 0;i < 200005;i++) sum[i] = INF;

	cin >> n >> k;

	for(int i = 0;i < n;i++){
		cin >> a;
		if(sum[a] == INF){
			cnt ++;
			sum[a] = 0;
		}
		sum[a] ++;
	}

	sort(sum, sum + n + 1);

	for(int i = 0;cnt > k && i < n;i++){
		ans += sum[i];
		cnt--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll ans = 0;

bool check(string S){
    ll now = 0;
    ll cnt = 0;
    for(int i = 0; i < S.length();i++){
        if(S[i] == '.'){
            if(now < 0 || now > 255) return false;
            if(now == 0 && cnt == 0) return false;
            if(now == 0 && cnt >= 2) return false;
            now = 0;
            cnt = 0;
        }else{
            if(now == 0 && cnt == 1) return false;
            now = now*10 + S[i] - '0';
            cnt++;
        }
    }
  //  cout << S << endl;
    return true;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S; cin >> S;
    ll ans = 0;
    for(int i = 1; i < S.length(); i++){
        for(int j = i; j < S.length(); j++){
            for(int k = j; k < S.length(); k++){
                string T = S;
                T.insert(k,".");
                T.insert(j, ".");
                T.insert(i, ".");
         //       cout << T << endl;
                T += ".";
                ans += check(T);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3224
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  i64 N, A, B;
  std::cin >> N >> A >> B;
  std::cout << std::min(N * A, B) << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Map <Integer,String> map = new HashMap<>();
        int ans = 0;
        int [] count =  new int [N] ;
        
        
        for(int i=0; i<M; i++){
            int num = sc.nextInt()-1;
            String tmp = sc.next();
            if(tmp.equals("AC") ){
                if(!map.containsKey(num) || map.get(num).equals("WA")){
                    ans++;
                    map.put(num,tmp);
                }
            }else{
                if(!map.containsKey(num) || map.get(num).equals("WA")){
                    count[num]++;
                    map.put(num,tmp);
                }
            }
        }
        
        int sum = 0;
        for(int i=0; i<N; i++){
            if(map.containsKey(i) && map.get(i).equals("AC")){
                sum += count[i];
            }
        }
        
        System.out.print(ans+" ");
        System.out.println(sum);
    }
}


Measured memory_bytes: 70128
use std::io;

fn main(){
    let mut s = String::new();
    io::stdin().read_line(&mut s);

    let mut cnt = 0;
    let mut max = 0;
    for c in s.chars() {
        if c == 'R' {
            cnt += 1;
        }
        if cnt > max {
                max = cnt;
        }
        
        if c != 'R' {
            cnt = 0;
        }
    }
    println!("{}", max);
}

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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 75236
#include<bits/stdc++.h>
using namespace std;
long long int trailing_zeroes(long long int n)
{
    long long cnt = 0 , x=5;
    
    while(n/x>=1)
    {
        cnt += n/x;
        x=x*5;
    }
    
    return cnt;
}

int main()
{
    long long int n;
    cin>>n;
    if(n%2==1)
        cout<<"0";
    else
        cout<<trailing_zeroes(n/2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
#include <cassert>
#include <cstring>
#include <set>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
const int MAXNUM = 30;

vector<vector<set<int> > > CKY(const vector<int> &A,
			       const vector<int> &L0,
			       const vector<int> &L1,
			       const vector<int> &R){
  int n = A.size();
  vector<vector<set<int> > > dp(n, vector<set<int> >(n + 1));
  REP(i, n) dp[i][1].insert(A[i]);
  
  REP2(w0, 2, n + 1)REP(i0, n)REP(j, R.size())REP2(w1, 1, w0){
    int i1 = (i0 + w1) % n;
    if(dp[i0][w1].count(L0[j])&&dp[i1][w0-w1].count(L1[j])){
      dp[i0][w0].insert(R[j]);
    }
  }
  return dp;
}

vector<vector<int> >
make_bitset(const vector<vector<set<int> > > &A){
  int n = A.size();
  vector<vector<int> > ans(n, vector<int>(n + 1, 0));
  REP(i, n)REP(w, n + 1)REP2(num, 1, MAXNUM + 1){
    if(A[i][w].count(num)) ans[i][w] |= 1 << num;
  }
  return ans;
}
	    

int dp[30][30][30][30];

int main(){
  int n, m, r;
  while(cin >> n >> m >> r && n + m + r){
    vector<int> A(n), B(m);
    vector<int> L0, L1, R;
    int counter = MAXNUM;
    REP(i, n) cin >> A[i];
    REP(i, m) cin >> B[i];
    
    REP(i, r){
      int k, num, result;
      cin >>k;
      stack<int> s;
      
      REP(j, k){
	cin >> num;
	s.push(num);
      }
      cin >> result;

      while(true){
	L1.push_back(s.top()); s.pop();
	L0.push_back(s.top()); s.pop();
	if(s.empty()){
	  R.push_back(result);
	  break;
	}else{
	  R.push_back(++counter);
	  s.push(counter);
	}
      }
    }
    
    vector<vector<int> > ai = make_bitset(CKY(A, L0, L1, R));
    vector<vector<int> > bi = make_bitset(CKY(B, L0, L1, R));
    
    int res = -1;
    memset(dp, -1, sizeof(dp));
    REP(i, n) REP(j, m) dp[i][0][j][0] = 0;
    
    REP(n0, n)REP(m0, m)REP(pn, n)REP(pm, m){
      if(dp[pn][n0][pm][m0] == -1) continue;
      REP2(n1, n0 + 1, n + 1)REP2(m1, m0 + 1, m + 1){
	int ppn = (n0 + pn) % n;
	int ppm = (m0 + pm) % m;
	if(ai[ppn][n1-n0] & bi[ppm][m1-m0])
	  dp[pn][n1][pm][m1] = max(dp[pn][n1][pm][m1],
				   dp[pn][n0][pm][m0] + 1);
      }
    }
    REP(i, n) REP(j, m) res = max(res, dp[i][n][j][m]);
    cout <<res << endl;
  }
  return 0;

}

Measured memory_bytes: 4568
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    double L;
    cin >> L;
    L /= 3.0;
    cout << fixed << setprecision(12) << L*L*L << endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld",--a*--b);
}

Measured memory_bytes: 128
class UFTree
  class Node
    attr_accessor :parent, :rank

    def initialize parent, rank=1
      @parent = parent
      @rank = rank
    end
  end

  def initialize size
    @nodes = Array.new(size)
    @sizes = Array.new(size)
    (0...size).each do |i|
      @nodes[i] = Node.new(i)
      @sizes[i] = 1
    end
  end

  def unite a, b
    a = root(a)
    b = root(b)

    return false if a == b

    if @nodes[a].rank < @nodes[b].rank
      @sizes[@nodes[a].parent] += @sizes[@nodes[b].parent]
      @nodes[b].parent = @nodes[a].parent
    else
      @sizes[@nodes[b].parent] += @sizes[@nodes[a].parent]
      @nodes[a].parent = @nodes[b].parent
      @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
    end

    true
  end

  def same? a, b
    root(a) == root(b)
  end

  def size i
    @sizes[root(i)]
  end

  private

  def root i
    if @nodes[i].parent == i
      i
    else
      @nodes[i].parent = root(@nodes[i].parent)
    end
  end
end

n, q = gets.split.map(&:to_i)
uft = UFTree.new n
q.times do
  c, x, y = gets.split.map(&:to_i)
  if c == 0
    uft.unite x, y
  else
    puts uft.same?(x, y) ? 1 : 0
  end
end


Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
int N;
int memo[100100];

int rec(int N){
  if(N == 0) return 0;
  if(memo[N] != -1) return memo[N];
  int num = N;
  for(int p6 = 1; p6 <= N; p6 *= 6) num = min(num, rec(N - p6) + 1);
  for(int p9 = 1; p9 <= N; p9 *= 9) num = min(num, rec(N - p9) + 1);
  return memo[N] = num;
}

signed main(){
  cin >> N;
  for(int i = 0; i <= N; i++) memo[i] = -1;
  cout << rec(N) << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long
// 商品の重さの種類
constexpr int N = 4;
// 商品の数、ナップサックの許容重さ
int n, total_w;
// 最初の商品の重さ -1は数値代入前を意味する
int w1 = -1;
// それぞれ重さ{w1,w1+1,w1+2,w1+3}の商品の価値
array<vector<int>, N> goods;

map<int, int> old_knapsucks;

// 現在重さwgt, 現在価値val、重さ{w1,w1+1,w1+2,w1+3}の商品をgs詰めたナップサックが取りうる最大価値を返す
int dfs(int wgt, int val, array<int, N> gs)
{
    // 重さ超過
    if (wgt > total_w)
        return -1;

    if (old_knapsucks.count(wgt) && old_knapsucks[wgt] >= val)
        return -1;
    old_knapsucks[wgt] = val;

    int max_rtn_val = val;

    // ナップサックに{w1,w1+1,w1+2,w1+3}の商品を一つつめたときの最大価値を再帰探索
    for (int i = 0; i < N; i++)
    {
        // 重さw1+iの商品はもう無い
        if (gs[i] >= goods[i].size())
            continue;

        auto ngs = gs;
        ngs[i]++;
        int rtn_val = dfs(wgt + w1 + i, val + goods[i][gs[i]], ngs);
        max_rtn_val = max(rtn_val, max_rtn_val);
    }

    return max_rtn_val;
}

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

    cin >> n >> total_w;
    for (auto &&x : goods)
        x.reserve(n);

    // goods配列に重さ毎の価値をプッシュ
    for (int i = 0; i < n; i++)
    {
        int w, v;
        cin >> w >> v;
        if (w1 < 0)
            w1 = w;

        goods[w - w1].push_back(v);
    }

    // 価値降順にソート
    for (auto &&x : goods)
    {
        sort(x.rbegin(), x.rend());
    }

    const int ans = dfs(0, 0, {0, 0, 0, 0});

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int ans=S.size();

    for(int i=0;i<S.size();i++) {
        if(S[i]==S[i+1]){ 
            ans--;
            i+=2;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
if n == 3:
    res = [2, 5, 63]
elif n == 4:
    res = [2, 5, 20, 63]
elif n == 5:
    res = [2, 5, 20, 30, 63]
else:
    res = [i for i in range(1, 30001)
           if i % 6 not in (1, 5)][:n]
    s = sum(res)
    if s % 6 == 2:
        res.pop(res.index(2))
        res.append(30000)
    elif s % 6 == 3:
        res.pop(res.index(3))
        res.append(30000)
    elif s % 6 == 5:
        res.pop(res.index(3))
        res.append(29998)

print(*res)

Measured memory_bytes: 4552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

bool check[400 + 2][400 + 2];
char s[400 + 2][400 + 2];
ll h, w;

pair<ll, ll> dfs(ll x, ll y){
    if(check[x][y]) return make_pair(0, 0);
    check[x][y] = true;

    pair<ll, ll> sum;
    if(s[x][y] == '#'){
        sum.first = 0;
        sum.second = 1;
    }else{
        sum.first = 1;
        sum.second = 0;
    }

    if(s[x][y] != s[x + 1][y] && s[x + 1][y] != 0){
        pair<ll, ll> tmp;
        tmp = dfs(x + 1, y);
        sum.first += tmp.first;
        sum.second += tmp.second;
    }
    if(s[x][y] != s[x - 1][y] && s[x - 1][y] != 0){
        pair<ll, ll> tmp;
        tmp = dfs(x - 1, y);
        sum.first += tmp.first;
        sum.second += tmp.second;
    }
    if(s[x][y] != s[x][y + 1] && s[x][y + 1] != 0){
        pair<ll, ll> tmp;
        tmp = dfs(x, y + 1);
        sum.first += tmp.first;
        sum.second += tmp.second;
    }
    if(s[x][y] != s[x][y - 1] && s[x][y - 1] != 0){
        pair<ll, ll> tmp;
        tmp = dfs(x, y - 1);
        sum.first += tmp.first;
        sum.second += tmp.second;
    }

    return sum;
}

int main(void){
    cin >> h >> w;

    rep(i, 0, h + 2){
        rep(j, 0, w + 2){
            if(i == 0 || i >= h + 1 || j == 0 || j >= w + 1){
                s[i][j] = 0;
                check[i][j] = true;
            }else{
                cin >> s[i][j];

            }
        }
    }

    ll ans = 0;
    rep(i, 1, h + 1){
        rep(j, 1, w + 1){
            if(s[i][j] == '#' && !check[i][j]){
                pair<ll, ll> tmp = dfs(i, j);
                ans += tmp.first * tmp.second;
            }
        }
    }

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


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

int main(){

    cout<<setprecision(5)<<fixed;

    int n; cin>>n;

    int seq[n];

    double sum =0;

    for(int i=0; i<n; i++){
     cin>>seq[i];
     sum +=  (double)1 / seq[i];
    }

    cout<< 1 /sum <<endl;

    return 0;
}



Measured memory_bytes: 256
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll n;
    unordered_map<ll,ll> m;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        ll tmp;
        std::cin >> tmp;
        m[tmp]++;
    }

    ll count2 = 0;
    for (auto e : m) {
        if(e.second %2 == 0){
            m[e.first] = 2;
            count2++;
        }else{
            m[e.first] = 1;
        }
    }
    // 2,2,2,2,2,2,2,2,2
    // 2,2,2
    // 2,2 →かならず欠損しない
    // 2　→　かならず1欠損
    if(count2%2 == 0){
        std::cout << m.size() << std::endl;
    }else{
        std::cout << m.size()-1 << std::endl;
    }
    
}


Measured memory_bytes: 4388
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long ll; 


//This source code is in the case of n, k <= 2020 (in nCk)

ll fact[4040404], frev[4040404];
ll invs[4040404];
//fact[n] = n! mod MOD
//frev[n] = 1 / n! mod MOD
//invs[n] = 


ll C(int a, int b) // <= this indicates combination aCb
{
	if (a < b) return 0;
	return fact[a] * frev[b] % MOD * frev[a - b] % MOD;
}
ll P(int a, int b){
    if(a<b) return 0;
    return fact[a] * frev[a - b] % MOD;
}

void fill_combination_table(){
	fact[0] = 1; frev[0] = 1;
	invs[0] = 1;
	invs[1] = 1;
	for (int i = 2; i < 4040404; ++i) invs[i] = MOD - MOD / i * invs[MOD % i] % MOD;
	for (int i = 1; i < 4040404; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		frev[i] = frev[i - 1] * invs[i] % MOD;
	}
}
int main(){
  fill_combination_table();
  long long int n;
  cin >> n;
  vector<int> v(n+1);
  long long int sum = 0;
  for(int i=0;i<n+1;i++){ cin >> v[i]; sum += v[i];}
  int dn =  sum - ( n * (n + 1) / 2);
  int f=-1,s=-1;
  for(int i=0;i<n+1;i++){
  	if(f==-1 && v[i] == dn) f = i;
    else if(s == -1 && v[i] == dn){s = i; break;}
  }
  int use = f + (n - s);
 // printf("f,s:%d,%d,%d\n", f,s,dn);
  for(int i=1;i<=n+1;i++){
  	 cout << (C(n+1,i) - C(use, i-1) + MOD) % MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 96256
#include <stdio.h>
int a,b,c,k;
main(){
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(k<=a) printf("%d\n",k);else if(k<=a+b) printf("%d\n",a);
  else printf("%d\n",a-(k-a-b));return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int q = sc.nextInt();
		boolean reverse = false;
		int t, f;
		char[] ans = new char[2*q+1];
		int l = q-1, r = q+1;
		for (int i = 0; i < q; i++) {
			t = sc.nextInt();
			if(t==1) {
				reverse = !reverse;
			}else {
				f = sc.nextInt();
				if(!reverse) {
					if(f==1) {
						ans[l] = sc.next().toCharArray()[0];
						l--;
					}else {
						ans[r] = sc.next().toCharArray()[0];
						r++;
					}
				}else {
					if(f==1) {
						ans[r] = sc.next().toCharArray()[0];
						r++;
					}else {
						ans[l] = sc.next().toCharArray()[0];
						l--;
					}
				}
			}
		}
		if(!reverse) {
			StringBuilder sb = new StringBuilder();
			for (int i = l+1; i < r; i++) {
				if(i==q) {
					sb.append(s);
				}else {
					sb.append(ans[i]);
				}
			}
			System.out.println(new String(sb));
		}else {
			StringBuilder sb = new StringBuilder();
			for (int i = r-1; i > q; i--) {
				sb.append(ans[i]);
			}
			System.out.print(new String(sb));
			System.out.print(new StringBuilder(s).reverse());
			sb = new StringBuilder();
			for (int i = q-1; i > l; i--) {
				sb.append(ans[i]);
			}
			System.out.println(new String(sb));
		}
		sc.close();
	}
}

Measured memory_bytes: 152872
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
N, A, B = map(int, input().split())
count = 0
for i in range(N):
    s = sum(map(int, (list(str(i+1)))))  # 各桁の和
    if s >= A and s <= B:
        count += i+1
print(str(count))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x;
    cin >> a;
    cin >> b;
    x = a + b;
    if(x % 2 == 0) {
        cout << x/2 << endl;
    }else{
        cout << x/2+1 << endl;
    }
}

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

const int INF = 1001001001;

int main() {
	int n,tmp;
	int minNum=INF,res=0;
	
	cin >> n ;
	rep(i,n){
		cin >> tmp;
		if(minNum >= tmp) {
			res++;
			minNum = tmp;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;

ll X,sum[2][200004];
int now = 0,rev = 1;

ll x(int now,int ind){
    if(ind==0){
        return sum[now][0];
    }
    return sum[now][ind]-sum[now][ind-1];
}

int main(){
    int N;
    ll L;
    cin>>L>>N;
    
    for(int i = 0;i < N;i++){
        cin>>X;
        sum[0][i]=X;
        sum[1][N-1-i]=L-X;}
    for(int i = 1;i < N;i++){
        sum[0][i]+=sum[0][i-1];
        sum[1][i]+=sum[1][i-1];
//        cout<<sum[0][i]<<" "<<sum[1][i]<<endl;
    }
    ll ans = 0;
    for(int xxxx = 0;xxxx < 2;xxxx++){
        for(int i = 0;i < N;i++){
            ll temp = 0;
            if((N-i)%2==1){
                int j = (N-1-i)/2;
                temp += 2*sum[rev][j-1];
                temp += 2*sum[now][j+i];
//                cout<<"b "<<temp<<endl;
                temp -= x(now,j+i);
                if(i>0){temp -= 2*sum[now][i-1];}
            }else{
                int j = (N-i)/2;
                temp += 2*sum[rev][j-1];
//                cout<<"a1 "<<temp<<endl;
                temp += 2*sum[now][j+i-1];
//                cout<<"a "<<temp<<endl;
                temp -= x(rev,j-1);
                if(i>0){temp -= 2*sum[now][i-1];}
            }
//            cout<<temp<<endl;
            ans = max(ans,temp);
        }
        now = 1,rev = 0;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3328
from collections import defaultdict
import sys

input = sys.stdin.readline

def main():
    H, W, M = map(int, input().split())
    d = defaultdict(int)
    e = defaultdict(int)
    x = defaultdict(set)
    y = defaultdict(set)
    X = []
    for _ in range(M):
        h, w = map(int, input().split())
        d[h] += 1
        e[w] += 1
        x[h].add(w)
        y[w].add(h)
        
    a = max(d.values())
    b = max(e.values())
    cand_d = set()
    cand_e = set()
    for i, j in d.items():
        if j == a:
            cand_d.add(i)

    for i, j in e.items():
        if j == b:
            cand_e.add(i)

    for i in cand_d:
        if (cand_e - x[i]) != set():
            ans = a + b
            print(ans)
            exit()

    for i in cand_e:
        if (cand_d - y[i]) != set():
            ans = a + b
            print(ans)
            exit()

    print(a + b - 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 369468