akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define inf 1000000007

int h, w, cnt;
char a[10][10];

void dfs(int i, int j) {
	if (i == 0 || j == 0 || i > h || j > w || a[i][j] != '#') {
		return;
	}
	cnt--;
	a[i][j] = '.';
	dfs(i + 1, j);
	dfs(i, j + 1);
	return;
}

signed main() {
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				cnt++;
			}
		}
	}
	int x = 1, y = 1;
	while (1) {
		cnt--;
		if (a[x + 1][y] == '#'&&a[x][y + 1] == '#') break;
		else if (a[x + 1][y] == '#') {
			x++;
			continue;
		}
		else if (a[x][y + 1] == '#') {
			y++;
			continue;
		}
		else break;
	}
	if (!cnt) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	END; 
}


Measured memory_bytes: 256
#include <iostream> //setprecision用
#include <iomanip>
using namespace std;

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

  cout << a / b << ' ';
  cout << a % b << ' ';
  cout << fixed << setprecision(5) << (double)a / b << endl;

  return 0;
}



Measured memory_bytes: 3276
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s, t; std::cin >> s >> t;
  t.insert(t.end(),all(s));
  std::cout << t << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

int main(){
      int a,b,k;
      cin>>a>>b>>k;
      vector<int>ans;
      for(int i=100;i>0;i--){
            if(a%i==0&&b%i==0){
                  ans.push_back(i);
            }
      }
      cout<<ans[k-1]<<endl;
      return 0;
}

Measured memory_bytes: 256
uses
  math;
var
  f:array[0..3033,0..3033] of longint;
  n,m,j,i:longint;
  s,r,kq:ansistring;
BEGIN
  ///assign(input,'a.in'); reset(input);
  readln(s);  n := length(s);
  readln(r);  m := length(r);
  
  fillchar(f,sizeof(f),0);
  for i:=1 to n do
    for j:=1 to m do
      if s[i] <> r[j] then f[i,j] := max(f[i-1,j], f[i,j-1])
      else f[i,j] := 1 + f[i-1,j-1];
  kq := '';
  i:=n; j:=m;
  while((i>0) and (j>0)) do begin
    if (f[i,j] = f[i-1,j-1] + 1) and (s[i]=r[j]) then begin kq:=s[i] + kq; dec(i); dec(j); end
    else
      if f[i,j] = f[i-1,j] then dec(i) else dec(j);
  end;
  writeln(kq);
END.


Measured memory_bytes: 36224
package main

import "fmt"

func main() {
  var n int
  var h []int64
  fmt.Scan(&n)

  for i := 0; i < n; i++ {
    var t int64
    fmt.Scan(&t)
    h = append(h, t)
  }

  for i := 1; i < n; i++ {
    cur := h[n-i-1]
    prev := h[n-i]
    if cur - prev > 1 {
      fmt.Println("No")
      return
    } else if cur - prev == 1 {
      h[n-i-1]--
    }
  }
  fmt.Println("Yes")
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int origin = 1;
		for(int i = 0;i < N;i++) {
			origin = Math.min(origin*2, origin+K);
		}
		System.out.println(origin);
	}

}

Measured memory_bytes: 20692
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

struct Union_Find {
	vector<int> rank, par, Size;
	int independent_tree;
	int N;

	Union_Find(int n) {
		N = n;
		for (int i = 0; i < N; i++)rank.push_back(1), par.push_back(i), Size.push_back(1);
		independent_tree = N;
	}

	int getroot(int X) {
		if (par[X] == X)return X;
		return par[X] = getroot(par[X]);
	}

	bool issame(int A, int B) {
		return getroot(A) == getroot(B);
	}

	void unite(int A, int B) {
		A = getroot(A), B = getroot(B);
		if (A == B)return;
		if (rank[A] > rank[B]) {
			par[B] = A;
			Size[A] += Size[B];
		}
		else if (rank[A] == rank[B]) {
			par[B] = A;
			rank[A]++;
			Size[A] += Size[B];
		}
		else {
			par[A] = B;
			Size[B] += Size[A];
		}
	}

};

struct Edge {
	int from, to;
	Edge(int a, int b) { from = a, to = b; }
};

ll N, M;
vector<Edge> E;
vector<ll> ans;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		E.push_back(Edge(A, B));
	}
	reverse(E.begin(), E.end());

	Union_Find uf(N);
	ll nokori = N * (N - 1) / 2;

	for (int i = 0; i < E.size(); i++) {
		ans.push_back(nokori);
		if (!uf.issame(E[i].from, E[i].to)) {

			nokori -= uf.Size[uf.getroot(E[i].from)] * uf.Size[uf.getroot(E[i].to)];
			uf.unite(E[i].from, E[i].to);
		}
	}

	reverse(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 5236
n = gets.chomp.to_i
a = gets.chomp.split().map(&:to_i)
b = gets.chomp.split().map(&:to_i)
c = gets.chomp.split().map(&:to_i)

ans = 0
n.times do |i|
  ans += b[a[i]-1]
  if i!=0 && a[i] - a[i-1] == 1
    ans += c[a[i-1]-1]
  end

end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<31;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0}; 
ll mpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%MOD;
        }
        n>>=1;
        x=x*x%MOD;
    }
    return res;
}
int main(){
    ll n,k;cin>>n>>k;
    cout<<mpow(k,n)<<endl;
}


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

int main() {

    int n;
    while (cin >> n, n) {
        int x[202], y[202];
        int dx[] = { -1, 0, 1, 0 };
        int dy[] = { 0, 1, 0, -1 };
        x[0] = y[0] = 0;
        rep(i, n-1) {
            int a, b;
            cin >> a >> b;
            x[i+1] = x[a] + dx[b];
            y[i+1] = y[a] + dy[b];
        }

        int ma_x = 0, mi_x = 1e8, ma_y = 0, mi_y = 1e8;
        rep(i, n) {
            ma_x = max(ma_x, x[i]);
            mi_x = min(mi_x, x[i]);
            ma_y = max(ma_y, y[i]);
            mi_y = min(mi_y, y[i]);
        }
        cout << ma_x-mi_x+1 << " " << ma_y-mi_y+1 << endl;
    }
}

Measured memory_bytes: 3004
import math

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

A.sort()
A.reverse()

t=A[0]

def myGCD(a,b):
    while b!=0:
        a,b=b,a%b 
    return(a)   

for i in range(1,N):
    t=myGCD(t,A[i])

if K > A[0]:
    print("IMPOSSIBLE")
else:
    if K%t==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, m;
    int cnt[100] = {};

    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }

    for (int i = 1; i <= n; i++)
        cout << cnt[i] << endl;
}


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

int main() {

	vector<string> akiba;
	akiba = {

		"KIHBR",
		"KIHBRA",
		"KIHBAR",
		"KIHBARA",
		"KIHABR",
		"KIHABRA",
		"KIHABAR",
		"KIHABARA",
		"AKIHBR",
		"AKIHBRA",
		"AKIHBAR",
		"AKIHBARA",
		"AKIHABR",
		"AKIHABRA",
		"AKIHABAR",
		"AKIHABARA"

	};

	string s;
	cin >> s;

	for (string x : akiba)if (s == x) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list_count=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		String s = sc.next();
		List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		int answer=0;
		for(int i=0;list.size()>i;i++) {
			int count=0;
			while(true) {
				if(list.get(i).equals("A")||list.get(i).equals("C")||list.get(i).equals("G")
						||list.get(i).equals("T")){
					count++;
				}
				else {
					break;
				}
				i++;
				if(i==list.size())
					break;
			}
			list_count.add(count);
		}
		System.out.println(Collections.max(list_count));
	}
}



Measured memory_bytes: 23764
//By Bibi
///                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
///             __.'              ~.   .~              `.__
///           .'//                  \./                  \\`.
///        .'//                     |                     \\`.
///       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
///     .'//.-"                 `-.  |  .-'                 "-.\\`.
///   .'//______.============-..   \ | /   ..-============.______\\`.
/// .'______________________________\|/______________________________`.
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
const int MAXN=1e5+7;
int read(){
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int n;
int a[MAXN];
int ans;
void init(){
	n=read();
	a[0]=0;
	rep(i,1,n) a[i]=read();
}
void work(){
	rep(i,1,n){
		ans+=abs(a[i]-a[i-1]);
	}
	ans+=abs(a[n]);
	rep(i,1,n){
		if(a[i]>=a[i-1]&&a[i]<=a[i+1]) printf("%d\n",ans);
		else if(a[i]>=a[i-1]&&a[i]>=a[i+1]&&a[i+1]<=a[i-1]) printf("%d\n",ans-2*abs(a[i-1]-a[i]));
		else if(a[i]>=a[i-1]&&a[i]>=a[i+1]&&a[i+1]>a[i-1]) printf("%d\n",ans-2*abs(a[i+1]-a[i]));
		else if(a[i]<=a[i-1]&&a[i]<=a[i+1]&&a[i+1]>=a[i-1]) printf("%d\n",ans-2*abs(a[i-1]-a[i]));
		else if(a[i]<=a[i-1]&&a[i]<=a[i+1]&&a[i+1]<a[i-1]) printf("%d\n",ans-2*abs(a[i+1]-a[i]));
		else if(a[i]<=a[i-1]&&a[i]>=a[i+1]) printf("%d\n",ans);
	}
}
int main(){
	init();
	work();
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
 
int main() {
	// your code goes here
	int n; cin>>n;
	int a[n+2];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int maxDist = INT_MIN;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			//if(i==j) continue;
			maxDist = max(maxDist, abs(a[i]-a[j]));
		} 
	}
	cout<<maxDist<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, a;
    cin >> n >> a;
    n %= 500;
    if (n <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000

int slove(int,int,int*);

int main(){
    int m[MAX];
    int A[MAX];
    int q;
    int n;

    scanf("%d",&n);
    for(int i = 0;i < n;i++)scanf("%d",&A[i]);
    scanf("%d",&q);
    for(int i = 0;i < q;i++)scanf("%d",&m[i]);

    for(int i = 0;i < q;i ++){
        if(slove(n,m[i],A) == 1)printf("yes\n");
        else printf("no\n");
    }          

    return 0;
}

int slove(int n,int m,int *A){
    if(n == 0)return 0;
    if(m == A[0])return 1;
    if(m < A[0])return slove(n-1,m,A + 1);
    return slove(n - 1,m - A[0],A + 1) || slove(n-1, m, A + 1);
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;cin>>n;
  ll a[n];rep(i,0,n)cin>>a[i];
  ll sum=accumulate(a,a+n,(ll)0);
  ll mi=sum;
  ll s=0;
  rep(i,0,n){
    s+=a[i];
    chmin(mi,abs(sum-2*s));
  }

  out(mi);


  
  return 0;
}


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

int main() {
    vector<int> a(5);
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    vector<int> p = {0, 1, 2, 3, 4};
    int final_answer = 643;

    do {
        int ans = 0;
        for (int i = 0; i < 5; i++) {
            while (ans % 10 != 0) ans++;
            ans += a[p[i]];
        }
        final_answer = min(final_answer, ans);
    } while (next_permutation(p.begin(), p.end()));

    cout << final_answer << endl;
    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 ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n-1);
    for(int i=0;i<n-1;i++){
        cin >> b.at(i);
    }
    a.at(0) = b.at(0);
    a.at(n-1) = b.at(n-2);
    for(int i=1;i<n-1;i++){
        a.at(i) = min(b.at(i-1),b.at(i));
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=a.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
s = input()

x = 0
lis =[0]
for i in range(n):
    if s[i] == "I":
        x += 1
        lis.append(x)
    else:
        x -= 1
        lis.append(x)

print(max(lis))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int n, a[100000];
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 1; i < n; ++i)
        a[0] = a[0] ^ a[i];
    if (!a[0])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
PROGRAM ATCODER

implicit none
integer :: n,k,i
character(len=10) :: s
character(len=1) :: c

read*, n,s,k

c = s(k:k)

do i = 1, n
  if ( s(i:i) /= c ) then
    s(i:i) = '*'
  end if
end do

print'(a)', trim(s) 

END PROGRAM ATCODER

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;
	for (int a = 1; a <= 9; a++) {
		for (int b = 1; b <= 9; b++) {
			if (a * b == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
 
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    sort(ALL(a),greater<int>());
    vector<mint> two(n+1); // two[i] := 2^i;
    two[0] = 1;
    rep(i,n) two[i+1] = two[i]*2;
    mint ans;
    // T == 0 のときをかんがえる
    rep(i,n){
        // a[i] が何回足されるかを考える
        int l = n - 1 - i,r = i;
        // l = i とあるが、iは最下位ビットなんですけど？
        mint now = two[i];
        if(r-1>=0) now += two[r-1] * r;
        now *= two[l];
        now *= a[i];
        ans += now;
    }
    ans *= two[n];
    cout << ans.x << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

int main(){
  int n;  cin >> n;
  vector<int> sum(n);
  cin >> sum[0];
  rep(i, 1, n){
    int weight;  cin >> weight;
    sum[i] = sum[i-1] + weight;
  }
  int mini = INF;
  REP(i, n){
    mini = min(mini, abs(sum[i]-(sum[n-1]-sum[i])));
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
int main()
{
	std::vector<int>num;
	for (int i; std::cin >> i;)
	{
		if (i == 0)
		{
			std::cout << num.back() << std::endl;
			num.pop_back();
		}
		else
		{
			num.push_back(i);
		}
	}
}


Measured memory_bytes: 3020
class SWAG():
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.fold_r=[unit]
        self.fold_l=[unit]
        self.data_r=[]
        self.data_l=[]
        sep=len(data)//2
        list(map(self.append,data[sep:]))
        list(map(self.appendleft,data[sep-1::-1]))
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.__init__(self.unit,self.f,self.data_l[::-1])
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.__init__(self.unit,self.f,self.data_r)
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 25884
from sys import stdin
for line in stdin:
	tmp = line.strip('\n').split(' ')
	a, b = int(tmp[0]), int(tmp[-1])
	if tmp[1] == '+':
		print(a + b)
	elif tmp[1] == '-':
		print(a - b)
	elif tmp[1] == '*':
		print(a * b)
	elif tmp[1] == '/':
		print(a // b)
	else:
		break



Measured memory_bytes: 5604
package main

import (
	"fmt"
)

func main() {
	var A int
	var B int
	fmt.Scanf("%d %d", &A, &B)
	if (B == 1) {
		fmt.Printf("%d", 0)
		return
	}
	total := 1
	rest := B - A
	for ;rest > 0; {
		rest = rest - (A-1)
		total++
	}
	fmt.Printf("%d", total)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>

#include <array>

using namespace std;


vector<pair<long long, long long> > prime_factorize(long long N);
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back(make_pair(a, ex));
    }

    // 最後に残った数について
    if (N != 1) res.push_back(make_pair(N, 1));
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    // cout << N << ":";
    long long int wa=0;
    long long int n=1;
    long long int resss=0;
    for (auto p : res) {
        while(wa+n<=p.second){
            wa+=n;
            n++;
        }
        n--;
        resss+=n;
        n=0;
        wa=0;
    }
    cout << resss << endl;
}

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

int main() {
int N; cin >> N;
string S; cin >> S;
int ans = 0;

for (int i = 0; i < (N - 2); i++){
    if (S[i] == 'A' & S[i+1] == 'B'& S[i+2] == 'C'){
        ans += 1;
    }
}
cout << ans << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N, Y = map(int, input().split())
    Y = Y // 1000

    # a: 10000 yen, b: 5000 yen, c: 1000 yen
    for a in range(N + 1):
        for b in range(N + 1):
            if N < a + b:
                continue

            c = N - (a + b)
            if Y == 10 * a + 5 * b + c:
                print(a, b, c)
                exit(0)

    print('-1 -1 -1')


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

long long min(long long a, long long b){
	return (a < b)? a: b;
}

int main(){
	long long n, ans = 10000000000;
	cin >> n;
	while(n >= 100){
		ans = min(abs((n % 1000)-753), ans);
		n /= 10;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    const int mod = 1000000007;

    static void Main() {
#if USE_IDE
        var exStdIn = new System.IO.StreamReader("./../../TestStdin.txt");
        Console.SetIn(exStdIn);
#endif
        var d = int.Parse(Console.ReadLine());
        var addStr = " Eve";
        var ans = "Christmas";
        for (int i = d; i < 25; i++) {
            ans += addStr;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
class Hp
  def initialize(len)
    @main = na(len,[999999999,-1])
    @ind = 1
    @main[0] = [-99999999,-1]
    @size = len - 5
  end
  def push(n)
    p "wa" if(@ind > @size)
    @main[@ind] = n
    sind = @ind
    while(sind != 0)
      nind = sind/2
      @main[sind], @main[nind] = @main[nind], @main[sind] if(@main[sind][0] < @main[nind][0])
      sind /= 2
    end
    @ind += 1
  end
  def put()
    return @main
  end
  def pop()
    ans = @main[1]
    @main[1] = @main[@ind]
    @main[@ind] = [999999999,-1]
    sind = 1
    while(true)
      nind = sind*2
      break if(nind > @ind)
      l = @main[nind]
      nind += 1 
      if(nind > @ind)
        ind = nind-1
        if(@main[ind][0] < @main[sind][0])
          @main[sind], @main[ind] = @main[ind], @main[sind] 
        end
        break 
      end
      r = @main[nind]
      ind = (l[0] > r[0])? nind : nind-1
      if(@main[ind][0] < @main[sind][0])
        @main[sind], @main[ind] = @main[ind], @main[sind] 
      end
      sind = ind
    end
    @ind -= 1
    return ans
  end
  def res()
    @ind = 1
    @main.push([999999999,-1])
  end
end
n,m = inp
pas = na2(n+1,0)
rec = na2(n+1,n+1,999999999)

test = []
m.times do 
  a,b,c=inp
  pas[a].push([b,c])
  pas[b].push([a,c])
  test.push([a,b,c])
end
#p pas
used = na(n)
hp = Hp.new(5100)
hp.push([1,1])
(1..n).each do |s|
  hp.put
  hp.res
  rec[s][s] = 0
  ind = s
  used = na(n+1,0)
  while(ind > 0) do
    used[ind] = true;
    max = 999999
    nex = -1
    tab = pas[ind]
    tab.each do |a|
      hi = a[0]
      next if(used[hi] == true)
      kyori = rec[s][ind] + a[1]
      rec[s][hi] = kyori if rec[s][hi] > kyori
      hp.push([kyori,hi])  if(used[hi] != true)
    end
    nex = hp.pop[1]
    used[nex] = true;
    
    ind = nex
  #rererereerer[missmissniu] += [waawawawawwa[bugbugbubg]] if(nex < 0)
  end
end
#p rec
c = 0
test.each do|a|
  if(rec[a[0]][a[1]] != a[2])
    c +=1
  end
end
p c

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

#define MAX 1000

int c[MAX + 1][MAX + 1];

int lcs(string X, string Y) {
	for (int i = 0; i <= X.size(); i++)
		c[i][0] = 0;
	for (int j = 0; j <= Y.size(); j++)
		c[0][j] = 0;
	for (int i = 1; i <= X.size(); i++) {
		for (int j = 1; j <= Y.size(); j++) {
			if (X[i - 1] == Y[j - 1]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			} else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
		}
	}
	return c[X.size()][Y.size()];
}

int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		string X, Y;
		cin >> X >> Y;
		cout << lcs(X, Y) << endl;
	}
	return 0;
}



Measured memory_bytes: 7096
import java.io.*;
public class Main{
  public static void main(String[] args){
    BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
    try{
      int a,b,c;
      int n=0;
      String str;
      String[] arr;
      str=mBufferedReader.readLine();
        arr=str.split(" ");
        a=Integer.parseInt(arr[0]);
        b=Integer.parseInt(arr[1]);
        c=Integer.parseInt(arr[2]);  
        for(int i=a;i<=b;i++){
          if(c%i==0){
          n++;
          }
        }
        System.out.println(n);
        
      
      
      
    }catch(IOException e){
      System.out.println("Error");
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;

int n;
int a[M];

void read() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = x - 1;
  }
}


void kill() {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int j = a[i];
    if (j > i && a[j] == i)
      ++ans;
  }
  cout << ans << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 768
from collections import deque
import numpy as np

N, K = map(int, input().split())

tele = list(input().split())
tele = np.array([int(tele[i]) for i in range(N)])
seen = set([])
roop_in = deque([])
now = 1
w_num = 0

while now not in seen and w_num < K:
    seen.add(now)
    roop_in.append(now)
    now = tele[now - 1]
    w_num += 1

if w_num == K:
    print(now)
else:
    roop_in_index = roop_in.index(now)
    roop = list(roop_in)[roop_in_index:]
    roop_len = len(roop)
    last = (K - (w_num - 1)) % roop_len
    print(roop[last - 1])

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

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		string str;
		cin >> str;
		set<string> Set;
		int size = str.size();
		for(int i = 1; i < size; ++i)
		{
			string first;
			string second;
			for(int j = 0; j < i; ++j)
			{
				first += str[j];
			}
			for(int j = i; j < size; ++j)
			{
				second += str[j];
			}
			string revFirst = first;
			string revSecond = second;
			reverse(revFirst.begin(), revFirst.end());
			reverse(revSecond.begin(), revSecond.end());
			Set.insert(first + second);
			Set.insert(first + revSecond);
			Set.insert(revFirst + second);
			Set.insert(revFirst + revSecond);
			Set.insert(second + first);
			Set.insert(second + revFirst);
			Set.insert(revSecond + first);
			Set.insert(revSecond + revFirst);
		}
		cout << Set.size() << endl;
	}
}

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

Measured memory_bytes: 1296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int ansb = 0, ansh = 0;
    rep(i, 4) cin >> b[i];
    rep(i, 4) rep(j, 4) {
      if (a[i] == b[j]) {
        if (i == j)
          ansh++;
        else
          ansb++;
      }
    }
    cout << ansh << ' ' << ansb << endl;
  }
  return 0;
}

Measured memory_bytes: 3056
def d_ki():
    import sys
    input = sys.stdin.readline
    N, Q = [int(i) for i in input().split()]

    tree = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) for i in input().split()]
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    ans = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        ans[p - 1] += x

    # 1次元配列だったら単純に累積和を取ればいいのだが、木なので
    # DFSをしなければならない
    q = [0]
    is_visited = [False] * N
    while q:
        current = q.pop()
        is_visited[current] = True
        for child in tree[current]:
            if is_visited[child]:
                continue
            ans[child] += ans[current]
            q.append(child)
    return ' '.join(map(str, ans))

print(d_ki())

Measured memory_bytes: 121548
use std::io;
use std::cmp::max;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	println!("{}",max(max(a+(a-1), b+(b-1)), a+b));
}

Measured memory_bytes: 4476
n = int(input())
h = list(map(int, input().split()))
def solve(n):
  #print(n)
  if len(n) == 1:
    return n[0]
  if n == []:
    return 0
  for i in range(len(n)):
    if n[i] == 0:
      return solve(n[:i]) + solve(n[i+1:])
  tempmin = min(n)
  nextn = [n[i]- tempmin for i in range(len(n))]
  return tempmin+solve(nextn)

print(solve(h))

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){

  long h,n;
  scanf("%ld %ld", &h, &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long attack = 0;
  for (long i = 0; i < n; i++) {
    attack += a[i];
  }

  if (attack >= h) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES  

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

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

    bool flg = true;
    for(int i = 1; i <= n; ++i){
        x = i;
        if(0 == x % 3){
            std::cout << " " << i;
        }else{
            std::string str = std::to_string(x);
            if(std::string::npos != str.find('3')){
                std::cout << " " << i;
            }
            x /= 10;
        }
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3276
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    int n;
    cin>>n;
    if(n%2==1) cout<<n/2*(n/2+1);
    else cout<<n/2*n/2;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2


fun main(args: Array<String>) {
    val (SA, SB) = readString().split(' ')
    val A = SA.toULong()  // [0, 1e15]
    //val B = SB.toDouble()  // [0.00, 9.99]
    //val BUL = (B * 100).toULong() // [0, 999]

    var BUL = 0L
    BUL += (SB[0]-'0')*100L
    BUL += (SB[2]-'0')*10L
    BUL += (SB[3]-'0')


    if (A==0UL || BUL==0L) {
        println(0)
        return
    }

    val ans = A * BUL.toULong() / 100UL

    println(ans)
}


Measured memory_bytes: 36108
#include <iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b;
	if (a > 10)
	{
		a = 10;
	}
	c = 100 * (10 - a) + b;
	cout << c << endl;


}


Measured memory_bytes: 256
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

a_sum = sum(a)
tmp = 0
ans = INF

for i in range(N-1):
	tmp += a[i]
	diff = abs(a_sum - tmp - tmp)
	ans = min(ans, diff)

print(ans)

Measured memory_bytes: 26108
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def run():
    N, *A = mapread()
    ans = 1
    current = [0,0,0]
    for a in A:
        transition = 0
        cache = 1
        for i, c in enumerate(current):
            if c == a:
                transition += 1
                cache = i
        ans *= transition
        ans %= mod
        current[cache] += 1
        #print(current)
    print(ans)

if __name__ == "__main__":
    run()


Measured memory_bytes: 19728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],x=0,sum=0;
    for(int i=0; i<3; i++){
        cin>>a[i];
        sum+=a[i];
        if(x<=a[i])x=a[i];
    }
    cout<<sum-x<<endl;
    return 0;

}


Measured memory_bytes: 384
#include<stdio.h>
#define N 200

int F[N];

int fibonacci(int n){
  if(n == 0 || n == 1){
    return F[n] = 1; // F[n] に 1 をメモしてそれを返す
  }
  if(F[n]!=NULL){
	return F[n];
  }
  else  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
		  }

main(){
  int n,F;

  scanf("%d",&n);
  F = fibonacci(n);
  printf("%d\n",F);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
 
int main()
{
    arena
    ll n;
    cin>>n;
    
    ll ans=LONG_MAX;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll a=i;
            ll b=n/i;
            ans=min(ans,a+b-2);
        }
    }
    cout<<ans<<'\n';
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 256
N, M = map(int, raw_input().split())

result = [0]*M

for i in range(N):
  foods = map(int, raw_input().split())
  pers_count = foods.pop(0)
  
  for f in foods:
    result[f-1] += 1

res_count = 0
for r in result:
  if N == r:
    res_count += 1

print res_count

Measured memory_bytes: 2568
s = input()
#print(s)
#print(len(s))
s = s+'X'
ans = []
cnt = 0
for i in range(len(s)):
  #print(s[i])
  if (s[i] != 'A') and (s[i] != 'T') and (s[i] != 'C') and (s[i] != 'G'):
    ans.append(cnt)
    #print(ans)
    cnt = 0
  elif s[i] == 'A':
    cnt += 1
    continue
  elif s[i] == 'T':
    cnt += 1
    continue
  elif s[i] == 'C':
    cnt += 1
  elif s[i] == 'G':
    cnt += 1

#print(ans)
print(max(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll primeNum[101] = {};
void primeFactors(int p)
{
	//in case of 2;
	if (p == 2) {
		primeNum[p]++;
		return;
	}

	ll n = p;
	for (int i = 2; i*i <= p; i++)
	{
		while (!(n % i))
		{
			primeNum[i]++;
			//cout << i << " ";
			n = n / i;
		}
	}
	//in case of prime number
	if (n > 2)	primeNum[n]++;
}

ll count(ll n) {
	ll cnt = 0;
	rep(i, 0, 101) {
		if (n <= primeNum[i]) {
			cnt++;
		}
	}
	return cnt;
}

int main() {
	ll n; cin >> n;
	repe(i, 2, n) {
		primeFactors(i);
	}
	ll p75 = count(75 - 1);
	ll p25 = count(25 - 1);
	ll p15 = count(15 - 1);
	ll p5 = count(5 - 1);
	ll p3 = count(3 - 1);

	cout << p75 +
		p25 * (p3 - 1) +
		p15 * (p5 - 1) +
		((p5 * (p5 - 1)) / 2) * (p3 - 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
ll x;
int main()
{
    cin>>x;
    ll t1=x%500;
    ll t2=(x/500)*1000;
    ll t3=(t1/5)*5;
    cout<<t2+t3<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
k_list = []

for i in range(n):
    x, l = map(int, input().split())
    k_list.append([x-l, x+l])

k_list.sort(key=lambda x: x[1])

ptr = - 10 ** 10
cnt = 0

for item in k_list:
    if item[0] >= ptr:
        ptr = item[1]
        cnt += 1

print(cnt)



Measured memory_bytes: 62680
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
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;}

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

int N,W;
cin >> N >> W;
vl w(N),v(N);
rep(i,N) cin >> w[i] >> v[i];

// dp[i][sum]:= w[i-1]までの品物からsumを超えないように選んだときの価値の最大値
vvl dp(N+1,vl(W+1,0));

for(int i = 0; i < N; ++i) {
    for(int sum = 0; sum <= W; ++sum) {
        chmax(dp[i+1][sum], dp[i][sum]);
        if(sum >= w[i]) chmax(dp[i+1][sum], dp[i][sum-w[i]]+v[i]);
    }
}
cout << dp[N][W] << endl;
return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 1e9+7; // 998244353;
const ll INF = 1e18;
 
int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int n; cin >> n;
   ll ans = 0;
   for (int i = 1; i < n; i++)
      ans += (n - 1) / i;
   cout << ans;
   return 0;
}

Measured memory_bytes: 3652
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	v1 := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if a[i] > a[j] {
				v1++
			}
		}
	}

	v2 := 0
	sort.Ints(a)
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if a[i] < a[j] {
				v2++
			}
		}
	}

	inf := int(1e9 + 7)
	c1 := (v1 * k) % inf
	c2 := v2 * (((k * (k - 1)) / 2) % inf)
	ans := (c1 + c2) % inf
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <stdio.h>

int main (void)
{
  int n , k , temp , ans = 0;
  scanf("%d %d",&n,&k);
  
  int a[n];
  for(int i = 0;i < n;i ++){
  scanf("%d",&a[i]);
  }
 for(int j = 0; j < n-1;j ++){
 for(int i = 0; i < n-1;i ++){
   if(a[i]<a[i+1]){
     temp = a[i];
     a[i] = a[i+1];
     a[i+1] = temp;
   }
 }}
  
  for(int i = 0;i < k;i ++){
    ans += a[i];
  }
  
  printf("%d",ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){

    string s;
    bool special=true;
    cin>>s;
    for (int i=0;i<4;i++){
        if(count(s.begin(),s.end(),s[i])!=2){
            special=false;
            break;
        }
    }
    if(special)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

using namespace std;


ll num[sz];
map<ll,ll>cnt;
set<ll>st;
set<ll>::iterator it;


int main()
{

    ll n,i,j,k,p,d,m,a,x,ar;
    ll c=0;

    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>num[i];
        st.insert(num[i]);
        cnt[num[i]]++;

    }

    priority_queue<ll>q;
    ar=1;
    i=1;
    n=st.size();

    for(it=st.begin(); it!=st.end(); it++)
    {
        a=*it;
     //   cout<<a<<endl;
        num[i]=a;
        i++;

    }



    for(i=n;i>=1;i--)
    {
        a=num[i];


        if(cnt[a]>=2)
        {
            c++;
            ar=ar*a;
            if(c==2){q.push(ar);
            break;}

        }
        if(cnt[a]>=4)
        {
            q.push(a*a);
        }
    }

    m=q.size();
    if(m==0)cout<<0<<endl;
    else
    {
        m=q.top();
        cout<<m<<endl;
    }

    return 0;
}


Measured memory_bytes: 11904
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def calc(p,x):
    return p*(100+x)//100


while True:
    H = int(input())
    if H == 0:
        break
    else:
        W = 5
        ban = [inpl() for i in range(H)]
        ans = 0
        while True:
            flag = False
            for y,[a1,a2,a3,a4,a5] in enumerate(ban):
                if a1 == a2 and a2 == a3 and a1 != -1:
                    flag = True
                    ban[y][0] = -1
                    ban[y][1] = -1
                    ban[y][2] = -1
                    ans += a1*3
                    if a3 == a4:
                        ban[y][3] = -1
                        ans += a4
                        if a4 == a5:
                            ban[y][4] = -1
                            ans += a5
                elif a2 == a3 and a3 == a4 and a2 != -1:
                    flag = True
                    ban[y][1] = -1
                    ban[y][2] = -1
                    ban[y][3] = -1
                    ans += a2*3
                    if a4 == a5:
                        ban[y][4] = -1
                        ans += a5
                elif a3 == a4 and a4 == a5 and a3 != -1:
                    flag = True
                    ban[y][2] = -1
                    ban[y][3] = -1
                    ban[y][4] = -1
                    ans += a3*3

            for _ in range(H):
                for y in reversed(range(1,H)):
                    for x in range(W):
                        if ban[y][x] == -1:
                            ban[y][x] = ban[y-1][x]
                            ban[y-1][x] = -1

            #for y in ban:
            #    print(y)
            #print()

            if not flag:
                break

        print(ans)
        



Measured memory_bytes: 7476
import queue


def main():
    n, m = map(int, input().split())
    es = [[] for _ in range(n+1)]
    ans = [0 for _ in range(n+1)]

    for _ in range(m):
        a, b = map(int, input().split())
        es[a].append(b)
        es[b].append(a)

    q = queue.Queue()
    q.put(1)
    while not q.empty():
        p = q.get()

        for t in es[p]:
            if ans[t] > 0:
                continue
            ans[t] = p
            q.put(t)

    if 0 in ans[2:]:
        print("No")
    else:
        print("Yes")
        for a in ans[2:]:
            print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 98808