akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

#define N ((ll)2505)

ll get(ll a, ll b)
{
    return a*N+b;
}

void dijk(vector<pair<ll,ll>> v[], ll n, ll x,vector<ll> &dis)
{
    set<pair<ll,ll>> st;
    
    st.insert(mp(0,x));
    dis[x] = 0;
    
    while(st.size() > 0)
    {
        ll temp = st.begin()->second;
        st.erase(st.begin());
        
        for(auto it = v[temp].begin();it!=v[temp].end();it++)
        {
            ll v1 = it->first;
            ll wt = it->second;
            
            if(dis[v1]>dis[temp] + wt)
            {
                dis[v1] = dis[temp] + wt;
                st.insert(mp(dis[v1],v1));
            }
        }
    }
    
}

int main()
{
   FAST/**/
   ll n;
   ll m,s;
   cin>>n>>m>>s;
   s = min(s,N-1);
   ll tot = n*N;
   
   vector<pair<ll,pair<ll,ll>>> v[n];
   rep(m)
   {
       ll a,b,c,t;
       cin>>a>>b>>c>>t;
       a--,b--;
       v[a].pb(mp(b,mp(c,t)));
       v[b].pb(mp(a,mp(c,t)));       
   }
   
   pair<ll,ll> hold[n];
   rep(n)
        cin>>hold[i].ff>>hold[i].ss;

   vector<pair<ll,ll>> gr[tot];
   rep(n)
   {
       for(ll j=0;j<N;j++)
       {
           ll t2 = j+hold[i].ff;
           t2 = min(t2,N-1);
           t2 = get(i,t2);
           gr[get(i,j)].pb(mp(t2,hold[i].ss));
       }
       autoit(v[i],it)
       {
           for(ll j=0;j<N;j++)
           {
               if(j-it->ss.ff<0)
                    continue;
               /*if(i == 0 && j == 4 && it->ff == 2)
                    cout<<"gotit "<<it->ss.ss<<"\n";*/
               ll n1 = get(i,j);
               ll n2 = get(it->ff,min(N-1,j-it->ss.ff));
               ll wt = it->ss.ss;
               
               gr[n1].pb(mp(n2,wt));
               //cout<<"b/w "<<n1<<" "<<n2<<" = "<<wt<<'\n';
           }
       }
   }
   
   vector<ll> dis(tot,inf);
   dijk(gr,tot,get(0,s),dis);
   vector<ll> ans(n,inf);
   rep(tot)
   {
       ans[i/N] = min(ans[i/N],dis[i]);
   }
   
   rep(n)
        if(i>0)
            cout<<ans[i]<<"\n";
    
   return 0;        
}  
  
   

Measured memory_bytes: 26348
#include <stdio.h>

void trace(int A[], int N) {
    int i;
    for (i = 0; i < N - 1; i++) printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
}

int bubbleSort(int A[], int N) {
    int i, j, flag, count;
    i = 0; // 整列済み部分の末尾のインデックス
    count = 0; // 交換回数
    flag = 1;
    while (flag) {
        flag = 0;
        for (j = N - 1; j > i; j--) {
            if (A[j-1] > A[j]) {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                count++;
                flag = 1;
            }
        }
        i++;
    }
    return count;
}

int main(void) {
    int i;
    int N; // 入力数
    int A[100]; // ソートする配列
    int count;
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", A + i);
    count = bubbleSort(A, N);
    trace(A, N);
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 1984
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), e = 0, no = N, max = Integer.MIN_VALUE, t = 0;
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		Set<Integer> s = new HashSet<Integer>();
		while (no-->0) {
			e = sc.nextInt();
			s.add(e); s.add(e-1); s.add(e+1);
			m.put(e, m.get(e)==null ? 1 : m.get(e)+1);
			m.put(e-1, m.get(e-1)==null ? 1 : m.get(e-1)+1);
			m.put(e+1, m.get(e+1)==null ? 1 : m.get(e+1)+1);
		}
		for (int d : s) if (m.get(d)>max) max = m.get(d);
		System.out.println(max);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 69720
#include <bits/stdc++.h>
#define pb push_back
#define wrln cout<<'\n';
using namespace std;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) ;
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n/x+(n%x!=0))*t;
}





Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
# define p 1000000007
int main() {
	// your code goes here
	int n;
	cin>>n;
	long long a[n],sum=0,res=0;
	for(long long i=0;i<n;i++){
	cin>>a[i];
	sum+=a[i];
	}
	for(long long i=n-1;i>=0;i--)
	{
		sum-=a[i];
		res+=((sum%p)*a[i]);
      res%=p;
	}
	cout<<res;
	return 0;
}

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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int ans = 0;

  for (int i = 0;i <= a;i++) {
    for (int j = 0;j <= b;j++) {
      for (int k = 0;k <= c;k++) {
	if (500*i+100*j+50*k == x) ans++;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
int main(){
  int n;
  cin >> n;
  int a[n + 1], b[n + 1], c[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int dp[n + 1][3] = {};
  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
    dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
    dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
  return 0;
}


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

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

int a, b;

int main()
{
    int i, j;

    scanf("%d%d", &a, &b);
    if(a>=13) printf("%d", b);
    else if(a>=6) printf("%d", b/2);
    else printf("0");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int x, n;
    cin>>x>>n;
    bool dame[102]={};
    for(int i=0; i<n; i++){
        int p; cin>>p;
        dame[p]=1;
    }
    P mn=P(1000, 1000);
    for(int i=0; i<=101; i++){
        if(!dame[i]) mn=min(mn, P(abs(i-x), i));
    }
    cout<<mn.second<<endl;
	return 0;
}


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

using namespace std;




int main() {

		int n, m, h[100000],ans=0;
		bool yokunai[100000] = {};

		vector<pair<int, int> > pairs(200000);

		cin >> n >> m;

		for (int i = 0; i < n; i++) {
			cin >> h[i];
		}
		for (int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
          	a--;
          	b--;

			if (h[a] >= h[b])yokunai[b] = true;
			if (h[b] >= h[a])yokunai[a] = true;
          
		}

		for (int i = 0; i < n; i++) {

			if (yokunai[i] == false)ans++;
		}
		

		cout << ans;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, M; cin >> N >> M;
  vector<vll> demands(N);
  rep(_, M){
    ll a, b;
    cin >> a >> b;
    demands[b-1].push_back(a-1);
  }

  set<ll> islands;
  ll ans = 0;
  rep(i, N){
    for(ll d : demands[i]){
      if(islands.find(d) != islands.end()){
        // cout << i << " " << d << endl;
        ans++;
        islands.clear();
        break;
      }
    }
    islands.insert(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6520
#include <cstdio>
using namespace std;

const int MAXN = 100005;

int N, L;
int a[MAXN];
	
int main() {
	scanf("%d%d", &N, &L);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);

	int pos = 0;
	for (int i = 1; i < N; i++)
		if (a[i] + a[i + 1] >= L) pos = i;
	
	if (!pos) {
		puts("Impossible");
		return 0;
	}	
	
	puts("Possible");
	for (int i = 1; i < pos; i++)
		printf("%d\n", i);
	for (int i = N - 1; i >= pos; i--)
		printf("%d\n", i);
	
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
  string s;
  int j, o, i, ans;
  j = o = i = ans = 0;
  cin >> s;
  for(int k = 0;k < s.size(); k++){
    if(s[k] == 'J' && !o && !i) j++;
    else if(s[k] == 'O' && j && !i) o++;
    else if(s[k] == 'I' && o) i++;
    else{
      if(j >= o && o <= i) ans = max(ans, o);
      j = o = i = 0;
      if(s[k] == 'J') j++;
    }
  }
  if(j >= o && o <= i) ans = max(ans, o);
  cout << ans << endl;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
int read() {
	char ch = getchar();
	int x = 0, flag = 1;
	for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}
void write(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

const int Maxn = 100009;
int n, a[Maxn], head[Maxn], e, k;

struct edge {
	int to, nxt;
}g[Maxn << 1];

void add(int u, int v) {
	g[++e] = (edge){v, head[u]}, head[u] = e;
}

int ans;
void init() {
	clar(head, -1);
	n = read();k = read(); ans = (a[1] = read()) != 1;
	a[1] = 1;
	rep (i, 2, n) add(a[i] = read(), i);
}


int dfs(int u, int dep) {
	int res = dep;
	for (int i = head[u]; ~i; i = g[i].nxt) {
		int v = g[i].to;
		res = max(dfs(v, dep + 1), res);
	}
	if (a[u] != 1 && res - dep == k - 1) {
		++ans;
		return 0;
	}
	return res;
}

void solve() {
	dfs(1, 0);
	cout << ans << endl;
}

int main() {
//	freopen("bosky.in", "r", stdin);
//	freopen("bosky.out", "w", stdout);

	init();
	solve();

#ifdef Qrsikno
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>

using ll = long long;

using field = std::vector<std::vector<char>>;
using point = std::pair<int, int>;

int solve(int h, int w, const field& f) {
    //各マスへの最短距離を格納
    std::vector<std::vector<int>> memo(h, std::vector<int>(w));
    const point direction[]{
        {1,0},{0,1},{-1,0},{0,-1}
    };

    point goal = point(h, w);

    //スタートを格納
    std::queue<point> q;
    q.push(point(1, 1));
    while (!q.empty()) {
        //先頭から一マス取り出す
        point cur = q.front(); q.pop();

        if (cur.first == goal.first && cur.second == goal.second) {
            return memo[cur.first - 1][cur.second - 1];
        }

        for (auto& p : direction) {
            //次のマスに移動
            point next = cur;
            next.first += p.first;
            next.second += p.second;

            //範囲内かチェック
            if (next.first > h || next.first < 1 || next.second > w || next.second < 1)continue;

            //次のマスを調べる
            char c = f[next.first - 1][next.second - 1];
            if (c != '.')continue;
            //未訪問か調べる
            if (memo[next.first - 1][next.second - 1] != 0)continue;

            q.push(next);
            memo[next.first - 1][next.second - 1] = memo[cur.first - 1][cur.second - 1] + 1;
        }
    }

    return -1;
}

int main() {
    int H, W;
    std::cin >> H >> W;
    field c(H, std::vector<char>(W));
    int black = 0;

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            char input;
            std::cin >> input;
            c[h][w] = input;
            if (input == '#')black++;
        }
    }

    int pass = solve(H, W, c);
    if (pass == -1) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << H * W - black - (pass + 1) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            string date = cin.Read;
            WriteLine("2018"+date.Substring(4,6));
        }
    }
       
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

const int INF = 1 << 28;

int main(){
  bool boin[256] = {false};
  boin['a'] = boin['i'] = boin['u'] = boin['e'] = boin['o'] = true;
  for (;;) {
    int n;
    std::cin >> n;
    if (n == 0) {
      break;
    }
    int m = 0;
    std::vector<std::string> list;
    for (int i = 0; i < n; ++i) {
      std::string atom;
      std::cin >> atom;
      std::stringstream ss;
      bool flag = false;
      for (int j = 0; j < atom.length(); ++j) {
        if (j == 0 || flag) {
          ss << atom[j];
        }
        flag = boin[atom[j]];
      }std::set<std::string> set;
      std::string dst = ss.str();
      list.push_back(dst);
      m = std::max(m, (int)dst.length());
    }
    int ans = -1;
    for (int k = 1; k <= m; ++k) {
      std::set<std::string> set;
      for (int i = 0; i < n; ++i) {
        std::string next = list[i].substr(0, std::min((int)list[i].length(), k));
        set.insert(next);
      }
      if (set.size() == n) {
        ans = k;
        break;
      }
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<bool> done(N);
  vector<int> penalty(N);
  int ac = 0;
  rep(i, M) {
    int p; string S;
    cin >> p >> S; p--;
    if(!done[p]) {
      if(S == "WA") penalty[p]++;
      else {
        done[p] = true;
        ac++;
      }
    }
  }
  int pena = 0;
  rep(i, N) pena += penalty[i] * done[i];
  cout << ac << ' ' << pena << "\n";
  return 0;
}


Measured memory_bytes: 3692
n=int(input())
w=[input() for _ in range(n)]
flag=0
for i in range(n):
  if flag==1:
    break
  for j in range(i+1,n):
    if w[i]==w[j]:
      flag=1
      break
for i in range(n-1):
  if flag==1:
    break
  if w[i][-1]!=w[i+1][0]:
    flag=1
    break
if flag==1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int a[90][90];

const int D = 80*160+10;
const int D2 = D*2;
typedef bitset<D2> bs;

bs dp[90][90];

int main() {
    int h, w;
    cin >> h >> w;
    rep(i,h)rep(j,w) cin >> a[i][j];
    rep(i,h)rep(j,w) {
        int ai;
        cin >> ai;
        a[i][j] = abs(a[i][j]-ai);
    }
    
    dp[0][0][D-a[0][0]] = 1;
    dp[0][0][D+a[0][0]] = 1;

    rep(i,h)rep(j,w) {
        if (i) {
            dp[i][j] |= dp[i-1][j]<<a[i][j];
            dp[i][j] |= dp[i-1][j]>>a[i][j];
        }
        if (j) {
            dp[i][j] |= dp[i][j-1]<<a[i][j];
            dp[i][j] |= dp[i][j-1]>>a[i][j];
        }
    }
    int ans = D;
    rep(i,D2) {
        if (dp[h-1][w-1][i]) ans = min(ans, abs(i-D));
    }
    cout << ans << endl;
    return 0;
}














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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	ll tLast,aLast;
	cin >> tLast >> aLast;
	FOR(i,1,n){
		ll t,a;
		cin >> t >> a;
		ll bairitsu = max( (tLast + t - 1) / t , (aLast + a - 1) / a );
		tLast = t * bairitsu;
		aLast = a * bairitsu;
	}
	ANS(tLast + aLast);
	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

class SegmentTree:
    def __init__(self, N, func, I):
        self.func = func
        self.I = I
        self.sz = 2**(N-1).bit_length()
        self.seg = [I] * (self.sz * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 56256
#include <iostream>

#define MOD 1000000007

typedef long long ll;

using namespace std;

int main() {
    ll n, ans = 1;
    string s1, s2, s = "_";
    cin >> n >> s1 >> s2;
    for (ll i = 0; i < n; ++i) {
        if (s1.at(i) == s2.at(i)) s.push_back('|');
        else {
            s.push_back('-');
            ++i;
        }
    }
    for (ll i = 0; i < s.size() - 1; ++i) {
        switch (s.at(i)) {
            case '_': ans *= (s.at(i + 1) == '|' ? 3 : 6); break;
            case '|': ans *= 2; break;
            case '-': ans *= (s.at(i + 1) == '|' ? 1 : 3); break;
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
lst = list(map(int, input().split()))
s = []
for i in range(n):
    a = lst[i]
    s.extend([str(i + 1)] * a)

for i in range(h):
    if i % 2 == 0:
        print(*list(s[i * w:i * w + w]))
    else:
        print(*list(s[i * w:i * w + w][::-1]))

Measured memory_bytes: 4084
#include <unistd.h>

char ibuf[(11<<18)+5];
char *ibufe = ibuf-1;

extern inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[40];
char *bufe = buf;

void write_uintln(int x){
  int i;
  static char tmp[13];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

extern inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


#define MAX(x, y) ((x) > (y) ? (x) : (y))

int n;
int A[1<<18];
int B[1<<18];

void zeta(int n){
  int i, j;
  int m = 1 << n;
  for(i=1;i<m;i<<=1){
    for(j=0;j<m;j++){
      if(j&i){
        int max = MAX(A[j], A[j^i]);
        B[j] = MAX(max^A[j]^A[j^i], MAX(B[j], B[j^i]));
        A[j] = max;
      }
    }
  }
}


int main(){
  int i, max;
  readall();
  n = read_uint();
  for(i=0;i<(1<<n);i++){
    A[i] = read_uint();
  }
  zeta(n);
  max = 0;
  for(i=1;i<(1<<n);i++){
    max = MAX(max, A[i]+B[i]);
    write_uintln(max);
  }
  writeall();
  return 0;
}


Measured memory_bytes: 7808
n = int(input())
correct = list(range(1 , n + 1))
a = [int(_) for _ in input().split()]
wrong = 0
if n == len(a):
    for i in range(len(correct)):
        if a[i] != correct[i]:
            wrong += 1
    if 0 <= wrong <= 2:
        print('YES')
    else:
        print('NO')
else:
    print('hoge!')

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a > 12) {
        cout << b << '\n';
    } else if(a > 5) {
        cout << b/2 << '\n';
    } else {
        cout << 0 << '\n';
    }
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
    }
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < N; ++i) {
        cnt1 += (P[i] <= A);
        cnt2 += (P[i] > A && P[i] <= B);
        cnt3 += (P[i] > B);
    }
    cout << min(cnt1, min(cnt2, cnt3)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


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


Measured memory_bytes: 3572
s = input()
 
if s == "SUN":
    print(7)
if s == "MON":
    print(6)
if s == "TUE":
    print(5)
if s == "WED":
    print(4)
if s == "THU":
    print(3)
if s == "FRI":
    print(2)
if s == "SAT":
    print(1)

Measured memory_bytes: 8888
#include <stdio.h>

long A,B,C,K;

int main()
{
	//変数宣言
	int ans=0;
	
	//初期入力
	scanf("%d %d %d %d",&A,&B,&C,&K);
	
	if(K <= A)
	{
		ans = K;
	}
	else
	{
		ans += A;
		if(K-A <= B)
		{
		}
		else
		{
			if(K-A-B<=C)
			{
				ans -= K-A-B;
			}
			else
			{
				ans -= C;
			}
		}
	}
	
	
	//最終出力
	printf("%d\n",ans);
	
	return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;
vector<int> h;
vector<ll> dp;

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

    cin >> N;
    h.resize(N + 10, 0);
    dp.resize(N + 10, INF);

    REP(i, N) cin >> h.at(i);

    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }

    cout << dp[N - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define PII pair < int, int >
#define x first
#define y second

using namespace std;
int n, k, a[10], u = 1;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	for (int i = 1, x; i <= k; i++) cin >> x, a[x] = 1;
	while (1){
		int x = n;
		u = 1;
		while (x){
			if (a[x%10]) u = 0;
			x /= 10;
		}
		if (u) return cout << n, 0;
		n++;
	}
	
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=int(readline())
m=map(int,read().split())
UVW=zip(m,m,m)

graph =[[] for i in range(N+1)]
for u,v,w in UVW:
    graph[u].append((v,w))
    graph[v].append((u,w))
color=[0]*(N+1)

def dfs(cur,par,dist):
    color[cur]=dist
    for dst,w in graph[cur]:
        if (dst==par):
            continue
        dfs(dst,cur,dist^(w&1))
dfs(1,-1,0)
print('\n'.join(map(str,color[1:])))


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

ll BinarySearch(ll ng, ll ok, function<bool(ll)> judge){
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

signed main(){
    int q;
    cin >> q;

    REP(i, q){
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);

        ll bound = BinarySearch(1e9, 0LL, [&](ll x){return x*x < a*b;});
        ll ans = bound * 2;
        if(bound*(bound+1) >= a*b) ans--;
        if(a <= bound) ans--;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import heapq

N,K=map(int,input().split())
A=list(map(int,input().split()))
l=[0]*max(A)
ans=0
for item in A:
    l[item-1]+=1
    
heapq.heapify(l)

while len(l)>K:
    ans+=heapq.heappop(l)
    
print(ans)


Measured memory_bytes: 24964
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n, m, c; cin >> n >> m >> c;
	vector<int> b (m);
	forn(i, m){
		cin >> b[i];
	}
	vector<vector<int>> a(n, vector<int> (m));
	forn(i, n){
		forn(j, m){
			cin >> a[i][j];
		}
	}
	int cont = 0;
	forn(i, n){
		int calc = 0;
		forn(j, m){
			calc+=(a[i][j]*b[j]);
		}
		if(calc+c > 0) cont++;
	}
	cout << cont << endl;
}


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

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

    vector<string> a(n), b(m);
    for (auto i = 0; i < n; i++) cin >> a[i];
    for (auto i = 0; i < m; i++) cin >> b[i];

    for (auto i = 0; i <= (n - m); i++) {
        for (auto j = 0; j <= (n - m); j++) {
            bool flg = true;
            for (auto k = 0; k < m; k++) {
                if(a[i + k].substr(j, m) != b[k]) {
                    flg = false; break;
                }
            }
            if(flg) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int x,y,ans=0;
  cin >> x >> y;
  if(x==3) {
    ans+=100000;
  }
  if(x==2) {
    ans+=200000;
  }
  if(x==1) {
    ans+=300000;
  }
  if(y==3) {
    ans+=100000;
  }
  if(y==2) {
    ans+=200000;
  }
  if(y==1) {
    ans+=300000;
  }
  if(x==1&&y==1) {
    ans+=400000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}

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

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


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


int main() {
  
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> vec(M, vector<int>(2));
  for(int i = 0; i < M; i++){
    for(int j = 0; j < 2; j++){
      cin >> vec[i][j];
    }
  }


  int answer=-2;
  for(int i = 0; i < M; i++){
      if(N!=1&&vec[i][0] == 1 && vec[i][1] == 0){
        answer = -1;
        cout << answer << endl;
        break;
      }
      else{
        for(int j = 0; j < M; j++){
          if(vec[i][0] == vec[j][0] && vec[i][1] != vec[j][1]){
            answer = -1;
            cout << answer << endl;
            goto SKIP;
          }
        }

      }
    }
    SKIP:
    
    if(answer != -1){
      vector<int> sp(N,0);
      if(N!=1){sp[0]=1;}
      for(int i = 0; i < M; i++){
        sp[vec[i][0] - 1] = vec[i][1];
      }
      
      for(int i=0;i<N;i++){
          cout<<sp[i];
      ;}
      
      }

      
    
    
 
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,n;
	cin>> x>>n;
	vector<int> vec(n) , a(n,101) , b(n,-101);
	for(int i=0;i<n;i++){
	    cin>> vec.at(i);
	}
	int k=0;
	int l=0;
	for(int i=0;i<n;i++){
	    if(vec.at(i)<x){
	        b.at(l)=vec.at(i)-x;
	        l++;
	    }
	    else {
	        a.at(k)=vec.at(i)-x;
	        k++;
	    }
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	
	for(int i=0;i<n;i++){
	    if(a.at(i)!=i) {
	        k=i;
	        break;
	    }
	}
	for(int i=1;i<n+1;i++){
	    if(b.at(n-i)!=0-i){
	        l=0-i;
	        break;
	    }
	}
	
	if(k<(0-l)) cout << x+k <<endl;
	else cout << x+l <<endl;
	
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long;

const int nax = 1005;
char sl[nax][nax];

const int mod = 1e9 +7;

void add_self(int& a,int b){
    a += b;
    if(a >= mod){
        a -= mod;
    }
}

int main()
{   
    int h,w;
    scanf("%d%d",&h,&w);
    REP(row,h){
        scanf("%s",sl[row]);
    }
    vector<vector<int>> dp(h,vector<int> (w));
    dp[0][0] = 1;
    //dp[i][j] is no of ways to reach (h-1,w-1)  from (0,0)
    REP(row,h){
        REP(col,w){
            for(int r2 : {row, row + 1}){
                int c2 = col;
                if(r2 == row){
                    c2 = col + 1;
                }
                if(r2 < h && c2 < w && sl[r2][c2]=='.'){
                    add_self(dp[r2][c2],dp[row][col]);
                }
            } 
        }
    }
    printf("%d\n",dp[h-1][w-1]);
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
 
int main(void){
  long int l,r,i,j;
  int min=2019;
  
  scanf("%ld", &l);
  scanf("%ld", &r);
 
  if(r-l>=2019-1){
    min=0;
    printf("%d", min);
    return 0;
  }
    
  for(i=l; i<=r-1; i++){
    for(j=i+1; j<=r; j++){
      if(((i*j)%2019)<min) min=(i*j)%2019;
    }
  }
  
  printf("%d", min);
  
  return 0;
}

Measured memory_bytes: 128
import sys
import fractions

def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    K = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return K


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    K = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    dict_ = {}
    for a in range(1,K+1):
        cnt += a
        for b in range(a+1,K+1):
            if '{}_{}'.format(a,b) in dict_:
                ans = dict_['{}_{}'.format(a,b)]
            else:
                ans = fractions.gcd(a,b)
                dict_['{}_{}'.format(a,b)] = ans
            cnt += 6*ans
            for c in range(b+1,K+1):
                if '{}_{}'.format(ans,c) in dict_:
                    _ans = dict_['{}_{}'.format(ans,c)]
                else:
                    _ans = fractions.gcd(ans, c)
                    dict_['{}_{}'.format(ans,c)] = _ans
                cnt += 6*_ans
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)

Measured memory_bytes: 81360
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS
vector<int> height,visited;
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n,m;
cin>>n>>m;
height.resize(n+1,0);
FOR(i,1,n+1) cin>>height[i];
vector<int> child(n+1,0),ans(n+1,0);
set<pair<int,int> > s;
FOR(i,0,m) {
    int a,b;
    cin>>a>>b;
    s.insert({a,b});
}
for(auto [a,b] : s) {
    if(height[a] > height[b]) ans[a]++;
    else if(height[a]<height[b]) ans[b]++;
    child[a]++,child[b]++;
}
int a = 0;
FOR(i,1,n+1) {
    if(child[i] == ans[i] || child[i] == 0)   a++;
}
cout<<a;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

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

int main() {
    // 整数はintという書き方！
    // cin >> 箱の名前 で箱に値を受け取れる！！
    // cout << 内容 で箱の値を出力できる！
    // endlで改行を表す
    // ""で囲うと文字列を表す
    // 割り算の商は/で求める、余りは%で求める！
    int a,b;
    cin >> a >> b;
    if (a*b %2 == 0){
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w;
char s[2010][2010];

int hc[2010][2010];
int wc[2010][2010];

int main(){
	cin>>h>>w;
	REP(i,h){
		REP(j,w){
			cin>>s[i][j];
		}
	}
	REP(i,h){
		int st=0;
		REP(j,w){
			if(s[i][j]=='#'){
				wc[i][j]=0;
				for(int k=st;k<j;k++){
					wc[i][k]=j-st;
				}
				st=j+1;
			}else if(j==w-1){
				for(int k=st;k<=j;k++){
					wc[i][k]=j-st+1;
				}
			}
		}
	}
	

	
	REP(i,w){
		int st=0;
		REP(j,h){
			if(s[j][i]=='#'){
				hc[j][i]=0;
				for(int k=st;k<j;k++){
					hc[k][i]=j-st;
				}
				st=j+1;
			}else if(j==h-1){
				for(int k=st;k<=j;k++){
					hc[k][i]=j-st+1;
				}
			}
		}
	}
	/*REP(i,h){
		REP(j,w){
			cout<<hc[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int ans=0;
	REP(i,h){
		REP(j,w){
			hc[i][j]+=wc[i][j];
			ans=max(ans,hc[i][j]);
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <utility>

using namespace std;

int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t result = b / x;
  if (0 < a) result -= (a - 1) / x; else ++result;
  cout << result << endl;
  return 0;
}


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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while(x <= y){
    ans++;
    x *= 2;
  }
  cout << ans << "\n";
}  

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

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

const int INF=1001001001;
int dp[50][600][600];

int main(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  vector<int>a(n),b(n),c(n);
  rep(i,n)cin>>a[i]>>b[i]>>c[i];

  rep(i,50)rep(j,600)rep(k,600)dp[i][j][k]=INF;
  dp[0][0][0]=0;

  for(int i=0; i<n; ++i){
    for(int j=0; j<500; ++j){
      for(int k=0; k<500; ++k){
        chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
        chmin(dp[i+1][j][k],dp[i][j][k]);
      }
    }
  }
  int ans=INF,i=ma,j=mb;
  while(1){
    if(i>=500||j>=500)break;
    ans=min(ans,dp[n][i][j]);
    i+=ma,j+=mb;
  }
  if(ans!=INF)cout<<ans<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 73952
n,k=map(int,input().split())
r,s,p=map(int,input().split())
T=list(input())
for i in range(len(T)):
    if T[i] == "r":
        T[i] = "p"
    elif T[i] == "s":
        T[i] = "r"
    else:
        T[i] = "s"
for i in range(k): #kでわった余り0~(k-1)
    j = i+k
    while j <= n-1: #j:何文字目
        if T[j-k] == T[j]:
            T[j] = "n"
        j = j+k
points = 0
for t in T:
    if t == "r":
        points += r
    elif t == "s":
        points += s
    elif t == "p":
        points += p
print(points)

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

using namespace std;
using ll = long long;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll X, Y;
    if (A > K) {
        X = A - K;
        Y = B;
    }else
    {
        X = 0;
        Y = max(B-(K-A), (ll)0);
    }
    cout << X << " " << Y << endl;
    
}

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

int main() {
	int D,N;
	cin>>D>>N;
	if(N!=100){
	cout<<N;
	while(D--)cout<<0<<0;
	cout<<endl;
}
else{
	if(D==0)cout<<101<<endl;
	if(D==1)cout<<10100<<endl;
	if(D==2)cout<<1010000<<endl;
}
}


Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
l=list(input())
sumup=0
for i in range(k):
  if l[i]=="r":
    sumup+=p
  if l[i]=="s":
    sumup+=r
  if l[i]=="p":
    sumup+=s
for i in range(k,n):
  if l[i]!=l[i-k]:
    if l[i]=="r":
      sumup+=p
    if l[i]=="s":
      sumup+=r
    if l[i]=="p":
      sumup+=s
  else:
    l[i]="f"
print(sumup) 


          

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
 
void subBin(string str, int n,int l)
{
    if (n == 0)    cout << str << "\n";
    if (n > 0) {
      if(l==1){
        subBin(str + 'a', n - 1,1);
        subBin(str + 'b', n - 1,2);
      }
      else if(l==2){
       subBin(str + 'a', n - 1,2);
        subBin(str + 'b', n - 1,2);
        subBin(str + 'c', n - 1,3);
      }
      else if(l==3){
        subBin(str + 'a', n - 1,3);
        subBin(str + 'b', n - 1,3);
        subBin(str + 'c', n - 1,3);
        subBin(str + 'd', n - 1,4);
      }
      else if(l==4){
         subBin(str + 'a', n - 1,4);
        subBin(str + 'b', n - 1,4);
        subBin(str + 'c', n - 1,4);
        subBin(str + 'd', n - 1,4);
        subBin(str + 'e', n - 1,5);
      }
       else if(l==5){
      subBin(str + 'a', n - 1,5);
        subBin(str + 'b', n - 1,5);
        subBin(str + 'c', n - 1,5);
        subBin(str + 'd', n - 1,5);
        subBin(str + 'e', n - 1,5);
        subBin(str + 'f', n - 1,6);
      }
       else if(l==6){
      subBin(str + 'a', n - 1,6);
        subBin(str + 'b', n - 1,6);
        subBin(str + 'c', n - 1,6);
        subBin(str + 'd', n - 1,6);
        subBin(str + 'e', n - 1,6);
        subBin(str + 'f', n - 1,6);
        subBin(str + 'g', n - 1,7); 
      }
      else if(l==7){
       subBin(str + 'a', n - 1,7);
        subBin(str + 'b', n - 1,7);
        subBin(str + 'c', n - 1,7);
        subBin(str + 'd', n - 1,7);
        subBin(str + 'e', n - 1,7);
        subBin(str + 'f', n - 1,7);
        subBin(str + 'g', n - 1,7); 
        subBin(str + 'h', n - 1,8); 
      }
      else if(l==8){
        subBin(str + 'a', n - 1,8);
        subBin(str + 'b', n - 1,8);
        subBin(str + 'c', n - 1,8);
        subBin(str + 'd', n - 1,8);
        subBin(str + 'e', n - 1,8);
        subBin(str + 'f', n - 1,8);
        subBin(str + 'g', n - 1,8); 
        subBin(str + 'h', n - 1,8); 
        subBin(str + 'i', n - 1,9);  
      }
      else if(l==9){
        subBin(str + 'a', n - 1,9);
        subBin(str + 'b', n - 1,9);
        subBin(str + 'c', n - 1,9);
        subBin(str + 'd', n - 1,9);
        subBin(str + 'e', n - 1,9);
        subBin(str + 'f', n - 1,9);
        subBin(str + 'g', n - 1,9); 
        subBin(str + 'h', n - 1,9); 
        subBin(str + 'i', n - 1,9); 
        subBin(str + 'j', n - 1,10); 
      }
    }
}
 
 
  int main(){
    int n;
    cin>>n;
    n--;
    string str ="a";
    subBin(str, n,1);
  }

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

using namespace std;

#define ll long long int

int n;
vector<int> arr;
ll dp[3001][3001][2];
ll solve(int st,int en,int move){

    if(st>en) return 0;

    if(dp[st][en][move]!=-1) return dp[st][en][move];
    ll ans;
    if(move==0){
        ans = max(arr[st]-solve(st+1,en,1),arr[en]-solve(st,en-1,1));
    }else{
        ans = max(arr[st]-solve(st+1,en,0),arr[en]-solve(st,en-1,0));
    }

    return dp[st][en][move] = ans;


}
int main() {
    cin>>n;
    arr.resize(n);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j][0] = dp[i][j][1] = -1;
        }
    }
    for(int i=0;i<n;i++) cin>>arr[i];

    ll ans; ans = solve(0,n-1,0);

    cout<<ans;

}


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

int main() {
  int n, l, s = 0;
  vector<int> v;
  cin >> n;
  REP(i, n * 2) {
    cin >> l;
    v.push_back(l);
  }
  sort(v.rbegin(), v.rend());

  REP(i, n) {
    s += min(v[i * 2], v[i * 2 + 1]);
  }

  cout << s << endl;
  return 0;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct UnionFind {
    vector<int> parent, size;

    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};

signed main() {
    long long n, m, ans = 0;
    cin >> n >> m;
    vector<long long> as(m);
    vector<long long> bs(m);
    vector<long long> ansv(m);
    ans = n * (n - 1) / 2;
    REP(i, m) {
        cin >> as[i] >> bs[i];
        as[i] -= 1;
        bs[i] -= 1;
    }
    reverse(as.begin(), as.end());
    reverse(bs.begin(), bs.end());
    UnionFind uf(n);
    ansv[0] = ans;
    REP(i, m - 1) {
        if (!uf.same(as[i], bs[i])) {
            ans -= uf.getsize(bs[i]) * uf.getsize(as[i]);
            uf.unite(as[i], bs[i]);
            ansv[i + 1] = ans;
        } else {
            ansv[i + 1] = ansv[i];
        }
    }
    reverse(ansv.begin(), ansv.end());
    REP(i, m) { cout << ansv[i] << endl; }
}

Measured memory_bytes: 4480