akhauriyash/Code-Regression huggingface dataset:
// template version 1.9

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  string s;cin>>s;
  cout << s.substr(0,4) << " " << s.substr(4, 8) << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
long long int adj[1000][1000];
long long int h[100000+10];
map<long long int,long long int>mp;
long long int val;
long long int answe1,res;
vector<lli>vect[400];
//set<lli>s;
/*void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.insert(n);
}
*/
int main()
{

    fast;


    lli n;
    cin>>n;
    lli INF=1e9+5;
    vector<lli>h(n);
    vector<lli>dp(n,INF);
    for(lli i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    for(lli i=0;i<n;i++)
    {
        for(lli j:{i+1,i+2})
            {
                if(j<n)
                {
                    dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
                }
            }
    }
    cout<<dp[n-1];
    return 0;

}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // divide into positive and negative
  vector<int> ps, ns;
  for (int i = 0; i < N; i++) {
    const int a = as[i];
    if (a >= 0) {
      ps.push_back(a);
    } else {
      ns.push_back(a);
    }
  }

  // solve
  int ans;
  vector<int> xs, ys;
  if (ns.size() == 0) {
    sort(ps.begin(), ps.end());
    const int n = ps[0] - ps[ps.size() - 1];
    ns.push_back(n);
    xs.push_back(ps[0]);
    ys.push_back(ps[ps.size() - 1]);
    vector<int> pds;
    for (int i = 1; i < ps.size() - 1; i++) {
      pds.push_back(ps[i]);
    }
    ps = pds;
  } else if (ps.size() == 0) {
    sort(ns.begin(), ns.end());
    const int p = ns[ns.size() - 1] - ns[0];
    xs.push_back(ns[ns.size() - 1]);
    ys.push_back(ns[0]);
    ps.push_back(p);
    vector<int> nds;
    for (int i = 1; i < ns.size() - 1; i++) {
      nds.push_back(ns[i]);
    }
    ns = nds;
  }
  if (ps.size() > 0 && ns.size() > 0) {
    for (int i = 1; i < ps.size(); i++) {
      const int x = ns[0], y = ps[i];
      xs.push_back(x);
      ys.push_back(y);
      ns[0] -= y;
    }
    for (int i = 0; i < ns.size(); i++) {
      const int x = ps[0], y = ns[i];
      xs.push_back(x);
      ys.push_back(y);
      ps[0] -= y;
    }
    ans = ps[0];
  } else if (ps.size() > 0) {
    ans = ps[0];
  } else if (ns.size() > 0) {
    ans = -ns[0];
    int tmp = xs[0];
    xs[0] = ys[0];
    ys[0] = tmp;
  } else {
    exit(-1);
  }

  // print ans
  printf("%d\n", ans);
  for (int i = 0; i < N - 1; i++) {
    printf("%d %d\n", xs[i], ys[i]);
  }

  return 0;
}


Measured memory_bytes: 3960
N = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(len(L)):
    for j in range(i+1, len(L)):
        for k in range(j+1, len(L)):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                maxL = max(L[i], L[j], L[k])
                if maxL < L[i] + L[j] + L[k] - maxL:
                    ans += 1
print(ans)

Measured memory_bytes: 9228
#include <iostream>

using namespace std;

int main()
{
   long long int n,m,X,K,D;
   cin >> X >> K >> D;
   X = abs(X);
   D = abs(D);
   n = X/D;
   m = X%D;
   if(n>=K) cout << X-K*D;
   else{
       K = K-n;
       if(K%2==0) cout << m;
       else cout << abs(m-D);
   }
   
   return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main (){
    int S;
    int h = 0;
    int m = 0;
    int s = 0;
    cin >> S ;
    while ((S / 3600)>= 1){
        h += 1;
        S -= 3600;
    }
    while ((S / 60)>= 1){
        m += 1;
        S -= 60;
    }

    s += S;
    
    cout << h << ":"<< m<<":"<<s<<"\n";
    
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)

int main(){
	int N;
	string S;
	cin>>N>>S;
	map<char,int> mp;
	for(int i=0;i<N;i++){
		mp[S[i]]++;
	}
	int ans = 1;
	for(auto a:mp){
		ans=mod(ans*(a.second+1));
	}
	
	cout<<ans-1<<endl;
	
	return 0;
}


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

int main() {
  int N; cin >> N;
  int P[N]; for (int i = 0; i < N; i++) cin >> P[i];
  int Q[N]; for (int i = 0; i < N; i++) Q[i] = P[i];
  sort(Q, Q+N);
  int c = 0;
  for (int i = 0; i < N; i++)
    if (P[i] != Q[i]) c++;
  if (c <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  	int x1,x2,i,k;
	int N,X;
 	cin>>N>>X;
  	int x=X/1000;
  
  	i=N;
  	while(i>=0){
   		for(k=0;k<=N-i;k++){
     		x1=5*k+1*(N-i-k)+10*i;
       	if(x1==x){
          cout<<i<< " "<<k<<" "<<N-i-k<<endl;
    	  return 0;
        }
        }
      i--;
    }
	cout <<-1<<" "<<-1<<" "<<-1<<endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3
char s[100010];

int main(){
    scanf("%s", s);
    int mini = INF, n = strlen(s);
    rep(i, n) {
        if (s[i - 1] != s[i]) minch(mini, max(i, n - i));
    }
    if (mini == INF) mini = 0;
    printf("%d\n", mini);
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n,q=map(int,input().split())
AB=[[int(x) for x in input().split()] for _ in range(n-1)]
PX=[[int(x) for x in input().split()] for _ in range(q)]

graph=[[] for _ in range(n+1)]
values=[0]*(n+1)

for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for p,x in PX:
    values[p]+=x

#print(graph)

def dfs(x,parent,add):
    values[x]+=add
    for i in graph[x]:
        if i==parent:
            continue
        dfs(i,x,values[x])

dfs(1,0,0)

print(' '.join(map(str,values[1:])))


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

typedef tuple<int,int,int> triple;
set<triple> intervals;

void write(){
    int id,len;
    cin >> id >> len;
    auto a=intervals.begin();
    auto b=intervals.begin();
    ++b;
    while(len>0){
        int l=get<1>(*a);
        if(b==intervals.end()){
            intervals.insert(triple(l,l+len,id));
            break;
        }
        int r=get<0>(*b);
        if(l==r){
            a=b;
            ++b;
            continue;
        }
        if(r-l>len) r=l+len;
        b=intervals.insert(triple(l,r,id)).first;
        a=b;
        ++b;
        len-=r-l;
    }
}

void del(){
    int id;
    cin >> id;
    for(auto it=intervals.begin();it!=intervals.end();){
        if(get<2>(*it)==id) it=intervals.erase(it);
        else ++it;
    }
}

void read(){
    int addr;
    cin >> addr;
    bool ok=false;
    for(const auto& interval:intervals) if(get<0>(interval)<=addr and addr<get<1>(interval)){
        cout << get<2>(interval) << endl;
        ok=true;
        break;
    }
    if(!ok) cout << -1 << endl;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;

        intervals.clear();
        intervals.insert(triple(0,0,-inf));
        rep(i,0,n){
            char command;
            cin >> command;
            if(command=='W') write();
            else if(command=='D') del();
            else read();
        }
        cout << endl;
    }
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    int num = 0;
    rep(i, n) {
        if (a[i] * (4 * m) >= sum) num++;
    }
    if (num >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, m, ans;
priority_queue<ll, vector<ll>, greater<ll>> q;
vector<pair<ll, ll>>pa;
int main() {
	cin >> n >> m;
	REP(i, n) {
		ll a;
		cin >> a;
		ans += a;
		q.push(a);
	}
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		pa.push_back(P(b, a));
	}
	sort(ALL(pa), greater<P>());
	REP(i, m) {
		REP(j, pa[i].second) {
			if (q.top() >= pa[i].first)break;
			ans += pa[i].first - q.top();
			q.pop();
			q.push(pa[i].first);
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

ll GCD( ll x, ll y ){
	if( x < y ) swap(x, y);
	if( y == 0 ) return x;
	return GCD( x%y, y );
}

ll LCM( ll x, ll y ){
	ll num = GCD( x, y );
	ll s, t;
	t = GCD( num, y );
	s = num/t;
	return (x/s)*(y/t);
}

int N;
ll T[112];
ll A;

int main(){
	
	cin>>N;
	
	REP( i, N ) cin>>T[i];
	
	A = T[0];
	
	FOR( i, 1, N ){
		A = LCM( A, T[i] );
	}
	
	cout<<A<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
defmodule Main do
  def main() do
    IO.gets("") |> String.trim() |> String.to_integer()
    list =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
    div_count(list, 0)
    |> IO.puts()
  end

  def div_count(list, acc) do
    case Enum.all?(list, &rem(&1, 2) == 0) do
      true ->
        Enum.map(list, &div(&1, 2))
        |> div_count(acc+1)
      false ->
        acc
    end
  end
end


Measured memory_bytes: 30560
#include <stdio.h>
 
int main(void){
  int i,sum;
  char num[1001];
 
  for(;;){
    scanf("%s", &num);
    if(num[0] == '0') break;
     
    sum = 0;
    for(i=0;num[i]!='\0';i++)
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
   
  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
const int M=1e9+7,M2=1e9+9;
const int Base=100,B2=457;
const int N=310;
char s[N+N][N+N];
int n;
pair<int,int> r[N][N],c[N][N];//i row rotate j
pair<int,int> calcr(int x,int y){
  pair<int,int> ret;
  int p=1,p2=1;
  for (int i=1; i<=n; ++i){
    // if (i!=x){
    (ret.first+=(long long)p*(s[x][y+i]-'a'+1)%M)%=M;
    (ret.second+=(long long)p2*(s[x][y+i]-'a'+1)%M2)%=M2;
    // }
    p=(long long)p*Base%M;
    p2=(long long)p2*B2%M2;
  }
  return ret;
}
pair<int,int> calcc(int x,int y){
  pair<int,int> ret;
  int p=1,p2=1;
  for (int i=1; i<=n; ++i){
    // if (i!=x){
    (ret.first+=(long long)p*(s[x+i][y]-'a'+1)%M)%=M;
    (ret.second+=(long long)p2*(s[x+i][y]-'a'+1)%M2)%=M2;
    // }
    p=(long long)p*Base%M;
    p2=(long long)p2*B2%M2;
  }
  return ret;
}
int main(){
  scanf("%d",&n);
  for (int i=1; i<=n; ++i){
    scanf("%s",s[i]+1);
    for (int j=n+1; j<n+n; ++j) s[i][j]=s[i][j-n];
    for (int j=0; j<n; ++j){
      r[i][j]=calcr(i,j);
      // cerr<<i<<" "<<j<<" "<<r[i][j]<<endl;
    }
  }
  for (int i=n+1; i<n+n; ++i){
    for (int j=1; j<=n; ++j)
      s[i][j]=s[i-n][j];
  }
  // for (int i=1; i<n+n; ++i) cout<<s[i]+1<<endl;
  for (int i=0; i<n; ++i)
    for (int j=1; j<=n; ++j){
      c[i][j]=calcc(i,j);
      // cerr<<"c:"<<i<<" "<<j<<" "<<c[i][j]<<endl;
    }
  int ans=0;
  for (int A=0; A<n; ++A)
    for (int B=0; B<n; ++B){
      bool flag=1;
      for (int i=1; i<=n; ++i){
	if (r[(i-A+n-1)%n+1][(n-B)%n]!=c[(n-A)%n][(i-B+n-1)%n+1]) flag=0;
	// cerr<<i<<" "<<r[(i-A+n-1)%n+1][B].first<<" "<<c[A][(i-B+n-1)%n+1].first<<endl;
      }
      // if (flag) cerr<<A<<" "<<B<<endl;
      // system("pause");
      ans+=flag;
    }
  cout<<ans;
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD{1000000007};
    // my fast in
    constexpr unsigned long buf_size = 5UL;
    char buffer[buf_size];
    fread(buffer, 1, buf_size, stdin);
    unsigned long tmp_buf = 0;
    const auto &read = [&tmp_buf, &buffer] {
        unsigned long ret;
        from_chars(begin(buffer) + tmp_buf, end(buffer), ret);
        return ret;
    };
    // fast in kokomade
    unsigned long S{read()};
    unsigned long a{1}, b{0}, c{0};
    for(unsigned long i{0}; i < S; ++i){
        swap(a, b);
        swap(b, c);
        (c += b) %= MOD;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3624
n, m, x = map(int,input().split())
a = list(map(int,input().split()))
cost_l = 0
cost_r = 0
for i in range(m):
    if a[i] < x:
        cost_l += 1
    else:
        cost_r += 1
print(min(cost_l, cost_r))

Measured memory_bytes: 3060
<?php

///// Input
$sc = new Scanner();
$a = $sc->next();

//$a = '011';

/////
$ans = substr($a, 0, 1) + substr($a, 1, 1) + substr($a, 2, 1);

out::println($ans);





//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


Measured memory_bytes: 3700
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var s = sc.next()
  var list:Array[Char] = Array.fill(s.length)(' ')
  var ans_list:Array[Int] = Array.fill(s.length - 2)(0)
  for (i <- 0 until s.length){
    list(i) = s(i)
  }
  for (i <- 0 until s.length - 2){
    ans_list(i) = (753 - (list(i).asDigit * 100 + list(i + 1).asDigit * 10 + list(i + 2).asDigit)).abs
  }
  println(ans_list.min)
}


Measured memory_bytes: 55636
#include <iostream>
#include<set>
#include<vector>
using namespace std;
int mod=1000000007;
int inv=(mod+1)/2;
int add(int x, int y)
{
	int c=x+y;
	if(c>=mod)c-=mod;
	return c;
}
int sub(int x, int y)
{
	int c=x-y;
	if(c<0)c+=mod;
	return c;
}
int mlt(int x, int y)
{
	long long c=x*1LL*y;
	if(c>=mod)c%=mod;
	return c;
}
vector<int>rec(vector<int>&dp, int m)
{
	vector<int>res(m+1), dpml(m+1), pref(m+1), pows(m+1), dvas(m+1);
	pows[0]=1;
	dvas[0]=1;
	for(int i=1; i<=m; i++)
	{
		pows[i] = mlt(pows[i - 1], inv);
		dvas[i] = mlt(dvas[i - 1], 2);
	}
	res[1]=add(dp[1],dp[1]);
	for(int i=1; i<=m-1; i++)
	{
		dpml[i]=mlt(dp[i], mlt(pows[i+1], i));
	}
	pref[0]=0;
	for(int i=1; i<m; i++)
		pref[i]=add(pref[i-1], dpml[i]);
	for(int i=2; i<=m; i++)
	{
		res[i]=mlt(dp[i], i+1);
	//	cout<<i<<' '<<res[i]<<endl;
		int val=pref[i-1];
		val=mlt(val, dvas[i]);
		res[i]=add(res[i], val);
	}
	return res;
}
int main()
{
	int n, m;
	cin>>n>>m;
	vector<int>dp(m+1);
	for(int i=1; i<=m; i++)
		dp[i]=1;
	for(int i=1; i<=n; i++)
	{
		dp =rec(dp, m);
		//for(int i=1; i<=m; i++)cout<<dp[i]<<' ';
	//cout << endl;
	}
	cout<<dp[m]<<endl;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    string s; cin >> s;
    ll K; cin >> K;

    if(s[0] != '1') {
        cout << s[0] << endl;
        return 0;
    }

    int cnt_1 = 0;
    rep(i,s.size()) {
        if(s[i] == '1') cnt_1++;
        else break;
    }

    if(K <= cnt_1) cout << 1 << endl;
    if(cnt_1 < K) cout << s[cnt_1] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m,a[100][100],b[100],c[100]={0},i,j;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			c[i]+=a[i][j]*b[j];
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H;
  char mas[10][5];
  while( cin >> H, H){
    for(int i = 0; i < H; i++){
      for(int j = 0; j < 5; j++){
        cin >> mas[i][j];
      }
    }

    int ret = 0;
    bool changed = true;

    for(int foo = 0; foo < 100; foo++){
      
      for(int q = 0; q < 30; q++){
        for(int i = H - 1; i > 0; i--){
          for(int j = 0; j < 5; j++){
            if(mas[i][j] == '*'){
              swap(mas[i][j],mas[i - 1][j]); //上から持ってくる
            }
          }
        }
      }

      for(int i = 0; i < H; i++){
        char prev = mas[i][0];
        int cnt = 0;
        for(int j = 0; j < 5; j++){
          if(mas[i][j] == '*'){
            cnt = 0;
            continue;
          }
          if(mas[i][j] != prev){
            prev = mas[i][j];
            cnt = 0;
          }
          cnt++;
          if(cnt == 3){
            ret += (mas[i][j] - '0') * 3;
            for(int k = j, l = 0; l < cnt; l++, k--){
              mas[i][k] = '*';
            }
          } else if(cnt > 3){
            ret += (mas[i][j] - '0');
            mas[i][j] = '*';
          }
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b){
        string s;
        cin>>s;
        int l=s.length();
        int flag=1;
        for(int i=0;i<l;i++){
            if(i==a&&s[i]!='-'){
                flag=0;
                break;
            }
            if(i!=a&&!(s[i]<='9'&&s[i]>='0')){
                flag=0;
                break;
            }
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = a + b;
		while(true) {
			if(23 < ans) {
				ans -= 24;
			}
			else {
				break;
			}
		}
		System.out.println(ans);
	}
}

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

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """RUDLUDR"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """DULL"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """UUUUUUUUUUUUUUU"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """ULURU"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_5(self):
        input = """RDULULDURURLRDULRLR"""
        output = """Yes"""
        self.assertIO(input, output)
def resolve():
    LR=['RUD','LUD']
    s=input()
    for i in range(len(s)):
        if not(s[i] in LR[i%2]):
            print('No')
            break
    else:
        print("Yes")
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 50796
#include<stdio.h>

int main(void){

int a,b,c,d;

d=0;

scanf("%d %d %d",&a,&b,&c);

for(a;a<=b;a++){

if(c%a==0){

d=d+1;


}

}


printf("%d\n",d);

return 0;

}

Measured memory_bytes: 596
def main():
    n, k = list(map(int, input().split()))
    d = input().split()
    pay = n
    while True:
        ok = True
        for d_i in d:
            if d_i in str(pay):
                ok = False
                break
        if ok:
            break
        else:
            pay += 1
    print(pay)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n; cin >> n;
	if(n == 1) cout << 0 << "\n";
	else cout << 1 << "\n";

    


	#ifdef LOCAL
	cerr << "\n";
	#endif
	return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = [int(i) for i in input().split()]

L = len(set(A))

if L % 2 == 1: # 奇数 -> 重複しているカード食えばok
    print(L)
else: # 偶数 -> 重複してないカードを1枚だけ食う必要あり
    print(L - 1)

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();

            var list = new List<int>();
            var len = N.ToString().Length;
            list.AddRange(Rec(len, 3));
            list.AddRange(Rec(len, 5));
            list.AddRange(Rec(len, 7));

            var ans = list.Count(l => l <= N && l.ToString().Contains("3") && l.ToString().Contains("5") && l.ToString().Contains("7"));



            Console.WriteLine(ans);
        }

        
        static List<int> Rec(int len,int n)
        {
            var list = new List<int>();
            if (n.ToString().Length != len)
            {
                list.AddRange(Rec(len, n * 10 + 3));
                list.AddRange(Rec(len, n * 10 + 5));
                list.AddRange(Rec(len, n * 10+ 7));
            }
            list.Add(n);
            return list;
        }

        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 16220
import math
from functools import reduce

N=int(input())
T=list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 :
            if i!=1:
                divisors.append(i)
            if i != n // i:

                divisors.append(n//i)

    divisors.sort()
    return divisors

    


def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
S=[]
tmp=gcd_list(T)
if tmp!=1:
    print("not coprime")
else:
    T.sort()

    n=10**6+1
    isprime=[True]*(n+1)
    isprime[0]=False
    isprime[1]=False
    for i in range(len(T)):
        S=make_divisors(T[i])
        #print(S)
        while len(S)!=0: 
            tmp=S.pop()
            if isprime[tmp]==True:
                j=tmp+tmp
                while j<=n:
                     
                    isprime[j] =False
                    j=j+tmp
                    
                        
            else:
                print("setwise coprime")
                exit()
    print("pairwise coprime")
    

Measured memory_bytes: 187316
#include <iostream>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n, x;
    ll sum=0, cow[200005];
    cin >> n;
    map <ll , int> zesura;
    zesura[0]=1;
    cow[0]=0;
    for(int i=1; i<=n; i++){
        cin >> x;
        cow[i]=x+cow[i-1];
        zesura[cow[i]]++;
        if(zesura[cow[i]]>1){
            sum+=zesura[cow[i]]-1;
        }    
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string str;
  cin>>str;
  ll K;
  cin>>K;
  ll memo=str.size();
  ll x=1,checker=0;
  if(str.at(0)==str.at(memo-1)){checker=54;}
  if(memo==1){
    cout<<K/2<<endl;return 0;
  }
  while(true){
    if(str.at(x)!=str.at(x-1))break;
    if(x==str.size()-1){cout<<(ll)str.size()*K/2<<endl;return 0;}
    x++;
  }
  ll rock=1;
  for(ll i=(ll)str.size()-1;i>=0;i--){
    if(str.at(i)==str.at(i-1)){rock++;}
    else{break;}
  }
  ll ans3=rock/2;
  rock=1;
  for(ll i=0;i<=(ll)str.size()-1;i++){
    if(str.at(i)==str.at(i+1)){rock++;}
    else{break;}
  }
  ll ans4=rock/2;
  ll ans1=0,ans2=0;
  str=str+str.at(0);
  ll k=0;
  //cout<<str<<endl;
  while(str.at(k+1)==str.at(k)){
    //cout<<k<<" "<<str.at(k+1)<<" "<<str.at(k)<<endl;
    str=str+str.at(1+k);
    //cout<<str<<endl;
    k++;
    if(1+k>=memo)break;
  }
  //cout<<str<<endl;
  for(ll i=1;i<(ll)str.size();i++){
    ll j=0;
    ll count;
    count=1;
    while(str.at(i+j)==str.at(i-1+j)){
      //cout<<i+j<<" "<<i-1+j<<endl;
      count++;j++;
      if(i+j>=str.size()){break;}
    }
    //cout<<i<<" "<<i+j-1<<" "<<count<<endl;
    if(i+j>=memo){ans2+=(count/2);break;}
    else{ans1+=(count/2);}
    i+=max(0,(int)j-1);
  }
  //ans1は右側を除いた連続部分　ans2は右側の連続成分
  //ans3は連結する前の右側の連続成分　ans4は左側の連続成分
  //cout<<ans1<<" "<<ans2<<" "<<ans3<<" "<<ans4<<endl;
  if(checker==54){cout<<(ans1-ans4)*K+ans2*(K-1)+ans3+ans4<<endl;}
  else{cout<<K*(ans1+ans3)<<endl;}
  //cout<<checker<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 300010
#define F(a) for(register int (i)(1);(i)^((a)+(1));(i)++)
using namespace std;
int n,m,a[szxb];
signed main(){scanf("%d%d",&n,&m);if(n&1){F(m){a[i]=(n+1)>>1;}int cnt(m>>1),now(m);while(cnt--){((!(a[now]-1))?(a[now--]=n):(--a[now],now=m));}F(now){printf("%d ",a[i]);}}else{printf("%d ",n>>1);F(m-1){printf("%d ",n);}}return putchar(10),0;}

Measured memory_bytes: 3456
N, A, B = map(int, input().split())
str = input()

K = 0
L = 0

for i in range(N):
  if(str[i] == "a"):
    if(K < A + B):
      print("Yes")
      K+=1
    else:
      print("No")
  elif(str[i] == "b"):
    if(K < A + B and L < B):
      print("Yes")
      K+=1
      L+=1
    else:
      print("No")
  else:
  	print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <set>

using namespace std;

int main(){
     int N;
     while(cin>>N,N){
	  multiset<int> ten;
	  for(int i=0;i<N;i++){
	       int temp;
	       cin>>temp;
	       ten.insert(temp);
	  }
	  multiset<int>::iterator itr=ten.begin();
	  ten.erase(itr);
	  multiset<int>::reverse_iterator ritr=ten.rbegin();
	  ritr++;
	  ten.erase(ritr.base());
	  itr=ten.begin();
	  int sum=0;
	  while(itr!=ten.end()){
	       sum+=*itr;
	       itr++;
	  }
	  cout<<(int)sum/ten.size()<<endl;
     }
}

Measured memory_bytes: 0
#include <cmath>
#include <iostream>

int main() {
  int x, a, b;
  std::cin >> x >> a >> b;
  if (std::abs(x - a) < std::abs(x - b)) {
    std::cout << 'A' << std::endl;
  } else {
    std::cout << 'B' << std::endl;
  }
}


Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
c=[[] for i in range(m+1)]
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        c[a].append(-b)
d=[]
heapq.heapify(d)
ans=0
for i in range(1,m+1):
    for j in c[i]:
        heapq.heappush(d,j)
    if d!=[]:
        ans+=heapq.heappop(d) 
print(-ans)    

Measured memory_bytes: 17732
#include <bits/stdc++.h>
     
    using namespace std;
    
    using ll = long long;
    const int inf = 1e9; 

    int main(){
        string s,pre;
        cin>>s;
        char c;
        int n, q, f;
        bool side = true;
        scanf("%d", &n);
        for (int i = 0; i < n; ++i){
        	scanf("%d", &q);
        	if(q==2){
        		scanf("%d", &f);
        		cin>>c;
        		if(((f-1)^side)){
        			pre.push_back(c);
        		}else{
        			s.push_back(c);
        		}
        	}else{
        		side = (side)?false:true;
        	}
        }

        if(!side){
        	for (int i = s.length()-1; i >=0 ; --i){
        		printf("%c", s[i]);
        	}

        	cout<<pre;
        }else{
        	for (int i = pre.length()-1; i >=0 ; --i){
        		printf("%c", pre[i]);
        	}
        	cout<<s;
        }



        return 0;
    }

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<bits/stdc++.h>
#include<set>
#define ll long long
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> h(n+1);
    for(ll i=1;i<=n;i++)
     cin>>h[i];
   //vector<ll> c[n+1];
    vector<set<int> >c(n+1);
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        c[a].insert(b);
        c[b].insert(a);
    }
    ll count=0;
    for(ll i=1;i<=n;i++)
    {
        ll b=0;
        for(auto x:c[i])
        {
          
            if(h[i]<=h[x])
            {
                b=1;
                break;
            }
        }
        if(b==0)
        count++;
    }
 
    cout<<count<<endl;
     return 0;
}

Measured memory_bytes: 18056
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
void solve()
{
  string s1,s2;
  cin>>s1>>s2;
  ll Result=0;
  for(int i=0;i<s1.size();i++)
  {
    if(s1[i]!=s2[i])Result++;
  }
  cout<<Result<<endl;
}
int  main()
{
    IOS
    solve();
    return 0;
}


Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

string s;
ll dp[10010][100][2];

int main(void){
	int n,i,d,j,k;
	fill(dp[0][0],dp[10010][0],0ll);
	dp[0][0][0] = 1ll;
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		s[i] -= '0';
	}
	cin >> d;
	for(i=0; i<n; ++i){
		for(j=0; j<d; ++j){
			for(k=0; k<10; ++k){
				add_mod(dp[i+1][(j+k)%d][1],dp[i][j][1]);
			}
			for(k=0; k<s[i]; ++k){
				add_mod(dp[i+1][(j+k)%d][1],dp[i][j][0]);
			}
			add_mod(dp[i+1][(j+s[i])%d][0],dp[i][j][0]);
		}
	}
	cout << ((dp[n][0][0]+dp[n][0][1]+MOD-1)%MOD) << endl;
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()

vector<tuple<int, int, int> > fs;

void writefs(int I, int S){
    for(int i=1; i<(int)fs.size(); ++i){
        if(1 < get<0>(fs[i]) - get<1>(fs[i-1])){
            int fw = get<1>(fs[i-1]) + 1, sp = get<0>(fs[i]) - get<1>(fs[i-1]) - 1;
            fs.insert(fs.begin() + i, make_tuple(fw, fw + min(sp, S) - 1, I));
            S -= sp;
            if(S <= 0)return;
        }
    }
    int fw = get<1>(fs.back()) + 1;
    fs.push_back(make_tuple(fw, fw + S - 1, I));
}

void deletefs(int I){
    fs.erase(remove_if(all(fs), [&](tuple<int, int, int> &t){return get<2>(t) == I;}), fs.end());
}

void readfs(int P){
    for(int i=1; i<(int)fs.size(); ++i){
        if(get<0>(fs[i]) <= P && P <= get<1>(fs[i])){
            cout << get<2>(fs[i]) << '\n';
            return;
        }
    }
    cout << "-1\n";
}

int main(){
    for(int N; cin >> N, N; cout << '\n'){
        cin.ignore();
        fs.clear();
        fs.push_back(make_tuple(-1, -1, -1));
        while(N--){
            char c;
            cin >> c;
            if(c == 'W'){
                int I, S;
                cin >> I >> S;
                writefs(I, S);
            }
            if(c == 'D'){
                int I;
                cin >> I;
                deletefs(I);
            }
            if(c == 'R'){
                int P;
                cin >> P;
                readfs(P);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>
#include<string.h>
int main(void)
{
 char s[27];
 int i,j,n;
 
 scanf("%s",s);
 n=strlen(s);
 
 for(i=0;i<n;i++){
  for(j=i+1;j<n;j++)
   if(s[i]==s[j]){printf("no\n"); return 0;}
 }
 printf("yes\n");
  return 0;
}

Measured memory_bytes: 128
//HowManyWays? ???????????°????????????????????§???
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int n,x,i,j,k,num;	//num????????????????????????????????????????????°???????´????????????°
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt();
		x = in.nextInt();
		
		while(n != 0){
			num =0;
			
			//????????§????????????????????????????????????
			for(i=1; i<=n; i++){
				for(j=1; j<=n; j++){
					if(j==i){continue;}
					for(k=1; k<=n; k++){
						if(k==i || k==j){continue;}
						if(i+j+k == x){
							num++;
						}
					}
				}
			}
			
			System.out.println(num/6);	//3! = 6??????????????????????????§6??§??????
			n = in.nextInt();
			x = in.nextInt();
		}
		
		in.close();
	}
}

Measured memory_bytes: 19672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,cnt=0,cnt1=0,cnt3=0,l=0;
    cin>>n>>m;
    int a[n+5],b[m+5],x[n+m+5];
    for(int i=2; i<=n*2; i=i+2)
    {
        a[cnt++]=i;
    }
    for(int i=1; i<m*2; i=i+2)
    {
        b[cnt1++]=i;
    }
    for(int i=0;i<cnt;i++)
    {
       x[cnt3++]=a[i];
    }
    for(int i=0;i<cnt1;i++)
    {
        x[cnt3++]=b[i];
    }
    for(int i=0;i<cnt3;i++)
    {
        for(int j=i+1; j<cnt3; j++)
        {
            if((x[i]+x[j])%2==0)
            {
                l++;
            }
        }
    }

     cout<<l;
}


Measured memory_bytes: 256
var
	M,L,R,ans,ll,rr:int64;
    k,i,x,y,xl,yl,limx,limy,xx,yy,id,ie:Longint;
    dp:array[1..64,1..2,1..2]of int64;
begin
	read(L,R);
    M:=1000000007;
    ll:=1;
    rr:=2;
    for k:=1 to 60 do begin
    	if(rr<=L)or(R<ll)then begin
        	ll:=ll*2;
            rr:=rr*2;
        	continue;
        end;
        for i:=1 to 61 do for xx:=1 to 2 do for yy:=1 to 2 do dp[i,xx,yy]:=0;
        if L<=ll then if rr-1<=R then dp[1,2,2]:=1 else dp[1,2,1]:=1 else if rr-1<=R then dp[1,1,2]:=1 else dp[1,1,1]:=1;
        for i:=1 to k-1 do begin
        	x:=(L>>(k-1-i))mod 2;
            y:=(R>>(k-1-i))mod 2;
            for xl:=1 to 2 do begin
            	if xl=1 then limx:=x else limx:=0;
                for yl:=1 to 2 do begin
                	if yl=1 then limy:=y else limy:=1;
                    for yy:=0 to limy do begin
                    	for xx:=limx to yy do begin
                        	if(xl=2)or(xx>limx)then id:=2 else id:=1;
                            if(yl=2)or(yy<limy)then ie:=2 else ie:=1;
                            dp[i+1,id,ie]:=(dp[i+1,id,ie]+dp[i,xl,yl])mod M;
                        end;
                    end;
                end;
            end;
        end;
        ll:=ll*2;
        rr:=rr*2;
        ans:=(ans+dp[k,1,1]+dp[k,1,2]+dp[k,2,1]+dp[k,2,2])mod M;
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int inf = 0x3f3f3f3f;
const int N = 10414;
const int M = 40414;

struct Edge{
	int u, v, d, c;
	int next;
}edge[M];

int cnt, head[N];
int op, tp, link[N];
int vis[N], dis[N], cost[N];
queue<int>q;

void add_edge(int u, int v, int d, int c);
void spfa(int n);

int main(){
	int n, m, i, u, v, d, c;
	while(scanf("%d %d", &n, &m) && (n || m)){
		cnt = 0;
		memset(head, -1, sizeof(head));
		for(i = 0; i < m; i++){
			scanf("%d %d %d %d", &u, &v, &d, &c);
			add_edge(u, v, d, c);
			add_edge(v, u, d, c);
		}
		spfa(n);
	}
	return 0;
}
void add_edge(int u, int v, int d, int c){
	edge[cnt].u = u;
	edge[cnt].v = v;
	edge[cnt].d = d;
	edge[cnt].c = c;
	edge[cnt].next = head[u];
	head[u] = cnt++;
}
void spfa(int n)
{
    int v, d, c;
    while(!q.empty())q.pop();
    memset(vis, 0,sizeof(vis));
    memset(dis, inf, sizeof(dis));
    memset(cost, inf, sizeof(cost));
    dis[1]=0;
    cost[1]=0;
    vis[1]=true;
    q.push(1);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u]; i!=-1; i=edge[i].next)
        {
            v = edge[i].v;
            d = edge[i].d;
            c = edge[i].c;
            if(dis[v] > dis[u] + d||(dis[v] == dis[u] + d && cost[v] > c))//有多条最短路时，取花费最小的
            {
                dis[v] = dis[u] +d;
                cost[v] = c;
                if(!vis[v])
                {
                    q.push(v);
                    vis[v]=true;
                }
            }
        }
    }
    int sum = 0;
    for(int i = 1; i <= n; i++){
    	sum += cost[i];
    }
    printf("%d\n", sum);
    return;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(int (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(int (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    ll n,m,ans = 0;
    cin >> n >> m;
    vector<ll> x(m),dif(m - 1);
    rep0(i, m)cin >> x[i];
    sort(all(x));
    rep1(i, m)dif[i - 1] = abs(x[i - 1] - x[i]);
    sort(all(dif),greater<>());
    for (ll i = n - 1; i < m - 1; ++i)ans += dif[i];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void)
{
  char S[4];
  cin >> S;
  sort(S,S+4);
  if(S[0]==S[1] && S[2]==S[3] && S[0] != S[2] && S[1] != S[3])
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

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

typedef long long LL;

const int N=100000;

int n,a[N+9],ord[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	scanf("%d",&a[i]);
	ord[i]=a[i];
  }
}

int cnt[5],ans;

void Get_ans(){
  sort(ord+1,ord+n+1);
  int co=unique(ord+1,ord+n+1)-ord-1;
  if (co>3) return;
  for (int i=1;i<=n;++i) ++cnt[a[i]=lower_bound(ord+1,ord+co+1,a[i])-ord];
  if (co==1) {ans=ord[1]==0;return;}
  if (co==2) {ans=ord[1]==0&&cnt[2]==cnt[1]<<1;return;}
  if (co==3) {ans=(ord[1]^ord[2])==ord[3]&&cnt[1]==cnt[2]&&cnt[2]==cnt[3];return;}
}

void work(){
  Get_ans();
}

void outo(){
  puts(ans?"Yes":"No");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4412
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
    if (a == b) 
        return a; 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
int main(){
    int n;
    cin>>n;
    ll a;
    ll sum =0;
    map<ll,ll>m;
    for(int i=0;i<n;i++){
        cin>>a;
        sum = sum + a;
        m[a]++;
    }
    int q;
    cin>>q;
    ll b,c;
    for(int i=0;i<q;i++){
        cin>>b>>c;
        sum = sum + m[b]*(c-b);
        m[c]=m[b]+m[c];
        m[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}






Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=222222;
int col[maxn],D[maxn],fir[maxn],nxt[maxn],to[maxn],tot=1;
void add_edge(int x,int y)
{
	nxt[++tot]=fir[x],to[fir[x]=tot]=y;
}
void dfs(int x,int y,int bad_col)
{
	int cnt=0;
	for(int i=fir[x],v=to[i];i;i=nxt[i],v=to[i])if(v!=y)
	{
		if((++cnt)==bad_col) ++cnt;
		col[i]=col[i^1]=cnt;
	}
	for(int i=fir[x],v=to[i];i;i=nxt[i],v=to[i])if(v!=y) dfs(v,x,col[i]);
}
int main()
{
	int N;scanf("%d",&N);
	for(int i=1;i<N;++i)
	{
		int a,b;scanf("%d%d",&a,&b);
		add_edge(a,b),add_edge(b,a);
		++D[a],++D[b];
	}
	int COL=1;
	for(int i=1;i<=N;++i) COL=max(COL,D[i]);
	printf("%d\n",COL);
	dfs(1,0,0);
	for(int i=1;i<N;++i) printf("%d\n",col[i<<1]);
	return 0;
}

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

#define ing long long

signed main(){
	string S;
	int n=0, m=0, ans=0;
	int a=0, b=0,c=0;
	cin>>S;
	if(S[0]!='A'){n=1;}
	else S[0]='a';
	for(int i = 2; i <= S.size()-2; i++){//cout<<S[i]<<endl;
		if(S[i]=='C'){m++;S[i]='c';}
	}
	if(m!=1)n=1;
	for(int i = 0; i <S.size(); i++){
		//if(S[i]=='A'||S[i]=='C')continue;
		if(S[i] >= 'a' && S[i] <= 'z'){
		}else n=1;
	}
	cout<<(n?"WA":"AC")<<endl;
	return 0;
}

Measured memory_bytes: 256