akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int h, w; std::cin >> h >> w;
  std::queue<std::pair<int, int>> que;
  auto dist = std::vector<std::vector<int>>(h, std::vector<int>(w, -1));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c; std::cin >> c;
      if (c == '#') {
        dist.at(i).at(j) = 0;
        que.emplace(i, j);
      }
    }
  }
  auto di = std::vector<int>{-1, +1, 0, 0};
  auto dj = std::vector<int>{0, 0, -1, +1};
  while (!que.empty()){
    int i, j; std::tie(i, j) = que.front(), que.pop();
    assert(dist.at(i).at(j) != -1);
    for (int k = 0; k < 4; k++) {
      int nxi = i + di.at(k);
      int nxj = j + dj.at(k);
      if (nxi < 0 || h <= nxi || nxj < 0 || w <= nxj ||
        dist.at(nxi).at(nxj) != -1) continue;
      dist.at(nxi).at(nxj) = dist.at(i).at(j) + 1;
      que.emplace(nxi, nxj);
    }
  }
  auto ret = 0;
  std::for_each(dist.begin(), dist.end(), [&](auto& v){
    std::for_each(v.begin(), v.end(), [&](auto x){ret = std::max(ret, x);});
  });
  std::cout << ret << std::endl;
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int alice = 0;
    int bob = 0;
    rep(i,n){
        if(i%2==0)alice+=a[i];
        else bob+=a[i];
    }
    cout<<abs(alice-bob);

    return 0;
    }


Measured memory_bytes: 3644
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

using ll = long long;

ll dp[110][2][110];

int main() {
  string N;
  int K;
  cin >> N >> K;

  memset(dp, 0, sizeof(dp));
  dp[0][1][0] = 1;

  for(int n = 0; n < N.size(); ++n) {
    for(int limited : {0, 1}) {
      int limit = (limited ? N[n] - '0' : 9);
      for(int i = 0; i <= limit; ++i) {
        for(int k = 0; k <= N.size(); ++k) {
          int add = i != 0 ? 1 : 0;
          dp[n + 1][limited && (i == limit)][k + add] += dp[n][limited][k];
        }
      }
    }
  }
  ll result = dp[N.size()][0][K] + dp[N.size()][1][K];
  cout << result << endl;
  return 0;
}

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

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

    int score1=0,score2=0;
    for(int i=0;i<n;i++){
        string card1,card2;
        cin>>card1>>card2;

        if(card1>card2){
            score1+=3;
        }
        else if(card1==card2){
            score1++;
            score2++;
        }
        else
        {
            score2+=3;
        }
    }

    cout<<score1<<" "<<score2<<endl;

    return 0;
}  


Measured memory_bytes: 3236
/******************************************
* AUTHOR :kamesh_11 *
* INSTITUTION : GVPCOE *
******************************************/

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

#define ll long long
#define MOD 1000000007
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define endl '\n'
#define start_clock clock_t beginn=clock()
#define end_clock clock_t endd=clock()
#define cal_exec_time double time_spent=(double)(endd-beginn)/CLOCKS_PER_SEC
#define print_exec_time cout<<endl<<time_spent<<" secs"

ll calc(ll wt[], ll val[], ll ind, ll W, ll N, vector<vector<ll>>&dp){
	if(ind>=N || W==0)
		return 0;
	if(dp[ind][W] != -1)
		return dp[ind][W];
 
	if(wt[ind] <= W){
		ll l = val[ind] + calc(wt, val, ind+1, W-wt[ind], N, dp);
		ll r = calc(wt, val, ind+1, W, N, dp);
 
		return dp[ind][W] = max(l, r);
	}
	else{
		return dp[ind][W] = calc(wt, val, ind+1, W, N, dp);
	}
}

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

	ll N, W;
	cin>>N>>W;
	ll wt[N], val[N];
	for(ll i=0;i<N;i++)
		cin>>wt[i]>>val[i];

	vector<vector<ll>>dp(N, vector<ll>(W+1, -1));
	cout<<calc(wt, val, 0, W, N, dp);

	/*ll dp[N][W+1];
	for(ll i=0;i<=W;i++){
		if(i >= wt[0])
			dp[0][i] = val[0];
		else
			dp[0][i] = 0;
	}
	for(ll i=1;i<N;i++){
		for(ll j=0;j<=W;j++){
			if(j >= wt[i]){
				dp[i][j] = max(dp[i-1][j-wt[i]] + val[i], dp[i-1][j]);
			}
			else	
				dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[N-1][W];*/

	return 0;
}

Measured memory_bytes: 79488
import sys

n=int(input())
a=list(map(int,input().split()))
s=0
now=0
for i in range(n):
    s+=abs(a[i]-now)
    now=a[i]
s+=abs(now)
a.insert(0,0)
a.append(0)
for i in range(1,n+1):
    mon=s
    mon-=(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))
    mon+=abs(a[i+1]-a[i-1])
    print(mon)

Measured memory_bytes: 14048
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int n, m;
	while(scanf("%d %d\n", &n, &m), n && m){
		vector<int> v;
		for(int i = 1; i <= n; i++) v.push_back(i);
		vector<int>::iterator it = v.begin();
		while(1 < v.size()){
			for(int i = 1; it = it == v.end() ? v.begin() : it, i < m; i++)
				it++;
			it = v.erase(it);
		}
		printf("%d\n", v[0]);
	}
	return 0;
}

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

using namespace std;

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

#define MOD ll(1e9 + 7)
#define MAXN int(1e5 + 10)

template<typename T> inline bool smin(T &a, const T &b) { return a > b ? a = b : a; }
template<typename T> inline bool smax(T &a, const T &b) { return a < b ? a = b : a; }
inline void add(ll &l, const ll &r) { l = (l + r) % MOD; }

int n, dp[MAXN];
vector<int> adj[MAXN];

void dfs(int v, int par = MAXN) {
	int cnt = 0;
	for (auto e : adj[v])
		if (e ^ par) {
			dfs(e, v);
			dp[v] += dp[e];
			if (!dp[e])
				cnt++;
		}
	if (cnt)
		dp[v] += cnt - 1;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n; 
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	int root = 0;
	for (int i = 1; i < n; i++)
		if (adj[i].size() >= adj[root].size())
			root = i;
	if (adj[root].size() <= 2) return cout << 1 << endl, 0;
	dfs(root);
	cout << dp[root] << endl;
	//system("pause");
	return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 2e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  int n, W; cin >> n >> W; 
  int m = 1000000;
  vector <vector <long>> dp(n + 1, vector <long> (m + 1, INF));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++){
    int w, val; cin >> w >> val;
    for (int j = 0; j <= m; j++){
      dp[i][j] = dp[i - 1][j];
      if (val <= j) chmin(dp[i][j], dp[i - 1][j - val] + w);
    }
  }
  for (int i = m; i >= 0; i--){
    if (dp[n][i] <= W) return cout << i, 0;
  }
  return 0;
}

Measured memory_bytes: 800444
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	nn := []float64{}
	re := float64(1000000000000)
	for index := 0; index < n; index++ {
		var na float64
		fmt.Scan(&na)

		nn = append(nn, na)
	}

	for index := 1; index < n; index++ {
		tmp := nn[index:]
		var s1 float64
		for _, item := range tmp {
			s1 += item
		}
		tmp2 := nn[:index]
		var s2 float64
		for _, item := range tmp2 {
			s2 += item
		}

		tre := math.Abs(s1 - s2)
		if re > tre {
			re = tre
		}
	}

	fmt.Println(re)
}

func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 512
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    abc = [list(map(int, input().split())) for i in range(n)]
    abc.reverse()

    ans = [[-1 for _ in range(3)] for __ in range(n)]

    ans[0][0], ans[0][1], ans[0][2] = abc[0][0], abc[0][1], abc[0][2]

    for i in range(1, n):
        for j in range(3):
            for k in range(3):
                if j != k:
                    ans[i][j] = max(ans[i][j], ans[i - 1][k] + abc[i][j])
                else:
                    continue
    print(max(ans[-1]))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
10 40 70
20 50 80
30 60 90"""
        output = """210"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1
100 10 1"""
        output = """100"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1"""
        output = """46"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 86356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int main(){
    FAST
    string s;
    cin>>s;
    if(s.substr(0,4)>"2019"){
        cout<<"TBD";
    }else if(s.substr(0,4)=="2019"){
        if(s.substr(5,2)<"04"){
            cout<<"Heisei";
        }else if(s.substr(5,2)>"04")
         cout<<"TBD";
         else {
             if(s.substr(8,2)<="30")
             cout<<"Heisei";
             else
             cout<<"TBD";
         }
    }else
     cout<<"Heisei";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;


int main() {  
  int r,g,b;
  cin >> r >> g >> b;
  int num = r*100+g*10+b;
  if (num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}




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

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

  int start = max(a, c);
  int end = min(b, d);

  cout << max(0, end - start) << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  // int64_t result = INT64_MIN;
  int64_t count_minus = 0;
  int64_t count_zero = 0;
  int64_t result = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    if (a < 0) {
      ++count_minus;
    } else if (a == 0) {
      ++count_zero;
    }
    A[i] = abs(a);
    result += A[i];
  }
  if (count_zero > 0 || count_minus % 2 == 0) {
    cout << result << endl;
  } else {
    nth_element(A.begin(), A.begin(), A.end());
    result -= 2 * A[0];
    cout << result << endl;
  }

  return 0;
}


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


using  namespace std;


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

    if(N==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
bool vv(int a,int b){
	if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
	{
		if(b==31)
		return true;
	}
	else if(a==4||a==6||a==9||a==11){
		if(b==30)
		return true;
	}
	else{
		if(b==28)
		return true;
	}
	return false;
}
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==12&&b==31&&c==1&&d==1)
	cout<<1;
	else{
	
	if(vv(a,b)&&c-a==1)
	cout<<1;
	else
	cout<<0;
	
}
	
	
	
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    int pos[2][3][60];
    vector<int> crs[3];
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<3;k++){
                scanf("%d",&pos[j][k][i]);
                crs[k].push_back(pos[j][k][i]);
            }
        }
    }
    for(auto &x:crs){
        sort(x.begin(),x.end());
        x.erase(unique(x.begin(),x.end()),x.end());
    }
    long long ans=0;
    for(int i=0;i<crs[0].size()-1;i++){
        for(int j=0;j<crs[1].size()-1;j++){
            for(int k=0;k<crs[2].size()-1;k++){
                int cnt=0;
                for(int l=0;l<N;l++){
                    if(pos[0][0][l]<=crs[0][i]&&crs[0][i]<pos[1][0][l]
                            && pos[0][1][l]<=crs[1][j]&&crs[1][j]<pos[1][1][l]
                            && pos[0][2][l]<=crs[2][k]&&crs[2][k]<pos[1][2][l]) cnt++;
                }
                if(cnt>=K) ans+=(long long)(crs[0][i+1]-crs[0][i])*(crs[1][j+1]-crs[1][j])*(crs[2][k+1]-crs[2][k]);
            }
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1040
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

template <typename M>
struct SegmentTree
{
	const int n;
	const M I;
	const std::function<M(M,M)> f;
	std::vector<M> data;
	SegmentTree(int n, M I, std::function<M(M,M)> f) : n(n), data(2*n,I), I(I), f(f) {}
	void set(int i, const M& v) {
		data[n+i]=v;
	}
	void build() {
		for(int i=n-1;i>0;i--) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	void update(int i, const M& v) {
		set(i,v);
		i+=n;
		for(i>>=1;i>0;i>>=1) {
			data[i]=f(data[i<<1],data[i<<1|1]);
		}
	}
	M get(int i) {
		return data[n+i];
	}
	M query(int l, int r) {
		M L=I, R=I;
		l+=n; r+=n;
		while(r>l) {
			if(l&1) L=f(L,data[l++]);
			if(r&1) R=f(data[--r],R);
			l>>=1; r>>=1;
		}
		return f(L,R);
	}
};


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	// for n even
	std::vector<int> ac1(n+1,0), ac2(n+1,0);
	rep(i,n) {
		if(i%2==0) ac1[i+1]=ac1[i]+a[i];
		else ac1[i+1]=ac1[i];
	}
	std::reverse(all(a));
	rep(i,n) {
		if(i%2==n%2) ac2[i+1]=ac2[i]+a[i];
		else ac2[i+1]=ac2[i];
	}
	std::reverse(all(a));
	// range max segment tree
	SegmentTree<int> seg(n+1,-INF,[](int a, int b){return std::max(a,b);});
	rep(i,n+1) if(i%2==0) seg.set(i,ac1[i]+ac2[n-i]);
	seg.build();
	if(n%2==0) {
		print(seg.query(0,n+1));
		return 0;
	}
	auto rec = [&] (auto f, int r) -> int {
		if(r<2) return 0;
		int even = seg.query(0,r+1) - ac2[n-r];
		int odd = f(f,r-2) + a[r];
		debug(even,odd);
		return std::max(even, odd);
	};
	print(rec(rec,n-1));
	return 0;
}


Measured memory_bytes: 28340
# ABC104 C-All Green

D, G = map(int, input().split())
pc = []
for _ in range(D):
    pc.append(list(map(int, input().split())))
    
ans = 10**10
for i in range(1 << D):
    c = 0
    p = 0
    l = [] # lを初期化
    for j in range(D):
        if ((i >> j) & 1) == 1: # bit演算
            c += pc[j][0] # 問題数をメモ
            p += (j+1)*100*pc[j][0] + pc[j][1] # ここまで獲得した特典TKO\
            l.append(j) # 利用したjをメモ
    ma = 0
    for ii in range(D-1, -1, -1): # もっとも得点の高い問題を選択
        if ii not in l:
            ma = ii
            break
    for k in range(pc[ma][0]):
        if p >= G:
            break
        c += 1
        p += (ma+1)*100
    if p >= G:
        ans = min(ans, c)
        
print(ans)

Measured memory_bytes: 42356
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
dp = [0]*(1000001)
dp[0] = 1
dp[1] = 1
for i in range(2,n+1):
    dp[i] = dp[i-1] + dp[i-2]
print(dp[n])


Measured memory_bytes: 14100
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;cin>>n;
    vector<ll> t(n+2,0), a(n+2,0);
    rep(i,n){cin>>t.at(i+1);}
    rep(i,n){cin>>a.at(i+1);}
    t.at(n+1) = t.at(n);
    a.at(0) = a.at(1);
    ll res = 1;
    ll max_now = 0;
    ll cur_from = 1;
    while(cur_from<=n+1&&t[cur_from]!=a[cur_from]){
        if(t.at(cur_from-1)<t.at(cur_from)){
            max_now = t.at(cur_from);
        }else{
            res *= max_now;
            res %= MOD;
        }
        DEBUG{
            cout << res << endl;
        }
        cur_from++;
    }
    ll cur_to = n;
    max_now = 0;
    while(cur_to>=0&&t[cur_to]!=a[cur_to]){
        if(a.at(cur_to)>a.at(cur_to+1)){
            max_now = a.at(cur_to);
        }else{
            res *= max_now;
            res %= MOD;
        }
        DEBUG{
            cout << res << " max : " << max_now << endl;
        }
        cur_to--;
    }
    if(cur_from>=n+1||cur_to<=0||t.at(n)!=a.at(1)||t.at(cur_from)!=t.at(n)||a.at(1)!=a.at(cur_to)){
        cout << 0 << endl;
        return 0;
    }
    for(int i=cur_from+1;i<cur_to;i++){
        res *= t.at(i);
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
signed main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD
    
    string s;
    cin>>s;
    ll p1=int(s[0])-48;
    ll p2=int(s[1])-48;
    ll p3=int(s[2])-48;
    ll p4=int(s[3])-48;
 //   cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl; 
    ll p = p1*10+p2;
    ll q= p3*10+p4;
    ll f1=0;
    ll f2=0;
    if(q<=12 && q>=1)
    {
        f1=1;
    }
    if(p<=12 && p>=1)
    {
        f2=1;
    }
    if(f1==1 && f2==1)
    cout<<"AMBIGUOUS"<<endl;
    else if(f1==1)
    {
        cout<<"YYMM";
    }
    else if(f2==1)
    {
        cout<<"MMYY";
    }
    else
    cout<<"NA";
}
    
    
    







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

typedef long long ll;
const ll MOD = 10007;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    ll n,m,Q;
    cin >> n >> m >> Q;
    ll lr[n+1][n+1];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            lr[i][j] = 0;
        }
    }
    vector<ll> p(Q), q(Q);
    for(int i = 0; i < m; i++){
        ll tl, tr;
        cin >> tl >> tr;
        lr[tl][tr]++;
    }
    for(int i = 0; i < Q; i++){
        cin >> p[i] >> q[i];
    }

    ll suml[n+1][n+1];
    for(int i = 1; i <= n; i++){
        suml[i][0] = 0;
        for(int j = 1; j <= n; j++){
            suml[i][j] = suml[i][j-1] + lr[i][j];
        }
    }

    for(int i = 0; i < Q; i++){
        ll ans = 0;
        for(int j = p[i]; j <= q[i]; j++){
            ans += suml[j][q[i]] - suml[j][p[i]-1];
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){

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

    int m;
    cin >> m;
    vector<int> b(m);
    for(int i = 0; i < m; ++i){
        cin >> b[i];
    }

    cout << lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()) << endl;

    return 0;
}


Measured memory_bytes: 3100
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        var n = m1(b - a);
        Console.WriteLine(n - b);
    }

    static int m1(int n)
    {
        if (n == 1) return 1;
        return n + m1(n - 1);
    }
}


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

template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	ModInt operator+(const int64_t operand)
	{
		int64_t ret{integer_ + operand};
		if (ret >= mod_)
			ret -= mod_;
		return ModInt(ret);
	}
	ModInt operator-(const int64_t operand)
	{
		int64_t ret{integer_ - operand};
		if (ret < 0)
			ret += mod_;
		return ModInt(ret);
	}
	ModInt operator*(const int64_t operand)
	{
		return ModInt(integer_ * operand % mod_);
	}
	ModInt operator/(const int64_t operand)
	{
		int64_t ret{1}, pow_ope{operand};
		for (int64_t pow_mod{mod_ - 2}; pow_mod > 0; pow_mod >>= 1)
		{
			if (pow_mod & 1)
				ret = ret * pow_ope % mod_;
			pow_ope = pow_ope * pow_ope % mod_;
		}
		return (*this) * ModInt(ret);
	}

	// 代入
	ModInt& operator=(const int64_t operand)
	{
		integer_ = operand;
		return *this;
	}
	ModInt& operator+=(const int64_t operand)
	{
		*this = *this + operand;
		return *this;
	}
	ModInt& operator-=(const int64_t operand)
	{
		*this = *this - operand;
		return *this;
	}
	ModInt& operator*=(const int64_t operand)
	{
		*this = *this * operand;
		return *this;
	}
	ModInt& operator/=(const int64_t operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	operator int64_t() { return integer_; }
};

template<int64_t mod_ = 1'000'000'007>
class Combination {
public:
	std::vector<ModInt<mod_>> inv, fact, finv;

	Combination(const int max = 200'000)
		: inv(max + 1), fact(max + 1), finv(max + 1)
	{
		inv[0] = inv[1] = fact[0] = fact[1] = finv[0] = finv[1] = 1;
		for (int num{2}; num <= max; num++)
		{
			inv[num] = (mod_ - (int64_t)inv[mod_ % num] * (mod_ / num) % mod_) % mod_;
			fact[num] = num * fact[num - 1] % mod_;
			finv[num] = inv[num] * finv[num - 1] % mod_;
		}
	}

	int64_t getCombi(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[r] * finv[n - r];
	}

	int64_t getPerm(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[n - r];
	}
};

template<typename T>
T pow(T a, int64_t b)
{
	T ret(1);
	while (b)
	{
		if (b & 1) ret *= a;
		b >>= 1;
		a *= a;
	}
	// printf("%lld\n", (int64_t)ret);
	return ret;
}

int main()
{
	int64_t n, a, b, c;
	scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
	ModInt<> N(n), A(a), B(b), C(c), ans(0);
	A /= 100ll;
	B /= 100ll;
	C /= 100ll;

	Combination<> combi;
	for (int64_t i{n}; i <= 2 * n - 1; i++)
	{
		ans += ModInt<>(combi.getCombi(i - 1, n - 1)) * (pow(A / (A + B), n) * pow(B / (A + B), i - n) + pow(B / (A + B), n) * pow(A / (A + B), i - n)) * i / (A + B);
	}
	printf("%lld\n", (int64_t)ans);

	return 0;
}

Measured memory_bytes: 5120
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.next();
    let s: String = sc.next();
    println!(
        "{}",
        if s[0..(n / 2)] == s[(n / 2)..] {
            "Yes"
        } else {
            "No"
        }
    );
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	int A, B;
	scanf("%d %d", &A, &B);
	if (A == 1)A = 14;
	if (B == 1)B = 14;
	if (A == B){
		printf("Draw\n");
	}
	else if (A > B){
		printf("Alice\n");
	}
	else{
		printf("Bob\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define N 2000
int solve(int,int);
int n,A[N],S[N];
int main(){
  int i,q,m[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
  if(solve(0,m[i])==1)printf("yes\n");
  else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res1,res2;
  if(m==0)return 1;
  if(i>=n)return 0;
  res1=solve(i+1,m);
  res2=solve(i+1,m-A[i]);
  if(res1==1||res2==1)
    return 1;
  else return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll a[n];
    for (int i = 0; i < n; ++i)
    {
      cin >> a[i];
    }
    ll b[n];
    memset(b,0,sizeof(b));
    for (int i = 0; i < n; i+=2)
    {
      b[i]+=a[i];if(i)b[i]+=b[i-2];
    }
    ll dp[n];memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=max(a[1],a[0]);
    for(ll i=2;i<n;i++)
    {
      dp[i]=max(a[i]+dp[i-2],(i%2)?(b[i-1]):(dp[i-1]));
    }
    cout << dp[n-1];
    }

Measured memory_bytes: 8340
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

void input(bool grid[][9])
{
	rep(i,9){
		string s;
		cin>>s;
		if(i%2==0)
			rep(j,4)
				grid[i][j*2+1]=s[j]-'0';
		else
			rep(j,5)
				grid[i][j*2]=s[j]-'0';
	}
}

enum dir{
	UP,RIGHT,DOWN,LEFT
};
const int di[]={-1,0,1,0};
const int dj[]={0,1,0,-1};
const char output[]="URDL";

bool in_range(int i,int j)
{
	return 0<=i && i<9 && 0<=j && j<9;
}

int main()
{
	bool grid[9][9]={{0}};
	input(grid);
	//rep(i,9){
	//	rep(j,9)
	//		cout<<grid[i][j]<<" ";
	//	cout<<endl;
	//}
	
	int i=0,j=0;
	dir prev=RIGHT;
	for(;;){
		//printf("# (%d,%d) prev:%c\n",i,j,output[prev]);
		
		dir next[4];
		if(prev==UP){
			next[0]=LEFT;next[1]=UP;next[2]=RIGHT;next[3]=DOWN;
		}
		else if(prev==RIGHT){
			next[0]=UP;next[1]=RIGHT;next[2]=DOWN;next[3]=LEFT;
		}
		else if(prev==DOWN){
			next[0]=RIGHT;next[1]=DOWN;next[2]=LEFT;next[3]=UP;
		}
		else if(prev==LEFT){
			next[0]=DOWN;next[1]=LEFT;next[2]=UP;next[3]=RIGHT;
		}
		int k;
		for(k=0;k<3;k++){
			if(in_range(i+di[next[k]],j+dj[next[k]]) && grid[i+di[next[k]]][j+dj[next[k]]])
				break;
		}
		
		//printf("%d(%c)\n",k,output[next[k]]);
		cout<<output[next[k]];
		
		i+=di[next[k]]*2;
		j+=dj[next[k]]*2;
		prev=next[k];
		
		if(i==0 && j==0)
			break;
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


int main(void){
  ll A, B;
  cin >> A >> B;
  if(A == B){
    cout << 0 << endl;
    return 0;
  }
  if((A + B) % 2){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << (A + B) / 2 << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), x[n], y[n];
	rep (i, n) {
		cin >> a[i];
		rep (j, a[i]) {
			int xx, yy;
			cin >> xx >> yy;
			x[i].push_back(xx - 1);
			y[i].push_back(yy);
		}
	}
	// bit全探索
	int hito, ans = 0;
	for (hito = 1; hito < (1 << n); hito++) {
		bool ok = true;
		rep (i, n) {
			rep (j, a[i]) {
				if ((hito & (1 << i)) && y[i][j] != !!(hito & (1 << x[i][j]))) {
					ok = false;
					// i = n;
					// j = a[i];
				}
			}
		}
		if (ok) {
			// cout << hito << endl;
			int tmp = 0, hh = hito;
			rep (i, 20) {
				tmp += hh % 2;
				hh >>= 1;
				chmax(ans, tmp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <climits>
# include <cstring>
using namespace std;
int dp[105][105];
char grid[105][105];
int R, C;
int dx[] = {1,0};
int dy[] = {0,1};
bool inside(int r, int c){
  return 1<=r && r<=R && 1<=c && c<=C;
}

int solve(int r,int c){
  if(r == R && c == C) return grid[r][c] == '#';
  if(dp[r][c] != -1) return dp[r][c];

  int ans = INT_MAX;
  for(int d=0; d<2; d++){
    int nxr = r+dx[d];
    int nxc = c+dy[d];
    if(!inside(nxr, nxc)) continue;
    if(grid[r][c] == '.') ans = min(ans, solve(nxr, nxc));
    else if(grid[r][c] == '#' && grid[nxr][nxc] == '#') ans = min(ans, solve(nxr, nxc));
    else ans = min(ans, solve(nxr, nxc)+1);
  }
  return dp[r][c] = ans;
}

int main(){
  memset(dp, -1, sizeof(dp));
  cin >> R >> C;
  for(int i=1; i<=R; i++){
    for(int j=1; j<=C; j++)
      cin >> grid[i][j];
  }

  cout << solve(1,1) << endl;
  return 0;
}

Measured memory_bytes: 3684
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T>
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

void solve() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
}

int main() {
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}


Measured memory_bytes: 3620
def array_converter(i)
  num_array=[]
  for num in 1..i
    line = readline.split(/[[:space:]]/)
    if judge_key_and_calc(num_array,line[0],line[1])
      num_array.unshift line[1]
    end
  end
  num_array
end

def judge_key_and_calc(array,key,val)
  if key == "delete"
    if array.index(val) != nil
      array.delete_at(array.index(val))
    end
    false
  elsif key == "deleteFirst"
    array.shift
    false
  elsif key == "deleteLast"
    array.pop
    false
  else
    true
  end
end

def queue_calc
  num = readline.to_i
  array_converter(num).join(" ")
end

puts queue_calc

Measured memory_bytes: 87936
#include<stdio.h>
int main(){
  int a,b,c,d=0;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=100; 1<=i; i--){
    if(a%i==0&&b%i==0){
      d++;
    }
    if(d==c){
      printf("%d",i);
      break;
    }
  }
  return 0;}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int len = S.size();
    int cnt= 0;
    string ans = "AC";
    if(S[0] != 'A'){
      ans = "WA";
    }
  
    for(int i = 1;i < len;i++){
      if(isupper(S[i])){
      	if(i == 1 || i == len - 1 || S[i] != 'C'){ 
        ans = "WA";
        }
        cnt++;
      }
    }
    if(cnt != 1){
      ans = "WA";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int a, b, ans;
string s;

int main() {
  cin >> a >> b;
  for (int i = 1; i <= a; i++) {
    if (!(i == a && a > b)) ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,n,j,k,o;
	scanf("%d",&o);
	int flag=1,flag1=1;
	int min,max;
	while(o--){
		scanf("%d",&n);
		if(flag){
			min=n;
			flag=0;
		}
		else if(!flag&&flag1){
			max=n-min;
			flag1=0;
			if(n<min)	min=n;
		}
		else if(!flag&&!flag1){
			if(n-min>max){
				max=n-min;
			}
			if(n<min){
				min=n;
			}
		}
	}
	printf("%d\n",max);
} 


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;
string s;
int main(){
    cin>>s;
    if(s=="ABC") printf("ARC");
    else printf("ABC");
    
    
    
    
 	return 0;
}




Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP1(i, n) for(int i = 1; i <= (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

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

	REP1(i, 9){
		if(N % i == 0 && (1 <= N/i && N/i <= 9)){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long N;
int main() {
    cin >> N;
    vector<long long> A(N, 0);
    for(long long i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

    long long max = 0;

    for(long long i = 0; i < N; ++i) {
        for(long long j = 0; j < N; ++j) {
            if(i != j) {
                long long sa = abs(A.at(i) - A.at(j));
                if(sa > max) {
                    max = sa;
                }
            }
        }
    }

    cout << max << endl;
}

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

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x==1){
        printf("%d",1);
        exit(0);
    }
    
    int ans=1;
    for(int i=2; i<=x/2; i++){
        int a=1;
        while(a*i<=x){
            a *= i;
        }
        if(ans<a){
            ans = a;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;
use ascii::AsciiString;
use ascii::AsciiChar;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        s :AsciiString,
        t :AsciiString,
    }

    let slen :usize = s.len();
    let tlen :usize = t.len();
    const BANHEI :usize = 1000000;

    let mut skip_table :Vec<Vec<usize>> = vec![vec![BANHEI;slen];26];
    for i in 0..26 {
        let mut last_match :usize = BANHEI;
        for j in (0..slen).rev() {
            if (s[j].as_char().to_digit(36).unwrap() - 10) as usize == i {
                last_match = j;
            }
            if last_match != BANHEI {
                skip_table[i][j] = last_match - (j);
            }
        }
        for j in (0..slen).rev() {
            if (s[j].as_char().to_digit(36).unwrap() - 10) as usize == i {
                last_match = j;
            }
            if (last_match != BANHEI) && (last_match < (j)) {
                skip_table[i][j] = last_match + slen - (j);
            }
        }
    }
    let mut i :usize = 0;
    for j in 0..tlen {
        let nowchar = (t[j].as_byte() - AsciiChar::from_ascii('a').unwrap().as_byte()) as usize;
        if skip_table[nowchar][i%slen] == BANHEI {
            println!("-1");
            return;
        }
        i += skip_table[nowchar][i%slen] as usize;
        i += 1;
    }
    println!("{}", i);
}


Measured memory_bytes: 22728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i, N) cin >> t[i];
    int before = 0;
    ll total = T;
    for (int i = 1; i < N; i++)
    {
        total += min(T, t[i] - before);
        before = t[i];
    }
    cout << total << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int r, d, x;
  cin >> r >> d >> x;
  rep(i, 10){
    x = r * x - d;
    cout << x <<endl;
  }
}

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

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

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

int main(void){
	int R,G,B,N;
	std::cin>>R>>G>>B>>N;

	int cnt = 0;
	for(int i=0;i<=N/R;i++){
		for(int j=0;j<=N/G;j++){
			int temp = N - i*R - j*G;
			if(temp%B == 0 && temp >= 0){
				cnt++;
			}
		}
	}
	
	std::cout<<cnt<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
#define MOD 1000000007; 

int main(void){
 int H,W,K;
 bool ok;
 long long int dp[150][10];
 cin>>H>>W>>K;

 for(int i=0; i<150; ++i)
  for(int j=0; j<10; ++j)dp[i][j]=0;

 dp[0][1]=1;
  
 for(int i=0;i<H; ++i){
  for(int j=1; j<=W; ++j){
   //bit全探索とDP
   for(int k=0; k<(1<<(W-1)); ++k){
    ok=true;
    //2つの横線を辿る  
    for(int l=0; l<W-2;++l){
     if(((k>>l) & 1) &&((k >> (l+1)) & 1))ok=false; 
    }
    if(ok){
     //棒を辿って左側にいく
     if(j>=2 &&((k >>(j-2))&1)){
      dp[i+1][j-1]+=dp[i][j];
      dp[i+1][j-1]%=MOD;  
     }
     //棒を辿って右側にいく
     else if(j<=W-1 && ((k >>(j-1))&1)){
      dp[i+1][j+1]+=dp[i][j];
      dp[i+1][j+1]%=MOD;
     }
     //横線を辿らないケース
     else{
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=MOD;
     }
    }
   }
  }
 }
 cout<<dp[H][K]<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
char c[N];
int f[N][4],i,j,k,l,n;
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	f[1][1]=1;
	/*
	for(i=2;i<=n;++i){
		f[i][2]=f[i-2][1]+1;
		f[i][1]=f[i-1][2]+1;
		if(c[i]!=c[i-1])f[i][1]=max(f[i][1],f[i-1][1]+1);
	}
	*/
	for(i=2;i<=n;++i)for(j=1;j<=3;++j)if(i-j>=0){
		if(i==j){
			f[i][j]=1;
			continue;
		}
		f[i][j]=-N;
		for(k=1;k<=3;++k)if(i-j-k>=0){
			if(j==k){
				for(l=0;l<j;++l)if(c[i-l]!=c[i-j-l])break;
				if(l==j)continue;
			}
			f[i][j]=max(f[i][j],f[i-j][k]+1);
		}
	}
	int ans=-N;
	for(i=1;i<=3 && i<=n;++i)ans=max(ans,f[n][i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
#define MAXN	505
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, a[MAXN][MAXN];
int cnt[MAXN], pos[MAXN];
bool disabled[MAXN];
bool ok(int value) {
	for (int i = 1; i <= m; i++)
		if (cnt[i] > value) return false;
	return true;
}
bool check(int value) {
	memset(cnt, 0, sizeof(cnt));
	memset(disabled, false, sizeof(disabled));
	for (int i = 1; i <= n; i++) {
		pos[i] = 1;
		cnt[a[i][1]]++;
	}
	while (!ok(value)) {
		for (int i = 1; i <= m; i++)
			if (cnt[i] > value) disabled[i] = true;
		for (int i = 1; i <= n; i++) {
			while (pos[i] <= m && disabled[a[i][pos[i]]]) {
				cnt[a[i][pos[i]]]--;
				pos[i]++;
				cnt[a[i][pos[i]]]++;
			}
			if (pos[i] > m) return false;
		}
	}
	return true;
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
		read(a[i][j]);
	int l = 1, r = n;
	while (l < r) {
		int mid = (l + r) / 2;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 896