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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m, lm = -1, rm = INF;
    cin >> n >> m;
    vector<int> l(m), r(m);

    rep(i, 0, m)
    {
        cin >> l[i] >> r[i];
        chmax(lm, l[i]);
        chmin(rm, r[i]);
    }

    if (lm <= rm)
    {
        cout << rm - lm + 1 << '\n';
    }
    else
    {
        cout << 0 << '\n';
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

  static final String[] ponNum = new String[]{"0", "1", "6", "8"};
  static final String[] bonNum = new String[]{"3"};

  public static void main(String[] args) {
    /**
     * N 2,4,5,7,9
     * N 0,1,6,8
     * N 3
     */        
    Scanner sc = new Scanner(System.in);
    String str;
    str = sc.nextLine();
    String N = str;
    String lastNum = N.substring(N.length() - 1, N.length());
    if (Arrays.asList(ponNum).contains(lastNum)) {
      System.out.println("pon");
    } else if (Arrays.asList(bonNum).contains(lastNum)) {
      System.out.println("bon");
    } else {
      System.out.println("hon");
    }
  }
}

Measured memory_bytes: 35764
n,k= map(int,input().split())
p= list(map(int,input().split()))
sp=[0]*(n-(k-1))
sp[0]=sum(p[0:k])
for i in range(1,n-(k-1)):sp[i]=sp[i-1]+p[i+k-1]-p[i-1]
print((max(sp)+k)/2)

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

typedef pair<int, int> P;
#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long

ll gcd(ll a, ll b){
    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);

    cout << a*b/n << endl;

    

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    mod = 1000000007
    nmax = 10 ** 5 + 1  # change here
    fac = [0] * (nmax + 1)
    finv = [0] * (nmax + 1)
    inv = [0] * (nmax + 1)
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    ans = 0
    for i in range(-1, -N-1, -1):
        ans = (ans + (A[i] * comb(N+i, K-1))%mod)%mod
    for i in range(N):
        ans = (ans - (A[i] * comb(N-1-i, K-1))%mod)%mod
    print(ans)


if __name__ == '__main__':
    main()


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    if (n % 2 == 0) {
        Int k = n / 2;
        print(k * (k - 1) / 2 * 4);
        for (Int i = 1; i <= n; i++) {
            for (Int j = i + 1; j <= n; j++) {
                if (j == n + 1 - i) continue;
                print(i, j);
            }
        }
    } else {
        Int k = n / 2;
        print(4 * k * (k - 1) / 2 + n - 1);
        for (Int i = 1; i <= n - 1; i++) {
            for (Int j = i + 1; j <= n - 1; j++) {
                if (j == n - i) continue;
                print(i, j);
            }
        }
        for (Int i = 1; i <= n - 1; i++) {
            print(i, n);
        }
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
int main()
{
    int k,s,ans=0;
    std::cin>>k>>s;
    for(int x=0;x<=k;x++)
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z<=k&&z>=0) ans++;
        }
    std::cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
P s[101];
int r[100];
int main(){
	int n;
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++)s[i]=P(0,i);
	for(i=0;i<n*(n-1)/2;i++){
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		a--;b--;
		if(c>d)s[a].first+=3;
		if(c<d)s[b].first+=3;
		if(c==d){
			s[a].first+=1;
			s[b].first+=1;
		}
	}
	s[n]=P(-1,-1);
	sort(s,s+n);
	reverse(s,s+n);
	int p=0;
	int pr=0;
	while(p<n){
		r[s[p].second]=pr;
		while(s[p].first==s[p+1].first){
			p++;
			r[s[p].second]=pr;
		}
		p++;
		pr=p;
	}
	for(i=0;i<n;i++)printf("%d\n",r[i]+1);
	return 0;
}

Measured memory_bytes: 1032
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10 ** 10
dp = [INF] * N

dp[0] = 0

for i in range(1, N):
    for j in range(min(K, i) + 1):
        dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j]))

print(dp[N-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	const int MAXN = 4e3;
	int n, p[MAXN + 1][3];
	string s;
	cin >> n >> s;
	memset(p[0], 0, sizeof p[0]);
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < 3; ++j)
			p[i + 1][j] = p[i][j];
		if(s[i] == 'R') 
			++p[i + 1][0];
		else if(s[i] == 'G') 
			++p[i + 1][1];
		else 
			++p[i + 1][2]; 
	}
	long long pairs = 0;
	for(int k = 0; k < n; ++k) {
		for(int i = k + 1; i < n; ++i) {
			if(s[k] != s[i]) {
				int cnt = 0;
				if('R' != s[k] && 'R' != s[i]) {
					cnt = p[i + 1][0] - p[k][0];
					if((k + i) % 2 == 0 && s[(k + i) / 2] == 'R') 
						--cnt;
				}
				else if('G' != s[k] && 'G' != s[i]) {
					cnt = p[i + 1][1] - p[k][1];
					if((k + i) % 2 == 0 && s[(k + i) / 2] == 'G') 
						--cnt;
				}
				else {
					cnt = p[i + 1][2] - p[k][2];
					if((k + i) % 2 == 0 && s[(k + i) / 2] == 'B') 
						--cnt;
				}
				pairs += cnt;
			}
		}
	}
	cout << pairs << '\n';
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<vector>
#include <tuple>
#include<cstring>
#include<algorithm>

using namespace std;

short map[10001];
short state_before[10001];
short map_before[10001];

std::vector< tuple< int,int,int> > points;



void read_points(int tate){
    memcpy(map_before,map,sizeof map);
    memset(map,0,sizeof(map));    
    for(int i=0;i<points.size();i++){
        auto tmp=points.at(i);
        if(get<0>(tmp)==tate){
            map[get<1>(tmp)]+=get<2>(tmp);
            //printf("%d,%d,%d\n",get<0>(tmp),get<1>(tmp),get<2>(tmp));
        }
    }
}
int main(){
    
    int n,r;
    
    int S=0;
    int L=0;

  
    while(1){
        cin>>n>>r;
        if(n==0&&r==0)break;
        
        points.clear();
        int x1,y1,x2,y2;
        int max_x=0,min_x=10000,max_y=0,min_y=10000;
        for(int i=0;i<n;i++){
            cin>>x1>>y1>>x2>>y2;
            tuple<int,int,int> tl=make_tuple(y1,x1,1);
            tuple<int,int,int> tr=make_tuple(y1,x2,-1);
            tuple<int,int,int> bl=make_tuple(y2,x1,-1);
            tuple<int,int,int> br=make_tuple(y2,x2,1);
            points.push_back(tl);
            points.push_back(tr);
            points.push_back(bl);
            points.push_back(br);
            if(max_x<x2)max_x=x2;
            if(max_y<y2)max_y=y2;
            if(min_x>x1)min_x=x1;
            if(min_y>y1)min_y=y1;
            
        }
        
        
        S=0;
        L=0;
        for(int h=min_y;h<=max_y;h++){
            
            read_points(h);
            int yoko_state=0;
            for(int w=min_x;w<=max_x;w++){
                
                
                yoko_state+=map[w];
                map[w]=yoko_state;
                if(h!=0){
                    map[w]+=state_before[w];
                }
                state_before[w]=map[w];
                //printf("%2d ",map[w]);
                if(map[w]>0){
                   S++;
                   if(w==0)L+=2;
                   else if(map[w-1]==0)L+=2;
                   if(h==0)L+=2;
                   else if(map_before[w]==0)L+=2;
                }
                
                
            }
            //cout<<endl;
            
        }


        cout<<S<<endl;
        if(r==2){
            cout<<L<<endl;
        }
        
        

    }

    

}

Measured memory_bytes: 2088
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toInt)
    val mod = 1000000007L

    var ans = 1L
    val hat = IntArray(n + 1) { 0 }
    for (a in aList) {
        ans *= ((hat.getOrNull(a - 1) ?: 3) - hat[a])
        ans %= mod
        hat[a]++
    }
    println(ans)
}


Measured memory_bytes: 51696
import math
n, m = map(int, input().split())
diff = abs(n - m)

# 階乗は、factorial

if (diff > 1):
    print(0)
else:
    x = math.factorial(n)
    y = math.factorial(m)

    if (n == m):
        tt = 2
    else:
        tt = 1

    ans = tt * (x * y) % (10 ** 9 + 7)

    print(ans)


Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
typedef long long int LL;
const int MAX = 105;
const int INF = 1e9;

int main() {
	LL n, k;
	cin >> n >> k;
	LL ar[n], sum[n + 1], s[n + 1];
	memset(sum, 0, sizeof sum);
	memset(s, 0, sizeof s);
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		sum[i + 1] = (sum[i] + ar[i]) % k;
		s[i + 1] = (sum[i + 1] - ((i + 1) % k)  + k) % k; 
	}

	map<LL, LL> mp;
	LL ans = 0;
	for (int i = 0; i <= n; i++) {
		if (i - k >= 0)
			mp[s[i - k]]--;
		ans += mp[s[i]];
		mp[s[i]]++;
	}
	cout << ans << endl;
}

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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
     ll n;
     cin>>n;
     ll arr[n];
     ll sum=0;
     for(int i=0;i<n;i++)
     {
         cin>>arr[i];
         sum+=arr[i];
     }
     ll mn=sum/n;
     ll minn=1e12;
     ll tmp=0;
     //cout<<mn<<"\n";
     for(int i=0;i<n;i++)
     {
         ll a=abst(mn-arr[i]);
         tmp+=a*a;
     }
     if(tmp<minn)
      minn=tmp;
      mn++;
      tmp=0;
      for(int i=0;i<n;i++)
     {
         ll a=abst(mn-arr[i]);
         tmp+=a*a;
     }
     if(tmp<minn)
      minn=tmp;
      cout<<minn<<"\n";
      return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5+5;
int a[maxn],t[maxn]={0},n,c,res=0;
int main()
{
	scanf("%d %d",&n,&c);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n);
	int j=0;
	while(c>0&&j<n)
	{
		if(c>=a[j]&&j==n-1)t[j]=c,c=0;
		else if(c>=a[j])t[j]=a[j],c-=a[j];
		else break;
		j++;
	}
	for(int i=0;i<n;i++)if(t[i]==a[i])res++;
//	printf("%d\n",c);
	printf("%d",res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

vii v;
int ans, n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    v.resize(3);
    rep(i, 0, 3) cin >> v[i];
    int ma = *max_element(ALL(v));
    rep(i, 0, 3) {
      if (v[i] != ma) {
        ans += (ma - v[i]) / 2;
        if ((ma - v[i]) / 2 > 0) 
          v[i] = v[i] + ((ma - v[i]) / 2) * 2;
      }
    }
    int cnt = 0;
    rep(i, 0, 3) {
      if (v[i] < ma) cnt++;
    }
    if (cnt == 1) ans += 2;
    else if (cnt == 2) ans++;
    cout << ans << endl; 
    return 0;
}



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

int main(){
  int n,i,j,sum1=0,sum2=0;
  cin >> n;
  for(i=1; i<=n; i++){
    if(i%2 == 1){
    	for(j=1;j<=i;j++){
          if(i%j==0)sum1++;
        }
        if(sum1 == 8)sum2++;
        sum1 = 0;
    }
  }
  cout << sum2 << endl;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i=0; i<M; i++){
    cin >> X.at(i);
  }
  sort(X.begin(),X.end());
  
  vector<int> L(M-1);
  for(int i=0; i<M-1; i++){
    L.at(i)=X.at(i+1)-X.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  
  if(N>=M){
    cout << 0 << endl;
  }
  else{
    int dame=0,sum=X.at(M-1)-X.at(0);
    for(int i=0; i<N-1; i++){
      dame+=L.at(i);
    }
    cout << sum-dame << endl;
  }
}

Measured memory_bytes: 1024
#include <stdio.h>

typedef unsigned char uchar;

#define HASHSIZ 543217
typedef struct { unsigned s; char x, v; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(unsigned s, int x)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return 0;
}

void insert(unsigned s, int x, char v)
{
	long long t = ((long long)x << 32) + s;
	HASH *hp = hash + (int)(t % HASHSIZ);
	while (hp->s) {
		if (hp->s == s && hp->x == x) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->x = x, hp->v = v;
}

#define QMAX 50000
typedef struct { unsigned s; char x, v; } T;
T s[QMAX+3]; int top, end;
int hi[9] = {2,3,2,3,4,3,2,3,2};
int to[9][4] = {{1,3},{0,2,4},{1,5},{0,4,6},{1,3,5,7},{2,4,8},{3,7},{4,6,8},{5,7}};

void toArray(char *nine, unsigned s, int x)
{
	int i;
	
	for (i = 8; i >= 0; i--) {
		if (i == x) nine[i] = 0;
		else nine[i] = s & 0xf, s >>= 4;
	}
}

unsigned swap(char *nine, int zero, int nx)
{
	int i;
	unsigned res;
	
	res = 0;
	for (i = 0; i < 9; i++) {
		if      (i == zero) res <<= 4, res |= nine[nx];
		else if (i != nx)   res <<= 4, res |= nine[i];
	}
	return res;
}

#define MAGIC 20

int main()
{
	int i, x, nx, v, nv, t;
	unsigned a, na;
	unsigned gs; int gx;	// goal
	char nine[9];
	
	gs = 0; for (i = 0; i < 9; i++) {
		scanf("%d", &t);
		if (t == 0) gx = i;
		else gs <<= 4, gs |= t;
	}
	s[0].s = 0x12345678, s[0].x = 8;
	s[1].x = -1;
	top = 0, end = 2;
	insert(s[0].s, s[0].x, 0);
	v = 0;
	while (top != end) {
		a = s[top].s, x = s[top].x;
		if (++top == QMAX) top = 0; 
		if (x < 0) {
			if (v == MAGIC) break;
			v++;
			s[end].x = -1; if (++end == QMAX) end = 0;
			continue;
		}
		if (x == gx && a == gs) goto done;
		if (lookup(a, x) < v) continue;

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx;
				if (++end == QMAX) end = 0;
				insert(na, nx, nv);
			}
		}
	}

	s[0].s = gs, s[0].x = gx, s[1].x = -1;
	top = 0, end = 2;
	v = 0;
	while (top != end) {
		a = s[top].s, x = s[top].x;
		if (++top == QMAX) top = 0; 
		if (x < 0) {
			v++;
			s[end].x = -1; if (++end == QMAX) end = 0;
			continue;
		}
		if ((t = lookup(a, x)) > 0) { v += t; break; }

		toArray(nine, a, x);
		for (i = 0; i < hi[x]; i++) {
			nx = to[x][i];
			na = swap(nine, x, nx), nv = v+1;
			t = lookup(na, nx);
			if (!t || nv < t) {
				s[end].s = na, s[end].x = nx;
				if (++end == QMAX) end = 0;
			}
		}
	}
done:
	printf("%d\n", v);
	return 0;
}




Measured memory_bytes: 6436
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int k,x;
  cin >> k >> x;
  int l = x-k+1, r = x+k-1;
  for(int i=l;i<=r;++i){
    printf("%d ",i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main (){
    int n;
    scanf("%d",&n);
    if(n<105) printf("0");
    else if(n<135) printf("1");
    else if(n<165) printf("2");
    else if(n<189) printf("3");
    else if(n<195) printf("4");
    else printf("5");
}

Measured memory_bytes: 128
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i )
#define rep (i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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; }



int main() {
	string s;;
	cin >> s;
	if ("ABC" == s) cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


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

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

	if (((a == 'H') && (b == 'H')) || ((a == 'D') && (b == 'D'))) {
		cout << 'H' << endl;
	} else if(((a == 'H') && (b == 'D')) || ((a == 'D') && (b == 'H'))) {
		cout << 'D' << endl;
	}

	return 0;
}


Measured memory_bytes: 256
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, a_list = gets_n_and_i_list

count_hash = a_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

total = 0
count_hash.keys.sort.each do |k|
  count = count_hash[k]
  if k > count
    total += count
  elsif k < count
    total += count - k
  end
end

puts total


Measured memory_bytes: 33552
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> mp(n, vector<int>(n,-1));
    rep(i,n) {
        int ai; cin >> ai;
        rep(j,ai) {
            int x, y;
            cin >> x >> y; x --;
            mp[i][x] = y;
        }
    }
    int ans = 0;
    rep(s,1<<n) {
        int cnt = 0;
        bool ok = true;
        vector<int> tman(n);
        rep(i,n) {
            tman[i] = (s>>i&1);
            if (s>>i&1) cnt++;
        }
        rep(i,n) {
            if (tman[i] == 1) {
                rep(j,n) {
                    if (mp[i][j] != -1 && mp[i][j] != tman[j]) {
                        ok = false;
                        break;
                    }
                }
            }
            if (!ok) break;
        }
        if (ok) chmax(ans, cnt);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sfu(n)                scanf("%llu", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pfu(n)                printf("%llu", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//


typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 200050;
const int mod = 1e9+7;


int main()
{
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;
    int tcase = 1, cas = 0;
    while(tcase--)
    {
        int n;
        cin >> n;
        double sum = 0;
        rep(i, 0, n)
        {
            int a;
            cin >> a;
            sum += (double)1/a;
        }
        cout << (double)1/sum << endl;

        ///printf("%d : %lld\n", ++cas, ans);
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 15
using namespace std;
int main(){
	int n,t,ci,ti,cmax=10000;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>ci>>ti;
		if(ti<=t){
			if(ci<cmax)
				cmax=ci;
		}
	}
	if(cmax==10000)
		cout<<"TLE";
	else
		cout<<cmax;
	return 0;
}


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

int main( ) {
  int N, A, B;
  cin >> N;
  
  if(N == 1){
    cout << "Hello World" << endl;
  } else if(N == 2){
    cin >> A >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#define F(a,b) for(int i=a;i<b;i++)
using namespace std;
int GCD(int,int);
int main(){
   int N,X,x[100010];
   cin>>N>>X;
   F(0,N){
       cin>>x[i];
       x[i]=abs(x[i]-X);
   }
   F(0,N-1) x[i+1]=GCD(x[i],x[i+1]);
   cout<<x[N-1]<<endl;
}
int GCD(int a,int b){
    int hoge;
    do{
        hoge=a%b;
        a=b;
        b=hoge;
    }while(hoge!=0);
    return a;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int calc(int X, int N, vector<int> &p)
{
    int ret = 102;
    int mindiff = 102;
    for (int i = 0; i <= 101; i++)
    {
        int diff = abs(i - X);
        if (mindiff > diff)
        {
            auto itr = find(p.begin(), p.end(), i);
            if (itr == p.end())
            {
                mindiff = diff;
                ret = i;
            }
        }
    }

    return ret;
}

int main()
{
    int X, N;
    cin >> X >> N;
    vector<int> p;
    for (size_t i = 0; i < N; i++)
    {
        int num;
        cin >> num;
        p.push_back(num);
    }

    auto answer = calc(X, N, p);
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"
#include<atcoder/string>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    string S;
    cin >> S;
    auto sa = suffix_array(S);
    auto lcp = lcp_array(S, sa);

    const int N = S.size();
    ll res = N - sa[0];
    rep(i, N - 1) {
        int len = N - sa[i + 1];
        int dup = lcp[i];
        int way = len - dup;
        res += way;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 15556
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>

int main(){
    std::string n;
    std::cin >> n;
    std::string m = n;
    std::reverse(n.begin(),n.end());

    std::cout << (m == n ? "Yes" : "No");
    return 0;



}


Measured memory_bytes: 256
A=[0]
B=[]
C=[]
for i in range(3):
    C.append(list(map(int,input().split())))
B.append(C[0][0])
B.append(C[0][1])
B.append(C[0][2])
A.append(C[1][0]-B[0])
A.append(C[2][0]-B[0])
for i in range(3):
    for j in range(3):
            if(C[i][j]!=A[i]+B[j] and C[i][j]!=B[i]+A[j]):
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 9096
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/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;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll s[n+10];
 rep(i,0,n)sc(s[i]);
 ll t[n+10];
 rep(i,0,n)t[i]=0;

 bool flag=false,end=true;
 ans=0;
 while(end){
  flag=true;
  end=false;
  rep(i,0,n){
   if(s[i]>t[i]){
    t[i]++;
    if(flag){
     end=true;
     flag=false;ans++;
    }
   }
   else{
    flag=true;
   }
  }
 }
 pr(ans);
 return 0;}



Measured memory_bytes: 3640
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    min_dist = 4*10**8+1
    for i, (c, d) in enumerate(cd):
        dist = abs(a-c)+abs(b-d)
        if dist < min_dist:
            min_dist = dist
            ans = i+1
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
using ll=long long;

const int N_MAX=100000;
int N, C,ans,st,tt,ct;
int s[N_MAX+1],t[N_MAX+1],ch[N_MAX+1];
int tl[2*(N_MAX+1)],sl[2*(N_MAX+1)];

int main(){
    cin>>N>>C;
    for(int i=0;i<N;i++){
        cin>>s[i]>>t[i]>>ch[i];
        s[i]=s[i]*2-1;
        t[i]=t[i]*2;
        ch[i]--;
    }

    for(int i=0;i<C;i++){
        for(int j=0;j<N;j++){
            if(ch[j]==i){
                for(int k=s[j];k<t[j];k++){
                    tl[k]++;
                }
            }
        }
        for(int j=0;j<2*(N_MAX+1);j++){
            if(tl[j]>0){
                sl[j]+=1;
            }
            tl[j]=0;
        }
    }
    ans=0;
    for(int i=0;i<2*(N_MAX+1);i++){
//    for(int i=0;i<2*(15+1);i++){
        //cout<<ans<<endl;
        ans=max(ans,sl[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2944
#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--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  string s;cin>>s;

  int r=0;
  rep(i, n)if(s[i]=='R')r++;

  int result=0;
  rep(i, r)if(s[i]=='W')result++;

  cout<<result<<endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<31; i++){
        if(n >= (1<<i)-1){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3132
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=250;

int n,mod;

int l[2*MAXN],r[2*MAXN];

pair<int,int> lst[2*MAXN];

int dp[2*MAXN+1][MAXN+1];

void inc(int &a,int b,int c) { a=(a+(ll)b*c)%mod; }
int solve() {
	REP(i,2*n) if(i>=n) l[i]=0; else { l[i]=sqrt(1.0*n*n-i*i); while(l[i]*l[i]<n*n-i*i) ++l[i]; }
	REP(i,2*n) r[i]=min(2*n-1,(int)sqrt(4.0*n*n-i*i));
	//REP(i,2*n) printf("%d: %d..%d\n",i,l[i],r[i]);

	REP(i,2*n) if(i<n) lst[i]=MP(l[i]-1,-i); else lst[i]=MP(r[i],-i);
	sort(lst,lst+2*n);
	REP(i,2*n) lst[i].second=-lst[i].second;
	//printf("lst:"); REP(i,2*n) printf(" (%d,%d)",lst[i].first,lst[i].second); puts("");

	int ret=0;
	REPE(ntot,n) {
		memset(dp,0,sizeof(dp)); dp[0][0]=1%mod;
		int nlft=0,nrgt=0;
		REP(i,2*n) {
			int at=lst[i].second;
			REPE(j,ntot) if(dp[i][j]!=0) {
				if(at>=n) {
					inc(dp[i+1][j],dp[i][j],r[at]+1-(nrgt+j));
				} else {
					inc(dp[i+1][j],dp[i][j],r[at]+1-(n+ntot+nlft-j));
					if(j+1<=ntot) inc(dp[i+1][j+1],dp[i][j],l[at]-(nrgt+j));
				}
			}
			if(at<n) ++nlft; else ++nrgt;
		}
		//printf("%d: %d\n",ntot,dp[2*n][ntot]);
		inc(ret,ntot%2==0?1:mod-1,dp[2*n][ntot]);
	}
	return ret;
}

void run() {
	scanf("%d%d",&n,&mod);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 768
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 -i):
    if 10000*i + 5000*j + 1000*(n - i -j) == y:
      print(i, j, n - i -j)
      break
  else:
    continue
  break
else:
  print('-1 -1 -1')


Measured memory_bytes: 3064
#include <stdio.h>
#define min(a,b) ((a)>(b)?(b):(a))

int main(){
	int N;
	scanf("%d", &N);
	char str[3][N];
	scanf("%s %s %s", str[0], str[1], str[2]);
	int i, j, count=0;
	for(i=0;i<N;i++){
		if(str[0][i]==str[1][i]){
			if(str[0][i]==str[2][i]) continue;
			else count++;
		}
		else if(str[0][i]==str[2][i]) count++;
		else if(str[1][i]==str[2][i]) count++;
		else count+=2;
	}
			
	printf("%d", count);
	
}

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int weit=0;
  for(int i=0; i<N; i++){
    cin >> m.at(i);
    weit+=m.at(i);
  }
  sort(m.begin(), m.end());
  int ans;
  ans = (X-weit)/m.at(0) + N;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		HashMap<String,Boolean> map = new HashMap<>();
		for(int i=0;i<N;i++){
			String tmp = nextString();
			map.put(tmp, map.getOrDefault(tmp, true));
		}
		System.out.println(map.size());
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 55720
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    interval = [1..k] :: [Int]
    gcds :: [Int]
    gcds = do
      a <- interval
      b <- interval
      let ab = gcd a b
      c <- interval
      return $ gcd ab c
  print . sum $ gcds

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 3868
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<memory.h>
using namespace std;
int n,m;
char youtian[101][101];
bool biaoji[101][101];
int dir[8][2]={-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
int dfs(int i,int j)
{
    int ii,jj,k,sumb=0;
    for(k=0;k<8;k++)
    {
        ii=i+dir[k][0];
        jj=j+dir[k][1];
        if(youtian[ii][jj]=='#'&&ii<n&&ii>=0&&jj<m&&jj>=0)
            sumb++;
    }
    return sumb;
}
int main()
{
    int i,j;
    while(cin>>n>>m)
    {
        for(i=0;i<n;i++)
            cin>>youtian[i];
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
        {
            if(youtian[i][j]=='.')
            {
                int p=dfs(i,j)+'0';
                youtian[i][j]=p;
            }
        }
        for(i=0;i<n;i++)
            cout<<youtian[i]<<endl;
    }
}


Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())
a=math.radians(H*30)+math.radians(M/2)
b=math.radians(M*6)
x1=A*math.cos(a)
y1=A*math.sin(a)
x2=B*math.cos(b)
y2=B*math.sin(b)
d=((x1-x2)**2+(y1-y2)**2)**(1/2)
print(d)

Measured memory_bytes: 9512
//https://atcoder.jp/contests/abc154/submissions/10006316
//勉強させていただいたコード

#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N,K;
    cin>>N>>K;
    int ANS=1;
    rep(i,N){
        ANS=min(ANS*2,ANS+K);
    }
    cout<<ANS<<endl;
    return 0;
}

Measured memory_bytes: 256
a = [int(input()) for i in range(5)]
k = int(input())
result = 0
for i in range(5):
    p = a[i]
    for j in range(4):
        q = a[j]
        if a != j and abs(p - q) > k:
            result = 1
if result == 1:
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 3060
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val numR = sc.nextInt
  val numL = sc.nextInt
  val numD = sc.nextInt

  var result = 0
  for(num <- numR to numL if(num % numD == 0)){
    result += 1
  }
  println(result)
}


Measured memory_bytes: 55388
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 105



void build(int first,int last,vector<int>& a,vector<int>& b,vector<int>& c,map<P,int>& mp){
    int times = last - first;
    for(int i = 0;i < (1<<times);i++){
        int suma = 0,sumb = 0,cost = 0;
        for(int j = 0;j < times;j++){
            
            if((i>>j)&1){
                //選ぶ
                suma += a[first + j];
                sumb += b[first + j];
                cost += c[first + j];
            }
        }
        if(!mp.count({suma, sumb}) || mp[{suma, sumb}] > cost) {
            mp[{suma, sumb}] = cost;
        }
    }
}

int main(){

    int n,ma,mb;
    cin >> n >> ma >> mb;
    vector<int> a(n),b(n),c(n);
    REP(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    map<P,int> s1,s2;

    build(0,n/2,a,b,c,s1);
    build(n/2,n,a,b,c,s2);

    int ans = INF;

    for(auto itr1:s1){
        for(auto itr2:s2){
            int suma = itr1.first.first + itr2.first.first;
            int sumb = itr1.first.second + itr2.first.second;
            if(suma*sumb > 0 && suma*mb == sumb*ma){
                ans = min(ans,itr1.second + itr2.second);
            }
        }
    }
    if(ans == INF){
        cout << "-1" << endl;
    }else{
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
#include<complex>
using namespace std;
typedef complex<int> P;

int n, x, y;
int d[5001][5001];
P p[5000];

int square(int x) { return x * x; }

bool isOk(P p) { return d[p.real()][p.imag()] == 1; }

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i <= 5000; i++) for (int j = 0; j <= 5000; j++) d[i][j] = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &x, &y);
      d[y][x] = 1;
      p[i] = P(y, x);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) {
      P dir1 = p[i] - p[j];
      P dir2 = P(dir1.imag(), -dir1.real());
      for (int i = -1; i <= 1; i += 2) {
        P p1 = dir2 * i + p[j];
        P p2 = p1 + dir1;
        if (p1.real() < 0 || p1.imag() < 0 || p2.real() < 0 || p2.imag() < 0) continue;
        if (p1.real() >= 5001 || p1.imag() >= 5001 || p2.real() >= 5001 || p2.imag() >= 5001) continue;
        if (isOk(p1) && isOk(p2)) ans = max(ans, square(dir1.real()) + square(dir1.imag()));
      }
    }
    printf("%d\n", ans);
  }
}



Measured memory_bytes: 100324
#include <bits/stdc++.h>
using namespace std;
#define ll double
// Return the maximum volume.
ll maxvolume(ll s)
{

	ll length = s / 3;

	s -= length;


	ll breadth = s / 2;

	ll height = s - breadth;
    //cout << length << breadth << height;
	return length * breadth * height;
}


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

	cout << fixed << setprecision(12)<<maxvolume(n);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
long n,k,a=0,i,j,m=1e9+7,v[2<<20];main(){for(std::cin>>n>>k;i++<n;)for(j=0;j++<n;){std::cin>>v[j];if(i==j)continue;if(v[i]>v[j])(a+=k*(k-1)/2+(i<j?k:0))%=m;}std::cout<<a;}


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

using namespace std;
using ll = long long;

const int table[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int main() {
	const int INF = 1e8;
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; ++i) { cin >> A[i]; }
	sort(A.rbegin(), A.rend());

	vector<int> dp(N + 1, -INF);
	dp[0] = 0;
	for (int i = 0; i < M; ++i) {
		int cost = table[A[i]];
		for (int j = 0; j <= N; ++j) {
			if (dp[j] < 0) { continue; }
			if (j + cost > N) { break; }
			dp[j + cost] = max(dp[j + cost], dp[j] + 1);
		}
	}

	string res = "";
	int num = N;
	int idx = 0;
	while (num > 0) {
		int cost = table[A[idx]];
		if ((num >= cost) && (dp[num] == dp[num - cost] + 1)) {
			res += to_string(A[idx]);
			num -= cost;
		} else {
			++idx;
		}
	}
	cout << res << endl;

	return 0;
}


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

using namespace std;

using ll = long long;

const int MAX_N = 301;
int n;
double dp[MAX_N][MAX_N][MAX_N];

double Solve(array<int, 3> &cnt) {
    if (cnt[0] + cnt[1] + cnt[2] == 0) return 0.0;
    if (dp[cnt[0]][cnt[1]][cnt[2]] != -1.0)
        return dp[cnt[0]][cnt[1]][cnt[2]];

    double &res = dp[cnt[0]][cnt[1]][cnt[2]];
    res = 0.0;
    for (int i = 0; i <= 2; ++i)
        if (cnt[i] != 0) {
            --cnt[i];
            if (i != 0) ++cnt[i - 1];
            res += Solve(cnt) * (cnt[i] + 1);
            ++cnt[i];
            if (i != 0) --cnt[i - 1];
        }
    res = res / (double)n + 1.0;
    int n0 = n - (cnt[0] + cnt[1] + cnt[2]);
    if (n0 != 0) res *= n / (double)(n - n0);

    return  res;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(10) << setiosflags(ios::fixed);

    cin >> n;

    array<int, 3> cnt = {0, 0, 0};
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        ++cnt[a - 1];
    }
    for (int i = 0; i <= cnt[0] + cnt[1] + cnt[2]; ++i)
        for (int j = 0; j <= cnt[1] + cnt[2]; ++j)
            for (int k = 0; k <= cnt[2]; ++k)
                dp[i][j][k] = -1.0;

    cout << Solve(cnt) << endl;

    return 0;
}


Measured memory_bytes: 213376
#include<bits/stdc++.h>
using namespace std;
int n,a[100003];
map<int,int>mp;
long long ans=1;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i+1];
	a[0]=-1;mp[0]=3;
	for(int i=1;i<=n;i++)
		ans=ans*mp[a[i]]%1000000007,
		mp[a[i]+1]++,
		mp[a[i]]--;
	cout<<ans;
}//e

Measured memory_bytes: 5376