akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
    //add x, [a, b)
    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, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    //getsum[a, b)
    ll getsum(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 = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    
    LazySegmentTree seg(vector<ll>(N, 0));
    while(Q--){
        int q, s, t, x;
        cin >> q;
        if(q == 0){
            cin >> s >> t >> x;
            --s;
            seg.add(s, t, x);
        }
        else{
            cin >> s >> t;
            --s;
            cout << seg.getsum(s, t) << endl;
        }
    }
}


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

const int64_t MOD = 1000000007;

int main() {
    int N; string S;
    cin >> N >> S;
    int64_t ans = 0;
    map<char, int> mp;
    for(auto &t : S) {
        int64_t tmp = 1;
        for(char c = 'a'; c <= 'z'; ++c) {
            if(t != c) tmp *= (mp[c] + 1), tmp %= MOD;
        }
        ans += tmp;
        ans %= MOD;
        mp[t]++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 512
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(v.rbegin(),v.rend());
    //c=0;
    set<ll> s;
    ll i;
    a=0;b=0;
    for(i=1;i<n;i++){
        c=1;
        d=1;
        if(f==1) {
            f=0;
            continue;
        }
        if(a!=0&&v[i-1]==v[i]){
        d++;    
        }
        if(d>=2) {
            b=v[i];
            break;
        }
        if(v[i-1]==v[i]) {
            c++;
        }
        if(c>=2) {
            a=v[i];
            c=0;
            f=1;
        }
    }
    cout<<a*b<<endl;

    return 0;
}


Measured memory_bytes: 3984
import java.io.*;
import java.util.regex.Pattern;
 
public class Main {

   public static void main(String args[]) {
   	

     BufferedReader Reader = new BufferedReader(new InputStreamReader(System.in));
try{
     String line = Reader.readLine();
   
          	if (line.indexOf("C")>-1 && line.indexOf("F")>-1 && line.indexOf("C")<line.lastIndexOf("F"))  {
          		System.out.println("Yes");
          	   } else  {
          	   	 System.out.println("No");
          	   	    } 
          	   	    
          	   	   } catch (IOException e) {
           								 System.out.println(e);
        												}
                }
}
          	  
          	   


      		


Measured memory_bytes: 8148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
	return 0;
}

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

int main(){
  map<int,bool> h;
  int q,n,cnt;
  cin >> q;
  while(q--){
    cin >> n;
    cnt = 0;
    h.clear();
    for(;;){
      int m = -1, k = 10;
      if(h[n]){
	cout << -1 << endl;
	break;
      }
      h[n] = true;
      if(n<10){
	cout << cnt << endl;
	break;
      }
      for(int i=0;i<5;i++){
	m = max(m,(n/k)*(n%k));
	k *= 10;
      }
      n = m; cnt++;
    }
  }
}

Measured memory_bytes: 1196
// J4180449 三宅亮輔
// 問題名
// - A Reward For A Carpenter
// 問題URL
// - https://onlinejudge.u-aizu.ac.jp/problems/0117
// 所要時間
// -
// 学んだこと
//
//
//

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

typedef long long ll;

ll n;

ll m;

ll a[101], b[101], c[101], d[101];

ll s, g, V, P;

ll D[21][21];

const ll INF = 0xfffffff;
vector<ll> v;

string S;

int main() {
    cin >> n >> m;
    for(ll i = 0; i < n; i++)
        for(ll j = 0; j < n; j++)
            D[i][j] = INF;

    for(ll i = 0; i < n + 1; i++)
        D[i][i] = 0;

    for(ll i = 0; i < m + 1; i++) {
        v.clear();
        cin >> S;
        for(ll j = 0; j < S.size(); j++) {
            if(S[j] == ',')
                v.push_back(j);
        }
        ll a, b, c, d;
        a = stoi(S.substr(0, v[0]));
        b = stoi(S.substr(v[0] + 1, v[1] - v[0] - 1));
        c = stoi(S.substr(v[1] + 1, v[2] - v[1] - 1));
        d = stoi(S.substr(v[2] + 1, v.size() - v[2] - 1));
        a--;
        b--;
        if(i < m) {
            D[a][b] = c;
            D[b][a] = d;
        } else {
            s = a;
            g = b;
            V = c;
            P = d;
        }
    }

    for(ll k = 0; k < n; k++)
        for(ll i = 0; i < n; i++)
            for(ll j = 0; j < n; j++)
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    cout << V - P - (D[s][g] + D[g][s]) << endl;
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main()
{   int n,m;
    while(true){
        cin >> n >> m;
        if(n==0&&m==0)break;
        int o[n],a[m];
        for(int i=0;i<n;i++)cin >>o[i];
        for(int i=0;i<m;i++)cin >> a[i];
        int b=0;
        int  co=0;
        for(int i=0;i<m;i++){
            co++;
            b+=a[i];
            if(b>=n)break;
            b+=o[b];
            if(b>=n)break;

        }
        cout << co << endl;
    }
    return 0;
}



Measured memory_bytes: 2988
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

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

    vector<double> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    double sum = accumulate(as.begin(), as.end(), 0.0, [](double a, double b) {
        return a + (1.0 / b);
    });
    cout << 1 / sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
using namespace __gnu_pbds;
 
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define  st first
#define  nd second
#define int long long
#define ull unsigned long long
 
 
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
 
const int  M    =  1000000007;
const int  maxn =  1001   ;
const long long   inf  =  1e18     ;
const long double eps = 1.084202e-19;
 
 
 
void solve(){
    int n , x , y ; 
    cin >> n >> x >> y ; 
    int a[n]={0};
    for(int i = 1 ; i<= n ; i++){
      for(int j = i+1 ; j<=n ; j++){
        int d = j-i;
        int l = max(x-i,i-x);
        int r = max(y-j,j-y);
        d = min(d,l+r+1);
        a[d]++;
      }
    }
    for(int i =1 ; i<=n-1 ; i++){
      cout<<a[i]<<"\n";
    }

}
 
int32_t main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int te;
      te = 1;
      while(te--){
          solve();
          //cout<<"\n";
      }
 
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 200020
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = acos(-1.0);
const int BLOCK = 333;

int dp[MAXN], N, nums[MAXN];

int solve(int K)
{
	if(dp[K] != -1) return dp[K];

	for(int i = 1; i <= N; i++)
		if(nums[i] <= K)
			if(!solve(K - nums[i]))
				return dp[K] = true;
			
	return dp[K] = false;
}

int main(int argc, char const *argv[])
{
	optimize;

	memset(dp, -1, sizeof dp);
	
	int K;

	cin >> N >> K;

	for(int i = 1; i <= N; i++)
		cin >> nums[i];

	cout << (solve(K) ? "First" : "Second") << endl;

	return 0;
}


Measured memory_bytes: 7460
#include <iostream>

using namespace std;

bool isprime(int n, int k = 2)
{
    if(n == 1) { return false; }
    
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return isprime(n, k + 1);
}

int main()
{
	int a, d, n, c;

	while (true)
	{
		cin >> a >> d >> n;

		if (n == 0) { break; }

		c = 0;

		while (c < n)
		{
			if (isprime(a))
			{
				c++;
			}
			
			a += d;
		}

		cout << a - d << endl;
	}

	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
 
int main() {
  ll n,m;
  cin>>n>>m;
  if (2*n>m) {
    cout<<m/2<<endl;
  }
  else {
    ll x=(m-2*n)/4;
    while (true) {
      if(2*(n+x)>m-2*x){
        break;
      }
      ++x;
    }
    cout<<n+x-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A.append(-1)
money = 1000
stocks = 0
down = True
for i in range(n):
    # 下がってるけど次上がる→買う
    if down and A[i+1] > A[i]:
        down = False
        stocks = money // A[i]
        money %= A[i]
    # 上がってるけど次下がる→売る
    elif not(down) and A[i+1] < A[i]:
        down = True
        money += A[i] * stocks
        stoks = 0
print(money)

Measured memory_bytes: 9204
using System;
using System.Linq;

namespace ABC125_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = ABT[0];
            var B = ABT[1];
            var T = ABT[2];
            Console.WriteLine(T / A * B);
        }
    }
}


Measured memory_bytes: 13268
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a+b+c>=22){
            System.out.println("bust");
        }else{
            
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 22612
#define MOD 1000000007
#define PI 3.14159265358979323846
#define inf 100000000000000
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
//#define int long long
#define _ <<" "<<
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#include <bits/stdc++.h>
 
 
using namespace std;

typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;

typedef vector<ii> vii;
#define int long long 


signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);

   	int n;cin>>n;
   	int a[n];
   	forn(i,n)cin>>a[i];

   	int ans =0 ;
   	forn(i,n)
   	{
   		for(int j=i+1;j<n;j++)
   		{
   			ans += (a[i] * a[j]);
   		}
   	}
   	cout<<ans;
    
}
    




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll K;
	cin >> K;
	vector<vll> M;
	ll i, j;
	for (i = 0; i < 15; i++) {
		vll ml(10);
		if (i == 0) {
			for (j = 0; j < 10; j++) {
				ml[j] = 1;
			}
			M.push_back(ml);
		}
		else{
			for (j = 0; j < 10; j++) {
				ll s = 0;
				if (j != 0) {
					s += M[i - 1][j - 1];
				}
				s += M[i - 1][j];
				if (j != 9) {
					s += M[i - 1][j + 1];
				}
				ml[j] = s;
			}
			M.push_back(ml);
		}
	}

	ll n = 0;
	ll p;
	vll ans;
	for (i = 0; i < 15; i++) {
		for (j = 1; j < 10; j++) {
			p = n;
			n += M[i][j];
			if (n >= K) {
				ans.push_back(j);
				while (i > 0) {
					i--;
					if (j > 0) {
						if (K <= p + M[i][j - 1]) {
							ans.push_back(j - 1);
							j--;
							continue;
						}
						p += M[i][j - 1];
					}
					if (K <= p + M[i][j]) {
						ans.push_back(j);
						continue;
					}
					p += M[i][j];
					ans.push_back(j + 1);
					j++;
				}
				for (auto& e : ans)cout << e;
				cout << endl;

				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
use proconio::input;
fn main() {
    input!{
        H:usize,
        W:usize,
        a:[String;H]
    }
    let mut top:String = "".to_string();
    for i in 0..W+2 {
        top.push('#');
    }
    println!("{}",top);
    for i in 0..H {
        println!("#{}#",a[i]);
    }
    println!("{}",top);
}

Measured memory_bytes: 2168
{-
 - `chebyshev n' returns the number of primes between n+1 and 2n.
 - e.g.:
 -   chebyshev 10 == 4    -- 11, 13, 17, 19
 -   chebyshev 13 == 3    -- 17, 19, 23
 -}

import Control.Monad  -- when

chebyshev :: Int -> Int
chebyshev n = length [x | x<-[n + 1 .. 2 * n], prime x]
 
prime :: Int -> Bool
prime n = [x | x<-fs, n`mod`x == 0] == []
  where fs = takeWhile (\x->x*x <= n) ([2] ++ [3,5..])
                         -- x*x is faster than x^2

main :: IO ()
main = do n <- readLn
          when (n /= 0) $ do
            print (chebyshev n)
            main

Measured memory_bytes: 4164
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int R[N],ans[N];
struct P{ int t,a,id; inline bool operator < (const P &b) const { return t<b.t; } }p[N];
int main()
{
	int s=gi(),n=gi(),m,i,t,k,l=0,r=s,d,sum=0;
	for (i=1;i<=n;i++) R[i]=gi();
	for (i=1,m=gi();i<=m;i++) p[i].t=gi(),p[i].a=gi(),p[i].id=i;
	sort(p+1,p+1+m);
	for (i=k=1,d=-1;i<=m;i++) {
		for (;k<=n&&R[k]<=p[i].t;k++,d*=-1) {
			l=max(0,l+d*(R[k]-R[k-1]));l=min(l,s);
			r=max(0,r+d*(R[k]-R[k-1]));r=min(r,s);
			sum+=d*(R[k]-R[k-1]);
		}
		t=max(p[i].a+sum,l);t=min(t,r);
		t=max(0,t+d*(p[i].t-R[k-1]));t=min(t,s);
		ans[p[i].id]=t;
	}
	for (i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define pb push_back
#define all(c) (c).begin() , (c).end()
const ll mod = 1e9 + 7;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    vvi a(n+1, vi(n+1));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    vi dp(1 << 21);
    dp[0] = 1;
    int i;
    for (i = 0; i < (1 << n); i++)
        for (int j = 0; j < n; j++)
            if (a[__builtin_popcount(i)][j] && ! (i & (1 << j)))
                dp[i | (1 << j)] = (dp[i] + dp[i | 1 << j]) % mod;
    cout << dp[i - 1] << endl;
    return 0;
}

Measured memory_bytes: 16640
####### 二項係数 C(n,k) mod pの計算 #######

MOD=10**9+7

## a**b mod p by 繰り返し二乗法 ##
def pow(a,b)
  return 1 if b==0
  return a*pow(a,b-1)%MOD if b%2==1
  return pow(a**2%MOD,b/2)
end

## n! mod p ##
def fact(n)
  ret=1
  n.times do |i|
    ret=ret*(i+1)%MOD
  end
  ret
end

## a**(-1) mod p ##
def inv(a)
  pow(a,MOD-2)%MOD
end

## C(n,k) mod p ##
def com(n,k)
  (fact(n)*inv(fact(k)))%MOD*inv(fact(n-k))%MOD
end

##########################################

def frac(k, n, m)
  f=1
  ff=1
  k.times do|i|
    ff*=i+1
    ff%=m
  end
  
k.times do |i|
  j=i+1
  f *= n-i
  f %= m
  
end
  f * inv(ff) % m
end




N,A,B=gets.split.map(&:to_i)
ans=pow(2,N)-1
ans+=MOD-frac(A,N,MOD)
ans+=MOD-frac(B,N,MOD)
puts ans%MOD

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

int plen,clen,width,cspace;
string fix(string name){
	while( name.size() < width ) name += ".";
	return name;
}
int main(){
	while(cin >> plen && plen){
		cin >> clen >> width >> cspace;
		string s;
		getline(cin,s);
		vector<string> ad;
		while( getline(cin,s) && s[0] != '?' ){
			if( s.size() && s[s.size()-1] == '\r' ) s = s.substr(0,s.size()-1);
			if(s=="")ad.push_back("");
			while(s.size()){
				ad.push_back(s.substr(0,min<int>(width,s.size())));
				
				s = s.substr(min<int>(width,s.size()));
			}
		}
		vector< vector< vector<string> > > output( (ad.size()+plen*clen-1) / (plen*clen) , vector< vector<string> > (plen,vector<string>(clen)));
		for(int i = 0 ; i < ad.size() ; i++){
			int p = i/(plen*clen);
			int x = i / plen % clen;
			int y = i % plen;
			output[p][y][x] = ad[i];
		}
		for(int i = 0 ; i < output.size() ; i++){
			for(int j = 0 ; j < output[i].size() ; j++){
				for(int k = 0 ; k < output[i][j].size() ; k++) cout << (k?string(cspace,'.'):"") << fix(output[i][j][k]);
				cout << endl;
			}
			cout << "#" << endl;
		}
		cout << "?" << endl;
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i, N) cin >> W[i];
    int left = W[0];
    int right = accumulate(W.begin() + 1, W.end(), 0);
    int ans = abs(right - left);
    for (int i = 1; i < N; i++) {
        left += W[i];
        right -= W[i];
        ans = min(abs(right - left), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
   int n; cin >> n;
   vector<int> t(n + 1), x(n + 1), y(n + 1);
   for(int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];

   bool ok = true;
   for(int i = 0; i < n; i++){
       int dx = x[i + 1] - x[i];
       int dy = y[i + 1] - y[i];
       int dt = t[i + 1] - t[i];

       if(abs(dx) + abs(dy) > dt || (abs(dx) + abs(dy)) % 2 != (dt % 2)){
           ok = false;
       }

       if(ok == false){
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;
}


Measured memory_bytes: 1408
using System;
class Program
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    long A = long.Parse(input[0]);
    long B = long.Parse(input[1]);
    string ans;
    
    if ((A + B) % 2 == 1)
    {
      ans = "IMPOSSIBLE";
    }
    else
    {
      ans = ((A + B) / 2).ToString();
    }
    
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11092
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias VDC = Tuple!(int, "v", int, "d", int, "c");

int[10^^5] MAX_D, COLS, MEMO;
int[][10^^5] G;
VDC[10^^5] QS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0] - 1;
        auto b = ab[1] - 1;
        G[a] ~= b;
        G[b] ~= a;
    }

    auto Q = readln.chomp.to!int;
    foreach_reverse (i; 0..Q) {
        auto vdc = readln.split.to!(int[]);
        QS[i] = VDC(vdc[0]-1, vdc[1]+1, vdc[2]);
    }

    void paint(int v, int d, int c) {
        if (MAX_D[v] >= d) return;
        MAX_D[v] = d;
        if (!COLS[v]) COLS[v] = c;
        foreach (w; G[v]) if (MAX_D[w] < d-1) paint(w, d-1, c);
    }

    foreach (q; QS) paint(q.v, q.d, q.c);

    foreach (i; 0..N) writeln(COLS[i]);
}

Measured memory_bytes: 24956
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    int N, M;
    cin >> N >> M;
    int counter[N];
    fill(counter, counter + N, 0);
    for(int i = 0; i < M; i++){
        int start, goal;
        cin >> start >> goal;
        counter[start - 1]++;
        counter[goal - 1]++;
    }
    for(int i = 0; i < N; i++){
        cout << counter[i] << endl;
    }
}

Measured memory_bytes: 256
N, A = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
dp = dict()
for cur in x:
    dp2 = dict()
    dp2[cur-A] = 1
    for val in dp:
        dp2[cur+val-A] = dp2.get(cur+val-A, 0) + dp[val]
    for val in dp2:
        dp[val] = dp.get(val, 0) + dp2[val]
print(dp.get(0, 0))

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

using namespace std;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;

int main(){

    int n;
    cin >> n;

    map<string,int> str;

    rep(i,n){
        string order;
        cin >> order;

        if(order == "insert"){
            string input;
            cin >> input;
            str[input] = 1;
        }else{
            string find;
            cin >> find;
            bool f = 0;
            yes(str[find]);
        }
    }
    

}


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

using namespace std;

const int MAXN = 200010;

int n;

int v[MAXN];
int mxPrefix[MAXN];
int mxSuffix[MAXN];

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

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	for(int i = 1 ; i <= n ; i++)
		mxPrefix[i] = max( mxPrefix[i - 1] , v[i] );

	for(int i = n ; i > 0 ; i--)
		mxSuffix[i] = max( mxSuffix[i + 1] , v[i] );

	for(int i = 1 ; i <= n ; i++)
		printf("%d\n",max( mxPrefix[i - 1] , mxSuffix[i + 1] ));
}

Measured memory_bytes: 3968
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
N, M = [int(_) for _ in input().split()]

# 隣接関係は隣接リストで管理する
lst_edge = [[] for _ in range(N)]

for _ in range(M):
  x, y = map(int, input().split()) 
  # 最初のindexをゼロにする
  lst_edge[x-1].append(y-1)
        
# dp[v] := ノードvを始点とした時の有向パスの長さの最大値
# -1 未訪問で初期化。
dp = [-1] * N

# メモ化再帰
def rec(v):
  # 既に更新済み
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v]
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1)
  dp[v] = ans
  return dp[v]
    
# 全ての点に対して更新する
ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)
    

Measured memory_bytes: 59056
n,m = map(int,input().split())
h = list(map(int,input().split()))
h_ngh = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    h_ngh[a] = max(h_ngh[a],h[b])
    h_ngh[b] = max(h_ngh[b],h[a])
cnt = 0
for i in range(n):
    if h_ngh[i] <h[i]:
        cnt+=1
print(cnt)

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

int  main()
{
    int t;
    cin>>t;
    vector<int >v,v1;
    for(int i=0;i<t;i++){
        int x;
        cin>>x;
        v.push_back(x);
        int y;
        cin>>y;
        v1.push_back(y);
    }
    int k=0,c=0;
    for(int i=0;i<t;i++)
    {
        if(v[i]==v1[i]&&(v[i+1]||v1[i+1]!=v[i]))

            c++;
             else
            c=0;
        if(c==3){
            k=1;
        break;
        }
        //cout<<c<<endl;
     //   cout<<v[i]<<" "<<v1[i]<<endl;
    }
    if(k==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(){
  int n,max,min,i,a;
  long int sum=0;
  max = -1000000;
  min = 1000000;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%",&a);
    if(max<a) max = a;
    if(min>a) min = a;
    sum+=a;
  }
  printf("%d %d %ld\n",min,max,sum);

  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
// use gp_hash_table<int,int,custom_hash> m;
// in place of map
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
// This custom_hash is for unordered_map 
// use map<int, int, custom_hash> mp;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
  //  	freopen("input.txt", "r", stdin);
    //	freopen("output.txt", "w", stdout);
	//#endif
	ll n,m;
	cin>>n>>m;
	// ll a[n];
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	ll sum[n];
	sum[0] = a[0];
	repa(i,1,n){
		sum[i] = sum[i-1] + a[i];
		// cout<<sum[i]<<" ";
	}
	ll r = 1e12;
	ll l = 0;
	ll ans,count;
	ll mid;
	while(r - l > 1){
		// cout<<r<<l<<"\n";
		mid = (r+l)/2; 
		count = 0;
		ans = 0;
		for(int i=0;i<n;i++){
			auto it = lower_bound(all(a),mid-a[i]);
			int take = a.end() - it;
			int leave = it - a.begin();
			count += take;
			ans += sum[n-1]+  take*(a[i]); // l ya r
			if(leave >= 1)ans -= sum[leave-1];
		}
		if(count >= m)l = mid;
		else r = mid;
	}
	// cout<<ans;
	cout<<ans - (count - m)*l;// l ya r
	return 0;
}

Measured memory_bytes: 1792
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)


int main(){
    int n;
    cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];
    int num_sm = ((n - 1) * (n - 2)) / 2;
    pair< int, int> sm[num_sm];
    int num = 0;
    sort(l, l + n);
    for(int i = 0; i < n - 2; i++){
        for(int j =  i + 1; j < n - 1; j++){
            sm[num].first = l[i] + l[j];
            sm[num].second = j;
            num++;
        }
    }
    // rep(i, num_sm) cout << sm[i].first << " " << sm[i].second.first << " " << sm[i].second.second << endl;
    
    int ans = 0;
    for(int i = 0; i < num_sm; i++){
        int mx = lower_bound(l, l + n, sm[i].first) - l - 1;
        int mn = sm[i].second;
        ans += mx - mn;

        

    }
    cout << ans << endl;   
}

Measured memory_bytes: 15872
#include <stdio.h>
int main (int argc, char * argv[])
{
    int r;//行
    int c;//烈
    int a[102][102] ={0};//値
    scanf("%d %d",&c,&r);
    for(int j=0;j<c;j++){
        for(int i=0;i<r;i++){
//            a[j][i]=0;
            scanf("%d",&a[j][i]);
            a[j][r] += a[j][i];
            a[c][i] += a[j][i];
            a[c][r] += a[j][i];
        }
    }
    for(int j=0;j<=c;j++){
        for(int i=0;i<=r;i++){
            printf("%d",a[j][i]);
            if(i!=r){
            printf(" ");
            }
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	map<string ,ll>a;
	ll ans=0;
	for(ll i=0;i<n;i++){
		string now;
		cin>>now;
		a[now]++;
		ans=max(ans,a[now]);
	}
	for(auto itr=a.begin();itr!=a.end();itr++){
		ll val=itr->second;
		if(val==ans){
			cout << itr->first<<endl;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 25216
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int s[5];
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		s[0]=a;
		s[1]=b;
		s[2]=c;
		sort(s,s+3);
		if(s[2]==(s[0]+s[1])){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
/*
やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん
（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。
今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、
そこでしこたま酒を飲んでからやりはじめたんや。
3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。
しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。
浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、
先に兄ちゃんがわしの口に糞をドバーっと出して来た。
それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、
3人で出した糞を手で掬いながらお互いの体にぬりあったり、
糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。
しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。
浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると
けつの穴が糞と小便でずるずるして気持ちが良い。
にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。
糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。
それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、
糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。
やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。
ああ～～早く糞まみれになろうぜ。
岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や
糞まみれでやりたいやつ、至急、メールくれや。
土方姿のまま浣腸して、糞だらけでやろうや。
*/

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Main m = new Main();
    }
    
    public Main(){
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();
        int num = 0;
        for(int i = A; i <= B; i++){
            if(i / 1000 == (i % 10) * 10 + i % 100 / 10)
                num++;
        }
        System.out.println(num);
    }
    
}


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

N, M = map(int, input().split())
ab = []
cd = []

# 学生の位置の取得
for i in range(N):
    tmp = list(map(int, input().split()))
    ab.append(tmp)

# チェックポイントの位置の取得
for i in range(M):
    tmp = list(map(int, input().split()))
    cd.append(tmp)


# 変数初期化
tmp_d = 0

# 学生を1人ずつ評価
for i in range(N):
    # 最小番号、最小距離の初期化
    min_d = 2 * (10 ** 8)
    min = 1
    for j in range(M):
        # マンハッタン距離の算出
        tmp_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_d > tmp_d:
            min_d = tmp_d
            min = j + 1
            #print('min', min)
    print(min)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, d, x, ans=0;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
        ans += (d+a.at(i)-1)/a.at(i);
    }
    cout << ans+x;
}

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

int		main(void)
{
	int n, k, x, y;

	cin >> n >> k >> x >> y;
	if (n > k)
		cout << x * k + y * (n - k) << endl;
	else
		cout << x * n << endl;
}


Measured memory_bytes: 256
def abc075_d():
    n, k = map(int, input().split())
    P = []
    xarr = []
    yarr = []
    for _ in range(n):
        x, y = (int(x) for x in input().split())
        P.append((x, y))
        xarr.append(x)
        yarr.append(y)
    xarr.sort()
    yarr.sort()

    def count_inside(xi, xj, yi, yj)->int:
        res = 0
        for x, y in P:
            if xi <= x and x <= xj and yi <= y and y <= yj:
                res += 1
        return res

    ans = 5*10**18
    for s, xi in enumerate(xarr):
        for xj in xarr[s+1:]:
            for t, yi in enumerate(yarr):
                for yj in yarr[t+1:]:
                    if count_inside(xi, xj, yi, yj) >= k:
                        area = (xj - xi) * (yj - yi)
                        ans = min(ans, area)
    print(ans)

if __name__ == '__main__':
    abc075_d()

Measured memory_bytes: 74144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N), C(N);
    rep(i,N){
        cin >> P[i];
        P[i]--;
    }
    rep(i,N){
        cin >> C[i];
    }
    ll ans = -1e18;
    /*rep(i,N){
        ll cur = i;
        ll sum = 0;
        vector<ll> s;
        while(1){
            cur = P[cur];
            s.push_back(C[cur]);
            sum += C[cur];
            if(cur == i) break;
        }
        ll l = s.size();
        ll t = 0;
        rep(j,l){
            t += s[j];
            if(j+1 > K) break;
            ll now = t;
            if(sum > 0){
                ll e = (K-(j+1))/l;
                now += sum*e;
            }
            cmax(ans, now);
        }
    }
    cout << ans << endl;*/
    
    rep(i,N){
        ll cur = i; 
        ll cnt = 0;
        //ll sum = 0;
        ll sum = 0;//C[P[cur]];
        vector<ll> memo(N);
        //vector<ll> S(N+10);
        //memo[P[cur]] = 1;
        //S[cnt] = sum;
        //cmax(ans,sum);
        //cnt++;
        //cur = P[cur];
        rep(j,min(N-1+10,K)){
            if(memo[P[cur]] != 0){
                break;
            }
            sum += C[P[cur]];
            cnt++;
            //S[cnt] = sum;
            memo[P[cur]] = 1;
            cur = P[cur];
            //cmax(ans,sum);
        }
        /*        if(N >= K){
            continue;
        }
        /*
        while(1){
            if(memo[cur] > 0){
                break;
            }
            memo[cur] = 1;
            sum += C[cur];
            //memo[P[cur]] = cnt;
            cur = P[cur];
            cnt++;
        }*/
        //cmax(ans, sum);
        //if(K <= N) continue;
        //cnt = memo[cur] - memo[P[cur]] + 1;
        //sum = S[memo[cur]];
        /*ll t = 0;
        cur = P[i];
        rep(j,cnt){
            t += C[cur];
            if(j+1 > K)break;
            ll now = t;
            if(sum > 0){
                ll e = (K-(j+1))/cnt;
                now += sum*e;
            }
            cur = P[cur];
            cmax(ans,now);
        }*/
        /*
        if(sum <= 0) continue;
        */
        ll q = ll(K/cnt) - 1;
        ll r = K%cnt;
        if(q < 0){
            cnt = 0;
            sum = 0;
            cur = i;
        }else{
            if(sum > 0){
                sum = sum*q;
            }else{
                sum = 0;
            }
            cur = i;
        }
        rep(j, cnt+r){
            sum += C[P[cur]];
            cur = P[cur];
            cmax(ans, sum);
        }        
        cmax(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    for (int i = N; i >= 0; i = i - 7) {
        if (i == 0) {
            cout << "Yes\n";
            return 0;
        }
        if (i % 4 == 0) {
            cout << "Yes\n";
            return 0;
        }
    }
    
    cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 256
s = input()
s = list(s)
judge = len(s)
todo = 0
if judge % 2 == 0:
    todo = judge / 2
else:
    todo = (judge-1) / 2
count = 0
for i in range(int(todo)):
    num = 0 - (i+1)
    if s[i] != s[num]:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    int n;
    cin>>n;
    vector<string>s(n);
    vector<ll>t(n);
    for(int i=0;i<n;i++)cin>>s[i]>>t[i];
    ll ans = 0;
    string x;
    cin>>x;
    bool flag =false;
    for(int i=0;i<n;i++){
        if(!flag){
            if(s[i] == x)flag=true;
        }
        else ans+=t[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

bool solve(){
    int h, w, n;
    cin >> h >> w >> n;
    if(h==0) return false;
    vector<vector<int> > a(h, vector<int>(w)), dp(h+1, vector<int>(w+1));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    dp[0][0] = n-1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]==0){
                dp[i+1][j] += (dp[i][j]+1)/2;
                dp[i][j+1] += dp[i][j]/2;
            }else{
                dp[i+1][j] += dp[i][j]/2;
                dp[i][j+1] += (dp[i][j]+1)/2;
            }
        }
    }
    int ni=0, nj=0;
    while(ni<h && nj<w){
        if((a[ni][nj]+dp[ni][nj]%2)%2 == 0) ni++;
        else nj++;
    }
    cout << ni+1 << " " << nj+1 << endl;
    return true;
}

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



Measured memory_bytes: 10756
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                A[j][k] = 0
ans = 'No'
for i in range(3):
    if all(c == 0 for c in [A[i][0], A[i][1], A[i][2]]):
        ans = 'Yes'
for i in range(3):
    if all(c == 0 for c in [A[0][i], A[1][i], A[2][i]]):
        ans = 'Yes'
if all(c == 0 for c in [A[0][0], A[1][1], A[2][2]]):
    ans = 'Yes'
if all(c == 0 for c in [A[0][2], A[1][1], A[2][0]]):
    ans = 'Yes'
print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, C;
  cin >> N >> K;
  C = 1;
  for(int i = 0; i < N; i++){
    if(C * 2 < C + K){
      C *= 2;
    }else{
      C += K; 
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int len = 0, maxlen = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            len++;
            if (len > maxlen) {
                maxlen = len;
            }
        } else if (len > 0) {
            len = 0;
        }
    }
    cout << maxlen << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long int
#define maxn 100000
using namespace std;

int f[maxn+5];
int v[maxn+5];

int getfa(int x)
{
    if(f[x]==x)
    return x;
    int t=f[x];
    f[x]=getfa(f[x]);
    v[x]=v[x]+v[t];
    return f[x];
}

void link(int x,int y,int d)
{
    int fx,fy;
    fx=getfa(x);
    fy=getfa(y);
    if(fx!=fy)
    {
        f[fy]=fx;
        v[fy]=v[x]+d-v[y];
    }
}
int main()
{
    int n,m;
    cin>>n>>m;

    for(int i=1;i<=n;i++)
    f[i]=i;
    int flag=1;
    int l,r,d;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d",&l,&r,&d);
        if(getfa(l)!=getfa(r))
        {
            link(l,r,d);
        }
        else
        {
            ///printf("%d %d\n",v[l],v[r]);
            if(-v[l]+v[r]!=d)
                flag=0;
        }
    }

    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1024
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,K=map(int,input().split())
if K==0:
    print(N**2)
    exit()
count=0
for b in range(K+1,N+1):
    count+=(N//b)*(b-K)
    count+=max(N%b-(K-1),0)
print(count)


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll N;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N;
  ll max = 0;
  ll count = 0;
  for (ll i = 0; i < N; i++) {
    ll h;
    cin >> h;
    if (max <= h) {
      count++;
      max = h;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
 
int _;

//========================================================================
int a[maxn];
//========================================================================
int main()
{
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++) 
    {
        ans+=a[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3812
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

vi divisor(int n){  // 約数全列挙{{{
  vi p,q;
  for(int i=1; i*i<=n; i++){
    if (n%i==0){
      p.pb(i);
      if (i*i!=n) q.pb(n/i);
    }
  }
  reverse(all(q));
  p.insert(p.end(), all(q));
  return p;
}//}}}

int solve(){
  int n;cin>>n;
  int m;cin>>m;

  auto ds = divisor(m);
  dump(ds);

  int ans = 1;
  each(d, ds){
    int p = m/d;
    if (p>=n) chmax(ans, d);
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256