akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 3e5 + 15, MOD = 1e9 + 7;
string s;
int n, ans;
int dp[MAX_N][3][2][2][5];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	if (c < 0)
		c += MOD;

	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int _pow (int a, int b) {
	if (!b)
		return 1;

	int res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);
	return res;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	n = s.size();
	s = '#' + s;

	int num = 0;
	for (int i = 1; i <= n; i++)
		num += s[i] == '?';

	if (s[1] != '0')
		dp[1][2][1][1][0] = 1;
	if (s[1] != '1')
		dp[1][2][0][1][2] = 1;

	for (int i = 1;  i < n; i++)
		for (int j = 0; j < 4; j++) {
			if (s[i + 1] != '1') {
				if (j) dp[i + 1][1][0][0][j - 1] = _sum(dp[i + 1][1][0][0][j - 1], dp[i][0][0][0][j]);
				if (j) dp[i + 1][2][0][1][j - 1] = _sum(dp[i + 1][2][0][1][j - 1], dp[i][0][0][1][j]);

				dp[i + 1][0][0][0][j + 1] = _sum(dp[i + 1][0][0][0][j + 1], dp[i][0][1][0][j]);
				dp[i + 1][2][0][1][j + 1] = _sum(dp[i + 1][2][0][1][j + 1], dp[i][0][1][1][j]);

				dp[i + 1][0][0][0][j + 1] = _sum(dp[i + 1][0][0][0][j + 1], dp[i][1][0][0][j]);
				dp[i + 1][0][0][0][j + 1] = _sum(dp[i + 1][0][0][0][j + 1], dp[i][1][0][1][j]);

				dp[i + 1][1][0][0][j + 1] = _sum(dp[i + 1][1][0][0][j + 1], dp[i][1][1][0][j]);
				dp[i + 1][1][0][0][j + 1] = _sum(dp[i + 1][1][0][0][j + 1], dp[i][1][1][1][j]);

				dp[i + 1][0][0][1][j + 1] = _sum(dp[i + 1][0][0][1][j + 1], dp[i][2][0][1][j]);
				dp[i + 1][1][0][1][j + 1] = _sum(dp[i + 1][1][0][1][j + 1], dp[i][2][1][1][j]);
			}
			if (s[i + 1] != '0' && j) {
				dp[i + 1][0][1][0][j - 1] = _sum(dp[i + 1][0][1][0][j - 1], dp[i][0][0][0][j]);
				dp[i + 1][0][1][0][j - 1] = _sum(dp[i + 1][0][1][0][j - 1], dp[i][0][0][1][j]);

				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][0][1][0][j]);
				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][0][1][1][j]);

				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][1][0][0][j]);
				dp[i + 1][2][1][1][j - 1] = _sum(dp[i + 1][2][1][1][j - 1], dp[i][1][0][1][j]);

				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][1][1][0][j]);
				dp[i + 1][1][1][0][j - 1] = _sum(dp[i + 1][1][1][0][j - 1], dp[i][1][1][1][j]);

				dp[i + 1][0][1][1][j - 1] = _sum(dp[i + 1][0][1][1][j - 1], dp[i][2][0][1][j]);
				dp[i + 1][1][1][1][j - 1] = _sum(dp[i + 1][1][1][1][j - 1], dp[i][2][1][1][j]);
			}
		}

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 2; j++)
			for (int t = 0; t < 2; t++)
				for (int k = 1; k < 4; k++)
					ans = _sum(ans, dp[n][i][j][t][k]);

	cout << _sub(_pow(2, num), ans) << "\n";
	return 0;
}

Measured memory_bytes: 71020
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>

using namespace std;

#define sqr(x) x * x
#define all(x) x.begin(), x.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
typedef long long ll;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int& e : h) cin >> e;
	vector<int> d(n, INF);
	d[0] = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 1; j <= k && i + j < n; ++j)
			d[i + j] = min(d[i + j], d[i] + abs(h[i] - h[i + j]));
	}
	cout << d.back();
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        class Matrix {
            private int x, y;
            private long[][] mat;
            public Matrix(int inX, int inY) {
                x = inX;
                y = inY;
                mat = new long[inX][inY];
            }
            public void set(int x, int y, long num) {
                mat[x][y] = num;
            }
            public long get(int x, int y) {
                return mat[x][y];
            }
            public int getX() { return x;}
            public int getY() { return y;}
            public Matrix mult(Matrix matB) {
                int ax = this.getX(), ay = this.getY();
                int bx = matB.getX(), by = matB.getY();
                Matrix ans = new Matrix(ax, by);

                for (int i = 0; i < ax; i++) {
                    for (int j = 0; j < by; j++) {
                        long sum = 0;
                        for (int k = 0; k < ay; k++) {
                            sum += this.get(i, k) * matB.get(k, j);
                        }
                        ans.set(i, j, sum);
                    }
                }

                return ans;
            }
        }
        Scanner scan = new Scanner(System.in);
        Matrix matA, matB, ans;
        int n, m, l;
        n = Integer.parseInt(scan.next());
        m = Integer.parseInt(scan.next());
        l = Integer.parseInt(scan.next());

        matA = new Matrix(n, m);
        matB = new Matrix(m, l);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                matA.set(i, j, Long.parseLong(scan.next()));
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                matB.set(i, j, Long.parseLong(scan.next()));
            }
        }
        ans = matA.mult(matB);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                System.out.print(ans.get(i, j));
                if (j != l - 1) System.out.print(" ");
            }
            System.out.print("\n");
        }

    }
}



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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[n+1],b[n+1];
    rep(i,1,n+1){
        cin >> a[i] >> b[i];
    }
    for(int i=3; i<=n; i++){
        if(a[i]==b[i] && a[i-1]==b[i-1] && a[i-2]==b[i-2]){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n,a=0,b=0,c=0;
    cin>>n;
    ll v[n][3];
    ll dp[n][3];
    memset(dp,0,sizeof(dp));
    r(i,0,n)
    {
      r(j,0,3)
        cin>>v[i][j];
    }
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];
    r(i,1,n)
    {
        dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
      
}

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

#define ll long long
#define pb push_back
#define N 1000000007
#define pll pair<ll,ll>
#define fill(A,n) for(int i=0;i<n;i++) cin>>A[i];

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

    vector<double> A(n);
    fill(A,n);

    vector<vector<double> > dp(n+1,vector<double>(n+1,0));
    dp[0][0] = 1;

    for(int i=1;i<=n;i++)
    	dp[i][0] = dp[i-1][0]*(1-A[i-1]);


    for(int i=1;i<=n;i++) {
    	for(int j=1;j<=i;j++) {
    		dp[i][j] = dp[i-1][j]*(1-A[i-1]) + dp[i-1][j-1]*A[i-1];
    	}
    }

    double sum = 0;
    for(int i=n/2+1;i<=n;i++) {
    	sum += dp[n][i];
    }
    cout<<setprecision(10)<<sum<<endl;

    return 0;
}




Measured memory_bytes: 70784
A, B, K = map(int, input().split())
S = set()

for x in range(A, A+K):
	if x > B:
		break
	
	S.add(x)

for x in range(B, B-K, -1):
	if x < A:
		break
	
	S.add(x)

L = list(S)
L.sort()

for x in L:
	print(x)


Measured memory_bytes: 3060
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	hh := make([]int, n)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		hh[i] = getNextInt(scanner) - 1
	}
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	dec := newDecomposition(n)
	for i := 0; i < n; i++ {
		m := dec.max(0, hh[i])
		dec.maximize(hh[i], m+aa[i])
	}
	fmt.Fprintln(writer, dec.max(0, n))
}

type decomposition struct {
	chunk  int
	bucket [][]int64
}

func newDecomposition(n int) decomposition {
	bucket := make([][]int64, 1)
	bucket[0] = make([]int64, n)
	chunk := 2
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		bucket = append(bucket, make([]int64, n))
	}
	return decomposition{
		chunk:  chunk,
		bucket: bucket,
	}
}
func (dec *decomposition) upleft(l int) int {
	return (l + dec.chunk - 1) / dec.chunk
}
func (dec *decomposition) upright(r int) int {
	return r / dec.chunk
}
func (dec *decomposition) maximize(index int, value int64) {
	dec.bucket[0][index] = value
	h := len(dec.bucket)
	for i := 0; i < h-1; i++ {
		p := index / dec.chunk
		r := (p + 1) * dec.chunk
		if r >= len(dec.bucket[i]) {
			r = len(dec.bucket[i])
		}
		dec.bucket[i+1][p] = value
		for j := p * dec.chunk; j < r; j++ {
			if dec.bucket[i+1][p] < dec.bucket[i][j] {
				dec.bucket[i+1][p] = dec.bucket[i][j]
			}
		}
		index /= dec.chunk
	}
}
func (dec *decomposition) max(l, r int) int64 {
	return dec.maxh(l, r, 0)
}
func (dec *decomposition) maxh(l, r, h int) int64 {
	m := dec.bucket[h][l]
	ll := dec.upleft(l)
	rr := dec.upright(r)
	for i := l; i < r && i < ll*dec.chunk; i++ {
		if m < dec.bucket[h][i] {
			m = dec.bucket[h][i]
		}
	}
	if ll < rr {
		mm := dec.maxh(ll, rr, h+1)
		if m < mm {
			m = mm
		}
	}
	for i := rr * dec.chunk; i < r && ll <= rr; i++ {
		if m < dec.bucket[h][i] {
			m = dec.bucket[h][i]
		}
	}
	return m
}


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

import sys
sys.setrecursionlimit(10 ** 9)
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()))

N=INT()

memo=[0]*50
memo[0]=memo[1]=1
def rec(n):
    if memo[n]:
        return memo[n]
    memo[n]=rec(n-1)+rec(n-2)
    return memo[n]

print(rec(N))



Measured memory_bytes: 5608
/*Bismillah Hir Rahmanir Rahim*/

#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, t, i, j, k, sum=0, tem=0, maxi, mini, arr[102];
    string s1, s2, s3;
    double po, pi;
    pi=4*atan(1);
    cin>>n;
    po=2*pi*n;
    cout<<po<<endl;




    return 0;
}


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


long int hoge[100];
long int lucas(int n) {
    if (n==0) {
        return 2;
    }
    if (n==1) {
        return 1;
    }
    if (hoge[n]!=0) {
        return hoge[n];
    }
    return hoge[n]=lucas(n-1)+lucas(n-2);
}


int main(void) {
    int n;
    cin>>n;
    cout<<lucas(n)<<endl;
}


Measured memory_bytes: 384
h1,p1,h2,p2 = gets.chomp.split(" ").map(&:to_i)

lose = 0

while lose == 0
  h2 -= p1
  if h2 < 1
    lose = 2
    break
  end
  h1 -= p2
  if h1 < 1
    lose = 1
    break
  end
end

if lose == 1
  puts("No")
else
  puts("Yes")
end

Measured memory_bytes: 14416
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N, M;
      cin >> N >> M;
      int x;
      x = N+1-2*M;
     if (x < 0) {
      cout << "NO" << endl;}
     else {cout << "YES" << endl;
      }
      }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];

int main() {
    int n,i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        cin>>s[i];
    sort(s,s+n);
    int m=1,cnt=1;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        m=max(cnt,m);
    }
    cnt=1;
    if(m==1)
        cout<<s[0]<<endl;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        if(cnt==m)
            cout<<s[i]<<endl;
    }
}


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

int main() {
	// your code goes here
	int n,l;
	while(cin>>n>>l && l){
	vector<int> ans;
	ans.push_back(n);
//	cout<<ans[0]<<endl;
	int n0=n;
	int j=0,u;
	while(1){
		vector<int> ve;
	int nn=n;
	for(int i=0;i<l;i++){
			ve.push_back(nn%10);
			nn=nn/10;
	}
	sort(ve.begin(),ve.end());
		int min=0,max=0;
	for(int i=0;i<l;i++){
			min=min+ve[i];
			min=min*10;
	}
	min=min/10;
	sort(ve.begin(),ve.end(),greater<int>());
	for(int i=0;i<l;i++){
			max=max+ve[i];
			max=max*10;
	}
		max=max/10;
		
		n=max-min;
	//	cout<<max<<" "<<min<<" "<<n<<endl;
		j++;
		 u=-1;
		 	
		ans.push_back(n);
		
		for(int i=0;i<j;i++){
	//		cout<<ans[0]<<" "<<ans[1]<<" "<<j<<endl;
			if(ans[i]==ans[j]){
				u=i;
				break;
			}
		}
//		cout<<ans[0]<<" "<<ans[1]<<endl;
		if(u!=-1) break;
	}
	cout<<u<<" "<<ans[j]<<" "<<j-u<<endl;
	
	}
	
	
	
	return 0;
}

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

typedef long long int ll;
int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    int k;
    scanf("%d",&k);
    printf("%d\n",arr[k-1]);
    return 0;
}


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

int main() {
  int n;
  long long p;
  long long a , b , c = 0;
  double root_a, root_b , root_c , root_ab , root_ac , root_bc;
  cin >> a >> b >> c;

//  a + b < c
//  2ab < c - a -b
//  4ab < (c - a - b)^2
//  ( c - a - b > 0 ) && ( 4ab < (c-a-b)^2)
  if ((c-a-b>0) && ( 4 * a * b < (c-a-b)*(c-a-b))){
    cout << "Yes" << endl;
  } else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define CIN(a) cin >> a;
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a
#define COUT2(a, b) cout << a << ' ' << b
#define COUT3(a, b, c) cout << a << ' ' << b << ' ' << c
#define ENDL cout << '\n'
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };

int sum = 0;
string str;

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

	CIN(str);
	for (char ch : str)
	{
		sum += (ch - '0');
	}
	if (sum % 9 == 0) COUT("Yes");
	else COUT("No");

	return 0;
}

Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] value = new int[5];
            for (int i = 0; i < 5; ++i)
            {
                value[i] = int.Parse(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine());
            if ((value[4] - value[0])>k)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }   
    }
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

template <class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template <class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 100000 + 5, MAXM = 10000 + 5;
const LL MAX = 10000000000LL;

int p[MAXM], p_cnt;
bool not_p[MAXN];
LL cube[MAXN];
std::map<LL, int> square;
std::map<std::pair<LL, LL>, int> s;

IL void init(int n) {
  not_p[1] = 1;
  For(i, 2, n) {
    if (!not_p[i]) {
      ++ p_cnt;
      p[p_cnt] = i, cube[p_cnt] = (LL)i * i * i;
      square[(LL)i * i] = i;
    }
    for (int j = 1; j <= p_cnt && i * p[j] <= n; ++ j) {
      not_p[i * p[j]] = 1;
      if (!(i % p[j])) {
        break;
      }
    }
  }
}

int main() {
  init(100000);
  int n;
  scanf("%d", &n);
  int answer = 0;
  For(i, 1, n) {
    LL cur;
    scanf("%lld", &cur);
    LL x = 1, y = 1;
    for (int j = 1; j <= p_cnt && cube[j] <= MAX; ++ j) {
      if (!(cur % p[j])) {
        while (!(cur % cube[j])) {
          cur /= cube[j];
        }
        if (!(cur % p[j])) {
          LL z = 1, w = cube[j];
          while (!(cur % p[j])) {
            cur /= p[j], z *= p[j], w /= p[j];
          }
          x *= z, y *= w;
          if (x > MAX || y > MAX) {
            ++ answer;
            goto NEXT;
          }
        }
      }
    }
    if (cur != 1) {
      x *= cur;
      if (square.count(cur)) {
        y *= square[cur];
      } else if (cur > 100000 || y > 2200) {
        ++ answer;
        goto NEXT;
      } else {
        y *= cur * cur;
      }
      if (x > MAX || y > MAX) {
        ++ answer;
        goto NEXT;
      }
    }
    ++ s[std::make_pair(x, y)];
    NEXT: ;
  }
  for (auto &x : s) {
    if (x.first.first == 1 && x.first.second == 1) {
      ++ answer;
      continue;
    }
    auto it = s.find(std::make_pair(x.first.second, x.first.first));
    if (it == s.end() || x.second >= it->second) {
      answer += x.second;
      x.second = INF;
    }
  }
  printf("%d\n", answer);
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll n;
ll a[310];
int dp[301][90001][2];

ll dfs(ll i,ll s,bool f){
  if(dp[i][s][f]!=-1)return dp[i][s][f];
  if(i==n){
    if(!f) return dp[n][s][f]=mod_pow(s,n);
    else return dp[n][s][f]=(mod-mod_pow(s,n))%mod;
  }
  ll res=0;
  if(s>=a[i]){
    (res+=dfs(i+1,s-a[i],!f))%=mod;
  }
  (res+=dfs(i+1,s,f))%=mod;
  return dp[i][s][f]=res;
}

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  ll S;
  cin>>S;
  memset(dp,-1,sizeof(dp));
  cout<<dfs(0,S,false)<<endl;
  return 0;
}



Measured memory_bytes: 214748
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long k = sc.nextInt();
        long c = 0;
        if(k % 2 == 0){
            long f1 = k / 2;
            if(f1 <= n) {
                long f2 = ((n - f1) / k + 1);
                c += f2 * f2 * f2;
            }
        }
        if(n >= k) {
            long f2 = ((n - k) / k + 1);
            c += f2 * f2 * f2;
        }
        System.out.println(c);
    }


}




Measured memory_bytes: 23124
n = int(input())
a = list(map(int, input().split()))
a.sort()
cum_a = [a[0]]
for i in range(1, n):
    cum_a.append(cum_a[i-1]+a[i])
res = 0
for i in range(1, n):
    if cum_a[i-1]*2 < a[i]:
        res = i

print(n-res)

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

using namespace std;

char s[3100], t[3100];
int lembra[3100][3100];

int LCS(int n, int m) {
	int result;
	if(n == 0 || m == 0)
		return 0;
	if(lembra[n][m] != -1)
		return lembra[n][m];
	if(s[n-1] == t[m-1]) {
		result = 1 + LCS(n-1, m-1);
	} else {
		result = max(LCS(n-1, m), LCS(n, m-1));
	}
	return lembra[n][m] = result;
}

void printar(int n, int m) {
	int i = n, j = m;
	if(i == 0 || j == 0)
		return;
	if(s[i-1] == t[m-1]) {
		printar(i-1, j-1);
		printf("%c", s[i-1]);
		return;
	} else {
		(lembra[i-1][j] > lembra[i][j-1])? --i: --j;
		printar(i, j);
	}
}



int main() {

	scanf(" %[^\n]", s);
	scanf(" %[^\n]", t);
	int n, tams = strlen(s), tamt = strlen(t);
	memset(lembra, -1, sizeof(lembra));
	n = LCS(tams, tamt);
	printar(tams, tamt);
	puts("");
	return 0;
}

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

int main() {
	long long int n,W;
	cin>>n>>W;
	long long int w[n], v[n];
	
	for( int i=0; i<n; i++)
	{cin>>w[i]>>v[i];}
	
	long long int dp[n][W];
	for( long long int i=n-1; i>=0; i--)
	{
	    for( long long int j=0;j<W; j++)
	    {
	        if(i==n-1)
	        {
	            if(j+1>=w[n-1])
	            dp[i][j]=v[n-1];
	            else
	            dp[i][j]=0;
	        }
	        else
	        {
	            if(j+1<w[i])
	            dp[i][j] = dp[i+1][j];
	            else if(j+1==w[i])
	            dp[i][j]= max(dp[i+1][j], v[i]);
	            else
	            {
	                dp[i][j] = max(dp[i+1][j] ,v[i]+dp[i+1][j-w[i]]);
	            }
	        }
	    }
	}
	
	cout<<dp[0][W-1]<<endl;
	return 0;
}

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

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> a(n),w(n);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>w[i];
  vector<int> x,y;
  for(int i=0;i<n;i++)
    (a[i]?x:y).emplace_back(w[i]);
  if(x.empty()||y.empty()){
    cout<<0<<endl;
    return 0;
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  cout<<x[0]+y[0]<<endl;
  return 0;
}



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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    string s, t;
    cin >> s >> t;

    int ans = inf;
    range(i, 0, s.size() - t.size() + 1) {
        int cnt = 0;
        range(j, 0, t.size()) {
            if (s[i + j] == t[j]) continue;
            cnt++;
        }

        chmin(ans, cnt);
    }

    cout << ans << endl;

}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3648
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;

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

    vector<int> cnt(40);
    rep(i, n){
        int x = a[i];
        rep(j, 40){
            cnt[j] += (x >> j) % 2;
        }
    }

    vector<int> pow(41);
    pow[0] = 1;
    rep(i, 40) pow[i+1] = pow[i] * 2;

    auto dp = initVec3<int>(41, 2, 2, -1);
    dp[40][0][1] = 0;
    for(int i = 40; i > 0; i--){
        rep(j, 2){
            if(dp[i][j][0] != -1){
                dp[i-1][0][0] = max(dp[i-1][0][0], dp[i][j][0] + cnt[i-1] * pow[i-1]);
                dp[i-1][1][0] = max(dp[i-1][1][0], dp[i][j][0] + (n - cnt[i-1]) * pow[i-1]);
            }
            if(dp[i][j][1] != -1){
                if((k >> (i - 1)) % 2 == 0){
                    dp[i-1][0][1] = max(dp[i-1][0][1], dp[i][j][1] + cnt[i-1] * pow[i-1]);
                }else{
                    dp[i-1][1][1] = max(dp[i-1][1][1], dp[i][j][1] + (n - cnt[i-1]) * pow[i-1]);
                    dp[i-1][0][0] = max(dp[i-1][0][0], dp[i][j][1] + cnt[i-1] * pow[i-1]);
                }
            }
        }
    }
    cout << max(dp[0][0][0], max(dp[0][1][0], dp[0][k%2][1])) << endl;

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  int cnt=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      cnt+=a[i]*a[j];
    }
  }
  cout<<cnt/2<<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")

#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

int gcd(int a,int b)
{
    while (a&&b){
        if (a>b){
            a%=b;
        }
        else{
            b%=a;
        }
    }
    return a+b;
}

int nsk(int a,int b)
{
    return a*b/gcd(a,b);
}

signed main()
{
    #ifdef __APPLE__
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int x;
    cin>>x;
    cout<<nsk(x,360)/x<<"\n";
}


Measured memory_bytes: 3652
import math
n, k = (int(i) for i in input().split()) 
mod = 1000000007

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

r = n - k
for i in range(1, k+1):
  if r + 1 >= i:
    print(combinations_count(r+1, i) % mod * combinations_count(k-1, i-1) % mod)
  else:
    print(0)
    
 
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
//[const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

struct UnionFind
{
	vector<int> par;
	UnionFind(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};


int main()
{
	cin.sync_with_stdio(false);
	int h, w;
	while (cin >> w >> h, h)
	{
		vs fld(h);
		REP(i, h) cin >> fld[i];
		int st;
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == '@')
			{
				st = place(i, j, w);
				fld[i][j] = '.';
			}
		}
		UnionFind uf(h*w);
		REP(i, h)REP(j, w)
		{
			if (fld[i][j] == '#') continue;
			REP(k, 4)
			{
				int nx = i + dx[k], ny = j + dy[k];
				if (!valid(nx, ny, h, w) || fld[nx][ny] == '#') continue;
				uf.unite(place(i, j, w), place(nx, ny, w));
			}
		}
		int cnt = 0;
		REP(i, h*w)
		{
			if (uf.same(i, st)) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int r;
    cin >> r;
    cout << 3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005
ll r,l,res=MOD;
int main(){
		_io;
		
		cin>>l>>r;
		if (r-l>=2019){cout<<0; exit(0);}
		FOR(i,l,r-1) FOR(j,i+1,r){
			res=min(res,1ll*i*j%2019);
		}
		cout<<res;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
a = [0]*n
for i in range(n):
    a[i] = p[i]*(p[i]+1)/(2*p[i])
s = sum(a[:k])
ans = s
# print(s)
for i in range(n-k):
    s -= a[i]
    s += a[i+k]
    ans = max(ans,s)
print(ans)

Measured memory_bytes: 25060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

#define rad(x) ((x)*3.141592653589793/180.)

double a, b, c, d;

main(){
    scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
    printf("%.12f\n", fabs(a*exp(rad(c*30.+d/2.)*I) - b*exp(rad(d*6.)*I)));
    return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u){
    --a;
  }else{
    --b;
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,ba,i,j,h[20],stk;
  char b[200];
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    scanf("%s",b);
    j=0;
    ba=0;
    for(i=0;i<a;i++)h[i]=0;
    for(i=0;i<100;i++){
      if(b[i]=='M')h[j]++;
      else if(b[i]=='S'){
	ba+=h[j]+1;
	h[j]=0;
      }else if(b[i]=='L'){
	h[j]+=ba+1;
	ba=0;
      }
      j++;
      if(j==a)j=0;
    }
    for(i=0;i<a*2;i++){
      for(j=1;j<a;j++){
	if(h[j]<h[j-1]){
	  stk=h[j];
	  h[j]=h[j-1];
	  h[j-1]=stk;
	}
      }
    }
    for(i=0;i<a;i++){
      printf("%d ",h[i]);
    }
    printf("%d\n",ba);
  }
  return 0;
}

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

using namespace std;

int n,m;
int node[100001];
int main() {
  cin >> n >> m;

  for(int i = 0; i < m; i++) {
    int a,b;

    cin >> a >> b;
    a--; b--;
    node[a]++;
    node[b]++;
  }

  bool there = true;

  for(int i = 0; i < n; i++) {
    if(node[i] % 2 != 0) there = false;
  }

  if(there) cout << "YES" <<endl;
  else cout << "NO" <<endl;
}
			

    


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
ll modpow(ll a, ll b, ll M) {
	ll res = 1;
	for (; b > 0; b >>= 1) {
		if (b & 1) res = (res * a) % M;
		a = a * a % M;
	}
	return res;
}
int main(){
	int n, k;
	cin >> n >> k;
	VL gcds(k + 1);
	for (int i = k; i >= 1; i--) {
		ll tmp = k / i; // gcdがtmpの倍数になるようなものの個数
		ll tmp2 = modpow(tmp, n, MOD); // tmp^n個だけある(mod 1e9+7)
		for (int j = i + i; j <= k; j += i) { // tmpの倍数ではあるがtmpではないものを引く
			tmp2 -= gcds[j];
		}
		gcds[i] = tmp2;
	}
	ll ans = 0;
	rep1(i, k) {
		ans += i * gcds[i];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3980
/*package whatever //do not write package name here */
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner input=new Scanner(System.in);
       int n=input.nextInt();
       int k=input.nextInt();
       int[] p=new int[n];
       for(int i=0;i<n;i++)
            p[i]=input.nextInt();
        Arrays.sort(p);
        int ans=0;
        for(int i=0;i<k;i++)
            ans+=p[i];
        System.out.println(ans);
       input.close();
	}
}

Measured memory_bytes: 38528
#include<stdio.h>
#include <math.h>
#include <stdlib.h>
 
 
main(void)
{
  int N,a,b,c;
  scanf("%d",&N);
  
  a=N/100;
  
  b=N/10-a*10;
  
  c=N-a*100-b*10;
  
  if(a==7 || b==7 || c==7)
  {
    printf("Yes");
  }
  
  else
  {
    printf("No");
  }
  
 
  
  return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int sum=0;
        for(int i=0;i<n*(n-1)/2;i++){
            int val;
            scanf("%d",&val);
            sum+=val;
        }
        printf("%d\n",sum/(n-1));
    }
    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int L, R;
	cin >> L >> R;
	if ((L%2019==0 || R%2019==0) || (L / 2019 != R / 2019))
	{
		cout << 0;
	}
	else
	{
		ll ans = 2018;
		for (ll i = L; i <= R; i++)
		{
			for (ll j = i+1; j <=R; j++)
			{
				ll cand = i * j;
				cand %= 2019;
				ans = min(ans, cand);
			}
		}
		cout << ans;
	}
	return 0;
}

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



int main (){ 
    int H, W;
    cin>>H>>W;
    int INF=1000;
    int V=H*W;
    vector<vector<int>> d(V, vector<int>(V, INF));
    vector<vector<char>> Ma(H, vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin>>Ma[i][j];
        }
    }
  for(int i=0; i<V; i++){
    	d[i][i]=0;
  }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
          	if(Ma[i][j]=='.'){
            if(i>0){
                if(Ma[i-1][j]=='.'){
                    d[i*W+j][(i-1)*W+j]==1;
                    d[(i-1)*W+j][i*W+j]==1;
                }
            }
            if(i<H-1){
                if(Ma[i+1][j]=='.'){
                    d[i*W+j][(i+1)*W+j]=1;
                    d[(i+1)*W+j][i*W+j]=1;
                }
            }
            if(j>0){
                if(Ma[i][j-1]=='.'){
                    d[i*W+j][i*W+j-1]=1;
                    d[i*W+j-1][i*W+j]=1;
                }
            }
            if(j<W-1){
                if(Ma[i][j+1]=='.'){
                    d[i*W+j][i*W+j+1]=1;
                    d[i*W+j+1][i*W+j]=1;
                }
            }
            }
        }
    }
    for(int k=0; k<V; k++){
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++){
                d[i][j]=min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    
    int Max=0;
    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++){
          	//cout<<d[i][j]<<" ";
            if(d[i][j]<INF){
                Max=max(Max, d[i][j]);
              	
            }
        }
      	//cout<<endl;
    }
    cout<<Max;

}





Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    string s;
    cin >> s;
    int ans=0;
    rep(i,4){
        if(s.at(i)=='+')ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
program test
implicit none

integer(8) :: h,w,k,i,j,ans,big=1d9+7
integer(8) :: go(0:10,3)=0,bou(0:10)=0,dp(0:200,0:10)=0

read(*,*) h,w,k

if(w == 1)then
	write(*,*) 1
else

	!全探査するか…
	do i=0,2**(w-1)-1
		do j=1,w-1
			if(BTEST(i,j-1))then
				bou(j) = 1
			else
				bou(j) = 0
			endif
		enddo
		
		do j=1,w-2
			if(bou(j)+bou(j+1)==2)then
				goto 100
			endif
		enddo
		
		!i番目にいるときに、左に行くか右に行くかそうでないか
		do j=1,w
			if(bou(j-1) == 1) then !左
				go(j,1) = go(j,1) + 1
			else if(bou(j) == 1) then !右
				go(j,3) = go(j,3) + 1
			else
				go(j,2) = go(j,2) + 1
			endif
		enddo
		
		100 continue
		
	enddo




	!とりあえずDPっしょ
	dp(0,1)=1
	do i=1,h
		do j=1,w
			!j-1から右へ、jからそのまま、j+1から左へ
			dp(i,j) = mod(dp(i-1,j-1)*go(j-1,3) +dp(i-1,j)*go(j,2) + dp(i-1,j+1)*go(j+1,1),big)
		enddo
	enddo

	write(*,*) dp(h,k)

endif

end program

Measured memory_bytes: 512