akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
ll n,k,i,j,f[nmax],in[nmax],x,rs,a[nmax],t;
ll pw(ll x,ll p)
{
	ll ans=1;
	while(p)
	{
		if(p&1LL)ans=(ans*x)%mod;
		x=(x*x)%mod;
		p>>=1LL;
	}
	return ans;
}
ll cb(int x,int y)
{
	return f[x]*in[y]%mod*in[x-y]%mod;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	f[0]=in[0]=1;
	for(i=1;i<=n;i++)
	{
		f[i]=(f[i-1]*i)%mod;
		in[i]=pw(f[i],mod-2);
	}
	for(i=1;i<=n;i++)
	{
		for(j=i;j<=n;j++)if(a[j]!=a[i])break;
		j--;
		if(j>=k)
		{
			for(t=1;t<=min(j-i+1,k);t++)
			{
				if(k-t>i-1)continue;
				x=cb(j-i+1,t)*cb(i-1,k-t)%mod*a[i]%mod;
				rs=(rs+x+mod)%mod;
			}
			/*x=f[j-1]*in[k-1]%mod*in[j-k]%mod*(j-i+1)%mod*a[i]%mod;
			cout<<x<<endl;
			rs=(rs+x+mod)%mod;*/
		}
		if(n-i+1>=k)
		{
			for(t=1;t<=min(k,j-i+1);t++)
			{
				if(k-t>n-j)continue;
				x=cb(j-i+1,t)*cb(n-j,k-t)%mod*a[i]%mod;
				rs=(rs-x+mod)%mod;
			}
			/*x=f[n-i]*in[k-1]%mod*in[n-i-k+1]%mod*(j-i+1)%mod*a[i]%mod;
			cout<<x<<endl;
			rs=(rs-x+mod+mod)%mod;*/
		}
		i=j;
	}    
	cout<<rs<<endl;                                      
	return 0;
}


Measured memory_bytes: 2560
import sys

readline = sys.stdin.readline

def myindex(l, s):
    if s in l:
        return l.index(s)
    else:
        return len(l)

def main():
    S = list(readline()[:-1])
    T = list(readline()[:-1])
    tmpS = []; tmpT = []
    cntS = 0; cntT = 0
    flag = True
    for i in range(len(S)):
        cntS = myindex(tmpS, S[i])
        cntT = myindex(tmpT, T[i])
        tmpS.append(S[i])
        tmpT.append(T[i])
        if cntS != cntT:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9776
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long ll;

ll dp[55][55][2500];//(x1~xj　k枚 合計をsにする　選び方の総数)

int main(){
  int n,a;
  int x[51];
  cin>>n>>a;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }

  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;

  ll ret=0;

  for(int i=1;i<n+1;i++){
    for(int j=0;j<i+1;j++){
      for(int k=0;k<2501;k++){
        dp[i][j][k]+=dp[i-1][j][k];
        if(j>=1&&k>=x[i-1]){
          dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]];
        }
      }
    }
  }
  for(int i=1;i<n+1;i++){
    ret+=dp[n][i][a*i];
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 59900
# Problem E - Dividing Chocolate

# input
H, W, K = map(int, input().split())
board = [[0]*W for i in range(H)]
for i in range(H):
    s = list(input())
    for j in range(W):
        board[i][j] = int(s[j])

# initialization
min_divide = 10**15

# pattern search
for i in range(2**(H-1)):
    # bit search
    h_pattern = [0]*(H-1)
    group_count = 1
    h_count = 0
    w_count = 0
    for j in range(H-1):
        if((i>>j)&1):
            h_pattern[j] = 1
            group_count += 1
            h_count += 1

    is_ok = True
    group_sum = [0]*group_count
    for w in range(W):
        cur_count = [0]*group_count
        cur_count_num = 0
        # 列そのものが条件を満たしているかチェック
        for h in range(H):
            if board[h][w]==1:
                cur_count[cur_count_num] += 1

            if cur_count[cur_count_num]>K:
                is_ok = False
                break

            if h<H-1 and h_pattern[h]==1:
                cur_count_num += 1

        if not is_ok:
            break

        # 現在の列をグループカウントに入れる
        is_smaller = True
        if w==0:
            is_smaller = True
        else:
            for c in range(group_count):
                if group_sum[c]+cur_count[c]>K:
                    is_smaller = False
        if is_smaller:
            for c in range(group_count):
                group_sum[c] += cur_count[c]
        else:
            # wで区切る
            for c in range(group_count):
                group_sum[c] = cur_count[c]
            w_count += 1

    if not is_ok:
        is_ok = True
        continue

    # update
    min_divide = min(min_divide, h_count + w_count)

# output
print(min_divide)


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

int n,m;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();m=rd();
	if (m<=(n+1)/2) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    if (N % 2) cout << N / 2 << endl;
    else cout << (N - 1) / 2 << 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()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i=l; i<=r; i++) ans += (i%d == 0);
    cout << ans << endl;
}

Measured memory_bytes: 3644
/**
 * @author torith
 * @date 2018-10-12
 */

#include <bits/stdc++.h>

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;
    if (a > 0){
        cout << "Positive" << "\n";
        return 0;
    }else if((b == 0) || (a == 0) || (a < 0 && b > 0)){
        cout << "Zero" << "\n";
        return 0;
    }

    if((min(0,b) - a) % 2 == 0){
        cout << "Negative" << "\n";
    }else{
        cout << "Positive" << "\n";
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 1000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------



int main() {

  string s;
  cin >> s;

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

  if(s==t[0]) cout << t[1];
  else if(s==t[1]) cout << t[2];
  else cout << t[0];

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <sstream>
#include <queue>
#include <iomanip>
#define FRER() freopen("in.txt","r",stdin);
#define FREW() freopen("out.txt","w",stdout);
#define clr(str,x) memset(str,x,sizeof(str))

using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int INF=0x3f3f3f3f;
ll a[maxn],s[maxn],next[maxn];


int main()
{

    ll n,t; scanf("%lld %lld",&n,&t);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

    s[2]=a[1];
    for(int i=3;i<=n;i++) s[i]=s[i-1]+a[i-1];

    next[1]=a[1];
    for(int i=2;i<=n;i++)
    {
        if(a[i]<=next[i-1]) next[i]=next[i-1];
        else next[i]=a[i];
    }

    ll cnt=t/a[1]+1;
    printf("%lld\n",cnt);
    for(int i=2;i<=n;i++)
    {
        cnt=(t-s[i])/next[i];
        if(cnt<0)
        {
            printf("1\n");
            continue;
        }
        cnt++;
        int tt=(t-s[i])%next[i];
        if(tt>=a[i]) cnt++;
        printf("%lld\n",cnt);
    }
    return 0;
}



Measured memory_bytes: 5572
n = int(input())
a = list(map(int, input().split()))

zero = 0
two = 0
four = 0

for i in a:
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1
    else:
        zero += 1

if two == 0:
    if four >= zero - 1:
        print('Yes')
    else:
        print('No')

else:
    if four >= zero:
        print('Yes')
    else:
        print('No')






Measured memory_bytes: 14252
def main():
    N, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(N)]    
    cnt = 0
    for i in range(len(A)-1):
        for j in range(i+1, len(A)):
            a1 = A[i]
            a2 = A[j]
            dist = 0
            for x, y in zip(a1, a2):
                dist += (x-y)**2
            dist_sqr = dist**0.5
            if dist_sqr == int(dist_sqr):
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


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

using namespace std;
using namespace __gnu_pbds;

const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int mod = 998244353;

int H,W,K;
char pic[307][307];
char res[307][307];
int ans;

void paint(int status_x,int status_y){
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			res[i][j] = pic[i][j];
		}
	}
	for(int i=0;i<H;i++){
		if(status_x&(1<<i)){
			for(int j=0;j<W;j++){
				res[i][j] = '.';
			}
		}
	}
	for(int j=0;j<W;j++){
		if(status_y&(1<<j)){
			for(int i=0;i<H;i++){
				res[i][j]='.';
			}
		}
	}
}

void calc(){
	int cnt=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cnt += (res[i][j]=='#');
		}
	}
	ans += (cnt==K);
}

void debug(){
	printf("\n");
	for(int i=0;i<H;i++){
		printf("%s\n",res[i]);
	}
}
int main(){
#ifndef ONLINE_JUDGE
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
#endif
	scanf("%d%d%d",&H,&W,&K);
	for(int i=0;i<H;i++){
		scanf("%s",pic[i]);
	}
	for(int i=0;i<(1<<H);i++){
		for(int j=0;j<(1<<W);j++){
			paint(i,j);
			calc();
			//debug();	
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    int[] A= new int[N];
	    int[] B= new int[N];

        for (int i=0; i<N; i++) {
        	A[i]=gi();
        	B[A[i]-1] = i;
        }

        for (int i=0; i<N;i++) {
        	if(i!=0) System.out.print(" ");
        	System.out.print(B[i]+1);
        }

	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 60724
n = gets.chomp.to_i
arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

MAX = 10 ** 10

min_x = MAX
min_y = MAX
max_x = 0
max_y = 0
arr.each do |(x, y)|
  min_x = x if x < min_x
  max_x = x if x > max_x
  min_y = y if y < min_y
  max_y = y if y > max_y
end

min1 = MAX
min2 = MAX
min3 = MAX
min4 = MAX
p_arr = [nil, nil, nil, nil]
arr.each do |(x, y)|
  tmp = (x - min_x).abs + (y - min_y).abs
  if tmp < min1
    p_arr[0] = [x, y]
    min1 = tmp
  end
  tmp = (x - min_x).abs + (y - max_y).abs
  if tmp < min2
    p_arr[1] = [x, y]
    min2 = tmp
  end
  tmp = (x - max_x).abs + (y - min_y).abs
  if tmp < min3
    p_arr[2] = [x, y]
    min3 = tmp
  end
  tmp = (x - max_x).abs + (y - max_y).abs
  if tmp < min4
    p_arr[3] = [x, y]
    min4 = tmp
  end
end

max = 0
p_arr.each do |(x1, y1)|
  p_arr.each do |(x2, y2)|
    tmp = (x1 - x2).abs + (y1 - y2).abs
    max = tmp if tmp > max
  end
end
puts max


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

namespace mondai0035
{
	class Program
	{
		static void Main(string[] args)
		{
			/*for( int i = 0; i <= 360; i += 10 ) {
				Console.WriteLine( "{0}={1:f5}", i, i / 180.0 * Math.PI );
			}
			return;*/
			
			while( true ) {
				var	str	= Console.ReadLine();
				if( str == null ) {
					break;
				}
				var	p	= Array.ConvertAll( str.Split( ',' ), s => double.Parse( s ) );
				
				var	angle	= new double[ 4 ];
				for( int i = 0; i < 4; i++ ) {
					var	x	= p[ ((i + 1) % 4) * 2 ] - p[ i * 2 ];
					var	y	= p[ ((i + 1) % 4) * 2 + 1 ] - p[ i * 2 + 1 ];
					angle[ i ]	= Math.Atan2( y, x );
					//Console.WriteLine( "{0}:{1:f5}", i, angle[ i ] );
				}
				
				int	cnt	=0;
				for( int i = 0; i < 4; i++ ) {
					var	d	= angle[ (i + 1) % 4 ] - angle[ i ];
					if( Math.Abs( d ) > Math.PI ) {
						if( d < 0.0f ) { d	+= Math.PI * 2.0; }
						else           { d	-= Math.PI * 2.0; }
					}
					if( Math.Sign( d ) > 0.0 ) {
						cnt++;
					} else {
						cnt--;
					}
				}

				if( (cnt == 4) || (cnt == -4)) {
					Console.WriteLine( "YES" );
				} else {
					Console.WriteLine( "NO" );
				}
			}
		}
	}
}

Measured memory_bytes: 5820
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic={}
for i in range(len(a)):
    dic.setdefault(a[i],0)
    dic[a[i]]+=1
answer=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    if b not in dic:
        answer = answer
    if c not in dic:
        answer = answer
    dic.setdefault(b,0)
    dic.setdefault(c,0)
    dic[c]+=dic[b]
    answer=answer+dic[b]*c-dic[b]*b
    dic[b] = 0
    print(answer)

Measured memory_bytes: 23596
fn main() {
    let n = read::<u32>();
    yn(n % 10 == n / 100);
}

#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
int w,a,b;
  cin >> w >> a >> b;
  if(a > b && a > b + w){
  	cout << a - b - w << endl;;
  }
  else if(a < b && a + w < b){
  cout << b - a - w << endl;
  }
  else 
    cout << 0 << endl;
}


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

void push(int);
int pop();

int S_num[1000],top;

int main(){
  int num_a,num_b;
  char str_num[100];

  top=0;

  while(scanf("%s",str_num)!=EOF){
    if(str_num[0]=='+'){
      num_a=pop();
      num_b=pop();
      push(num_a+num_b);
    }else if(str_num[0]=='-'){
      num_b=pop();
      num_a=pop();
      push(num_a-num_b);
    }else if(str_num[0]=='*'){
      num_a=pop();
      num_b=pop();
      push(num_a*num_b);
    }else{
      push(atoi(str_num));
    }
  }
 
  printf("%d\n",pop());

  return 0;
}

void push(int x){
  top++;
  S_num[top]=x;
}

int pop(){
  top--;
  return S_num[top+1];
}

Measured memory_bytes: 552
import sys
sys.setrecursionlimit(10**7)

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n-1)]

neighbor = [[] for _ in range(n+1)]
for edge in lst:
    neighbor[edge[0]].append((edge[1], edge[2]))
    neighbor[edge[1]].append((edge[0], edge[2]))

    
color = [-1] * (n+1)

#startをbwで塗る
def dfs(start, bw):
    color[start] = bw
    for pair in neighbor[start]:
        if color[pair[0]] != -1:
            continue
        elif pair[1] % 2 == 0:
            dfs(pair[0], bw)
        else:
            dfs(pair[0], (bw + 1) % 2)

dfs(1, 0)
        
for i in range(1, n+1):
    print(color[i])

Measured memory_bytes: 91876
#include<iostream>
using namespace std;
int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      int d1 = j / 10;
      int d2 = j % 10;
      ans += (d1 >= 2 && d2 >= 2 && d1 * d2 == i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
ans = 0
lpr = min(a) + min(b)
dcp = []

for i in range(M):
    indexA = xyc[i][0] - 1
    indexB = xyc[i][1] - 1
    dcp.append(a[indexA] + b[indexB] - xyc[i][2])

ans = min(min(dcp), lpr)
print(ans)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b;

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);

  if (a >= 13) {
    printf("%d\n", b);
  }
  else if (6 <= a && a <= 12) {
    printf("%d\n", b / 2);
  }
  else {
    printf("%d\n", 0);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int ans = 1;
	string s2 = s.substr(0,1);
	s = s.substr(1);
	int n = s.length();
	while(n > 1){
		string s3 = s.substr(0,1); 
		if(s2 == s3){
			s2 = s.substr(0,2);
			ans ++;
			s = s.substr(2);
			n = s.length();
		}
		else{
			s2 = s.substr(0,1);
			ans ++;
			s = s.substr(1);
			n = s.length();
		}
	}
	if(s.length() == 1){
		if(s != s2)
			ans ++ ;
	}
	cout << ans << endl;
}

Measured memory_bytes: 772
import math

n, m = map(int, input().split())

if abs(n - m) > 1:
    print(0)
else:
    t = math.factorial(n)
    s = math.factorial(m)

    if abs(n - m) == 1:
        print(t * s % (10 ** 9 + 7))
    else :
        print(t * s * 2 % (10 ** 9 + 7))


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}

int main(){
  ll n;
  cin >> n;
  int ans=0;
  map m=prime_factor(n);
  for(auto i:m){
    int c=i.second;
    int b=1;
    while(c>=b){
      c-=b;
      b++;
      ans++;
    }
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 3640
{-
  A,C,G,T にそれぞれ 0,1,2,3 を対応させ、4進で表現する。

  状態を文字列の最後3文字の状態遷移を考える。（状態数 4^3 = 64）
  遷移先が pqr だとすると、入力は r で遷移元は 0pq, 1pq, 2pq, 3pq

  どの遷移元からも許されない遷移先は 021, 012, 102
  遷移元 0pq からだけは許されない遷移先は 132, 112, 212, 312
-}

ds1 = [d (0,2,1), d (0,1,2), d (1,0,2)]
ds2 = [d (1,3,2), d (1,1,2), d (2,1,2), d (3,1,2)]

d (a,b,c) = 16 * a + 4 * b + c

dp3 = [if elem i ds1 then 0 else 1 | i <- [0..63]]

f xs = map g [0..63] where
  g i
    | elem i ds1 = 0
    | elem i ds2 = h [16,32,48]
    | otherwise = h [0,16,32,48]
    where
      pq = i `div` 4
      h os = sum [xs !! (pq + o) | o <- os] `mod` 1000000007

solve n =  (`mod` 1000000007) $ sum $ (!! (n - 3)) $ iterate f dp3

main = do
  n <- read <$> getLine
  print $ solve n

Measured memory_bytes: 1276
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)


function main()
	n = readline() |> parseInt
	if n == 3
		println("2 5 63")
	else
		e = [2,10,3,9,4,8,6,12]
		o = [6,2,10,3,9,4,8,12]
		c = 0
		mod = 1
		x = Int[]
		if n%2 == 1
			x = o
		else
			x = e
		end
		for i in 1:n-1
			print(x[mod]+12*c, " ")
			mod += 1
			if mod > 8
				c += 1
				mod = 1
			end
		end
		println(x[mod]+12*c)
	end
end
main()

Measured memory_bytes: 165240
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in map(str, range(1, N + 1)):
        cnt[int(n[0])][int(n[-1])] += 1

    print(np.sum(cnt * cnt.T))


if __name__ == '__main__':
    main()


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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int n;
  cin>>n;
vector<int>ans(10001);
for(int x=1;x<=100;x++){
  for(int y=1;y<=100;y++){
    for(int z=1;z<=100;z++){
        int t=x*x+y*y+z*z+x*y+y*z+z*x;
        if(t<=10000)ans.at(t)++;
    }
  }
}
for(int i=1;i<=n;i++){
  cout<<ans[i]<<endl;
}
}


Measured memory_bytes: 3676
n=int(input())
num1=0
num2=0
num3=0
num4=0
for i in range(n):
    x=input()
    if x=="AC":
        num1+=1
    elif x=="WA":
        num2+=1
    elif x=="TLE":
        num3+=1
    elif x=="RE":
        num4+=1
print(f"AC x {num1}\nWA x {num2}\nTLE x {num3}\nRE x {num4}")        


Measured memory_bytes: 9128
/*
Author : N_o_o_B
Created : June 22 2020 12:23:35 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const ll mod=998244353;
// const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int x;
    cin >> x;
    int ang = 0;
    for(int j=x;;j+=x){
        ang += x;
        ang %= 360;
        if(ang == 0){
            cout << j/x << endl;
            return 0;
        }
    }
    


    time_taken();
    return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <list>
#include <unordered_map>
#include <utility>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;
int R,C,N;

int length(int x,int y){
    if(y==0){
        return x;
    }
    if(x==0){
        return 2*(R+C)-y;
    }
    if(x==R){
        return R+y;
    }
    return 2*R+C-x;
}

bool comp(pair<int,int>& p1,pair<int,int>& p2){
    return p1.first - p2.first;
}

int main() {
    cin>>R>>C>>N;
    vector<pair<int,int>> border;

    REP(i,N){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if ((x1%R==0||y1%C==0)&&(x2%R==0||y2%C==0)){
            border.push_back(pair<int,int>(length(x1,y1),i+1));//   [length(x1,y1)]=i+1;
            border.push_back(pair<int,int>(length(x2,y2),i+1));
        }
    }
    sort(border.begin(),border.end());

    stack<int> pos;
    pos.push(-1);

    REP(i,border.size()) {
        if(pos.top()!=border[i].second){
                pos.push(border[i].second);
            }else{
                pos.pop();
            }
    }

    if(pos.size()==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sp std::fixed<<std::setprecision
#define MOD 1000000007
#define MAX 1e18
#define N 1000005
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll cnt = 0;
    cin >> s;
    ll freq[26];
    memset( freq , 0 , sizeof(freq));
    for( int i = 0 ; i < 4 ; i++ )
        freq[s[i] - 'A']++;
    for( int i = 0 ; i < 26 ; i++ )
    {
        if( freq[i] == 2 )
            cnt++;
    }
    if( cnt == 2 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
SCORE=[]
preSCORE=0
OUTcount=0
BASE=[False]*3
n=int(input())
for i in range(n):
    while OUTcount<3:
        spam=input()
        if 'HIT' in spam:
            if BASE[2]==True:
                preSCORE+=1
            BASE[2]=BASE[1]
            BASE[1]=BASE[0]
            BASE[0]=True
        elif 'OUT' in spam:
            OUTcount+=1
        elif 'HOMERUN' in spam:
            preSCORE+=sum(x for x in BASE)+1
            BASE=[False]*3
    SCORE.append(preSCORE)
    BASE=[False]*3
    OUTcount=0
    preSCORE=0
for i in SCORE:
    print(i)

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

int main()
{
  long long X;
  cin >> X;
  long long B = 100;  //預金
  int n = 0;    //n年度

  while(B<X){
    B += B / 100;
    n++;
  }

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 3644
n,k = map(int,input().split())
from itertools import accumulate
a = [i for i in range(n+1)]
b = [i for i in reversed(range(n+1))]

ac_a = list(accumulate(a))
ac_b = list(accumulate(b))
ans = 0

for i in range(k-1,n+1):
    ans += ac_b[i]-ac_a[i]+1

mod=10**9+7
ans%=mod
print(ans)

Measured memory_bytes: 46116
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  int x = 0,x_max = 0,N;
  char S[110];
  cin>>N;

  REP(i,N){
    cin>>S[i];
  }

  REP(i,N){
    if (S[i] == 'I') {
      x++;
    }

    if (S[i] == 'D') {
      x--;
    }

    if (x_max < x) {
      x_max = x;
    }

  }

  cout<<x_max;

  return 0;
}


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

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] h = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = in.nextInt();
        }
        if (n == 1) {
            System.out.println(0); return;
        }
        int[] min = new int[n];
        Arrays.fill(min, Integer.MAX_VALUE);
        min[0] = 0;
        min[1] = Math.abs(h[1] - h[0]);
        for (int i = 2 ; i < n ; i++) {
            for (int j = Math.max(0, i - k) ; j < i ; j++) {
                min[i] = Math.min(min[i], min[j] + Math.abs(h[i] - h[j]));
            }
        }
        System.out.println(min[n-1]);
    }
}


Measured memory_bytes: 50992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
#define itn int
signed main(void){
    int k,x; cin>>k>>x;
    int st = x - k + 1;
    int end = x + k -1;
    for(int i=st;i<=end;i++){
    cout<< i<<' ';
    }
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

calc :: [(Int, Int)] -> Int -> [Int]
calc [] _ = []
calc ((ph, pc):phcs) h = cost : calc phcs h 
  where cost = pc + abs (ph - h)

solve :: [Int] -> [(Int, Int)] -> [Int]
solve [] _ = []
solve (h:hs) aphcs@((ph, pc):phcs) = cost : next
  where cost = minimum $ calc aphcs h
        next = solve hs $ phcs ++ [(h, cost)]

main :: IO ()
main = do
  [n, k] <- readIntsLine
  (h:hs) <- readIntsLine
  print . last . solve hs $ replicate k (h, 0)


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

int main(){
    int n, m;

    while(cin >> n >> m, n != 0 || m != 0){
        vector<int> tl(n+m+1);
        int max = 0;
        tl[0] = 0;
        for(int i=1; i<tl.size(); i++){
            cin >> tl[i];
        }

        sort(tl.begin(), tl.end());

        for(int i=0; i<tl.size()-1; i++){
            int tmp = tl[i+1] - tl[i];
            if(max < tmp){
                max = tmp;
            }
        }


        cout << max << endl;
    }

    return 0;
}

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

std::vector<int> L;

int main(int argc, char const* argv[])
{
    int N, X;
    std::cin >> N >> X;
    int tmp;
    while (std::cin >> tmp) {
        L.push_back(tmp);
    }

    int sum = 0;
    int bound = 1;
    for (int i = 0; i < N; i++) {
        sum += L[i];
        if (sum > X) {
            break;
        }
        else {
            bound++;
        }
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            String x = sc.next();

            if(x.equals("0"))break;

            int sum = 0 ,i;

            for(i = 0;i < x.length();i++){
                sum = sum + x.charAt(i) - 48;
            }
            
            System.out.printf("%d\n",sum);
            
        }
    }
}


Measured memory_bytes: 26604
import java.util.Scanner;
import java.util.function.Function;

/**
 * Created by btk on 2017/10/13.
 */
public class Main {
   public static void main(String[] args){
       Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
       int k=sc.nextInt();
       long[] x = new long[n];
       long[] y = new long[n];
       for (int i = 0; i < n; i++) {
           x[i]=sc.nextLong();
           y[i]=sc.nextLong();
       }
       long ret=4123456789123456789l;
       for (int i = 0; i < n; i++) {
           for (int j = 0; j < n; j++) {
               for (int l = 0; l < n; l++) {
                   long lb=y[l];
                   long ub=1123456789;
                   final long xl=x[i];
                   final long xu=x[j];
                   final long yl=y[l];
                   Function<Long,Integer> calc=(m)->{
                       int sum=0;
                       for (int o = 0; o < n; o++) {
                           if(xl<=x[o]&&x[o]<=xu&&yl<=y[o]&&y[o]<=m){
                               sum++;
                           }
                       }
                       return sum;
                   };
                   if(calc.apply(ub)<k)continue;
                   while(ub-lb>1){
                       long m=(lb+ub)/2;
                       if(calc.apply(m)>=k)ub=m;
                       else lb=m;
                   }
                   ret=Math.min(ret,(xu-xl)*(ub-yl));

               }
           }
       }
       System.out.println(ret);
       sc.close();
   }
}


Measured memory_bytes: 41372
#!python3.8
# -*- coding: utf-8 -*-
# tokiomarine2020/tokiomarine2020_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    print(S[:3])
    return

main()


Measured memory_bytes: 9072
#include <iostream>
#include <string>

int main() {
  double a, b;
  std::cin >> a >> b;

  int d = a/b;
  int r = a - (b*d);
  double f = a/b;

  std::cout << d << " " << r << " " << std::fixed << f << std::endl;
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using Graph = vector<vector<bool>>;
int ans=0;
int N,M;

// 深さ優先探索
void dfs(const Graph &G, int v,vector<int> seen) {
    seen[v] = 1; // v を訪問済にする
    if(accumulate(seen.begin(),seen.end(),0)==N)ans++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v, seen); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
  vector<int> perm;
  for(int i=1; i<N; i++){
    perm.push_back(i);
  }
    Graph G(N,vector<bool>(N,false));
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
      a--;b--;
        G[a].at(b) = true;
        G[b].at(a) = true;
    }
  do{
      if(!G[0].at(perm.at(0))){continue;}
    for(int i=0; i<N-1; i++){
      if(i==(N-2)){ans++;break;}
      if(G[perm.at(i)].at(perm.at(i+1))){continue;}
      else{break;}
    }
  }while(next_permutation(perm.begin(),perm.end()));
    // 頂点 0 をスタートとした探索
  //vector<int> seen;
    //seen.assign(N, 0); // 全頂点を「未訪問」に初期化
    //dfs(G, 0, seen);
  cout << ans << endl;
}

Measured memory_bytes: 256
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
N = int(input())
S = input()

R=[]
G=set()
B=set()

from collections import defaultdict
Bd = defaultdict(lambda: -1)


for i in range(N):
	c = S[i]
	if c=='R': R.append(i)
	if c=='G': G.add(i)
	if c=='B': B.add(i)


p(R)
p(G)
p(B)

lenB = len(B)

ans=0
for i in R:
	for j in G:
		a = (i+j)/2
		b = (i*2-j)
		c = (j*2-i)
		
		x = lenB
		if (a in B): x -= 1
		if (b in B): x -= 1
		if (c in B): x -= 1
		
		ans += x

print(ans)


Measured memory_bytes: 9640
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, As):
    k = 0
    for a in As:
        k ^= a
    ans = []
    for a in As:
        ans.append(str(k ^ a))
    return " ".join(ans)


# assert(solve(4 , [20, 11, 9, 24]) == "26 5 7 22")
# assert(solve(2 , [0, 0]) == "0 0")
# assert(solve(2 , [0, 1]) == "1 0")
# assert(solve(2 , [1, 2, 4]) == "")
#
# print("OK")
if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 34076
#include<stdio.h>
#include<math.h>

int main(void)
{
        double a_len, b_len, c_deg;
        double c_len;
        double s_area, l_circum, h_hight;

        scanf("%lf%lf%lf", &a_len, &b_len, &c_deg);

        c_len = pow(a_len, 2) + pow(b_len, 2) - 2 * a_len * b_len * cos(c_deg * M_PI / 180);
        c_len = sqrt(c_len);

        l_circum = a_len + b_len + c_len;
        h_hight = b_len * sin(c_deg * M_PI / 180);

        s_area = l_circum / 2;
        s_area = s_area * (s_area - a_len) * (s_area - b_len) * (s_area - c_len);
        s_area = sqrt(s_area);

        printf("%lf\n%lf\n%lf\n", s_area, l_circum, h_hight);

        return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int p[4];
int t[4];

int main() {
	int i, j, k;
	
	cin >> n;
	rep(i, 4) cin >> t[i];
	rep(i, 4) cin >> p[i];
	
	int ans = 1145141919;
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 101) {
				int l = n - (i * p[0] + j * p[1] + k * p[2]);
				if (l < 0) l = 0;
				l = (l + p[3] - 1) / p[3];
				int res = i * t[0] + j * t[1] + k * t[2] + l * t[3];
				ans = min(ans, res);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	string str;
	cin >> str;
	long q;
	cin >> q;
	for (long i = 0; i < q; i++){
		long a = 0, b = 0;
		string p;
		string order;
		cin >> order;
		if (order == "print"){
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << endl;
		}
		else if (order == "reverse"){
			cin >> a >> b;
			string str2;
			str2 = str.substr(a, b - a + 1);
			reverse(str2.begin(), str2.end());
			str = str.replace(a, b - a + 1, str2);
		}
		else if (order == "replace"){
			cin >> a >> b >> p;
			str = str.replace(a, b - a + 1, p);
		}
	}
	return 0;
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll r,c; cin>>r>>c;
    string s;
    int dp[r][c];
    loop(i,r){
	    cin>>s;
	    loop(j,c){
	    	
	    	int &ret = dp[i][j];
	    	if(s[j]=='#'){ret=0; continue;}
	    	if(i==0 && j==0){
	    		ret = 1;
	    	}else if(i==0)ret = dp[i][j-1];
	    	else if(j==0) ret = dp[i-1][j];
	    	else{
	    		ret = dp[i][j-1] + dp[i-1][j];
	    	}
	    	ret %= mod;
	    }
	}
	pt(dp[r-1][c-1]);
}


/*


*/





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

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

  string S; cin >> S;
  ll N = S.size();
  if (S[N - 1] != 's') {
    cout << S << "s";
  } else {
    cout << S << "es";
  }
  return 0;
}

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

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


    int n, r;
    cin >> n >> r;

    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }


    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++)
typedef pair<int, int> P;

int n;
P robots[101010];

int main(){
  cin >> n;
  rep(i, n){
    int x, l;
    cin >> x >> l;
    robots[i].second = x - l;
    robots[i].first = x + l;
  }
  sort(robots, robots + n);
  //rep(i, n) cerr << robots[i].second << " " << robots[i].first << endl;
  int pos = -1000000000;
  int ans = 0;
  for(P x : robots){
    if(x.second >= pos){
      pos = x.first;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

char ansbuff[300];
char *ans;
int maxlen;

void max_substr(char *s1, char *s2, int l1, int l2){
  static int dp[330][330];
  REP(i,l1+1) REP(j,l2+1) dp[i][j] = 0;  
  REP(i,l1) REP(j,l2){
    if(s1[i] == s2[j]){
      dp[i+1][j+1] = dp[i][j] + 1;
    }
    dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
  }
  REP(i,l1) dp[i+1][l2] = max(dp[i+1][l2], dp[i][l2]);
  REP(j,l2) dp[l1][j+1] = max(dp[l1][j+1], dp[l1][j]);
  
  if(maxlen < dp[l1][l2]){
    int p1 = l1;
    int p2 = l2;
    ans = ansbuff + sizeof(ansbuff) - 1;

    maxlen = dp[l1][l2];

    while(p1 != 0 || p2 != 0){
      if(p1 != 0 && dp[p1-1][p2] == dp[p1][p2]){
	p1 = p1 - 1;
      }else if(p2 != 0 && dp[p1][p2-1] == dp[p1][p2]){
	p2 = p2 - 1;
      }else{
	assert(p1 != 0 && p2 != 0);
	*--ans = s1[p1-1];
	p1 = p1 - 1;
	p2 = p2 - 1;
      }
    }

    /*
    REP(i, l1) putchar(s1[i]);
    printf(" ");
    REP(i, l2) putchar(s2[i]);
    printf(" : %s\n", ans);
    */
  }
}

int main(){
  char buff[330];

  while(scanf("%s", buff), buff[0] != '#'){
    int len = strlen(buff);
    char *str1 = buff;

    maxlen = 0;
    for(char *str2 = buff + 1; *str2 != '\0'; str2++){
      int len1 = (int)(str2 - str1);
      int len2 = (int)(len  - len1);

      max_substr(str1, str2, len1, len2);
    }
    
    puts(ans);
  }

  return 0;
}

Measured memory_bytes: 1232
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		boolean ok = false;
		
		for(int i=0;i<100;i++) {
			for(int j=0;j<100;j++) {
				if(2*i+4*j==Y&&i+j==X) {
					
					ok = true;
					break;
				}
			}
		}
		if(ok) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 35896
#include <iostream>
#include <iomanip>
#include <stdexcept>

class SymbolException : public std::logic_error {
public:
    SymbolException(): std::logic_error("????????????????????????") {}
};

int main() {
  while(1){
    try{
      int x=0,y=0;
      char symbol;
      std::cin >> x >> symbol >> y;
      if(symbol == '?') break;
      switch(symbol){
        case '+':
          std::cout << (x+y) << std::endl;
          break;
        case '-':
          std::cout << (x-y) << std::endl;
          break;
        case '*':
          std::cout << (x*y) << std::endl;
          break;
        case '/':
          std::cout << (x/y) << std::endl;
          break;
        default:
          throw SymbolException();
          break;
      }
    }catch (const SymbolException& e) {
        std::cerr << e.what() << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3092
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner kb = new Scanner(System.in);

        double D = kb.nextDouble();
        double S = kb.nextDouble();
        double T = kb.nextDouble();

        if(D/S <= T)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

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

int main(int argc, char* argv[])
{
	string A,B;
	cin>>A>>B;
	int aLen=A.length();
	int bLen=B.length();
	if (aLen>bLen){
		cout<<"GREATER"<<endl;
		return 0;
	}else if (aLen<bLen){
		cout<<"LESS"<<endl;
		return 0;
	}else{
		int i;
		for (i=0;i<aLen;i++){
			if (A[i]>B[i]){
				cout<<"GREATER"<<endl;
				return 0;
			}else if (A[i]<B[i]){
				cout<<"LESS"<<endl;
				return 0;
			}
		}
		cout<<"EQUAL"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256