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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<double, double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n)               \
  for (int vari = 0; vari < (n)-1; ++vari) \
    for (int varj = vari + 1; varj < (n); ++varj)
#define repC3(vari, varj, vark, n)                  \
  for (int vari = 0; vari < (n)-2; ++vari)          \
    for (int varj = vari + 1; varj < (n)-1; ++varj) \
      for (int vark = varj + 1; vark < (n); ++vark)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define found(s, e) ((s).find(e) != (s).end())
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
#define cons make_pair
#define clamp(v, lo, hi) min(max(v, lo), hi)
#define ABS(x) max((x), -(x))
#define PQ(T) priority_queue<T, vector<T>, greater<T>>

template <typename T1, typename T2>
inline void amin(T1& a, T2 const& b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void amax(T1& a, T2 const& b) {
  if (a < b) a = b;
}
template <typename X, typename T>
auto vectors(X x, T a) {
  return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
  auto cont = vectors(y, z, zs...);
  return vector<decltype(cont)>(x, cont);
}

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) {
  while (a) swap(a, b %= a);
  return b;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <typename T>
inline T mod(T a, T b) {
  return ((a % b) + b) % b;
}

int main() {
  ll A;
  cin >> A;
  int r = A % 1000;
  int ans = (r == 0) ? 0 : 1000 - r;

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


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 24)
		cout << a + b - 24 << endl;
	else
		cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> friend_tree(n);
    vector<int> block_cnt(n,0);
    vector<int> color(n, 0);
    unordered_map<int, int> ctc;
    int mc = 0;
    REP(i, m)
    {
        int a, b;
        cin >> a >> b;
        friend_tree[a - 1].push_back(b - 1);
        friend_tree[b - 1].push_back(a - 1);
    }

    REP(i,n){
        if(color[i] != 0){
            continue;
        }

        queue<int> s;
        s.push(i);
        color[i] = ++mc;
        ctc[mc] = 0;
        while (!s.empty())
        {
            int v = s.front();
            s.pop();
            REP(j,friend_tree[v].size()){
                if(color[friend_tree[v][j]] == 0){
                    color[friend_tree[v][j]] = color[i];
                    ctc[color[i]]++;
                    s.push(friend_tree[v][j]);
                }
            }
        }
    }

    REP(i,k){
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        if (color[c] == color[d])
        {
            block_cnt[c]++;
            block_cnt[d]++;
        }

    }

    REP(i,n){
        cout << ctc[color[i]] - friend_tree[i].size() - block_cnt[i] << " ";
    }
    cout << endl;

    return 0;
}

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

    int H, W;
    cin >> H >> W;
    
	while (1) {
		if ((H == 0)&&(W == 0)) break;
		for (int h = 1; h <= H; h++) {
	   	 	for (int w = 1; w <= W; w++) {
	    		cout << "#";
			}
			cout << endl;
		}
	cout << endl;
	cin >> H >> W;
	}

    return 0;
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////i

int n;P a[110000];
signed main(){
  cin>>n;rep(i,n)cin>>a[i].first;rep(i,n)a[i].second = i+1;
  sort(a, a+n);
  rep(i,n)cout << a[i].second << (i == n-1 ? "\n" : " ");
}





Measured memory_bytes: 1664
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = (a); i <= (b); ++i)
#define ll long long

main() {
    while(1) {
        int n, m;
        cin >> n >> m;
        if(!n) return 0;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        int ma = 0;
        rep(i, n) rep2(j, i + 1, n - 1) {
            if(a[i] + a[j] <= m) ma = max(ma, a[i] + a[j]);
        }
        if(ma)
            cout << ma << endl;
        else
            cout << "NONE" << endl;
    }
}


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


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

int A;
vector<int> B(100002);
for( int i = 0; i < N; i++ ){
cin >> A;
if( A == 0 ){
B.at(A)++;
B.at(A+1)++;
}else {
B.at(A-1)++;
B.at(A)++;
B.at(A+1)++;
}
}

int ans = 0;
for( int i = 0; i <= 100001; i++ ){
if( B.at(i) > ans ) {
ans = B.at(i);
}
}
cout << ans << endl;

}


Measured memory_bytes: 1024
//be name khoda
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll maxn = 3e5;
const ll K = 4e3;
const ll mod = 1e9+7;

ll poww(ll a, ll b)
{
    if(b == 0) return 1;
    if(b == 1) return a;
    ll k = poww(a,b/2); k = (k*k) % mod;
    if(b&1) k = (k*a) % mod;
    return k;
}

ll fac[maxn+10];
ll C(ll n, ll k)
{
    if(n < k) return 0;

    ll x = (fac[k] * fac[n-k]) % mod;
    return (fac[n] * poww(x,mod-2)) % mod;
}

ll n , m , k, d;
ll dp[K];
vector<pair<ll,ll> > v1;
vector<ll> v2[maxn+10];
vector<pair<ll,ll> > v;
ll h,w;

int main()
{
    fac[0] = 1;
    for(ll i = 1; i <= maxn; i++) fac[i] = (fac[i-1] * i) % mod;

    cin>> h >> w >> n;
    for(ll i = 0; i < n; i++)
    {
        ll r, c; cin>> r >> c;
        v1.push_back({r,c});
        v2[r].push_back(c);
    }
    for(ll i = 1; i <= maxn; i++)
        if(v2[i].size())
            sort(v2[i].begin(), v2[i].end());
    sort(v1.begin(), v1.end());

    for(ll i = 0; i < n; i++)
    {
        if(i == 0)
            for(ll j = 0; j < v2[v1[i].first].size(); j++)
                v.push_back({v1[i].first, v2[v1[i].first][j]});
        if(i != 0)
            if(v1[i].first != v1[i-1].first)
                for(ll j = 0; j < v2[v1[i].first].size(); j++)
                    v.push_back({v1[i].first, v2[v1[i].first][j]});

    }

    v.push_back({h,w});

    dp[0] = C(v[0].first+v[0].second-2, v[0].second-1);
    for(ll i = 1; i < v.size(); i++)
    {
        dp[i] = C(v[i].first+v[i].second-2, v[i].second-1);
        for(ll j = 0; j < i; j++){
            dp[i] -= (dp[j] * C(v[i].first+v[i].second-v[j].first-v[j].second, v[i].first-v[j].first)) % mod; dp[i] %= mod;
            if(dp[i] < 0) dp[i] += mod;
        }
    }
    cout<< dp[v.size()-1];
}











Measured memory_bytes: 9856
import math

while True:
    n = int(input())
    if n == 0:
        break
    data = [int(n) for n in input().split()]
    ave = sum(data) / len(data)
    var = 0
    for s in data:
        var += (s - ave) ** 2
    print(math.sqrt(var / len(data)))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>cnt(n+1);
  rep(i,n-1){
    int a;
    cin>>a;
    cnt[a-1]++;
  }
  rep(i,n){
    cout<<cnt[i]<<endl;
  }
  return(0);
}
  


Measured memory_bytes: 4052
#include <iostream>

using namespace std;

int main() {
    int N, P;
    cin >> N >> P;
    bool odd = false;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        if (A & 1) odd = true;
    }
    cout << (odd ? 1LL << (N - 1) : (P ? 0 : 1LL << N)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;
const int MAX_N = 8;
bool graph[MAX_N][MAX_N];
bool visited[MAX_N];

int n, m;
int ans = 0;

void dfs(int curN){
    bool flag = true;
    REP(i, n) {
        if(!visited[i]) {
            flag = false;
            break;
        }
    }
    if(flag) {
        ans++;
        return;
    }

    REP(i, n) {
        if(!graph[curN][i]) continue;
        if(visited[i]) continue;
        visited[i] = true;
        dfs(i);
        visited[i] = false;
    }
}

int main() {
    cin >> n >> m;
    int a, b;
    REP(i, m) {
        cin >> a >> b;
        graph[a-1][b-1] = true;
        graph[b-1][a-1] = true;
    }
    REP(i, n) {
        visited[i] = false;
    }
    visited[0] = true;
    dfs(0);
    cout << ans << endl;
}

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

int N;
string S;

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

    int ans = 0;
    rep(i, S.size()) {
        map<char, int> mp;
        set<char> st_l;
        set<char> st_r;
        int tmp = 0;

        for (int j = 0; j < S.size(); j++) {
            if (i >= j) {
                st_l.insert(S[j]);
            } else {
                st_r.insert(S[j]);
            }
        }

        for (auto iter = st_l.begin(); iter != st_l.end(); iter++) {
            mp[*iter]++;
        }

        for (auto iter = st_r.begin(); iter != st_r.end(); iter++) {
            mp[*iter]++;
        }

        for (auto iter = mp.begin(); iter != mp.end(); iter++) {
            // cout << iter->first << " " << iter->second << endl;
            if (iter->second == 2) tmp++;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve(){
    string s;
    cin>>s;
    reverse(all(s));
    ll n=s.size();
    ll m=2019;
    ll pow10=1;

    ll ans=0;
    Array con(2019,0);
    con[0]=1;
    ll num=0;

    REP(i,n){
        ll d=s[i]-'0';
        num+=d*pow10%m;
        num%=m;
        ans+=con[num];
        con[num]++;
        pow10*=10;
        pow10%=m;
    }
    cout<<ans<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define ull unsigned long long
using namespace std;


ull gcd(ull a, ull b){
    if(a == 0) return b;
    else if(b == 0) return a;
    if(a == b) return a;
    else if(a > b) return gcd(a%b,b);
    else return gcd(b%a,a);
}


int main(){
    ll N,X;
    cin >> N >> X;
    ll x;
    ll last = 0;
    REP(i,N){
        cin >> x;
        ll diff = abs(x-X);
        last = gcd(last, diff);
    }

    cout << last << endl;
    return 0;
}


Measured memory_bytes: 256
l,r=map(int,input().split())
r-=(l//2019)*2019
l%=2019
if r>=2019:
  print(0)
  exit()
ans=2019
for i in range(l,r):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int p[n + 1];
  REP1(i, n) cin >> p[i];
  int index[n + 1];
  REP1(i, n) index[p[i]] = i;
  multiset<int> st;
  st.insert(0);
  st.insert(0);
  st.insert(n + 1);
  st.insert(n + 1);
  ll ans = 0;
  for (int i = n; i >= 1; --i) {
    st.insert(index[i]);
    auto it = st.lower_bound(index[i]);
    --it;
    --it;
    int w = *it;
    ++it;
    int x = *it;
    it = st.upper_bound(index[i]);
    int y = *it;
    ++it;
    int z = *it;
    ans += 1ll * i * (x - w) * (y - index[i]);
    ans += 1ll * i * (index[i] - x) * (z - y);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
from collections import Counter

s = list(input())
ls = len(s)
T = [0] * (ls+1)
modL = [0]
cnt = 0
pad = 1

for i in reversed(range(0, ls)):
    T[i] = T[i+1] + int(s[i]) * pad
    modL.append(T[i] % 2019)
    pad = pad * 10 % 2019

ans = 0
for c in Counter(modL).values():
    ans += c * (c - 1) // 2

print(ans)


Measured memory_bytes: 26164
L = [[0]*10 for _ in range(10)]
S = 0
for i in range(1, int(input())+1):
  L[int(str(i)[0])][int(str(i)[-1])] += 1
for j in range(9):
  for i in range(j+1, 10):
    S += 2*L[j][i]*L[i][j]
for i in range(10):
  S += L[i][i]**2
print(S)

Measured memory_bytes: 73572
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int ans[105][105];
int arr[100005];
void solve() {
  int layer = 0;
  int dir = 1;
  int i = 0 ;
  int j = 0;
  int cnt = 0;
  int k = 0;
  for(cnt = 0 ; cnt < n*m ; cnt++){
    if(dir == 1){
      if(!arr[k]) {
	k++;
      }
//      cout << k <<" "<<arr[k] << endl;
      ans[i][j] = (k+1);
      arr[k]--;
      j++;
      if(j == m-layer){
	i++;
	dir = 2;
	j = m-layer-1;
      }
    }
    else if(dir == 2){
      if(!arr[k]) k++;
      ans[i][j] = (k+1);
      arr[k]--;
      i++;
      if(i == n-layer){
	dir = 3;
	i = n-layer-1;
	j--; 
      }
    }
    else if(dir == 3){
      if(!arr[k]) k++;
      ans[i][j] = (k+1);
      arr[k]--;
      j--;
      if(j == layer-1){
	dir = 4;
	j = layer;
	i--;
      }
    }
    else if(dir == 4){
      if(!arr[k]) k++;
      ans[i][j] = (k+1);
      arr[k]--;
      i--;
      if(i == layer){
	layer++;
	j++;
	i++;
	dir = 1;
      }
    }
  }
  for(int i = 0 ; i < n ; i++) {
    for(int j = 0 ; j < m ; j++) {
      cout << ans[i][j] <<" ";
    }
    cout << endl;
  }
}
int main() {
  cin >> n >> m;
  cin >> k;
  for(int i = 0 ; i < k ; i++) {
    cin >> arr[i];
  }
  solve();
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n,m,q;
  cin >> n >> m >> q;

  // cnt[l][r] .. count of trains at (l,r).
  vector<vector<ll>> cnt(n,vector<ll>(n));
  rep(i,m) {
    ll l,r;
    cin >> l >> r;
    --l;--r;
    ++cnt[l][r];
  }

  // s[r][c] .. sum of cnt in [0,r)-[0,c)
  vector<vector<ll>> s(n+1,vector<ll>(n+1));
  rep(r,n) {
    vector<ll> now(n+1);
    rep(c,n) {
      now[c+1] += now[c] + cnt[r][c];
      s[r+1][c+1] = s[r][c+1] + now[c+1];
    }
  }

  // sum of [r1,r2)-[c1,c2)
  auto calc = [&](ll r1, ll c1, ll r2, ll c2) {
    return s[r2][c2] - s[r1][c2] - s[r2][c1] + s[r1][c1];
  };

  rep(iter,q) {
    ll p,q;
    cin >> p >> q;
    --p;--q;
    cout << calc(p,p,q+1,q+1) << endl;
  }
}


Measured memory_bytes: 4864
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def main():
    k = int(input())
    ans = 0
    for i in range(1, k+1):
        ans += k//i * (2 * i + (k//i - 1) * i) // 2
    print(ans)
main()


Measured memory_bytes: 9392
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int N;
    R(N);
    int ma=0;
    LL an=0;
    REP(i,N){
        int v;
        R(v);
        if(v<ma)an+=ma-v;
        else ma=v;
    }
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	string s;
	cin >> s;
	stack<char> stk;
	int res = 0;
	for(char x : s){
		if(stk.empty()){
			stk.push(x);
			continue;
		}
		if(stk.top() != x){
			stk.pop();
			res += 2;
		}
		else stk.push(x);
	}
	cout << res;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  int n,res=0;
  cin>>n;
  vector<int> a(n),s(n+1),x(n+1);
  for(int i=0;i<n;++i)cin>>a[i];
  s[0]=x[0]=0;
  for(int i=1;i<=n;++i){
    s[i]=a[i-1]+s[i-1];
    x[i]=a[i-1]^x[i-1];
  }
  int r=1;
  for(int l=1;l<=n&&r<=n;++l){
    while(r<n&&s[r+1]-s[l-1]==(x[r+1]^x[l-1]))r++;
    if(r>n)break;
    res+=r-l+1;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 4992
def gen_range(N, Y, reverse=False):
    for i in range(N, 0 - 1, -1):
        for j in range(N - i + 1):
            if reverse:
                yield (j, i, N - i - j)
            else:
                yield (i, j, N - j - i)


def calc(N, Y):
    if 10000 * N < Y or Y < 1000 * N:
        return [-1, -1, -1]
    if Y % 10000 == 0 and Y // 10000 == N:
        return (Y // 10000, 0, 0)
    if Y % 5000 == 0 and Y // 5000 == N:
        return (0, Y // 5000, 0)
    if Y % 1000 == 0 and Y // 1000 == N:
        return (0, 0, Y // 1000)
    if (Y - 1000 * N) % 4000 == 0:
        k5 = (Y - 1000 * N) // 4000
        if k5 >= 0 and N - k5 >= 0:
            return [0, k5, N - k5]
    elif (Y - 1000 * N) % 9000 == 0:
        k10 = (Y - 1000 * N) // 9000
        if k10 >= 0 and N - k10 >= 0:
            return [k10, 0, N - k10]
    if 5000 * N < Y:
        for k10, k1, k5 in gen_range(N, Y, reverse=True):
            if k10 * 10000 + k1 * 1000 + k5 * 5000 == Y:
                return (k10, k5, k1)
    else:
        for k10, k1, k5 in gen_range(N, Y):
            if k10 * 10000 + k1 * 1000 + k5 * 5000 == Y:
                return (k10, k5, k1)

    #
    # for k1 in range(N, 0 - 1, -1):
    #     for k10 in range(N - k1 + 1):
    #         if k1 * 1000 + k10 * 10000 > Y:
    #             break
    #         for k5 in range(N - k1 - k10 + 1):
    #             print(k10, k5, k1)
    #             if k1 * 1000 + k5 * 5000 + k10 * 10000 == Y:
    #                 return [k10, k5, k1]
    return (-1, -1, -1)


def main():
    N, Y = list(map(int, input().split()))
    print(*calc(N, Y))


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

int n, k, h[200005];
ll sums;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h, h+n);
    for(int i=0;i<n-k;i++){
        sums+=h[i];
    }
    cout<<sums;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>


typedef struct{
	double x;
	double y;
} C_T;	// coordinate


void Koch(int n, C_T p1, C_T p2)
{
	C_T s, t, u;


	if(n == 0)
		return;

	// p1, p2から三等分&正三角形の座標を求める
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x) * cos(60 * M_PI / 180) - (t.y - s.y) * sin(60 * M_PI / 180) + s.x;
	u.y = (t.x - s.x) * sin(60 * M_PI / 180) + (t.y - s.y) * cos(60 * M_PI / 180) + s.y;

	Koch(n - 1, p1, s);
	printf("%.8f %.8f\n", s.x, s.y);

	Koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);

	Koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);

	Koch(n - 1, t, p2);
}


int main()
{
	int n;
	C_T p1, p2;


	scanf("%d", &n);

	p1.x = 0;
	p1.y = 0;
	p2.x = 100;
	p2.y = 0;


	printf("%.8f %.8f\n", p1.x, p1.y);
	Koch(n, p1, p2);
	printf("%.8f %.8f\n", p2.x, p2.y);

	return 0;
}


Measured memory_bytes: 2084
T = gets.to_i

T.times do
  distance = []
  n, k = gets.chomp.split(' ').map(&:to_i) 
  x = gets.chomp.split(' ').map(&:to_i)
  if n <= k
    puts 0
  elsif n == 2
      puts x[1] - x[0]
  elsif k == 1
    puts x[-1] - x[0]
  else
    for i in 0...x.size-1
      distance << x[i+1] - x[i]
    end
    distance.sort!
    sum = x[-1] - x[0]
    (k-1).times do  
      sum -= distance.pop
    end
    print sum,"\n" 
  end
end

Measured memory_bytes: 23116
N, T = map(int, input().split())

A = list(map(int, input().split()))

best_buy = 1e9
best_diff = 0
best_diff_cnt= 0

for i in range(N):
  if best_buy > A[i]:
    best_buy = A[i]
  
  if best_diff < A[i] - best_buy:
    best_diff = A[i] - best_buy
    best_diff_cnt = 1
  elif best_diff == A[i] - best_buy:
    best_diff_cnt += 1
    
  #print(i, best_buy, best_diff, best_diff_cnt)
    
print(best_diff_cnt)

Measured memory_bytes: 15020
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String o = sc.next();
		String e = sc.next();
		for(int i=0; i<e.length(); i++){
			System.out.print(o.charAt(i));
			System.out.print(e.charAt(i));
		}
		if(o.length()>e.length()){
			System.out.println(o.charAt(o.length()-1));
		}
	}
}

Measured memory_bytes: 22100
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<limits.h>
using namespace std;

const int RANGE = 201;

int primes[RANGE], primesCnt;
bool st[RANGE];

void getPrimes(int n)
{
	for (int i = 2; i <= n; i++)
	{
		if (!st[i]) primes[primesCnt++] = i;
		for (int j = 0; j < primesCnt && i * primes[j] <= n; j++)
		{
			st[primes[j] * i] = true;
			if (i % primes[j] == 0) break;
		}
	}
}

int main()
{
	getPrimes(200);
	int N;
	cin >> N;
	int res = 0;
	for (int x = 1; x <= N; x++)
	{
		if ((x & 1) == 0) continue;
		int divisorNum = 1;
		int tmp = x;
		for (int i = 0; i < primesCnt; i++)
		{
			int times = 0;
			if (primes[i] > tmp) break;
			while(tmp % primes[i] == 0)
			{
				times++;
				tmp /= primes[i];
			}
			if(times > 0) divisorNum *= (times + 1);
			if (divisorNum > 8) break;
		}
		if (divisorNum == 8)
		{
			res++;
		}
	}
	cout << res << endl;
	return 0;
}

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

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a-1); i >= (b); i--)

using namespace std;

u ll int gcdsum(u int K);

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

    u int K;
    cin >> K;

    cout << gcdsum(K) << "\n";
}

u ll int gcdsum(u int K)
{
    u ll int sum = 0;

    REP(i, 1, K + 1)
        REP(j, 1, K + 1)
            REP(k, 1, K + 1)
                sum += __gcd(__gcd(i, j), k);

    return sum;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main
{
	public static boolean Check(String s, String target)
	{
		for(int pos=0; pos<s.length(); pos++)
		{
			int dist=1;
			int checkSize=target.length();
			
			while(pos+checkSize-1 < s.length())
			{
				boolean isFound=true;
				for(int i=0; i<target.length(); i++)
				{
					if(s.charAt(pos+i*dist) != target.charAt(i))
					{
						isFound = false;
						break;
					}
				}
				if(isFound)return true;
				dist++;
				checkSize+=target.length()-1;
			}
		}
		return false;
	}
	
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		
		int N=sc.nextInt();
		int ans=0;
		
		sc.nextLine();
		String  target  =sc.nextLine();
		String[]s       =new String[N];
		for(int i=0; i<N; i++)
			s[i]=sc.nextLine();
		
		for(int i=0; i<N; i++)
			if(Check(s[i], target))ans++;
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21676
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 100010
#define D 18
ll n,q,p[N],len[N],rui[N],dep[N];
namespace lca{
  ll t[N][D];
  void init(){
      for(int i=1;i<=n;i++)t[i][0]=p[i];
      for(int d=1;d<D;d++){
	  for(int i=1;i<=n;i++){
	      t[i][d]=t[t[i][d-1]][d-1];
	  }
      }
  }
  ll ad(ll a,ll k){
      for(ll d=0;k!=0;d++){
	  if(k&1)a=t[a][d];
	  k>>=1;
      }
      return a;
  }
  ll qry(ll a,ll b){
      if(dep[a]<dep[b])swap(a,b);
      a=ad(a,dep[a]-dep[b]);
      if(a==b)return a;
      for(ll d=D-1;d>=0;d--){
	  if(t[a][d]!=t[b][d]){
	      a=t[a][d],b=t[b][d];
	  }
      }
      return p[a];
  }
  ll dist(ll a,ll b){
      ll c=qry(a,b);
      return rui[a]+rui[b]-2*rui[c];
  }
};


struct edge{
  ll to,cost;  
};
edge edges(ll to,ll cost){
    edge gen;gen.to=to,gen.cost=cost;
    return gen;
}
vector<edge> g[N];
void dfs(ll x,ll from,ll sum,ll d){
    rui[x]=sum; dep[x]=d;
    for(auto y:g[x])if(y.to!=from){
	p[y.to]=x,len[y.to]=y.cost;
	dfs(y.to,x,sum+y.cost,d+1);
    }
}

ll ldi(ll mid,ll a,ll b,ll c,ll lk,ll rk,ll m){//cout<<"ldi"<<mid<<endl;
    ll ldis;
    if(mid<=lk)ldis=lca::dist(a,lca::ad(a,mid));
    else ldis=lca::dist(a,c)+lca::dist(c,lca::ad(b,m-mid));
    return ldis;
}
ll rdi(ll mid,ll a,ll b,ll c,ll lk,ll rk,ll m){//cout<<"rdi"<<mid<<endl;
    ll rdis;
    if(mid>=lk)rdis=lca::dist(b,lca::ad(b,m-mid));
    else rdis=lca::dist(b,c)+lca::dist(c,lca::ad(a,mid));
    return rdis;
}
int main(){
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
	ll a,b,c;cin>>a>>b>>c;
	g[a].push_back(edges(b,c));
	g[b].push_back(edges(a,c));
    }
    dfs(1,0,0,0); p[1]=1;
    lca::init();
    while(q--){
	ll a,b,c;cin>>a>>b>>c;
	ll ab=lca::dist(a,b);
	ll ac=lca::dist(a,c);
	ll bc=lca::dist(b,c);
	if(ab>=ac&&ab>=bc){}
	else if(ac>=ab&&ac>=bc){swap(b,c);}
	else if(bc>=ab&&bc>=ac){swap(a,c);}
	c=lca::qry(a,b);//cout<<"$$$$$"<<a<<" "<<b<<" "<<c<<endl;
	ll lk=dep[a]-dep[c],rk=dep[b]-dep[c],m=lk+rk;
	ll l=0,r=m,mid;
	while(l<r-1){
	    mid=(l+r)/2;
	    ll ldis=ldi(mid,a,b,c,lk,rk,m);
	    ll rdis=rdi(mid,a,b,c,lk,rk,m);
	    if(ldis<rdis)l=mid;
	    else r=mid;
	}
	ll ldis,rdis;
	ldis=ldi(l,a,b,c,lk,rk,m);
	rdis=rdi(l,a,b,c,lk,rk,m);
	ll vl=max(ldis,rdis);
	ldis=ldi(r,a,b,c,lk,rk,m);
	rdis=rdi(r,a,b,c,lk,rk,m);
	ll vr=max(ldis,rdis);
	cout<<min(vl,vr)<<endl;
    }
    return 0;
}



Measured memory_bytes: 33588
s = input()
n = len(s)
for i in range(0,n//2):
    if s[i] != s[n-i-1]:
        print("No")
        break
else:
    for j in range(0,(n-1)//4):
        if s[i] != s[(n-1)//2-i-1]:
            print("No")
            break
    else:
        for k in range((n+3)//2-1,n//2):
            if s[(n+3)//2-1+i] != s[n-i-1]:
                print("No")
                break
        else:
            print("Yes")

Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
foreach ($a as $b) {
	$q = [$b, $b + 1, $b - 1];
	foreach ($q as $c) {
		if (isset($x[$c])) {
			$x[$c]++;
		} else {
			$x[$c] = 1;
		}
	}
}
echo max($x);

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double n;
    while (cin >> n)
    {
        if (n <= 48)
            OP("light fly");
        else if (48 < n && n <= 51)
            OP("fly");
        else if (51 < n && n <= 54)
            OP("bantam");
        else if (54 < n && n <= 57)
            OP("feather");
        else if (57 < n && n <= 60)
            OP("light");
        else if (60 < n && n <= 64)
            OP("light welter");
        else if (64 < n && n <= 69)
            OP("welter");
        else if (69 < n && n <= 75)
            OP("light middle");
        else if (75 < n && n <= 81)
            OP("middle");
        else if (81 < n && n <= 91)
            OP("light heavy");
        else if (91 < n)
            OP("heavy");
    }
    return 0;
}


Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

          
			var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long A = inputArray[0];
			long B = inputArray[1];
			long N = inputArray[2];

			//n = i*B + jとする
			var l = A % B;
			long maxW = 0;

			var BB = B * B;

			if(B > N) {
				maxW = N%B;
			}
			else {
				maxW = B - 1;
			}
			/*
			for (long n = 1; n <= N; n++) {
				var i = n / B;
				var j = n % B;
				var w = j % B;
				if(maxW < w) {
					maxW = w;
				}
			}*/

			//答えの出力
			var ans =  (A * maxW) / B - A * (maxW / B);
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28188
#ABC138C
N = int(input())
V = list(map(int, input().split()))
sortV = sorted(V)
ans = 0
if N == 2:
    ans = sum(V)/2
else:
    ans = ((sortV[0] +sortV[1])/2)
    for i in range(2, N):
        ans = (ans + sortV[i])/2
print(ans)

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

using namespace std;

void solveA()
{
    int x;
    cin >> x;
    if (x == 7|| x == 5|| x == 3)
        cout << "YES\n";
    else
        cout << "NO\n";
}

void solveB()
{
    int a, b, c;
    cin >> a >> b >> c;

    int hp = max(a, b);
    hp = max(hp, c);

    int area;

    if (a == hp)
        area = (b * c) / 2;
    if (b == hp)
        area = (a * c) / 2;
    if (c == hp)
        area = (a * b) / 2;

    cout << area;
}

void solveC()
{
    int a, b;
    cin >> a >> b;
    if ((a*b) % 2 == 0)
        cout << "No\n";
    else
        cout << "Yes\n";
}

void solveD()
{
    int n, s=0, cp;

    cin >> n;
    cp = n;

    while (cp){
        s += cp%10;
        cp /= 10;
    }
    if (n % s == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

void solveE()
{
    int n, t;

    cin >> n >> t;

    int rotas[n][2];

    int coast = INT_MAX;

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

        cin >> rotas[i][0] >> rotas[i][1];

        if (rotas[i][1] <= t){
            coast = min(coast, rotas[i][0]);
        }
    }
    if (coast == INT_MAX)
        cout << "TLE\n";
    else
        cout << coast << "\n";
}

void solveF()
{
    int k;
    cin >> k;
    int par = 0, impar = 0;
    for (int i = 1; i <= k ; i++){
        if (i % 2 == 0)
            par++;
        else
            impar++;
    }
    cout << par * impar << endl;
}

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);

    solveE();

    return 0;
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

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

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int n;
	cin >> n;
	bool a = false;

	FOR(i,1,10) {
		if(n%i == 0 && n/i <=9) {
			a = true;
			break;
		}
	}
	if(a) {
		cout << "Yes" <<endl;
	} else {
		cout << "No" << endl;
	}
}



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


int main (){
    long long N, M;
    cin>>N>>M;
    vector<long long> R(N+1);
    vector<int> Bre(N+1, 1);//1:通れる
    Bre.at(0)=1;
    for(int i=1; i<=M; i++){
        int a;
        cin>>a;
        Bre.at(a)=0;
    }
    R.at(0)=1;
    R.at(1)=Bre.at(1);
    for(int i=2; i<=N; i++){
        if(Bre.at(i)==0){
            R.at(i)=0;
        }
        else{
            R.at(i)=R.at(i-1)+R.at(i-2);
          	R.at(i)%=1000000007;
        }
    }
    cout<<R.at(N)<<endl;

}

Measured memory_bytes: 1408
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]
l0 = []
for i in range(8):
    lst = []
    for j in range(3):
        lst.append(i >> j & 1)
    l0.append(lst)

def f(x,i):
    return x*((-1)**i)
ans = 0
for i in range(8):
    lst = []
    for j in range(n):
        lst.append(
            f(l[j][0],l0[i][0])
            +f(l[j][1],l0[i][1])
            +f(l[j][2],l0[i][2])
        )
    lst.sort(reverse=True)
    ans = max(ans, sum(lst[:m]))
print(ans)

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}


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

int main(void) {
	int k;
	char s[100];
	scanf("%d", &k);
	scanf("%s", s);
	int len;
	len = strlen(s);
	if (len <= k)
		printf("%s", s);
	else if (len > k) {
		
		s[k] = '\0';
		printf("%s...", s);
	}
	return 0;
}

Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int K = int.Parse(strs[1]);

            line = Console.ReadLine();
            strs = line.Split(' ');

            int[] p = new int[N];
            for(int i = 0; i < N; i++)
            {
                p[i] = int.Parse(strs[i]);
            }

            var 期待値list = Get期待値(1000);
            //隣接するK個を取って、最大値を求める

            double[] dp = new double[N];
            for(int i = 0; i < K; i++)
            {
                dp[0] += 期待値list[p[i]];
            }

            for (int i = 1; i < N - K + 1; i++)
            {
                dp[i] += dp[i-1] + 期待値list[p[i+K-1]] - 期待値list[p[i-1]];
            }

            double MAX = 0;
            for(int i = 0; i < N - K + 1; i++)
            {
                if (MAX < dp[i]) MAX = dp[i];
            }

            Console.WriteLine(MAX);
        }

        static double[] Get期待値(int N)
        {
            var ret = new double[N+1];
            for(int i = 1; i < N+1; i++)
            {
                ret[i] = ret[i - 1] + i;
            }
            for (int i = 1; i < N + 1; i++)
            {
                ret[i] /= (double)i;
            }
            return ret;
        }
    }
}


Measured memory_bytes: 30940
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> arr(2*n);
    for(int i=0;i<2*n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    ll ans=0;
    for(int i=0;i<2*n;i+=2){
        ans+=arr[i];
        //cout<<arr[i]<<" ";
    }
    cout<<ans;
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   ll n,a,b,c,d; scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
   bool f=0;
   rep(_,0,n+1){
      ll lb=c*_-d*(n-1-_),rb=d*_-c*(n-1-_);
      if(lb<=b-a&&b-a<=rb){f=1; break;}
   }
   printf(f?"YES\n":"NO\n");
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    size_t N;
    int S;
    scanf("%zu %d", &N, &S);

    vector<int> a(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &a[i]);

    if (accumulate(a.begin(), a.end(), 0LL) < S)
        return !printf("0\n");

    int sum=0;
    vector<int>::iterator first=a.begin(), last=first;
    ptrdiff_t slen=N+1;
    while (first < a.end()) {
        while (sum<S && last<a.end()) {
            sum += *last;
            ++last;
        }
        if (sum >= S)
            if (slen > last-first)
                slen = last-first;

        sum -= *first;
        ++first;
    }

    printf("%td\n", slen);
    return 0;
}

Measured memory_bytes: 2772
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(x,b) (0<=(x)&&(x)<(b))
using namespace std;

int H, W;
int board[128][128];
char point;

void dfs(int y, int x){
  board[y][x] = '.';
  int dy[] = {0,-1,0,1}, dx[] = {-1,0,1,0};
  rep(i, 4){
    int ny = y + dy[i], nx = x + dx[i];
    if(BW(ny,H) && BW(nx, W) && board[ny][nx] == point)
      dfs(ny, nx);
  }
  return;
}

int main(){
  char in[128];
  while(scanf("%d%d", &H, &W) && H+W){
    rep(i, H){
      scanf("%s", in);
      rep(j, W) 
	board[i][j] = in[j];
    }
    
    int res = 0;
    rep(i, H) rep(j, W){
      if(board[i][j] != '.'){
	point = board[i][j];
	dfs(i, j);
	res++;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1872