akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    string S;

    cin >> S;

    ll N = S.size(), tmp = 0;
    vector<ll>C;
    char l = 'A';

    rep(i, N) {
        if (i == 0) {
            tmp++;
            l = S[i];
        }
        else if (S[i] == l) {
            tmp++;
            if (i == N - 1) {
                C.push_back(tmp);
            }
        }
        else {
            l = S[i];
            C.push_back(tmp);
            tmp = 1;
            if (i == N - 1) {
                C.push_back(tmp);
            }
        }
    }


    ll ans;
    
    if (N == 1) {
        ans = 0;
    }
    else {
        ans = C.size() - 1;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4248
#include<iostream>

using namespace std;

int main(){

  int a,b;
  cin>>a>>b;
  if(a==1 && b==1)cout<<"Draw";
  else if(a==1 && b !=1)cout<<"Alice";
  else if(b==1 && a !=1)cout<<"Bob";
  else if(a>b)cout<<"Alice";
  else if(b>a) cout<<"Bob";
  else cout<<"Draw";
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  int arr[N];
  for(int &x:arr){
    cin>>x;
  }
  int a[N];
  for(int i=0;i<N;i++){
    a[i]=arr[i];
  }
  sort(arr,arr+N);
  reverse(arr,arr+N);
  for(int x:a){
    if(x==arr[0]){
      cout<<arr[1];
    }
    else{
      cout<<arr[0];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3200
import sys
input = sys.stdin.readline

class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        stack = []
        while self.parent_or_size[a] >= 0:
            stack.append(a)
            a = self.parent_or_size[a]
        for i in stack:
            self.parent_or_size[i] = a
        return a

    def size(self, a):
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)


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

int main(){
    int k,n;
    int A[200000];
    int dis,longest=0;
    cin >> k >> n;
    for (int i=0; i<n; i++){
        cin >> A[i];
    }

    for (int i=0; i<n-1; i++){
        dis = max(A[i+1] - A[i], longest);
        if (longest < dis){
            longest = dis;
        }
    }
    dis = max(longest, k - A[n-1] + A[0]);
    if (longest < dis){
        longest = dis;
    }
    cout << k - dis << endl;
    return 0;
    
}

Measured memory_bytes: 1024
import sys

while True:
    
    ins = input().split()
    h = int(ins[0])
    w = int(ins[1])

    if h == 0 and w == 0:
        break
        
    for i in range(h):
        for j in range(w-1):
            sys.stdout.write("#")
        print("#")
        
    print("")

Measured memory_bytes: 8320
#include<iostream>
using namespace std;
int a,b;
main()
{
	cin>>b;
	a=b/100;
	b%=100;
	a=a&&a<13;
	b=b&&b<13;
	cout<<(a?b?"AMBIGUOUS":"MMYY":b?"YYMM":"NA")<<endl;
}


Measured memory_bytes: 640
formula = gets.split

s = []

until formula.empty? do
    o = formula.shift
    if o.match?(/\d+/) then
        s.unshift(o.to_i)
    elsif o == "+" then
        s.unshift(s.shift + s.shift)
    elsif o == "-" then
        s.unshift(s.shift * -1 + s.shift)
    else
        s.unshift(s.shift * s.shift)
    end
    # p s
end

puts s[0]



Measured memory_bytes: 6876
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<ll> X(M);
  for(int i=0;i<M;++i) cin>>X[i];
  sort(X.begin(), X.end());
  vector<ll> L(M-1);
  for(int i=0;i<M-1;++i) {
    L[i] = X[i+1]-X[i];
  }
  sort(L.begin(), L.end(), greater<ll>());
  ll ans = 0;
  for(int i=N-1;i<M-1;++i) ans += L[i];
  cout<<ans<<endl;
}



Measured memory_bytes: 4664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

#define MAX_N 101
#define MAX_M 101
#define INF (1<<29)

int M, N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];

double width(int* X, int* Y, int n, double x){
  double lb = INF, ub = -INF;
  for(int i = 0 ; i < n ; i++){
    double x1 = X[i], y1 = Y[i], x2 = X[(i+1)%n], y2 = Y[(i+1)%n];
    if((x1 - x) * (x2 - x) <= 0 && x1 != x2){
      double y = y1 + (y2-y1) * (x-x1) / (x2-x1);
      lb = min(lb, y);
      ub = max(ub, y);
    }
  }
  return max(0.0, ub - lb);
}

void solve(){
  int min1 = *min_element(X1, X1+M), max1 = *max_element(X1, X1+M);
  int min2 = *min_element(X2, X2+N), max2 = *max_element(X2, X2+N);
  vector<int> xs;
  for(int i = 0 ; i < M ; i++) xs.push_back(X1[i]);
  for(int i = 0 ; i < N ; i++) xs.push_back(X2[i]);
  sort(xs.begin(), xs.end());
  
  double res = 0;
  
  for(int i = 0 ; i+1 < xs.size() ; i++){
    double a = xs[i], b = xs[i+1], c = (a+b)/2;
    if(min1 <= c && c <= max1 && min2 <= c && c <= max2){
      double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
      double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
      double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
      res += (b-a)/6*(fa+4*fc+fb);
    }
  }
  printf("%.10f\n", res);
}

int main(void){

  while(cin >> M >> N,N|M){
    for(int i=0;i<M;i++){
      cin >> X1[i] >> Y1[i];
    }
    for(int i=0;i<N;i++){
      cin >> X2[i] >> Z2[i];
    }
    solve();
  }

  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  return string(1, 'a' + (n%26));
}

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

  string ans = "";
  vector<string> alpha;

  while(N > 0) {
    N--;
    ans = get_alphabet(N) + ans;
    N /= 26;
  }

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


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

int n;
#define MAX 502

vector<int> v;

bool flag[MAX][MAX];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int dist[MAX][MAX];
queue<pair<int,int> > q;
void upd(int a,int b){
	if(a<0||b<0||a>=n||b>=n)return;
	int cur=dist[a][b];
	dist[a][b]=INT_MAX;
	for(int i=0;i<4;i++){
		int xx=a+dx[i];
		int yy=b+dy[i];
		if(xx>=0&&yy>=0&&xx<n&&yy<n){
			dist[a][b]=min(dist[a][b],dist[xx][yy]+1-flag[xx][yy]);
		}
		else{
			dist[a][b]=0;
		}
	}
	if(cur>dist[a][b]){
		for(int g=0;g<4;g++){
			q.push(make_pair(a+dx[g],b+dy[g]));
		}
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n*n;i++){
		int p;
		scanf("%d",&p);
		v.push_back(p);
	}
	long long int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			dist[i][j]=min(min(min(i,j),n-i-1),n-j-1);
		}
	}
	for(int i=0;i<v.size();i++){
		v[i]--;
		int x=v[i]/n;
		int y=v[i]%n;
		ans+=dist[x][y];
		//cerr<<x<<" "<<y<<" "<<dist[x][y]<<endl;
		flag[x][y]=true;
		for(int k=0;k<4;k++){
			q.push({x+dx[k],y+dy[k]});
		}
		while(!q.empty()){
			auto f=q.front();
			q.pop();
			upd(f.first,f.second);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5660
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    S = list(input())
    T = list(input())
    ans = 0
    for i in range(len(S)):
        #print(S[i], T[i])
        if S[i] != T[i]:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 30032
from sys import stdin
import itertools
a = stdin.readline().strip()
n = int(a)
b = list(a)
c = itertools.permutations(b)
ans = ''
j = ['+++','++-','+-+','+--','-++','-+-','--+','---']
for ii in c:
    i = list(ii)
    #print i
    ans = ''
    for x in j:
     #   print x
        f = i[0] + x[0] + i[1] + x[1] + i[2] + x[2] + i[3]
        if eval(f)==7:
            ans = f
            break
    if len(ans):
        break
print ans+'=7'

Measured memory_bytes: 2692
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a,b,ans = 0;
    String calc;
    ArrayList<Integer> ansArray = new ArrayList<Integer>();
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
      while (true) {
        String line = reader.readLine();
        String[] splitted = line.split(" ");
          a = Integer.parseInt(splitted[0]);
          calc = splitted[1];
          b = Integer.parseInt(splitted[2]);
          switch(calc){
            case "+":
              ans = a + b;
              ansArray.add(ans);
              continue;
            case "-":
              ans = a - b;
              ansArray.add(ans);
              continue;
            case "*":
              ans = a * b;
              ansArray.add(ans);
              continue;
            case "/":
              ans = a / b;
              ansArray.add(ans);
              continue;
            case "?":
              break;
            default:
              break;
          }
          break;
          
      }
      
		}catch(Exception e){
      a = 0;
      b = 0;
    }

    for (int item : ansArray){
      System.out.println(item);
  }
		
	}
}


Measured memory_bytes: 24396
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<vector>
#include <algorithm>
#include <sstream>


int main(){
  int a;
  std::string s;
  
  std::cin >> a;
  std::cin >> s;
  
  std::cout << ((a >=3200) ? s : "red") << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359

int main(){
  ll N;
  cin>>N;
  if(N<=1){
    cout<<0<<endl;
    return 0;
  }
ll ans=0;
ll tmp=1;
  while(1){

    if(N-tmp>tmp){
      ans++;
      tmp++;
    }
    else{
      break;
    }
    
  }
cout<<ans<<endl;
  

}


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

int main(){

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

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for(int i=0;i<n;i++){
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout<<mn<<" "<<mx<<" "<<sum<<endl;
  
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<(n);i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;

int main(){
    int n;
    ll ans=0,sum=0;
    cin>>n;
    rep(i,n){
        ll t; cin>>t;
        sum+=t;
        if(t==0 or i+1==n){
            ans+=sum/2;
            sum=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int n;
int par[100000];
int sib[100000];
int deg[100000]; 

int depth(int i) {
  if(par[i] == -1) return 0;
  return depth(par[i]) + 1;
}
 
int height(int i) {
  int j, h;
  h = 0;
  for(j = 0; j < n; ++j) {
    if(par[j] == i) {
      int tmp = height(j)+1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}
 
int main() {
  int i,j;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    par[i] = -1;
    sib[i] = -1;
    deg[i] = 0;
  }
  for(i = 0; i < n; ++i) {
    int id, left, right;
    scanf("%d %d %d", &id, &left, &right);
    if(left != -1) {
      par[left] = id;
      sib[left] = right;
      deg[id]++;
    }
    if(right != -1) {
      par[right] = id;
      sib[right] = left;
      deg[id]++;
    }
  }
 
  for(i = 0; i < n; ++i) {
    int dep = depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, par[i], sib[i], deg[i], dep, height(i));
    if(dep == 0) printf("root\n");
    else if(deg[i] == 0) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}



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

int prime[100000];
vector<ll> p;

void init() {
  for (int i = 2; i < 100000; i++) {
    prime[i] = 1;
  }
  for (ll i = 2; i < 100000; i++) {
    if (prime[i] == 1) {
      p.push_back(i);
      for (ll j = i * i; j < 100000; j += i) {
        prime[j] = 0;
      }
    }
  }
}

int main() {
  ll n, a[100000], m, flag;
  vector<pair<ll, ll> > v;
  map<ll, ll> ma;
  cin >> n >> m;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  init();
  flag = 1;
  while (flag) {
    flag = 1;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 1) {
        flag = 0;
      }
    }
    if (flag) {
      if (ma.find(2) == ma.end()) {
        ma.insert({2, 1});
      } else {
        ma[2]++;
      }
      for (int i = 0; i < n; i++) {
        a[i] /= 2;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (ll i = 0; i < n; i++) {
    v.clear();
    ll x = a[i];
    for (ll j = 1; p[j] * p[j] <= a[i]; j++) {
      while (x % p[j] == 0) {
        if (v.empty() || v.back().first != p[j]) {
          v.push_back({p[j], 1});
        } else {
          v.back().second++;
        }
        x /= p[j];
      }
    }
    if (x != 1) {
      v.push_back({x, 1});
    }
    for (ll j = 0; j < v.size(); j++) {
      if (ma.find(v[j].first) == ma.end()) {
        ma.insert({v[j].first, v[j].second});
      } else {
        ma[v[j].first] = max(ma[v[j].first], v[j].second);
      }
    }
  }
  map<ll, ll>::iterator it = ma.begin();
  ll x = 1;
  while (it != ma.end()) {
    for (ll i = 0; i < it->second; i++) {
      x *= it->first;
      if (x > 2LL * m) {
        cout << 0 << endl;
        return 0;
      }
    }
    it++;
  }
  x /= 2LL;
  cout << m / x / 2 + m / x % 2 << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sort_all(T& v) { return std::sort(v.begin(),v.end()); }
template<typename T>
auto sum_all(const T& v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }
template<typename T>
auto input( std::size_t N,
            const std::vector<T>& head={},
            const std::vector<T>& tail={}) {
    auto s = head.size();
    auto t = tail.size();
    std::vector<T> v;
    v.reserve(s+N+t);
    v.insert(v.end(), head.begin(), head.end());
    v.resize(s+N);
    loop(i,N) std::cin >> v[s+i];
    v.insert(v.end(), tail.begin(), tail.end());
    return std::move(v);
}
class range {
    typedef int Int;
    Int start, stop, step;
    void initialize() {
        auto sign = (step >= 0) ? 1 : -1;
        stop = start + ((stop-start-sign)/step + 1) * step;
        if ((stop-start) * step <= 0) stop = start;
    }
public:
    range(Int start, Int stop, Int step=1) : start(start), stop(stop), step(step) {
        initialize();
    }
    range(Int stop) : start(0), stop(stop), step(1) { initialize(); }
    struct iterator {
        Int i, step;
        Int& operator*() { return i; }
        iterator& operator++() { i += step; return *this; }
        bool operator!=(const iterator& v) { return i != v.i; }
    };
    iterator begin() { return {start, step}; }
    iterator end()   { return {stop, step}; }
};
template<typename T1, typename T2>
std::pair<T1,T2> operator-(const std::pair<T1,T2>& x)
{
    return std::make_pair(-x.first, -x.second);
}
template<typename T1, typename T2>
std::pair<T1,T2> operator+(
    const std::pair<T1,T2>& x,
    const std::pair<T1,T2>& y)
{
    return std::make_pair(x.first+y.first, x.second+y.second);
}
template<typename T1, typename T2>
std::pair<T1,T2> operator-(const std::pair<T1,T2>& x, const std::pair<T1,T2>& y)
{
    return x + (-y);
}
template<typename T1, typename T2>
std::pair<T1,T2>& operator+=(std::pair<T1,T2>& x, const std::pair<T1,T2>& y)
{
    x.first += y.first;
    x.second += y.second;
    return x;
}
template<typename T1, typename T2>
std::pair<T1,T2>& operator-=(std::pair<T1,T2>& x, const std::pair<T1,T2>& y)
{
    return x += (-y);
}
template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& cout, const std::pair<T1,T2>& data)
{
    cout << "(" << data.first << ", " << data.second << ")";
    return cout;
}
template<typename T>
std::ostream& operator<<(std::ostream& cout, const std::vector<T>& data)
{
    cout << "[";
    if (data.size() == 0) {}
    else if (data.size() == 1) { cout << data[0]; } 
    else {
        cout << data[0];
        for (auto itr=data.begin()+1; itr!=data.end(); ++itr) {
            cout << ", " << *itr;
        }
    }
    cout << "]";
    return cout;
}

typedef llint Int;

int main(void)
{
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int n, m;
long long x[100000], y[100000];
long long  ansx, ansy;
int waru = 1000000000+7;
long long ans;
int main() {
	std::cin >> n >> m;
	for (int i = 0; i < n; i++) {
		std::cin >> x[i];
	}
	for (int j = 0; j < m; j++) {
		std::cin >> y[j];
	}
	for (int i = 1; i <= n; i++) {
		ansx = ((i + i - n - 1)*x[i - 1] + ansx) % waru;
	}
	for (int i = 1; i <= m; i++) {
		ansy = ((i + i - m - 1)*y[i - 1] + ansy) % waru;
	}
	ans = (ansx*ansy) % waru;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<101&&a>-101&&b<101&&b>-101&&c<101&&c>-101){
		if(c>=a&&c<=b){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("-100から100の間の数値を入力しろ\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	int sum1,sum2;
	sum1 = x-a;
	sum2 = x-b;
	sum1 < 0 ? sum1 *= -1 : sum1;
	sum2 < 0 ? sum2 *= -1 : sum2;
	sum1 < sum2 ? printf("A\n") : printf("B\n");
	return 0;
}

Measured memory_bytes: 2008
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n; string s; cin >> n >> s;
  int cnt = 0;
  rep(i,n-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      cnt++;
    }
  }
  cout << cnt << endl;
  
  return 0;
}


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

struct Area {
	int a;
	int d;
};


int main() {
	string str;
	stack<int> s;
	queue<int> q;
	vector<Area> as;
	Area area;
	int total = 0;

	area.a = 0;
	area.d = 0;

	cin >> str;

	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '/') {

			if (!s.empty()) {
				area.a = i - s.top();
				area.d--;

				total += area.a;
				for (int i = 0; i < as.size(); i++) {
					if (as[i].d > area.d) {
						area.a += as[i].a;
						as.erase(as.begin() + i);
						i--;
					}
				}
				as.push_back(area);
				area.a = 0;
				s.pop();
				if (s.empty()) {
					q.push(as[0].a);
					
					area.a = 0;
					area.d = 0;
					as.clear();
				}
			}
		}
		else if (str[i] == '\\') {
			s.push(i);
			area.d++;
		}
	}

	for (int i = 0; i < as.size(); i++) {
		q.push(as[i].a);
	}

	cout << total << endl;
	cout << q.size();
	while (!q.empty()) {
		cout << " " << q.front();
		q.pop();
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3212
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 1010;
const int INF = (int) 1e9;

int n, m, d[N][N][2];
char s[N][N];

int main() {

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			d[i][j][0] = INF;
			d[i][j][1] = INF;
		}
	}

	d[0][0][(s[0][0] == '.') ? 0 : 1] = (s[0][0] == '.' ? 0 : 1);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < 2; k++) {
				if (d[i][j][k] == INF) {
					continue;
				}
				if (i + 1 < n) {
					int c = (s[i + 1][j] == '.' ? 0 : 1);
					int v = ((c == 1 && k == 0) ? 1 : 0);
					d[i + 1][j][c] = min(d[i + 1][j][c], d[i][j][k] + v);
				}
				if (j + 1 < m) {
					int c = (s[i][j + 1] == '.' ? 0 : 1);
					int v = ((c == 1 && k == 0) ? 1 : 0);
					d[i][j + 1][c] = min(d[i][j + 1][c], d[i][j][k] + v);
				}
			}
		}
	}

	printf("%d\n", min(d[n - 1][m - 1][0], d[n - 1][m - 1][1]));

	return 0;

}

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



int main(){
  
  long long a,b,n;
  cin>>a>>b>>n;
  long long x = min(b-1,n);
  cout<<(a*x)/b - a*(x/b)<<endl;
  
  
  
  
 return 0; 
  
}

Measured memory_bytes: 3648
#include <stdio.h>
#define MAX 1000000
int main(void){
    // Your code here!
    int K,flag=1;
    scanf("%d",&K);
    int mod=7;
    for(int i=0;i<MAX;i++){
        mod=mod%K;
        if(mod==0) {
            printf("%d",i+1);
            flag =0;
            break;
        }
        else{
        mod=mod*10 +7;
        }
    }
    if(flag==1) printf("-1");
    return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc013_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 1;
  int mode = 0;
  if (c[1] > c[0]) {
    mode = 1;
  } else if (c[1] < c[0]) {
    mode = -1;
  }

  repi(i, 1, N) {
    int bef = mode;
    if (c[i] == c[i - 1]) continue;
    if (c[i] > c[i - 1]) {
      mode = 1;
    } else if (c[i] < c[i - 1]) {
      mode = -1;
    }

    if (bef != 0 && bef != mode) {
      ans++;
      mode = 0;
      if (c[i + 1] > c[i]) {
        mode = 1;
      } else if (c[i + 1] < c[i]) {
        mode = -1;
      }
    }
  }

  cout << ans << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int32 R, G, B, N;
    cin >> R >> G >> B >> N;
    int32 ans = 0;
    REP(r,N / R + 1){
        REP(g,N / G + 1){
            if(R * r + G * g > N)break;
            if((N - (R * r + G * g)) % B == 0)ans++;
        }
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class ADividingAString {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int[][] dp = new int[s.length + 1][3];
            for (int[] i : dp) {
                Arrays.fill(i, Integer.MIN_VALUE);
            }
            dp[0][0] = 0;
            for (int pos = 0; pos < s.length; pos++) {
                for (int len = 0; len <= 2; len++) {
                    if (dp[pos][len] != Integer.MIN_VALUE) {
                        for (int newLen = 1; newLen <= 2 && pos + newLen <= s.length; newLen++) {
                            if (!eq(s, pos, len, newLen)) {
                                dp[pos + newLen][newLen] = Math.max(dp[pos + newLen][newLen], dp[pos][len] + 1);
                            }
                        }
                    }
                }
            }
            out.println(Math.max(dp[s.length][2], dp[s.length][1]));
        }

        private boolean eq(char[] s, int pos, int len, int newLen) {
            if (len != newLen) {
                return false;
            }
            if (pos == 0) {
                return false;
            }
            for (int i = 0; i < len; i++) {
                if (s[pos - len + i] != s[pos + i]) {
                    return false;
                }
            }
            return true;
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



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

using namespace std;

const int MAXN = 1e5 + 10;

int n;
long long arr[MAXN], all;
vector<int> vec;

long long gcd(long long v, long long u) {
	return v ? gcd(u % v, v) : u;
}

bool solve() {
	all = 0;
	vec.clear();
	for (int i = 0; i < n; i++) {
		all += arr[i];
		if (arr[i] & 1)
			vec.push_back(i);
	}
	if ((all & 1) != (n & 1))
		return true;
	if (vec.size() != 1 || arr[vec[0]] == 1)
		return false;
	arr[vec[0]]--;
	int GCD = arr[0];
	for (int i = 1; i < n; i++)
		GCD = gcd(GCD, arr[i]);
	for (int i = 0; i < n; i++) 
		arr[i] /= GCD;
	return !solve();
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		all += arr[i];
	}
	if (n <= 2) {
		if ((all & 1) == (n & 1))
			cout << "Second\n";
		else
			cout << "First\n";
		return 0;
	}
	if (solve()) 
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}

Measured memory_bytes: 1660
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int k, s;
    while (cin >> k >> s) {
        int ans = 0;
        FOR(x,0,k+1) FOR(y,0,k+1) {
            int z = s - x - y;
            if (z >= 0 && z <= k)
                ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
const int mod = 1e9+7;
const double eps = 1e-8;
const double pi = asin(1.0)*2;
const double e = 2.718281828459;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}

struct edge {
	double u;
	double v;
	double d;
	edge(double _u = 0, double _v = 0, double _d = 0): u(_u), v(_v), d(_d) {}
	bool operator < (const edge &a) const {
		return d > a.d;
	}
};

int n, m;
int tu, tv;
double ans;
PDD co[maxn];
int pre[maxn];
vector<edge> q;

void init() {
	for (int i = 1; i <= n; ++i) {
		pre[i] = i;
	}
}

int find(int x) {
	if (x == pre[x]) {
		return pre[x];
	}
	else {
		pre[x] = find(pre[x]);
		return pre[x];
	}
}

double caldis(PDD a, PDD b) {
	return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}

int main(int argc, char *argv[]) {
//#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
	read(n); read(m);
	init();
	for (int i = 1; i <= n; ++i) {
		read(co[i].first);
		read(co[i].second);
	}
	for (int i = 1; i <= m; ++i) {
		read(tu); read(tv);
		q.pb(edge(tu, tv, caldis(co[tu], co[tv])));
	}
	sort(q.begin(), q.end());
	ans = 0;
	for (int i = 0; i < int (q.size()); ++i) {
		int x = find(q[i].u), y = find(q[i].v);
		if (x != y) {
			pre[x] = y;
		}
		else {
			ans += q[i].d;
		}
	}
	printf("%.3lf\n", ans);
//#ifndef ONLINE_JUDGE
//	fclose(stdin);
//	fclose(stdout);
//	system("gedit out.txt");
//#endif
    return 0;
}



Measured memory_bytes: 3936
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

bool f(ll x) {
  vector<int> vec = {3, 5, 7};
  vector<bool> appears(3);
  while(x) {
    rep(i, 3) {
      if(x % 10 == vec[i]) appears[i] = true;
    }
    x /= 10;
  }
  bool res = true;
  rep(i, 3) res &= appears[i];
  return res;
}

int dfs(ll x, ll n) {
  int res = 0;
  if(x > n) return 0;
  if(f(x)) res++;
  rep(i, 3) res += dfs(x * 10 + 2 * i + 3, n);
  return res;
}

int main() {
  ll n;
  cin >> n;
  cout << dfs(0, n) << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    R, G, B, N = map(int, input().split())

    cnt = 0
    for r in range(N//R+1):
        if r*R > N: break
        for g in range(N//G+1):
            if r*R + g*G > N: break
            res = N - (r*R+g*G)
            if res % B == 0:
                cnt += 1
    print(cnt)

main()

Measured memory_bytes: 9144
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;
const ll mod=1e9+7;

//const ll INF=1e10+100;
const ll white=0; //未探索
const ll gray=1; //探索中
const ll black=2; //探索済み

vector<vector<pll>> m; 

ll v,r;

vector<ll> d_p,d_q,d;

void dijkstra(){
    priority_queue<pll> PQ;
    vector<ll> color(v);
    rep(i,v){
        d[i]=INF;
        color[i]=white;
    }
    d[r]=0;
    PQ.push(make_pair(0,r));
    color[r]=gray;
    while(!PQ.empty()){
        pll f=PQ.top();
        PQ.pop();
        ll u=f.second;
        color[u]=black;
        if(d[u]<f.first*(-1)) continue; //d[u]は正。
        for(ll j=0;j<m[u].size();j++){
            ll v=m[u][j].first;
            if(color[v]==black) continue;
            if(d[v]>d[u]+m[u][j].second){
                d[v]=d[u]+m[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=gray;
            }
        }
    }
    /*rep(i,v){
        if(d[i]==INF){
            cout << "INF" << endl;
        }
        else{
            cout << d[i] << endl;
        }
    }*/
}

const ll cash=1e15;

int main(){
    ll n,M,s,t;
    cin >> n >> M >> s >> t;
    s--; t--;
    v=n;
    r=s;
    d_p.resize(n);
    d_q.resize(n);
    d.resize(n);
    vector<vector<pll>> p(n),q(n);
    rep(i,M){
        ll u,v,a,b;
        cin >> u >> v >> a >> b;
        u--; v--;
        p[u].push_back({v,a});
        p[v].push_back({u,a});
        q[u].push_back({v,b});
        q[v].push_back({u,b});
    }
    m=p;
    dijkstra();
    d_p=d;
    m=q;
    r=t;
    dijkstra();
    d_q=d;
    vector<ll> ans(n);
    rep(i,n){
        ans[i]=cash-(d_p[i]-d_p[s]+d_q[i]-d_q[t]);
        //cout << ans[i] << endl;
    }
    for(ll i=n-1;i>=0;i--){
        if(i==n-1) continue;
        ans[i]=max(ans[i],ans[i+1]);
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(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 ALL(v) v.begin(), v.end()

int main() {
  int n;
  int ans;
  cin >> n;
  vector<int> d(n);
  REP(i,n) {
    cin >> d[i];
  }
  sort(ALL(d));
  int l = d[n/2-1];
  int r = d[n/2];
  cout << r-l << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a,b,i,k;
stack<int>st;
char ans,stt[5000];
int main()
{
   // freopen("a.in","r",stdin);
  //  freopen("a.out","w",stdout);
    scanf("%d%d",&a,&b);
    if(a<=b)
    {
        printf("Impossible\n");
        return 0;
    }
    for(i=0; i<a+b; ++i)
        if(st.empty())st.push(i);
        else
        {
         //   printf("? %d %d\n",st.top(),i);
         cout<<'?'<<" "<<st.top()<<" "<<i<<'\n';
            fflush(stdout);
            cin>>ans;
            if(ans=='N')st.pop();
            else st.push(i);
        }
    k=0;
    for(i=0; i<a+b; ++i)
    {
        cout<<'?'<<" "<<st.top()<<" "<<i<<'\n';
        fflush(stdout);
        cin>>ans;
        if(ans=='N')stt[k++]='0';
        else stt[k++]='1';
    }
    printf("! %s",stt);
    return 0;
}



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

const int maxn=505;
int n,m,q,dif[maxn][maxn],ans[maxn][maxn],f[maxn][maxn],l,r;

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&l,&r);
		dif[l][r]++;
	}
	for (int j=1;j<=n;j++){
		ans[j][j]=dif[j][j];
		for (int i=j-1;i>=1;i--) ans[i][j]=ans[i+1][j]+dif[i][j];
	}
	for (int i=1;i<=n;i++){
		f[i][i]=dif[i][i];
		for (int j=i+1;j<=n;j++) f[i][j]=f[i][j-1]+ans[i][j];
	}
	for (int i=1;i<=q;i++){
		scanf("%d%d",&l,&r);
		printf("%d\n",f[l][r]);
	}
	return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		int sum=0;
		int uo=0;
		for(int i=0;;i++) {
			sum+=i;
			if(sum>=a) {
				uo=i;
				break;
			}
		}
		int b=sum-a;
		for(int i=1;i<=uo;i++) {
			if(i!=b)System.out.println(i);
		}
	}
}

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

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

	int m, d;
	cin >> m >> d;

	int res = 0;
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= d; ++j) {
			int ones = j % 10;
			int tens = j / 10;
			if (ones >= 2 && tens >= 2 && ones * tens == i) ++res;
		}
	}
	cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <utility>
#include <algorithm>
#include<map>
#include<cmath>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int INF = 1 << 29;
int n,x[101];
int main(){
    cin>>n;rep(i,n)cin>>x[i];
    int sum=0;
    int min=INF;
rep(i,100){
    sum=0;
    rep(j,n){
    sum+=(x[j]-i)*(x[j]-i);
}
if(sum<min)min=sum;
}
cout<<min<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 5000

int v[MAX][MAX];

main(){
  int a,b,ten,k,i,j,p,q;

  scanf("%d",&ten);
  for(i = 0;i < ten;i++){
    scanf("%d%d",&q,&p);
    for(j = 0;j < p;j++){
    scanf("%d",&b);
    v[q-1][b-1] = 1;
    }
    }
  for(i = 0;i < ten;i++){
    for(j = 0;j <ten-1; j++){
      printf("%d ",v[i][j]);
    }
    printf("%d\n",v[i][j]);
  }
  return 0;
}

Measured memory_bytes: 1000
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

	vector<u64> A(N);
	vector<u64> a_max(N);

	for(u64 i=0; i<N; i++) {
		cin >> A[i];
		a_max[i] = (i > 0) ? max(a_max[i-1], A[i]) : A[i];
	}
	
	u64 ans = 0;
	for(u64 i=0; i<N; i++) {
		ans += (A[i] > a_max[i]) ? 0 : a_max[i] - A[i];
	}

	cout << ans << endl;

	return 0;
	
}


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

using namespace std;

typedef pair < int, int > pI;
#define fr first
#define sc second

const int N = 2e5 + 7;

pI v[N];

bool fc(pI a, pI b) {
    if (a.sc == b.sc)
        return a.fr < b.fr;
    return a.sc < b.sc;
}

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    for (int i = 0; i < n; ++i)
        cin >> v[i].fr >> v[i].sc;
    v[n++] = {h + 1, 1};
    sort(v, v + n, fc);
    int ans(v[0].fr);
    for (int i = 2, x(1), p(0); i <= w; ++i) {
        ++x;
        while (p < n && fc(v[p], {x, i}))
            ++p;
        if (p < n && v[p] == (pI){x, i}) {
            while (p < n && v[p + 1].sc == i && v[p + 1].fr == v[p].fr + 1)
                ++p;
            x = v[p++].fr + 1;
        }
        if (p < n && v[p].sc == i)
            ans = min(ans, v[p].fr);
    }
    cout << ans - 1;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>

std::string D[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::string d;
    std::cin >> d;
    int i=0;
    while (D[i] != d) ++i;
    std::cout << 7-i << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>

int main()
{   char s[200001];
    scanf("%s",s);
    int a,z;
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(int i=0;i<strlen(s);i++){
        if(s[strlen(s)-i]=='Z'){
            z=strlen(s)-i;
            break;
        }
    }
    printf("%d",z-a+1);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
int main()
{

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

	string s;
	cin >> s;

	int f = -1, ss = -1;
	int c1 = 0, c2 = 0;
	int ans[s.size()] = {0};
	c2++;
	for (int i = 1; i < s.size(); i++)
	{
		if (s[i - 1] == 'L' && s[i] == 'R')
		{
			/* watch(c1);
			watch(c2); */
			ans[f] = (f % 2 ? c1 : c2);
			ans[ss] = (ss % 2 ? c1 : c2);
			c1 = c2 = 0;
			f = ss = -1;
		}
		if (i % 2)
			c1++;
		else
			c2++;
		if (s[i - 1] == 'R' && s[i] == 'L')
		{
			f = i - 1, ss = i;
		}
	}
	/* watch(c1);
	watch(c2); */
	ans[f] = (f % 2 ? c1 : c2);
	ans[ss] = (ss % 2 ? c1 : c2);
	c1 = c2 = 0;
	f = ss = -1;

	for (int i = 0; i < s.size(); i++)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    K--;
    string S;
    cin >> S;

    char c = S[K];
    S[K] = c + 'a' - 'A';

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256