akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 10)
        cout << "error" << endl;
    else
        cout << a + b << endl;
}

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



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

	string s; cin >> s;
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
			continue;
		}
		else {
			cout << "No";
			return 0;
		}
	}
	for (int i = 1; i < s.size(); i += 2) {
		if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
			continue;
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    X,Y,Z,K = LMIIS()
    A = LMIIS()
    B = LMIIS()
    C = LMIIS()
    
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    ans = []
    for ai in range(X):
        for bi in range(Y):
            if ai * bi > K:
                break
            for ci in range(Z):
                if ai * bi * ci > K:
                    break
                
                ans.append(A[ai]+B[bi]+C[ci])
    ans.sort(reverse=True)
    for i in range(K):
        print(ans[i])


    
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 105176
#[test]
fn test_solve() {
    assert_eq!(solve("12\n"), "1\n");
    assert_eq!(solve("5\n"), "0\n");
    assert_eq!(solve("1000000000000000000\n"), "124999999999999995\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let mut n: u64 = sc.read();

    if n & 1 == 1 {
        return "0\n".to_string();
    }
    n >>= 1;
    let mut c = 0;
    while n >= 5 {
        n /= 5;
        c += n;
    }

    format!("{}\n", c)
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}

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

int main() {
    int N; cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    int ans[N];
    for (int i = 0; i < N; i++) ans[A[i] - 1] = i + 1;
    for (int i = 0; i < N; i++) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>}

int main(void){
	int n,i,S[100000],q,j,T,C = 0,M;
	scanf("%d",&n);
	for (i=0;i!=n;i++){
		scanf("%d",&S[i]);
	}
	for (i=0;i!=n;i++){
		for (j=0;j!=n;j++){
			if (S[i]<S[j]){
				M=S[i];
				S[i]=S[j];
				S[j]=M;
			}
		}
	}
	scanf("%d",&q);
	for (j=0;j!=q;j++){
		scanf("%d",&T);
		for (i=0;i<n;i++){
			if (S[i]==T){
				C++;
				break;
			}
		}
	}
	printf("%d\n",C);
	
	return 0;
}

Measured memory_bytes: 1076
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
    dp[0][0]=1.0;
    for(int i=0;i<n;++i){
        double p;cin>>p;
        for(int k=0;k<n;++k){
            dp[i+1][k] += dp[i][k] * (1.0-p);
            dp[i+1][k+1] += dp[i][k] * p;
        }
    }
    double res = 0;
    for(int i=0;i<=n;++i)if(i>n-i)res+=dp[n][i];
    cout<<setprecision(50)<<res<<endl;
    return 0;
}

Measured memory_bytes: 70656
N = int(input())
SP = []
for i in range(1,N+1):
    S,P = map(str,input().split())
    SP.append([S,int(P),i])
SP = sorted(SP, key=lambda x:x[1], reverse=True)
SP = sorted(SP, key=lambda x:x[0])
[print(SP[i][2]) for i in range(N)]


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


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

  if(b==1){
    cout << 0 << endl;
  }else if(a>b){
    cout << 1 << endl;
  }else{
    b = b-a;
    if(b%(a-1) == 0){
      cout << 1 + b/(a-1) << endl;
    }else{
      cout << 2 + b/(a-1) << endl;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
 
#define M 255
 
int main() {
  int n, c, t, ans;
  char buf[M+2];
  char a[M][M];
  while (1) {
    scanf("%d\n", &n);
    if (!n) break;
 
    for (int i=0; i<n; i++) {
      fgets(buf, sizeof(buf), stdin);
      for (int j=0; j<n; j++) {
        a[i][j] = (buf[j]=='0') ? 0 : 1;
      }
    }
 
    ans = 0;
    for (int i=0; i<n; i++) {
      c = 0;
      for (int j=0; j<n; j++) {
        if (a[i][j]) {
          ans = max(ans, ++c);
        } else {
          c = 0;
        }
      }
    }
    for (int i=0; i<n; i++) {
      c = 0;
      for (int j=0; j<n; j++) {
        if (a[j][i]) {
          ans = max(ans, ++c);
        } else {
          c = 0;
        }
      }
    }
    for (int s=0; s<2*n-1; s++) {
      c = 0;
      for (int i=0; i<n; i++) {
        t = s-i;
        if (t>=0 && t<n && a[i][t]) {
          ans = max(ans, ++c);
        } else {
          c = 0;
        }
      }
    }
    for (int d=-n+1; d<n; d++) {
      c = 0;
      for (int i=0; i<n; i++) {
        t = i+d;
        if (t>=0 && t<n && a[i][t]) {
          ans = max(ans, ++c);
        } else {
          c = 0;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2652
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.println(a*b + " " + (a+b)*2);
		scan.close();
	}
}

Measured memory_bytes: 17160
# -*- coding: utf-8 -*-
# 整数の入力
# スペース区切りの整数の入力
a, b, c = map(int, raw_input().split())

count = 0

while b > 0:
    if b-a <0: break
    b  = b - a
    count += 1

    if count == c: break

print count


Measured memory_bytes: 2568
#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
const int inf = 1e9 + 7;

#define nd second
#define st first
#define mp make_pair
#define pb push_back

const int N = 1e6 + 6;
const int logN = 17;

int n, k, x;
vector< int > v1, v2;

int main() {

	scanf("%d %d", &n, &k);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &x);
		if(x < 0) {
			v1.pb(-x);
		}
		else if(x > 0) {
			v2.pb(x);
		}
		else k--;
	}

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	if(k <= 0) {
		cout << 0 << endl;
		return 0;
	}

	int ans = inf;

	for(int i = 0; i <= k; i++) {
		int t1 = i - 1;
		int t2 = k - i - 1;
		int c1 = 0, c2 = 0, cur = 0;
		if(t1 >= (int)v1.size()) continue;
		if(t2 >= (int)v2.size()) continue;
		if(t1 >= 0) c1 = v1[t1];
		if(t2 >= 0) c2 = v2[t2];
		ans = min(ans, c1 + c2 + min(c1, c2));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
  cin>>s;
  if(s=="SUN")
    cout<<7<<endl;
  else if(s=="SAT")
    cout<<1<<endl;
  else if(s=="FRI")
    cout<<2<<endl;
  else if(s=="THU")
    cout<<3<<endl;
  else if(s=="WED")
    cout<<4<<endl;
  else if(s=="TUE")
    cout<<5<<endl;
  else if(s=="MON")
    cout<<6<<endl;
  
    
  
  
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        long ans = 0;
        if(A+B > C*2){
            int c = Math.min(X, Y);
            ans += C * 2 * c;
            X -= c;
            Y -= c;
        }
        if(X > 0){
            if(A > C*2) ans += C * 2 * X;
            else ans += A * X;
        }
        if(Y > 0){
            if(B > C*2) ans += C * 2 * Y;
            else ans += B * Y;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	// respect http://agc005.contest.atcoder.jp/submissions/1402971

	string X;
	cin >> X;
	LL ans = X.length();
	LL Sstock = 0;

	FOR(i, 0, X.length()) {
		if (X[i] == 'S') {
			Sstock++;
		}
		else {
			if (Sstock) {
				ans -= 2;
				Sstock--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int n, k;
  int ans[105] = {};
  int d, a;
  cin >> n >> k;
  rep(i, k){
    cin >> d;
    rep(j, d){
      cin >> a;
      ans[a] ++;
    }
  }
  int nasu = 0;
  reps(i, n){
    if(ans[i] == 0){
      nasu ++;
    }
  }
  cout << nasu << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,cnt,ans;
char ch;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>ch;
        if(ch=='I')
		{
			cnt++;	
		}
        else
        {
        	cnt--;	
		}
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	// fastio;
	#ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif

	// eachTest

	int h, n;
	cin >> h >> n;
	vector <PII> arr(n);
	FOR(i,0,n) cin >> arr[i].first >> arr[i].second;

	int table[h+1];
	fill(table, table+h+1, -1);

	int temp;
	FOR(i,1,h+1) {
		int temp = arr[0].second;
		if (i - arr[0].first > 0) {
			temp += table[i - arr[0].first];
		}
		table[i] = temp;
		FOR(j,1,n) {
			temp = arr[j].second;
			if (i - arr[j].first > 0) {
				temp += table[i - arr[j].first];
			}
			table[i] = min(table[i], temp);
		}
	}

	cout << table[h] << "\n";

	return 0;
}


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

int main() {
  int K;
  cin >> K;
  
  int sevens = 7 % K;  // 初期値0にするとkが7のとき何度更新してもsevensが0になってしまう
  set<int> s;
  int i = 1;
  
  if (K % 2 == 0) cout << -1 << endl;
  else {
    // mod Kの値はK以下なので, forループする場合は上限をKにすれば良い.
    // mod Kの値は循環し, mod K == 0のときreturnするので,
    // 既に出た値に当たるということは既に一巡し, mod K == 0となることはない.
    // その場合-1を出力する
    // s.countは引数と等価な値がsetにある場合1を, ない場合0を返す
    while (s.count(sevens) == 0) {
      if (sevens == 0) {
        cout << i << endl;
        return 0;
      }
      s.insert(sevens);
      sevens = (sevens * 10 + 7) % K;
      i++;
    }
    cout << -1 << endl;  // 上限値までループしても見つからなかった場合
  }
}


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var n = int.Parse(Console.ReadLine());
			int count = 0;
			while (n-- != 0)
			{
				var r = Console.ReadLine();
				if ((r + r).Contains(s))
					count++;
			}
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 6244
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int re_dist[301][301];

struct edge{
	int f,t,c;
	edge(){}
	edge(int ff,int tt,int cc){
		f=ff;
		t=tt;
		c=cc;
	}
	bool operator<(const edge &e)const{
		return c<e.c;
	}
};

vector<edge> ed;
vector<P> G[301];
int dist[301];

int dijk(int s,int e){
	for(int i=0;i<n;i++){
		dist[i]=INF;
	}
	dist[s]=0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));
	while(que.size()){
		P p=que.top();
		que.pop();
		if(dist[p.second]<p.first)continue;
		if(p.second==e)return p.first;
		for(int i=0;i<G[p.second].size();i++){
			P ep=G[p.second][i];
			if(dist[ep.first]>dist[p.second]+ep.second){
				dist[ep.first]=dist[p.second]+ep.second;
				que.push(P(dist[ep.first],ep.first));
			}
		}
	}
	return INF;
}

void dijk2(int s){
	for(int i=0;i<n;i++){
		dist[i]=INF;
	}
	dist[s]=0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));
	while(que.size()){
		P p=que.top();
		que.pop();
		if(dist[p.second]<p.first)continue;
		for(int i=0;i<G[p.second].size();i++){
			P ep=G[p.second][i];
			if(dist[ep.first]>dist[p.second]+ep.second){
				dist[ep.first]=dist[p.second]+ep.second;
				que.push(P(dist[ep.first],ep.first));
			}
		}
	}
}

bool check(){
	for(int i=0;i<n;i++){
		dijk2(i);
		for(int j=0;j<n;j++){
			if(dist[j]!=re_dist[i][j])return false;
		}
	}
	return true;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&re_dist[i][j]);
		}
	}
	for(int i=0;i<n;i++){
		if(re_dist[i][i]!=0){
			printf("-1\n");
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(re_dist[i][j]!=re_dist[j][i]){
				printf("-1\n");
				return 0;
			}else{
				ed.push_back(edge(i,j,re_dist[i][j]));
			}
		}
	}
	sort(ed.begin(),ed.end());
	ll sum=0;
	for(int i=0;i<ed.size();i++){
		if(dijk(ed[i].f,ed[i].t)>ed[i].c){
			sum+=ed[i].c;
			G[ed[i].f].push_back(P(ed[i].t,ed[i].c));
			G[ed[i].t].push_back(P(ed[i].f,ed[i].c));
		}
	}
	if(!check()){
		printf("-1\n");
		return 0;
	}
	printf("%lld\n",sum);
	return 0;
}

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

using namespace std;

int main() {
  string S, T;
  
  cin >> S >> T;
  
  int ans = 0;
  
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == T[i]) {
      ans++;
    }
  }
  
  cout << (S.length() - ans) << endl;
  
  return 0;
}

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

int n;
int cnt[101],s[101];
const int max_n=10001;
bool is_prime[max_n];
int prime[max_n];
int sieve(int n){
    int p=0;
    rep(i,n+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    FOR(i,2,n+1){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int main(){
    cin>>n;
    sieve(100);
    FOR(i,1,n+1){
        int cur=i;
        FOR(j,1,i+1)if(is_prime[j]){
            while(cur%j==0){
                ++cnt[j];
                cur/=j;
            }
        }
    }
    ll c75=0,c25=0,c15=0,c5=0,c3=0;
    rep(i,n+1){
        if(cnt[i]>=74) ++c75;
        if(cnt[i]>=24) ++c25;
        if(cnt[i]>=14) ++c15;
        if(cnt[i]>=4) ++c5;
        if(cnt[i]>=2) ++c3;
    }
    cout<<c75+c25*c3-c25+c15*c5-c15+c5*(c5-1)*(c3-2)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, x := float64(getInt()), float64(getInt()), float64(getInt())

	h := 2 * x / (a * b)
	s := 2 * (a*a*b - x) / (a * a)

	ans := math.Atan2(b, h) * 180 / math.Pi
	if h > a {
		ans = math.Atan2(s, a) * 180 / math.Pi
	}

	// out(b, h)
	// out(a, s)
	fmt.Printf("%-12.12f\n", ans)
}


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

bool isPrime(const int n) {
  for (int p = 2; p * p <= n; ++p) {
    if (n % p == 0)
      return false;
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  while (!isPrime(x))
    ++x;
  cout << x << "\n";
  return 0;
}



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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << s1[0] << s2[1] << s3[2] << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

n,m = map(int,input().split())
d = {}
ans = ["" for i in range(m)]

for i in range(m):
    p,y = map(int,input().split())
    if p not in d:
        d[p] = [[y,i]]
    else:
        d[p].append([y,i])
for key in d.keys():
    temp = d[key]
    temp.sort(key=lambda x:x[0])
    city = key
    if len(list(str(city))) < 7:
        city = "0" * (6 - len(list(str(city)))) + str(city)
    for i in range(len(temp)):
        if len(list(str(i+1))) < 7:
            y = "0"*(6-len(list(str(i+1))))+str(i+1)
            # print(len(list(str(i))))
        ans[temp[i][1]] = city+y

for i in range(m):
    print(ans[i])





Measured memory_bytes: 54992
#include <bits/stdc++.h>
#define PB push_back
using namespace std;

int h,w;
int d[15][15],tmp;
long long cnt;

int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			scanf("%d",&d[i][j]);
		}
	}
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%d",&tmp);
			if(tmp==-1)continue;
			cnt+=d[tmp][1];
		}
	}
	printf("%lld\n",cnt);
}


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

int main(){
	int n, k, b, T = 0;
	
	cin>>n;
	
	cin>>k;
	
	for(int i = 0; i < k; i++){
		cin>>b;
		T |= 1<<b;
	}
	
	for(int i = 0; i < (1<<n); i++){
		if((~T)&i) continue;
		cout<<i<<":";
		for(int j = 0, k = i; k; j++){
			if(k&(1<<j)){
				cout<<" "<<j;
				k &= ~(1<<j);
			}
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  vector<pi> r(n), b(n);
  REP(i, n) {
    cin >> r[i].first >> r[i].second;
  }
  sort(r.begin(), r.end());
  REP(i, n) {
    cin >> b[i].first >> b[i].second;
  }
  sort(b.begin(), b.end());
  int cnt = 0;
  REP(i, n) {
    int x = -1, mmax = -1;
    REP(j, n) {
      if (r[j].first < b[i].first && r[j].second < b[i].second) {
	if (mmax < r[j].second) {
	  mmax = r[j].second;
	  x = j;
	}
      }
    }
    if (x < 0) continue;
    r[x].first = 500;
    cnt++;
  }
  dump(cnt);
  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

unsigned long long int ulli;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string s1,s2,ans(105,' ');
  cin >> N;
  rep(i,N){
    cin >> s1 >> s2;
    ans = string(105,' ') ;
    if(s1.size()> 80 || s2.size() > 80){
      cout << "overflow" << endl;
      continue;
    }
    int a,b,c = 0;
    bool f = s1.size() >= s2.size();
    for(int i = 0;i <min(s1.size(),s2.size());++i){
      if(f){
        a = s1[s1.size()-1-i] - '0' ;
        b = s2[s2.size()-1-i] - '0' ;
      }
      else{
        a = s1[s1.size()-1-i] - '0' ;
        b = s2[s2.size()-1-i] - '0' ;
      }
//       debug((a+b+c)%10+'0');
      ans[ans.size()-1-i] = (a+b+c)%10+'0';
      c = (a+b+c)/10;
//       cout << ans.size()-1-i << " :" << a << " :" << b << " :" << c <<endl;
    }
    for(int i = min(s1.size(),s2.size()); i < max(s1.size(),s2.size());++i){
      if(f){
        ans[ans.size()-1-i] = (s1[s1.size()-1-i] - '0' + c)%10+'0';
        c = (s1[s1.size()-1-i] - '0' + c )/10;
      }
      else{
        ans[ans.size()-1-i] = (s2[s2.size()-1-i] + c - '0')%10+'0';
        c = (s2[s2.size()-1-i] + c - '0')/10;
      }
    }
    if(c > 0){
//       cout << ans << "c :"<<  c << endl;
      ans[0] = c +'0' ;
    }
    if(ans.size()-count(all(ans),' ') > 80){
      cout << "overflow" << endl;
      continue;
    }
    for(size_t c = ans.find_first_of(" "); c != string::npos; c = ans.find_first_of(" ")){
      ans.erase(c,1);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3028
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int l[300000], r[300000];
vector<int> v[100001];
struct BIT {
	vector<ll> bit;
	int n;
	BIT(int n) :n(n) {
		bit = vector<ll>(n + 1, 0);
	}
	ll sum(int i) {
		i++;
		ll s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	ll get(int i) {
		ll ret = sum(i);
		if (i > 0) ret -= sum(i - 1);
		return ret;
	}
	void add(int i, ll x) {
		i++;
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
		v[r[i] - l[i] + 1].push_back(i);
	}
	cout << N << endl;
	int sum = N;
	BIT bit(M + 2);
	for (int i = 2; i <= M; i++) {
		sum -= v[i - 1].size();
		for (int j : v[i - 1]) {
			bit.add(l[j], 1);
			bit.add(r[j] + 1, -1);
		}
		int ans = sum;
		for (int j = i; j <= M; j += i) {
			ans += bit.sum(j);
		}
		cout << ans << endl;
	}
}


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

bool Substring(string s, string sub)
{
    int l1=s.length();
    int l2=sub.length();
    int i, j, k;
    for(int i=0;i<=l1-l2;i++)
    {
        k=i;
        for(j=0;j<l2;j++)
        {
            if(s[k]!=sub[j])
            {
                break;
            }
            k++;
        }
        if(j==l2)
        {
            return true;
        }
    }
    return false;
}


int main()
{
      string s;
      cin>>s;
      string sub="AC";
      bool isSub=Substring(s, sub);
      if(isSub)
      {
          cout<<"Yes"<<endl;
      }
      else 
      {
          cout<<"No"<<endl;
      }
    


    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,s,t) for (int i=s;i<=t;++i)
const int maxn=1e5+10;
using namespace std;
typedef long long ll;
ll n,s;
ll f(ll b,ll n){
    ll ans=0;
    while(n)
    {
    	ans+=n%b;
    	n/=b;
	}
	return ans;
}
int main()
{
    scanf("%lld%lld",&n,&s);
     
    if (n==s) return 0*printf("%lld\n",n+1);
    for(ll i=2;i<=sqrt(n)+1;++i) if (f(i,n)==s) return 0*printf("%lld\n",i);
    if (n>s+1) for(ll i=sqrt(n);i;--i){
        ll b=(n-s)/i+1;
        if (f(b,n)==s) return 0*printf("%lld\n",b);
    }
    puts("-1");  
    return 0;
}
    

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

int main(){
  int N,answer;
  int count_red = 0;
  int count_blue = 0;
  cin >> N;
  vector<char> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  for(int i = 0; i < N; i++){
    if(data.at(i) == 'R'){
      ++count_red;
    }else{
      ++count_blue;
    }
  }
  if(count_red > count_blue){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

x = []
y = []
for i in range(n):
    xx,yy = map(int,input().split())
    x.append(xx)
    y.append(yy)

res = 0
for i in range(n):
    if x[i]**2 + y[i]**2 <= d**2:
        res += 1
print(res)

Measured memory_bytes: 87908
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 300010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

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> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

PII A[maxn];

int Ans[maxn];

vector<int> has;

void Work(){
	int now=1;
	REP(i,1,n){
		int x=A[i].se,y=A[i].fi;
		Ans[y]=x;
		REP(j,1,x-1){
			while(Ans[now])now++;
			Ans[now++]=x;
		}
		if(now>y){
			puts("No");return;
		}
	}
	while(Ans[now])now++;
	REP(i,1,n){
		int x=A[i].se;
		REP(j,1,n-x)has.PB(i);
	}
	int now2=0;
	while(now<=n*n){
		if(A[has[now2]].fi>now){
			puts("No");
			return;
		}
		Ans[now]=A[has[now2]].se;
		now2++;
		while(Ans[now])now++;
	}
	puts("Yes");
	REP(i,1,n*n)printf("%d ",Ans[i]);
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i].fi),A[i].se=i;
	sort(A+1,A+n+1);
}

int main(){
	Init();
	Work();
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(){
  int N,M;
  cin >> N;
  vector<int> T(N);
  rep(i,N){
    cin >> T.at(i);
  }
  cin >> M;
  vector<pair<int,int>> P(M);
  rep(i,M){
    cin >> P.at(i).first >> P.at(i).second;
  }
  rep(i,M){
    int t = 0;
    rep(j,N){
      if(P.at(i).first==j+1){
        t += P.at(i).second;
      }else{
        t += T.at(j);
      }
    }
    cout << t << endl;
  }
}

Measured memory_bytes: 256
import math
import sys

N = int(input())
if N == 0:
    max = 1
else:
    max = math.ceil(math.log(abs(N), 2)) + 3

result = []
numerator = N
for i in range(0, max):
    if numerator % (math.pow(2, i + 1)) == 0:
        result.append(str(0))
    else:
        result.append(str(1))
        numerator -= math.pow(-2, i)

    if numerator == 0:
        break
result.reverse()
print("".join(result))

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n, m;
	cin>>n>>m;
	cout<<max(0ll, n-2*m);	
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

#define ll long long

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

    std::string S;
    std::cin >> S;

    int S_size = S.size();

    if(S_size <= K) {
        std::cout << S << std::endl;
    }
    else {
        for(int i=0; i < K; i++) {
            std::cout << S[i];
        }
        std::cout << "..." << std::endl;
    }
}

Measured memory_bytes: 3584
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_12_B: Single Source Shortest Path I

#include <algorithm>
#include <cstdio>

using uint = unsigned int;

class Graph {
  const uint n_;
  uint* const g_;
  const uint INFINIT;
  
public:

  Graph(uint n) : n_(n), g_(new uint[(n_*n_)]), INFINIT(100000*(n_-1)+1) {
    std::fill_n(g_, (n_*n_), INFINIT);
  }

  ~Graph() { delete[] g_; }
  
  uint* operator [](uint i) const { return g_+(n_*i); }

  void dijkstra(uint* dist)
  {
    std::fill_n(dist, n_, INFINIT);
    bool visited[n_];
    std::fill_n(visited, n_, false);
    auto i = 0u; // 0-start
    visited[i] = true;
    dist[i] = 0u;
    for (auto n = 0u; n < n_-1; ++n) {
      auto cur_min = INFINIT;
      auto es = (*this)[i];
      auto base_dist = dist[i];
      for (auto j = 0u; j < n_; ++j) {
        if (visited[j]) continue;
        dist[j] = std::min(dist[j], base_dist+es[j]);
        if (cur_min > dist[j]) {
          cur_min = dist[j];
          i = j;
        }
      }
      visited[i] = true;
    }
  }
};

int main()
{
  uint n;
  std::scanf("%u", &n);

  Graph g(n);

  uint u, k, v, c;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u %u", &u, &k);
    for (auto j = 0u; j < k; ++j) {
      std::scanf("%u %u", &v, &c);
      g[u][v] = c;
    }
  }

  uint dist[n];
  g.dijkstra(dist);
  for (auto i = 0u; i < n; ++i) {
    std::printf("%u %u\n", i, dist[i]);
  }
}

// eof

Measured memory_bytes: 2700
import java.util.*;
import java.math.*;

class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long [] a = new long[n];
        long [] dp = new long[n];
        dp[0] = 0;
        for(int i = 0; i < n; i++)
        {
            a[i] = sc.nextInt();
            if(i > 0)
            {
                dp[i] = 100000000000000L;
                for(int j = i - 1; j >= 0 && j >= i - k; j--)
                    dp[i] = Math.min(dp[i], dp[j] + Math.abs(a[j] - a[i]));
            }
        }
        System.out.println(dp[n - 1]);
    }
}

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

int main() {
  
  while(true){
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }else{
      for(int j = 0; j < H; j++){
        for(int k = 0; k < W; k++){
          cout << "#";
          if(k == W-1){
          cout << endl;
          }
        }
      }
      cout << endl;
    }
  }

  
  return 0;
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll D) {
  cout << (N-1)/(2*D+1)+1 << endl;
}

int main() {
  ll N;
  cin >> N;
  ll D;
  cin >> D;
  solve(N, D);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int now(int a,int b)
{
 
  int r, tmp;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int main(){
	int N;

	scanf("%d",&N);

	int i,j,k;
	int temp =0;
	int temp2 = 0;
	int sum =0;

	for(i=1;i<N+1;i++){
		for(j=1;j<N+1;j++){
			for(k=1;k<N+1;k++){
				temp = now(k,j);
				temp2 = now(i,temp);
				sum = sum + temp2;
				

			}
		}
	}
	printf("%d\n",sum);



	return 0;
}

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

int main(){
	int h, w;
	cin >> h >> w;
	string a[h];
	for(int i = 0; i < h; i++) cin >> a[i];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(j == 0){
				cout << '#';
			} else if(j == w-1){
				cout << '.';
			} else if(a[i][j] == '#'){
				cout << '#';
			} else if(i % 2){
				cout << '#';
			} else {
				cout << '.';
			}
		}
		cout << endl;
	}
	cout << endl;
	cout << endl;

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(j == w-1){
				cout << '#';
			} else if(j == 0){
				cout << '.';
			} else if(a[i][j] == '#'){
				cout << '#';
			} else if(i % 2){
				cout << '.';
			} else {
				cout << '#';
			}
		}
		cout << endl;
	}
	cout << endl;


}


Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
    [n, t] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    ts <- V.fromList . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ n * t - V.sum (V.map (\x -> max (t - x) 0) $ V.zipWith subtract ts (V.tail ts))


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

int main() {
int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		String S=sc.next();
		int Q=sc.nextInt();
		Segtree[] st=new Segtree[26];
		for(int i=0; i<26; i++) {
			st[i]=new Segtree(N+1);
			st[i].fill(0);
		}
		for(int i=0; i<N; i++) {		//1　はじまり
			int tmp=S.charAt(i)-'a';
			st[tmp].add(i+1, 1);
		}
		for(int i=0; i<Q; i++) {
			int q=sc.nextInt();
			if(q==1) {
				int iq = sc.nextInt();
				String cq =sc.next();
				int moto=0;
				 for(int k=0; k<26; k++) {
					 if(st[k].get(iq)>0) {
						 moto=k;
						 break;
					 }
				 }
				if(moto == cq.charAt(0) - 'a') {
					//
				}
				else {
					st[moto].add(iq, -1);
					st[cq.charAt(0) - 'a' ].add(iq, 1);
				}
			}
			else if(q==2) {
				int lq = sc.nextInt();
				int rq =sc.nextInt();
				int res = 0;
				for(int j=0; j<26; j++) {
					if(st[j].sum(lq, rq, 0, 0, (st[j].length()+1)/2) >0) {
						res++;
					}
				}
				pl(res);
			}
		}



	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	static class Segtree{
		int[] Segtree;
		public Segtree(int vol){
			int truevol=calc_vol(vol);		//vol以上で最も小さい2ベキを求める
			Segtree=new int[truevol*2-1];
			for(int i=0; i<truevol*2-1; i++) {
				Segtree[i]=0;
			}
			//pl(truevol*2-1);
		}
		public void fill(int num) {		//特定の値にフィルする
			for(int i=0; i<Segtree.length; i++) {
				Segtree[i]=num;
			}
		}
		public int calc_vol(int vol) {	//2のべき乗の値のサイズにする
			int beki=0;
			int tmp=1;
			while(vol>=tmp) {
				tmp*=2;
				if(tmp==vol) {
					break;
				}
				beki++;
			}
			return tmp;
		}
		public int get(int elem) {		//値を返す
			int leaf=elem-1+(length()+1)/2;	//更新するセグ木の末端
			return Segtree[leaf];
		}
		public int getParent(int num) {	//親取得
			return (num-1)/2;
		}
		public int getChild(int num) {	//子取得
			return num*2+1;	//子は2つあるが、そのうち数が若いほう
		}
		public void add(int elem,int num) {	//elem番目の要素にnum足す(elemは0オリジン)
			int leaf=elem-1+(length()+1)/2;	//更新するセグ木の末端
			boolean zero=false;	//0までたどり着いたか
			while(!zero && leaf>=0) {
				//pl(leaf);
				Segtree[leaf]+=num;
				if(leaf==0) {
					zero=true;
				}
				leaf=getParent(leaf);	//上に（根の方）近づく
			}
		}
		public int sum(int a, int b, int k, int l, int r) {//sum(a, b, 0, 0, seg.tree.length/2)
			//[a,b]の要素の和を求める
			//pl(a+" "+b+" "+k+" "+l+" "+r);
			if(r <= a || b < l) return 0; //区間が交わっていないなら0
			if(a <= l && r-1 <= b) return Segtree[k]; //[l,r)が完全に[a,b)に内包されているならそのノードを返す
			else {
				int vl = sum(a, b, k*2+1, l, (l+r)/2);
				int vr = sum(a, b, k*2+2, (l+r)/2, r);
				return vl + vr;
			}
		}
		public int length() {
			return Segtree.length;
		}
	}

}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int odd = 0;
  rep(i, n) {
    if (a.at(i) % 2 == 1) {
      odd++;
    }
  }
  ll res;
  if (odd == 0) {
    if (p == 0) {
      res = 1LL << n;
    } else {
      res = 0;
    }
  } else {
    res = 1LL << (n - 1);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include<string.h>
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
#define all(c) c.begin(), c.end()
#define sec second
#define fst first
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
int main()
{
    ll n,k,min;
    cin>>n>>k;
    ll h[n];
    for (ll i = 0; i < n; ++i)
    {
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for (ll i = 2; i < n; ++i)
    {
        min=dp[i-1]+abs(h[i]-h[i-1]);
        for(ll j=2; i-j>=0 && j<=k;j++)
        {
            if(dp[i-j]+abs(h[i]-h[i-j]) < min)
            {
                min=dp[i-j]+abs(h[i]-h[i-j]);
            }
        }
        dp[i]=min;
    }
    cout<<dp[n-1];
}

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

int main()
{
	int n,i,taro,hana;
	char ani1[101];
	char ani2[101];
	
	taro=hana=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%s %s",ani1,ani2);
	
		
	int a = strcmp(ani1,ani2);

	
	
	if(a>0)
		taro += 3;
	else if(a == 0){
		taro += 1;
		hana += 1;
	}else
		hana += 3;
	}
	
	printf("%d %d\n",taro,hana);
	
	return 0;
}	


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

typedef long long ll;

string s;
int w;

int main(){
	cin >> s >> w;
	string res = "";
	for(int i = 0;s[i];i++){
		if(i % w == 0){
			cout << s[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
/*#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll f (ll b , ll n){
    if (n < b) return n;
    return f(b , n / b) + (n % b);
}
int main()
{
    ios::sync_with_stdio(false);
    ll n , s; cin >> n >> s;
    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    ll ans = -1;
    for (ll i = 2 ; i * i <= n ; i++){
        if (f(i , n) == s) {
            ans = i;
            break;
        }
    }
    if (ans != -1){
        cout << ans << endl;
        return 0;
    }
    for (ll i = 1 ; i * i <= n - s ; i++){
        if (n % i == 0){
            ll b = (n - s) / i + 1;
            if (b <= n / b) continue;
            if (b < 2) continue;
            ll k = n / b , r = n % b;
            if (s != r + k) continue;
            if (ans == -1 || ans > b) ans = b;
        }
    }
    cout << ans << endl;
    return 0;
}*/

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,s;
bool check(ll x){
	if(n/x>=x)return 0;
	if(x<2)return 0;
	ll k=n/x;ll r=n%x;
	if(s==k+r)return 1;
	return 0;
}
ll js(ll x,ll b){
	ll ans=0;
	while(x){
		ans+=x%b;
		x/=b;
	}
	return ans;
}
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	cin>>n>>s;
	ll b=1e18;
	if(n==s)b=n+1;
	for(ll t=2;t * t <= n;t++){
		ll cnt=js(n,t);
		if(cnt==s){
			b=min(b,t);
			break;
		}
	}
	if (b != 1e18){
        cout << b << endl;
        return 0;
	}
	if(n>s){
		ll temp=n-s;
		for(ll t=1;t<=sqrt(temp);t++){
			if(temp%t==0){
				ll x=t+1,y=temp/t+1;
				if(check(y))b=min(b,y);
			}
		}
	}
	if(b==1e18)printf("-1\n");
	else printf("%lld\n",b);
	return 0;
}


/*
82914867733
1676425945
*/


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N), B(N);
    for(int n=0; n<N; n++) {
        cin >> A[n] >> B[n];
    }
    
    long long int ans=0;
    for(int n=N-1; n>=0; n--) {
        if((A[n]+ans)%B[n]==0) continue;
        ans += B[n] - (A[n]+ans)%B[n];
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 1792