akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll p = 1e9+7;

ll mypow(ll b,ll e) {
  if(e<0) return 0L;
  if(e==0) return 1L;
  if(e%2==0) {
    ll t=mypow(b,e/2);
    return (t*t)%p;
  }
  return (b*mypow(b,e-1))%p;
}

int main() {
  string s; cin>>s;
  int n = s.size();
  vector<ll> A(n);
  vector<ll> L(n);
  vector<ll> R(n);
  vector<ll> C(n);
  ll Q = 0;
  rep(i,n) if(s[i]=='?')Q++;
  rep(i,n-1) {
    if(s[i]=='A') A[i+1]=A[i]+1;
    else A[i+1]=A[i];
  }
  rep(i,n-1) {
    if(s[i]=='?') L[i+1]=L[i]+1;
    else L[i+1]=L[i];
  }
  for(int i=n-2; i>=0; i--) {
    if(s[i+1]=='C') C[i]=C[i+1]+1;
    else C[i]=C[i+1];
  }
  for(int i=n-2; i>=0; i--) {
    if(s[i+1]=='?') R[i]=R[i+1]+1;
    else R[i]=R[i+1];
  }
  ll ans=0;
  rep(i,n) {
    if(s[i]=='B') {
      ans+= (((A[i]*C[i])%p)*mypow(3,Q))%p;
      ans%=p;
      ans+= (((A[i]*R[i])%p)*mypow(3,Q-1))%p;
      ans%=p;
      ans+=(((L[i]*C[i])%p)*mypow(3,Q-1))%p;
      ans%=p;
      ans+=(((L[i]*R[i])%p)*mypow(3,Q-2))%p;
    }
    if(s[i]=='?') {
      ans+=(((A[i]*C[i])%p)*mypow(3,Q-1))%p;
      ans%=p;
      ans+=(((A[i]*R[i])%p)*mypow(3,Q-2))%p;
      ans%=p;
      ans+=(((L[i]*C[i])%p)*mypow(3,Q-2))%p;
      ans%=p;
      ans+=(((L[i]*R[i])%p)*mypow(3,Q-3))%p;
    }
    ans%=p;
    // if(s[i]=='?'||s[i]=='B') {
    //   ll t1 = 0;
    //   t1+=A[i]*(L[i]+1);
    //   t1%=p;
    //   t1+=L[i]*(L[i]+1)/2;
    //   t1%=p;
    //   ll t2 = 0;
    //   t2+=C[i]*(R[i]+1);
    //   t2%=p;
    //   t2+=R[i]*(R[i]+1)/2;
    //   t2%=p;
    //   ans+=(t1*t2)%p;
    //   ans%=p;
    // }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

int main(void){
  int a, b, c, k = 0;
  scanf("%d %d %d", &a, &b, &c);
  for (int i = a; i <= b; i++){
    if (c % i == 0) k++;
  }
  printf("%d\n", k);
  return 0;
}

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

int main(){
  int ans = 0;
  string s;
  cin >> s;
  
  rep(i, s.size() - 1, 0){
    if(s.at(i) == s.at(i+1)) ans = 1;
  }
  
  if(ans) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i,j,l,p,q,ans,v=INF;
	cin >> n >> l;
	for(i=0; i<n; ++i){
		p = 0; q = 0;
		for(j=0; j<n; ++j){
			q += (l+j);
			if(i==j){
				continue;
			}
			p += (l+j);
		}
		if(v > abs(p-q)){
			v = abs(p-q);
			ans = p;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
void dfs(string s,char mxc)
{
  if(n==s.size())
   cout << s << endl;
  else
  {
     for(char c = 'a'; c <= mxc; ++c) {
      dfs(s+c, (c==mxc?mxc+1:mxc));
     }
  }
}
int main()
{
  cin>>n;
  dfs("",'a');
}
  

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

// #include "debug.h"
// #define debug(...) 42

using ll = long long;

void solve() {
   int n;
   cin >> n;
   string s;
   cin >> s;

   map <char, int> m, c;
   for(int i = 0; i < n; i++) {
      m[s[i]]++;
   }

   int ans = 0;
   for(int i = 0; i < n; i++) {
      c[s[i]]++;
      int t_ans = 0;
      for(auto ch: c) {
         if(ch.second < m[ch.first])
            t_ans++;
      }
      ans = max(ans, t_ans);
   }
   cout << ans << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int a,b,c;
int main(){
	ios::sync_with_stdio(0);
	cin>>a>>b>>c;
	cout<<a+b+c-max(a,max(b,c));
	re 0;
}

Measured memory_bytes: 256
#include<stdio.h>
   
int main(){
    int dice[6],q,i;
    char c;
       
    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
       
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        if((x==dice[5] && y==dice[4])||(x==dice[4] && y==dice[0])||(x==dice[0] && y==dice[1])||(x==dice[1] && y==dice[5])){
            printf("%d\n",dice[2]);
        }else if((x==dice[0] && y==dice[2])||(x==dice[2] && y==dice[5])||(x==dice[5] && y==dice[3])||(x==dice[3] && y==dice[0])){
            printf("%d\n",dice[4]);
        }else if((x==dice[5] && y==dice[1])||(x==dice[1] && y==dice[0])||(x==dice[0] && y==dice[4])||(x==dice[4] && y==dice[5])){
            printf("%d\n",dice[3]);
        }else if((x==dice[0] && y==dice[3])||(x==dice[3] && y==dice[5])||(x==dice[5] && y==dice[2])||(x==dice[2] && y==dice[0])){
            printf("%d\n",dice[1]);
        }else if((x==dice[2] && y==dice[1])||(x==dice[1] && y==dice[3])||(x==dice[3] && y==dice[4])||(x==dice[4] && y==dice[2])){
            printf("%d\n",dice[5]);
        }else{
            printf("%d\n",dice[0]);
        }
    }
    return 0;
}


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

int a[300100];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < 3*n; i++)
		scanf("%d", a+i);
	sort(a, a + 3*n, greater<int>());
	long ans = 0;
	for(int i = 1; i < 2*n; i+=2)
		ans += a[i];
	printf("%ld\n", ans);
}


Measured memory_bytes: 1408
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

decimal.getcontext().prec = 50

N = input()
x = []
y = []
for i in range(N):
    x_, y_ = map(int, raw_input().split())
    x += [decimal.Decimal(x_)]
    y += [decimal.Decimal(y_)]

ans = 0

for i in range(N):
    for j in range(N - 1):
        if math.atan2(x[j], y[j]) > math.atan2(x[j + 1], y[j + 1]):
            x[j], x[j + 1] = x[j + 1], x[j]
            y[j], y[j + 1] = y[j + 1], y[j]
for i in range(N):
    for j in range(N):
        X = decimal.Decimal(0)
        Y = decimal.Decimal(0)
        for k in range(N):
            if i <= j and i <= k <= j:
                X += x[k]
                Y += y[k]
            elif j < i and not j < k < i:
                X += x[k]
                Y += y[k]
        ans = max(ans, X * X + Y * Y)

print math.sqrt(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N) cin >> h[i];
  
  int cnt = 0;
  rep(i,N) {
    if (h[i] >= K) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func getInt() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func main() {
	s.Split(bufio.ScanWords)
	n := getInt()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = getInt()
	}

	count := 0
	ans := 0
	for i := 1; i < n; i++ {
		count = 0
		for j := 0; j < i; j++ {
			if h[j] > h[i] {
				count = 1
				break
			}
		}
		if count == 0 {
			ans++
		}
	}
	fmt.Println(ans + 1)
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> h(n,0);
    rep(i,n) cin>>h[n-1-i];
    rep(i,n-1){
        if(h[i+1]-h[i]>1){
            cout<<"No"<<endl;
            break;
        }
        if(h[i+1]-h[i]==1) h[i+1]--;
        if(i==n-2) cout<<"Yes"<<endl;
    }
    if(n==1) cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static long N;
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            Console.WriteLine(Dfs("0"));
        }

        static int Dfs(string s)
        {
            int result = 0;
            if (long.Parse(s) > N)
            {
                return result;
            }

            if (s.Contains('7') && s.Contains('5') && s.Contains('3'))
            {
                result++;
            }

            foreach (var item in "753")
            {
                result += Dfs(s + item);
            }
            return result;
        }
    }
}


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

const int MOD = 1000000007;

int main(void){
    // Your code here!
    long long N,K;
    
    cin >> N >> K;
    
    long long res = 0;
    for (long long k = K; k <= N+1; k++) {
        
        long long first = k * (k-1) / 2;
        
        long long final = (2*N-k+1) * k / 2;
        
        long long add = final - first + 1;
        
        res = (res + add) % MOD;

    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 3644
x, n = map(int, input().split())

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

an = [0]*105



for pi in pn:
    an[pi] = -1


dist = 10000
ans = 99999
for i, ai in enumerate(an):
    if ai == -1:
        continue

    if dist > abs(i-x):
        dist = abs(i-x)
        ans = i


print(ans)


Measured memory_bytes: 9188
#include<iostream>
#include<stdio.h>
#include<string.h> 
using namespace std;
struct node{long long x,y;}a[1010];
int n;
bool p[233],pp[233];
int pint(int x){
	for(int j=0;j<x;j++){
		if(p[j]&&pp[j])putchar('R');
		if(!p[j]&&!pp[j])putchar('L');
		if(p[j]&&!pp[j])putchar('U');
		if(!p[j]&&pp[j])putchar('D');
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[i].x=x+y;a[i].y=x-y;
	}
	for(int i=1;i<=n;i++)if((a[i].x&1)!=(a[i].y&1)){puts("-1");return 0;}
	for(int i=2;i<=n;i++)if((a[i].x&1)!=(a[1].x&1)){puts("-1");return 0;}
	if (a[1].x&1){
		puts("39");
		for (int i=0;i<39;i++) printf("%lld ",1LL<<i);
		puts("");
		for (int i=1;i<=n;i++){
			long long hh=((1LL<<39)-1-a[i].x)/2;
			for(int j=0;j<39;j++)if((1LL<<j)&hh) p[j]=false;else p[j]=true;
			hh=((1LL<<39)-1-a[i].y)/2;
			for(int j=0;j<39;j++)if((1LL<<j)&hh) pp[j]=false;else pp[j]=true;
			pint(39);
			puts("");
		}
	}
	else{
		puts("40");
		printf("1 ");
		for (int i=0;i<39;i++) printf("%lld ",1LL<<i);
		puts("");
		for(int i=1;i<=n;i++){
			if(a[i].x==0){for(int j=0;j<39;j++)p[j]=false;p[39]=true;}
			else{
				long long hh=((1LL<<39)-1-(a[i].x-1))/2;
				p[0]=1;
				for (int j=0;j<39;j++)if((1LL<<j)&hh) p[j+1]=false;else p[j+1]=true;
			}
			if(a[i].y==0){for(int j=0;j<39;j++)pp[j]=false;pp[39]=true; }
			else{
				long long hh=((1LL<<39)-1-(a[i].y-1))/2;
				pp[0]=1;
				for(int j=0;j<39;j++)if((1LL<<j)&hh)pp[j+1]=false;else pp[j+1]=true;
			}
			pint(40);
			puts("");
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;

class Code {
  static void Main() {
  	int N = int.Parse(Console.ReadLine().Trim());
    string S = Console.ReadLine().Trim();
    
    if(N % 2 == 1 ) {
     	Console.WriteLine("No");
    } else {
    	string S1 = S.Substring(0, N / 2);
		string S2 = S.Substring(N / 2, N / 2);
        if(S1 == S2) {
          Console.WriteLine("Yes");
        } else {
          Console.WriteLine("No");
        }
    }
  }
}

Measured memory_bytes: 11092
N, M = map(int, input().split())

ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])

ab.sort()

counter = 0
ans = 0
for i in range(N):

    for j in range(ab[i][1]):
        counter += 1
        ans += ab[i][0]

        if counter >= M:
            print(ans)
            exit()


Measured memory_bytes: 20072
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let N = get!(usize);
    let ps = get!(usize | );

    let mut has_changed = false;
    let mut second = false;
    let mut prev_i = 0;
    let mut prev_p = 0;
    for (i, &p) in ps.iter().enumerate() {
        if i+1 != p {
            if has_changed {
                println!("NO");
                return;
            }
            if second {
                if prev_i+1 == p && prev_p == i+1 {
                    has_changed = true;
                } else {
                    println!("NO");
                    return;
                }
            } else {
                prev_i = i;
                prev_p = p;
                second = true;
            }
        }
    }
    println!("YES");
}


Measured memory_bytes: 4352
#include<stdio.h>

int A[100][100],n;

int main()
{
  int i,j,k,l,m;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  A[i][j]=0;
	}
    }
  
  for(l=0;l<n;l++)
    {
      scanf("%d",&i);
      scanf("%d",&k);
      for(m=0;m<k;m++)
	{
	  scanf("%d",&j);
	  A[i-1][j-1]=1;
	}
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j==n-1)printf("%d",A[i][j]);
	  else printf("%d ",A[i][j]);
	}
      printf("\n");
    }

  return 0;

}
  

Measured memory_bytes: 636
N = gets.to_i
A = Array.new(N){gets.split.map(&:to_i)}
A.unshift([0,0,0])

ans = true
A.each_cons(2) do |a1,a2|
  dt = a2[0] - a1[0]
  dx = (a2[1] - a1[1]).abs
  dy = (a2[2] - a1[2]).abs
  dl = dx + dy
  if dl <= dt && (dt - dl).even?
  else
    ans = false
  end
end

puts ans ? "Yes" : "No"

Measured memory_bytes: 9980
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg



int main()
{
	long double a, b;
	cin >> a >> b;
	
	cout << (ll)floor(a*b) <<endl;

	return 0;
}



Measured memory_bytes: 3732
(set! *unchecked-math* true)
(defn input []
  (vector
    (->> (clojure.string/split (read-line) #"\s")
      (map #(Integer/parseInt %)))
    (apply vector (read-line))
    (apply vector (read-line))))

(defn gcd [A B]
  (.gcd (BigInteger. (str A)) (BigInteger. (str B))))

(defn lcm [a b]
  (quot (* (bigint a) (bigint b)) (gcd a b)))

(defn first-inner [N S L]
  (zipmap (range 0 L (quot L N)) S))

(defn second-inner [M T L X]
  (let [Number (quot L M)]
    (loop [t T i 0]
      (if (empty? t)
        true
        (if-let [v (find X i)]
          (if (not= (v 1) (first t))
            false
            (recur (rest t) (unchecked-add-int i Number)))
          (recur (rest t) (unchecked-add-int i Number)))))))


(defn TwoAbbreviation [[[N M] S T]]
  (let [L (lcm N M)]
    (if (->> (first-inner N S L) (second-inner M T L))
      (str L)
      -1)))

(->> (input)
  TwoAbbreviation
  println)


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    vector<pair<string,pair<int,int>>> dat(n);
    rep(i,n){
        cin>>dat[i].first>>dat[i].second.first;
        dat[i].second.first*=-1;
        dat[i].second.second=i+1;
    }
    sort(ALL(dat));
    rep(i,n){
        cout<<dat[i].second.second<<endl;
    }
}


Measured memory_bytes: 256
using System;

namespace AGC036
{
    class A
    {
        static void Main(string[] args)
        {
            long W = 1000000000;
            long S = long.Parse(Console.ReadLine());
            long x = (W - S % W) % W;
            long y = (S + x) / W;
            Console.WriteLine("{0} {1} {2} {3} {4} {5}", 0, 0, W, 1, x, y);
        }
    }
}


Measured memory_bytes: 11220
/*
created by: Son Dinh
*/
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sqr(X) ((X)*(X))
#define sz(x) ((int)(x).size())
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int n,q,l,r;
string s;
int f[100005];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>q;
    cin.ignore();
    cin>>s;
    f[0]=f[1]=0;
    for(int i=1;i<sz(s);++i){
        if(s[i]=='C'&&s[i-1]=='A') f[i+1]=f[i]+1;
        else f[i+1]=f[i];
    }
    while(q--){
        cin>>l>>r;
        cout<<f[r]-f[l]<<'\n';
    }
}



Measured memory_bytes: 1488
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
int pref[10000010];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	ll i, j;
   	for(i = 1; i <= 10000000; i++) {
   		for(j = i; j <= 10000000; j += i) {
   			pref[j]++;
   		}
   	}
   	ll n;
   	cin >> n;
   	ll ans = 0;
   	for(i = 1; i <= n; i++) {
   		ans = ans + i*pref[i];
   	}
   	cout << ans << "\n";
}

Measured memory_bytes: 42704
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int d[2][2010][2010];
int s[2][2010][2010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    int sw = 0, sb = 0;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<char> c(n);
    rep(i, 0, n){
        cin >> x[i] >> y[i] >> c[i];
        d[(c[i] == 'B' ? 1  : 0)][y[i] % (2 * k)][x[i] % (2 * k)]++;
        if(c[i] == 'B') sb++;
        else sw++;
    }
    rep(i, 0, 2){
        rep(j, 1, 2 * k + 1){
            rep(l, 1, 2 * k + 1){
                s[i][j][l] = d[i][j - 1][l - 1];
            }
        }
    }
    rep(i, 0, 2){
        rep(j, 1, 2 * k + 1){
            rep(l, 1, 2 * k + 1){
                s[i][j][l] += s[i][j][l - 1];
            }
        }
    }
    rep(i, 0, 2){
        rep(j, 1, 2 * k + 1){
            rep(l, 1, 2 * k + 1){
                s[i][l][j] += s[i][l - 1][j];
            }
        }
    }
    // rep(l, 0, 2){
    //     rep(i, 1, 5){
    //         rep(j, 1, 5){
    //             cout << " " << s[l][i][j];
    //         }
    //         cout << endl;
    //     }
    //     cout << endl;
    // }
    int ans = 0;
    rep(i, k, 2 * k + 1){
        rep(j, k, 2 * k + 1){
            int white = s[0][j][2 * k] - s[0][j][0] - s[0][j - k][2 * k] + s[0][j - k][0] + s[0][2 * k][i] - s[0][2 * k][i - k] - s[0][0][i] + s[0][0][i - k] - 2 * (s[0][j][i] - s[0][j][i - k] - s[0][j - k][i] + s[0][j - k][i - k]);
            int black = s[1][j][2 * k] - s[1][j][0] - s[1][j - k][2 * k] + s[1][j - k][0] + s[1][2 * k][i] - s[1][2 * k][i - k] - s[1][0][i] + s[1][0][i - k] - 2 * (s[1][j][i] - s[1][j][i - k] - s[1][j - k][i] + s[1][j - k][i - k]);
            assert(black >= 0);
            int tmp = white + (sb - black);
            tmp = max(tmp, n - tmp);
            if(ans < tmp){
                // cout << i << " " << j << " " << sb << " " << black << " " << white << endl;
                ans = tmp;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 128000
# ARC059C - いっしょ / Be Together (ABC043C)
def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    ans = float("inf")
    MIN, MAX = min(lst), max(lst)

    for i in range(MIN, MAX + 1):
        cnt = 0
        for j in lst:
            cnt += (i - j) ** 2
        ans = min(ans, cnt)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define F first
#define S second
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e9;

ll n,a,b;
ll h[100010];
bool solve(long long t){
    long long cnt = 0;
    for(int i = 0;i < n;i++){
        if(h[i] <= t*b) continue;
        else cnt += (h[i] - t*b - 1)/(a-b) + 1;
    }
    return (cnt <= t);
}
int main(void){
    cin>>n>>a>>b;
    rep(n) cin>>h[i];
    /////////////////

    ll lb = 0,ub = (ll)1e9;
    for(int i = 0;i < 1000;i++){
        ll m = (lb+ub)/2;
        if(solve(m)){
            ub = m;
        }else{
            lb = m + 1;
        }
        //debug(m);
        if(ub==lb)break;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
constexpr long long mod1 = 1e9+7;
using namespace std;

int main(){
  long long n, k, ans = 0; cin >> n >> k;
  vector<long long> v(k+1, 1);
  rrep(i, k){
    rep(j, k/(i+1)){
      if(j == 0){
        long long u = n, w = k/(i+1);
        while(u > 0){
          if(u & 1){
            v[i+1] *= w;
            v[i+1] %= mod1;
          }
          u /= 2;
          w *= w;
          w %= mod1;
        }
      }
      else{
        v[i+1] += mod1;
        v[i+1] -= v[(i+1)*(j+1)];
        v[i+1] %= mod1;
      }
    }
  }
  rep(i, k){
    ans += v[i+1] * (i+1);
    ans %= mod1;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>
int a = 0;
int count = 0;

void two(int a) {
    if(a % 2 != 1) {
        a = a / 2;
        count++;
        two(a);
    } else {
        return;
    }
}

int main(int argc, char *argv[])
{
    int n = 0;
    int i = 0;

    scanf("%d", &n);
    long a[n];

    while (n >= (i + 1))
    {
        scanf("%ld", &a[i]);
        two(a[i]);
        i++;
    }

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

    return 0;
}


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

int main() {
  int a;
  int b;
  string s;
  cin >> a >> b;
  if (a * b % 2 == 0 ) {
    s = "Even";
  }else {
    s = "Odd";
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
signed main()
{
	int n, m, h[100001], ans = 0;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &h[i]);
	}
	vector<vector<int>> c(n, vector<int>(0));
	for(int i = 0, a, b; i < m; ++i)
	{
		scanf("%d%d", &a, &b);
		c[a - 1].push_back(b - 1);
		c[b - 1].push_back(a - 1);
	}
	for(int i = 0; i < n; ++i)
	{
		bool good = true;
		for(int j = 0; j < c[i].size(); ++j)
		{
			good &= h[i] > h[c[i][j]];
		}
		ans += good;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 8800
int main (void){
    int i,j,n,r,p,c;
    int card[100]={0},nc[100]={0};
    while(-1){
        scanf("%d %d",&n,&r);
        if(n==0&&r==0){break;}
        for(i=0;i<n;i++){
            nc[i]=n-i;
        }
        for(i=0;i<r;i++){
            scanf("%d %d",&p,&c);
            for(j=0;j<p-1;j++){
                card[j+c]=nc[j];
            }
            for(j=p-1;j<p+c-1;j++){
                card[j-p+1]=nc[j];
            }
            for(j=p+c-1;j<n;j++){
                card[j]=nc[j];
            }
            for(j=0;j<n;j++){
                nc[j]=card[j];
            }
            
        }
        printf("%d\n",nc[0]);
    }
    return 0;
        
}

Measured memory_bytes: 600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long N = 1;
		List<long> ans = new List<long>();
		for(;ans.Count < K;){
			ans.Add(N);
			N = f(N + 1);
		}
		
		Console.WriteLine(String.Join("\n", ans));
		
		
	}
	
	long f(long n){
		char[] ca = String.Format("{0:D016}",n).ToCharArray();
		List<long> L = new List<long>();
		for(int i=ca.Length - 1;i>=0;i--){
			L.Add(long.Parse(new String(ca)));
			ca[i] = '9';
		}
		
		long minn = L[0];
		long mind = ds(L[0]);
		
		for(int i=0;i<L.Count;i++){
			long vn = L[i];
			long vd = ds(L[i]);
			if(vn  * mind < minn * vd){
				minn = vn;
				mind = vd;
			}
		}
		
		return minn;
	}
	
	long ds(long v){
		long ret = 0;
		while(v > 0){
			ret += v % 10;
			v /= 10;
		}
		return ret;
	}
	
	
	int K;
	public Sol(){
		K = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11260
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

n, i = list(map(int, sys.stdin.buffer.readline().split()))

print(n - i + 1)


Measured memory_bytes: 13424
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define MP  make_pair
using namespace std;
typedef long long ll;

int vx[]={1,0,-1,0},vy[]={0,1,0,-1};

int main(){
    int p1,p2,p3,j1,j2;
    scanf("%d%d%d%d%d",&p1,&p2,&p3,&j1,&j2);
    printf("%d\n",min(min(p1,p2),p3)+min(j1,j2)-50);
}

Measured memory_bytes: 0
/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);   cout.tie(NULL);
#define mod (ll)1e18
#define pb push_back
#define N 100000 + 5
#define N 100000 + 5
# define deb(x) cout<<#x<<" "<<x<<endl;
//   cout << fixed << setprecision(12);
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))
#define forabr(i, a, b, c) for (ll(i) = a; (i) >= (b); (i) -= (c))
void arrinitialize(ll n,ll a[],ll x){
    forab(i,0,n-1,1){
        a[i]=x;
    }
}
void start(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int main(){
    fastio;
   // start();
    ll n,k;cin>>n>>k;ll a[n];forab(i,0,n-1,1)cin>>a[i];ll b[n]={0};
    arrinitialize(n,b,1000000000000000000);ll s=0;b[0]=0;
    forab(i,1,n-1,1){
        forab(j,max((ll)0,i-k),i-1,1)
        b[i]=min(b[i],abs(a[i]-a[j])+b[j]);
    }
    cout<<b[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,x="Yes\n",y="No\n";
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C'){
			for(int j=i+1;j<a.size();j++){
				if(a[j]=='F'){
					cout<<x;
					return 0;
				}
			}
		}
	}
	cout<<y;
	return 0;
}


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

int knapsack(vector<int> &v, vector<int> &w, vector<int> &m, int W) {
    vector<int> dp(W + 1, 0);
    for (int i = 0; i < v.size(); ++i) {
        int num = m[i];
        for (int k = 1; num > 0; k <<= 1) {
            int mul = min(k, num);
            for (int j = W; j >= w[i] * mul; --j) {
                dp[j] = max(dp[j], dp[j - w[i] * mul] + v[i] * mul);
            }
            num -= mul;
        }
    }
    return dp[W];
}

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N), m(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i] >> m[i];
    }
    cout << knapsack(v, w, m, W) << endl;
}


Measured memory_bytes: 3156
while True:
    N = int(input())
    if N == 0: break

    s = []
    for _ in range(N):
        d,a = input().split()
        s.append((d,1))
        s.append((a,-1))
    s.sort()
    s.append(('END',0))
    ans = 0
    cnt = 0
    bt = ''
    for t,c in s:
        if bt != t: ans = max(ans,cnt)
        cnt += c
        bt = t
    print (ans)


Measured memory_bytes: 8252
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (N*A<B)
	{
		cout << N*A << endl;
	}
	else
	{
		cout << B << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    string a, b,ans;
    cin >> a >> b;
    if (a.size() != b.size()) {
        if (a.size() > b.size())ans = "GREATER";
        else ans = "LESS";
    }
    else {
        if (a == b)ans = "EQUAL";
        else {
            rep(i, a.size()) {
                if (a[i] != b[i]) {
                    if (a[i] > b[i])ans = "GREATER";
                    else ans = "LESS";
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var pg = new Program();

            pg.Execute();

        }

        private void Execute()
        {
            var input = ReadLineLong;
            var sequence = Enumerable.Range(1, (int)input);

            var sum = sequence.Where(e =>e % 3 != 0 && e % 5 != 0).Select(v => (long)v).Sum();
            OutputResult(sum);
        }

        private void OutputResult<Type>(Type result)
        {
            Console.WriteLine(result);
        }

        static long ReadLineLong => long.Parse(Console.ReadLine());
        static string ReadLineString => Console.ReadLine();
        static IEnumerable<long> ReadLinesLongList => Console.ReadLine().Split(' ').Select(i => long.Parse(i));
        static IEnumerable<string> ReadLinesStringList => Console.ReadLine().Split(' ');

    }
}


Measured memory_bytes: 28288
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_N=100;

int main(void){
    int n;
    int B[MAX_N];

    // 入力
    cin >> n;
    for(int i=0; i<n-1; i++){
        cin >> B[i];
    }

    // 0番目と n番目は決まる
    int ans = B[0]+B[n-2];

    // B内で隣合う数字比べて小さい方を加算
    for(int i=0; i<n-2; i++){
        if(B[i]<=B[i+1]) ans+=B[i];
        else ans+=B[i+1];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


int main() {
    string s;
    cin >> s;
    deque<char> sta;
    string ss;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B')
            if (!sta.empty())
                sta.pop_back();
            else
                continue;
        else
            sta.push_back(s[i]);
    }
    while (!sta.empty()) {
        cout << sta.front();
        sta.pop_front();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    char i;
    cin >> i;
    if (isupper(i)) {
        cout << 'A';
    }
    else {
        cout << 'a';
    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	// cin>>t;

	int n, m;
	ll a, b, mini = 1e6, maxi = -1;
	rep(nc, 0, t){
		cin>>n>>m;
		rep(i, 0, m) {
			cin>>a>>b;
			maxi = max(maxi, a);
			mini = min(mini, b);
		}

		mini = min(mini, (ll)n);
		maxi = max(maxi, 1LL);
		// cout<<mini; cn;
		// cout<<maxi; cn;
		if(mini >= maxi)
			cout<<mini - maxi + 1<<"\n";
		else cout<<"0\n";
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
int i = 1;
while(i < 3000){
int x = sc.nextInt();
int y = sc.nextInt();
if (x >= 0 && x <= 10000){
if (y >= 0 && y <= 10000){
if ((x == 0) && (y == 0)) {
break;
}else{
if (x <= y){
System.out.println(x + " " + y);
}else{
System.out.println(y + " " + x);
}
}
}
}
}
}
}


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

typedef struct {
    char name[11];
    int rate;
    int id;
} Restaurant;


int compare(const void *a, const void *b) {
    Restaurant *A = (Restaurant *)a;
    Restaurant *B = (Restaurant *)b;
    int ret = strcmp(A->name, B->name);
    if(ret==0){
        return B->rate - A->rate;
    }else{
        return ret;
    }
}

int main(){
    int i, j, k, l, m, n;
    int N, M, L;
    char buf[11];
    
    
    scanf("%d", &N);
    Restaurant *arr = (Restaurant*)malloc(sizeof(Restaurant) * N);
    
    for(i = 0; i < N; i++){
        scanf("%s", buf);
        scanf("%d", &arr[i].rate);
        sprintf(arr[i].name, "%s", buf);
        arr[i].id = i+1;
    }
    
    // for(i = 0; i < N; i++){
    //     printf("%d %s %d\n", arr[i].id, arr[i].name, arr[i].rate);
    // }
    
    qsort(arr, N, sizeof(Restaurant), compare);

    for(i = 0; i < N; i++){
        printf("%d\n", arr[i].id);
    }

    
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int H, W;
int ch_cnt[26];

void No()
{
	cout << "No" << endl;
	exit(0);
}

signed main()
{
	cin >> H >> W;

	int cnt4 = 0;
	int cnt2 = 0;
	int cnt1 = 0;

	int x4 = (W / 2);
	int y4 = (H / 2);
	cnt4 = x4 * y4;

	if (W % 2 == 1)
	{
		cnt2 += y4;
	}
	if (H % 2 == 1)
	{
		cnt2 += x4;
	}

	if (W % 2 == 1 && H % 2 == 1)
	{
		cnt1 = 1;
	}


	REP(y, H)
	{
		char str[200];
		cin >> str;
		REP(x, W)
		{
			char ch = str[x];
			ch_cnt[ch - 'a']++;
		}
	}

	for (int i = 0; i < cnt4; i++)
	{
		bool ok = false;
		for (int c = 0; c < 26; c++)
		{
			if (ch_cnt[c] >= 4)
			{
				ch_cnt[c] -= 4;
				ok = true;
				break;
			}
		}
		if (!ok)
		{
			No();
		}
	}

	for (int i = 0; i < cnt2; i++)
	{
		bool ok = false;
		for (int c = 0; c < 26; c++)
		{
			if (ch_cnt[c] >= 2)
			{
				ch_cnt[c] -= 2;
				ok = true;
				break;
			}
		}
		if (!ok)
		{
			No();
		}
	}

	if(cnt1 > 0)
	{
		bool ok = false;
		for (int c = 0; c < 26; c++)
		{
			if (ch_cnt[c] >= 1)
			{
				ch_cnt[c] -= 1;
				ok = true;
			}
		}
		if (!ok)
		{
			No();
		}
	}

	cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
int main()
{
	for(int i=1;;i++)
	{
		if(i*(i+1)/2>1e9)
		{
			break;
		}
		v.push_back(i*(i+1)/2);
	}
	scanf("%d",&n);
	printf("%d\n",lower_bound(v.begin(),v.end(),n)-v.begin()+1);
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
int main()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	ll dp[n];
	dp[0]=0;
	dp[1]=llabs(arr[1]-arr[0]);

	for(int i=2;i<n;i++)
	{
		ll temp=INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)
			{
				temp=min(temp,(dp[i-j]+llabs(arr[i]-arr[i-j])));
			}
			
		}
		dp[i]=temp;
	}

	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class PaizaSample
{


    static void Main()
    {

        string s = Console.ReadLine();
        s = "0" + s;

        int count = 0;
        for (int i = 0; i < s.Length - 1; i++)
        {
            if (s[i + 1] == '0')
            {
                continue;
            }

            int a = int.Parse(s.Substring(0, i + 1));
            int b = int.Parse(s.Substring(i + 1));

            if ((a + b) % 2 == 0 && b - a >= 0 && (b - a) % 2 == 0)
            {
               // Console.WriteLine("{0} + {1}", (a + b) / 2 , (b - a) / 2);
                count++;
            }
        }

        Console.WriteLine(count);
            
       // Console.ReadKey();

    }
}

Measured memory_bytes: 9160
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

const LINT MOD = 1000000007; //nより大きい素数であってくれ

class COMB{
private:
  LINT n;
  vector<LINT> fac;
  vector<LINT> finv;
  vector<LINT> inv;

public:
  COMB(LINT N)
  : fac(vector<LINT>(N+1, 1)), finv(vector<LINT>(N+1, 1)),
    inv(vector<LINT>(N+1, 1)), n(N)
  {
    COMB::init();
  }

  // テーブルを作る前処理
  void init() {
    for (int i = 2; i < n+1; i++){
        COMB::fac[i] = COMB::fac[i - 1] * i % MOD;
        COMB::inv[i] = MOD - COMB::inv[MOD%i] * (MOD / i) % MOD;
        COMB::finv[i] = COMB::finv[i - 1] * COMB::inv[i] % MOD;
    }
  }

  // 二項係数計算
  //1<= k <= n <=10^7くらいまで
  LINT com(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return COMB::fac[n] * (COMB::finv[k] * COMB::finv[n - k] % MOD) % MOD;
  }
};

int main(){
  LINT N, M;
  cin >> N >> M;
  map<int, int> mp;

  if(M==1 || N==1){
    cout << 1 << endl;
    return 0;
  }

  LINT M2 = M;
  for(int i = 2; i<1+sqrt(double(M)); ++i){
    while(M2%i==0){
      ++mp[i];
      M2 /= i;
    }
  }
  if(M2!=1) ++mp[M2];
  
  int r_max=0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    r_max = max(r_max, itr->second);
  }
  COMB CM(N+r_max-1);

  LINT ans = 1;
  LINT b;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    b = itr->second;
    ans = ans * CM.com(N+b-1, b) %MOD;
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 2560
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int n,l;
	int a[203];
	int sum = 0;
	scanf("%d%d",&n,&l);
	for (int i = 1; i <= n; ++i){
		a[i] = l + i - 1;
		sum += a[i];
	}
	for (int i = 1; i <= n; ++i)
	{
		if(a[i] == 0){
			printf("%d\n", sum);
			return 0;
		}
	}
	if(sum < 0){
		printf("%d\n", sum - a[n]);
	}
	else{
		printf("%d\n", sum - a[1]);
	}
	return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    char c[100][100];
    for (int i=0; i<H ;i++){
        for (int j=0; j<W; j++){
            cin >> c[i][j];
        }
    }
    
    for (int i=0; i<H; i++){
        for (int n=0; n<2; n++){
            for (int j=0; j<W; j++){
                cout << c[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-

# CODE FESTIVAL 2016 qual C
# Problem A

if __name__ == '__main__':
    import re
    s = input()
    
    # See:
    # https://beta.atcoder.jp/contests/code-festival-2016-qualc/submissions/942114
    if re.search('C.*F', s):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    vi a(N);
    in(N,a);
    
    int ans = 0;
    rep(i,N) if(i%2==0 && a[i]%2==1) ans++;
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3604