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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  vector<int> v(5);
  int loss = 9;
  int num = -1;
  int ans = 0;
  for(int i = 0; i < 5; ++i) {
    cin >> v[i];
    if(v[i] % 10 != 0 && v[i] % 10 <= loss) loss = v[i] % 10, num = v[i];
  }
  if(num == -1) {
    for(int i = 0; i < 5; ++i) {
      ans += v[i];
    }
    cout << ans << endl;
    return 0;
  } else {
    for(int i = 0; i < 5; ++i) {
      if(v[i] == num) {
        ans += v[i];
        num = (int)1e9;
      } else {
        if(v[i] % 10 == 0) ans += v[i];
        else ans += ((v[i] / 10)+1)*10;
      }
    }
    cout << ans << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
const int INF = 1e9;
const int A = 1000005;
int main(){
    string s;cin>>s;
    int n;n = s.length();
    vector<int> st={},g={},ans(n,0);
    rep(i,n-1){
        if(s[i]=='R'&&s[i+1]=='L')st.emplace_back(i);
        if(s[i]=='L'&&s[i+1]=='R'){g.emplace_back(i);}
    }
    int l = 0;
    g.emplace_back(n-1);
    rep(i,st.size()){
        
        int x = st[i];
        int r = g[i];
        ans[x] = 1 + (x-l)/2 + (r-x)/2;
        ans[x+1] = r + 1 - ans[x] - l;
        l = r + 1;
       // cout<<l<<r<<x<<endl;
    }
    rep(i,n){
        printf("%d ",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 4492
#include<stdio.h>

int main()
{
  int A[1000],i=0,N,v,j,n;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
     
    }
  for(i=0;i<N-1;i++)
    {
      printf("%d ",A[i]);
    }
  printf("%d\n",A[i]);
      for(i=1;i<N;i++)
    {
      v=A[i];
      j=i-1;
      while(j>=0&&A[j]>v)
	{
	  A[j+1]=A[j];
	    j--;
	    }
      A[j+1]=v;
      for(n=0;n<N-1;n++){
      printf("%d ",A[n]);
      }
      printf("%d\n",A[n]);
    }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
vector<ll> node[200005];
ll add_num[200005]={0},ans[200005]={0};
bool used[200005];
void dfs(int pos,ll val){
  val+=add_num[pos];
  used[pos]=true;
  ans[pos]=val;
  for(int i=0;i<node[pos].size();i++){
    int to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs(to,val);
    }
  }
}
int main(){
  int n,q;
  cin>>n>>q;
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    node[a].push_back(b);
    node[b].push_back(a);
    used[i]=false;
  }
  for(int i=1;i<=q;i++){
    ll p,x;
    cin>>p>>x;
    add_num[p]+=x;
  }
  dfs(1,0);
  for(int i=1;i<=n;i++) cout<<ans[i]<<(i==n?"\n":" ");
}


Measured memory_bytes: 25856
n, l, t = map(int, input().split())
ants = [tuple(map(int, input().split())) for _ in range(n)]

def dist(x, y, sign_0):
    if sign_0 == -1:
        x, y = y, x
    if x < y: return y - x
    else: return y - x + l

place = []
for i, (x, w) in enumerate(ants):
    sign = 1 if w == 1 else -1
    place.append((x + t * sign) % l)
    if i == 0:
        num = 0
        x_0 = x
        sign_0 = sign
    elif sign_0 * sign == -1:
        length = 2 * t
        d = dist(x_0, x, sign_0)
        if length > d or (length == d and sign_0 == -1):
            num = (num + sign_0) % n
            length -= d
            num = (num + (length // l) * sign_0) % n
            if length % l == 0 and sign_0 == 1:
                num = (num - 1) % n
    else: continue

place.sort()
i_0 = (place.index((x_0 + t * sign_0) % l) - num) % n
place.count((x_0 + t * sign_0) % l)

for i in range(i_0, n + i_0):
    i = i % n
    print(place[i])

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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 x,y;

int dis(int x,int y){
	if(x>y)return INF;
	else return (y-x);
}

int main(){
	cin>>x>>y;
	cout<<min(min(dis(x,y),dis(-x,y)+1),min(dis(x,-y)+1,dis(-x,-y)+2))<<endl;
}
	
	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 1;; i++) {
			int x = sc.nextInt();
			if (x == 0) {
				break;
			}
			System.out.println("Case " + i + ": " + x);
		}
	}
}


Measured memory_bytes: 41912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.ABC141
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            // 文字列配列の入力
            var inputIntArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int n = inputIntArray[0];
            long k = inputIntArray[1];
            int q = inputIntArray[2];

            long[] score = new long[n];
            for(int i = 0; i < q; i++)
            {
                int a_i = int.Parse(Console.ReadLine()) - 1;
                score[a_i]++;
            }
            for (int i = 0; i < n; i++)
            {
                //正解した数だけ点が減らない
                long result = k - q + score[i];

                if(result > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 18268
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  string N;
  cin >> N;

  if (N == "Sunny") {
    COUT("Cloudy");
  } else if (N == "Cloudy") {
    COUT("Rainy");
  } else {
    COUT("Sunny");
  }
  return 0;
}

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

int main(void){
	int N,A=1;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	for(int i=1;i<N;i++){
		if(a.at(i)>a.at(i-1)){
			A++;
		}
	}
	cout << A << endl;
	return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N,K;
string S;

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

	cin >> S >> K;
	N = S.size();

	FOR(i,0,N){
		if(S [i] != 'a' && 26 - (S [i] - 'a') <= K){
			K -= 26 - (S [i] - 'a');
			S [i] = 'a';
		}
	}

	if(K){
		S.back() = (S.back() - 'a' + K) % 26 + 'a';
	}

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 592
Q,H,S,D = gets.split.map(&:to_i)
n = gets.to_i * 4

def q(n)
  n*Q
end

def h(n)
  m = n/2
  [m*H, q(2*m)].min
end

def s(n)
  m = n/4
  [m*S, h(4*m)].min
end

def d(n)
  m = n/8
  [m*D, s(8*m)].min
end

ans = 0
ans += d(n/8*8)
n = n % 8
ans += s(n/4*4)
n = n % 4
ans += d(n/2*2)
n = n % 2
ans += d(n)
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;

ll ans =0;
vector<ll> march(5,0);

void dfs(vector<int> tmp){
    if(tmp.size()>=5){
        // ans += tmp[0]*tmp[1]*tmp[2];
        int cnt = 0;
        rep(i,5)cnt+=tmp[i];
        if(cnt==3){
            vector<int> k;
            rep(i,5){
                if(tmp[i])k.push_back(i);
            }
            ans+=march[k[0]]*march[k[1]]*march[k[2]];
        }
        return;
    }
    tmp.push_back(1);
    dfs(tmp);
    tmp.back()=0;
    dfs(tmp);
}

int main(){
    int n;cin >>n;
    rep(i,n){
        string s;cin >> s;
        if(s[0]=='M')++march[0];
        if(s[0]=='A')++march[1];
        if(s[0]=='R')++march[2];
        if(s[0]=='C')++march[3];
        if(s[0]=='H')++march[4];
    }
    dfs(vector<int>());
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import math
 
def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChar():
	return input()

def readChars():
	return input().split()
 
n,k = readInts()
d = []
a = []

for i in range(k):
	d.append(readInt())
	a.append(readInts())

su = [0]*(n+1)

for i in range(1,k+1):
	for j in range(len(a[i-1])):
		su[a[i-1][j]]+=1
print(su.count(0)-1)

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

int main(){
    ll a,b,sum,n,balls,rem;
    cin>>n>>a>>b;
    sum=a+b;
    if(n%sum==0){
        balls=(n/sum)*a;
    }
    else{
        rem=n%sum;
        if(rem<=a)
        balls=(n/sum)*a+rem;
        
        else
        balls=(n/sum)*a+a;
    }
    cout<<balls;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
ll X,Y;
/*0 1 2 3 4 5 6
0 x x o o o o o
1 x x x o o o o
2 o x x x o o o
3 o o x x x o o
4 o o o x x x o
5 o o o o x x x
6 o o o o o x x
 */
int main(void)
{
  cin >> X >> Y;
  if(abs(X-Y)<=1)
    {
      cout << "Brown" << endl;
    }
  else
    {
      cout << "Alice" << endl;
    }
  return 0;
}


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

int main(){
  	int n;
  	int a,b,c;
	cin>>n;
  	a=(int)(n/100);
  	b=(int)((n%100)/10);
  	c=n%10;
  	if(a==1){
    	a=9;
    }else if(a==9){
      	a=1;
    }
  
  	if(b==1){
    	b=9;
    }else if(b==9){
      	b=1;
    }
  
  	if(c==1){
    	c=9;
    }else if(c==9){
      	c=1;
    }
  cout<<100*a+10*b+c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

    // Constructor
    UnionFind(int sz_): par(sz_), siz(sz_, (int)1) {
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, (int)1);
        for (int i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

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

    // Union(Unite, Merge)
    bool merge(int x, int 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(int x, int y) { // 連結判定
        return root(x) == root(y);
    }

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

// ATC001(https://atcoder.jp/contests/atc001/tasks/unionfind_a)
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, Q;
    cin >> N >> Q;

    UnionFind uf(N);
	int a, b;
	map<int, int> mp;
	bool ok[N]{};
	int ans = 0;
	ok[0] = true;

    rep(i,Q){
		cin >> a >> b;
		--a; --b;
		mp[a]--;
		mp[b]++;
		if(ok[a]){
			ok[b] = true;
			if(mp[a] == -1){
				ok[a] = false;
			}
		}
    }
	rep(i,N) if(ok[i]) ++ans;
	cout << ans << endl;
}

Measured memory_bytes: 8192
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextLong();
        }

        for (int cx = 0; cx <= 100; cx++) {
            for (int cy = 0; cy <= 100; cy++) {
                for (int i = 0; i < n; i++) {
                    long hh = h[i] + Math.abs(x[i] - cx) + Math.abs(y[i] - cy);
                    boolean allMatched = true;
                    for (int j = 0; j < n; j++) {
                        if (Math.max(hh - Math.abs(x[j] - cx) - Math.abs(y[j] - cy), 0) != h[j]) {
                            allMatched = false;
                            break;
                        }
                    }
                    if (!allMatched) {
                        continue;
                    }
                    System.out.println(cx + " " + cy + " " + hh);
                    return;
                }
            }
        }
    }

}


Measured memory_bytes: 40400
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int A, B;
	cin >> A >> B;

	int ret = 0;
	for(int i=A; i<=B; i++){
		string l = to_string(i);
		string r = l;
		reverse(r.begin(), r.end());

		if(r == l)
			ret++;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  string s; cin >> s;
  itn n=s.size();
  map<char,int> mp;
  rep(i,n) mp[s[i]]++;
  vector<ll> a(0);
  for(auto v:mp){
    a.push_back(v.second);
  }
  vector<ll> sa(a.size());
  sa[0]=a[0];
  rep(i,a.size()-1) sa[i+1]=sa[i]+a[i+1];
  ll ans=0;
  rep(i,sa.size()){
    ans+=a[i]*(sa[sa.size()-1]-sa[i]);
  }
  cout << 1+ans << endl;
}

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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int n;
    cin >> n;
    int y = 200 * (n / 15);
    int x = 800 * n;
    cout << x-y << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
  print(0)
  exit()
if 2*X < Y or 2*Y < X:
  print(0)
  exit()
  
t = (X+Y)//3

# ①nCrの各項のmod(10^9+7)を事前計算
p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, t + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

# ②事前計算した項を掛け合わせ
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

print(cmb(t, X-t, p))

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

int main(){
  int n;
  vector<int> hoge(81);
  cin >> n;
  
  int index = 0;
  for (int i = 1; i <= 9; i++){
    for (int a = 1; a <= 9; a++){
      hoge[index] = i*a;
      index += 1;
    }
  }

  auto itr = find(hoge.begin(), hoge.end(), n);
  if (itr != hoge.end()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bitset>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const LL MOD = 998244353;

const int SIZE = 4096;
//const int SIZE = 16;
using Bits = bitset<SIZE>;
int N;
Bits X, A[6];
Bits B[SIZE];
char buf[SIZE];

void read(Bits &b) {
    scanf("%s", buf);
    b = Bits(buf);
}

int get_high(const Bits &b) {
    for (int i=SIZE; i--;) if (b.test(i)) return i;
    return -1;
}

void MAIN() {
    scanf("%d", &N);
    read(X);
    REP (i, N) read(A[i]);

    REP (i, N) {
	Bits b = A[i];
	int high = get_high(b);

	while (0 <= high && high < SIZE) {
	    if (B[high].test(high)) {
		b ^= B[high];
		high = get_high(b);
	    } else {
		B[high] = b;
		b <<= 1;
		high++;
	    }
	}
    }

    int z = -1;
    REP (i, SIZE) if (B[i].test(i)) {
	z = i;
	break;
    }

    LL cnt = 0;
    Bits ex;

    for (int i=SIZE-1; i>=z; i--) {
	cnt *= 2;
	if (X.test(i)) {
	    cnt += 1;
	}
	if (cnt >= MOD) cnt -= MOD;

	if (X.test(i) != ex.test(i)) {
	    ex ^= B[z] << (i-z);
	}
    }
//    REP (i, SIZE) cerr << B[i].to_ullong()<< " " << B[i] << endl;
//    cerr << X << endl;
//    cerr << ex << endl;
    bool le = true;
    for (int i=z; i>=0; i--) {
	if (!X.test(i) && ex.test(i)) {
	    le = false;
	    break;
	}
	if (X.test(i) && !ex.test(i)) {
	    break;
	}
    }
    if (le) cnt++;

    cnt %= MOD;
    printf("%lld\n", cnt);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(true){
        c-=b;
        if(c<=0){ 
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if(a<=0){ 
            cout << "No" << endl;
            return 0;
        }


    }
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return

#B
def B():
    _ = II()
    s = S()
    d = {}
    d["I"] = 1
    d["D"] = -1
    ans = 0
    now = 0
    for i in s:
        now += d[i]
        ans = max(ans, now)
    print(ans)
    return

#C
def C():
    def primes2(n):
        """https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n/3035188#3035188"""
        """ Returns  a list of primes < n """
        sieve = [True] * (n//2)
        for i in range(3,int(n**0.5)+1,2):
            if sieve[i//2]:
                sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
        return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]
    n = II()
    prime = primes2(n+1)
    d = []
    for i in prime:
        b = n
        f = 0
        while b:
            b = b // i
            f += b
        d.append(f%mod)
    ans = 1
    for i in d:
        ans *= (i + 1)
        ans %= mod
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 40560
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

const int N = 200200;
ll n, a[N];

void fail () {
   printf("NO");
   exit(0);
}

int main () {
   IOS
   cin >> n;
   FOR(i,n) cin >> a[i];
   ll sum = 0;
   FOR(i,n) sum += a[i];
   if (sum % (n*(n+1)/2) != 0) fail();
   ll k = sum / (n*(n+1)/2);
   ll sk = 0;
   FOR(i,n) {
      ll t = (a[i] + k) - a[(i+1)%n];
      if (t < 0 || t % n != 0) fail();
      sk += t/n;
   }
   if (k != sk) fail();
   printf("YES");
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int a,b,x[N];
  int i;
  for(i=0;i<N;i++) x[i] = 0;
  for(i=0;i<M;i++){
    cin >> a >> b;
    x[a-1] += 1;
    x[b-1] += 1;
  }
  for(i=0;i<N;i++) cout << x[i] << endl;
}
  

Measured memory_bytes: 3600
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it before "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int gcd(int a,int b)
{
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

int main()
{
    int n;
    scanf("%d",&n);
    ll sum = 0;
    for (int i = 1;i <= n;i ++) {
        for (int j = 1;j <= n;j ++) {
            for (int k = 1;k <= n;k ++) {
                sum += gcd(gcd(i,j),k);
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


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

	string s;
	cin >> s;
	string l = "", r = "";
	bool check = true;
	int q;
	cin >> q;
	rep(_,q) {
		int type;
		cin >> type;
		if (type == 1) {
			if (check) check = false;
			else check = true;
		}
		else if (type == 2) {
			int f; char c;
			cin >> f >> c;
			if (check&&f == 1 || !check&&f == 2) {
				l += c;
			}
			else {
				r += c;
			}
		}
	}
	if (check) {
		reverse(all(l));
		for (char c : l) cout << c;
		for (char c : s) cout << c;
		for (char c : r) cout << c;
	}
	else {
		reverse(all(r));
		reverse(all(s));
		for (char c : r) cout << c;
		for (char c : s) cout << c;
		for (char c : l) cout << c;
	}
	cout << endl;
}

Measured memory_bytes: 1040
a, b, c = map(int, input().split())
ans = False
if (c - a - b < 0):
	ans = False
else:
	lhs = 4 * a * b
	rhs = (c - a - b) * (c - a - b)
	ans = lhs < rhs

if (ans == True):
	print("Yes")
else:
	print("No")

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const int mxN = 2e5+7;

ll n, k, cy, nd;
int dph[mxN], ed[mxN];

void dfs(int cur, int depth){
	if(depth==k) {nd=cur; k=0; return;}
	if(dph[cur]>-1){
		k-=dph[cur];
		nd=cur;
		cy=depth-dph[cur];
		return;
	}
	dph[cur]=depth;
	dfs(ed[cur], depth+1);
}

int main(){
	setIO();
	memset(dph,-1,sizeof dph);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int x; cin>>x;
		ed[i]=x;
	}
	dfs(1, 0);
	int tr = k%cy;
	while(tr--){
		nd = ed[nd];
	}
	cout<<nd<<endl;
}

Measured memory_bytes: 5204
N = int(input())
abcs = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0, 0, 0] for i in range(N)]

for i, abc in enumerate(abcs):
    if i == 0:
        dp[i][0] = abc[0]
        dp[i][1] = abc[1]
        dp[i][2] = abc[2]
    else:
        dp[i][0] = max(dp[i-1][1] + abc[0], dp[i-1][2] + abc[0])
        dp[i][1] = max(dp[i-1][0] + abc[1], dp[i-1][2] + abc[1])
        dp[i][2] = max(dp[i-1][0] + abc[2], dp[i-1][1] + abc[2])

print(max(dp[-1]))

Measured memory_bytes: 40216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	cout<<a-max(((b+d-1)/d),((c+e-1)/e))<<endl;
}


Measured memory_bytes: 3152
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	ax := make([]float64, N)
	ay := make([]float64, N)
	ah := make([]float64, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&ax[i], &ay[i], &ah[i])
	}
	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			var H float64
			for i := 0; i < N; i++ {
				if ah[i] > 0 && H == 0 {
					H = ah[i] + math.Abs(float64(x)-ax[i]) + math.Abs(float64(y)-ay[i])
					break
				}
			}
			b := true
			for i := 0; i < N; i++ {
				w := math.Max(H-math.Abs(ax[i]-float64(x))-math.Abs(ay[i]-float64(y)), 0)
				if ah[i] != w {
					b = false
					break
				}
			}
			if b {
				fmt.Printf("%d %d %d\n", x, y, int64(H))
				return
			}
		}
	}
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[100];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        if (a[i - 1] < a[i] && a[i] < a[i + 1]) cnt++;
        if (a[i + 1] < a[i] && a[i] < a[i - 1]) cnt++;
    }
    cout << cnt << "\n";
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int[] A = new int[N];
            int Amax = 0;
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(strs[i]);
                if (Amax < A[i]) Amax = A[i];
            }

            bool[] map = new bool[Amax+1];
            var hash = new HashSet<int>();
            var daburi = new HashSet<int>();
            for(int i = 0; i < N; i++)
            {
                if (hash.Contains(A[i]))
                {
                    if (!daburi.Contains(A[i])) daburi.Add(A[i]);
                    continue;
                }
                for(int j = A[i] * 2; j <= Amax; j+= A[i])
                {
                    map[j] = true;
                }
                hash.Add(A[i]);
            }
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (!map[A[i]] && !daburi.Contains(A[i]))
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 51464
import java.io.*;
public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		for(int i = 0; i < input.length(); i++){
			char a = input.charAt(i);
			if(Character.isUpperCase(a)){
				System.out.print(Character.toLowerCase(a));
			}
			else{
				System.out.print(Character.toUpperCase(a));
			}
		}
		System.out.print("\n");
	}
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for ( int i = 0; i < n; i++ ){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    long long ans = 0;
    for ( auto& p : mp ){
        int s = p.second;
       /* cout << "p.second = " << s << endl;
	string D = p.first;
        cout << "p.first = " << D << endl; */
	ans += (long long) s * ( s - 1 ) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 205;

vector<int> T[N];
int c[N];

int cnt = 0;
int bit[N];
void dfs(int u){
  c[u]=cnt;
  for(auto x : T[u]){
    if(bit[x]==-1){
      bit[x]=1-bit[u];
      dfs(x);
    }
    else{
      if(bit[x] == bit[u]){
        cout << -1;
        exit(0);
      }
    }
  }
}

int dis[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  char p;
  for(int i = 1; i <= n; i ++ ){
    bit[i]=-1;
    for(int j = 1; j <= n; j ++ ){
      cin >> p;
      if(p - '0' == 1){
        T[i].push_back(j);
      }
    }
  }
  for(int i = 1; i <= n; i ++ ){
    if(bit[i] == -1){
      cnt ++ ;
      bit[i] = 0;
      dfs(i);
    }
  }
  int ans = 0;
  int node;
  for(int i = 1; i <= cnt; i ++ ){
    vector<int> lis;
    for(int j = 1; j <= n; j ++ ){
      if(c[j] == i) lis.push_back(j);
    }
    int add = 0;
    for(auto x : lis){
      for(auto y : lis){
        dis[y]=(int)1e9;
      }
      queue<int> bfs;
      bfs.push(x);
      dis[x]=1;
      while(!bfs.empty()){
        node = bfs.front();
        add = max(add, dis[node]);
        bfs.pop();
        for(auto p : T[node]){
          if(dis[p] == (int)1e9){
            dis[p] = dis[node] + 1;
            bfs.push(p);
          }
        }
      }
    }
    ans += add;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000001

const ll MOD = 1e9+7;

int main(){
	ll n,m;
	cin>>n>>m;
	ll a[m];
	for(ll i=0;i<m;i++)cin>>a[i];
	int nn[10] = {0,2,5,5,4,5,6,3,7,6};
	ll dp[100005];
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	for(ll i=0;i<m;i++){
		dp[nn[a[i]]] = 1;
	}
	for(ll i=1;i<=n;i++){
		//if(dp[i]==-1)continue;
		for(ll j=0;j<m;j++){
			//if(n-i>=nn[a[j]]&&i-nn[a[j]]>=0){
			if(i-nn[a[j]]>=0){
				//cout<<nn[a[j]]<<endl;
				dp[i] = max(dp[i-nn[a[j]]]+1,dp[i]);
			}
			//cout<<"i:"<<i<<"dp[i]:"<<dp[i]<<endl;
		}
	}
	/*fill(dp,dp+10005,-1);
	dp[0]=0;
	for(ll i=0;i<n;i++){
		if(dp[i]==-1)continue;
		for(ll j=0;j<m;j++){
			dp[nn[a[j]]+i] = max(dp[nn[a[j]]+i],dp[i]+1);
		}
	}*/
	//cout<<dp[n]<<endl;
	ll ans = 0;
	ll tmp = n,tmp2=0;
	ll cnt=0;
	for(ll i=0;i<dp[n];i++){
		ans = 0;
		if(cnt == dp[n]-1){
			for(ll j=0;j<m;j++){
				if(tmp-nn[a[j]]==0){
					//cout<<"tmp:"<<tmp<<" nn:"<<nn[a[j]]<<endl;
					ans = max(ans,a[j]);
				}
			}
			cout<<ans<<endl;
			return 0;
		}else {
			for(ll j=0;j<m;j++){
				if(dp[tmp-nn[a[j]]]==dp[tmp]-1){
					if(ans<a[j]){
						ans = a[j];
						tmp2 = nn[a[j]];
					}
				}
			}
			tmp-=tmp2;
			//cout<<"i:"<<i<<"tmp:"<<tmp<<endl;
			cout<<ans;
			cnt++;
			//cout<<cnt<<endl;
		}
	}

}


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


int main()
{
  int x;
  cin >> x;
  if (x == 2)
  {
    puts("2");
    return 0;
  }
  vector<bool> prime(1e6, true);
  for (int i=3; i<1e6; i+=2)
  {
    if (!prime[i])
      continue;
    if (i >= x)
    {
      cout << i << endl;
      return 0;
    }
    int j = i * 2;
    while (j < 1e6)
    {
      prime[j] = false;
      j += i;
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,x,t;
  cin >> n >> x >> t;
  n = ceil((double)n / x);
  cout << n * t << endl;
}

Measured memory_bytes: 3632
from collections import defaultdict, Counter
from itertools import combinations
INF = float("inf")


def main():
    N, K = map(int, input().split())
    points = []
    for i in range(N):
        x, y = map(int, input().split())
        points.append((y, x))

    ans = INF
    for i in range(N):
        for j in range(N):
            for k in range(N):
                for l in range(N):
                    y1, y2, x1, x2 = points[i][0], points[j][0], points[k][1], points[l][1]
                    area = abs(y1 - y2) * abs(x1 - x2)
                    if y1 <= y2 and x1 <= x2 and area < ans:
                        n = 0
                        for p in points:
                            n += y1 <= p[0] <= y2 and x1 <= p[1] <= x2
                        if n >= K:
                            ans = min(ans, area)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48604
n = int(input())
D = [int(i) for i in input().split()]

p = 998244353

if D[0] != 0:
    print(0)
    exit()

for i, d in enumerate(D):
    if i != 0 and d == 0:
        print(0)
        exit()

C = [0] * n

for d in D:
    C[d] += 1

flag = False

for c in C:
    if flag and c != 0:
        print(0)
        exit()
    if c == 0:
        flag = True
    

ans = 1

for i in range(1, n):
    ans *= pow(C[i - 1], C[i], p)
    ans %= p

print(ans)


Measured memory_bytes: 14396
# -*- coding:utf-8 -*-

def bubble_sort(num_list):
    swap_count = 0
    for i in range(len(num_list)):
        for j in range(len(num_list)-1, i , -1):
            if num_list[j] < num_list[j-1]:
                num_list[j], num_list[j-1] = num_list[j-1], num_list[j]
                swap_count = swap_count + 1
    return num_list, swap_count

def show_list(list):
    i = 0;
    while(i < len(list)-1):
        print(list[i], end=" ")
        i = i + 1
    print(list[i])

num = int(input())
num_list = [int(x) for i, x in enumerate(input().split()) if i < num]
num_list, swap_count = bubble_sort(num_list)
show_list(num_list)
print(swap_count)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> l(N, -1);
    int i = 0, now = 0;
    while (i < N && now < K) {
        if (S[i] == 'o') {
            l[i] = now;
            now++;
            i += C;
        }
        i++;
    }

    vector<int> r(N, -1);
    i = N - 1, now = K - 1;
    while (0 <= i && 0 <= now) {
        if (S[i] == 'o') {
            r[i] = now;
            now--;
            i -= C;
        }
        i--;
    }

    rep(i, N) {
        if (l[i] != -1 && l[i] == r[i]) cout << i+1 << endl;
    }
}

Measured memory_bytes: 3332
fun main(args: Array<String>) {
    readLine()
    val ws = readLine()!!.split(" ").map { it.toInt() }
//    print(ws)
//    val ws = "1 3 1 1".split(" ").map { it.toInt() }
    val ss = ws.subList(0, ws.size-1)

    val all = ws.sum()
    var left = 0
    var right = all
    var min = all
    ss.forEach { n ->
        left += n
        right -= n
        val diff = Math.abs(right - left)
        if (diff < min) {
            min = diff
        }
//        println(left)
//        println(right)
//        println(diff)
//        println()
    }
    print(min)
}


Measured memory_bytes: 36144
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

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


	int K;
	cin >> K;

	string S;
	cin >> S;
	int M = S.size();
	int N = M + K;

	int inv[1000010];
	inv[0] = 1;
	inv[1] = 1;
	rep1(i, K - 1) inv[i + 1] = ll(inv[i]) * i % mod;
	ll tmp = modpow(ll(inv[K]) * K % mod, mod - 2);
	for (int i = K; i > 0; i--) {
		inv[i] = inv[i] * tmp % mod;
		tmp = tmp * i % mod;
	}

	const ll are = 423076927;
	tmp = modpow(26, K);
	ll kotae = 0;
	rep(i, K + 1) {
		tmp = tmp * inv[i] % mod;
		kotae += tmp;
		tmp = tmp * (M + i) % mod;
		tmp = tmp * are % mod;
	}

	co(kotae % mod);

	Would you please return 0;
}

Measured memory_bytes: 8172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new BG042().slove();
        }
    }

    class BG042
    {
        public void slove()
        {
            Console.WriteLine(Console.ReadLine().Split(' ').Select((v) => int.Parse(v)).Sum() == 17 ? "YES" : "NO");
        }
    }

}

Measured memory_bytes: 11220
N, M, Q = map(int, input().split())
l = []
for i in range(Q):
  l.append(list(map(int, input().split())))

A_N = [[i] for i in range(1, M+1)]
for i in range(N-1):
  a = []
  for j in range(len(A_N)):
    last = A_N[j][-1]
    for k in range(last, M+1):
      a.append(A_N[j] + [k])
  A_N = a

high_score = 0
for i in range(len(A_N)):
  A = A_N[i]
  score = 0
  for j in range(len(l)):
    aj, bj, cj, dj = l[j]
    if A[bj-1]-A[aj-1] == cj:
      score += dj
  high_score = max(high_score, score)

print(high_score)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll D;
  scanf("%lld",&D);
  ll X;
  scanf("%lld",&X);
  vector<ll> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  ll sum=0;
  for (int i=0; i<D; i++) {
    for (int j=0; j<N; j++) {
      if (i%A[j]==0) sum++;
    }
  }
  cout << sum+X << endl;
}

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


Measured memory_bytes: 256