akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int ssum(int x){
  int a = 0;
  while(x>0){
    a += x%10;
    x /= 10;
  }
  return a;
}

int main(){
  int N, A, B; cin >> N >> A >> B;
  int ans = 0;
  rep(i,N+1){
    int b =ssum(i);
    if( b >= A && b <= B) ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
   ll n,k;cin >>n>>k;
   vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    vector<ll>cnt(50,0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 50; ++j) {
            if((a[i]>>j)&1LL)cnt[j]++;
        }
    }
    ll now=0;
    ll ans=0;
    for (int i = 49; i>=0;--i) {
        if(now+((1LL)<<i)<=k) {
            if (cnt[i] < n - cnt[i]) {
                now += ((1LL) << i);
                ans += ((1LL) << i) * (n - cnt[i]);
            } else {
                ans += ((1LL) << i) * cnt[i];
            }
        }
        else {
            ans += ((1LL) << i) * cnt[i];
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>


using namespace std;

int n, m;
pair<int, int> a[100][100];
int b[100][100];

vector<int> bg[200];
int used[200];
int pairing[200];

bool kuhn(int v)
{
    if (used[v]) return 0;
    used[v] = 1;
    for (int i = 0; i < bg[v].size(); i++)
    {
        int u = bg[v][i];
        if (pairing[u] == -1 || kuhn(pairing[u]))
        {
            pairing[u] = v;
            return 1;
        }
    }
    return 0;
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j].first;
            a[i][j].second = (a[i][j].first - 1) / m;
        }
    }

    for (int j = 0; j < m; j++)
    {
        for (int i = 0; i < 200; i++) bg[i].resize(0);

        for (int num = 0; num < n; num++)
        {
            for (int row = 0; row < n; row++)
            {
                int t = 0;
                for (int j2 = j; j2 < m; j2++)
                {
                    if (a[row][j2].second == num)
                    {
                        t = 1;
                    }
                }
                if (t)
                {
                    bg[num].push_back(100 + row);
                    bg[100 + row].push_back(num);
                }
            }
        }

        for (int i = 100; i < 200; i++) pairing[i] = -1;

        for (int num = 0; num < n; num++)
        {
            fill(used, used + n, 0);
            kuhn(num);
        }

        for (int row = 0; row < n; row++)
        {
            //cout << "number " << pairing[row + 100] << " from row " << row << endl;
            int x = pairing[row + 100];
            for (int j2 = j; j2 < m; j2++)
            {
                if (a[row][j2].second == x)
                {
                    swap(a[row][j2], a[row][j]);
                    break;
                }
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cout << a[i][j].first << " ";
            b[j][i] = a[i][j].first;
        }
        cout << "\n";
    }

    for (int i = 0; i < m; i++)
        sort(b[i], b[i] + n);

    for (int j = 0; j < n; j++)
    {
        for (int i = 0; i < m; i++)
        {
            cout << b[i][j] << " ";
        }
        cout << "\n";
    }
}


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

using namespace std;

#define int long long
#define nl '\n'

#define st first
#define nd second
#define ins insert

#define pb push_back
#define mp make_pair

#define hashmap unordered_map
#define hashset unordered_set

signed main(){
	vector<int> v(5); int ans;
	for (int i = 0; i < 5; i++){
		cin >> v[i];
		if (v[i] == 0){
			ans = i + 1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3496
N = int(input())
A = list(map(int, input().split()))

cand = [0] * 10**5

for i in range(len(A)):
    cand[A[i]] += 1
    if A[i] < len(A)-1:
        cand[A[i]+1] += 1
    if A[i] > 0:
        cand[A[i]-1] += 1

print(max(cand))


Measured memory_bytes: 14004
<?php
$goals;
while($line = trim(fgets(STDIN))){
    $goals[] = $line;
}
foreach($goals as $val){
    $cnt = 0;
    $fetch_tmp = array();
    for($a = 0;$a < 10 && $a <= $val;$a++){
        for($b = 0;$b < 10 && $a+$b <= $val;$b++){
            for($c = 0;$c < 10 && $a+$b+$c <= $val;$c++){
                for($d = 0;$d < 10;$d++){
                    $fetch = $a.$b.$c.$d;
                    $flg = check($fetch_tmp,$fetch);
                    if($val == $a+$b+$c+$d && (empty($fetch_tmp) || $flg)){
                        $fetch_tmp[] = $fetch;
                        $cnt++;
                        break 1;
                    }
                }
            }
        }
    }
    echo $cnt."\n";
}
function check($fet_ary,$fetch){
    foreach($fet_ary as $val){
        if($val == $fetch){
            return false;
        }
    }
    return true;
}


Measured memory_bytes: 9404
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int n,m,x,y,count=0;
  scanf("%d%d",&n,&m);
  int obs[n+1];
  int c[n+1];
  bool d[n+1];
  for (int i=0;i<=n;i++)
    c[i]=0;
  memset(d,1,sizeof(d));
  obs[0]=d[0]=0;
  for (int i=1;i<=n;i++)
    scanf("%d",&obs[i]);
  for (int i=1;i<=m;i++)
  {
    scanf("%d%d",&x,&y);
    if (obs[x]>obs[y])
      d[y]=0;
    else if (obs[x]<obs[y])
      d[x]=0;
    else
    {
      d[x]=0;
      d[y]=0;
    }
    c[x]++;
    c[y]++;
  }
  for (int i=1;i<=n;i++)
  {
    if (d[i]==1)
      count++;
    //if (c[i]==0)
      //count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 4684
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int X,Y,Z;
	cin>>X>>Y>>Z;
	int ans = (X-Z)/(Y+Z);
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <set>
#include <unordered_set>

using namespace std;

int main() {
    string s;
    cin>>s;
    string t,u;
    int k=0;
    for (int i=0;i<s.size();++i){
        t+=s[i];
        if(t!=u){
            u=t;
            t="";
            ++k;
        }
    }
    cout<<k;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 5100000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  ll X;
  cin>>X;
  ll ans=0;
  ans+=(X/500)*1000;
  X%=500;
  ans+=(X/5)*5;
  cout<<ans<<endl;
}


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

int main(){
    ll A, B, C;
    ll K;
    cin >> A >> B >> C >>K;

    if(K%2==1){
        cout << (B-A) << endl;
    }else{
        cout << (A-B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
# # n = int(input())
# a, b = map(int, input().split())
# # c = list(map(int, input().split()))
# # d = [list(map(int, input().split())) for _ in range(n)]
# # s = input()
#
# ans = "Yey!"
#
# if a <= 8 and b <= 8:
#     ans ="Yey!"
# else:
#     ans = ":("
#
# print(ans)




# D, N = map(int, input().split())
#
# ans = pow(100,D)*N
#
# if D == 0:
#     print(N)
# else:
#     print(ans)


# n = int(input())
# a = list(map(int, input().split()))
#
# sum_count = 0
#
# for a_i in a:
#     while 1:
#         a_i = a_i / 2
#         if a_i.is_integer():
#             sum_count += 1
#             continue
#         else:
#             break
#
# print(sum_count)


N, M = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]

x_value = []
for x_i in x:
    x_value.append(x_i[0]+ x_i[1] +x_i[2])
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = sum_value

x_value = []
for x_i in x:
    x_value.append(0 - x_i[0] + x_i[1] + x_i[2])
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

x_value = []
for x_i in x:
    x_value.append(0 + x_i[0] - x_i[1] + x_i[2])
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

x_value = []
for x_i in x:
    x_value.append(0 - x_i[0] - x_i[1] + x_i[2] )
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

x_value = []
for x_i in x:
    x_value.append(0 + x_i[0] + x_i[1] - x_i[2] )
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

x_value = []
for x_i in x:
    x_value.append(0 - x_i[0] + x_i[1] - x_i[2])
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

x_value = []
for x_i in x:
    x_value.append(0 + x_i[0] - x_i[1] - x_i[2])
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

x_value = []
for x_i in x:
    x_value.append(0 - x_i[0] - x_i[1] - x_i[2])
x_value.sort()
x_value.reverse()
sum_value = sum(x_value[:M])
ans = max(ans, sum_value)

print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    char c[3][3];

    for(int i = 0; i < 3; ++i){
        scanf("%s", c[i]);
    }

    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            if(i == j){
                printf("%c", c[i][j]);
            }
        }
    }
    puts("");

    return 0;
}


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

int main()
{
  long a, b;
  cin >> a >> b;
  long tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  long r;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  //printf("b%d\n", b);
  long rem = 2;
  long prev = 0;
  long c = 1;
    while (b >= rem * rem) {
      if (b % rem == 0) {
        b /= rem;
        if(prev != rem) c++;
        //printf("b %d rem %d\n", b , rem);
        prev = rem;
      } else {
        rem++;
      }
    }
    if(b > 1 && b != rem) c++;
  cout << c << endl;
}

Measured memory_bytes: 256
#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(){

int n;
cin >> n;
ll ans=1;
vector<ll> a(100010);
rep(i,n){
    cin >> a[i];
    if(a[i]==0){
        cout << 0 << endl;
        return 0;
    }
}
rep(i,n){
    ans *= a[i];
    if(a[i+1] > 1000000000000000000/a[i] || ans > 1000000000000000000){
        cout << -1 << endl;
        return 0;
    }
}
cout << ans << endl;

}

Measured memory_bytes: 4048
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,k;
	string s;
	cin>>n;
	cin>>s;
	cin>>k;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[k-1])
			s[i]='*';
	}
	cout<<s<<endl;
	return 0;
}

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
#define QUO(x,y) (x-x%y)/y	//x÷yの商
 
int main(){

	char a[10]={NULL},b[10]={NULL},c[10]={NULL};
	cin>>a>>b>>c;

	

	if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])PRINT("YES");
	else PRINT("NO");
	
	
	

	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S,T = read().decode('utf-8').rstrip().split()

A = [None] * (N+N)
A[::2] = S
A[1::2] = T

answer = ''.join(A)
print(answer)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;



int main(){
    int n;cin>>n;
    int c[n+1],w[n+1];for(int i=1;i<=n;i++)cin>>c[i]>>w[i];
    int sum[n+1];sum[0]=0;for(int i=1;i<=n;i++)sum[i]=sum[i-1]+w[i];
    bool take[n+1][n+1];
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)take[i][j]=false;
    for(int i=1;i<=n;i++)take[i][i]=true;
    for(int len=2;len<=n;len++){
        for(int i=1;i<=n+1-len;i++){
            int j=i+len-1;
            if(take[i][j-1]==true&&c[j]>=sum[j-1]-sum[i-1])take[i][j]=true;
            if(take[i+1][j]==true&&c[i]>=sum[j]-sum[i])take[i][j]=true;
        }
    }
    int dp[n+1];
    dp[0]=0;dp[1]=1;
    for(int i=2;i<=n;i++){
        int k=i;
        dp[i]=dp[i-1]+1;
        while(k>=1&&take[k][i]==true){
            dp[i]=min(dp[i],dp[k-1]+1);
            k--;
        }
    }
    cout<<dp[n]<<endl;
    
    
    return 0;
}



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

int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	vector<int> v = {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 k;
	cin >> k;
	cout << v[k-1];
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <algorithm>
using namespace std;
 bitset<10500> a[50];
int sum;
int r,c;

void dfs(int ans)
{
    if(ans==r)
    {
        int result=0;
        for(int j=0;j<c;j++)
        {
            int number=0;
            for(int i=0;i<r;i++)
            {
                if(a[i][j]) number++;
            }
            number=max(number,r-number);
            result+=number;
        }
        sum=max(sum,result);
        return ;
    }
    dfs(ans+1);
    a[ans].flip();
    dfs(ans+1);
    a[ans].flip();
}

int main(void)
{
   // freopen("C.txt","r",stdin);
  //  int r,c;
    while(scanf("%d%d",&r,&c)!=EOF&&(r||c))
    {

        for(int i=0;i<r;i++)
        {
            for(int j=0;j<c;j++)
            {
                   bool temp;
                scanf("%d",&temp);
                a[i][j]=temp;
            }
        }
        sum=0;
        dfs(0);
        printf("%d\n",sum);


    }

    return 0;
}

Measured memory_bytes: 1252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] c = S.toCharArray();
        for (int i=0;i<c.length;i++) {
            if (c[i]<=90-N) {
                c[i] += N;
            } else {
                c[i] += N-26;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0;i<c.length;i++) {
            sb.append(c[i]);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 21716
a=[];c=[];d=0;p=0;q=0;r=0;m=0;l=0
for i in range(3) :
    b=list(map(int,input().split()))
    a.append(b)
n=int(input())
for i in range(n) :
    z=int(input())
    c.append(z)
for i in range(len(a)) :
    for j in range(len(a)) :
        if a[i][j] in c :
            a[i][j]=1
for i in range(len(a)) :
    if a[i][0]+a[i][1]+a[i][2]==3 :
        d+=1
for i in range(len(a)) :
    p=p+a[i][0];q=q+a[i][1];r=r+a[i][2]
if p==3 or q==3 or r==3 :
    d+=1
for i in range(len(a)) :
    for j in range(len(a)) :
        if i==j :
            l=l+a[i][j]
        elif i+j==(len(a))-1 :
            m=m+a[i][j]
m=m+a[1][1]
if l==3 or m==3 :
    d+=1
if d==0 :
    print("No")
else :
    print("Yes")


Measured memory_bytes: 3064
def main():
    process, quantum = input().split()
    process = int(process)
    quantum = int(quantum)
    processes = []
    for i in range(process):
        t, u = input().split()
        processes.append((t, int(u)))
    ptime = 0
    while len(processes) > 0:
        t = processes.pop(0)
        if t[1] > quantum:
            processes.append((t[0], t[1]-quantum))
            ptime += quantum
        else:
            ptime += t[1]
            print(t[0] + " " + str(ptime))




if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Measured memory_bytes: 14184
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int A = stdIn.nextInt();
        int B = stdIn.nextInt();
        int C = stdIn.nextInt();
        
        int t;

        t = A;
        A = B;
        B = t;

        t = A;
        A = C;
        C = t;

        System.out.print(A+" "+B+" "+C);
       


    }

}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, p, r int
	fmt.Scan(&N)
	min := math.MaxInt64
	for i := 0; i < N; i++ {
		fmt.Scan(&p)
		if p <= min {
			min = p
			r++
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 5504
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

const ll mod = 1000000007;
int main(){
	FASTIO;
  ll n; cin >> n;
  ll dp[1000][n + 1]; memset(dp, 0, sizeof dp);
  for ( int k = 3; k <= n; k++ )
    dp[0][k] = 1;
  ll pref[n + 1];
  for ( int k = 1; k < 1000; k++ ){
    pref[0] = 0; pref[1] = 0, pref[2] = 0;
    for ( int j = 3; j <= n; j++ ){
      pref[j] = dp[k - 1][j] + pref[j - 1];
      pref[j] %= mod;
    }
    for ( int j = 3; j <= n; j++ ){
      dp[k][j] = pref[j - 3];
    }
  }
  ll ans = 0;
  for ( int k = 0; k < 1000; k++ ) {
    ans += dp[k][n];
    ans %= mod;
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19184
// youngjinp20
// 2020 03

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

typedef long long ll;

const int MAX = 100;
int N, W;
int w[MAX];
int v[MAX];

int main() {
	cin >> N >> W;

	int V = 0;
	for (int i=0; i<N; i++) {
		cin >> w[i] >> v[i];
		V += v[i];
	}

	ll dp[V+1] = {0};
	for (int i=0; i<=V; i++) {
		dp[i] = 1e18;
	}
	dp[0] = 0;

	for (int j=0; j<N; j++) {
		for (int i=V; i>0; i--) {
			if (i >= v[j]) {
				dp[i] = min(dp[i-v[j]]+w[j], dp[i]);
			}
		}
	}

	for (int i=V; i>=0; i--) {
		if (dp[i] <= W) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
   long long int i,n,j,k,x,y,sum=0,a,b,c;
   vector<long long int>v,u,w;
   cin>>x>>y>>a>>b>>c;
   for(i=0;i<a;i++)
   {
       cin>>k;
       v.push_back(k);
   }
   for(i=0;i<b;i++)
   {
       cin>>k;
       u.push_back(k);
   }
   for(i=0;i<c;i++)
   {
       cin>>k;
      w.push_back(k);
   }
   sort(u.begin(),u.end());
   sort(v.begin(),v.end());
   reverse(u.begin(),u.end());
   reverse(v.begin(),v.end());
   for(i=0;i<x;i++)
   {
       w.push_back(v[i]);
   }
    for(i=0;i<y;i++)
   {
       w.push_back(u[i]);
   }
   sort(w.begin(),w.end());
   reverse(w.begin(),w.end());
   for(i=0;i<x+y;i++)
   {
       sum+=w[i];
   }
   cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 8048
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<set>
using namespace std;
#define input freopen("/Users/peteryuanpan/data.txt","r",stdin)

const double eps = 1e-8, pi = acos(-1.0);
int sgn(double x){
    if(abs(x) < eps) return 0;
    else return x > 0 ? 1 : -1;
}

#define N 10010
int n;
struct Maze{
    int x1, y1;
    int x2, y2;
}ma[N];

struct Seg{
    double l, r;
    bool operator<(const Seg a)const{
        if(sgn(r-a.r)==0)return l<a.r;
		return r<a.r;
	}
};
set<Seg>s;

double getangle(int x1, int y1){
    double a = atan2(y1, x1);
    if(sgn(a) < 0) a += 2 * pi;
    return a;
}

int solve(){
    set<Seg>::iterator it1,it2;
    int ans=0;
    for(it1=s.begin(), it2 = s.begin(); it1!=s.end();)
    {
        ans++;
        for(; it2!=s.end() && sgn(it2->l - it1->r) <= 0; it2++);
        it1=it2;
    }
    return ans;
}

int main(){
    //input;
    scanf("%d",&n);
        for(int i = 1; i <= n; i++){
            scanf("%d%d%d%d",&ma[i].x1, &ma[i].y1, &ma[i].x2, &ma[i].y2);
        }
        for(int i = 1; i <= n; i++){
            double rad[10];
            rad[1] = getangle(ma[i].x1, ma[i].y1);
            rad[2] = getangle(ma[i].x1, ma[i].y2);
            rad[3] = getangle(ma[i].x2, ma[i].y1);
            rad[4] = getangle(ma[i].x2, ma[i].y2);
            double d = 0.0;
            int w1 = 1, w2 = 2;
            for(int i1 = 1; i1 <= 4; i1++){
                for(int i2 = i1 + 1; i2 <= 4; i2++){
                    double d1 = abs(rad[i1] - rad[i2]);
                    d1 = min(d1, 2 * pi - d1);
                    if(sgn(d1 - d) > 0){
                        d = d1;
                        w1 = i1, w2 = i2;
                    }
                }
            }
            double a1 = rad[w1], a2 = rad[w2];
            if(sgn(a1 - a2) > 0) swap(a1, a2);
            if(sgn((a2 - a1) - d) != 0) swap(a1, a2);
            if(sgn(a1 - a2) > 0) a2 += 2 * pi;
//            seg[i].l = a1, seg[i].r = a2;
            s.insert((Seg){a1,a2});
        }
        int ans = n;
        for(int i = 1; i <= n; i++){
            ans=min(ans,solve());
            Seg cmp=*s.begin();
            s.erase(s.begin());
            cmp.l+=2*pi;
            cmp.r+=2*pi;
            s.insert(cmp);
        }
        printf("%d\n", ans);

    return 0;
}
/*
2
10000 9999 10001 10000
10000 10002 10001 10003

2
10000 9999 10001 10000
9999 10001 10000 10002
*/

Measured memory_bytes: 1420
a = input()
odd = {"R","U","D"}
even = {"L","U","D"}
good = True
for i in range(len(a)):
    if i%2 == 0:
        if a[i] not in odd:
            good = False
    else:
        if a[i] not in even:
            good = False
if good:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()

print("ABC") if S == 'ARC' else print("ARC")


Measured memory_bytes: 9036
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int ASC(const int *a,const int *b){
	return (*a - *b);
}

int main(int argc, char const *argv[])
{
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	qsort(a,3,sizeof(int),ASC);
	printf("%d\n",a[0]+ a[1]);
	return 0;
}


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

void fnInput(vector<string>& rvsStrX, vector<string>& rvsStrY)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i)
  {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string>& cnrvsStrX, const vector<string>& cnrvsStrY)
{
  for (int i = 0; i < cnrvsStrX.size(); ++i)
  {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();
    vector<vector<int>> vvnLcsDP(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}

Measured memory_bytes: 6956
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int INF=1e9+7;
int main(){
  string s;
  cin>>s;
  bool ans=false;
  if(s[2]==s[3]&&s[4]==s[5]){ans=true;}
  if(ans){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        string t = s.substr(0, k);
        cout << t << "..." << endl;
    }
}

Measured memory_bytes: 3616
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;

int main()
{
    speed;
    ll t,i,j,a,b,d=0,e=0;
    string s;
    cin>>s;
    for(i=0;i<3;i++)
        cout<<s[i];
    cout<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
const long long mod = 1e9+7;

int main(){
    long long n;
    cin >> n;
    
    map<int, int> mp; // mmp[i] : 素因数iが何個存在するか？？
    
    // 2, 3, ,,,, nについて各素数の個数を求めよう
    for (int i = 2; i <= n; i++){
        
        int copy = i;
        
        // iについて, 各素因数で何回割り切れるかを調べる
        for (int j = 2; j <= copy; j++){
            
             // j で割り切れる間, 割り続ける
            while (copy % j == 0){
                copy /= j;
                mp[j]++;
            }
        }
    }
    
    long long ans = 1; // 少なくとも, 1が約数である
        
    for (auto p : mp){
        ans = ans * (p.second + 1) % mod;
    }
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >>C;
  int max=0,min=0;
  if(A>B){
  	if(A>C){
    	max=A;
          if(B>C){
          	min=C;
          }else{
          	min=B;
          }
    }else{
    	max=C;
      	min=B;
    }
  }else{
  	if(B>C){
    	max=B;
      if(A>C){
      	min=C;
      }else{
      	min=A;
      }
    }else{
    	max=C;
      min=A;
    }
  }
  
  cout << max-min << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
h=LI()
dp=[0 for i in range(n)]
dp[1]=abs(h[1]-h[0])
for i in range(n-2):
    dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]))
#print(dp)
print(dp[-1])

Measured memory_bytes: 14492
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    x1, y1, x2, y2 = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    dx = x2-x1
    dy = y2-y1
    
    tmp=dx
    dx = -dy
    dy = tmp
    x_3 = x2 +dx
    y_3 = y2 +dy

    tmp=dx
    dx = -dy
    dy = tmp
    x_4 = x_3 +dx
    y_4 = y_3 +dy
    print(x_3,y_3,x_4,y_4)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<bool> b(1000000,true);
  b[0]=b[1]=false;
  for(int i=2;i<1000000;i++){
    if(b[i]){
      for(int j=2;i*j<1000000;j++){
        b[i*j]=false;
      }
    }
  }
  int n,c=0;
  cin>>n;
  for(int i=3;i<1000000;i+=5){
    if(b[i]){
      cout<<i<<" ";
      c++;
    }
    if(c==n)break;
  }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {

    int r, g, b, n;
    cin >> r >> g >> b >> n;

    long long int ans = 0;

    for (int i = 0; i <= n/r; i++) {
        for (int j = 0; j <= n/g; j++) {
            int kari = r*i+g*j;
            if ((n-kari) >= 0 && (n-kari) % b == 0) {
                //cout << i << ' ' << j << endl;
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N,M,X=map(int,input().strip().split())
C=[]
A=[]
for n in range(N):
    l=list(map(int,input().strip().split()))
    C.append(l[0])
    A.append(l[1:])

cost=sum(C)
reach=False
def dfs(L,N):
    global reach
    global cost
    if len(L)==N:
        skill=[0 for m in range(M)]
        temp=0
        for n in range(N):
            if L[n]==1:
                temp+=C[n]
                for m in range(M):
                    skill[m]+=A[n][m]
        res=True
        for e in skill:
            if e<X:
                res=False
                break
        
        if res==True:
            reach=True
            if temp<=cost:
                cost=temp     
        return
    
    else:
        for i in range(2):
            L.append(i)
            dfs(L,N)
            L.pop()

dfs([],N)
if reach==True:
    print(cost)
else:
    print(-1)

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

int main(void)
{
    int N;
    cin >> N;

    set<int> d;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        d.insert(tmp);
    }

    cout << d.size() << endl;
}


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

int main()
{	
	double d, t, s;
	while(cin >> d >> t >> s){
		if(d/t < s || (d/t - s) < 1e-6)
			cout << "Yes\n";

		else
		{
			cout << "No\n";
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define nl endl
#define tc    \
    ll t;     \
    cin >> t; \
    while (t--)
#define fastio                       \
    ios_base::sync_with_stdio(NULL); \
    cin.tie(NULL);                   \
    cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
    int n,b=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2!=0)
            b++;
    }
    if(b%2!=0)
        cout<<"NO";
    else
        cout<<"YES";
}

Measured memory_bytes: 3948
N=gets.to_i;M=10**9+7;I=[1,1];*F=I;*R=I;2.upto(N){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M};r=F[N];(-~N/2...N).each{|i|r=(r-F[i-1]*R[2*i-N]*F[i])%M};p r

Measured memory_bytes: 27180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		String res = (k * 500 >= x) ? "Yes" : "No";
		
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22740
#include<stdio.h>
int data[100];
int sp =0;
int empty(){
  return sp <= 0;
}
int pop(){
  sp--;
  return data[sp+1];
}
void push(int v){
  sp++;
  data[sp] = v;
}
int main(){
  int a;
  while(scanf("%d",&a) != EOF){
    if(a != 0){
      push(a);
    }else{
      if(empty()) break;
      printf("%d\n",pop());
    }
    
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
using namespace std;

int main()
{
    int N, C, K, ans = 0;
    cin >> N >> C >> K;

    vector<int> vec(N);
    for(int i = 0; i < N; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());

    for(int i = 0; i < N;)
    {
        int cnt = 0;
        int j = i;
        while(1)
        {
            if(cnt == C || vec.at(j) > vec.at(i) + K) 
            {
                
                ans++;
                //cout << i << " " << j << endl;
                break;
            }
            else if(j == N - 1)
            {
                ans++;
                j++;
                break;
            }

            cnt++;
            j++;
        }

        i = j;
    }

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

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] output_char = new char[52];
		
		for(int i = 0; i < 26; i++){
			output_char[i] = (char)('a' + i);
			output_char[i + 26] = (char)('A' + i);
		}
		
		Map<Character, Integer> dict = new HashMap<Character, Integer>();
		for(int i = 0; i < output_char.length; i++){
			dict.put(output_char[i], i);
		}
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] keys = new int[n];
			for(int i = 0; i < n; i++){
				keys[i] = sc.nextInt();
			}
			
			
			char[] input = sc.next().toCharArray();
			int[] input_value = new int[input.length];
			for(int i = 0; i < input.length; i++){
				input_value[i] = dict.get(input[i]);
			}
			
			for(int pos = 0; pos < input_value.length; pos++){
				final int use_key = pos % n;
				
				//System.out.println(use_key);
				
				//System.out.println(use_key);
				
				int out = (52 + input_value[pos] - keys[use_key]) % 52;
				
				input[pos] = output_char[out];
			}
			
			for(int i = 0; i < input.length; i++){
				System.out.print(input[i]);
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 24604
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;
LL n, x;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
int main() {
	cin >> n >> x;
	cout << 3 * (n - gcd(n, x)) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=0; i<=n; i+=4){
        for(int j=0; j<=n; j+=7){
            if(i+j==n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll sum[200010];

int bin_s(int l, int r) {
	ll g = (sum[l] + sum[r]) >> 1;
	int ok = l, ng = r;
	while (ok + 1 < ng) {
		int mid = (ok + ng) >> 1;
		if (sum[mid] <= g)ok = mid; else ng = mid;
	}
	if (g - sum[ok] < sum[ng] - g)return ok; else return ng;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		sum[i + 1] = sum[i] + a;
	}
	ll ans = 1e15;
	for (int i = 2; i + 2 <= n; i++) {
		int form = bin_s(0, i), lat = bin_s(i, n);
		ll mn = min(sum[form], sum[i] - sum[form]), mx = max(sum[form], sum[i] - sum[form]);
		mn = min(mn, min(sum[lat] - sum[i], sum[n] - sum[lat]));
		mx = max(mx, max(sum[lat] - sum[i], sum[n] - sum[lat]));
		ans = min(ans, mx - mn);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int((x).size()))
#define fi first
#define se second
#define pb push_back
#define VI vector<int>
typedef long long ll;
typedef pair<int,int> pii;
const int maxN=(1<<18)+5;
int n,a[maxN];
pii f[maxN];
void up(int k,pii&p){
  if(a[k]>a[p.fi])p.se=p.fi,p.fi=k;
  else if(k!=p.fi&&a[k]>a[p.se])p.se=k;
}
int main(){
  //freopen("aa.in","r",stdin);
  int i,j;
  scanf("%d",&n);
  for(i=0;i<1<<n;++i){
    scanf("%d",a+i);
    f[i].fi=i;
    f[i].se=1<<n;
  }
  a[1<<n]=0;
  int ans=0;
  for(int k=0;k<1<<n;++k){
    //printf("f %d : %d %d\n",k,f[k].fi,f[k].se);
    for(i=0;i<n;++i)up(f[k].fi,f[k|1<<i]);
    if(k){
      ans=max(ans,a[f[k].fi]+a[f[k].se]);
      printf("%d\n",ans);
    }
  }
  return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;

	ll g = 0;
	vector<bool> exist(32);
	for (auto i = 0; i < N; ++i)
	{
		ll a;
		cin >> a;
		g ^= a;

		for (auto j = 0; j < 32; ++j)
		{
			auto bit = 1ll << j;
			auto mask = (1ll << (j + 1)) - 1;
			if ((a & mask) == bit)
			{
				exist[j] = true;
				break;
			}
		}
	}

	auto result = 0;
	for (auto i = 31; i >= 0; --i)
	{
		auto bit = 1ll << i;
		if ((g & bit) == 0)
		{
			continue;
		}

		if (!exist[i])
		{
			result = -1;
			break;
		}

		++result;
		g ^= bit;
		g ^= bit - 1;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    use std::collections::HashSet;

    let n: usize = read();
    let a: HashSet<u32> = (0..n).map(|_| read()).into_iter().collect();
    println!("{}", a.len());
}


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

 
int main(){
  int h,a;
  cin >>h >> a;
  if(h%a==0){
  cout << h/a << endl;
  }
  else{
    cout << (h/a)+1 << endl;
  }
}
      
  
  
  

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int n;
	cin >> n;

	double ans = 0;

	vector<double> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		a[i] = 1 / a[i];
		ans += a[i];
	}

	ans = 1 / ans;

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
val high=listOf(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)
 
fun main(args: Array<String>) {
    val input = readLine()?.toInt()
    println(high[input!!-1])
 
}

Measured memory_bytes: 31948
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 111;
const int M = N * 3;
int dp[N][N][M];
int a[N], b[N];
int W;
int n;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d%d", &n, &W);
    for (int i = 0; i < n; i++)
        scanf("%d%d", &a[i], &b[i]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= i; j++)
            for (int h = 0; h <= 3 * j; h++)
            {
                dp[i + 1][j][h] = max(dp[i + 1][j][h], dp[i][j][h]);
                dp[i + 1][j + 1][h + a[i] - a[0]] = max(dp[i + 1][j + 1][h + a[i] - a[0]], dp[i][j][h] + b[i]);
            }
    int ans = 0;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= 3 * i; j++)
        {
            ll curW = (ll)a[0] * i + j;
            if (curW <= W)
                ans = max(ans, dp[n][i][j]);
        }
    printf("%d\n", ans);

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256