akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(),x.end()
#define val(x) ((apos ? x.a : -x.a) + (bpos ? x.b : -x.b) + (cpos ? x.c : -x.c))
struct triple {ll a,b,c;};
vector<triple> og;
int main () {
 int n,m; ll ans = 0;
 scanf ("%d %d",&n,&m);
 og.resize(n);
 for (auto &au : og) scanf ("%lld %lld %lld",&au.a,&au.b,&au.c);
 for (int mask = 0; mask <= 7; mask++) {
   bool apos = mask&1, bpos = (mask>>1)&1, cpos = (mask>>2)&1;
   sort(all(og),[&](triple aa, triple bb) {return val(aa) > val(bb);});
   ll tot = 0;
   for (int i = 0; i < m; i++) tot += val(og[i]);
   ans = max(ans,tot);
 }
 printf ("%lld\n",ans);
 return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

ll fact[252521];
ll ifact[252521];
ll modpow(ll a,ll b){
    ll r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}
ll modinv(ll a){
    return modpow(a,MOD-2);
}
ll comb(int a, int b){
    if(a<0 || b<0 || a-b<0)return 0ll;
    return fact[a]*ifact[b]%MOD*ifact[a-b]%MOD;
}

int n,a,b,c;

int main(){
    scanf("%d%d%d%d",&n,&a,&b,&c);
    fact[0] = 1;
    FOR(i,1,252521)fact[i]=fact[i-1]*i%MOD;
    ifact[252521-1] = modinv(fact[252521-1]);
    FORR(i,1,252521)ifact[i-1]=ifact[i]*i%MOD;
    ll ans = 0;
    FOR(end,n,2*n){
        ll add = 0;
        ll pa = a*modinv(a+b)%MOD;
        ll pb = b*modinv(a+b)%MOD;
        // a win
        ll p = comb(end-1,n-1)*modpow(pa,n-1)%MOD*modpow(pb,end-n)%MOD*pa%MOD;
        // b win
        p += comb(end-1,n-1)*modpow(pb,n-1)%MOD*modpow(pa,end-n)%MOD*pb%MOD;
        // if(c==0){
        //     ans += p*end%MOD;
        //     continue;
        // }
        // added turns
        ll pc = c*modinv(a+b+c)%MOD;
        ll ex = 1*modinv(1+MOD-pc)%MOD*end%MOD;
        ans += p*ex%MOD;
        ans %= MOD;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
  
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int x=0,y=0,z=0;
  for(int i=1;i<=n;i++){
    for(int j=x;j<n;j++){
      if(a[j]==i){
        x=j+1;
        y++;
        break;
      }
      y=0;
    }
    if(y==0){
      z=i-1;
      break;
    }
    if(x==n){
      z=i;
      break;
    }
  }
  
  if(z==0) cout << -1 << endl;
  else cout << n-z << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int ar[3];
    for(int i=0;i<3;++i) cin>>ar[i];
    sort(ar,ar+3);
	cout<<accumulate(ar,ar+3,0)-ar[2];
    return 0;
}

Measured memory_bytes: 3644
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())


using namespace std;



int main(){
	int D,x,y;
	vector<int> one,two;
	int ans=0;
	cin>>D;
	cin>>x;
	rep(i,x){
		char a;
		int p;
		cin>>a>>p;
		if(a=='D')one.push_back(p);
	}
	cin>>y;
	rep(i,y){
		char b,c;
		int p;
		cin>>b>>c>>p;
		if(b=='D'&&c=='D')two.push_back(p);
	}
	sort(all(one),greater<int>());
	sort(all(two),greater<int>());
	rep(i,D/2+1){
		int s=0;
		rep(j,min<int>(D-2*i,one.size()))s+=one[j];
		rep(j,min<int>(i,two.size()))s+=two[j];
		ans=max(ans,s);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
    int n, m, wa = 0, ac = 0, p;
    string s;
    cin >> n >> m;
    int res[n][2] = {};
    for(int i=0; i<m; i++){
        cin >> p >> s;
        if(s == "WA") res[p-1][1]++;
        else if(res[p-1][0] == 0){
            res[p-1][0]++;
            ac++;
            wa += res[p-1][1];
        }
    }
    printf("%d %d\n", ac, wa);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,k,d;
int main(){
	cin>>x>>k>>d;
	if(x>0&&x/d>=k)return cout<<x-k*d<<endl,0;
	else if(x>0)k-=x/d,x%=d;
	if(x<0&&(-x)/d>=k)return cout<<-x-k*d<<endl,0;
	else if(x<0)k-=(-x)/d,x=-(x%d);
	if(k%2==0)cout<<x;
	else cout<<d-x;
} 
//-5 2 3

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

int main() {
   ll H, W; cin >> H >> W;

   ll ans = 1e18;
   for (int k = 0; k < 2; k++) {
      for (int i = 1; i < H; i++) {
         ll a = i*W;
         ll b = (W/2) * (H-i);
         ll c = ((W+1)/2) * (H-i);
         ans = min(ans, abs(max({a, b, c}) - min({a, b, c})));

         b = ((H-i)/2) * W;
         c = ((H-i+1)/2) * W;
         ans = min(ans, abs(max({a, b, c}) - min({a, b, c})));
      }
      swap(H, W);
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
num = input()

op_count = 3

for i in range(2**op_count):
    op = ["-"] * op_count
    for j in range(op_count):
        if (i >> j & 1):
            op[j] = "+"

    equ = ""

    for n_i,o_i in zip(num,op + [""]):
        equ += n_i + o_i
    if(eval(equ) == 7):
        print(equ + "=7") 
        break


Measured memory_bytes: 9000
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            Func<long, long> func = null;
            var memo = new Dictionary<long, long>();
            func = (i) =>
            {
                if (i == 0)
                    return 2;
                if (i == 1)
                    return 1;

                if (memo.ContainsKey(i))
                {
                    return memo[i];
                }

                memo[i] = func(i - 1) + func(i - 2);
                return memo[i];
            };
            Console.WriteLine(func(N)); 
        }

        public static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0)
                throw new Exception("0未満");

            if (start > stop || (start == 0 && stop == 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        public static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        public static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        public static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IList<int> ReadIntInputs()
        {
            return Read().Split(' ').Select(int.Parse).ToList();
        }

        public static int ReadInt()
        {
            return int.Parse(Read());
        }

        public static IList<string> ReadInputs()
        {
            return Read().Split(' ').ToList();
        }
    }
}

Measured memory_bytes: 13152
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main(){
    string b = "  kstnhmyrw";
    string input;

    cin >> input;
    for(int i=0; i < input.size(); i+=2){
        string str = input.substr(i, 1);
        if(atoi(str.c_str()) != 0){
            if(atoi(str.c_str()) != 1) cout << b[atoi(str.c_str())];
            switch(input[i+1]){
                case 'T':
                    cout << 'a';
                    break;
                case 'L':
                    cout << 'i';
                    break;
                case 'U':
                    cout << 'u';
                    break;
                case 'R':
                    cout << 'e';
                    break;
                case 'D':
                    cout << 'o';
                    break;
            }
        }
        else {
            switch(input[i+1]){
                case 'T':
                    cout << "wa";
                    break;
                case 'D':
                    cout << "wo";
                    break;
                case 'U':
                    cout << "nn";
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 1196
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll N, ll M, std::vector<ll> a, std::vector<ll> b) {
  vector<ll> e(N);
  for (int i = 0; i < N; i++) {
    e.at(i) = i;
  }

  ll count = 0;

  do {
    if (e.at(0) == 0) {
      bool result = true;
      rep(i, N - 1) {
        bool found = false;
        rep(j, M) {
          if ((e.at(i) == a.at(j) && e.at(i + 1) == b.at(j)) ||
              (e.at(i + 1) == a.at(j) && e.at(i) == b.at(j))) {
            found = true;
            break;
          }
        }
        result = result && found;
        if (!result)
          break;
      }

      if (result)
        count++;
    }
  } while (next_permutation(all(e)));

  cout << count << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  std::vector<ll> a(M);
  std::vector<ll> b(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    a[i]--;
    b[i]--;
  }
  solve(N, M, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

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

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

int main()
{
  string s;
  cin>>ws>>s;
  bool okpal=true;
  int n=s.size()-1;
  for(int i=0;i<=n-i;i++){
    if(s[i]!=s[n-i]){
      okpal=false;
      break;
    }
  }
  if(okpal==false){
    cout<<"No";
    return 0;
  }
  okpal=true;
  int nmij=(n-1)/2;
  for(int i=0;i<=nmij-i;i++){
    if(s[i]!=s[nmij-i]){
      okpal=false;
      break;
    }
  }
  if(okpal==false){
    cout<<"No";
    return 0;
  }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    low = []
    high = []
    for i in range(n):
        a,b = map(int, input().split())
        low.append(a)
        high.append(b)

    low.sort()
    high.sort()
    if n % 2:
        print(high[(n+1)//2-1] - low[(n+1)//2-1] + 1)
    else:
        hh = (high[(n)//2-1] + high[(n)//2]) / 2
        ll = (low[(n)//2-1] + low[(n)//2]) / 2
        print(int((hh - ll)*2) + 1)


if __name__ == "__main__":
    resolve()


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

namespace ConsoleApp15
{
    class Class211
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 1;
            int max = H[0];
            for(int i = 1; i < N; i++)
            {
                if (max <= H[i])
                {
                    ans++;
                    max = H[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    int c1 = 0, c2 = 0;
    for (char c: s) if (c == '.') c2++;
    int ans = 999999;
    for (char c: s) {
        ans = min(ans,c1+c2);
        if (c == '#') c1++;
        else c2--;
    }
    ans = min(ans,c1+c2);
    cout << ans << '\n';
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct LazySegTree {
	vector<ll> node, lazy;
	int n;
	
	LazySegTree(int _n) {
		n = 1;
		while (n < _n) n *= 2;
		
		node.resize(2 * n - 1, 0);
		lazy.resize(2 * n - 1, 0);
	}
	
	void eval(int k, int l, int r) {
		if (lazy[k] == 0) return;
		node[k] += lazy[k];
		
		if (r - l > 1) {
			lazy[k * 2 + 1] += lazy[k] / 2;
			lazy[k * 2 + 2] += lazy[k] / 2;
		}
		
		lazy[k] = 0;
	}
	
	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] += (r - l) * x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, k * 2 + 1, l, (l + r) / 2);
			add(a, b, x, k * 2 + 2, (l + r) / 2, r);
			node[k] = node[k * 2 + 1] + node[k * 2 + 2];
		}
	}
	
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return node[k];
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return vl + vr;
	}
};

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]);
	
	// K - 1 回で ON になる区間が知りたい
	
	REP(i, K - 1) {
		bool all = true;
		REP(j, N) if (A[j] != N) all = false;
		if (all) break;
		
		vector<int> sum(N + 1);
		REP(j, N) {
			int l = j - A[j];
			chmax(l, 0);
			sum[l]++;
			
			int r = j + A[j] + 1;
			chmin(r, N);
			sum[r]--;
		}
		REP(j, N) sum[j + 1] += sum[j];
		REP(j, N) A[j] = sum[j];
	}
	vector<int> sum(N + 1);
	REP(j, N) {
		int l = j - A[j];
		chmax(l, 0);
		sum[l]++;
		
		int r = j + A[j] + 1;
		chmin(r, N);
		sum[r]--;
	}
	REP(j, N) sum[j + 1] += sum[j];
	REP(j, N) A[j] = sum[j];
	
	REP(i, N) printf("%d%c", A[i], i + 1 == N ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 5036
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
#define ull unsigned long long  
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
//ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	int k,a,b;
 	cin>>k>>a>>b;
 	for(int i=a;i<=b;i++)
 	{
 		if(i%k==0){
 			cout<<"OK";
 			return 0;
		 } 
	 } 
 	cout<<"NG";
}

Measured memory_bytes: 3604
#include <deque>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>

using namespace std;

string a;

int t,op,f;

char c;

deque<char>de;

int main(void) {
	cin >> a;
	for(int i = 0; i < a.length(); i ++) {
		de.push_front(a[i]);
	}
	scanf("%d",&t);
	int ans = 0;
	while(t --) {
		scanf("%d",&op);
		if(op == 1) {
			ans ++;
		} else {
			scanf("%d",&f);
			getchar();
			scanf("%c",&c);
			if(ans % 2 == 1) {
				if(f == 1) {
					de.push_front(c);
				} else {
					de.push_back(c);
				}
			} else {
				if(f != 1) {
					de.push_front(c);
				} else {
					de.push_back(c);
				}
			}
		}
	}
	if(ans % 2 == 1)
		for(int i = 0; i < de.size(); i ++) {
			printf("%c",de[i]);
		}
	else {
		for(int i = de.size() - 1; i >= 0; i --) {
			printf("%c",de[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 960
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define PI 3.14159265358979323846
using namespace std;
using ll = long long;

int gcd(int a, int b) {
    if (a % b == 0) {
        return b;
    }
    else {
        return gcd(b, a % b);
    }
}
int main() {
    int k;
    cin >> k;
    int ans = 0;

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                ans += gcd(gcd(i, j), l);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    int P, Q, R;
    cin >> P >> Q >> R;

    int ans, M;
    
    M = max(P, Q);
    M = max(M, R);

    ans = P + Q + R - M;

    cout << ans;

    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
    double r;
    cin >> r;
    r *= 2 * M_PI;
    printf("%.6f\n", r);
}


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

int t[110];

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

    int n;
    cin>>n;

    int sum=0;

    for(int i=0;i<n;i++)
    {
        cin>>t[i];
        sum+=t[i];
    }

    int m;
    cin>>m;

    for(int i=0;i<m;i++)
    {
        int p,x;
        cin>>p>>x;

        cout<<(sum-t[p-1]+x)<<"\n";
    }

    return 0;
}


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

using namespace std;

const int N = 2000006;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

int fat[N], ifat[N];

int C(int n, int k) {
	if(n < k) return 0;
	return mul(mul(fat[n], ifat[k]), ifat[n - k]);
}

int main() {
	fat[0] = 1;
	for(int i = 1; i < N; i++) fat[i] = mul(i, fat[i - 1]);
	ifat[N - 1] = fexp(fat[N - 1]);
	for(int i = N - 2; i >= 0; i--) ifat[i] = mul(i + 1, ifat[i + 1]);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	int ans = 0;

	ans = add(ans, add(C(r2 + c2 + 1 + 1, c2 + 1), mod - C(r1 + c2 + 1, c2 + 1)));
	ans = add(ans, mod - add(C(r2 + c1 + 1, c1), mod - C(r1 + c1, c1)));
	
	printf("%d\n", ans);
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	int k;
	cin >> k >> s;
	
	if( s.size() <= k ) {
		cout << s << endl;
	} else {
		for(int i = 0; i < k; ++i) {
			cout << s[i];
		}
		
		cout << "..." << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int i, j, k = 0;

	scanf("%d", &i);
	scanf("%d", &j);

	if (i < j) {
		for (k = 1; k <= j; k++) {
			printf("%d", i);
		}
	}

	else if (j < i) {
		for (k =1; k <= i; k++) {
			printf("%d", j);
		}
	}

	else if(j=i){
		for(k = 1; k <= i; k++){
			printf("%d", j);

		}
	}
}

Measured memory_bytes: 128
#coding:utf-8

n = list(map(int,input().split()))
alist = [list(map(int,input().split())) for i in range(n[0])]

res = 0

for i in range(n[0]):
	if n[1] <= alist[i][0] and n[2] <= alist[i][1]:
		res += 1
		
print(res)

Measured memory_bytes: 3188
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	map<string,int> M;

	REP(i,N){
		M[in<string>()]++;
	}

	out("AC x",M["AC"]);
	out("WA x",M["WA"]);
	out("TLE x",M["TLE"]);
	out("RE x",M["RE"]);
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <map>
using namespace std;
int main(void){

    int N, M, A, B;
    map<int, int> bridge_Count;
    cin >> N >> M;
    
    for(int i = 1; i <= N; i++){
        bridge_Count[i] = 0;
    }
    
    for(int j = 0; j < M; j++){
        cin >> A >> B;
        bridge_Count[A]++;
        bridge_Count[B]++;
    }
    
    for(auto p : bridge_Count){
        auto value = p.second;
        cout << value << endl;
    }
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 400005
#define P 1000000007
#define ll long long
#define inf ((ll)1e18)
using namespace std;
 
int n;ll A,B,a[N];
struct seg
{
	int val[N],tg[N];
	void mdy(int x,int l,int r,int p)
	{
		tg[x]=p;val[x]=(ll)p*(r-l+1)%P;
	}
	void dn(int x,int l,int r)
	{
		if (tg[x]!=-1)
		{
			int mid=l+r>>1;
			mdy(x<<1,l,mid,tg[x]);
			mdy(x<<1|1,mid+1,r,tg[x]);
			tg[x]=-1;
		}
	}
	void up(int x)
	{
		val[x]=(val[x<<1]+val[x<<1|1])%P;
	}
	void mdy(int k,int l,int r,int x,int y,int p)
	{
		if (x<=l&&r<=y)
		{
			mdy(k,l,r,p);
			return;
		}
		int mid=l+r>>1;dn(k,l,r);
		if (x<=mid) mdy(k<<1,l,mid,x,y,p);
		if (y>mid) mdy(k<<1|1,mid+1,r,x,y,p);
		up(k);
	}
	void add(int k,int l,int r,int x,int p)
	{
		if (l==r)
		{
			val[k]=(val[k]+p)%P;
			return;
		}
		int mid=l+r>>1;dn(k,l,r);
		if (x<=mid) add(k<<1,l,mid,x,p);
		else add(k<<1|1,mid+1,r,x,p);
		up(k);
	}
	int qry(int k,int l,int r,int x,int y)
	{
		if (x<=l&&r<=y) return val[k];
		int mid=l+r>>1,ans=0;dn(k,l,r);
		if (x<=mid) ans+=qry(k<<1,l,mid,x,y);
		if (y>mid) ans+=qry(k<<1|1,mid+1,r,x,y);
		return ans%P;
	}
	void mdy(int l,int r,int p)
	{
		mdy(1,0,n,l,r,p);
	}
	void add(int x,int y)
	{
		add(1,0,n,x,y);
	}
	int qry(int l,int r)
	{
		return qry(1,0,n,l,r);
	}
}TA,TB;
int main()
{
	scanf("%lld%lld%lld",&n,&A,&B);
	
	TA.add(0,1);
	TB.add(0,1);
	a[0]=-inf;
	scanf("%lld",&a[1]);
	for (int i=2;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		int t1=lower_bound(a+0,a+i,a[i]-A+1)-a-1,t2=lower_bound(a+0,a+i,a[i]-B+1)-a-1;
		int s1=TA.qry(0,t2),s2=TB.qry(0,t1);
		if (a[i-1]+A>a[i]) TA.mdy(0,n,0);
		if (a[i-1]+B>a[i]) TB.mdy(0,n,0);
		TA.add(i-1,s2);TB.add(i-1,s1);
	}
	printf("%lld\n",(TA.val[1]+TB.val[1])%P);
	
}

Measured memory_bytes: 8188
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int N, M, Q;

int a[50];
int b[50];
int c[50];
int d[50];

int ans;

void dfs(vector<int>& A) {
  if (A.size() == N) {
    int tmp = 0;
    for (int i = 0; i < Q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        tmp += d[i];
      }
    }
    ans = max(ans, tmp);
    return;
  }

  const int prev = A.empty() ? 1 : A.back();
  for (int i = prev; i <= M; i++) {
    A.push_back(i);
    dfs(A);
    A.pop_back();
  }
}

int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  ans = 0;
  vector<int> A;
  dfs(A);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  int x;
  cin>>x;
  if(x>=30) { cout<<"Yes"; }
  else { cout<<"No"; }
  //} 
  return 0;
}

Measured memory_bytes: 3652
import numpy as np

dish_min = []
 
for i in range(5):
   dish_min.append(int(input()))
    
p = [i%10 for i in dish_min]
pp = [(i-1)%10 for i in dish_min]
x = np.argmin(pp)

for i in range(5):
  if i != x and p[i]:
  	dish_min[i] += (10 - p[i])

print(sum(dish_min))

Measured memory_bytes: 12396
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        long A = 1, B = 1;
                        for (int i = 0; i < N; i++) {
                                long X = sc.nextInt(), Y = sc.nextInt();
                                long num;
                                A = ((A - 1) / X + 1) * X;
                                B = Math.max(B, A / X * Y);
                                B = ((B - 1) / Y + 1) * Y;
                                A = Math.max(A, B / Y * X);
                        }
                        System.out.println(A + B);
                }
        }
}

Measured memory_bytes: 13816
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// http://agc019.contest.atcoder.jp/tasks/agc019_b

int64_t run()
{
  string str;
  cin >> str;

  DEBUG('z' - 'a' + 1);
  const int64_t n = str.size();
  vector<int64_t> cnt(26);
  for(const auto i: str) ++ cnt[i - 'a'];

  int64_t out = 1 + n * (n + 1) / 2;
  for(const auto x: cnt)
    out -= x * (x + 1) / 2;

  return out;
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << run();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 720
import sys
input = sys.stdin.readline
import random

a,b=map(int,input().split())
while a!=b:
    if a>b:
        a-=b
    else:
        b-=a
    if a==b:
        break
def prime_factorize(s):
    l = []
    while s % 2 == 0:
        l.append(2)
        s //= 2
    f = 3
    while f * f <= s:
        if s % f == 0:
            l.append(f)
            s //= f
        else:
            f += 2
    if s != 1:
        l.append(s)
    return l
m=prime_factorize(a)
m=set(m)
print(len(m)+1)
#print(m)

Measured memory_bytes: 4208
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[1100];
int dp[510][1010];
int next[1010];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		int ret=1;
		for(int i=0;i<510;i++)for(int j=0;j<=a;j++)
			dp[i][j]=0;
		for(int i=0;i<a;i++)dp[b[i]][i]=1;
		for(int i=0;i<a;i++){
			next[i]=-1;
			for(int j=i+1;j<a;j++){
				bool ok=true;
				int S=b[i];
				int T=b[j];
				if(S>T)swap(S,T);
				int U=T/S;
				if(T%S)ok=false;
				while(U%2==0)U/=2;
				if(U!=1)ok=false;
				if(ok){
					next[i]=j;break;
				}
			}
		}
	//	for(int i=0;i<a;i++)printf("%d ",next[i]);
		int sum=0;
		for(int i=0;i<a;i++)sum+=b[i];
		for(int i=0;i<=sum;i++){
			int t=i%505;
			int nt=(t+501)%505;
			for(int j=0;j<=a;j++)dp[nt][j]=0;
			for(int j=0;j<a;j++){
				if(!dp[t][j])continue;
				if(~next[j]&&i%b[next[j]]==0){
					dp[(t+b[next[j]])%505][next[j]]=max(dp[(t+b[next[j]])%505][next[j]],dp[t][j]+1);
				}
				if(~next[j]){
					dp[t][next[j]]=max(dp[t][next[j]],dp[t][j]);
				}
			}
			for(int j=0;j<a;j++){
				if(ret>=dp[t][j]||i%b[j])continue;
				int q=i/b[j];
				while(q%2==0)q/=2;
				if(q==1)ret=dp[t][j];
			}
		}
		printf("%d\n",ret);
	}
}

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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;

    if (abs(B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        cout << min(A - 1, N - B) + 1 + (B - A) / 2 << endl;
    }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
	int N, A;
	cin >> N >> A;

	bool can = false;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= 20; j++) {
			if (i + 500 * j == N && N >= 1) {
				can = true;
			}
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 2000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
bool B[MN+5][MN+5];
int n,m,head[MN+5],Len[MN+5][MN+5],cnt=0,fa[MN+5][MN+5],ans;
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void dfs(int x,int y)
{
    for(int i=head[x];i;i=e[i].next) if(e[i].to!=fa[y][x])
        fa[y][e[i].to]=x,dfs(e[i].to,y);
}
inline void Clear(int x,int y){B[x][y]=B[y][x]=0;}
void dfs2(int x,int fa,int y,int z,vector<pair<int,int> >&todo)
{
    if(B[x][y]) {Clear(x,y),todo.push_back(make_pair(z,x));return;}
    for(int i=head[x];i;i=e[i].next) 
        if(e[i].to!=fa) dfs2(e[i].to,x,y,z,todo);
}
void dfs3(int x,int fa,int y)
{
    if(B[x][y]) ++ans,y=x;
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa) dfs3(e[i].to,x,y);
}
void Solve(int x,int y)
{
    if(B[x][y]) return;
    for(int i=y;i!=x;i=fa[x][i]) if(B[i][y]) {Solve(x,i);return;}
    for(int i=x;i!=y;i=fa[y][i]) if(B[i][x]) {Solve(i,y);return;}
    vector<pair<int,int> >todo;
    dfs2(y,fa[x][y],x,y,todo);dfs2(x,fa[y][x],y,x,todo);
    B[x][y]=B[y][x]=1;
    for(int i=0;i<todo.size();++i) Solve(todo[i].first,todo[i].second);
}
int main()
{
    n=read();m=read();
    for(int i=1;i<n;++i) ins(read(),read());
    for(int i=1;i<=n;++i) dfs(i,i);
    while(m--) Solve(read(),read());
    for(int i=1;i<=n;++i) dfs3(i,0,i);
    cout<<ans/2;
	return 0;
}

Measured memory_bytes: 21632
#include<stdio.h>
#define N 100
int selectionSort(int *,int);
int main(){
  int A[N];
  int i,n,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&A[i]);
  }
  c = selectionSort(A,n);
  for(i=0;i<n;i++) {
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",c);

  return 0;
}

int selectionSort(int *A,int n) {
  int i,j,tmp,minj,c=0;
  for(i = 0;i < n;i++) {
    minj = i;
    for(j = i;j < n;j++) {
      if(A[j] < A[minj]) {
	minj = j;
      }
    }
    if(i != minj){
    	tmp = A[i];
	A[i] = A[minj];
	A[minj] = tmp;
	c++;
    }
  }
  return c;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<int,int>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

vector<vector<ll>> child;

ll dfs(ll p) {
	vector<ll> v;
	REP(i,child[p].size()) v.pb(dfs(child[p][i]));
	sort(ALL(v)); reverse(ALL(v));
	ll ret = 0;
	REP(i,v.size()) {
		ret = max(ret, (i + 1) + v[i]);
	}
	return ret;
}

/* --------------------------------------- */
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	child.resize(n);
	REP(i,n - 1) {
		ll a;
		cin >> a;
		a--;
		child[a].pb(i + 1);
	}
	cout << dfs(0) << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 13568
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc110_d
{
	class Program
	{
		const int mod = 1000000007;
		static long Calc_pow(long x, long pow)
		{
			if (pow == 0) return 1;
			long a = Calc_pow(x, pow / 2);
			a = a * a % mod;
			if (pow % 2 == 1) a *= x;
			return a % mod;
		}
		static long[] fact;
		static void Init_fact(int n)
		{
			fact = new long[n]; fact[0] = 1;
			for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % mod;
		}
		static long Combination(long n, long r)
		{
			return fact[n] * Calc_pow(fact[r] * fact[n - r] % mod, mod - 2) % mod;
		}
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			List<int> primes = new List<int>();
			double sq = Math.Sqrt(x[1]);
			for (int i = 2; i < sq + 1; i++)
			{
				int a = 0;
				while (x[1] % i == 0)
				{
					x[1] /= i; a++;
				}
				if (a > 0) primes.Add(a);
			}
			if (x[1] > 1) primes.Add(1);
			long ret = 1;
			Init_fact(1000000);
			foreach (var num in primes)
			{
				ret *= Combination(x[0] + num - 1, num);
				ret %= mod;
			}
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 21204
# D - Lunlun Number

import queue

K = int(input())

Q = queue.Queue()
for i in range(1, 10):
    Q.put(i)
ans = 0
for _ in range(K):
    ans = Q.get()
    if ans % 10 != 0:
        Q.put((10 * ans) + (ans % 10) - 1)
    Q.put((10 * ans) + (ans % 10))
    if ans % 10 != 9:
        Q.put((10 * ans) + (ans % 10) + 1)

print(ans)

Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
#define intl long long int 

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,n;
	intl m,k;
	cin>>n>>m>>k;
	vector<intl> ar(n);
	vector<intl> br(m);
	vector<intl> brr(m);
	for(i=0;i<n;i++){
		 cin>>ar[i];
	}
	for(i=0;i<m;i++){
		cin>>br[i];
		brr[i]=br[i];
		if(i!=0){
			brr[i]+=brr[i-1];
		}
	}
	intl ans=0;
	intl x=0;
	for(i=-1;i<n;i++){
		if(i!=-1)
		x+=ar[i];
		// printf("i x are %lld %lld\n",i,x);
		if(k>=x){
			intl k1=k-x;
			// printf("k1 is %lld\n",k1);
			intl mn1=0;
			intl mx1=m-1;
			intl b=(mn1+mx1)/2;
			while(b>mn1){
				if(brr[b]>k1){
					mx1=b;
					b=(mn1+mx1)/2;
				}
				else{
					mn1=b;
					b=(mn1+mx1)/2;
				}
			}
			intl tmp;
			if(brr[mx1]<=k1){
				tmp=(i+mx1+2);
			}
			else if(brr[mn1]<=k1){
				tmp=(i+mn1+2);
			}
			else{
				tmp=(i+1);
			}
			// printf("tmp is %lld\n",tmp);
			ans=max(ans,tmp);
		}
		else{
			break;
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 7952
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

bool comp(int a, int b) {
    return abs(a) > abs(b);
}

const int MOD = 1e9 + 7;
const double EPS = 1e-9;

bool can(int a, int b, int k) {
    if (b % 2) {
        b--;
    }
    if (k % 2) {
        return a + b >= k && a > 0;
    } else {
        return a + b >= k;
    }
}

int n, k;
vector<int> arr;
vector<double> pa;
vector<double> pb;
vector<int> ra;
vector<int> rb;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    arr.resize(n);
    int a = 0;
    int b = 0;
    int z = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        if (arr[i] > 0) {
            a++;
        } else if (arr[i] < 0) {
            b++;
        } else {
            z++;
        }
    }
    sort(arr.begin(), arr.end(), comp);
    if (can(a, b, k)) {
        pa.push_back(0);
        pb.push_back(0);
        ra.push_back(1);
        rb.push_back(1);
        for (int x : arr) {
            if (x > 0) {
               double z = log(x);
                pa.push_back(pa.back() + z);
                ra.push_back((ra.back() * x) % MOD);
            } else if (x < 0) {
              double z = log(-x);
                pb.push_back(pb.back() + z);
                rb.push_back((rb.back() * -x) % MOD);
            }
        }
        double fin = -1;
        int ans = INT_MIN;
        for (int i = 0; i <= k; i += 2) {
            if (i < pb.size() && k - i < pa.size()) {
                if (pb[i] + pa[k - i] > fin) {
                    fin = pb[i] + pa[k - i];
                    ans = (rb[i] * ra[k - i]) % MOD;
                }
            }
        }
        cout << ans << '\n';
    } else if (z > 0) {
        cout << 0 << '\n';
    } else {
        int res = 1;
        for (int i = n - 1; i >= n - k; i--) {
            res = (((res * arr[i]) % MOD) + MOD) % MOD;
        }
        cout << res << '\n';
    }

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 11816
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    print(n/3);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s; cin >> s;
	if (s[0] != s[1] || s[0] != s[2] || s[1] != s[2]) {
		cout << "Yes" << '\n';
	}
	else cout << "No" << '\n';


	


}




Measured memory_bytes: 256
N,M=map(int,input().split())
li=[1]*N
ri=[0]*N
ri[0]=1

for i in range(M):
    x,y=map(int,input().split())
    if ri[x-1]==1:
        ri[y-1]=1
    li[x-1]-=1
    li[y-1]+=1
    if li[x-1]==0:
        ri[x-1]=0
print(sum(ri))

Measured memory_bytes: 10412
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int x;
    cin >> x;

    if(x<100){
        cout << 0 << endl;
        return 0;
    }

    int y=x%100;
    int pc=y/5;
    y=y%5;
    int ame=y/4;
    y%=4;
    int cake=y/3;
    y%=3;
    int cookie=y/2;
    y%=2;
    int sand=y;

    if(pc+ame+cake+cookie+sand<=x/100){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


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

void view(vector<int64_t> rem) {
  cout << "rem = {";
  for (int i = 0; i < 13; i++) {
    cout << rem[i] << ", ";
  }
  cout << "}" << endl;
}

void view_5(vector<int64_t> rem) {
  cout << "rem[5] = " << rem[5] << endl;
}

// 数が書いてある場合
void proceed_constant(vector<int64_t> &rem, int exp, int digit) {
  int a = digit;
  for (int j = 1; j <= exp % 6; j++) {
    a *= 10;
  }
  a = a % 13;

  vector<int64_t> temp(13);
  for (int i = 0; i < 13; i++) {
    temp[(i + a) % 13] = rem[i];
  }
  rem = temp;
//  view_5(rem);
}

// ?の場合
void proceed_variant(vector<int64_t> &rem, int exp) {
  vector<int> a = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  for (int i = 0; i < 10; i++) {
    for (int j = 1; j <= exp % 6; j++) {
      a[i] *= 10;
    }
    a[i] = a[i] % 13;
  }
  
  vector<int64_t> temp(13);
  for (int i = 0; i < 13; i++) {
    for (int x : a) {
      temp[(i + x) % 13] += rem[i];
    }
  }
  for (int i = 0; i < 13; i++) {
    temp[i] = temp[i] % 1000000007;
  }
  rem = temp;
//  view_5(rem);
}

int main() {
  string S;
  cin >> S;
  int n = S.size(); // 桁数
  // 1の位から検討していくため逆順にする
  reverse(S.begin(), S.end());
//  cout << S << endl;
  
  // 整数の個数を13で割った余りごとに数えるための配列
  vector<int64_t> rem = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  
  for (int k = 0; k < n; k++) {
    if (S[k] != '?') {
      proceed_constant(rem, k, S[k] - '0'); // 文字'0'と整数0は一致しないので一工夫
    } else {
      proceed_variant(rem, k);
    }
  }
  
  cout << rem[5];
}

Measured memory_bytes: 512
import sys

for s in sys.stdin:
	stack = []
	for s in s.split():
		if s in ('+','-','*','/'):
			stack.append(eval('{2}{1}{0}'.format(stack.pop(),s,stack.pop())))
		else:
			stack.append(float(s))
	print '{:.6f}'.format(stack.pop())

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

int main() {
  int n,m;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n;i++){
    cin >> s.at(i);
  }
  cin >> m;
  vector<string> t(m);
  for(int i=0; i<m; i++){
    cin >> t.at(i);
  }
  
  int i;
  int sum=1,ans=0;

  vector<string> u;
  for(i=0;i<n;i++){
    
    for(int j=i+1;j<n;j++){
      if(s.at(i) == s.at(j)){
        sum++;
      }
    }
    for(int l=0;l<m;l++){
      if(s.at(i)==t.at(l)){
      sum--;
      }
    }
      
    if(ans<sum){
      ans = sum;
      //u=s.at(i);

    }
    sum=1;
  }
  
    cout << ans << endl;
}


         
    
  

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

const long long INF = 1LL << 60;
int N, K;
long long h[100010];
long long dp[100010];

long long rec(int i) {
    if(dp[i] < INF) return dp[i];
    if(i == 0) return 0;
    long long res = INF;
    for(int k = 1; k <= K; ++k) {
        if(i >= k) res = min(res, rec(i-k) + abs(h[i] - h[i-k]));
    }
    return dp[i] = res;
}

int main() {
    cin >> N >> K;
    for(int i = 0; i < N; ++i) cin >> h[i];
    for(int i = 0; i < N; ++i) dp[i] = INF;
    
    cout << rec(N-1) << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	ll sum = 0;
	ll n; cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		sum += (ll)i;
	}
	cout << sum << '\n';


}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int plan1 = a * n;
  int ans;
  
  if (plan1 < b)
    ans = plan1;
  else
    ans = b;
  
  cout << ans << endl;
}
  

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

using namespace std;

#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i <= n; i++)
#define frm(i, n) for(int i = n-1; i >= 0; i--)

#define pb push_back
#define f first
#define s second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> ponto;
typedef vector<vector<ll>> matrix;

#define mem(v, k) memset(v, k, sizeof(v));

#define db cout << "Debug" << endl;

#define mp make_pair
#define pq priority_queue

#define mx(a, b) a = max(a, b);
#define mod(a, b) a = a%b;

#define MAXN 100010
#define MOD 1000000007
#define MAXL 30
#define ROOT 1
#define INF 987654321

int main(){
	ios::sync_with_stdio(false);
	string s;
	cin >> s;

	int a = -1, z = -1;
	fr(i, s.size()){
		if(s[i] == 'A'){
			if(a == -1) a = i;
		}
		else if(s[i] == 'Z'){
			z = i;
		}
	}

	if(a==-1 || z == -1){
		cout << 0 << endl;
	}
	else{
		cout << z - a + 1 << endl;
	}
}


Measured memory_bytes: 720