akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class FactInvMOD:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD

        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """
        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def nPr(self, n, r):
        """ 順列 """
        if n < r: return 0
        return self.fact[n] * self.inv[n-r] % self.MOD

N,K=MAP()
nodes=[[] for i in range(N)]
for i in range(N-1):
    a,b=MAP()
    nodes[a-1].append(b-1)
    nodes[b-1].append(a-1)

fim=FactInvMOD(max(N, K), MOD)

ans=1
def rec(u, prev):

    global ans
    # 子ノードの数
    cldcnt=len(nodes[u])
    # 根だけは自分と子を両方決める
    if u==0:
        ans*=fim.nPr(K, cldcnt+1)
    # 他は子について決める
    else:
        # 親の分を引く
        cldcnt-=1
        ans*=fim.nPr(K-2, cldcnt)
    ans%=MOD
    for v in nodes[u]:
        if v!=prev:
            rec(v, u)

rec(0, -1)
print(ans)


Measured memory_bytes: 95304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n;
    double su=0,a;
    string s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a>>s;
        if(s=="JPY")
            su+=a;
        else
            su+=(380000.0*a);
    }
    cout<<su<<endl;
}


Measured memory_bytes: 3768
using System;
using System.Collections.Generic;
using System.Linq;

namespace Snack
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputNumbers = Console.ReadLine().Split();
            long firstNumber = long.Parse(inputNumbers[0]);
            long secondNumber = long.Parse(inputNumbers[1]);

            long highestValue = highestD(firstNumber, secondNumber);
            long lowestValue = (firstNumber * secondNumber) / highestValue;

            Console.WriteLine(lowestValue);
        }

        static long highestD(long firstNumber, long secondNumber)
        {
            long highestValue = 0;
            while (secondNumber != 0)
            {
                highestValue = firstNumber % secondNumber;
                firstNumber = secondNumber;
                secondNumber = highestValue;
            }
            return firstNumber;
        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){
    int n, k; cin >> n >> k;
    vector<ll> X(n), Y(n);
    rep(i, n) cin >> X[i] >> Y[i];

    ll res = LLONG_MAX;
	rep(a, n){
      rep(b, n){
        rep(c, n){
          rep(d, n){
          	ll lx = X[a], rx = X[b], ly = Y[c] , ry = Y[d];
            if(lx >= rx || ly >= ry)continue;
            //構成された長方形が含む点の数を数える
            int cnt = 0;
            rep(i, n){
              ll x = X[i], y = Y[i];
              if(x >= lx && x <= rx && y >= ly && y <= ry)cnt++;
            }
            if(cnt==k){
              ll area = (rx - lx) * (ry - ly);
              chmin(res, area);
            }
          }
        }
      }
    }
    cout << res << ln;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

vector<bool> sieveFlags(int n) {
    vector<bool> f(n + 1);
    for (int i = 3; i <= n; i += 2) f[i] = 1;
    for (int i = 3; i <= sqrt(n); i += 2) if (f[i]) for (int j = i * 3; j <= n; j += i) f[j] = 0;
    if (n >= 2) f[2] = 1;
    return f;
}

const int N = 100005;
int A[N];

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

    auto F = sieveFlags(N);

    int Q;
    cin >> Q;

    FOR(i, 1, N - 1) {
        if (F[i] && F[(i + 1) / 2] && i%2)A[i] = 1;
        A[i] += A[i - 1];
    }

    while (Q--) {
        int l, r;
        cin >> l >> r;
        cout << A[r] - A[l - 1] << endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int t, n;
  int sales;
  int price[] = { 6000, 4000, 3000, 2000 };
  
  for (int i = 0; i < 4; i++) {
    cin >> t >> n;
    sales = price[t - 1] * n;
    cout << sales << endl;
  }
}



Measured memory_bytes: 3116
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u32,
        a: [u32; n]
    }

    println!("{}", a.iter().sum::<u32>() - n);
}


Measured memory_bytes: 4352
#include<stdio.h>

 int n;
 int A[21];

 int solve(int i,int m){
       int res;
       if(m==0)return 1;
       if(i>=n)return 0;

       res=solve(i+1,m)||solve(i+1,m-A[i]);
       return res;
       }


 int main(){
       int i,q,m;
       scanf("%d",&n);
       for(i=0;i<n;i++){
                scanf("%d",&A[i]);
                }
       scanf("%d",&q);
       for(i=0;i<q;i++){
                scanf("%d",&m);
                if(solve(0,m))printf("yes\n");
                else printf("no\n");
                }
       return 0;
       }

                


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string s;
    cin >> N >> s;
    int nr = 0, nb = 0;
    FORO(i, N) {
        if(s[i] == 'R') nr++;
        else nb++;
    }  
    cout << (nr > nb ? "Yes" : "No") << endl;
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;

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

	unsigned short n;
	cin >> n;

	unsigned short i;
	unsigned int b[n - 1];
	for (i = 0; i < n - 1; ++i) {
		cin >> b[i];
	}

	// max(a[0], a[1]) <= b[0]
	// max(a[1], a[2]) <= b[1]
	// max(a[0], a[1]) <= 2 : a[1] は2以下かつ5以下
	// max(a[1], a[2]) <= 5
	unsigned int as = 0;
	as += b[0]; // a[0]
	for (i = 1; i <= n - 2; ++i) {
		// max(a[i], a[i+1]) <= b[i]
		as += min(b[i - 1], b[i]); // a[i]
	}
	as += b[n - 2]; // a[n - 1]

	cout << as << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
using namespace std;

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

	if (a + b + c >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(){
  int a,b,n;
  cin >> a >> b >> n;
  if(b<=n){
    cout << ((int)a*(b-1)/b) << endl;
  }else{
    cout << ((int)a*n/b) << endl;
  }
}


Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		int a;
		scanf("%d", &a);
		n -= a;
	}
	if (n >= 0)
	{
		printf("%d\n", n);
	}
	else
	{
		puts("-1");
	}
	return 0;
}


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

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

    int n = s.size()-2;

    while(n >= 2) {
        if(s.substr(0, n/2) == s.substr(n/2, n/2)) {
            cout << n << endl;
            break;
        }
        else n -= 2;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        long K = in.nextLong();
        long A[] = new long[N];
        for (int i = 0; i <= N - 1; i++) {
            A[i] = in.nextLong();
        }

        int[][] bA = new int[40][2];
        for (int i = 0; i <= N - 1; i++) {
            long ac = A[i];
            for (int j = 0; ac > 0; j++) {
                bA[j][0] += ac % 2;
                ac /= 2;
            }
        }

        long kc = K;
        int keta = 0;
        for (int j = 0; kc > 0; j++) {
            bA[j][1] += kc % 2;
            kc /= 2;
            keta++;
        }


        long dp[][] = new long[2][keta+1];
        Arrays.fill(dp[0], -1);
        Arrays.fill(dp[1], -1);
        dp[0][0] = 0; 

        for (int d = 0; d <= keta-1; d++) {

            long c0 = bA[keta-1-d][0] * pow(2, keta-1-d);
            long c1 = (N-bA[keta-1-d][0]) * pow(2, keta-1-d);

            if (dp[1][d] != -1) {
                dp[1][d+1] = Math.max(dp[1][d+1], dp[1][d] + Math.max(c0, c1)); 
            }

            if (dp[0][d] != -1) {
                if (bA[keta-1-d][1] == 1) { 
                    dp[1][d+1] = Math.max(dp[1][d+1], dp[0][d] + c0);
                }
            }

            if (dp[0][d] != -1) {
                if (bA[keta-1-d][1] == 1) { 
                    dp[0][d+1] = Math.max(dp[0][d+1], dp[0][d] + c1);
                } else { 
                    dp[0][d+1] = Math.max(dp[0][d+1], dp[0][d] + c0);
                }
            }

        }

        long ans = Math.max(dp[0][keta], dp[1][keta]);
        for (int d = keta; d <= 39; d++) {
            ans += bA[d][0] * pow(2, d);
        }

        out.println(ans);
    }

public   static long pow(long x, long n) {
        long sum = 1;
        while (n > 0) {
            if ((n & 1) == 1) {  
                sum *= x;        
            }
            x *= x;              
            n >>= 1;
        }
        return sum;
    }

}
}



Measured memory_bytes: 51232
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    public static void Main()
    {
        var str = Console.ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
        var a = str[0];
        var b = str[1];
        if (a + b >= 8)
        {
            var dif = Math.Abs(a - b);
            if (dif > 1)
                Console.WriteLine(":(");
            else
                Console.WriteLine("Yay!");
        }
        else
            Console.WriteLine("Yay!");
        Console.ReadLine();
    }
}


Measured memory_bytes: 13396
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	ans := 0
	for i := 1; i <= n; i++ {
		x := n / i
		add := i * x * (x + 1) / 2
		ans += add
	}

	puts(ans)
}


Measured memory_bytes: 1796
# author:  Taichicchi
# created: 17.09.2020 23:46:19


N = int(input())

S = input()

cnt = 0

for i in map(lambda x: str(x).zfill(3), range(1000)):
    f = 0
    for s in S:
        if s == i[f]:
            f += 1
        if f == 3:
            break
    if f == 3:
        cnt += 1

print(cnt)


Measured memory_bytes: 83404
#include<stdio.h>

int main() {
	int a, b, c;

	scanf("%d %d", &a, &b);

	if ((a + b) % 2 == 1) {
		c = (a + b) / 2 + 1;
	}
	else {
		c = (a + b) / 2;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
while line = gets do
  number = line.chomp.to_i
  if number > 36
    puts 0
  else
    counter = 0
    (0..9).each do |a|
      (0..9).each do |b|
        (0..9).each do |c|
          (0..9).each do |d|
            counter += 1 if (a + b + c + d) == number
          end
        end
      end
    end
    puts counter
  end
end

Measured memory_bytes: 6096
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#define SIZE 405

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char mp[SIZE][SIZE];
bool use[SIZE][SIZE];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%s",&mp[i]);
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(use[i][j]) continue;
			queue <P> que;
			que.push(P(i,j));
			use[i][j]=true;
			int w=0,b=0;
			while(!que.empty())
			{
				P p=que.front();que.pop();
				if(mp[p.first][p.second]=='.') w++;
				else b++;
				for(int t=0;t<4;t++)
				{
					int x=p.first+dx[t],y=p.second+dy[t];
					if(0<=x&&x<n&&0<=y&&y<m)
					{
						if(mp[p.first][p.second]!=mp[x][y]&&!use[x][y])
						{
							use[x][y]=true;
							que.push(P(x,y));
						}
					}
				}
			}
			ret+=(ll) w*(ll) b;
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<int>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };
 
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << c <<' '<< a <<' '<< b << endl;
}

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

int main() {
	char s[100] = {};
	char p[100] = {};
	cin >> s >> p;

	char s2[200];
	strcpy(s2, s);
	strcat(s2, s);

	if (strstr(s2, p) == NULL) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3116
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 27 21:03:22 2019

@author: doppe
"""

A, B = (int(x) for x in input().split())

if (A > 0 and A <= 9 and B > 0 and B <= 9 ):
    print(A * B)
else:
    print(-1)


Measured memory_bytes: 2940
results = []

loop do
  m, f, r = gets.split.map(&:to_i)
  break if [m, f, r].all?(&:negative?)

  result = ''
  mf = m + f

  if [m, f].any?(&:negative?)
    result = 'F'
  elsif mf >= 80
    result = 'A'
  elsif mf >= 65
    result = 'B'
  elsif mf >= 50
    result = 'C'
  elsif mf >= 30
    result = 'D'
    result = 'C' if r >= 50
  else
    result = 'F'
  end

  results << result
end

results.each do |result|
  puts result
end



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// 素因数分解
map<ll, ll> factorize(ll n){
    map<ll, ll> mp;
    ll sq = sqrt(n);
    FOR(i, 2, sq+1){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    // 残り
    if(n!=1){
        mp[n]++;
    }
    return mp;
}

// 約数リスト (1, nも含む)
set<ll> divisor_list(ll n){
    auto mp = factorize(n);
    vector<ll> P;
    for(auto p : mp){
        ll v = p.first;
        ll count = p.second;
        FOR(i, 0, count){
            P.push_back(v);
        }
    }
    ll L = P.size();
    set<ll> se;
    FOR(i, 0, 1<<L){
        ll p = 1;
        FOR(j, 0, L){
            if(i>>j&1){
                p *= P[j];
            }
        }
        se.insert(p);
    }
    return se;
}

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

    // input
    ll N;
    cin >> N;

    ll sum = 0;
    auto se = divisor_list(N);
    for(ll v : se){
        ll m = v-1;
        if(m==0) continue;
        if(N/m == N%m){
            sum += m;
        }
    }

    p(sum);

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int dp[50];

int fib(int n)
{
  if( n == 0 || n == 1 ) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main()
{
  int n,i;
  for(i=0 ; i<50 ; i++) dp[i] = -1;
  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
  
}



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

int main()
{
	int n;
	cin >> n;
	for (int i = 3; i <= n; i++)
	{
		string a = to_string(i);
		for (int j = 0; j <= a.length() - 1; j++)
		{
			if (a[j] == '3')
			{
				while (a[j] == '3')
				{
					cout << " " << i;
					i++;
					if (i > n)
					{   
						cout << endl;
						return 0;
					}
					a = to_string(i);
				}
				break;
			}
		}
		if (i % 3 == 0) cout << " " << i;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M_PI 3.14159265358979323846

int main()
{
// clock_t begin = clock();
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
tani_nachi_ke  

int n;
cin>>n;
double p[n+1];
for(int i=1; i<=n; i++)cin>>p[i];

double dp[n+1][n+1];
for(int i=1; i<=n ;i++)dp[0][i]=0;
dp[0][0]=1;
dp[1][0]=(1.0-p[1]);
for(int i=2; i<=n ;i++)
{
  dp[i][0]=dp[i-1][0]*(1.0-p[i]);
}

for(int i=1; i<=n; i++)
{
  for(int j=1; j<=n ;j++)
  {
    if(i>=j)
    {
      dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
    }
    else dp[i][j]=0;
  }
}
double ans=0.0;
for(int i=(n+1)/2 ;i<=n ;i++)ans+=dp[n][i];
cout<<setprecision(10);
cout<<fixed;
// for(int i=1; i<=n; i++)
// {
//   for(int j=1; j<=n ;j++)cout<<dp[i][j]<<" ";
//   cout<<endl;
// }
cout<<ans<<endl;
// #ifndef ONLINE_JUDGE 
// clock_t end = clock();
// cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
// #endif 
// return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll x, n;
    cin >> x >> n;
    set<ll> p;
    REP(i, n){
        ll pi;
        cin >> pi;
        p.insert(pi);
    }

    REP(d, 110){
        if(p.count(x - d) == 0){
            cout << x - d << endl;
            return 0;
        }else if(p.count(x + d) == 0){
            cout << x + d << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; ll w; cin >> n >> w;
    VL wei(n); VI val(n);
    int Max = 0;
    FOR(i, 0, n) {
        cin >> wei[i] >> val[i];
        Max += val[i];
    }

    auto dp = defvec<ll>(LLINF, n + 1, Max + 1);
    dp[0][0] = 0;
    FOR(i, 0, n)eFOR(j, 0, Max) {
        chmin(dp[i + 1][j], dp[i][j]);
        if (Max < j + val[i])continue;
        chmin(dp[i + 1][j + val[i]], dp[i][j] + wei[i]);
    }

    erFOR(i, 0, Max)if (dp[n][i] <= w) {
        cout << i << "\n";
        return 0;
    }
}


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin >> a >> b;
    string s,t;
    rep(i,b){
        s += to_string(a);
    }
    rep(i,a){
        t += to_string(b);
    }

    cout << min(s,t) << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s, t;
	while (cin >> s && s != ".") {
		cin >> t;
		string s_a[234], t_a[234];
		int i = 0, s_l = 0, t_l = 0;
		for (i = 0; i < s.size(); i++) {
			while (i < s.size() && s[i] != '"') {
				s_a[s_l] += s[i];
				i++;
			}
			s_l++;
		}
		for (i = 0; i < t.size(); i++) {
			while (i < t.size() && t[i] != '"') {
				t_a[t_l] += t[i];
				i++;
			}
			t_l++;
		}
		if (s_l != t_l) {
			cout << "DIFFERENT\n";
			goto heaven;
		}
		else {
			int cnt = 0;
			for (int i = 0; i < s_l; i++) {
				if (s_a[i] != t_a[i]) {
					if (i % 2 == 0) {
						cout << "DIFFERENT\n";
						goto heaven;
					}
					else cnt++;
				}
			}
			if (!cnt)cout << "IDENTICAL\n";
			else cout << (cnt == 1 ? "CLOSE\n" : "DIFFERENT\n");
		}heaven:;
	}
}


Measured memory_bytes: 3196
"""
Writer: SPD_9X2
https://atcoder.jp/contests/arc065/tasks/arc065_d

圧倒的dp感

lは非減少なので、 l[i-1] ～l[i] の間が確定する範囲

dp[i][今の区間に残っている1の数] = 並び替えの通り数　でやると
dp推移がO(N^2)になってしまう…

1の位置さえ決まればよい。
あらかじめ、それぞれの1に関して、移動しうる最小のindexと最大のindexを前計算
→どうやって？
→heapといもす法で、最小・最大値管理しつつ

あとはdp中に一点取得、区間加算がO(N)で出来れば、O(N**2)で解ける
→dp[i個目までの1を処理][右端にある1のindex]
とし、最後に累積和で区間加算する→DP推移はO(N)なのでおｋ

→なんか違う？
→1をもってける範囲の右端が実際より短くなっているのが原因


"""
from collections import deque
import heapq
N,M = map(int,input().split())
S = input()
"""
lri = deque([])
rpick = [ [] for i in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    lri.append([l-1,r-1,i])
    rpick[r].append(i)

lheap = []
rheap = []
state = [False] * M

LRlis = []

for i in range(N):

    while len(lri) > 0 and lri[0][0] == i: #新たに区間を入れる
        l,r,ind = lri.popleft()
        heapq.heappush(lheap,[l,ind])
        heapq.heappush(rheap,[-1*r,ind])

    for pickind in rpick[i]:

        state[pickind] = True

    while len(lheap) > 0 and state[ lheap[0][1] ]:
        heapq.heappop(lheap)
    while len(rheap) > 0 and state[ rheap[0][1] ]:
        heapq.heappop(rheap)

    if S[i] == "1":

        if len(lheap) == 0 or len(rheap) == 0:
            LRlis.append([i,i])
        else:
            LRlis.append([lheap[0][0] , -1 * rheap[0][0] ])

"""
lri = []
for i in range(M):
    l,r = map(int,input().split())
    lri.append([l-1,r-1,i])
lri.append([N,float("inf"),float("inf")])

nexvisit = 0
onenum = 0
LRlis = []
LRlisind = 0
r = 0
for loop in range(M):
    
    l,nr,tempi = lri[loop]
    r = max(nr,r)
    nexl = lri[loop+1][0]
    #print (l,r,nexl)

    for i in range( max(l,nexvisit) , r+1 ):
        if S[i] == "1":
            LRlis.append([l,None])
            onenum += 1
            nexvisit = max(nexvisit,i+1)
    if r-nexl+1 < onenum:

        for i in range(min(onenum , onenum - (r-nexl+1))):
            LRlis[LRlisind][1] = r-onenum+1
            onenum -= 1
            LRlisind += 1
            
mod = 10**9+7
dp = [0] * (N+1)
#print (LRlis)

for i in range(len(LRlis)):

    #print (dp)

    l,r = LRlis[i]

    ndp = [0] * (N+1)

    if i == 0:
        ndp[l] += 1
        ndp[r+1] -= 1
    else:

        for v in range(r):

            ndp[max(l,v+1)] += dp[v]
            ndp[r+1] -= dp[v]

    for j in range(N):
        ndp[j+1] += ndp[j]
        ndp[j] %= mod
        ndp[j+1] % mod

    dp = ndp

#print (dp)
print (sum(dp[0:N]) % mod)


    

    


Measured memory_bytes: 50648
#include <iostream>

using namespace std;

int main() {
    int r, c;
    int a[101][101];

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

    for (int i = 0; i <= c; i++) {
        int colSum = 0;
        for (int j = 0; j < r; j++)
            colSum += a[j][i];
        a[r][i] = colSum;
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            cout << a[i][j];
            if (j < c)
                cout << " ";
            else
                cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X, t;
  cin >> X >> t;
  cout << max(X-t, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,q; cin >> n >> q;
    string s; cin >> s;
    VI ac;
    rep(i,n-1) if(s[i] == 'A' && s[i+1] == 'C') ac.push_back(i);
    rep(i,q){
        int l,r; cin >> l >> r;
        l--; r--;
        auto ll = lower_bound(all(ac),l);
        auto rr = lower_bound(all(ac),r);
        int ans = rr - ll;
        ANS;
    }

    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> k;
	if (k<1e15) {
		if (k%2==0) {
			cout << 2 << endl;
			cout << (k+2)/2 << " " << k/2 << endl;
		} else {
			cout << 2 << endl;
			cout << k/2 << " "<<k+1-k/2 << endl;
		}
		return 0;
	} else {
		cout << 50 << endl;
		LL low=k/50;
		for (int i=0;i<50-(k%50);++i) cout << low+i << " ";
		for (int i=50-(k%50);i<50;++i) cout << low+i+1 << " ";
	}
}

Measured memory_bytes: 256
n = int(input())
nums = []
for i in range(n):
    num = list(map(int, input().split()))
    nums.append(num)

count = 0
for i in range(len(nums)-2):
    if nums[i][1] == nums[i][0] and nums[i+1][1] == nums[i+1][0] and nums[i+2][1] == nums[i+2][0]:
        count += 1

if count >= 1:
    print('Yes')
else:
    print('No')

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

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

    if (k <= a) {
        cout << a - k << " " << b << endl; 
        return 0;
    }
    else if (k <= a + b) {
        cout << 0 << " " << b - (k - a) << endl;
        return 0;
    }
    else if (k > a + b){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
def FizzBuzz_sum():
    # 入力
    N = int(input())
    # 初期処理
    N = [i for i in range(1,N+1)]
    sum = 0
    # 比較処理
    for i in N:
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            sum += i
    return sum

result = FizzBuzz_sum()
print(result)

Measured memory_bytes: 48504
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine

getString = readString <$> BS.getLine

productP :: [Int] -> Int -> Int
productP [] p = p
productP (x : xs) p = productP xs ((x + 1) * p `mod` (10 ^ 9 + 7))

sum' :: [Int] -> Int -> Int
sum' [] s = s
sum' (x : xs) s = sum' xs ((x + s) `mod` (10 ^ 9 + 7))

main = do
  n <- getInt
  [s] <- getString
  let s' = map length (group (sort s))
  print $ sum' [(productP s' 1), (-1)] 0


Measured memory_bytes: 15840
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	int n, k;
	cin >> n >> k;
	unordered_map<int, int> mp;
	for(int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for(int i = 0; i < d; i++) {
			int inp;
			cin >> inp;
			mp[inp]++;
		}
	}
	cout << n - mp.size() << endl;

}

Measured memory_bytes: 3632
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld a,lld b){//return (x%mod+mod)%mod; //long long int r = a % b;return r < 0 ? r + b : r;
}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<lld> v[maxi];
// vector<lld> h(maxi);
// vector<long long> a(maxi,0);
// lld res=0;
// void dfs(int x){
//     if(a[x]){
//         return;
//     }
//     a[x]=1;
//     int flag=1;
//     for(int i:v[x]){
//         if(h[x]<=h[i]){
//             flag=0;
//             break;
//         }
//     }
//     if(flag){
//         ++res;
//     }
// }

void test_case(){
    int l,d,r;
    cin>>l>>d>>r;
    int cnt=0;
    for(int i=l;i<=d;++i){
        if(i%r==0){
            ++cnt;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}
// PD?D??P

Measured memory_bytes: 3636
// O(qlogn)
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;

const int N=2e6+9;

void slv()
{
    string s;
    cin >> s;
    int n=s.size();
    int sum=0;
    for(int i=0;i<n;i++) sum += (s[i]-'0');
    if(sum%9) puts("No");
    else
    {
        puts("Yes");
    }
    
}
int main()
{
    int t;
    t=1;
    for(int cs=1;cs<=t;cs++) {
        //printf("Case %d:\n",cs);
        slv();
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll a = 0, b = 0;
    vector<ll> A;
    cin >> N;
    A.resize(N);
    for(ll i = 0;i < N;i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<>());
    for(ll i = 0;i < A.size();i++) {
        if(i % 2) {
            b += A[i];
        } else {
            a += A[i];
        }
    }
    cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)
if n == 0
  puts x
  exit
end
p = gets.split.map(&:to_i)

list = (0..101).to_a - p # 候補のリスト
if list == []
  if x <= 50
    puts 0
  else
    puts 101
  end
  exit
end
diff_list = list.map { |a| (a - x).abs } # 差分のリスト
index = diff_list.find_index(diff_list.min)
puts list[index]


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

void solve() {
    int N, Q;
    cin >> N >> Q;
    dsu uf(N);
    while(Q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if(!t) uf.merge(u, v);
        else cout << uf.same(u, v) << '\n';
    }
}

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


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1LL << 30;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    // vector<vector<int>> A(n,vector<int>(m,0));
    int flag= 0;
    REP(i,n+1){
        REP(j,m+1){
            if(k==i*m+j*n-2*i*j) flag= 1;
        }
    }
    cout << ((flag)?"Yes":"No") << endl;
}

Measured memory_bytes: 256
import math

ONE_BIGGER_TWO = 1
TWO_BIGGER_ONE = 2
SAME = 0


def calculate_area(input_list):
    last = 360 - sum(input_list)
    input_list.append(last)

    radian_list = [math.radians(item) for item in input_list]
    sin_list = [math.sin(item) for item in radian_list]

    area = math.fsum(sin_list)

    return area


while True:
    input_count = int(input())

    if input_count == 0:
        break

    input_list1 = [int(input()) for _ in range(input_count - 1)]
    area1 = calculate_area(input_list1)

    input_count = int(input())
    input_list2 = [int(input()) for _ in range(input_count - 1)]
    area2 = calculate_area(input_list2)

    if math.isclose(area1, area2):
        print(SAME)
    elif area1 > area2:
        print(ONE_BIGGER_TWO)
    else:
        print(TWO_BIGGER_ONE)



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

int main(){
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=n-1;i>=0;i--) {
        if(i > 0 && arr[i] > arr[i-1]){
            arr[i] -= 1;
            continue;
        }
        if(i<=(n-2) && arr[i] > arr[i+1]) {
            arr[i] -= 1;
            continue;
        }
    }
    int flag = 0;
    for(int i=1;i<n ;i++){
        if(arr[i] < arr[i-1]) {
            flag = 1;
            break;
        }
    }
    if(flag)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vc vector<char>
#define vs vector<string>
#define vpi vector<pii>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vvd vector<vector<double>>
#define vvc vector<vector<char>>
#define vvs vector<vector<string>>
#define vvpi vector<vector<pii>>
#define vvpl vector<vector<pll>>

const int INF = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int N, M, K;
	cin >> N >> M >> K;

	vl A(N), B(M), canMake, cnt;

	for (auto& i : A) cin >> i;
	for (auto& i : B) cin >> i;
	
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
		if (sum > K) break;
		canMake.push_back(sum);
		cnt.push_back(i + 1);
	}
	
	ll ans = 0;
	
	int loc = lower_bound(canMake.begin(), canMake.end(), K) - canMake.begin();
	
	if (loc == cnt.size() || canMake[loc] > K) {
		if (loc - 1 >= 0) ans = max(ans, cnt[loc - 1]);
	}
	else ans = max(ans, cnt[loc]);
	
	sum = 0;
	for (int i = 0; i < M; i++) {
		sum += B[i];
		if (sum > K) break;
		int loc = lower_bound(canMake.begin(), canMake.end(), K - sum) - canMake.begin();
		
		if (loc == cnt.size() || canMake[loc] > K - sum) {
			if (loc - 1 >= 0) ans = max(ans, i + 1 + cnt[loc - 1]);
			else ans = max<ll>(ans, i + 1);
		}
		else {
			ans = max(ans, i + 1 + cnt[loc]);
		}
	}
	
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 9656
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int n,k;
vector<ll> v(5555);
vector<vector<bool>> dp(5010,vector<bool>(5010));

bool check(int p){
    if(v[p]>=k) return true;
    // without v[p], make x s.t. k-v[p]<=x<k
    // dp[i][j] := v[i]迄でjを作る
    for(int i=0;i<=n;i++) dp[0][i]=false;
    for(int i=0;i<=n;i++) dp[i][0]=true;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            dp[i][j]=dp[i-1][j];
            if(i!=p && j-v[i]>=0){
                dp[i][j] =  dp[i][j] | dp[i-1][j-v[i]];
            }
        }
    }
    bool f=false;
    for(int i=max(0LL,k-v[p]);i<k;i++) f |= dp[n][i];
    return f;
}

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

    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.rbegin(),a.rend());
    for(int i=1;i<=n;i++) v[i]=a[i-1];
    int low=1,high=n;
    for(int i=0;i<14;i++){
        int mid=(low+high)/2;
        if(check(mid)) low=mid;
        else high=mid;
    }
    if(!check(low)) cout<<n-low+1<<endl;
    else if(!check(high)) cout<<n-low<<endl;
    else cout<<n-high<<endl;
}


Measured memory_bytes: 3712
/*
题意：就是DFS找划分区域
*/
#include <bits/stdc++.h>
using namespace std;
char g[200][200];
// row,col =y,x  
int X,Y,res;
int dx[4] = {1,-1,0,0}, dy[4] ={0,0,1,-1};

void dfs(int row,int col){
	char t = g[row][col] ; 
	g[row][col] = 'x';
	int x,y;
	for(int k=0;k<4;k++){
		x = col + dx[k];
		y = row + dy[k];
		if(x>=0&&y>=0&&x<X&&y<Y&&g[y][x]==t)
			dfs(y,x);
	}


}


int main(int argc, char const *argv[])
{	int row,col;
	while(cin >> row >>col){
		if(row==0&&col==0)break;
		X= col ,Y=row;
		memset(g,0,sizeof(g));
		res=0;
		for(int r=0;r<row;++r){
				cin >> g[r];
		}
		for(int r=0;r<row;++r){
			for(int c=0;c<col;++c){
				if(g[r][c] != 'x'){
					++res;
					dfs(r,c);
				}
			}
		}
		
		cout << res <<endl;

	}
	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

vi T;

// MODULAR INVERSE
ll modInverse(ll a, ll m){
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1) return 0;
    while (a > 1){
        ll q = a / m; ll t = m;
        m = a % m, a = t;
        t = y; y = x - q * y; x = t;
    }
    if (x < 0) x += m0;
    return x;
}


// SIEVE + prime factor decomposition
bool prime[1000005];
int spf[1000005];
vector<int> sieve(int n){
	vector<int> v;
    memset(prime, true, sizeof(prime));
    spf[0] = 1;
    spf[1] = 1;
    for (int p=2; p*p<=n; p++){
        if (prime[p] == true){
            for (int i=p*p; i<=n; i += p){
                if(prime[i]) spf[i] = p;
                prime[i] = false;
            }
        }
    }

    for (int p=2; p<=n; p++) if (prime[p]){
      v.push_back(p);
      spf[p] = p;
    }
	return v;
}


map<ll, ll> get_prime_factors(ll x){
  map<ll, ll> res;
  while(x > 1){
    res[spf[x]]++;
    x/=spf[x];
  }
  return res;
}


ll xp(ll x, ll b){
  if(x == 0) return 1;
  else if(x % 2) return (b * xp(x-1, b)) % mod;
  ll a = xp(x/2, b);
  return (a * a) % mod;
}

map<ll, ll> find_lcm_h(vi& a, int k) {
  if(k == sz(a)) return map<ll, ll>();
  map<ll, ll> aa = get_prime_factors(a[k]);
  map<ll, ll> bb = find_lcm_h(a, k+1);
  // DBG(a[k])
  for(auto k : aa){
    // DBG(k.first)
    // DBG(k.second)
    bb[k.first] = bb[k.first] + k.second - min(bb[k.first], k.second);
  }
  return bb;
}

ll find_lcm(vi &a){
  map<ll, ll> x = find_lcm_h(a, 0);
  ll ans = 1;
  for(auto k : x){
    ll u = xp(k.second, k.first);
    ans = (ans * u) % mod;
  }
  return ans;
}

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    sieve(1e6+ 5);
    int n;
    cin >>  n;
    vi a(n); f(i, n) cin >> a[i];
    ll lcm = find_lcm(a);
    // DBG(lcm)
    ll ans = 0;
    f(i, n){
      ans = (ans + ( (lcm * modInverse(a[i], mod))%mod) ) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10564