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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

int main(){
    REP(i,1,10){
        REP(j,1,10){
            cout<<i<<"x"<<j<<"="<<i*j<<endl;
        }
    }   
}

Measured memory_bytes: 2976
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MODD 998244353
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MODD;
		x = (x*x)%MODD;
		n = n>>1;
	}
	return ans%MODD;
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

int t=1;
//cin>>t;

while(t--)
{
	int x,y;
	cin>>x>>y;
	
	if(x>y)
	cout<<"safe\n";
	else
	cout<<"unsafe\n";
}



return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  double a, b, C, S, L, h, pi=3.14159265358979;
  cin >> a >> b >> C;
  C=C*pi/180;
  h= b * sin(C);
  S = a * h /2;
  L = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(C)) + a + b;
  cout << fixed;
  cout << std::setprecision(5) << S << endl << L << endl << h << endl;
  return 0;
}



Measured memory_bytes: 3472
s = input()
stack = []
stack1 = []
tot = 0
rs = []
for i in range(len(s)):
    if s[i] == '\\':
        stack.append(i)
    elif s[i] == '/':
        if len(stack) > 0:
            tmp = i - stack[-1]
            tot += tmp
            while len(stack1) > 0 and stack1[-1][0] > stack[-1]:
                tmp += stack1[-1][1]
                stack1.pop()
            stack1.append((stack[-1], tmp))
            stack.pop()
print(tot)
print(len(stack1), *(y for x,y in stack1))


Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> vec(m);
  rep(i, m) cin >> vec[i];
  sort(all(vec));
  vector<int> dis(m-1);
  rep(i, m-1) dis[i] = vec[i+1]-vec[i];
  sort(all(dis));
  if(n >= m) cout << 0 << endl;
  else{
   	ll ans = 0;
    rep(i, m-n) ans += dis[i];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3936
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	int n,x;
	cin >> n >> x;
	int a[n+1],front[n+1];
	front[0]=0;
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		front[i]=front[i-1]+a[i];
		if(front[i]<=x) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<numeric>
#include<list>
#include<cmath>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0])
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;



int main(void) {
	int k;
	cin >> k;
	int x = 7 % k;
	for (int i = 0; i < k; i++) {
		if (x == 0) {
			cout << i + 1;
			return 0;
		}
		x = (x * 10 + 7) % k;
	}
	cout << -1;
	


	return 0;
}


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

int main() {
    ll w, h, x, y; cin >> w >> h >> x >> y;
    double tmp = 0;

    tmp = (double)w*(double)h/(double)2;
    cout << fixed << setprecision(10) << tmp;
    if(2*x==w && 2*y==h){
        cout << " " ;
        cout << 1 << endl;
    }
    else{
        cout << " " ;
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int MAX = 5e3+3;
const int INF = 1e9;
const int MOD = 1e9+7;

int a[MAX];

int main(){

  int n; cin >> n;
  REP(i,n) cin >> a[i];
  ll ans = 0;
  REP(i,n) ans += a[i]-1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long N;cin>>N;
  for(long long I = 1; 3500 >= I; I++){
    for(long long J = 1; 3500 >= J; J++){
      if(!(4*J*I-N*I-N*J))continue;
      if(!(N*J*I % (4*J*I-N*I-N*J)) && (N*J*I / (4*J*I-N*I-N*J)) > 0){
        cout << I << " " << J << " " << N*J*I / (4*J*I-N*I-N*J) << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, d int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &d)

	m := 2*d + 1
	fmt.Println((n + m - 1) / m)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; 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 inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(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); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, k;
string s;

int main() {
	cin >> n >> k >> s;
	
	s[k - 1] -= 'A';
	s[k - 1] += 'a';
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = [int(_) for _ in input().split()]
cnt = 0

for i in range(N):
    p = P[i]
    ni = (i + 1) % N
    if p == (i + 1):
        cnt += 1
        P[i], P[ni] = P[ni], P[i]

print(cnt)


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

int main()
{
  int a , b , num , i ;
  num = 1 ;
  
  cin >> a >> b ;
  
  for(i=0; num<b; i++)
  {
    num += a-1 ;
  }
  
  cout << i << endl ;
}

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

long long table[10001];

int main(){
  int n;
  table[0]=1;
  for(int i=1; i<=10000; i++)
    table[i]=table[i-1]+i;
  while(cin>>n){
    cout<<table[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 30000 + 5;
int main(){
    ll n,k,mul=1;
    ll a[200005];
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n-k;i++){
        if(a[i]<a[k+i]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 5316
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    int cnt[N];
    void main()
	{
		int n=qread();
		int ans=0;fo(i,1,n){int oth=n-i;if(oth>0 and i<oth) ans++;
		}write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
/*
				C++
				encoding: UTF-8
				Last Modified: 29/Aug/20 05:31:22 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

#define int int64_t

template < typename T > void print (const T& t) {
	cout << t << '\n';
}

template < typename T, typename U, typename... ARGS >
void print (const T& t, const U& u, const ARGS&... args) {
	cout << t << " ";
	print (u, args...);
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d) {
		print ("Yes");
	} else {
		print ("No");
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<"L"<<__LINE__ <<" : "<<#x<<" = "<<(x)<<endl
// #define gcd __gcd
// for c++14
inline int ones(unsigned x){int r=0;while(x!=0) r++,x=x&(x-1);return r;}

using vi=vector<int>;
using pii=pair<int,int>;
using vii=vector<pii>;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int inf=0x3f3f3f3f;
const int nmax=100;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin.exceptions(cin.failbit);
    //Solution
    int a,b;
    cin>>a>>b;
    if(a<=5) cout<<0;
    else if(a<=12) cout<<b/2;
    else cout<<b;
    cout<<endl;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
long long x,y,ans;
int main()
{
    scanf("%lld%lld",&x,&y);
    while(x<=y)
    {
        x*=2;
        ans++;
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  bool can = false;
  int n; scanf("%d", &n);
  for (int a = 1; a <= 9; a ++)
    for (int b = 1; b <= 9; b ++)
      if (a * b == n)
        can = true;
  if (!can)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}

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

using namespace std;

// int main()
// {
//   string str;
//   getline(cin, str);
//   char a;
//   int ans[26];

//   for (int i = 0; i < 26; i++)
//   {
//     ans[i] = 0;
//   }

//   for (int i = 0; i < str.size(); i++)
//   {
//     a = str[i];

//     if (isupper(a))
//       a = tolower(a);

//     ans[a - 'a']++;
//   }

//   for (int i = 0; i < 26; i++)
//   {
//     cout << char(i + 'a') << ":" << ans[i] << endl;
//   }
// }
int main()
{
  string str;
  int alp[26] = {};
  while (getline(cin, str))
  {
    for (int i = 0, l = str.size(); i < l; i++)
    {
      if (str[i] >= 'a' && str[i] <= 'z')
        alp[str[i] - 'a']++;
      else if (str[i] >= 'A' && str[i] <= 'Z')
        alp[str[i] - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++)
  {
    printf("%c : %d\n", i + 'a', alp[i]);
  }
}


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

int m = 111;

int main() {
    int n;
    cin >> n;
    int ans;
    if (n%m == 0) ans = n;
    else ans = n/m*m+m;
    cout << ans << endl;
    return 0;
}


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

int f[100005], h[100005];
int main() {
	int n, K=2;
	scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		scanf("%d", &h[i]);
		f[i]=1000000000;
		f[1]=0;
		for (int k=1; k<=K; k++)
		if (i>k) f[i]=min(f[i], f[i-k]+abs(h[i]-h[i-k]));
	}	
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  string ans[3]={"Sunny","Cloudy","Rainy"};

  string s;
  cin>>s;
  rep(i,3){
    if(ans[i]==s){
      cout<<ans[(i+1)%3]<<endl;
    }
  }


}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 初期処理
		Scanner sc = null;

		// テキスト入力クラス
		sc = new Scanner(System.in);

		// 入力値をfloatで取る
		Double first = sc.nextDouble();
		Double second = sc.nextDouble();
		DecimalFormat df2 = new DecimalFormat("##########.##########");

		// 求める値
		Double quotient = first / second;
		Double product = first % second;
		
		// 元データをBigDecimal型にする
		BigDecimal quo = new BigDecimal(quotient);
		BigDecimal pro = new BigDecimal(product);
		
		quotient = (Double)first / second;

		// 出力
		System.out.println(quo.setScale(0,BigDecimal.ROUND_DOWN) + " " + pro.setScale(0,BigDecimal.ROUND_DOWN)
				+ " " + df2.format(quo.setScale(8,BigDecimal.ROUND_DOWN)));

	}
}

Measured memory_bytes: 19160
#include<cstdio>
#include<string>
#include<numeric>
#define rep(i,a) for(int i=0;i<(a);++i)

const int mod = 10007;

int N, R[1001];
char S[1001];
const std::string JOI = "JOI";

int dp[1001][1<<3];

int main()
{
	scanf( "%d%s", &N, S );
	rep( i, N )
		R[i] = JOI.find(S[i]);

	rep( j, 1<<3 )
		dp[0][j] = j&1 && j>>R[0]&1;

	rep( i, N-1 ) rep( j, 1<<3 ) if( j>>R[i]&1 ) rep( k, 1<<3 ) if( k>>R[i+1]&1 && j&k )
		dp[i+1][k] = (dp[i+1][k]+dp[i][j]) % mod;

	printf( "%d\n", std::accumulate( dp[N-1], dp[N-1]+(1<<3), 0, []( int a, int b ){ return (a+b)%mod; } ) );

	return 0;
}

Measured memory_bytes: 1076
nmxy = gets.chomp.split
n = nmxy[0].to_i
m = nmxy[1].to_i
X = nmxy[2].to_i
Y = nmxy[3].to_i

x = gets.chomp.split
n.times do |i|
    x[i] = x[i].to_i
end

y = gets.chomp.split
m.times do |i|
    y[i] = y[i].to_i
end

war = true
((X + 1)..Y).each do |z|
    agreement = true
    n.times do |i|
        if x[i] >= z
            agreement = false
            break
        end
    end
    if agreement
        m.times do |i|
            if y[i] < z
                agreement = false
                break
            end
        end
    end
    if agreement
        war = false
        break
    end
end

puts war ? "War" : "No War"

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

int main() {
  string str;
  int len;
  int temp;

  while(getline(cin,str)) {
    len = str.size();
    for(int i = 0; i < len; i++) {
      if(str[i] == '@') {
	temp = str[i+1] - '0';
	for(int j = 0; j < temp; j++) {
	  cout << str[i+2];
	}
	i+=2;
      } else {
	cout << str[i];
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
MOD=10**9+7
def exp(n,x)
    x=x.to_s(2).split("").reverse
    ret=1
    k=n
    x.each do|bit|
      if bit=='1'
          ret*=k
          ret%=MOD
      end
      k=k*k
      k%=MOD
    end
    return ret
end
puts (exp(10,N)+exp(8,N)-exp(9,N)*2)%MOD

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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 998244353
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
vector< pair<int,int> >v;
#define cases int t;cin>>t;while(t--)

int main()
{
ll n,k;
cin>>n>>k;
ll ans = 0;

if(n>=k){
ll x = n/k;
ll tmp1 = n-x*k;
ll a1 = abs(tmp1 - k);
ll tmp = tmp1 + k;
ll a2 = abs(tmp - k);
ans = min(a1,a2);
}
else{
    ll a1 = n;
    ll a2 = abs(n-k);
    ans = min(a1,a2);
}

cout<<min(n , ans)<<endl;

}


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

struct Node{
  Node () :
    left (nullptr),
    right (nullptr),
    parent (-1),
    sibling (-1),
    id (0),
    depth (0),
    degree (0),
    height (0)
  {}
  int id;
  int depth;
  int parent;
  int sibling;
  int degree;
  int height;
  Node *right, *left;
  //right ==  && left
};


int FindRoot(Node* nodes, int n){
  for(int i=0; i<n; i++){
    if(nodes[i].parent == -1){
      return i;
    }
  }
  return n-1;
}
void ComputeDepth(Node*nodes, int idx, int depth){
  nodes[idx].depth = depth;
  if( nodes[idx].right != nullptr){
    ComputeDepth(nodes, nodes[idx].right->id, depth+1);
  }
  if( nodes[idx].left != nullptr){
     ComputeDepth(nodes, nodes[idx].left->id, depth+1);
  }
}

void ComputeHeight(Node *nodes, int n, int target, int idx, int height){
  nodes[target].height = std::max(nodes[target].height, height); //input max
  if(nodes[idx].left != nullptr){
    ComputeHeight(nodes, n, target, nodes[idx].left->id, height+1);
  }
  if(nodes[idx].right!= nullptr){
    ComputeHeight(nodes, n, target, nodes[idx].right->id, height+1);
  }
}

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

  Node nodes[n];
  for(int i=0; i<n; i++){
    int id, left, right;
    std::cin >> id >> left >> right;
    nodes[id].id = id;
    if( left != -1 ){
      nodes[id].left = &nodes[left];
      nodes[id].degree++;
      nodes[left].parent = id;
    }
    if( right != -1 ){
      nodes[id].right = &nodes[right];
      nodes[id].degree++;
      nodes[right].parent = id;
    }
    if( left != -1 && right != -1 ){
      nodes[left].sibling = right;
      nodes[right].sibling = left;
    }
  }

  //Get root index.
  int root = FindRoot(nodes, n);

  //Compute depth.
   ComputeDepth(nodes, root, 0);

   //Compute height.
   for(int i=0; i<n; i++){
     ComputeHeight(nodes, n, i, i, 0);
   }

  //output
  for(int i=0; i<n; i++){
    std::cout << "node " << nodes[i].id;
    std::cout << ": parent = " << nodes[i].parent;
    std::cout << ", sibling = " << nodes[i].sibling;
    std::cout << ", degree = " << nodes[i].degree;
    std::cout << ", depth = " << nodes[i].depth;
    std::cout << ", height = " << nodes[i].height << ", ";

    if(nodes[i]. parent == -1){ std::cout << "root" << std::endl; }
    else if( nodes[i].degree != 0 ){ std::cout << "internal node" << std::endl; }
    else { std::cout <<"leaf" << std::endl; }
  }
  return 0;
}



Measured memory_bytes: 3100
a,b,k = map(int, input().split())

s = set()
if a==b:
    s.add(a)
for x in range(a,min(a+k,b)):
    s.add(x)
for x in range(b,max(a,b-k),-1):
    s.add(x)

l = [x for x in s]
l.sort()
for x in l:
    print(x)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        cout << (n - 1) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    string s;
    cin>>s;
    int m=s.size();
    rep(i,m) cout<<'x';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	while(1)
	{
		char a,b;
		a=getchar();
		if((a!=EOF)&&(a!='\n'))
		{
			b=getchar();
			if((b!=EOF)&&(b!='\n'))
			{
				if((a!='h')||(b!='i'))
				{
					printf("No\n");
					return 0;
				}
			}
			else
			{
				printf("No\n");
				return 0;
			}
		}
		else break;
	}
	printf("Yes\n");
	return 0;
 } 

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

constexpr int mod = 2019;

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

    vector<ll> cnt(2019);
    ll cur = 0, powten = 1;
    cnt.at(cur)++;
    for (int i=n-1; i>=0; --i) {
        cur += (ll)(s.at(i)-'0') * powten % mod;
        cur %= mod;
        cnt.at(cur)++;
        powten *= 10;
        powten %= mod;
    }
    ll res = 0;
    for (int i=0; i<2019; ++i) {
        res += cnt.at(i) * (cnt.at(i)-1) / 2;
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


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

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

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while (ord[v] == -1) {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}


Measured memory_bytes: 5880
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n),b(m);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<m;i++) cin>>b[i];
  map<Int, Int> cnt;
  for(Int x:a) cnt[x]++;
  for(Int x:b) cnt[x]++;
  map<Int, Int> dup;
  for(auto p:cnt)
    if(p.second==2) dup[p.first]=1;
  cout<<dup.size()<<" "<<cnt.size()<<endl;
  for(auto p:dup) cout<<p.first<<endl;
  for(auto p:cnt) cout<<p.first<<endl;
  return 0;
}



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

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n+1);
	for(int i = 0; i < n+1;i++)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	long long ans = a[1] - a[0];
	for(int i = 2; i < n+1;i++)
	{
		ans = __gcd(a[i]-a[i-1],ans);
	}
	cout << ans << endl;
}


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

const int N = 1e6;
int n, c, k;
int t[N + 7];
bool pokr[N + 7];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> c >> k;
	for(int i = 1; i <= n; ++i) {
		cin >> t[i];
	}
	sort(t + 1, t + n + 1);
	
	int wynik = 0;	
	for(int i = 1; i <= n; ++i) {
		if(!pokr[i]) {
			int xc = c;
			wynik++;
			for(int j = i; j <= n; ++j) {
				if(xc == 0 || t[j] - t[i] > k) break;
				pokr[j] = 1;
				xc--;
			}
		}
	}
	cout << wynik << endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
void Y()
{
    cout<<"YES"<<endl;
}
void N()
{
    cout<<"NO"<<endl;
}
V<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>a;
    k=(a[0]-'0')*10;
    k+=(a[1]-'0');
    l=(a[2]-'0')*10;
    l+=(a[3]-'0');
    if(k>0 && l>0 && k<=12 && l<=12)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if( l>0 && l<=12)
    {
        cout<<"YYMM"<<endl;
    }
    else if(k<=12 && k>0)
    {
        cout<<"MMYY"<<endl;
    }
    else
    {
        cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
def cmb(n, r):
    if n-r<0:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

def main():
    n,a,b,*v=map(int,open(0).read().split())
    v.sort(reverse=1)
    m=sum(v[:a])/a
    print(m)
    n=v[a-1]
    x,y=v[:a].count(n),v.count(n)
#    print(x,y)
    ans=0
    if m==n and y-x>0:
        for i in range(x,x+b-a+1):
            ans+=cmb(y,i)
        print(ans)
    else:
        print(cmb(y,x))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5304
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	LL cnt = 0;
	rep(i, S.length()) if (S[i] == '0') ++cnt;

	out << std::min<LL>(cnt, S.length() - cnt) * 2 << std::endl;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        if ((Integer.parseInt(line[1])*10 + Integer.parseInt(line[2])) % 4 == 0) System.out.println("YES");
        else System.out.println("NO");
        
    }
}


Measured memory_bytes: 20692
using System;
class Program
{
	static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if(a > b)
        {
            int tmp = a;
            a = b;
            b = tmp;
        }

        for (int i = 0; i < b; i++)
        {
            Console.Write(a);
        }

		//出力
		Console.WriteLine();
	}
}


Measured memory_bytes: 11092
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut l_max = 0;
    let mut r_min = n;
    for _ in 0..m {
        let v = read_vec::<usize>();
        let (l, r) = (v[0], v[1]);
        l_max = max(l, l_max);
        r_min = min(r, r_min);
    }
    if r_min >= l_max {
        println!("{}", r_min - l_max + 1);
    } else {
        println!("0");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false); cin.tie(0)

using namespace std;

struct state{
    string br;
    bool* contains;
    state(string br, bool* contains){
        this->br = br;
        this->contains = contains;
    }
};

string n;
string br[] = {"3", "5", "7"};
unordered_map<char, int> mapa;
int res;

void bfs(){
    mapa['3'] = 0;
    mapa['5'] = 1;
    mapa['7'] = 2;
    queue<state> que;
    bool container[] = {false, false, false};
    state st("", container);
    que.push(st);
    while (!que.empty()){
        state top = que.front();
        que.pop();
        for (int i = 0; i < 3; ++i){
            if ((top.br + br[i] <= n && top.br.size() == n.size() - 1) || top.br.size() < n.size() - 1){
                bool ccc[] = {false, false, false};
                for (int j = 0; j < top.br.size(); ++j){
                    ccc[mapa[top.br[j]]] = true;
                }
                ccc[i] = true;
                state novi(top.br + br[i], ccc);
                if (novi.contains[0] && novi.contains[1] && novi.contains[2]){
                    ++res;
                }
                que.push(novi);
            }
        }
    }
}


int main()
{
    IOS;
    cin >> n;
    bfs();
    cout << res;
    return 0;
}


Measured memory_bytes: 1792
N, K = map(int, input().split(' '))
R, S, P = map(int, input().split(' '))
T = list(input())

U = []
for t in T:
    if t == 'r':
        u = 'p'
    elif t == 's':
        u = 'r'
    else:
        u = 's'
    U.append(u)

ans = 0
for i in range(N):
    if i >= K and U[i] == U[i - K]:
        U[i] = ''
    else:
        if U[i] == 'r':
            ans += R
        elif U[i] == 's':
            ans += S
        elif U[i] == 'p':
            ans += P

print(ans)


Measured memory_bytes: 10584
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int bit(int n, int th) {
	return (n >> th) & 1;
}
int main() {
	int n, m;
	cin >> n >> m;
	auto cake = mat(ll, 3, n, 0);
	auto tmpcake = mat(ll, 3, n, 0);
	rep(i, 0, n) {
		rep(j, 0, 3)cin >> cake[j][i];
	}
	ll ma = 0;
	rep(com, 0, 8) {
		rep(i, 0, 3) {
			int sign = (bit(com, i) ? -1 : 1);
			rep(j, 0, n) {
				tmpcake[i][j] = sign*cake[i][j];
			}
		}
		vector<ll>sum(n,0);
		rep(j, 0, n) {
			rep(i, 0, 3) {
				sum[j] += tmpcake[i][j];
			}
		}
		sort(all(sum));
		ll whole = 0;
		rep(k, 0, m)whole += sum[k];
		ma = max(ma, abs(whole));

	}
	cout << ma << endl;;
	return 0;
}





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

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

using namespace std;
using ll = long long;

int main(void)
{
    int str;
    int one = 0;
    int seven = 0;
    int nine = 0;
    int four = 0;
    rep(i, 4)
    {
        cin >> str;
        if (str == 1)
        {
            one = 1;
        }
        else if (str == 9)
        {
            nine = 1;
        }
        else if (str == 7)
        {
            seven = 1;
        }
        else if (str == 4)
        {
            four = 1;
        }
    }
    if (one == 1 && seven == 1 && nine == 1 && four == 1)
    {
        cout << "YES" << endl;
    }
    else if (one == 1 || seven == 1 || nine == 1 || four == 1)
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#import <Foundation/Foundation.h>

int main() {
    @autoreleasepool {
        long N;
        scanf("%ld", &N);
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        for (long i=0;i<N;i++) {
            long a;
            scanf("%ld", &a);
            NSNumber *count = [dic objectForKey:@(a)];
            [dic setObject:@(count ? count.integerValue+1 : 1) forKey:@(a)];
        }
        NSInteger count = 0;
        for (NSNumber *num in dic) {
            NSInteger i = num.integerValue;
            NSInteger a = [[dic objectForKey:num] integerValue];
            count += (a>=i) ? (a-i) : a;
        }
        printf("%ld", count);
    }
}



Measured memory_bytes: 15972
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String X = sc.next();
		String Y = sc.next();
		char[] x = X.toCharArray();
		char[] y = Y.toCharArray();
		if (x[0] < y[0])
			System.out.println("<");
		else if (x[0] == y[0])
			System.out.println("=");
		else if (x[0] > y[0])
			System.out.println(">");

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

bool cmp(pair<int,int> a,pair<int,int> b){
    return a.second<b.second;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N,M;
cin>>N>>M;

vector<pair<int,int>> req;

rep(i,M){
    int a,b;
    cin>>a>>b;
    req.pb(mp(a,b));
}

sort(req.begin(),req.end(),cmp);

int res=0;
int et=0;
rep(i,M){
    if(req[i].first>=et){
      et=req[i].second;
      ++res;   
    }
}
cout<<res<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n,a;
    cin>>n;
  vector<int> x;
  for(int i=0;i<n;i++){
    cin>>a;
    x.push_back(a);
  }

  sort(x.begin(),x.end());
  cout<<x[n-1]-x[0];
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Edge {
    int src,dst,cost;
};
bool operator<(const Edge &e,const Edge &f) {
    return (e.cost != f.cost)?e.cost>f.cost:e.src<f.src;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int L;
inline int idx(int a,int l) { return a*L+l; }

void dijkstra(const Graph &g,int s,vector<int> &dist) {
    const int n = g.size();
    for(int i=0; i<dist.size(); ++i)
        dist[i] = 1<<29;

    vector<int> prev(n, -1);

    priority_queue<Edge> q;
    q.push((Edge){-2,s,0});
    dist[s] = 0;

    while(!q.empty()) {
        Edge e = q.top(); q.pop();

        if(prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        //cout<<(e.dst/L)<<","<<(e.dst%L)<<" : "<<e.cost<<endl;

        for(int i=0; i<g[e.dst].size(); ++i) {
            int w = g[e.dst][i].dst;
            if(dist[w] > dist[e.dst]+g[e.dst][i].cost) {
                dist[w] = dist[e.dst]+g[e.dst][i].cost;
                q.push((Edge){e.dst,w,dist[w]});
            }
        }
    }
}

int main() {
    int n,m,l;
    int a,b,d,e;
    while(cin>>n>>m>>l, n|m|l) {
        L = l+1;
        Graph g(n*L);
        for(int i=0; i<m; ++i) {
            cin>>a>>b>>d>>e; a--,b--;
            for(int j=0; j<=l; ++j) {
                g[idx(a,j)].push_back((Edge){idx(a,j),idx(b,j),e});
                g[idx(b,j)].push_back((Edge){idx(b,j),idx(a,j),e});
                if(j >= d) {
                    g[idx(a,j)].push_back((Edge){idx(a,j),idx(b,j-d),0});
                    g[idx(b,j)].push_back((Edge){idx(b,j),idx(a,j-d),0});
                }
            }
        }

        vector<int> dist(n*L, 0);
        dijkstra(g,l,dist);

        int ans = 1<<29;
        for(int i=0; i<=l; ++i) {
            ans = min(ans, dist[idx(n-1,i)]);
        }
        cout<<ans<<endl;
    }
}

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

public class  Main{
	static long[]memo;
	static int mod=(int)1e9+7;
	static boolean[]broken;
	static long dp(int i) {
		if(i==memo.length)return 1l;
		if(i>memo.length)return 0;
		if(memo[i]!=-1)return memo[i];
		if(broken[i]) {
			return memo[i]=0;
		}
		return memo[i]=(dp(i+1)+dp(i+2))%mod;
	}
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        int m=sc.nextInt();
        broken=new boolean[1000000];
        for(int i=0;i<m;i++)broken[sc.nextInt()]=true;
        memo=new long[n];Arrays.fill(memo, -1);
        pw.println(dp(0));
        pw.flush();
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

#define INT_MAX 2147483647

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int* binary_search(int* array, size_t size, int value)
{
    int lower = 0;          // 探索範囲の下限の添字
    int upper = (int)size;  // 探索範囲の上限の添字 + 1

    while( lower < upper ){  // 上限と下限が逆転したら終わり
        // 中央の位置を求める
        int mid = (lower + upper) / 2;

        if( array[mid] < value ){
            lower = mid + 1;  // 次は中央より後ろを調べるため、下限を変更
        }
        else{
            // ここに来るケースには、目的の値と同じ場合を含んでいる
            // そのため、upper = mid - 1; ではない
            upper = mid;  // 次は中央より手前を調べるため、上限を変更
        }
    }

    // 目的の値を発見している場合も、発見できなかった場合も、
    // ここに来ることになるので、ここで最終的な確認を行う。
    // lower == upper は、array が空の場合への備え。
    if (lower == upper && array[lower] == value){
        return &array[lower];
    }

    return NULL;
}

int main()
{
    int n,x[200000],y[200000],i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)scanf("%d",&x[i]);

    for (i = 0; i < n; i++)y[i] = x[i];
    qsort(y,n,sizeof(int),asc);
    printf("\n");
    for (i = 0; i < n; i++)
    {
        if(n / 2 > binary_search(y,n,x[i]) - y)printf("%d\n",y[n / 2]);else printf("%d\n",y[n / 2 - 1]);
    }
}

Measured memory_bytes: 3704