akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; 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 allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> td(n);
  rep (i, n) cin >> td[i].first >> td[i].second;
  unordered_map<int, int> neta_max;
  rep (i, n) neta_max[td[i].first] = max(neta_max[td[i].first], td[i].second);
  sort(all(td), [](pair<int, int> &a, pair<int, int> &b) { return a.second > b.second; });
  unordered_map<int, int> neta_num;
  lint sum = 0;
  rep (i, k) {
    sum += td[i].second;
    ++neta_num[td[i].first];
  }
  lint num  = neta_num.size();
  lint maxi = sum + num * num;
  allrep (p, neta_num) neta_max.erase(p.first);
  vector<int> left(neta_max.size());
  auto itr = neta_max.begin();
  rep (i, left.size()) {
    left[i] = itr->second;
    ++itr;
  }
  sort(all(left), greater<int>());
  int now = k - 1;
  rep (i, left.size()) {
    while (now >= 0 && neta_num[td[now].first] <= 1) --now;
    if (now < 0) break;
    sum = sum - td[now].second + left[i];
    ++num;
    maxi = max(maxi, sum + num * num);
    --neta_num[td[now].first];
    --now;
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 7460
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, h;
  cin >> n >> h;
  vi a(n), b(n);
  REP(i, n) { cin >> a[i] >> b[i]; }

  int m = 0;
  REP(i, n) { m = max(m, a[i]); }
  vi th;
  int ans = 0;
  int sum = 0;
  REP(i, n) {
    if (m < b[i]) {
      th.push_back(b[i]);
      sum += b[i];
    }
  }

  if (sum >= h) {
    sort(th.rbegin(), th.rend());
    REP(i, (int)th.size()) {
      h -= th[i];
      ans++;
      if (h <= 0)
        break;
    }
  } else {
    ans += (int)th.size();
    h -= sum;
    ans += (h + m - 1) / m;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <cassert>

using namespace std;
typedef long long ll;

const int MAXM = 1024;
int a[MAXM], to_msk[MAXM];
int dp[MAXM][1<<12];
const int INF = 1e9;

int n, m;

int go(int pos, int msk) {
  if (pos == m) {
    if (msk + 1 == (1 << n)) {
      return 0;
    }
    return INF;
  }
  if (dp[pos][msk] != -1) return dp[pos][msk];
  int op1 = go(pos + 1, msk);
  int op2 = a[pos] + go(pos + 1, msk | to_msk[pos]);
  return dp[pos][msk] = min(op1, op2);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    int b;
    cin >> b;
    int msk = 0;
    for (int j = 0; j < b; j++) {
      int x;
      cin >> x;
      x--;
      msk = msk | (1 << x);
    }
    to_msk[i] = msk;
  }
  for (int i = 0; i < MAXM; i++)
    for (int j = 0; j < (1 << 12); j++) 
      dp[i][j] = -1;

  int res = go(0, 0);
  if (res > INF / 2) res = -1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 20112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] s = sc.next().toCharArray();
        
        int a = 0;
        int b = 0;
        for (int i = 0; i < s.length; i++) {
            char c = s[i];
            if (i % 2 == 0) {
                if (c == '0')
                    a++;
                else
                    b++;
            } else {
                if (c == '1')
                    a++;
                else
                    b++;
            }
        }
        
        System.out.println(Math.min(a, b));
    }
}


Measured memory_bytes: 26196
// inputに入力データ全体が入る
function Main(input) {
  var p, q, r;
  p = Number(input.split('\n')[0].split(' ')[0]);
  q = Number(input.split('\n')[0].split(' ')[1]);
  r = Number(input.split('\n')[0].split(' ')[2]);
  console.log([p, q, r].sort()[0] + [p, q, r].sort()[1]);
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#define NMAX 105
#define VALMAX 100005
using namespace std;
int n,w,j,i;
long long a[NMAX],b[NMAX],d[VALMAX],maxim,sol;
int main()
{
    cin>>n>>w;
    for(i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(i=1;i<=n;i++)
    {
        for(j=maxim;j>=1;j--)
        {
            if(d[j]!=0 && j+a[i]<=w)
            {
                d[j+a[i]]=max(d[j+a[i]],d[j]+b[i]);
                maxim=max(maxim,j+a[i]);
            }
        }
        d[a[i]]=max(d[a[i]],b[i]);
        maxim=max(maxim,a[i]);
    }
    for(i=1;i<=w;i++)
        sol=max(sol,d[i]);
    cout<<sol;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s;
	cin >> s;
	int res = 0;
	for(int i = 1; i < s.size(); i++) {
		res += s[i-1] != s[i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int p_max=1e5+10;
const int n_max=1e3+10;
const ll inf=1e13;

ll dp[p_max];

int main()
{
    int n;
    ll c;
    cin>>n>>c;
    ll w[n_max];
    int p[n_max];
    for(int i=1;i<=n;i++){
        cin>>w[i]>>p[i];
    }
    int p_sum=accumulate(p,p+n_max,0);
    //cout<<p_sum;
    for(int i=1;i<=p_sum;i++)
        dp[i]=inf;
    dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        ll x=w[i];
        int y=p[i];
        for(int j=p_sum;j>=y;j--)
        {
            dp[j]=min(dp[j],dp[j-y]+x);
        }
    }
    for(int i=p_sum;i>=0;i--)
    {
        if(dp[i]<=c){
            cout<< i <<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,x,a[N];
ll sum[N];

int main() {
	scanf("%d%d",&n,&x);
	REP(i,1,n) scanf("%d",a+i);
	REP(i,1,n) sum[i]=sum[i-1]+a[i];
	ll ans = 1e18;
	REP(i,1,n) {
		ll ret = 0;
		int c = 5;
		for (int j=n; j>0; j-=i) {
			ret += c*(sum[j]-sum[max(0,j-i)]);
			if (ans<ret+(ll)i*x) break;
			if (j!=n) c += 2;
		}
		ans = min(ans, ret+(ll)i*x);
	}
	printf("%lld\n", ans+(ll)n*x);
}








Measured memory_bytes: 5888
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N, A, B;

int main() {
  cin >> N >> A >> B;
  cout << min(A * N, B);
}


Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
P = LIST()

P.append(-1)

ans = 0
i = 0

while i < N:
    if P[i] == i+1:
        ans += 1
        if P[i+1] == i+2:
            i += 1
    i += 1

print(ans)


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

using namespace std;

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

    int m1, d1;
    cin >> m1 >> d1;
    int m2, d2;
    cin >> m2 >> d2;

    if(d2==1) cout << 1;
    else cout << "0";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

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

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    int N,K,L;
    cin>>N>>K>>L;
    UnionFind tr(N),ro(N),All(2*N+1);
    for (size_t i = 0; i < K; i++)
    {
        int p,q;
        cin>>p>>q;
        p--;q--;
        ro.unite(p,q);
    }
    for (size_t i = 0; i < L; i++)
    {
        int r,s;
        cin>>r>>s;
        r--;s--;
        tr.unite(r,s);
    }
    map<pair<int,int>,ll> cnt;
    for (size_t i = 0; i < N; i++)
    {
        cnt[{ro.find(i),tr.find(i)}]++;
    }
    for (size_t i = 0; i < N; i++)
    {
        cout<<cnt[{ro.find(i),tr.find(i)}]<<endl;
    }
    
    
    return 0;
}

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

int main()
{
    string s;
    int c = 0;
    cin >> s;

    for(int i=0; i<s.size()-1; i++){
        if(s[i] == '0' && s[i+1] == '0'){
            s[i+1] = '1';
            c++;
        }
        if(s[i] == '1' && s[i+1] == '1'){
            s[i+1] = '0';
            c++;
        }
    }

    cout << c << endl;
    return 0;
}

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

int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  if(A>=B){
    if(A>=C&&B<=C) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(A<=C&&B>=C) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    bool ans = true;
    //一文字のときに注意.
    //Nが奇数のときにも注意
    if(S.size() == 1 or S.size()%2 != 0)ans = false;

    for(int i=0;i<N/2;i++){
        if(S[i] != S[i+N/2]){
            ans = false;
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
S=input()
b=1
x=''
y=''
for i in range(int(input())):
    q=input()
    if q=='1':b^=1
    else:
        a,f,c=q.split()
        if (int(f)-1)^b:x=c+x
        else:y=y+c
S=x+S+y
print(S if b else S[::-1])

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  int C = nextInt();
  if (A > B) swap(A, B);
  if (A <= C && C <= B) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

const int N = 110;
const int W = 100100;

int main() {
  int n, w;
  cin >> n >> w;
  vector<int> weight(N), value(N);
  rep(i,n) cin >> weight[i] >> value[i];
  vector<vector<ll>> dp(N, vector<ll>(W));
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= w; j++) {
      if(j - weight[i-1] >= 0) {
        dp[i][j] = max(dp[i][j], dp[i-1][j-weight[i-1]] + value[i-1]);
      }
      dp[i][j] = max(dp[i][j], dp[i-1][j]);
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}


Measured memory_bytes: 90300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef struct edge
{
	ll from,to;
	ll cost;
};
typedef struct points
{
	ll x,y;
	ll id;
};
bool xcmp(points a,points b)
{
	return a.x<b.x;
}
bool ycmp(points a,points b)
{
	return a.y<b.y;
}
bool cmp(edge a, edge b)
{
	return a.cost<b.cost;
}
int find(int x,int par[])
{
	if(x==par[x]) return x;
	return par[x]=find(par[x],par);
}
int main()
{
	int n; cin>>n;
	points v[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>v[i].x>>v[i].y;
		v[i].id=i;
	}
	
	vector<edge>e;
	sort(v+1,v+n+1,xcmp);
	for(int i=1;i<n;i++)
	{
		edge xx;
		xx.from=v[i].id;
		xx.to=v[i+1].id;
		xx.cost=v[i+1].x-v[i].x;
		e.push_back(xx);
	}
	sort(v+1,v+n+1,ycmp);
	for(int i=1;i<n;i++)
	{
		edge xx;
		xx.from=v[i].id;
		xx.to=v[i+1].id;
		xx.cost=v[i+1].y-v[i].y;
		e.push_back(xx);
	}
	sort(e.begin(),e.end(),cmp);
	int par[n+1];
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
	}
    ll ans=0;
	for(int i=0;i<e.size();i++)
	{
		int x=e[i].from;
		int y=e[i].to;
		int root1=find(x,par);
		int root2=find(y,par);
		if(root1!=root2)
		{
			ans+=e[i].cost;
			par[root2]=root1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 10864
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to, cost;}; //edgeパラメータ
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み
  vector<ll> parent;

  graph(ll n): N(n), G(N), d(n,INF2), parent(N) {}

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
    G[t].emplace_back((edge){s, cost}); //無向ならON
  }

  void dijkstra(ll s){
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que; //ansが小さい順に出る
    que.push(P(0,s)); // P < ans , Node >
    while(!que.empty()){
      P p = que.top(); que.pop(); //pに <ans,Node> 入れる
      ll v = p.second; //vに Node 入れる
      if(d[v] < p.first) continue; //すでに良い数値が入っているならパス
      rep(i,G[v].size()){
        edge& E = G[v][i];
        if(d[E.to] > d[v] + E.cost){ //更新するなら
          d[E.to] = d[v]+ E.cost;
          parent[E.to] = v; //親を記録,goalから遡れば道順
          que.push(P(d[E.to], E.to));
        }
      }
    }
  }
};

//--MAIN-----------------------------------
void Main() {
    ll N,M,S,T; cin>>N>>M>>S>>T; --S,--T;
    graph g(N);
    graph g2(N);
    rep(i,M){
        ll u,v,a,b; cin>>u>>v>>a>>b; --u,--v;
        g.add_edge(u,v,a);
        g2.add_edge(u,v,b);
    }
    g.dijkstra(S);
    g2.dijkstra(T);
    ll ans[N];
    rep(i,N){
        ans[i]=g.d[i]+g2.d[i];
    }
    repr(i,N-2,0){
        mini(ans[i],ans[i+1]);
    }
    ll sai=pow(10,15);
    rep(i,N){
        cout<< sai-ans[i] <<"\n";
    }
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(void){
    int L,R,d,count1,count2;
    cin>>L>>R>>d;
    count2=0;

    for (;R>=L;R--){
        if(R%d==0){
            count2++;
        }
        
    }

    cout<<count2<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int x;
    cin>>x;
    int x1=x,y=360;
    int z=__gcd(x,y);
    // cout<<z<<endl;
    x/=z;
    y=y*x/x1;
    cout<<y<<endl;
}

int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("oo.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int a[maxn];
int main()
{
    int k,n;
    while(~scanf("%d%d",&n,&k))
    {
        int pos ;
        for(int i = 1; i <= n; ++i)
        {
            scanf("%d",a+i);
            if(a[i] == 1)pos = i;
        }
        if(n == k)
            printf("1\n");
        else
        {
            int qian = 0,hou = 0;
            //qian = (pos - 1)/k + ((pos - 1)%k?1:0);
            //hou  = (n - pos + 1)/k + ((n - pos + 1)%k?1:0);
            printf("%d\n",(n - 1)/(k - 1) + ((n-1)%(k-1)?1:0));
        }
    }

}
















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

int a, b, c, n;
int parts[310];
int result[1010][4];
int main()
{
  while(cin >> a >> b >> c && (a || b || c)){
    cin >> n;
    for(int i = 1; i <= a + b + c; i++)
      parts[i] = 2;

    for(int i = 0; i < n; i++)
      for(int j = 0; j < 4; j++)
	cin >> result[i][j];

    for(int i = 0; i < n; i++)
      if(result[i][3])
	parts[result[i][0]] = parts[result[i][1]] = parts[result[i][2]] = 1;

    for(int i = 0; i < n; i++)
      if(!result[i][3]){
	if(parts[result[i][0]] == 1 && parts[result[i][1]] == 1)
	  parts[result[i][2]] = 0;
	if(parts[result[i][1]] == 1 && parts[result[i][2]] == 1)
	  parts[result[i][0]] = 0;
	if(parts[result[i][2]] == 1 && parts[result[i][0]] == 1)
	  parts[result[i][1]] = 0;
      }

    for(int i = 1; i <= a + b + c; i++)
      cout << parts[i] << endl;

  }
  return 0;
}

Measured memory_bytes: 1176
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static boolean possible(List<Integer> w, int n, int k, int P) {
		int current = 0;
		k--; // ???????????£???????????????????????°
		for (int c : w) {
			if (current + c > P) {
				if (k > 0) {
					k--;
					if (c <= P)
						current = c;
					else 
						return false; 
				} else {
					return false;
				}
			} else {
				current += c;
			}
		}
		return true;
	}
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		// BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
		String[] line = br.readLine().split(" ");
		int n = Integer.parseInt(line[0]);
		int k = Integer.parseInt(line[1]);
		List<Integer> w = new ArrayList<Integer>();
		for (int i = 0; i < n; i++)
			w.add(Integer.parseInt(br.readLine()));
		
		// O(kn^2)?????¢?????´??????????????????????????????...????????????(?????¶)
		// ????????????????????????O(kn)?????????????§£?????????????????????????????????...
		// List<List<Integer>> P = new ArrayList<List<Integer>>();
		// List<Integer> P0 = new ArrayList<Integer>();
		// P0.add(w.get(0));
		// for (int j = 1; j < n; j++)
		// 	P0.add(P0.get(j - 1) + w.get(j));
		// P.add(P0);
		// for (int i = 1; i < k; i++) {
		// 	List<Integer> Pk = new ArrayList<Integer>();
		// 	for (int j = 0; j < n; j++) {
		// 		int min = P.get(i - 1).get(j);
		// 		int sum = 0;
		// 		for (int l = 0; l < j; l++) {  // j??????????????????????????????l+1???????????????
		// 			sum += w.get(j - l);
		// 			if (min < sum)
		// 				break;
		// 			min = Math.max(P.get(i - 1).get(j - l - 1), sum);
		// 		}
		// 		Pk.add(min);
		// 	}
		// 	P.add(Pk);
		// }
		// System.out.println(P.get(k - 1).get(n - 1));
		
		// ??????P????????????????????????????????????????????????????????????????????¨???????°????
		// ???????????¨??????2?????¢?´¢??§?????£?????????O(nlnP)??§???????????????
		// System.out.println(possible(w, n, k, 6));
		// l????????????u???????????????
		int u = 1000000000, l = 1;

		while (u - l > 1) {
			int mid = (u + l) / 2 - 1;
			if (possible(w, n, k, mid))
				u = mid + 1;
			else
				l = mid + 1;
		}
		System.out.println(l);
	}
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a;
	a.resize(n);
	rep(i, n)
		cin>>a[i];

	int ans=0;
	bool end = false;
	while(1)
	{
		rep(i,n)
		{
			if(a[i]%2 != 0) end=true;
			a[i] /= 2;
		}
		if(end) break;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
	int N,X;
	cin >> N >> X;
	vector<int> L(N);
	for(int i = 0; i < N; i++) cin >> L[i];
	int D = 0;
	int c = 1;
	for(int i = 1; i <= N; i++){
		D += L[i - 1];
		if (D <= X) {
			c++;
		}
		else {
			break;
		}
	}
	cout << c << endl;
}

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

using namespace std;

int main() {
  int a[4];
  for(int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  sort(a,a+4);

  if(a[0] == a[1] && a[2] == a[3]) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }

}

Measured memory_bytes: 3104
N = int(input())
P = list(map(int, input().split()))

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  
print(c)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
    int n;
    int count = 0, flag = 0;
    scanf("%d\n", &n);
    int a[n];
    for(int i=0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    while(1) {
        for(int i=0; i < n; i++) {
            if(a[i] % 2 == 1) {
                flag = 1;
                break;
            }
            a[i] = a[i] / 2;
        }
        if(flag == 1) break;
        count++;
    }
    printf("%d\n", count);

    return 0;
}

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


using namespace std;

int N;
int ans = 0;


void dpf(long int num, int a, int b, int c){
    
    
    if (num*10+3 <= N && (a+1)*b*c != 0) {
        ans += 1;
        dpf(num*10+3, a+1, b, c);
        

        
    }else if(num*10+3 <= N && a*b*c == 0){
        
        dpf(num*10+3, a+1, b, c);
        
    }
    
    
    if (num*10+5 <= N && a*(b+1)*c != 0) {
        ans += 1;
        dpf(num*10+5, a, b+1, c);
        
        
        
    }else if(num*10+5 <= N && a*b*c == 0){
        
        dpf(num*10+5, a, b+1, c);
        
    }
    
    if (num*10+7 <= N && a*b*(c+1) != 0) {
        ans += 1;
        dpf(num*10+7, a, b, c+1);
        
    }else if(num*10+7 <= N && a*b*c == 0){
        
        dpf(num*10+7, a, b, c+1);
        
    }
    
    
}



int main(){
   
    cin >> N;
    
    dpf(0, 0, 0, 0);
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	string s;
	cin >> s;
	int n = sz(s);
	if (s[n - 1] != 's')
		cout << s << "s" << en;
	else
		cout << s << "es" << en;


	return 0;
}




Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
set<int> s;
int n, a;
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}

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


int main(int argc, char **argv) {
    int X, Y;
    int A, B, C;
    std::vector<long> p, q, r;

    std::cin >> X >> Y >> A >> B >> C;

    for (int i = 0; i < A; i++) {
        long d;
        std::cin >> d;
        p.push_back(d);
    }
    for (int i = 0; i < B; i++) {
        long d;
        std::cin >> d;
        q.push_back(d);
    }
    for (int i = 0; i < C; i++) {
        long d;
        std::cin >> d;
        r.push_back(d);
    }

    std::sort(p.begin(), p.end());
    std::sort(q.begin(), q.end());
    std::sort(r.begin(), r.end());

    // remove never used elements
    p.erase(p.begin(), p.end() - X);
    q.erase(q.begin(), q.end() - Y);

    std::vector<long> v(p.size() + q.size(), 0);
    std::merge(p.begin(), p.end(), q.begin(), q.end(), v.begin());

    long long sum = 0;
    for (auto d : v)
        sum += d;

    auto it = v.begin();
    auto repl = r.rbegin();
    for (;
            it != v.end() && repl != r.rend() && *it < *repl;
            it++, repl++) {
        sum -= *it;
        sum += *repl;
    }

    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 4084
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
const long long maxn = 1e6;
struct Node{
	int ai,bi;
}node[maxn];
bool cmp(Node a,Node b)
{
	if(a.bi == b.bi) return a.ai < b.ai;
	return a.bi < b.bi;
}
int main(void)
{
	scanf("%d",&n);
	for(int i = 1;i<=n;i++)
		scanf("%d %d",&node[i].ai,&node[i].bi);
	sort(node+1,node+1+n,cmp);
//	int ans = 0;
//	for(int i = 1;i<=n;i++)
//	{
//		if((ans + node[i].ai) <= node[i].bi) ans += node[i].ai;
//		else{
//			puts("NO");
//			return 0;
//		}
//	}
//	puts("Yes");
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(ans+node[i].ai<=node[i].bi)
			ans+=node[i].ai;	
		else
		{
			puts("No");
			return 0;
		}
	}
//	printf("Yes\n");
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
ABC = list(map(int,input().split()))

cor = 0
mis = 0
for i in range(1,3):
	if ABC[0] ==ABC[i]:
		cor += 1
	if ABC[0] !=ABC[i]:
		mis += 1

if mis == 2:
	if ABC[1] == ABC[2]:
		print("Yes")
	else:
		print("No")

elif cor == 1 and mis == 1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
import sys
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
mylist = [i for i in range(-1,102)]
#print(mylist)
mymin = float('INF')
mynum = 0

for i in range(103):
    if abs(mylist[i] - X) < mymin and mylist[i] not in p:
        mymin = abs(mylist[i] - X)
        mynum = i
    #print(mymin, mylist[i])
print(mylist[mynum])

Measured memory_bytes: 9144
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <cstdlib>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MAX = 100000;
#define fi first
#define se second

int main() {
    ios::sync_with_stdio(false);
    string s;
    int cnt[4] = {0,0,0,0};
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'N') cnt[0]++;
        else if (s[i] == 'S') cnt[1]++;
        else if (s[i] == 'W') cnt[2]++;
        else cnt[3]++;
    }
    bool flag = false;
    if (cnt[0] != 0 && cnt[1] != 0 && cnt[2] != 0 && cnt[3] != 0) flag = true;
    else if (cnt[0] != 0 && cnt[1] != 0 && cnt[2] == 0 && cnt[3] == 0) flag = true;
    else if (cnt[0] == 0 && cnt[1] == 0 && cnt[2] != 0 && cnt[3] != 0) flag = true;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10**7)

    N,M=list(map(int,sys.stdin.readline().split()))
    dic=[[] for _ in range(N)]
    for i in range(M):
        x,y=list(map(int,sys.stdin.readline().split()))
        dic[x-1].append(y-1)


    dp=[0]*(N)
    def dfs(frm):
        if dp[frm]:
            return dp[frm]

        mx=0
        if not dic[frm]:
            return 0

        dp[frm]=max(dfs(val)+1 for val in dic[frm])

        return dp[frm]

    mx=0
    return max(dfs(x) for x in range(N))


print(main())


Measured memory_bytes: 109360
As = []
for i in range(3):
    As.append(list(map(int, input().split())))
N = int(input())
Bs = []
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if As[i][j] == b:
                As[i][j] = -1

for i in range(3):
    if set(As[i]) == {-1}:
        print("Yes")
        exit(0)
for j in range(3):
    if As[0][j] == -1 and As[1][j] == -1 and As[2][j] == -1:
        print("Yes")
        exit(0)

if set(As[i][i] for i in range(3)) == {-1}:
    print("Yes")
    exit(0)
if set(As[i][2-i] for i in range(3)) == {-1}:
    print("Yes")
    exit(0)
print("No")




Measured memory_bytes: 38384
#include<stdio.h>
int main (void){
	int a,b;
	int num;
	int ans=0;

	while(scanf("%d %d",&a,&b)!=EOF){
		num=a+b;
		while(num!=0){
			num=num/10;
			ans++;
		}
		printf("%d\n",ans);
		ans=0;
	}
		
	return 0;
}

Measured memory_bytes: 600
N,M = map(int,input().split())
if N >= 3 and M >= 3:
    ans = (N-2)*(M-2)
elif N == 2 or M == 2:
    ans = 0
elif N == 1 and M == 1:
    ans = 1
else:
    ans = max(N-2,M-2)

print(ans)


Measured memory_bytes: 2940
#include<cstdio>
using namespace std;
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==b)
    printf("Draw\n");
  else if(a==1||(b!=1&&a>b))
    printf("Alice\n");
  else
    printf("Bob\n");
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
int n,k,las,tims;
char s[MAXN],p[MAXN];
int main(){
	SF("%d%d",&n,&k);	
	SF("%s",s+1);
	for(int i=1;i<=n;i++)
		s[i]='B'-s[i];
	las=n;
	for(int i=1;i<=min(2*n,k);i++){
		if((s[tims+1]^(tims%2))==1){
			s[tims+1]^=1;
			continue;
		}
		else{
			if(las-tims==0&&n%2==1){
				s[tims+1]^=1;
				continue;	
			}
		}
		int add=(las-tims>=1);
		tims+=add;
		while(las-tims>=n%2+1&&(s[las]^(tims%2))==(n+tims-las+1)%2)
			las--;
	//PF("[%d]",las);
	}
	//PF("[%d %d]",las,tims);
	for(int i=1;i<=max(1,las-tims);i++)
		p[i]='B'-(s[i+tims]^(tims%2));
	for(int i=max(2,las-tims+1);i<=n;i++)
		p[i]='B'-(n-i+1)%2;
	if(k>=2*n){
		int t=(k-2*n)%2;
		if(n%2==1&&t==1)	
			p[1]='A'+'B'-p[1];
		for(int i=2;i<=n;i++)
			p[i]='B'-(n-i+1)%2;
	}
	PF("%s",p+1);
}

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

int main(void) {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  if (A1 + A2 + A3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
string S[100]; int n, l;
int main() {
	cin >> n >> l;
	for (int i = 0; i < n; i++)cin >> S[i];
	sort(S, S + n);
	for (int i = 0; i < n; i++)cout << S[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int f[10001][101][2];
char a[10001];
int main()
{
	int K,D,i,j,k;
	scanf("%s",a);
	scanf("%d",&D);
	K=strlen(a);
	f[0][0][1]=1;
	for(i=0;i<K;i++)
	{
		for(j=0;j<D;j++)
		{
			for(k=0;k<=9;k++)
			{
				f[i+1][(j+k)%D][0]=(f[i+1][(j+k)%D][0]+f[i][j][0])%1000000007;
			}
			for(k=0;k<=a[i]-'0';k++)
			{
				if(k==a[i]-'0')
					f[i+1][(j+k)%D][1]=(f[i+1][(j+k)%D][1]+f[i][j][1])%1000000007;
				else
					f[i+1][(j+k)%D][0]=(f[i+1][(j+k)%D][0]+f[i][j][1])%1000000007;
			}
		}
	}
	printf("%d",(f[K][0][0]+f[K][0][1]-1+1000000007)%1000000007);
	return 0;
}

Measured memory_bytes: 8192
import sys
f = sys.stdin

def take2(iterable):
    while True:
        yield next(iterable), next(iterable)
#外積
def cross(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real
# 線分13と線分24の交点を求める
def get_intersection(p1,p2,p3,p4):
    a1 = p4 - p2
    b1 = p2 - p3
    b2 = p1 - p2
    s1 = cross(a1, b2) / 2
    s2 = cross(a1, b1) / 2
    return p1 + (p3 - p1) * s1 / (s1 + s2)

n = int(f.readline())
for i in range(n):
    p1, p2, p3 = [x + y * 1j for x, y in take2(map(float, f.readline().split()))]
    p12 = (p1 + p2) / 2
    p13 = (p1 + p3) / 2
    pxy = get_intersection(p12,p13,p12 + (p2 - p1) * 1j,p13 + (p1 - p3) * 1j)
    r = abs(pxy - p1)
    print('{:.3f} {:.3f} {:.3f}'.format(pxy.real,pxy.imag,r))

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

int main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  if(A>=13) ans=B;
  else if(A<=5) ans=0;
  else ans=B/2;
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX_N 100

int main() {

    int n;
    cin >> n;

    int A[MAX_N], B[MAX_N], C[MAX_N];
    for ( int i=0; i<n; ++i ) A[i] = B[i] = C[i] = 0;

    int x, y, z, e;
    cin >> x;
    for ( int i=0; i<x; ++i ) {
	cin >> e;
	A[e-1] = 1;
    }

    cin >> y;
    for ( int i=0; i<y; ++i ) {
	cin >> e;
	B[e-1] = 1;
    }

    cin >> z;
    for ( int i=0; i<z; ++i ) {
	cin >> e;
	C[e-1] = 1;
    }

    int ans = 0;
    for ( int i=0; i<n; ++i ) {
	if ( (!A[i] && C[i]) || (B[i] && C[i]) ) ++ans;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int solve(int a[], int n, int vmin) {
    int ans = 0;
    int b[MAX], t[VMAX+1];
    bool p[MAX];
    for (int i = 0; i < n; i++) {
        b[i] = a[i];
        p[i] = false;
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++) t[b[i]] = i;
    for (int i = 0; i < n; i++) {
        if (p[i]) continue;
        int cur = i;
        int sum = 0;
        int m = VMAX;
        int an = 0;
        while (true) {
            p[cur] = true;
            an++;
            int v = a[cur];
            m = min(m, v);
            sum += v;
            cur = t[v];
            if (p[cur]) break;
        }
        ans += min(sum + (an - 2) * m, m + sum + (an + 1) * vmin);
    }

    return ans;
}

int main() {
    int n, a[MAX];
    int vmin = VMAX;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        vmin = min(vmin, a[i]);
    }
    cout << solve(a, n, vmin) << endl;
}



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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h.at(i);

	reverse(h.begin(), h.end());

	bool res = true;
	rep(i, n-1){
		if(h.at(i) >= h.at(i+1)) continue;
		else if(h.at(i) == h.at(i+1)-1) h.at(i+1) -= 1;
		else{
			res = false;
			break;
		}
	}

	if(res) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 200005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }



void solve()
{
   ld s,baki;
   cin >> s;
   cout << setprecision(14) << pow(s/3,3) << "\n";
}

int main()
{
    fast;
	int t;
	t=1;
	while(t--) solve();
	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;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc003.contest.atcoder.jp/tasks/agc003_b>
問題文============================================================
 高橋君は 1 から N までの整数のうちのどれかが書かれたカードをたくさん持っています。
 高橋君は整数 i が書かれたカードを Ai 枚持っています。
 
 2 枚のカードについて、それらに書かれた整数の差の絶対値が 1 以下のとき、これらをペアにすることができます。
 
 高橋君は、同じカードが複数のペアに使われないように、できるだけ多くのペアを作りたいです。
 高橋君が作れるペアの個数の最大値を求めてください。
 
=================================================================

解説=============================================================
 
 まず、ある整数i自身でペアを作ることができるのであれば作った方がいい。
 そして、残るようであれば i-1 または i+1で作ればいいが、
 これは、左(右）から順に流していくと
 
 左からなら i-1までのペアは作りきっているので、 i+1だけを見ればよく
 右からなら i+1までのペアは作りきっているので、 i-1だけを見ればいい
 
 よって、これをシミュレーションすればok
 (おそらく片方からのみで十分だが、念のため左右から行っている)
 
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N);
    for(auto&in:A) cin >> in;
    vector<ll> tA(A);
    
    ll cntl = 0;
    for(int i = 0; i < N - 1;i++){
        cntl += A[i]/2;
        A[i] -= A[i]/2 * 2;
        ll minv = min(A[i],A[i+1]);
        cntl += minv;
        A[i] -= minv; A[i+1] -= minv;
    }
    cntl += A[N-1]/2;
    
    A = tA;
    
    ll cntr = 0;
    for(int i = N - 1; i > 0; i--){
        cntr += A[i]/2;
        A[i] -= A[i]/2 * 2;
        ll minv = min(A[i],A[i-1]);
        cntr += minv;
        A[i] -= minv; A[i-1] -= minv;
    }
    cntr += A[0]/2;
    cout << max(cntl,cntr) << endl;
	return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int A = scan.nextInt();
			int B = scan.nextInt();
			int C = scan.nextInt();
			int K = scan.nextInt();
			
			if(K<=A) {
				System.out.println(K);
			}else if(K<=A+B) {
				System.out.println(A);
			}else {
				int c = K-A-B;
				System.out.println(A+c*-1);
			}
			
		}
		
		
	}
		

}


Measured memory_bytes: 35804
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();

		int[] x = new int[N];
		int[] y = new int[N];
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}
		int[][] grid = new int[W][H];
		for (int i=0; i<N; i++) {
			if (a[i] ==1) {
				for (int j=0; j<x[i]; j++) {
					for (int k=0;  k<H; k++) {
						grid[j][k] = 1;
					}
				}
			}else if (a[i] ==2) {
				for (int j=x[i]; j<W; j++) {
					for (int k=0;  k<H; k++) {
						grid[j][k] = 1;
					}
				}
			}else if (a[i] ==3) {
				for (int j=0; j<W; j++) {
					for (int k=0;  k<y[i]; k++) {
						grid[j][k] = 1;
					}
				}
			}else if (a[i] ==4) {
				for (int j=0; j<W; j++) {
					for (int k=y[i];  k<H; k++) {
						grid[j][k] = 1;
					}
				}
			}
		}
		int res = 0;
		for (int j=0; j<W; j++) {
			for (int k=0;  k<H; k++) {
				if (grid[j][k] == 0) res ++;
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int cnt = 0;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    for (int i = 0; i < (n - 2); i++) {
      if (a[i] == a[i + 1]) {
        a[i + 1] = a[i + 2] + 1;
        cnt++;
      }
    }

    if (a[n - 2] == a[n - 1]) {
      cnt++;
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 35916