akhauriyash/Code-Regression huggingface dataset:
// Aizu Vol-1 0177: Distance Between Two Cities
// 2017.8.3

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

char *gets(char *);
char buf[100], *p;

#define PI 3.1415926535897932384626433832795
#define M (PI/180.0)
#define EPS 0.000001

int EQ(double a1, double a2) {	return -EPS <= a1 - a2 && a1 - a2 <= EPS; }

int main()
{
	double x1, y1, x2, y2, a;
	int d;

	while (1) {
		scanf("%lf%lf%lf%lf", &y1, &x1, &y2, &x2);
		if (EQ(x1, -1) && EQ(y1, -1) && EQ(x2, -1) && EQ(y2, -1)) break;
		a = cos(y1*M)*cos(y2*M)*cos((x1 - x2)*M) + sin(y1*M)*sin(y2*M);
		d = (int)(6378.1 * acos(a) + 0.5);
		printf("%d\n", d);
	}
	return 0;
}

Measured memory_bytes: 696
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	//変数の宣言
	long int h,w;
	int i,j,k;
	long int ans;
	long int max,min;
	
	//データの読み込み
	scanf("%ld %ld",&h,&w);
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(h%3==0||w%3==0){
		printf("0");
		return 0;
	}else if(h<w){
		ans=h;
	}else{
		ans=w;
	}
	
	for(i=1;i<h;i++){
		max=i*w;
		min=i*w;
		if((w/2)*(h-i)>max) max=(w/2)*(h-i);
		if((w/2)*(h-i)<min) min=(w/2)*(h-i);
		if(((w+1)/2)*(h-i)>max) max=((w+1)/2)*(h-i);
		if(((w+1)/2)*(h-i)<min) min=((w+1)/2)*(h-i);
		
		if(max-min<ans) ans=max-min;
	}
	
	for(i=1;i<w;i++){
		max=i*h;
		min=i*h;
		if((h/2)*(w-i)>max) max=(h/2)*(w-i);
		if((h/2)*(w-i)<min) min=(h/2)*(w-i);
		if(((h+1)/2)*(w-i)>max) max=((h+1)/2)*(w-i);
		if(((h+1)/2)*(w-i)<min) min=((h+1)/2)*(w-i);
		
		if(max-min<ans) ans=max-min;
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	printf("%ld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    ans = 0
    for a in range(1, n):
        ans += (n-1)//a
    print(ans)



if __name__ == '__main__':
    main()


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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    VI abc(3);
    REP(i, 3) cin >> abc[i];
    sort(ALL(abc));
    cout << abc[0] + abc[1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


int main(){
	int n, d;
	std::cin>>n>>d;

	std::vector<std::vector<int>> xList(n);
	std::vector<std::vector<int>> dist(n);

	std::vector<int> exp(1000);

	for(int i=0; i<n; i++)
		xList[i].resize(d);

	for(int i=0; i<n; i++)
		dist[i].resize(n, 0);

	for(int i=0; i<1000; i++)
		exp[i]= i*i;

	for(int i=0; i<n; i++)
		for(int j=0; j<d; j++)
			std::cin>>xList[i][j];


	for(int j=0; j<n; j++){
		for(int i=0; i<j; i++){
			for(int k=0; k<d; k++)
				dist[i][j]+= (xList[j][k]-xList[i][k])*(xList[j][k]-xList[i][k]);
		}
	}
	
	int ans=0;

	for(int j=0; j<n; j++){
		for(int i=0; i<j; i++){
			bool isZ= false;
			for(int k=0; k<1000; k++){
				if(dist[i][j]==exp[k])
					isZ=true;
			}

			if(isZ)
				ans++;
		}
	}

	std::cout<<ans<<std::endl;

	return 0;
	
}

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

int main () {
  int n;
  int T, a;
  cin >> n >> T >> a;

  int ans = 0;
  double m = 1e9;
  rep(i,n) {
    int h;
    cin >> h;
    double t = T - h * 0.006;
    if(abs(t-a) < m) {
      ans = i + 1;
      m = abs(t-a);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_NM 10

using namespace std;
typedef pair<int, int> ipair;

vector<int> light[MAX_NM];
int p[MAX_NM];
int N, M;

int solve() {
    int res = 0;
    for(int i = 0; i < (1 << N); ++i) {

        bool is_all = true;
        for(int lt = 0; lt < M; ++lt) {

            int sw_cnt = 0;
            for(int sw_i = 0; sw_i < light[lt].size(); ++sw_i) {
                int sw = light[lt][sw_i];
                if((i >> sw) % 2 == 1)
                    ++sw_cnt;
            }

            if(sw_cnt % 2 != p[lt])
                is_all = false;
            
        }

        if(is_all)
            ++res;
    }
    return res;
}

int main(int argc, char **argv) {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j){
            int s;
            cin >> s;
            light[i].push_back(s - 1);
        }
    }
    
    for(int i = 0; i < M; ++i)
        cin >> p[i];

    cout << solve() << endl;
}

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

int main(){
    int n,rank;
    char mark;
    int card[4][13]={};
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>mark>>rank;
        switch(int(mark)){
                case 'S':card[0][rank-1]=true;
                    break;
                case 'H':card[1][rank-1]=true;
                    break;
                case 'C':card[2][rank-1]=true;
                    break;
                case 'D':card[3][rank-1]=true;
                    break;
        }
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card[i][j]==false){
                switch(i){
                    case 0:cout<<"S "<<j+1<<endl;
                        break;
                    case 1:cout<<"H "<<j+1<<endl;
                        break;
                    case 2:cout<<"C "<<j+1<<endl;
                        break;
                    case 3:cout<<"D "<<j+1<<endl;
                        break;
                }
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 3112
#include<cstdio>
const int MAXN = 100;
int a[MAXN + 5];
int main() {
	int N;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		int x;
		scanf("%d", &x);
		a[x]++;
	}
	int mx;
	for(int i=N-1;i>=1;i--)
		if( a[i] ) {
			mx = i;
			break;
		}
	for(int i=mx;i>=mx/2+1;i--) {
		if( a[i] < 2 ) {
			puts("Impossible");
			return 0;
		}
		a[i] -= 2;
	}
	if( mx % 2 == 0 ) {
		if( a[mx/2] < 1 ) {
			puts("Impossible");
			return 0;
		}
		a[mx/2]--;
	}
	for(int i=1;i<=(mx+1)/2;i++) {
		if( a[i] ) {
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

void dfs(int u, const vvi &to, vi &res, int dist){
	if(dist==0){ 
		res.push_back(u);
		return;
	}
	for(auto v: to[u]){
		dfs(v,to,res,dist-1);
	}
}

vi dis3(int sv, vvi &to){
	vi res;
	dfs(sv,to,res,3);
	return res;
}

int main(void) {
	int n,m; cin >> n >> m;
	vvi to(n);
	rep(i,m){
		int u,v; cin >> u >> v;
		--u; --v;
		to[u].push_back(v);
	}
	int s,t; cin >> s >> t;
	--s; --t;
	
	vvi to3(n*3);
	rep(l,3){
		rep(i,n){
			int u = i+n*l;
			for(auto v: to[i]){
				if(l<2) to3[u].push_back(v+n*(l+1));
				else to3[u].push_back(v);
			}
		}
	}
/* 	
 	rep(u,n){
		cout << u << " : ";
		for(auto v: to[u]) cout << v << " ";
		cout << endl;
	}
	cout << endl;	
 	rep(u,n*3){
		cout << u << " : ";
		for(auto v: to3[u]) cout << v << " ";
		cout << endl;
	}
 */	
	queue<int> q;
	q.push(s);
	vi dist(n*3,-3);
	dist[s]=0;
	while(q.size()){
		int u = q.front(); q.pop();
		for(auto v: to3[u]){
			if(dist[v]!=-3) continue;
			dist[v] = dist[u]+1;
			q.push(v);
		}
	}
	cout << dist[t]/3 << endl;
	
}




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

namespace AtCoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var c = Console.ReadLine()[0];
            switch (c)
            {
                case 'A':
                    Console.WriteLine('T');
                    break;
                case 'T':
                    Console.WriteLine('A');
                    break;
                case 'C':
                    Console.WriteLine('G');
                    break;
                case 'G':
                    Console.WriteLine('C');
                    break;
            }
            return;
        }
    }
}


Measured memory_bytes: 13140
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
difmin = 10**5
imin = -1
for i, h in enumerate(H):
    dif = abs((T - h*0.006) - A)
    if difmin > dif:
        difmin = dif
        imin = i+1
print(imin)

Measured memory_bytes: 3060
n=int(input())
b=[int(i) for i in input().split()]
c=[]
for _ in range(n):
  for i in range(len(b)-1,-1,-1):
    if i+1==b[i]:
      del b[i]
      c.append(i+1)
      break
  else:
    print(-1)
    exit()
for i in c[::-1]:
  print(i)

Measured memory_bytes: 38512
str = gets.split
N,M = str[0].to_i, str[1].to_i
a = Array.new(M){Array.new(2)}
for i in 0...M do
    str = gets.split
    a[i][0] = str[0].to_i
    a[i][1] = str[1]
end

b = Array.new(N+1,0)
c = Array.new(N+1,0)

for i in 0...M do
    d = a[i][0]
    e = a[i][1]
    if e == "AC"
        c[d] += 1
    elsif c[d] == 0
        b[d] += 1
    end
end

ac = 0
wa = 0
for i in 1..N do
    if c[i] > 0
        ac += 1
        wa += b[i]
    end
end
print ac," ",wa
puts

Measured memory_bytes: 16636
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,a[maxn];
int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n; ++i) scanf("%d",a+i);
    sort(a+1,a+n+1);
    LL ans = a[n]; int x = n-1,cnt = 0;
    for(int i = n-2;i > 0; --i){
        ans += a[x]; cnt++;
        if(cnt == 2){
            x -= 1;
            cnt = 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4500
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;

		try {

			sc = new Scanner(System.in);
			int dataSet = 0;
			char[] num = new char[8];
			Integer max = 0;
			Integer min = 0;
			Integer result = 0;

			while (sc.hasNext()) {
				dataSet = sc.nextInt();
				for (int i = 1; i <= dataSet; i++) {
					num = sc.next().toCharArray();

					max = sortDesc(num);
					min = sortAsc(num);
					result = max - min;

					System.out.println(result);
				}

			}

		} finally {
			sc.close();
		}

	}

	public static Integer sortAsc(char[] c) {

		Arrays.sort(c);
		return Integer.parseInt(String.valueOf(c));
	}

	public static Integer sortDesc(char[] c) {

		Arrays.sort(c);
		char[] result = new char[c.length];

		for (int i = 0; i < c.length; i++) {
			result[result.length - (1 + i)] = c[i];
		}

		return Integer.parseInt(String.valueOf(result));

	}

}

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

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

int main()
{
 int N , X;
 scanf("%d %d",&N,&X);
 int x[N];
 

 for (int i = 0;i<N;i++)
  {
   scanf("%d",&x[i]);
   x[i]-=X;
  }
 
 for (int i = 0;i<N;i++)
  {
    x[i]=abs(x[i]);
  }
  
  
  if (N==1)
 {
   N++;
   x[1]=x[0];
 }

  int A = gcd(x[0],x[1]);
  
  int c = 0; 
  for (int i = 2; i<N;i++)
  {
    c = gcd(A,x[i]);
    A = c;
    
  }

   printf("%d",A);
 
  return 0;
}
 



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

int change(char *a,char **b){
	int n=1200;
	int eret;
	*b=(char*)malloc(strlen(a)+1);
	if(fgets(a,n,stdin)){
		for(;*a;++a){
			if(*a>='a'&&*a<='z'){
				*a-='a'-'A';
			}
			else if(*a>='A'&&*a<='Z'){
				*a+='a'-'A';
			}
			*b=a;
			printf("%c",**b);
		}
		if(strlen(a)<n && a!=NULL && *b!=NULL){
			return 0;
		}
		else{
			eret=1;
			return (-1);
		}
	}
}

int main(){
	int n=1200;
	int eret;
	char *a=(char*)malloc(n+1);
	change(a,&a);
	if(eret==1){
		printf("over\n");
		return 1;
	}
	else{
		return 0;
	}
}

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

#define all(c) (c).begin(),(c).end()
#define FOR(i, x, n) for(int i = x; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) #x << "=" << (x) << "(L" << __LINE__ << ")"
#define show(x) cout << #x << "=" << x << endl
#define show2(x,y) cout << #x << "=" << x << "," << #y << "=" << y <<  endl
#define show3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z <<  endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

const ld eps = 1e-9, pi = acos(-1.0);
const ld EPS = 1e-8;
const int INF = INT_MAX/2;
const ll LINF = LONG_MAX/2;
const int MOD = 1000000007;

template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }

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 (a>b) { a=b; return 1; } return 0; }

int main(){
    
    ll n;
    cin >> n;
    
    ll m = 0;
    ll ans = 0;
    ll t,h;
    rep(i,n){
        cin >> h;
        if(m<=h){
            ans++;
            m = h;
        }else{
            
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long ll;
ll a[110000];
ll sum[110000];
map<ll,ll>cnt;
int main()
{
    ll n,m;
    sum[0]=0;
    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=(sum[i-1]+a[i])%m;
    }
     sort(sum,sum+n+1);
        ll s=1;
        long long ans=0;
        for(ll i=1;i<=n;i++){
            if(sum[i]==sum[i-1]) s++;
            else{
                ans+=s*(s-1)/2;
                s=1;
            }
        }
        ans+=s*(s-1)/2;
        printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

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

void no(){
    cout<<-1;exit(0);
}

int main(){fastio
    ll n,a,b;cin>>n>>a>>b;
    if(a*b<n)no();
    if(a+b>n+1)no();
    vector<ll>v[a];
    ll cnt=1;
    rep(i,0,a-1){
        if(i==0){
            rep(z,1,b){
                v[i].pb(cnt);cnt++;
            }
            continue;
        }
        if(i==a-1){
            while(cnt<=n){
                v[i].pb(cnt);cnt++;
            }
            continue;
        }
        ll k=(n-cnt+1)/(a-i);
        while(k--){
            v[i].pb(cnt);cnt++;
        }
    }
    rep(i,0,a-1){
        reverse(v[i].begin(),v[i].end());
        for(auto x:v[i])cout<<x<<" ";
    }
    
    return 0;
}

/*
 1 7
 2 4
 2 5
 2 6
 3 3
 3 4
 3 5
 4 2
 4 3
 4 4
 5 2
 5 3
 6 2
 7 1
 */


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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,m,k;
  cin >> n >> m >> k;

  ll a[n+1],b[m+1];
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<m;i++)cin >> b[i];

  ll sa[n+1]={},sb[m+1]={};

  //sa[i]..aのi番目までの和(1-indexed)
  for(int i=0;i<n;i++)sa[i+1]=sa[i]+a[i];
  for(int i=0;i<m;i++)sb[i+1]=sb[i]+b[i];

  ll s=0;
  for(int i=0;i<=n;i++){
    if(sa[i]<=k){  //sa[i]>kなら論外
      ll c=upper_bound(sb,sb+m,k-sa[i])-sb;  //sb[c]+sa[i]が初めてkを超えるようなcを探す
      if(c==m+1)c--; //sa[i]+sb[m]<=kのとき
      else if(sa[i]+sb[c]>k)c--;  //upper_boundについてよくわかっていないがこれが必要らしい(これがないとサンプルすら通らない)
      s=max(s,c+i);
    }
  }
  cout << s << endl;
}



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

int main(){
    int N, K;
    std::string S;
    std::cin >> N >> K >>S;
    
    int cnt = 1;
    int init_happy = 0;
    int cont = 0;
    char cur = 'N';
    for(int i=0; i<N; i++){
        if(S[i] == cur){
            cnt++;
            
        }else{
            cont++;
            cur = S[i];
            init_happy += cnt - 1;
            cnt = 1;
        }
    }
    init_happy += cnt - 1;
    
    if(cont <= 2 * K){
        std::cout << N - 1 << std::endl;
    }else{
        std::cout << init_happy + 2 * K << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int d, n;
    cin >> d >> n;
    if(d==0 && n!=100){
        cout << n << endl;
    }
    else if(d==0 && n==100){
        cout << 101 << endl;
    }
    else if(d==1 && n!=100){
        cout << 100*n << endl;
    }
    else if(d==1 && n==100){
        cout << 10100 << endl;
    }
    else if(d==2 && n!=100){
        cout << 10000*n << endl;
    }
    else{
        cout << 1010000 << endl;
    }
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
const int MAXN=3010;
long long sum[MAXN],dp[MAXN][MAXN],res;
char x;
int n;

int main(){
	cin>>n;
	dp[1][1]=1;
	for(int i=2;i<=n;++i){
		cin>>x;
		for(int j=1;j<=n;++j) (sum[j]=sum[j-1]+dp[i-1][j])%=MOD;
		for(int j=1;j<=n;++j){
			if(x=='<') dp[i][j]=sum[j-1]%MOD;
			else dp[i][j]=(sum[i-1]-sum[j-1]+MOD)%MOD;
		}
	}
	for(int i=1;i<=n;(res+=dp[n][i])%=MOD,++i);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 70784
h,w = map(int,input().split())
S = [input() for i in range(h)]
yoko = [[1]*w for _ in range(h)]
tate = [[1]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == '#':
            yoko[i][j] = 0
        else:
            if j != 0:
                yoko[i][j] += yoko[i][j-1]
for i in range(h):
    for j in range(w-1,-1,-1):
        if yoko[i][j] == 0:
            continue
        else:
            if j != w-1:
                yoko[i][j] = max(yoko[i][j],yoko[i][j+1])
for j in range(w):
    for i in range(h):
        if S[i][j] == '#':
            tate[i][j] = 0
        else:
            if i != 0:
                tate[i][j] += tate[i-1][j]
for j in range(w):
    for i in range(h-1,-1,-1):
        if tate[i][j] == 0:
            continue
        else:
            if i != h-1:
                tate[i][j] = max(tate[i][j],tate[i+1][j])
res = 0
for i in range(h):
    for j in range(w):
        res = max(res,tate[i][j]+yoko[i][j]-1)
print(res)

Measured memory_bytes: 123096
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll f(ll x){
    if(x%4==0) return x;
    else if(x%4==1) return 1;
    else if(x%4==2) return x+1;
    else if(x%4==3) return 0;
}

int main(){
    ll A,B;
    cin>>A>>B;
    ll ans=f(A-1)^f(B);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,p;
	cin>>s>>p;
	bool a=false;
	for(int i=0;i<s.size();i++){
		int count=0;
		for(int j=0;j<p.size();j++){
			if(s[(i+j)%s.size()]==p[j%p.size()])
				count++;
		}
		if(count==p.size())
            a=true;
	}
    if(a==true)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;

public class Main {
static Scanner reader =new Scanner (System.in);
  
    public static void main(String[] args) {
        String arr[]={"Sunny","Cloudy","Rainy" };
        int an=0;
         String s=reader.nextLine();
         for(int i=0;i<3;i++)
         {
             if(s.equals(arr[i]))
             {
                an = i + 1;
	        an %= 3;
				
                 break;
             }
         }
         System.out.println(arr[an]);
    }
    
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a[1000][999], p[1000];
bool ok[1000][1000];

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n - 1) {
		cin >> a[i][j];
		a[i][j]--;
	}
	}
	
	set<int> se1;
	inc(i, n) { se1.insert(i); }
	int fin = 0;
	inc(i, n * n) {
		if(fin == n) { cout << i << endl; return 0; }
		
		#define f a[e][p[e]]
		
		RF(e, se1) { ok[f][e] = true; }
		
		set<int> se2;
		RF(e, se1) { if(ok[e][f]) { se2.insert(e); se2.insert(f); } }
		if(se2.empty()) { cout << -1 << endl; return 0; }
		
		se1.clear();
		RF(e, se2) {
			ok[e][f] = false;
			p[e]++;
			if(p[e] < n - 1) { se1.insert(e); } else { fin++; }
		}
	}
	
	UR;
}


Measured memory_bytes: 5248
object Main extends App {

  def areaOfBlocks(start: Int, step: Int): Int = {
    if (start <= 0) 0
    else start*start*step + areaOfBlocks(start - step, step)
  }

  for (step <- io.Source.stdin.getLines.map(_.toInt))
    println(areaOfBlocks(600-step, step))
}

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int a[Sz], b[Sz];
                   
int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();  
  cin >> n;          
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  ll sum = accumulate (a + 1, a + n + 1, 0ll);
  ll s = n * 1ll * (n + 1) / 2;

  if (sum % s) {
    cout << "NO";
    return 0;
  }
  ll k = sum / s;

  ll need = 0;
  for (int i = 1; i <= n; i++) {
    b[i] = a[i] - a[i%n + 1];
    b[i] += k;
    if (b[i] < 0 || b[i] % n) {
      cout << "NO";
      return 0;
    }
    need += -b[i] / n;
    if (need > k) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES"; 
    
                 
  



  return 0;
}






// Coded by Z..



Measured memory_bytes: 2688
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<N;++i)
using namespace std;

int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  printf("%f %d", (double)W*(double)H/2, x*2 == W && y*2 == H);
}

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

using i64 = std::int64_t;
constexpr i64 MaxC = 1e14;

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

	std::vector<i64> a(n + 1);
	for (auto&& e : a)
		std::cin >> e;
	
	if (n != 0 && a[0] == 1) {
		std::cout << -1 << std::endl;
		return 0;
	}

	std::vector<i64> c(n + 1);
	c[0] = 1;
	for (int i = 0; i < n; ++i) {
		if (c[i] >= MaxC) {
			c[i + 1] = MaxC;
			continue;
		}

		if (c[i] <= 0) {
			std::cout << -1 << std::endl;
			return 0;
		}

		c[i + 1] = (c[i] - a[i]) * 2;
	}
	if (a[n] > c[n]) {
		std::cout << -1 << std::endl;
		return 0;
	}

	i64 cur = a[n];
	i64 ans = cur;
	for (int i = n - 1; i >= 0; --i) {
		cur += a[i];
		if (cur > c[i])
			cur = c[i];
		
		ans += cur;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 4844
/*
Md. Shahnewaz Siddique Labib
Dept. of CSE
IUT'19
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
    fastio;
    int n, b;
    cin >> n >> b;
    cout << floor((log(n)/log(b))) + 1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define nl '\n'
#define ff first
#define ss second
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

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

  int n; cin >> n;
  string s; cin >> s;
  string lx = s.substr(0, n), rx = s.substr(n, n);
  reverse(rx.begin(), rx.end());

  map<string, int> mp[n+1];

  for(int i=0; i<(1<<n); i++) {
    string red="", blue="";
    int rc=0;
    for(int j=0, b=1; j<n; j++, b<<=1)
      if( b&i ) {
	red += rx[j];
	rc++;
      } else {
	blue += rx[j];
      }
    reverse(blue.begin(), blue.end());
    // cerr << rc << " : " << red << ' ' << blue << endl;
    mp[rc][red+blue]++;
  }

  ll ans = 0;
  for(int i=0; i<(1<<n); i++) {
    string red="", blue="";
    int rc = 0;
    for(int j=0, b=1; j<n; j++, b<<=1)
      if( b&i ) {
	rc++;
	red += lx[j];
      } else {
	blue += lx[j];
      }
    reverse(blue.begin(), blue.end());
    ans += mp[rc][red+blue];
  }

  cout << ans << nl;

  return 0;
}

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


Measured memory_bytes: 70656
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    k=int(input())
    que=deque([1,2,3,4,5,6,7,8,9])
    for _ in range(k-1):
        q=que.popleft()
        if q%10>0:que.append(10*q+q%10-1)
        que.append(10*q+q%10)
        if q%10<9:que.append(10*q+q%10+1)
    print(que[0])


if __name__=='__main__':
    main()

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

int main(){
    ll N;
    bool judge=true;
    cin >> N;
    vector<ll> tower(N);
    rep(i,tower.size()) cin >> tower[i];
    for(ll i=N-2;i>=0;i--){
        if(tower[i]>=tower[i+1]+2){
            judge=false; break;
        }else if(tower[i]==tower[i+1]+1){
            tower[i]--;
        }
    }
    
    if(judge) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 1024
import math
import sys
N=int(input())
if N<=5:
    print(0)
    sys.exit()

z=100
Combi=[[] for i in range(z+1)]
Combi[0]=[1,0]

for i in range(1,z+1):
    Combi[i].append(1)
    for j in range(i):
        Combi[i].append(Combi[i-1][j]+Combi[i-1][j+1])
    Combi[i].append(0)

    
FACT=dict()


for x in range(2,N+1):
    L=math.floor(math.sqrt(x))
    
    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

LIST=[list(FACT.values())[i] for i in range(len(FACT)) if FACT[list(FACT.keys())[i]]>=2]

x2=len([l for l in LIST if l>=2])
x4=len([l for l in LIST if l>=4])
x24=len([l for l in LIST if l>=24])
x14=len([l for l in LIST if l>=14])
x74=len([l for l in LIST if l>=74])

ANS1=(x2-2)*Combi[x4][2]
ANS2=x24*(x2-1)
ANS3=x14*(x4-1)
ANS4=x74

print(ANS1+ANS2+ANS3+ANS4)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

struct UFT {
	vector< int > par;
	int getpar(int i) {
		if (par[i] == i)
			return i;
		return par[i] = getpar(par[i]);
	}
	void unite(int i, int j) {
		int t = getpar(i);
		par[t] = getpar(j);
	}
	bool uf(int i, int j) {
		return getpar(i) == getpar(j);
	}
	UFT(int n) {
		par = vector< int >(n);
		for (int i = 0; i < n; i++)
			par[i] = i;
	}
};

int N, M, K, T, Q;
int main() {
	cin >> N >> M;
	vector< vector< int > > A(M);
	rep(i, N) {
		int K;
		cin >> K;
		rep(j, K) {
			int L;
			cin >> L;
			--L;
			A[L].push_back(i);
		}
	}
	UFT uf(N);
	rep(j, M) {
		if (A[j].size() < 2)
			continue;
		int prev = A[j][0];
		for (int i = 1; i < A[j].size(); i++) {
			uf.unite(prev, A[j][i]);
			prev = A[j][i];
		}
	}
	string ans = "YES";
	for (int i = 1; i < N; i++) {
		if (!uf.uf(0, i)) {
			ans = "NO";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  double maxp = 0;
  int swater = 0;
  int sugar = 0;
  for(int i = 0; 100 * a * i <= f; i++) {
    for(int j = 0; 100 * a * i + 100 * b * j <= f; j++) {
      for(int k = 0; 100 * a * i + 100 * b * j + k * c <= f; k++) {
        if((a * i + b * j) * e < k * c) break;
        int l = min(((a * i + b * j) * e - k * c) / d, (f - 100 * a * i - 100 * b * j - k * c) / d);
        if((100 * a * i + 100 * b * j + c * k + d * l) == 0) continue;
        double p = (double)(k * c + l * d) / (double)(100 * a * i + 100 * b * j + c * k + d * l);
        if(maxp <= p) {
          maxp = p;
          swater = 100 * a * i + 100 * b * j + c * k + d * l;
          sugar = c * k + d * l;
        }
      }
    }
  }
  cout << swater << " " << sugar << endl;
  


  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  sort(all(a));
  vector<ll> s(N+1);
  s[0]=0;
  rep(i,N+1) s[i+1]=s[i]+a[i];
  ll l=0,r=2e5+1;
  ll cnt;
  while(r-l!=1){
    ll mid=(l+r)/2;
    bool flag=false;
    cnt=0;
    for(int i=0;i<N;i++){
      ll j=lower_bound(all(a),mid-a[i])-a.begin();
      cnt+=N-j;
    }
    if(cnt>=M) flag=1;
    if(flag) l=mid;
    else r=mid;
  }
  int x=l;
  ll ans=0;
  cnt=0;
  rep(i,N){
    ll j=lower_bound(all(a),x-a[i])-a.begin();
    ans+=a[i]*(N-j)+s[N]-s[j];
    cnt+=N-j;
  }
  ans-=(cnt-M)*x;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a, b;
	
	// 数値入力
	scanf("%d%d", &a, &b);
	
	// 比較、結果出力
	if(a == b)
	{
		printf("a == b\n");
	}
	else if(a < b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a > b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2036
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int a, b;
	cin >> a >> b;
	string s = "";
	if(a < b){
		for(int i = 0; i < b; i++){
			s += a+'0';
		}
	}else{
		for(int i = 0; i < a; i++) s += b+'0';
	}	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import string


def main():
    s = input()
    a = {i: False for i in string.ascii_lowercase}
    for i in s:
        a[i] = True
    r = [i for i, j in a.items() if j == False]
    if 0 < len(r):
        print(r[0])
    else:
        print("None")


main()


Measured memory_bytes: 39536
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  
  ll l,r,d;cin>>l>>r>>d;
  cout<<r/d-(l-1)/d<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int ans;
	double v,y,t;
	while(cin>>v){
		t=v/9.8;
		y=4.9*t*t;
		ans=0;
		while(y>5*ans-5)ans++;
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
    int n;
    bool flag = true;
    cin >> n;
    vector<vector<int>> plan(n + 1, vector<int>(3));
    plan.at(0).at(0) = 0;
    plan.at(0).at(1) = 0;
    plan.at(0).at(2) = 0;
    rep(i, n) cin >> plan.at(i + 1).at(0) >> plan.at(i + 1).at(1) >> plan.at(i + 1).at(2);
    rep(i, n) {
        int dis = abs(plan.at(i + 1).at(1) - plan.at(i).at(1)) + abs(plan.at(i + 1).at(2) - plan.at(i).at(2));
        int time = plan.at(i + 1).at(0) - plan.at(i).at(0);
        if(dis <= time && dis % 2 == time % 2) continue;
        flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 200000;
int n;
LL cnt;
LL a[maxn + 5];
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)scanf("%lld", &a[i]);
	int l = 1, r = 1;
	LL res1 = a[r], res2 = a[r];
	while(res1 == res2 && r < n) {
		res1 ^= a[++r];
		res2 += a[r];
	}
	if(res1 != res2) {
		res1 ^= a[r];
		res2 -= a[r];
		r--;
	}
	//printf("%d %d %lld %lld\n", l, r, res1, res2);
	cnt += (LL)(r - l + 1);
	for(int l = 2; l <= n; l++) {
		res1 ^= a[l - 1];
		res2 -= a[l - 1];
		while(res1 == res2 && r < n) {
			res1 ^= a[++r];
			res2 += a[r];
		}
		if(res1 != res2) {
			res1 ^= a[r];
			res2 -= a[r];
			r--;
		}
	//	printf("%d %d %lld %lld\n", l, r, res1, res2);
		cnt += (LL)(r - l + 1);
	}
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
char S[101010];
int cnt[26];

int main()
{
	scanf("%d%s", &N, S);
	for (int i = 0; i < N; ++i) {
		cnt[S[i] - 'a']++;
	}
	i64 ret = 1;
	for (int i = 0; i < 26; ++i) {
		ret = ret * (1+cnt[i]) % MOD;
	}
	ADD(ret, MOD - 1);
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	long A, B;
	long K, TMP;

	scanf ("%ld %ld",  &A, &B);

	TMP = A + B;
	if (TMP%2) {
		printf("IMPOSSIBLE\n");
	}
	else {
		printf("%d\n",TMP/2);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <climits>
using namespace std;
int main()
{
  map<int,int> h;

    int x,n;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<endl;
    }
    else if(n!=0)
    {
    for(int i=0;i<n;i++)
    {
        int k;cin>>k;
        h[k]=1;
    }
    int num=0,od=INT_MAX,cd=INT_MAX;
    for(int i=0;i<102;i++)
    {
        if(h[i]==0)
        {
            cd=(x>i)?x-i:i-x;
            if(cd<od)
            {
                od=cd;
                num=i;
            }

        }
    }
    cout<<num<<endl;


    }
   return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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


int main(){fastio
    string s,t;cin>>s>>t;
    ll n=s.size(),m=t.size();
    ll dp[n+1][m+1];
    dp[0][0]=0;
    rep(i,0,n){
        rep(j,0,m){
            if(i==0||j==0)dp[i][j]=0;
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                if(s[i-1]==t[j-1])Max(dp[i][j],dp[i-1][j-1]+1);
            }
        }
    }
    //rep(i,0,n){rep(j,0,m)cout<<dp[i][j]<<" ";cout<<endl;}
    string ans;
    ll pi=n,pj=m;
    while(pi>0&&pj>0){
        if(dp[pi-1][pj]==dp[pi][pj])pi--;
        else if(dp[pi][pj-1]==dp[pi][pj])pj--;
        else{
            ans+=s[pi-1];pi--;pj--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
    return 0;
}



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

int main() {

  long long int n;
  cin >> n;

  long long int ans = 0;

  for ( long long int i = 1; i * i <= n; i++ ) {

    if ( ( n - i ) % i != 0 ) continue;
    long long int cnt = ( n - i ) / i;
    if ( cnt == 0 ) continue;
    if ( n / cnt != n % cnt ) continue;
    ans += cnt;

  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()
 
const int MOD = 1000000007;
 
 
int main() {
 
ll X; cin >> X ;
 
ll c=0,d=0;
 
for(int i=-1000;i<=1000;i++){
  for(int j=-1000;j<=1000;j++){
    ll A=(ll)pow(i,5),B=(ll)pow(j,5);
    if(A-B==X){
      c=i; d=j;
    }
  }
}

  cout << c << ' ' << d << endl;
 
return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    cin>>N;
    vint A(N);rep(i,N)cin>>A[i];
    sort(all(A));
    int ans=0;
    rep(i,N/2)ans+=(A[N-1-i]-A[i])*2;
    if(N%2==0)ans+=A[N/2-1]-A[N/2];
    else{
        ans+=max(A[N/2-1]-A[N/2],A[N/2]-A[N/2+1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
V e,s;
int N,M;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(!n)return e;
	if(n==1)return a;
	if(n%2==1)return mul(exp(a,n-1),a);
	V b=exp(a,n/2);
	return mul(b,b);
}

main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&a,&b,&c,&t),N;){
		s.resize(N);
		e.resize(1);
		e.resize(N*N);
		V x(N*N);
		for(i=0;i<N;i++){
			scanf("%d",&s[i]);
			e[i*N+i]=1;
			if(i>0)x[i*N+i-1]=a;
			x[i*N+i]=b;
			if(i<N-1)x[i*N+i+1]=c;
		}
		const V r=exp(x,t);
		for(i=0;i<N;i++){
			printf(i<N-1?"%d ":"%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
		}
	}
}

Measured memory_bytes: 1092