akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            int M = int.Parse(Console.ReadLine());
            
            Console.WriteLine(48 - M);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
K = []

for _ in range(M):
    a, _ = map(int, input().split())
    k = 0
    for i in map(int, input().split()):
        k |= (1 << (i - 1))
    K.append((a, k))

dp = [10**18] * (1 << N)
dp[0] = 0
for state in range(1 << N):
    for a, k in K:
        dp[state | k] = min(dp[state | k], dp[state] + a)

ans = dp[(1 << N) - 1]
print(ans if ans < 10**18 else -1)


Measured memory_bytes: 45144
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int H, W;
int h, w;

int main(int argc, const char * argv[]) {
    H = inputValue();
    W = inputValue();
    h = inputValue();
    w = inputValue();

    output(H * W - h * W - w * H + h * w);

    return 0;
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(100000)::s
    character(:),allocatable:: ts, bs
    character(1):: top(200000), bottom(200000)
    character(1),allocatable:: sar(:)
    character(5):: query_input
    integer(int32):: i,q,ti,bi
    logical:: flip, insert_top

    read*, s
    read*, q
    flip = .false.
    ti=1
    bi=1

    do i=1,q
        read'(a)', query_input
        if (query_input(1:1) == '1') then
            flip = .not. flip
            cycle
        end if

        insert_top = .false.
        if (query_input(3:3) == '1') insert_top = .true.
        if (flip .neqv. insert_top) then
            top(ti) = query_input(5:5)
            ti=ti+1
        else
            bottom(bi) = query_input(5:5)
            bi=bi+1
        end if
    end do
    ti=ti-1
    bi=bi-1
    allocate(character(ti):: ts)
    allocate(character(bi):: bs)

    if (.not. flip) then
        do i=1,ti
            ts(i:i) = top(ti+1-i)
        end do
        do i=1,bi
            bs(i:i) = bottom(i)
        end do
        print'(a)', ts // trim(s) // bs
    else
        allocate(sar(len_trim(s)))
        do i=1,len_trim(s)
            sar(i) = s(i:i)
        end do
        do i=1,len_trim(s)
            s(i:i) = sar(len_trim(s)+1-i)
        end do
        do i=1,ti
            ts(i:i) = top(i)
        end do
        do i=1,bi
            bs(i:i) = bottom(bi+1-i)
        end do
        print'(a)', bs // trim(s) // ts
    end if
end program name

Measured memory_bytes: 3364
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=list(input())
if len(s)==len(list(set(s))):
    print("yes")
else:
    print("no")

Measured memory_bytes: 77400
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
def g(x):
    if x%10==0:
        return 10
    else:
        return x%10
m=min(g(a),g(b),g(c),g(d),g(e))
def f(x):
    if x%10==0:
        return x
    else:
        return (x//10+1)*10
a=f(a)
b=f(b)
c=f(c)
d=f(d)
e=f(e)
print(a+b+c+d+e+m-10)


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

int main(void){
    string a, b, c;
    cin >> a >> b >> c;
    cout << (a[a.length()-1] == b[0] && b[b.length()-1] == c[0] ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
      	int M = sc.nextInt();
      	int A[] = new int[N];
      	int sum=0;
      	int count=0;
      
      	for(int i=0;i<N;i++){
        	A[i]=sc.nextInt();
        	sum=sum+A[i];
        }
      
      	for(int i=0;i<N;i++){
        	if(A[i]>=(double)sum/4/M){
            	count=count+1;
            }
        }
       	
		if(count>=M){
          System.out.println("Yes");
        }
      	else{
          System.out.println("No");
        }
		
	}
}

Measured memory_bytes: 21844
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int h, w;
    cin >> h >> w;
    //i->jの書き換え
    int c[10][10];
    rep(i, 10)
    {
        rep(j, 10)
        {
            cin >> c[i][j];
        }
    }
    int kabe[h][w];
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> kabe[i][j];
        }
    }

    //最短の書き換え
    //ベルマンフォード
    int d[10][10];
    rep(i, 10)
    {
        fill(d[i], d[i] + 10, INF);
        d[i][i] = 0;
        while (true)
        {
            bool update = false;
            rep(j, 10)
            {
                rep(k, 10)
                {
                    if (d[i][j] != INF && d[i][k] > d[i][j] + c[j][k])
                    {
                        d[i][k] = d[i][j] + c[j][k];
                        update = true;
                    }
                }
            }
            if (!update)
                break;
        }
    }

    int ans = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            if (kabe[i][j] == -1)
                continue;
            else
                ans += d[kabe[i][j]][1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int H, W, D;
string maps[100];
int dp[100][100];

int main() {
	cin >> H >> W >> D;
	REP(i, H) cin >> maps[i];
	
	REP(j, W) {
		dp[H - 1][j] = maps[H - 1][j] == '.';
		for (int i = H - 2; i >= 0; i--) {
			if (maps[i][j] == '#') dp[i][j] = 0;
			else dp[i][j] = dp[i + 1][j] + 1;
		}
	}
	
	int ans = 0;
	REP(i, H) REP(j, W) if (dp[i][j] >= D) ans++;
	
	memset(dp, 0, sizeof(dp));
	REP(i, H) {
		dp[i][W - 1] = maps[i][W - 1] == '.';
		for (int j = W - 2; j >= 0; j--) {
			if (maps[i][j] == '#') dp[i][j] = 0;
			else dp[i][j] = dp[i][j + 1] + 1;
		}
	}
	
	REP(i, H) REP(j, W) if (dp[i][j] >= D) ans++;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
void ade(int& x,int y){x+=y;if(x>=mod)x-=mod;}
int qpow(int x,int k)
{
	int r=1;
	while(k)
	{
		if(k&1)r=1ll*r*x%mod;
		k>>=1;x=1ll*x*x%mod;
	}
	return r;
}
int fac[2000200],ifac[2000200];
void init()
{
	int ma=2e6+10;fac[0]=1;
	for(int i=1;i<=ma;++i)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[ma]=qpow(fac[ma],mod-2);
	for(int i=ma-1;i>=0;--i)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
int C(int x,int y)
{
	if(x<y||x<0||y<0)return 0;
	return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int g(int n,int m)
{
	int res=add(C(n+m+2,m+1),mod-1);
//	if(res<0||res>=mod)cout<<"ahhh\n";
	return res;
}
int f(int x,int y,int X1,int Y1,int X2,int Y2)
{
	int sx=abs(X1-x),mx=abs(X2-x);if(sx>mx)swap(sx,mx);
	int sy=abs(Y1-y),my=abs(Y2-y);if(sy>my)swap(sy,my);
	int res=(0ll+g(mx,my)-g(sx-1,my)-g(mx,sy-1)+g(sx-1,sy-1)+mod+mod)%mod;
//	if(res<0)cout<<"sx: "<<sx<<" mx: "<<mx<<" sy: "<<sy<<" my: "<<my<<endl;
	return res;
}
int calc(int X1,int X2,int Y1,int Y2){return C(X2-X1+Y2-Y1,X2-X1);}
main()
{
	init();
	scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
	scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
	int p,q,u,v;
	/*
	int re=0;
	for(p=x3;p<=x4;++p)
		for(q=y3;q<=y4;++q)
			ade(re,1ll*f(p,q,x1,y1,x2,y2)*f(p,q,x5,y5,x6,y6)%mod);
	cout<<"re: "<<re<<endl;
	cout<<endl;
	*/
	int ans=0,ta;
//	cout<<"f: "<<f(x3,y3,x5,y5,x6,y6)<<endl;
	for(int i=x3;i<=x4;++i)
	{
		p=i,q=y4+1;
		ta=1ll*f(p,q-1,x1,y1,x2,y2)*f(p,q,x5,y5,x6,y6)%mod*(p+q)%mod;
//		cout<<"p: "<<p<<" q: "<<q<<" ta: "<<ta<<endl;
//		cout<<"f1: "<<f(p,q-1,x1,y1,x2,y2)<<" f2: "<<f(p,q,x5,y5,x6,y6)<<endl;
		ade(ans,ta);
	}
	for(int i=y3;i<=y4;++i)
	{
		p=x4+1,q=i;
		ta=1ll*f(p-1,q,x1,y1,x2,y2)*f(p,q,x5,y5,x6,y6)%mod*(p+q)%mod;
//		cout<<"p: "<<p<<" q: "<<q<<" ta: "<<ta<<endl;
//		cout<<"f1: "<<f(p-1,q,x1,y1,x2,y2)<<" f2: "<<f(p,q,x5,y5,x6,y6)<<endl;
		ade(ans,ta);
	}
//	cout<<endl;
	for(int i=x3;i<=x4;++i)
	{
		u=i,v=y3-1;
		ta=1ll*f(u,v,x1,y1,x2,y2)*f(u,v+1,x5,y5,x6,y6)%mod*(u+v+1)%mod;
//		cout<<"u: "<<u<<" v: "<<v<<" ta: "<<ta<<endl;
//		cout<<"f1: "<<f(u,v,x1,y1,x2,y2)<<" f2: "<<f(u,v+1,x5,y5,x6,y6)<<endl;
		ade(ans,mod-ta);
	}
	for(int i=y3;i<=y4;++i)
	{
		u=x3-1,v=i;
		ta=1ll*f(u,v,x1,y1,x2,y2)*f(u+1,v,x5,y5,x6,y6)%mod*(u+v+1)%mod;
//		cout<<"u: "<<u<<" v: "<<v<<" ta: "<<ta<<endl;
		ade(ans,mod-ta);
		/*
		if(ans>mod)
		{
		cout<<"f1: "<<f(u,v,x1,y1,x2,y2)<<" f2: "<<f(u,v,x5,y5,x6,y6)<<endl;
			cout<<"ans: "<<ans<<" mod-ta: "<<mod-ta<<" ta: "<<ta<<endl;
		}
		*/
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 16000
s_L = [int(val) for val in input()]
n = len(s_L)

if sum(s_L) == 0 or sum(s_L) == n:
    print(0)
    exit()
elif n == 1:
    print(0)
    exit()

one = s_L.count(1)
zero = s_L.count(0)
print(2*min(zero,one))

Measured memory_bytes: 44764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

int color(int n) {
  if(n >= 3200) return -1;
  return n / 400;
}

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0; i < n; i++) {
    int k; cin >> k;
    a.push_back(k);
  }
  set<int> normal; int special = 0;
  for(auto ai : a) {
    int c = color(ai);
    // cout << ai << " color: " << c << endl;
    if(c == -1) {
      special++;
    } else {
      normal.insert(color(ai));
    }
  }
  int q = normal.size();
  if(q < 1 && special) {
    q = 1;
  }
  cout << q << " " << normal.size() + special << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main extends App {
  val N = readInt().toDouble
  val ingredients = readLine().split(" ").map(_.toDouble)
  var buf = collection.mutable.ArrayBuffer(ingredients: _*).sortWith(_ < _)

  while (buf.nonEmpty) {
    if (buf.size == 1) {
      println(buf.head); sys.exit()
    }
    val acc = (buf(0) + buf(1)) / 2
    buf = buf.drop(2)
    buf = (buf :+ acc).sortWith(_ < _)
  }
}


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

const int MAXN = 100010;
const int mod = 1000000007;
void reduce(int & x) { x += x >> 31 & mod; }
char buf[MAXN];
int dp[MAXN];
int d[3];
int main() {
	std::cin >> buf + 1; int len = strlen(buf + 1);
	bool flg = true;
	int pre = 0;
	dp[0] = d[0] = 1;
	for (int i = 1; i <= len; ++i) {
		buf[i] = buf[i] == 'a' ? 1 : 2;
		if (i > 1) flg &= buf[i] != buf[i - 1];
		pre = (buf[i] + pre) % 3;
		reduce(dp[i] = dp[i - 1] + d[(6 - (buf[i] ^ 3) + pre) % 3] - mod);
		if (!pre) reduce(dp[i] += 1 - mod);
		d[pre] = dp[i];
	}
	int ans = dp[len];
	if (!pre) reduce(ans -= 1);
	if (flg) ans = 1;
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] dp = new int[n + 1];
        long res = 1000;
        for(int i = 1; i <= n; i++){
            dp[i] = sc.nextInt();
        }
        for(int i = 1; i < n; i++){
            if(dp[i] < dp[i + 1])
                res += res / dp[i] * (dp[i + 1] - dp[i]);
        }
        System.out.println(res);
    }
}

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

int main() {
  int N, A[110];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  for (int i = 1; i < N; i++) {
    int v = A[i], j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;

    for (j = 0; j < N; j++) {
      if (j) cout << " ";
      cout << A[j];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<math.h>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    
    int count = 1;
    
    for(int i = 1; i < N; i++){
        for(int j = 0; j < i; j++){
            if( vec.at(j) <= vec.at(i)){
                if(j == i -1){
                    count++;
                }
                continue;
            }
            else{
                break;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int R = 1010;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> s(R, vector<int>(R, 0));
    while (n--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        s[a][b]++;
        s[a][d]--;
        s[c][b]--;
        s[c][d]++;
    }
    
    for (int i = 0; i < R; i++) {
        for (int j = 0; j+1 < R; j++) {
            s[i][j+1] += s[i][j];
        }
    }
    for (int i = 0; i+1 < R; i++) {
        for (int j = 0; j < R; j++) {
            s[i+1][j] += s[i][j];
        }
    }
    
    int ans = 0;
    for (int i = 0; i < R; i++) {
        ans = max(ans, *max_element(s[i].begin(), s[i].end()));
    }

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


Measured memory_bytes: 6848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,ans = 0;cin >> n;
  vector<pair<int,int>> r(n),b(n);int rs=n;
  for(i=0;i<n;i++) cin >> r[i].second >> r[i].first;
  for(i=0;i<n;i++) cin >> b[i].first >> b[i].second;
  sort(r.begin(),r.end(),greater<pair<int,int>>());sort(b.begin(),b.end());//red y,x blue x,y
  for(i=0;i<n;i++){
    for(j=0;j<rs;j++){
      if(b[i].first > r[j].second && b[i].second > r[j].first){
        ans++;r.erase(r.begin()+j);rs--;break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 1
    field = K
    for i in range(N):
        if field >= N:
            break
        field += K-1
        cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 13880
ss = gets.chomp

cnt1=0
cnt2=0
l = ss.length
# 1はじまり
ex1 = "10" * (l/2) + "1" * (l%2)
# 0はじまり
ex2 = "01" * (l/2) + "0" * (l%2)

l.times do |i|
  cnt1+=1 unless ss[i] == ex1[i]
  cnt2+=1 unless ss[i] == ex2[i]
end

puts cnt1<cnt2 ? cnt1 : cnt2

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef pair<int, int> ii;
typedef long long int lli;

int main() {
    int N;
    cin >> N;
    vector<ii> to[100001];
    for (int i = 0; i < N-1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        to[a].push_back(ii(b, c));
        to[b].push_back(ii(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    lli far[100001];
    bool visited[100001] = {};
    queue<int> que;

    far[K] = 0;
    for (auto it = to[K].begin(); it != to[K].end(); ++it) {
        int v = it->first;
        int c = it->second;
        if (!visited[v]) {
            que.push(v);
            far[v] = c;
        }
    }
    visited[K] = true;

    while (!que.empty()) {
        int u = que.front(); que.pop();
        for (auto it = to[u].begin(); it != to[u].end(); ++it) {
            int v = it->first;
            int c = it->second;
            if (!visited[v]) {
                que.push(v);
                far[v] = far[u] + c;
            }
            visited[u] = true;
        }
    }

    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        cout << far[x] + far[y] << endl;
    }
}


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

const int maxN = 4005, mod = 1e9 + 7;

int n, x[maxN * 100 + 1], y[maxN * 100 + 1], fac[maxN * 2 + 1], inv[maxN * 2 + 1];
int f[maxN + 1][maxN + 1], ans;

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline int C(int n, int m)
{
	if(n < m) return 0;
	return 1ll * fac[n] * inv[n - m] % mod * inv[m] % mod;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i++) x[i] = read(), y[i] = read(), f[ 2000 - x[i] ][ 2000 - y[i] ] ++;

	fac[0] = 1;
	for(int i = 1; i <= 8000; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[8000] = mpow(fac[8000], mod - 2);
	for(int i = 8000 - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
		
	for(int i = 0; i <= 4000; i++)
		for(int j = 0; j <= 4000; j++)
		{
			if(i) f[i][j] = ADD(f[i][j], f[i - 1][j]);
			if(j) f[i][j] = ADD(f[i][j], f[i][j - 1]);
		} 

	for(int i = 1; i <= n; i++) 
		ans = SUB(ADD(ans, f[ 2000 + x[i] ][ 2000 + y[i] ]), C(2 * x[i] + 2 * y[i], 2 * x[i]));

	ans = 1ll * ans * mpow(2, mod - 2) % mod;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 65792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 5000
using namespace std;
typedef long long ll;

int main(){
  string n;  cin >> n;
  int digitSum = 0;
  REP(i, n.length()){
    digitSum += n[i]-'0';
  }
  if(stoi(n)%digitSum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) (int)(x).size()
using namespace std;

const int N = 107;

int h, w, n;

int a[N*N];

int res[N][N];

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> h >> w >> n;

	int ch = 1, cw = 1;

	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];

		while(a[i]--)
		{
			res[ch][cw] = i;

			if(cw==w)
			{
				++ch;
				cw = 1;
			}
			else
				++cw;
		}
	}

	for(int i = 2; i <= h; i += 2)
		reverse(res[i]+1, res[i]+w+1);

	for(int i = 1; i <= h; ++i)
	{
		for(int j = 1; j <= w; ++j)
		{
			cout << res[i][j] << " ";
		}

		cout << endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

const int max = 1000005;

std::string text;
int textSize, k = 1;
int rank[max + 1], tmp[max + 1], sa[max + 1];

bool compare_sa(int i, int j){
	if (rank[i] != rank[j])return rank[i] < rank[j];
	else {
		int ri = (i + k <= textSize ? rank[i + k] : -1);
		int rj = (j + k <= textSize ? rank[j + k] : -1);
		return ri < rj;
	}
}

void construct_sa(){
	textSize = text.size();
	rep(i, textSize + 1){
		sa[i] = i;
		rank[i] = (i < textSize ? text[i] : -1);
	}

	for (; k <= textSize; k *= 2){
		std::sort(sa, sa + textSize + 1, compare_sa);

		tmp[sa[0]] = 0;
		REP(j, 1, textSize + 1)tmp[sa[j]] = tmp[sa[j - 1]] + (compare_sa(sa[j - 1], sa[j]) ? 1 : 0);
		rep(j, textSize + 1)rank[j] = tmp[j];
	}
}

bool find(std::string t){
	int l = 0, r = text.size();
	while (l <= r){
		int m = (l + r) / 2;
		if (text.compare(sa[m], t.size(), t) < 0)l = m + 1;
		else r = m - 1;
	}
	return (text.compare(sa[r + 1], t.size(), t) == 0);
}

int n;

int main(){
	std::cin >> text >> n;
	construct_sa();
	rep(i, n){
		std::string str;
		std::cin >> str;
		std::cout << (find(str) ? 1 : 0) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 13928
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
 
signed main(){

    int n;
    cin >> n;
    int a[60] = {0};
    rep(i,n)cin >> a[i];
    int maxi = 0;
    int flag = -1;
    rep(i,n){
        if(maxi < abs(a[i])){
            maxi = abs(a[i]);
            flag = i;
        }
    }
    if(flag == -1){
        cout << 0 << endl;
        return 0;
    }

    vector<pair<int,int>> ans;
    if(a[flag] < 0){
        for(int i = n-2;i >= 0;i--){
            if(a[i] > a[i+1]){
                ans.pb(MP(flag,i));
                a[i] += a[flag];
                if(a[i] < a[flag])flag = i;
            }
            if(a[i] > a[i+1]){
                ans.pb(MP(flag,i));
                a[i] += a[flag];
                if(a[i] < a[flag])flag = i;
            }
        }
    }else{
        for(int i = 1;i <= n-1;i++){
            if(a[i-1] > a[i]){
                ans.pb(MP(flag,i));
                a[i] += a[flag];
                if(a[i] > a[flag])flag = i;
            }
            if(a[i-1] > a[i]){
                ans.pb(MP(flag,i));
                a[i] += a[flag];
                if(a[i] > a[flag])flag = i;
            }
        }
    }

    cout << ans.size() << endl;
    for(auto x:ans){
        cout << x.fi+1 << " " << x.se+1 << endl;
    }

  	rep(i,n)cerr << a[i] << endl;


    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc081.contest.atcoder.jp/tasks/arc086_b
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 384
mod=10**9+7
n=int(raw_input())
l=len(raw_input())
dp=[[0]*(n+2) for j in range(n+1)]
for i in range(n+1):
    for j in range(i+1):
        if i==0:dp[i][j]=1
        elif j==0:dp[i][j]=(dp[i-1][1]*2+dp[i-1][0])%mod
        else:dp[i][j]=(dp[i-1][j-1]+dp[i-1][j+1]*2)%mod
print dp[n][l]

Measured memory_bytes: 214172
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = -1; ll z = 0, o = 1;
vl flag, color, D; vll path; ll pre = 0;
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	ll count = 1;
	ll type = 1;
	ll pre = 0;
	for (i = 0; i < N-1; i++) {
		if (A[i] == A[i + 1]) count++;
		else {
			pre += count - 1;
			count = 1;
			type++;
		}
	}
	if (type % 2 == 1) cout << type;
	else cout << type - 1;
}

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

using namespace std;

int aa[101][101];

int cul[2];

int dl[] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int dc[] = {0, 1, 2, 0, 1, 2, 0, 1, 2};
int cc[] = {1, 1, 1, 1, 0, 1, 1, 1, 1};

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

    int n = 100;

    int a, b;
    cin >> a >> b;

    if(a > b)
    {
        swap(a, b);
        cul[0] = 1;
        cul[1] = 0;
    }

    else
    {
        cul[0] = 0;
        cul[1] = 1;
    }

    a --;

    int diff = b - a;
    int i, j;
    int last = 0;
    for(i = 1; i <= n; i += 2)
    {
        for(j = 1; j <= n && diff > 0; j += 2, diff --)
            aa[i][j] = 1, last = i;
    }



    b = a;

    int h;
    for(i = last + 2; i + 2 <= n; i += 4)
    {
        for(j = 1; j + 2 <= n && a > 0; j += 4)
        {
            for(h = 0; h < 9; h ++)
            {
                aa[i + dl[h]][j + dc[h]] = cc[h];
            }

            a --;
        }
    }

    cout << 100 << " " << 100 << "\n";
    for(i = 1; i <= 100; i ++)
    {
        for(j = 1; j <= 100; j ++)
        {
            aa[i][j] = cul[aa[i][j]];

            if(aa[i][j] == 0)
                cout << '.';

            else
                cout << '#';
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  int ans=0;

  for(int i=a;i<=b;i++){
    string s=to_string(i);
    auto copy=s;
    reverse(all(copy));
    if(s==copy) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
p_q_r=gets.chomp.split(" ").map{|a| a.to_i}
index_length=p_q_r.length-1
min=nil
for i in 0..index_length-1
  for j in i+1..index_length
    min=p_q_r[i]+p_q_r[j] if min==nil || p_q_r[i]+p_q_r[j]<min
  end
end
puts min

Measured memory_bytes: 3836
#include<iostream>
#include<stack>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for(int i=0; cin>>ch; i++) {
        if(ch == '\\') {
            S1.push(i);
        } else if(ch =='/' && S1.size() > 0) {
            int j = S1.top();
            S1.pop();
            int a = i - j;
            sum += a;
            while(S2.size() > 0 && j < S2.top().first) {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }

    vector<int> ans;
    while(S2.size() > 0) {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0; i<ans.size(); i++)cout<<' '<<ans[i];
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3196
#include <iostream>

int gcd(int x, int y);
int gcd3(int x, int y, int z);

int main(){
  int K;
  std::cin >> K;

  long int sum = 0;

  for(int a=1; a<K+1; a++){
    for(int b=1; b<K+1; b++){
      for(int c=1; c<K+1; c++){
        sum += gcd3(a, b, c);
      }
    }
  }

  std::cout << sum << std::endl;
  return 0;
}

int gcd(int x, int y){
  if(x>y){
    if(x%y == 0){
      return y;
    }else{
      return gcd(y, x%y);
    }
  }
  else{
    if(y%x == 0){
      return x;
    }else{
      return gcd(x, y%x);
    }
  }
}

int gcd3(int a, int b, int c){
  return gcd(gcd(a,b),c);
}



Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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

ll k(ll n) {
	if (n == 0) { return 0; }
	return k(n / 10) + 1;
}


int main() {

	ll N;
	cin >> N;

	ll M = sqrt(N);

	ll ans = k(N);

	repn(i, M) {
		if (N%i == 0) { ans = min(ans, max(k(i), k(N / i))); }
	}

	cout << ans;
	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <stdio.h>

int main(void){
int N ;
scanf("%d",&N);
int k = N/7;
for(int i = 0; i <=k ; i++){
        if((N-(i*7))%4==0){
                printf("Yes\n");
                return 0;
        }
}
printf("No\n");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
#define M 1000000009
#define pi 3.14159265358979323846264338327950
typedef pair<int,int> pr;
#define N 1000002
signed main()
{
    SPEED;
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    if(h1<=h2)
    {
        int hour=(h2-h1)*60,p=0;
        hour-=m1;
        hour+=m2;
        cout<<max(p,hour-k);
    }
    else
    {
        int hour=(h2+24-h1)*60,p=0;
        hour-=m1;
        hour+=m2;
        cout<<max(p,hour-k);
    }
}

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

string s;
long long a,b,c,p,mod;

int main(){
    cin >> s;
    a=b=c=0LL;
    p=1LL;
    mod = 1000000007LL;
    for(int i=0;i<s.length();i++){
        if(s[i]=='?'){
        c = 3LL*c+b;
        b = 3LL*b+a;
        a = 3LL*a+p;
        p *= 3LL;
        }
        else if(s[i]=='A'){
            a+=p;
        }
        else if(s[i]=='B'){
            b+=a;
        }else if(s[i]=='C'){
            c+=b;
        }
        a%=mod;
        b%=mod;
        c%=mod;
        p%=mod;
    }
    cout << c << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define BAGGAGE_MAX_NUM 100000
#define BAGGAGE_MAX_WEIGHT 10000
typedef long long llong;
int n, k;
llong BagWList[BAGGAGE_MAX_NUM];


int pSizeCheck(llong p){
	int countBag = 0;
	for (int i=0;i<k;i++){
		llong MtBag = 0;
		while(MtBag + BagWList[countBag] <= p){
			MtBag += BagWList[countBag];
			countBag++;
			if(countBag == n){
				return n; //領域外を見ないように．
			}
		}
	}
	return countBag;
}

int pSearch(){
	llong left = 0;
	llong right = BAGGAGE_MAX_NUM * BAGGAGE_MAX_WEIGHT;
	llong mid;
	while(left+1<right){
		mid = (left+right)/2;
		int check = pSizeCheck(mid);
		//nかそれより小さい値しか返ってこないため
		if(check == n){
			right = mid;
		}else{
			left = mid;
		}
	}
	return right;
}

int main(){
	scanf("%d%d",&n, &k);
	for(int i=0;i<n;i++){
		scanf("%llu",&BagWList[i]);
	}
	
	llong pResult = pSearch();
	printf("%llu\n",pResult);
	
	
	return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  sort(d.begin(), d.end());
  
  int count=1;
  int tmp=d.at(0);
  for(int i=1;i<N;i++){
    if(tmp<d.at(i)){
      count++;
    }
    tmp = d.at(i);
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in();
    vec a(n);
    int s=0;
    rep(i,n){
        a[i]=in();
        s=s xor a[i];
    }
    REP(e,a)cout<<(s xor e)<<" ";
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using ll = long long;
const ll INF = (ll)1e18L;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vvi = std::vector<vi>;
#define isz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
template<class X, class Y>
X& remax(X& x, Y y) { return x = (y > x ? y : x); }
int main() {
    int n; std::cin >> n;
    vvi a(n, vi(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            std::cin >> a[i][j];
        }
    }
    vl cost(1 << n), dp(1 << n, -INF);
    for (int mask = 1; mask < (1 << n); mask++) {
        int low = 0;
        while (!(mask & (1 << low))) low++;
        cost[mask] = cost[mask ^ (1 << low)];
        for (int bit = 0; bit < n; bit++) {
            if (mask & (1 << bit)) {
                cost[mask] += a[low][bit];
            }
        }
    }
    vi stack;
    dp[0] = 0;
    for (int sub = 0; sub < (1 << n); sub++) {
        stack.clear();
        for (int i = 0; i < n; i++) {
            if (!(sub & (1 << i))) {
                stack.push_back(i);
            }
        }
        int group = 0;
        while (true) {
            bool was = false;
            for (int i = 0; i < isz(stack); i++) {
                const int bit = stack[i];
                if (group & (1 << bit)) {
                    group ^= (1 << bit);
                } else {
                    group ^= (1 << bit);
                    was = true;
                    break;
                }
            }
            if (!was) {
                break;
            }
            assert((sub & group) == 0);
            remax(dp[sub ^ group], dp[sub] + cost[group]);
        }
    }
    std::cout << dp[(1 << n) - 1] << std::endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;

int main()
{
	char a[1000000];
	scanf("%s", a+1);
	for (int j = 2; a[j] != '\0'; j++)
	{
		if (a[j] == a[j - 1]) {
			printf("%d %d", j - 1, j);
			return 0;

		}
		if (a[j] == a[j - 2])
		{
			printf("%d %d", j - 2, j);
			return 0;
		}
	}
	printf("-1 -1");
}


Measured memory_bytes: 384
import java.util.Scanner;


class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		for(int i=0;i<s.length()-1;i++){
			if(s.substring(i,i+2).equals("AC")){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int l,r,d;
	 cin>>l>>r>>d;
	 int ans=0;
	 for(int i=l;i<=r;i++)
	 {
		 if(i%d==0)
		 ans++;
	 }
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    ll t, a[100010];
    cin >> n >> t;
    rep(i, n) cin >> a[i];

    ll curMin = LLINF, curMax = 0;
    vector<ll> v;
    rep(i, n) {
        if (a[i] < curMax) {
            if (curMax > curMin) v.push_back(curMax - curMin);
            curMax = 0;
        }
        if (a[i] < curMin) curMin = a[i];
        if (a[i] > curMax) curMax = a[i];
        // printf("curMax: %lld  curMin: %lld\n", curMax, curMin);
    }
    if (curMax > curMin) v.push_back(curMax - curMin);

    ll ans = 0;
    sort(v.begin(), v.end(), greater<ll>());
    for (auto x: v) {
        if (x == v[0]) ans++;
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1660
import heapq as h;I=lambda:list(map(int,input().split()));n,k=I();z=[i*2+1for i in range(n)];q=[];v=i=T=A=0;l=[0]*-~n
for a,b in sorted([I()for _ in[0]*n],key=lambda x:-x[1]):
 if i<k:
  if l[a]:h.heappush(q,b)
  else:T+=z[v];v+=1
  l[a]=1;T+=b
 elif l[a]^1and q:l[a]=1;T+=b+z[v]-h.heappop(q);v+=1
 A=max(A,T);i+=1
print(A)

Measured memory_bytes: 37736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	ll n; cin >> n;
	vector<ll> a(n);	
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	const ll p = 1000005LL;
	vector<ll> num(p, 0);	
	for (ll i = 0; i < n; i++) {
		ll now = a[i];
		if (num[now] != 0) {
			num[now] = 2;
			continue;
		}
		for (ll j = now; j < p; j += now) {
			num[j]++;
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (num[a[i]] == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12640
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int n = readln().chomp().to!int;
    for(int j=0;j<n;j++){
	int s = readln().chomp().to!int;
	writef("Case %d:\n",j+1);
	for(int i=0;i<10;i++){
	    string a = to!string(s*s);
	    int size = to!int(a.length);
	    for(int k=0;k<8-size;k++){
		a = '0' ~ a;
	    }
	    if(size==9) a = a[3..$-2];
	    else a = a[2..$-2];
	    int c;
	    if(a == "0000"){
		writeln('0');
		s = 0;
		continue;
	    }
	    while(a[c]=='0'){
	       	c++;
	    }
	    s = to!int(a[c..$]);
	    writeln(s);
	}
    }

}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    else if(s=="Rainy")
        cout<<"Sunny"<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: u64 = read_line().trim().parse().unwrap();
    let mut a: u64 = n-1;
    for i in (2..1_000_001u64).rev() {
        if n % i == 0 {
            a = cmp::min(a, (i-1) + (n/i - 1));
        }
    }
    println!("{}", a);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
    long long min,max,sum,con,i,x;
    scanf("%lld %lld",&con,&min);
    max=min;
    sum=min;
    i=1;
    while(i < con){
        scanf("%lld",&x);
        if(x<min){
            min = x;
        }
        else if(x>max){
            max = x;
        }
        sum = sum + x;
        i++;
    }
    printf("%lld %lld %lld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 600
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, A;
    scan(H, A);
    writeln((H + A - 1) / A);
}


Measured memory_bytes: 256
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
a = A[0]
for i in range(N - 1):
#    a = A[i]
    b = A[i + 1]
    plus = a % b
    while plus != 0:
        a = b
        b = plus
        plus = a % b
    a = b
print(a)


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

#define INF 10e+12

int main()
{
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long int> s(A), t(B), x(Q);
    for (int i = 0; i < A; ++i)
        cin >> s[i];
    for (int i = 0; i < B; ++i)
        cin >> t[i];
    for (int i = 0; i < Q; ++i)
        cin >> x[i];
    s.push_back(INF);
    s.push_back(-INF);
    t.push_back(INF);
    t.push_back(-INF);
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for (int i = 0; i < Q; ++i)
    {
        ll sl = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        ll tl = lower_bound(t.begin(), t.end(), x[i]) - t.begin();
        ll ans = INF, dis;
        for (ll j = sl - 1; j < sl + 1; ++j)
        {
            for (ll k = tl - 1; k < tl + 1; ++k)
            {
                dis = min(abs(x[i] - s[j]), abs(x[i] - t[k])) + abs(s[j] - t[k]);
                ans = min(ans, dis);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3680
M=10**9+7;F=lambda X:pow(X,M-2,M);H,W,A,B=map(int,input().split());Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*F(I+1)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*F(I*(W+H-B-1-I))%M;Z=(Z+C)%M
print(Z)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a,b,k,t;
    string s;
    cin>>n>>s;
    string abc="ABC";
    ll count=0;
    for(i=0;i<s.size()-3+1;i++)
    {
        string temp=s.substr(i,3);
        if(temp==abc) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int a = sumDigits(n);
		if (n % a == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static int sumDigits(int n) {
		int sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}
}


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


int IsPalindrome(char *Str, int N)
{
	for (int s = 0; s < N; s++)
		if (Str[s] != Str[N - 1 - s])
			return 0;
	return 1;
}

int main()
{
	char Str[128];
	#ifdef _WIN32
		freopen("input.txt", "r", stdin);
	#endif
	scanf("%s", Str);

	int Result = 1;
	Result *= IsPalindrome(Str, strlen(Str));
	Result *= IsPalindrome(Str, strlen(Str) / 2);
	Result *= IsPalindrome(&Str[strlen(Str) / 2 + 1], strlen(Str) / 2);
	
	if (Result)
		printf("Yes");
	else
		printf("No");

	return 0;
}

Measured memory_bytes: 128