akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
//約数列挙配列生成
vector<int> divisor(int n){
    vector<int> ret;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s; cin >> s;
    bool can = 1;
    if(s[0]!='A') {
        cout << "WA" << '\n';
        return 0;
    }

    int cntC = 0;
    for(int i = 1; i < s.size(); ++i) {

        if(2<=i && i < s.size()-1) {
            if(s[i] == 'C') cntC++;
            else if(!(0 <= s[i]-'a' && s[i]-'a' <= 26)) {
                cout << "WA" << '\n';
                return 0;
            }
            if(cntC>=2) {
                cout << "WA" << '\n';
                return 0;
            }
        }
        else {
            if(!(0 <= s[i]-'a' && s[i]-'a' <= 26)) {
                cout << "WA" << '\n';
                return 0;
            }
        }
    }
    if(cntC==0) cout << "WA" << '\n';
    else cout << "AC" << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
    ll a,b,c;
    ll n;cin>>n;
    ll dp[n+1][4];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=n;i++){
        cin>>a>>b>>c;
        if(i==1){
        dp[i][1]=a;
        dp[i][2]=b;
        dp[i][3]=c;}
        else{
            dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a;
            dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b;
            dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c;
        }
    }
    cout<<max({dp[n][1],dp[n][2],dp[n][3]});
}
int main(){
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

#define N 100001
#define YES 1
#define NO  0

char *t[4] = {"dream", "dreamer", "erase", "eraser"};
char *ans[2] = {"NO", "YES"};

int match(char *);
int strncomp(char *, char *, int);
int strlength(char*);

int main(void){
	char str[N];
	int r;

	scanf("%s", str);
	r=match(str);
	printf("%s\n", ans[r]);
	
	
	return 0;
}

int match(char *str){
	int len, r=NO, flg, i;
	
	if(*str == '\0') return YES;
	for(i=0; i<4; i++){
		len = strlength(t[i]);
		if(strncomp(str, t[i], len) == 0){
			r = match(str+len);
			if(r == YES) return r;
		}
	}
	
	return NO;
}

int strlength(char *p){
	int cnt=0;

	while(p[cnt++] != '\0');
	cnt--;
	return cnt;
}

int strncomp(char *a, char *b, int size){
	int i;
	
	for(i=0; i<size; i++){
		if(a[i] >  b[i]) return -1;
		else if(a[i] < b[i]) return 1;
	}
	
	return 0;
}

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

int main() {
	int a, b, c;
	bool f[60] = {};
	cin >> a >> b >> c;
	for (int t = c; ; t += 60) {
		int d = t % (a + b);
		if (d <= a) {
			cout << t << endl;
			break;
		} else if (f[d]) {
			cout << -1 << endl;
			break;
		}
		f[d] = true;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, ans = INF;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a = i, b = n - i;
        int sum = 0;
        while(a > 0)
        {
            sum += a % 10;
            a /= 10;
        }
        while(b > 0)
        {
            sum += b % 10;
            b /= 10;
        }
        ans = min(sum, ans);
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<utility>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  int H[N];
  int GV[N];
  for(int i=0;i<N;i++) GV[i]=true;
  for(int i=0;i<N;i++) cin>>H[i];
  int A,B;
  for(int i=0;i<M;i++){
    cin>>A>>B;
    A--;B--;
    if(H[A]==H[B]){
      GV[A]=false;
      GV[B]=false;
    }
    else if(H[A]<H[B]){
      GV[A]=false;
    }
    else GV[B]=false;
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(GV[i]) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){
    
    int X;
    int A;
    cin >> X >> A;
    
    if (X < A) {
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

pp qr[200010];
int n, q;
int s[200010];

const int inf = 2e9;

struct Tree {
	static const int M = 262144;
	int T[M<<1];
	void init(){ for(int i=0; i<(M<<1); ++i) T[i]=inf; }
	void put(int p, int v){ for(p+=M; p; p>>=1) T[p]=min(T[p], v); }
	int range(int l, int r){
		int ret=inf;
		for(l+=M, r+=M; l<=r; l/=2, r/=2){
			if(l%2==1) ret=min(ret, T[l++]);
			if(r%2==0) ret=min(ret, T[r--]);
		}
		return ret;
	}
	void put(int l, int r, int v, int mp=1, int ml=0, int mr=M-1){
		if(r<ml || mr<l) return;
		if(l<=ml && mr<=r){ T[mp]=min(T[mp], v); return; }
		int mid=(ml+mr)/2;
		put(l, r, v, mp*2, ml, mid);
		put(l, r, v, mp*2+1, mid+1, mr);
	}
	int pick(int p){
		int ret=inf;
		for(p+=M; p; p>>=1) ret=min(ret, T[p]);
		return ret;
	}
} tt, t2;

int main()
{
	read(n);
	for(int i=1; i<=n; ++i){ read(s[i]); s[i]+=s[i-1]; }
	read(q);
	for(int i=1; i<=q; ++i) read(qr[i].x, qr[i].y);
	sort(qr+1, qr+q+1, [&](const pp& a, const pp& b){ return a.second < b.second; });
	
	tt.init(); t2.init();
	tt.put(0, 0);
	int ans=s[n];
	for(int i=1; i<=q; ++i){
		int l=qr[i].x, r=qr[i].y;
		int mydp = inf;
		
		mydp = min(mydp, t2.pick(l) + r - s[r]);
		mydp = min(mydp, tt.range(0, l-1) + r-l+1 - s[r]+2*s[l-1]);
		ans=min(ans, mydp+s[n]-s[r]);
		
		tt.put(r, mydp-s[r]);
		t2.put(l, r, mydp+s[r]-r);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6656
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve1(N, K, heights):
    heights += [INF] * K
    costs = [INF] * (N + K)
    costs[0] = 0
    for i in range(N - 1):
        for k in range(1, K + 1):
            newcost = costs[i] + abs(heights[i + k] - heights[i])
            if newcost < costs[i + k]:
                costs[i + k] = newcost
    return costs[N - 1]


def solve(N, K, heights):
    costs = [0] * N
    costs[0] = 0
    costs[1] = abs(heights[1] - heights[0])
    for i in range(1, N):
        costs[i] = min(
            costs[j] + abs(heights[i] - heights[j])
            for j in range(max(i - K, 0), i)
        )

    return costs[-1]


def solve3(N, heights):
    costs = [None] * N
    costs[0] = 0
    costs[1] = abs(heights[1] - heights[0])

    def get_cost(i):
        if costs[i] != None:
            return costs[i]

        c = min(
            get_cost(i - 2) + abs(heights[i] - heights[i - 2]),
            get_cost(i - 1) + abs(heights[i] - heights
                                  [i - 1]),
        )
        costs[i] = c
        return c

    return get_cost(N - 1)


def main():
    N, K = map(int, input().split())
    heights = list(map(int, input().split()))
    print(solve(N, K, heights))


def _test():
    """
    >>> solve(5, 3, [10, 30, 40, 50, 20])
    30
    >>> solve(3, 1, [10, 20, 10])
    20
    >>> solve(2, 100, [10, 10])
    0
    >>> solve(10, 4, [40, 10, 20, 70, 80, 10, 20, 70, 80, 60])
    40
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

set<int> st;
vi ans;
vi sz;
bool ok = false;
int ng = -1;
void sch(int n, int k, vi &a) {
  if(n - k <= 5) {
    vi rem;
    for(auto &e: st) rem.push_back(e);
    REP(i, 120) {
      bool tmp = true;
      tmp &= ans.empty() || a[ans.back()] != rem[0];
      REP(j, SZ(rem)-1) {
        tmp &= a[rem[j]] != rem[j+1];
      }
      if(tmp) {
        ok = true;
        break;
      }
      next_permutation(ALL(rem));
    }
    if(ok) for(auto &e: rem) ans.push_back(e);
  } else {
    int mi = INF;
    for(auto &e: st) {
      if(e != ng) {
        mi = e;
        break;
      }
    }

    if(mi == INF) {
      return;
    }

    if(sz[a[mi]] == n - k - 1) {
      mi = a[mi];
    }

    ng = a[mi];
    sz[a[mi]]--;
    st.erase(mi);
    ans.push_back(mi);
    sch(n, k+1, a);
  }
}

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

  int n; cin >> n;
  vi a(n);
  sz.resize(n);
  REP(i, n) {
    cin >> a[i];
    a[i]--;
    sz[a[i]]++;
  }
  REP(i, n) st.insert(i);

  sch(n, 0, a);

  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  REP(i, n) {
    cout << ans[i]+1;
    cout << " ";
  }
  cout << endl;

}
























Measured memory_bytes: 15744
import itertools 
def diff(a,b,c):
    return abs(A-a)+abs(B-b)+abs(C-c)
    
N,A,B,C,*l=map(int,open(0).read().split())
_min=10**6
for i in itertools.product([0,1,2,3],repeat=N):
    cnt=0
    abc=[0,0,0]
    for j in range(N):
        if i[j] !=3:
            abc[i[j]]+=l[j]
            cnt+=1
    if 0 in abc:
        continue
    _min=min(_min,10*cnt-30+diff(abc[0],abc[1],abc[2]))
print(_min)    
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e5+5;

int main()
{
   ll a, v, b, w, t;
   cin >> a >> v >> b >> w >> t;
   ll d = abs(a - b);
   v -= w;
   if(v <= 0) puts("NO");
   else {
      ll tt = (v + d - 1) / v;
      if(tt <= t) puts("YES");
      else puts("NO");
   }
}


Measured memory_bytes: 3576
while True:
  n, m = map(int, input().split())
  if n == 0:
    break
  alst = [int(input()) for _ in range(n)]
  blst = [int(input()) for _ in range(m)]
  alst.sort()
  blst.sort()
  suma = sum(alst)
  sumb = sum(blst)
  def search():
    for a in alst:
      for b in blst:
        if (a - b) * 2 == suma - sumb:
          print(a, b)
          return
    print(-1)
  search()


Measured memory_bytes: 5600
S_raw = input()
T_raw = input()

S = list(S_raw)
T = list(T_raw)

i = 0
j = 0

j_list = []
S_list = []

lt = len(T)
ls = len(S)

while True:
	if (j >= ls) or (i >= lt):
		if i < lt  :
			if j_list == []:
				print("UNRESTORABLE")
				exit(0)
			else:
				break
		elif j < ls:
			j_list.append(j)
			i = 0
			j = j - lt + 1

		else:
			j_list.append(j)
			break

	if T[i] == S[j]:
		i += 1
		j += 1
	elif S[j] == '?':
		i += 1
		j += 1
	else:
		j -= (i - 1)
		i = 0

for k in j_list:
	M = S[:]
	for i,c in zip(range(k-lt,k),T):
		M[i] = c

	S_tmp = ''

	for i in range(ls):
		if M[i] == '?':
			S_tmp += 'a'
		else:
			S_tmp += M[i]

	S_list.append(S_tmp)

S_list.sort()
print(S_list[0])

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

const int inf = 1001001001;

struct segtree {
  function<int(int, int)> f;
  vector<int> node;
  static const int N = 1 << 18;
  int ide;

  segtree(int ide, function<int(int, int)> f) : ide(ide), f(f), node(2 * N, ide){}

  void init(vector<int> &v) {
    for (int i = 0; i < v.size(); ++i) {
      node[i + N - 1] = v[i];
    }
    for (int i = N - 2; i >= 0; --i) {
      node[i] = f(node[2 * i + 1], node[2 * i + 2]);
    }
  }

  int find(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return ide;
    if (a <= l && r <= b) return node[k];
    return f(
      find(a, b, 2 * k + 1, l, (l + r) / 2),
      find(a, b, 2 * k + 2, (l + r) / 2, r)
    );
  }

  int find(int a, int b) {
    return find(a, b, 0, 0, N);
  }
};

struct data {
  pair<int, int> p;
  int k;
  data(pair<int, int> p, int k) : p(p), k(k) {}
};

bool operator<(const data& a, const data& b) {
  return a.p > b.p;
}

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

  map<int, int> id;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    id[p[i]] = i;
  }

  vector<int> u, v;
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      u.push_back(p[i]);
      v.push_back(inf);
    } else {
      u.push_back(inf);
      v.push_back(p[i]);
    }
  }

  auto f = [&](int a, int b) { return min(a, b); };

  segtree even(inf, f), odd(inf, f);
  odd.init(u);
  even.init(v);

  int idx = 0;
  vector<vector<int>> G(n);
  vector<pair<int, int>> val(n);

  function<void(int, int)> solve = [&](int l, int r) {
    int x, y;
    x = id[(l & 1 ? odd : even).find(l, r)];
    y = id[(l & 1 ? even : odd).find(x, r)];

    int v = idx;
    idx++;

    val[v] = make_pair(p[x], p[y]);
    if (l != x) {
      G[v].push_back(idx);
      solve(l, x);
    }
    if (x + 1 != y) {
      G[v].push_back(idx);
      solve(x + 1, y);
    }
    if (y + 1 != r) {
      G[v].push_back(idx);
      solve(y + 1, r);
    }
  };

  solve(0, n);

  vector<int> ans;

  priority_queue<data> que;
  que.push(data(val[0], 0));
  while (!que.empty()) {
    pair<int, int> p = que.top().p;
    int k = que.top().k;
    que.pop();

    ans.push_back(p.first);
    ans.push_back(p.second);

    for (auto e : G[k]) {
      que.push(data(val[e], e));
    }
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << (i + 1 == n ? "\n" : " ");
  }
}


Measured memory_bytes: 71404
a = int(input())
b = int(input())
c = int(input())
x = int(input())

patterns = 0
for i in range(a+1):
    if i * 500 > x:
        continue
    for j in range(b+1):
        if i*500 + j*100 > x:
            continue
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                patterns += 1
#                 print(i, j, k)
print(patterns)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

ostream& operator<<(ostream& os, const pair<char, int>& unit) {
  return os << unit.first << "^" << unit.second;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

#define px first
#define py second

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; ++i)
    cin >> p[i].px >> p[i].py;
  bool par = (p[0].px ^ p[0].py) & 1;
  for (int i = 1; i < n; ++i)
    if (par != ((p[i].px ^ p[i].py) & 1)) {
      puts("-1");
      return 0;
    }
  // R U L D
  int dim = 33;
  ll s = (1LL << dim) - 1 + par;
  printf("%d\n", dim + !par);
  if (!par)
    puts("1");
  for (int i = 0; i < dim; ++i)
    printf("%lld\n", 1LL << i);
  for (const auto& pr : p) {
    if (!par) putchar('R');
    ll vx = pr.px + pr.py + s, vy = pr.px - pr.py + s;
    for (int i = 1; i <= dim; ++i)
      putchar("LDUR"[((vx >> (i - 1)) & 2) | ((vy >> i) & 1)]);
    putchar('\n');
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//1になる前
//N=9
//9-8
//9/9
//9/3/3
//素因数
//9-1=8
//8の約数
//n=12={1,2,3,4,6,12}
//2,3,11
//n=13
//2,3,4,6,12
//n=14
//2,13
//n=15
//2,7,14
//n=16
//2,3,5,15
//n=19
//2,3,6,9,18
//1個前じゃね
//{2,3}
//n=24
//
//2って必ずOKじゃね？
//素因数分解必須
//-1したものが
int main(){
  ll N; cin>>N;
  N--;
  vector<ll> H,G;
  for(int i=1; i<=N/i; i++){
    if(N%i==0){
      H.emplace_back(i);
      if(i==N/i) continue;
      H.emplace_back(N/i);      
    }
  }
  N++;
  for(int i=1; i<=N/i; i++){
    if(N%i==0){
      G.emplace_back(i);
      if(i==N/i) continue;
      G.emplace_back(N/i);      
    }
  }
  ll Gsz=G.size();
  for(int i=1; i<Gsz; i++){
    ll tmp=N;
    while(tmp%G[i]==0){
      tmp/=G[i];
    }
    if(tmp%G[i]==1) H.emplace_back(G[i]);
  }
  sort(H.begin(), H.end());
  H.erase(unique(H.begin(), H.end()), H.end());
  cout<<H.size()-1<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int x;
  char s[100];
  int stack[100];
  int t=0;
  int ans;

  while( scanf("%s", s) != EOF ){
    
    if ( s[0] == '+' ){
      t--;
 
      stack[t-1]=stack[t-1]+stack[t];

	
    }
    
    else if ( s[0] == '-' ){

      t--;

      stack[t-1]=stack[t-1]-stack[t];
    }
    
    else if ( s[0] == '*' ){
      t--;
      stack[t-1]=stack[t-1]*stack[t];
    }
    
    else {
      x = atoi(s);
      stack[t]=x;
      t++;
    }
  }

  printf("%d\n",stack[0]);
  return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>

int main(void){
	int H, W, i, j;

	scanf("%d %d", &H, &W);
	while (H != 0 && W != 0){
		if (1 <= H && H <= 300 && 1 <= W && W <= 300){
			for(i = 0; i < H; i++){
				for (j = 0; j < W; j++){
					if (i % 2 == 0){
						if (j % 2 == 0) printf("#");
						else printf(".");
					}
					else{
						if (j % 2 == 0) printf(".");
						else printf("#");
					}
				}
				printf("\n");
			}
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}
}

Measured memory_bytes: 572
#include<iostream>
#include<string>
using namespace std;
int main(){

	int N, A, B;

	cin >> N;

	if (N == 1){
		cout << "Hello World" << endl;
	}

	if (N == 2){
		cin >> A >> B;
		cout << A + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    long N = long.Parse(Console.ReadLine());
    long move = long.MaxValue;
    for (long i = 1; i <= Math.Sqrt(N); i++) {
      if (N % i == 0) {
        move = Math.Min(move, (i - 1) + ((N / i) - 1));
      }
    }
    Console.WriteLine(move);
  }
}


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

using namespace std;

int main()
{
    int n, a, b;

    cin >> n >> a >> b;
    string s;
    cin >> s;

    int total = 0;
    int overseas = 0;
    for (int i = 0; i < n; i++)
    {
        if (total >= a+b || s[i] == 'c') cout << "No" << '\n';
        else if (s[i] == 'a')
        {
            total++;
            cout << "Yes" << '\n';
        }
        else if (s[i] == 'b')
        {
            if (overseas < b)
            {
                cout << "Yes" << '\n';
                overseas++;
                total++;
            }
            else cout << "No" << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MODD 1000000007
#define Inf 123372036854775806ll
using namespace std;

int X[111111];
int Y[111111];
int M[111111][18];
int INVPOW[111111];

// 1,2,3
// 1,0,3


int RMQ(int i, int j) {
    if (i > j)
        return 0;
    int k=INVPOW[j-i+1];
    return min(X[M[i][k]],X[M[j-(1<<k)+1][k]]);
}


int main() {
    int N;
    cin>>N;
    
    //vector<int> X(N);
    X[0]=-1;
    for(int i=1;i<=N;i++) {
        cin>>X[i];
        X[i]-=2*i+1;
    }
    
    for(int i=1;i<111111;i++) {
        int k=0;
        while((1<<(k+1))<=i) {
            k++;
        }
        INVPOW[i]=k;
    }
    
    for (int i = 0; i < N; i++)
        M[i][0] = i;
    for (int j = 1; (1 << j) <= N; j++) {
        for (int i = 0; i + (1 << j) - 1 < N; i++) {
            if (X[M[i][j - 1]] <= X[M[i + (1 << (j - 1))][j - 1]])
                M[i][j] = M[i][j - 1];
            else
                M[i][j] = M[i + (1 << (j - 1))][j - 1];
        }
    }
    
    
    ll prod = 1;
    Y[0]=0;
    int prev_ct=0;
    for(int i=1;i<=N;i++) {
        int numsp=0;
        int minn=-1;
        
        int low=1;
        int high=i;
        while(low < high) {
            int mid=(low+high)/2;
            if (RMQ(mid,i-1) >= -2*mid) {
                high=mid;
            } else {
                low=mid+1;
            }
        }
        
        /*
        
        for(int j=1;j<=i;j++) {
            
            if (RMQ(j,i-1) >= -2*j) {
                minn=j;
                break;
            }
            
            // X[j] to X[i-1]
            // X[j] >= 1
            // X[j+1] >= 3
            // X[i-1] >= 2*(i-1-j)+1
            
            // X[k] >= 2*(k-j)+1
            // X[k]-2*k-1 >= -2*j
            bool ok;
            if (X[i-1] < 2*(i-1-j)+1)
                ok=false;
            else
                ok=true;
            
            
            for(int k=j;k<=i-1;k++) {
                //
            }
            // 1,3,...
            bool ok=true;
            // minn(Xt[j]..Xt[i-1]) >= -2*j
            for(int k=j;k<=i-1;k++) {
                if (X[k]-2*k-1<-2*j) {
                    ok=false;
                    break;
                }
            }
            
            if (ok)
            {
                minn=j;
                break;
            }
             
        }
             */
    

        prod = (prod * (ll)(i-low+1))%MODD;
    }
    
    cout << prod%MODD << endl;
    //cout << Solve(X) << endl;
    
    
}

Measured memory_bytes: 8832
import numpy as np
from numba import njit
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())), dtype=np.int64)


@njit
def solve(N, K, A):
    # 一度照らされると二度目以降は確実に照らされるはず。
    for i in range(K):
        # j番目の電球を操作
        B = np.zeros(N + 1, dtype=np.int64)
        for j in range(N):
            # 左辺を確認
            B[max(j - A[j], 0)] += 1
            # 右辺を確認(なんで-1?)
            B[min(j + A[j] + 1, N)] -= 1

        A = np.cumsum(B)[:-1]

        if np.all(A == N):
            return A

    else:
        return A


A = solve(N, K, A)
for i in range(N):
    if i != (N - 1):
        print(A[i], end=" ")
    else:
        print(A[i])


Measured memory_bytes: 120656
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long H, long long W, long long N){
    if(H < W)
        swap(H, W);
    cout<< (N+H-1)/H<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    solve(H, W, N);
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int Q;
map<int, int> mp;

bool pdp[100001];
void Prime(){
	for (int i = 2; i < 100001; i++)
	{
		if (!pdp[i]){
    		++mp[i];
    		for (int j = i + i; j < 100001; j += i)
    		{
    			pdp[j] = true;
    		}
		}
	}
	return;
}

int main(void){
    
    Prime();
    scanf("%d", &Q);
    
    int sum = 0;
    vector<int> v(100001, 0);
    for(int i = 1; i <= 100000; ++i){
        if(mp.find(i) != mp.end() && mp.find((i + 1) / 2) != mp.end()) ++sum;
        v[i] = sum;
    }
    
    for(int i = 0; i < Q; ++i){
        int l, r; scanf("%d %d", &l, &r);
        printf("%d\n", v[r] - v[l - 1]);
    }
	
    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 210;

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  int sg = 0;
  while (n--) {
    int a, k;
    cin >> a >> k;
    while (a % k) {
      int per = a / k + 1, remain = a % k;
      a -= (remain + per - 1) / per * per;
    }
    sg ^= a / k;
  }
  puts(sg ? "Takahashi" : "Aoki");

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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


int main(){
int n,sum=0;
  cin>>n;
  vector<int> v(n-1);
  for(int i=0;i<n-1;i++){
  cin>>v[i];
  }

  for(int i=n-2;i>0;i--){
  sum+=min(v[i],v[i-1]);
  }
  cout<<sum+v[0]+v[n-2];
  
  
  return 0;
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int M = 505;
const int inf = 1e9;

int n, a[M][M];
int b[M][M];

void copy(int a[M][M], int b[M][M]) {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      b[i][j] = a[i][j];
}

void apply(int a[M][M], int i, int j) {
  for (int k = 0; k < n; ++k)
    if (k != i)
      a[k][j] = a[i][k];
  a[i][j] = a[i][i];
}

void read() {
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      a[i][j] = c == '#' ? 1 : 0;
    }
}

int cost(int i) {
  int ans = 0;
  copy(a, b);

  bool noe = true;
  for (int k = 0; k < n; ++k)
    noe &= !b[k][i];
  
  if (noe)
    ++ans;

  for (int j = 0; j < n; ++j)
    if (!b[i][j]) {
      ++ans;
    }

  for (int j = 0; j < n; ++j) {
    for (int t = 0; t < n; ++t)
      if (!b[t][j]) {
        ++ans;
        break;
      }
    }
  return ans;
}

void kill() {
  bool no = true;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      no &= !a[i][j];
  if (no) {
    cout << "-1\n";
    exit(0);
  }

  int ans = inf;
  for (int i = 0; i < n; ++i)
    ans = min(ans, cost(i));
  assert(ans != inf);
  cout << ans << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int a, b;
    cin >> a >> b;
    dump(max(a + b, max(a - b, a * b)));
    return 0;
}

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

using namespace std;


long long ar[100005];
long turn[100005];
long long A[100005],B[100005],C[100005];
long n,m;
priority_queue< long long ,vector<long long >,greater<long long > > mypq;
vector< long long > mystart;
vector< long long > myend;

int main(){
    cin >> n >> m ;
    for(long i=0;i<m;i++) cin>>ar[i];

    for(long i=0;i<m-1;i++)
        if(ar[i]<ar[i+1]){
            mystart.push_back(ar[i]);
            myend.push_back(ar[i+1]);
        }
        else{
            mystart.push_back(ar[i+1]);
            myend.push_back(ar[i]);
        }
    sort(mystart.begin(),mystart.end());
    sort(myend.begin(),myend.end());

    //            for(long i=0;i<mystart.size();i++) cout<<mystart[i]<<" ";cout<<endl;
    //            for(long i=0;i<myend.size();i++) cout<<myend[i]<<" ";cout<<endl;

    long long dem=0;
    for(long i=n;i>=1;i--){
        while(i==mystart[mystart.size()-1]){dem--;mystart.pop_back();}
        while(i==myend[myend.size()-1]){dem++;myend.pop_back();}
        turn[i-1]=dem;
    }
    //            for(long i=1;i<=n;i++) cout<<turn[i]<<" ";cout<<endl;

    for(long i=1;i<n;i++) cin>>A[i]>>B[i]>>C[i];

    dem=0;
    for(long i=0;i<n;i++){
        long long ia=A[i]*turn[i];
        long long ib=C[i]+B[i]*turn[i];

        if(ia>ib) dem+=ib;
        else dem+=ia;
    }
    cout<<dem<<endl;
}

Measured memory_bytes: 8452
#ifdef DBG_MACRO_NO_WARNING
#include <dbg.h>
#endif
#include <bits/stdc++.h>
#define all(c) c.begin(), c.end()
#define isz(c) (int)c.size()

using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main(void)
{
    int a, b;
    cin >> a >> b;

    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3616
N, X = gets.split(" ").map(&:to_i)
output = N + 1
D = 0
l_array = gets.split(" ").map(&:to_i)
(1..N).each{|n|
  D += l_array[n - 1]
  if D > X
    output = n
    break
  end
}
puts output

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string S;
	int ans = 0;
	cin >> S;
	for (int i = 0; i < S.size() - 1 - i; ++i) {
		if (S[i] != S[S.size() - 1 - i]) ++ans;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		string hoge = to_string(i);
      	if (hoge[0] == hoge[4] && hoge[1] == hoge[3])
          	ans++;
    }
	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int max=0;
    if(a==1&&b==1000000000){
        printf("1000000000");
        return 0;
    }
    for(int i=1;i<=b/a;i++){
        if(b%i==0&&i>=max){
                max=i;
        }
    }
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            b[i] = in.nextInt();
        }

        int ans = b[0];
        for (int i = 0; i < n - 2; i++) {
            ans += Math.min(b[i], b[i + 1]);
        }
        ans += b[n - 2];

        System.out.println(ans);
    }
}

Measured memory_bytes: 35820
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC104_1 solver = new ABC104_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC104_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int RR = in.nextInt();

            if (RR < 1200) {
                out.println("ABC");
            } else if (RR < 2800) {
                out.println("ARC");
            } else {
                out.println("AGC");
            }
        }

    }
}



Measured memory_bytes: 21716
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> uni;
int find(int at){
    if(at==uni[at]) return at;
    else return uni[at]=find(uni[at]);
}
void unite(int a,int b){
    uni[find(a)]=find(b);
}

int main(){
    for(;;){
        int n,m;
        scanf("%d%d",&n,&m);
        if(n==0&&m==0) break;
        vector<pair<int,pair<int,int> > > costs;
        uni=vector<int>(n);
        for(int i=0;i<n;i++){
            uni[i]=i;
        }
        for(int i=0;i<m;i++){
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            costs.push_back(make_pair(c,make_pair(a,b)));
        }
        sort(costs.begin(),costs.end());
        int ret=0;
        for(int i=0;i<costs.size();i++){
            int a=costs[i].second.first,b=costs[i].second.second,co=costs[i].first;
            if(find(a)!=find(b)){
                ret+=co;
                unite(a,b);
            }
        }
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 0
N = int(input())
A =[0 for _ in range(N+2)]
A[1:N+1] = list(map(int,input().split()))

cnt = 0

for i in range(N+1):
    cnt += abs(A[i+1]-A[i])

for i in range(1,N+1):
    ans = cnt - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1])
    print(ans)

Measured memory_bytes: 14852
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

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

    vector<int> a(n),b(n);
    REP(i,n){
        cin>>a[i];
    }
    REP(i,n){
        cin>>b[i];
    }

    int sum=0,max=0;
    REP(i,n){
        sum=0;
        REP(j,n){
            if(j<i){
                sum+=a[j];
            }else if(j==i){
                sum+=(a[j]+b[j]);
            }else{
                sum+=b[j];
            }
        }
        if(sum>max){
            max=sum;
        }
    }

    cout<<max<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

// k回2倍 -> bit演算を使うと便利
int main() {
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; k <= n; k++){
                int x = a * (1 << i);
                int y = b * (1 << j);
                int z = c * (1 << k);
                if(i + j + k <= n && x < y && y < z){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3636
import fractions
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i in b[1:]:
        ans=fractions.gcd(ans,i)
    print(ans) 

Measured memory_bytes: 16036
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

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

    let mut count = t.len();

    for i in 0..s.len() - t.len() + 1 {
        let mut c = 0;
        for j in 0..t.len() {
            if t[j] != s[i + j] {
                c += 1;
            }
        }
        if c <= count {
            count = c;
        }
    }


    println!("{}", count);
}


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

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    return 0;
}

Measured memory_bytes: 256
//aising2020_a.cpp
//Sat Jul 11 20:50:58 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int l,r,d;
	cin >> l >> r >> d;

	cout << r/d-(l-1)/d << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<double>v(n);
    rep(i,n)v[i] = i;
    vector<double>x(n),y(n);
    rep(i,n)cin >> x[i] >> y[i];
    double ans = 0;
    do{
        double sum = 0;
        rep(i,n-1)sum += sqrt(pow(x[v[i]]-x[v[i+1]],2) + pow(y[v[i]]-y[v[i+1]],2));
        ans += sum;
    }while(next_permutation(all(v)));
    double m = 1;
    rep(i,n)m *= i+1;
    cout << fixed << setprecision(10) << ans/m << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
using namespace std;
long long s, t;
int main(void){
    // Your code here!
    cin >> s >> t;
    long long test = t / s, a = 1;
    int res = 0;
    while (test >= a) {
        a *= 2;
        res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
ll gcd(ll x, ll y)
{                     
        return (x==0)? y : gcd(y % x, x);
}

int main(){
     string s ; cin >> s ;
     int x  = s.size();
     int res = 1e7;
     for(int i =0 ; i < x-2 ; i++){
     	   int x = s[i] - '0';
     	   int y = s[i+1] - '0';
     	   int z = s[i+2] -'0';
     	   int ans = x*100 + y*10+ z;
     	   res = min(res , abs(ans-753));
	 }
	 cout << res << endl;
}

Measured memory_bytes: 3568
toInt :: (String -> Int)
toInt x = read x ::Int
judgeTransferL :: Int -> Int -> Int -> Int
judgeTransferL a b c
  | (a - b)    <  c = c - (a - b)
  | (a - b)    >= c = 0

main = do
  args <- words <$> getLine
  putStrLn (show (judgeTransferL (map(toInt) args !! 0)
                                 (map(toInt) args !! 1)
                                 (map(toInt) args !! 2)))

Measured memory_bytes: 508
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  s <- getLine
  print $ solve s

solve s =
  maximum
    $ map length
    $ map (\x -> takeWhile (\m -> m `elem` ['A', 'C', 'G', 'T']) x)
    $ tails s


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;



int main()
{
	int L,R,x;
	scanf("%d%d%d",&L,&R,&x);
	int ans = 0;
	for(int i=L;i<=R;i++)
	{
		if(i%x == 0)
		{
			ans++;
		}
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

int n, data[51];
ll dp[51];

int solve(){

  for(int i = 0 ; i < 51 ; i++ ){
    dp[i] = 1ll << i;
  }
  for(int day = 0 ; day < 30 ; day++ ){
    for(int i = 0 ; i < n ; i++ ){
      if( (data[i] >> day) & 1){ //Happyだね
        for(int j = 0 ; j < n ; j++ ){
          if( (data[j] >> day) & 1){ // さらにHappyだね
            dp[i] = dp[j] = ( dp[i] | dp[j] );
          }
        }
      }
    }
    for(int i = 0 ; i < n ; i++ ){
      if( dp[i] == (1ll << n) - 1) return day + 1;
    }
  }
  return -1;
}

int main(){

  while(cin >> n , n){
    fill_n( data, 51, 0);
    for(int i = 0 ; i < n ; i++ ){
      int q;
      cin >> q;
      while( q-- ){
        int day;
        cin >> day;
        day--;
        data[i] |= 1 << day;
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1156
import java.util.*;

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


      System.out.println(repeat("x",n));
    }
  public static String repeat(String str, int n) {
  return String.join("", Collections.nCopies(n, str));
  }
}

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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  a = N / 1000;
  b = N / 100 -a * 10;
  c = N /10 - a * 100 - b * 10;
  d = N - a * 1000 - b * 100 - c * 10;
  
  if (a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
int main()
{
    int i,j,k,n,s1[10000]={0};
    scanf("%d",&n);
    int a[2][n];
       for(i=0;i<2;i++)
       for(j=0;j<n;j++)
       scanf("%d",&a[i][j]);
    for(i=0;i<n;i++)
    {

        for(j=0;j<i;j++)
        {
            s1[i]=s1[i]+a[0][j];
        }
        s1[i]=s1[i]+a[0][i]+a[1][i];

        for(k=i+1;k<n;k++)
        {
            s1[i]=s1[i]+a[1][k];
        }
    }

    sort(s1,s1+n);
    printf("%d",s1[n-1]);
}


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

using namespace std;

typedef long long	ll;
const int N = int(2e6 + 10);
ll fat[N];
const ll mod = ll(1e9 + 7LL);

ll fast_pow(ll number, ll x){
	ll b = number;
	ll r = 1LL;

	while(x){
		if(x & 1LL){
			r = (r * b) % mod;
		}

		b = (b * b) % mod;
		x >>= 1LL;
	}

	return r;
}

ll inv(ll number){
	return fast_pow(number, mod - 2LL);
}

ll comb(ll n, ll k){
	return ((fat[n] * inv(fat[k])) % mod * (inv(fat[n - k]))) % mod;
}

int main(){
	fat[0] = 1LL;

	for(ll i = 1LL ; i < N ; i++){
		fat[i] = (i * fat[i - 1]) % mod;
	}

	ll r1, c1, r2, c2;

	scanf("%lld %lld %lld %lld", &r1, &c1, &r2, &c2);

	ll sum = 0LL;

	for(ll c = c1 ; c <= c2 ; c++){
		sum += comb(r2 + c + 1, c + 1);

		if(sum >= mod){
			sum -= mod;
		}

		sum -= comb(r1 + c, c + 1);
		
		if(sum < 0){
			sum += mod;
		}
	}

	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 15872