akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
//finds the next permutation to given sequence of nos
int nextpermutation(vi v)
{
    vi t=v;
    sort(t);
    int x=0;
    while(true)
    {
        x++;
        if(t==v)
        {
            return x;
        }
        next_permutation(all(t));
    }
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)print(c)
    else if(a==c)print(b)
    else print(a)
}
    
    
    
    
    
    

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

int main() {
  int N;
  bool ans = true;
  cin >> N;
  
  vector<int> s(N);
  for (int i = 0; i < N; i++){
    cin >> s.at(i);
  }
  
  for(int i = N - 1; i > 0; i--){
  	if(s.at(i) < s.at(i - 1)){
      //cout << "inorder" << i << endl;
      if(s.at(i) == s.at(i - 1) - 1){
        s.at(i - 1) = s.at(i - 1) - 1;
        //cout << s.at(i - 1) << endl;
      }
      else{
      	ans = false;
        break;
      }
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 640
import sys
import math
mod = 1000000007
 
n = int(sys.stdin.readline().rstrip())
ab = {}
for i in range(n):
    a,b = map(int,sys.stdin.readline().rstrip().split())
    if a == 0 and b == 0:
        pass
    elif a == 0:
        b = 1
    else:
        gcd = math.gcd(a,b)
        a //= gcd
        b //= gcd
        if a < 0:
            a = -a
            b = -b
    ab.setdefault((a,b),0)
    ab[(a,b)]+=1
ans = 0
pairs=[]
s = set(ab.keys())
for i in ab.keys():
    a = i[0];b = i[1]
    if a == 0 and b == 0:
        ans = ab[(0,0)]
        n -= ans
    else:
        if (-b, a) in s:
            pairs.append([ab[(a,b)],ab[(-b,a)]])
select = 1
for pair in pairs:
    select*= (pow(2,pair[0],mod) + pow(2,pair[1],mod) -1)
    n -= (pair[0]+pair[1])
all_ans = (pow(2,n,mod) * select) % mod + ans -1
all_ans %= mod
print(all_ans)

Measured memory_bytes: 59356
#include <stdio.h>

int main(void){
    int N;
    int i,j,k;
    int bingo[3][3];
    for(i=0 ;i<3 ;i++){
        for(j=0 ; j<3 ; j++){
            bingo[i][j]=0;
        }
    }
    int Aar[3][3];
    for(i=0 ;i<3 ;i++){
        for(j=0 ; j<3 ; j++){
            scanf("%d",&Aar[i][j]);
        }
    }
    scanf("%d",&N);
    int bar[N];
    for(k=0; k<N ;k++){
        scanf("%d",&bar[k]);
    } 

    for(k=0;k < N ;k++){
        for(i=0 ;i<3 ;i++){
            for(j=0 ; j<3 ; j++){
                if(Aar[i][j] == bar[k]){
                    bingo[i][j] =1;
                }
            }
        }
    }
    k=0;
    for(i=0 ; i<3 ;i++){
    k +=bingo[i][0] * bingo[i][1] *bingo[i][2];
    k +=bingo[0][i] * bingo[1][i] *bingo[2][i];
    }
    k +=bingo[0][0]*bingo[1][1]*bingo[2][2];
    k +=bingo[0][2]*bingo[1][1]*bingo[2][0];
    if(k==0){
    printf("No");
    }
    else{
    printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <vector>
using namespace std;
int main() {
  int n, c = 0;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {cin >> p.at(i);}
  for (int i = 0; i < n - 2; i++) {
    if (p.at(i) < p.at(i + 1) && p.at(i + 1) < p.at(i + 2)) {c++;}
    else if (p.at(i) > p.at(i + 1) && p.at(i + 1) > p.at(i + 2)) {c++;}
  }
  cout << c << endl;
}

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

int main()
{
    int a[3];
    int b[3];
    int c[3][3];
    int sum = 0;

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            sum += c[i][j];
        }
    }

    if(sum % 3 == 0){
        sum /= 3;
    }else{
        cout << "No";
        return 0;
    }
    
    for(int i = 0; i <= sum; i++){
        a[0] = i;
        for(int j = 0; j < 3; j++){
            b[j] = c[0][j] - a[0];
            a[1] = c[1][0] - b[0];
            a[2] = c[2][0] - b[0];
        }
        if(c[1][1] == a[1] + b[1] && c[1][2] == a[1] + b[2] && c[2][1] == a[2] + b[1] && c[2][2] == a[2] + b[2] && a[0]+ a[1] + a[2] + b[0] + b[1] + b[2] == sum){
            cout << "Yes";
            return 0;
        }    
    }
    cout << "No";
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

cnt = 0
for i in range(N):
    if x - a[i] >= 0:
        cnt += 1    
    x -= a[i]

if x <= 0:
    print(cnt)
else:
    print(cnt - 1)

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

struct CycleDetection{
    vector<vector<int>> G;
    vector<int> seen,finished;
    stack<int> hist;
    int pos;
    CycleDetection(int n):G(n),seen(n,0),finished(n,0),pos(-1){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
    }
    void dfs(int v,int p){
        seen[v]=1; hist.push(v);
        for (int u:G[v]){
            if (u==p) continue;
            if (finished[u]) continue;
            if (seen[u]&&!finished[u]){pos=u; return;}
            dfs(u,v);
            if (pos!=-1) return;
        }
        finished[v]=1; hist.pop();
    }
    vector<int> build(int &cycle){
        dfs(0,-1);
        cycle=(pos!=-1);
        vector<int> res;
        while(!hist.empty()){
            int t=hist.top(); hist.pop();
            res.emplace_back(t);
            if (t==pos) break;
        }
        return res;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    CycleDetection CD(N);
    for (int i=0;i<N;++i){
        int u,v; cin >> u >> v; --u,--v;
        CD.add_edge(u,v); CD.add_edge(v,u);
    }
    int a;
    vector<int> Cycle=CD.build(a);
    set<int> s;
    for (int v:Cycle) s.emplace(v);
    int Q; cin >> Q;
    for (;Q--;){
        int a,b; cin >> a >> b;
        cout << (s.count(--a)&&s.count(--b)?2:1) << '\n';
    }
}


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

int main()
{
	int count = 0;
	string str,str2;
	cin >> str;

	for(int i=0;i<str.size();++i)
		if(str[i] >= 'a' && str[2] <= 'z')
			str[i] -= 32;

	while(cin >> str2){
		if(str2 ==  "END_OF_TEXT")
			break;
		
		for(int i=0;i<str2.size();++i)
			if(str2[i] >= 'a' && str2[i] <= 'z')
				str2[i] -= 32;
		
		
		if(str2 == str)
			++count;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1188
package main

import (
	"fmt"
	"os"
//	"strconv"
	"text/scanner"
)

var sin scanner.Scanner
var ans int

func scan() string {
	tok := sin.Scan()
	if tok == scanner.EOF {
		return ""
	}
	return sin.TokenText()
}

func main() {
	sin.Init(os.Stdin)
	b := scan()

	if b == "A"{
		fmt.Printf("T")
}

if b == "C"{
	fmt.Printf("G")
}

if b == "G"{
	fmt.Printf("C")
}

if b == "T"{
	fmt.Printf("A")
}
	fmt.Printf("\n")


}




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

int main(){

    int N,L;
    cin >> N >> L;
    vector<string> s(N);
    for(int i = 0; i < N; ++i){
        cin >> s[i];
    }

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

    for(int i =0; i < N; ++i){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
double arr[100];
int main() {
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) {
        scanf("%lf",&arr[i]);
    }
    sort(arr,arr+n);
    double temp;
    temp = arr[0];
    for (int i = 1; i < n; i++) {
        temp = (arr[i] + temp) / 2;
    }
    printf("%.5lf\n",temp);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    cout<<n * n * n<<endl;
    return 0;
}






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

int main(){
  int N,M; cin >> N >> M;
  vector<int> X(M);
  cinf(M,X);
  sort(X.begin(),X.end());
  
  vector<long long> dif;
  for(int i=1;i<M;i++) dif.push_back(X[i]-X[i-1]);
  sort(dif.begin(), dif.end(),greater<long long>());
  
  long long res= X.back()-X[0];
  
  for(int i=0;i<min((int)dif.size(),N-1);i++)
    res -= dif[i] ;
  cout << res << endl;
}
       
  

Measured memory_bytes: 1784
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Stack;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	int[] memo;

	void solve(){
		Scanner in = new Scanner(System.in);

		memo = new int[45];

		int n = in.nextInt();

		System.out.println(fib(n));
		
	}
	
	int fib(int n){
		if(n<2) return 1;
		if(memo[n] != 0) return memo[n];
		return memo[n] = fib(n - 1) + fib(n - 2);
	}

}

Measured memory_bytes: 26440
import heapq
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

h = []
heapq.heappush(h,(-1) * A[0])
ans = 0
for i in range(1,N):
  wk = heapq.heappop(h) * (-1)
  ans += wk
  heapq.heappush(h,(-1) * A[i])
  heapq.heappush(h,(-1) * A[i])
  
print(ans)

Measured memory_bytes: 31784
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector <int> p(n);
    for(int i=0;i<n;++i) cin >> p[i];
    vector <int> q(n);
    for(int i=0;i<n;++i) q[i]=p[i];
    sort(q.begin(),q.end());
    int sum=0;
    for(int i=0;i<n;++i) {
        if(p[i]!=q[i]) ++sum;
    }
    if(sum>=3) cout << "NO" << endl;
    else cout << "YES" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=5e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
const int mo=1e9+7;
int n,size[N];
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>();
		E[x].pb(y),E[y].pb(x);
	}
}
int mx[N];
void dfs1(int u,int pre)
{
	size[u]=1;
	for(int v:E[u])if(v^pre)
	{
		dfs1(v,u);
		size[u]+=size[v];
		cmax(mx[u],size[v]);
	}
	cmax(mx[u],n-size[u]);
}
void dfs2(int u,int pre)
{
	size[u]=1;
	for(int v:E[u])if(v^pre)
	{
		dfs2(v,u);
		size[u]+=size[v];
	}
}
int c[N],top;
int C[N][N],mc[N];
void add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
int dp[N][N];
void work()
{
	dfs1(1,0);
	int Min=n,num=0,rt=0;
	For(i,1,n)
	{
		if(cmin(Min,mx[i]))num=1,rt=i;
		else if(Min==mx[i])num++;
	}
	assert(num<=2);
	if(num==2)
	{
		int ans=1;
		For(i,1,n>>1)ans=1ll*ans*i%mo;
		write(1ll*ans*ans%mo,'\n');
	}
	else
	{
		dfs2(rt,0);			
		for(int v:E[rt])c[++top]=size[v];
		For(i,0,n)
		{
			C[i][0]=1;
			For(j,1,i)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
		}
		int tot=0;
		mc[0]=1;
		For(i,1,n)mc[i]=1ll*mc[i-1]*i%mo;
		dp[0][0]=1;
		For(i,1,top)
		{
			For(j,0,tot)For(k,0,c[i])
			{
				add(dp[i][j+k],1ll*dp[i-1][j]*C[c[i]][k]%mo*C[c[i]][k]%mo*mc[k]%mo);
			}
			tot+=c[i];
		}
		int ans=0;
		For(i,0,tot)
		{
			if(i&1)add(ans,mo-1ll*dp[top][i]*mc[n-i]%mo);
			else add(ans,1ll*dp[top][i]*mc[n-i]%mo);
		}
		write(ans,'\n');
	}
	
}
int main()
{

	input();
	work();
	return 0;
}



Measured memory_bytes: 194688
#include<cstdio>
#include<queue>
#include<map>
#include<functional>
using namespace std;
typedef pair<int,int>S;
int main()
{
	int N,p[100000],i,j,c;
	for(i=!scanf("%d",&N);i<N;++i)scanf("%d",p+i);
	bool f[100000]={};
	priority_queue<S,vector<S>,greater<S> >q;
	q.push(S(0,0));
	for(;;)
	{
		S s=q.top();q.pop();
		c=s.first;
		i=s.second;
		if(f[i]++)continue;
		if(i>=N-1)break;
		if(p[i])q.push(S(c,i+p[i]));
		else for(j=1;j<7;++j)q.push(S(c+1,i+j));
	}
	return !printf("%d\n",c);
}

Measured memory_bytes: 1300
PROGRAM ATCODER

implicit none
integer(8) :: n,i,j,s,dif
integer(8),allocatable :: a(:), b(:), c(:)

read(*,*) n
allocate(a(n)) ; allocate(b(n)) ; allocate(c(n))

dif = 0
do i = 1, n
    read(*,*) a(i),b(i)
end do

c(:) = a(:) + b(:)

dif = -sum(b)

call hsort(n,c)

do i = 1, n, 2
    dif = dif + c(i)
end do

deallocate(a) ; deallocate(b) ; deallocate(c)

write(*,'(i0)') dif

END PROGRAM ATCODER


subroutine hsort(n, x)
  implicit none
  integer, intent(IN) :: n
  integer(8), intent(INOUT) :: x(n)
  ! local
  integer k
  integer(8) :: tmp
  ! external subroutine
  external mkheap
 
  do k = n/2, 1, -1
     tmp = x(k)
     call mkheap(n, x, k, n, tmp)
  enddo
 
  do k = n, 2, -1
     tmp = x(k)
     x(k) = x(1)
     call mkheap(n, x, 1, k-1, tmp)
  end do
 
  return
end subroutine hsort
 
subroutine mkheap(n, x, root, leaf, val)
  implicit none
  integer(8), intent(IN)    :: n
  integer, intent(IN)       :: root, leaf
  integer(8), intent(INOUT) :: x(1:n)
  integer(8), intent(IN)    :: val
  ! local
  integer :: i, j
 
  i = root
  j = i * 2
 
  do
     if (j > leaf) exit
 
     if (j < leaf) then
        if (x(j) > x(j+1)) j = j + 1
     end if
 
     if (x(j) < val) then
        x(i) = x(j)
        i = j
        j = i * 2
     else
        j = leaf + 1
     endif
  end do
 
  x(i) = val
 
  return
end subroutine mkheap

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long int

void test()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (k >= n)
    {
        cout << 1 << endl;
    }
    else
    {
        n--, k--;
        cout << ceil(n / (k * 1.0)) << endl;
    }
    
}
int32_t main()
{

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test();
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,m;
    int c=0;
    int a[1000][1000],b[1000];
    cin>>n>>m;
     for(int i=1;i<=n;i++){
         for(int j=1;j<=m;j++){
         cin>>a[i][j];
         }}
         
        for(int j=1;j<=m;j++){
         cin>>b[j];
         } 
         
    for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
          
        c=c+a[i][j]*b[j];
    }  
    cout<<c<<endl;
    c=0;
    }
}

Measured memory_bytes: 3240
using System;
using System.Diagnostics;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = Console.ReadLine()
                .Split(' ')
                .Sum(x => int.Parse(x))
                >= 22 ? "bust" : "win";

            Debug.WriteLine(result);
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          998244353
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<class T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll h = in(), w = in();
    ll c[10][10]; REP(i, 10)REP(j, 10)c[i][j] = in();
    REP(k, 10) {
        REP(i, 10) {
            REP(j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    ll ans = 0;
    REP(i, h) {
        REP(j, w) {
            ll a = in();
            if (a != -1) {
                ans += c[a][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll x,y;
    cin>>x>>y;
    ll f = x;
    ll ans = 0;
    while(f<=y)ans++,f=f*2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// Contest No.: ABC175
// Problem No.: C
// Solver:      Jinmin Goh
// Date:        20200815

#include <cstring>
#include <iostream>
#include <cstdlib>
#include <list>
#include <array>
#include <atomic>
#include <algorithm>
#include <deque>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <valarray>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int nums[200010];

int main() {
    long long int x, k, d;
    scanf("%lld %lld %lld", &x, &k, &d);
    if(x < 0) x = -x;

    //printf("%lld %lld %lld\n", d, x, k);

    long long int divVal = x / d, ans = 0;
    if(k <= divVal) {
        ans = x - k * d;
    }
    else {
        k -= divVal;
        x -= divVal * d;
        //printf("%lld %lld %lld\n", divVal, x, k);
        if(k % 2) {
            x -= d;
        }
        ans = abs(x);
    }

    printf("%lld", ans);
    return 0;
}

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

ll N, X;
vector<ll> x(200010, 0);
vector<ll> v(200010, 0);

int main(void){
	
	scanf("%lld %lld", &N, &X);
	for(int i = 1; i <= N; ++i) scanf("%lld", &x[i]);
	
	ll sum = 0;
	for(int i = 1; i <= N; ++i) sum += x[i], v[i] = sum;
	
	ll ans = LLONG_MAX;
	for(int k = 1; k <= N; ++k){
	    ll sum = 0;
	    for(int i = 0; i < (N - 1) / k + 1; ++i){
	        ll M = N - i * k;
            ll m = max(0LL, M - k);
            ll c = (i == 0) ? 5 : 2 * i + 3;
            sum += c * (v[M] - v[m]);
            if(sum < 0) break;
	    }
	    sum += N * X + k * X;
	    if(sum > 0) ans = min(ans, sum);
	}
	printf("%lld\n", ans);
	
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
#define ll long long
int main(){
    int A, B, C, D, N;
    cin >> N >> A >> B >> C >> D;
    int target = B - A;
    for(int a = 0; a <= N - 1; a++){
        int b = N - 1 - a;
        ll mn = a * 1ll *C - b * 1ll * D;
        ll mx = a * 1ll * D - b * 1ll * C;
        if(target >= mn && target <= mx){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;

vector<int> dx = {-1,1,0,0};
vector<int> dy = {0,0,-1,1};

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> maze(h+2,vector<char>(w+2,'#'));
  int walls = 0;
  rep1(i,h){
    rep1(j,w){
      cin >> maze[i][j];
      if(maze[i][j] == '#') walls ++;
    }
  }
  queue<pair<int,int>> q;
  q.push(make_pair(1,1));
  vector<vector<bool>> seen(h+2,vector<bool>(w+2,0));
  vector<vector<int>> dist(h+2,vector<int>(w+2,-1));
  dist[1][1] = 0;
  while(!q.empty()){
    int x,y;
    x = q.front().first;
    y = q.front().second;
    q.pop();
    if(seen[x][y]) continue;
    seen[x][y] = 1;
    if(x<1 || x>h) continue;
    if(y<1 || y>w) continue;
    rep(i,4){
      int nx = x+dx[i];
      int ny = y+dy[i];
      bool sub1 = seen[nx][ny] == 0;
      bool sub2 = maze[nx][ny] == '.';
      if(sub1 && sub2){
        dist[nx][ny] = dist[x][y]+1;
        q.push(make_pair(nx,ny));
      }
    }
  }
  if(dist[h][w] == -1){
    cout << -1 << endl;
    return 0;
  }
  int white = dist[h][w] + 1;
  cout << h*w - walls - white << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int l[n];
  REP(i, n) cin>>l[i];
  int ans = 0;
  REP(k, n){
    REP(j, k){
      REP(i, j){
        vector<int> edges;
        edges.push_back(l[i]);
        edges.push_back(l[j]);
        edges.push_back(l[k]);
        sort(ALL(edges));
        if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
        if(edges[2] < edges[0] + edges[1]) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] dp = new long[n+1];
		Arrays.fill(dp, 10000000000l);
		dp[0] = 0;
		for(int i = 1; i <= n; i++) {
			dp[i] = Math.min(dp[i], dp[i-1]+1);
			for(int j = 6; j <= 100000; j*=6) {
				if(i>=j) dp[i] = Math.min(dp[i], dp[i-j]+1);
			}
			for(int j = 9; j <= 100000; j*=9) {
				if(i>=j) dp[i] = Math.min(dp[i], dp[i-j]+1);
			}
		}
		System.out.println(dp[n]);	
	}

}

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

int main(){
    double pi = 3.141592653589;

    // int r;
    double r;
    cin >> r;

    double menseki = pi * r * r;
    double enshuu = 2 * pi * r;

    printf("%f %f", menseki, enshuu);

    return 0;
}


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

using namespace std;

const int z = 1e9+7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int count[26] = {0};
    for (char c : s) {
        count[c-'a']++;
    }

    int ans = 1;
    for (int i = 0; i < 26; i++) {
        ans = 1ll * ans * (count[i] + 1) % z;
    }
    ans--;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 100003, M = 1024, mod = 998244353;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
void qmo(int &x){x += (x >> 31) & mod;}
int ksm(int a, int b){
	int res = 1;
	for(;b;b >>= 1, a = (LL) a * a % mod) if(b & 1) res = (LL) res * a % mod;
	return res;
}
template<typename T>
inline bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
int n, m, head[N], to[N], nxt[N], cnt, f[3][M], sg[N], pw[N], ans; bool vis[N];
void add(int a, int b){
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
void solve(int t){
	cnt = 0; read(m);
	for(Rint i = 1;i <= n;++ i) head[i] = sg[i] = 0;
	for(Rint i = 1, u, v;i <= m;++ i){
		read(u); read(v); if(u > v) swap(u, v); add(u, v);
	}
	for(Rint i = n;i;-- i){
		for(Rint j = head[i];j;j = nxt[j]) vis[sg[to[j]]] = true;
		for(;vis[sg[i]];++ sg[i]); qmo(f[t][sg[i]] += pw[i] - mod);
		for(Rint j = head[i];j;j = nxt[j]) vis[sg[to[j]]] = false;
	}
}
int main(){
	read(n); pw[0] = 1; pw[1] = 716070898;
	for(Rint i = 2;i <= n;++ i) pw[i] = (LL) pw[i-1] * pw[1] % mod;
	for(Rint t = 0;t < 3;++ t) solve(t);
	for(Rint i = 0;i < M;++ i)
		for(Rint j = 0;j < M;++ j)
			qmo(ans += (LL) f[0][i] * f[1][j] % mod * f[2][i^j] % mod - mod);
	printf("%d\n", ans);
} // NTFTSD0

Measured memory_bytes: 5728
while True:
    h,w=map(int,input().split())
    if ([w,h]==[0,0]):
        exit()
    for i in range(h):
        if (i != 0 and i != h-1):
            print('#' + '.'*(w-2) + '#')
        else:
            print('#'*w)
    print()


Measured memory_bytes: 5612
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = [-A[i] for i in range(N)]
A = sorted(A)
cnt = 0
while cnt<M:
    a = heapq.heappop(A)*(-1)
    a = a/2
    heapq.heappush(A,-a)
    cnt += 1
A = [int(-A[i]) for i in range(N)]
print(sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    string a, b;
    cin >> a >> b;
    int l = sz(a);
    int ans = 0;
    rep(i, 0, l) ans += (a[i] != b[i]);
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 2e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ll fact[MAXN], invfact[MAXN];
ll factsum[MAXN];

ll expo( ll base, ll exp )
{
    ll res = 1;
    while( exp > 0 )
    {
        if( exp&1 )
        {
            res *= base;
            res = mod(res);
        }
        base *= base;
        base = mod(base);
        exp /= 2;
    }
    res = mod(res);
    return res;
}

ll modinv( ll x, ll m = MOD )
{
    return expo(x,m-2);
}

ll choose( ll n, ll k )
{
    if( k < 0 || k > n )
        return 0;
    ll ans = fact[n];
    ans = mod( ans * invfact[k] );
    ans = mod( ans * invfact[n-k] );
    return ans;
}

void add( ll &x, ll y )
{
    x += y;
    if( x >= MOD )
        x -= MOD;
}

void subtract( ll &x, ll y )
{
    x -= y;
    if( x < 0 )
        x += MOD;
}

int main() 
{
    fastio();

    fact[0] = invfact[0] = 1;
    factsum[0] = 1;
    for(int i=1;i<MAXN;i++)
    {
        fact[i] = mod( i * fact[i-1] );
        invfact[i] = modinv( fact[i] );
        add( factsum[i], fact[i] );
    }

    int n;
    cin>>n;
    vector<ll>c(n);
    ll ans = 0, sub = 0;
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        add( ans, c[i] );
    }

    if( n == 1 )
    {
        ans = mod( ans * expo(2,n) );
        cout<<ans,nl;
        return 0;
    }

    sort(all(c));

    ans = mod( ans * (n+1) );
    ans = mod( ans * expo(2,n-2) );
    for(int i=0;i<n;i++)
    {
        add( sub, mod(i*c[i]) );
    }

    sub = mod( sub * expo(2,n-2) );

    subtract( ans, sub );
    ans = mod( ans * expo(2,n) );
    cout<<ans,nl;



    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

int g[2001][2001];

int hor[2001][2001];
int ver[2001][2001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m,q;
	cin>>n>>m>>q;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		for(int j=0;j<m;j++)
			if(s[j]=='1')
				g[i][j+1]=1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<m;j++){
			if(g[i][j]&&g[i][j+1])
				ver[i][j]=1;
			ver[i][j]+=ver[i-1][j]+ver[i][j-1]-ver[i-1][j-1];
		}
	for(int j=1;j<=m;j++)
		for(int i=1;i<n;i++){
			if(g[i][j]&&g[i+1][j])
				hor[i][j]=1;
			hor[i][j]+=hor[i-1][j]+hor[i][j-1]-hor[i-1][j-1];
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			g[i][j]+=g[i-1][j]+g[i][j-1]-g[i-1][j-1];
	while(q--){
		int x1,x2,y1,y2;
		cin>>x1>>y1>>x2>>y2;
		int ans = g[x2][y2]-g[x1-1][y2]-g[x2][y1-1]+g[x1-1][y1-1];
		if(x1<x2){
			ans-=hor[x2-1][y2]-hor[x1-1][y2]-hor[x2-1][y1-1]+hor[x1-1][y1-1];
		}
		if(y1<y2){
			ans-=ver[x2][y2-1]-ver[x1-1][y2-1]-ver[x2][y1-1]+ver[x1-1][y1-1];
		}
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 48768
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

using P = pair<int,int>;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    {
        string tmp;
        cin>>tmp;
        for(int i=0;i<n;i++) a[i] = tmp[i]-'0';
    }
    vector<int> b(n-1);
    for(int i=0;i<n-1;i++) b[i] = abs(a[i+1]-a[i]);

    if(n==2){
        cout<<b[0]<<endl;
        return 0;
    }
    auto f=[&](int x){
        int res=0;
        for(int i=0;i<20;i++){
            res+=(x>>i);
        }
        return res;
    };
    auto judge=[&](int x,int y){
        int res = f(x+y)-f(x)-f(y);
        return res==0;
    };
    int cnt1=count(b.begin(),b.end(),1);
    int cnt2=count(b.begin(),b.end(),2);
    int cntT=0;
    int cnt2T=0;
    for(int i=0;i<n-1;i++){
        if(b[i]==1){
            int x = n-2-i;
            int y = i;
            if(judge(x,y)) cntT++;
        }
        if(b[i]==2){
            int x = n-2-i;
            int y = i;
            if(judge(x,y)) cnt2T++;
        }
    }
    
    if(cntT%2==1){
        cout<<1<<endl;
    }
    else if(cnt1==0 && cnt2T%2==1){
        cout<<2<<endl;
    }
    else{
        cout<<0<<endl;
    }
    
    return 0;
}


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

int main() {
	int a, b, c, k, ans, other;
	
	cin >> a >> b >> c >> k;

	ans = max({ a,b,c });

	if (ans == a) {
		other = b + c;
	}
	else if (ans == b) {
		other = c + a;
	}
	else if (ans == c) {
		other = a + b;
	}

	for (int i = 0; i < k; i++) {
		ans *= 2;
	}

	cout << ans+other << endl;

	return 0;
}

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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  int A, B, C, X, ret = 0;
  cin >> A >> B >> C >> X;
  
  for(int i = 0; i <= A; i++){
    if(500 * i == X){
      ret++;
      break;
    }else if(500 * i < X){
      for(int j = 0; j <= B; j++){
        if(500 * i + 100 * j == X){
          ret++;
          break;
        }else if(500 * i + 100 * j < X){
          for(int k = 0; k <= C; k++){
            if(500 * i + 100 * j + 50 * k == X){
              ret++;
              break;
            }else if(500 * i + 100 * j + 50 * k > X){
              break;
            }
          }
        }else{
          break;
        }
      }
    }else{
      break;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= N; i++) {
            if ((1 <= i && i <= 9) || (100 <= i && i <= 999) || (10000 <= i && i <= 99999)) {
                count++;
            }
        }
        System.out.print(count);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}



Measured memory_bytes: 23892
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int x[100];
int y[100];
int h[100];

int f(int dx, int dy, int hh){
  return hh + abs(dx) + abs(dy);
}

int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> x[i] >> y[i] >> h[i];

  rep(i, N){
    if(h[i]){
      swap(x[i], x[0]);
      swap(y[i], y[0]);
      swap(h[i], h[0]);
      break;
    }
  }

  rep(cx, 101){
    rep(cy, 101){
      int H = f(x[0] - cx, y[0] - cy, h[0]);
      rep(i, 1, N){
        if(f(x[i] - cx, y[i] - cy, h[i]) == H) continue;
        if(h[i] == 0 && f(x[i] - cx, y[i] - cy, h[i]) >= H) continue;
        goto F;
      }
      printf("%d %d %d\n", cx, cy, H);
      return 0;
F:;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {

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

	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	cout << (N - 2) / (K - 1) + 1;

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		System.out.println(fact(n));
	}

	public static long fact(long n)
	{
		if(n<=1)
			return 1;
		n = n*fact(n-1);
		return n;
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;

int main(){
int n,m,p;
while(cin>>n>>m>>p && n!=0){
int a[104]={0};
int sum=0;
for(int i=1;i<n+1;i++){
cin>>a[i];
sum=sum+a[i];
}
int ans=sum*(100-p);
if(a[m]==0) ans=0;
else ans=ans/a[m];
cout<<ans<<endl;

}



return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] L = new int[n];
    for(int i=0;i<n;i++)L[i]=sc.nextInt();
    Arrays.sort(L);
    int l = 0;
    int r = 1;
    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        l=j;
        r=n;
        while(r-l>1){
          int m = (l+r)/2;
          if(L[m]<L[i]+L[j])l=m;
          else r=m;
        }
        ans+=l-j;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26612
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        while(true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            char grade;
            
            if (m == -1 &&
                f == -1 &&
                r == -1) {
                break;
            }
            if (m == -1 || f == -1) {
                grade = 'F';
            } else if (m + f >= 80) {
                grade = 'A';
            } else if (m + f >= 65) {
                grade = 'B';
            } else if (m + f >= 50 || r >= 50) {
                grade = 'C';
            } else if (m + f >= 30) {
                grade = 'D';
            } else {
                grade = 'F';
            }
            System.out.println(grade);
        }
        
    }
}



Measured memory_bytes: 26120
#include<bits/stdc++.h>
using namespace std;
string s, t;
int ans, x;
int main()
{
    cin>>s>> t;
    if(s.length()>t.length())x=s.length();
    else x=t.length();
    for(int i=0; i<x; i++)
        if(s[i]!=t[i]) ans++;
    cout<< ans;
}


Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <set>

using Int = long long int;
using std::vector;

int main() {
    int n;
    std::cin >> n;
    vector<Int> a(n);
    for (auto& x : a) std::cin >> x;

    std::set<Int> primes;
    for (auto x : a) {
        for (Int p = 2; p * p <= x; ++p) {
            if (x % p != 0) continue;
            primes.insert(p);
            while (x % p == 0) x /= p;
        }
        if (x > 1) primes.insert(x);
    }

    Int ans = 0;
    for (auto p : primes) {
        Int sum = 0;
        for (auto x : a) {
            if (x % p == 0) sum += x;
        }
        ans = std::max(ans, sum);
    }

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



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


int main()
{
    string a, b;
    cin >> a >> b;
    if(a == b.substr(0, a.size()))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


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

int main() 
{
    int p, q, r;
    cin >> p >> q >> r;

    int ans = min(r+p, min(p+q, q+r));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
arnum = input().split()
n = int(arnum[0])
m = int(arnum[1])
road = []
for i in range(m):
    lists = [int(x) for x in input().split()]
    road.append(int(lists[0]))
    road.append(int(lists[1]))
for j in range(1,n+1):
    print(road.count(j))

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

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

 string a,b,ans="";
 cin>>a>>b;
 int dp[b.size()+1][a.size()+1]={0};
 int n=b.size(),m=a.size();
 int f=0;
 for(int i=0;i<a.size();i++)
 {
      if(a[i]==b[0])
      f=1;
      dp[0][i]=f;
      
 }
 f=0;
 for(int i=0;i<b.size();i++)
 {
      if(a[0]==b[i])
      f=1;
      dp[i][0]=f;
 }
 for(int i=1;i<b.size();i++)
 {
      for(int j=1;j<a.size();j++)
      {
           if(b[i]==a[j])
           {
                dp[i][j]=dp[i-1][j-1]+1;
           }
           else
           {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
           }
      }
 }
//  for(int i=n-5;i<n;i++)
//  {
//       for(int j=0;j<m;j++)
//       cout<<dp[i][j]<<" ";
//       cout<<endl;
//  }
 //cout<<dp[n-1][m-1]<<endl;
 for(int i=n-1,j=m-1;i>=0&&j>=0;)
 {
     // cout<<i<<" "<<j<<" "<<b[i]<<" "<<a[j]<<" "<<dp[i][j]<<endl;
      if(b[i]==a[j]){
      ans=b[i]+ans;
      i--;
      j--;
      }
      else if(i-1>=0)
      {
           if(dp[i-1][j]==dp[i][j])
           i--;
           else
           j--;
      }
      else
      {
           j--;
      }
 }

 cout<<ans;
 
}

Measured memory_bytes: 35456
def gli
  gets.split.map(&:to_i)
end

n, k = gli
d = gli

# ret = ""
# carry = 0
# n.to_s.reverse.each_char {|c|
#   g = c.to_i + carry
#   while d.include?(g%10)
#     g += 1
#   end
#   carry = g/10
#   ret += (g%10).to_s
# }
# while carry > 0
#   while d.include?(carry%10)
#     carry += 1
#   end
#   ret += (carry%10).to_s
#   carry = carry/10
# end
#
# puts ret.reverse.to_i

while true
  if n.to_s.split("").map(&:to_i).any? {|k| d.include?(k)}
    n += 1
  else
    puts n
    exit
  end
end


Measured memory_bytes: 2300
function main()
	N=parse(Int,readline())
	A=sort(map(x->parse(Int,x),split(readline())))
	M=parse(Int,readline())
	B=sort(map(x->parse(Int,x),split(readline())))
	id=1
	for b=B
		while id<=N&&A[id]<b
			id+=1
		end
		if id>N||A[id]!=b
			println("NO")
			exit()
		end
		id+=1
	end
	println("YES")
end
main()


Measured memory_bytes: 154984
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int N,M,K;
  in(N,M,K);
  up(i,0,N){
    up(j,0,M){
      if(i*(M-j)+j*(N-i)==K){
        out("Yes");
        return;
      }
    }
  }
  out("No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <stdio.h>
int color[8]={0};
//cntはレート3200以上
int cnt=0;
void check(int a){
    if(1<=a&&a<=399)color[0]++;
    else if(a<=799)color[1]++;
    else if(a<=1199)color[2]++;
    else if(a<=1599)color[3]++;
    else if(a<=1999)color[4]++;
    else if(a<=2399)color[5]++;
    else if(a<=2799)color[6]++;
    else if(a<=3199)color[7]++;
    else if(a>=3200)cnt++;
}
int main(void){
    int n,min=0,max=0,u,c=0;
    int a[100];
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        u=a[i];
        check(u);
    }
    //cはレート3200以下の種類
    for(i=0;i<8;i++){
        if(color[i]>0)c++;
    }
    
    if(c==0&&cnt>0)min=1;
    else if(c>=1){
        min=c;
    }
    max=c+cnt;
    printf("%d %d\n",min,max);
    return 0;
    
}

Measured memory_bytes: 128
n=int(input())
ans=0
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

for i in range(n):
  ans+=B[i]
for j in range(n-1):
  if (A[j]+1)==A[j+1]:
    ans+=C[A[j]-1]
print(ans)

Measured memory_bytes: 3064
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------

# s で始まる七五三数
def dfs(s):
    if int(s) > N:
        return 0
    if s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
        cnt = 1
    else:
        cnt = 0
    for c in "753":
        cnt += dfs(s + c)
    return cnt
    

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

print(dfs("0"))

Measured memory_bytes: 3060