akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

ll dp[44][444][444];
ll a[44],b[44],c[44];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n, ma, mb; cin >> n >> ma >> mb;
    REP(i,n) cin >> a[i] >> b[i] >> c[i];
    REP(i,n+1) REP(j,404) REP(k,404) dp[i][j][k] = INF;

    dp[0][0][0] = 0;
    REP(i,n) {
        REP(j,404) {
            REP(k,404) {
                chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
                chmin(dp[i+1][j][k], dp[i][j][k]);
            }
        }
    }

    ll ans = INF;
    rep(i,1,404) rep(j,1,404) if(i*mb == j*ma) chmin(ans, dp[n][i][j]);
    if(ans==INF) cout << -1;
    else cout << ans;
    cout << '\n';

    return 0;
}

Measured memory_bytes: 63616
unittest
{
	assert( [ "5", "1 4 3 5 2" ].parse.expand.solve == 2 );
	assert( [ "2", "1 2" ].parse.expand.solve == 1 );
	assert( [ "2", "2 1" ].parse.expand.solve == 0 );
	assert( [ "9", "1 2 4 9 5 8 7 3 6" ].parse.expand.solve == 3 );
	
	assert( [ "6", "1 2 3 4 5 6" ].parse.expand.solve == 3 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	as[] -= 1;
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	
	// 1回の入れ替えで2個解消できるところを優先して入れ替える
	foreach( i; 0L .. as.length.signed - 1 )
	{
		if( as[ i ] != i || as[ i + 1 ] != i + 1 ) continue;
		as.swapAt( i, i + 1 );
		ans++;
	}
	
	// 残りを入れ替える
	foreach( i; 0L .. as.length.signed - 1 )
	{
		if( as[ i ] != i && as[ i + 1 ] != i + 1 ) continue;
		as.swapAt( i, i + 1 );
		ans++;
	}
	
	return ans;
}


Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define sqr(a) (a)*(a)

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if((a[0] == a[1] || a[1] == a[2]) && a[0] != a[2]){
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h := intScanner()
	w := intScanner()
	s := stringSliceScanner(h)
	a := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if string(s[i][j]) == "#" {
				a++
			}
		}
	}
	c, x, y := 1, 0, 0
	for i := 0; x != h && y != w; i++ {
		if y+1 < w {
			if string(s[x][y+1]) == "#" {
				y++
				c++
				continue
			}
		}
		if x+1 < h {
			if string(s[x+1][y]) == "#" {
				x++
				c++
				continue
			}
		}
		break
	}
	if c == a {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 640
#include<stdio.h>

int main () {
   int a[50];
   int n, i, j;

   scanf("%d", &n);

   a[0] = 1;
   a[1] = 1;

   for(i = 2; i <= n; i++){
      a[i] = a[i-1] + a[i-2];
   }

   printf("%d\n", a[n]);

   return 0;
}

Measured memory_bytes: 1820
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong(sc.next());
        long w = Long.parseLong(sc.next());
        if (h == 1 || w == 1) {
            System.out.println(1);
        } else if (h % 2 == 0) {
            System.out.println((h / 2) * w);
        } else {
            System.out.println((((h / 2) + 1) * w) - (w / 2));
        }
    }
}

Measured memory_bytes: 20560
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INARR(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n;
	
}


void preprocess() {
	
	
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	u = min(n, 9);
	
	v = min(n, 999);
	v = max(0, v - 99);
	
	w = min(n, 99999);
	w = max(0, w - 9999);
	
	cout << u + v + w << endl;
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        List<int>[] graph = Enumerable.Repeat(0, n).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < m; i++)
        {
            var st = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            graph[st[0]].Add(st[1]);
        }
        ImmutableStack<int> resStack = null;
        for (int i = 0; i < n; i++)
        {
            ImmutableStack<int>[] istacks = new ImmutableStack<int>[n];
            istacks[i] = new ImmutableStack<int>().Push(i);
            Queue<int> queue = new Queue<int>();
            queue.Enqueue(i);
            while (queue.Count > 0)
            {
                var item = queue.Dequeue();
                foreach (var adj in graph[item])
                {
                    if (adj == i)
                    {
                        if (resStack == null || resStack.Count > istacks[item].Count) resStack = istacks[item];
                        goto end;
                    }
                    if (istacks[adj] != null) continue;
                    istacks[adj] = istacks[item].Push(adj);
                    queue.Enqueue(adj);
                }
            }
            end:;
        }
        if (resStack == null) Console.WriteLine(-1);
        else
        {
            Console.WriteLine(resStack.Count);
            while (resStack.Count > 0)
            {
                Console.WriteLine(resStack.Top + 1);
                resStack = resStack.Pop();
            }
        }
    }
}


class ImmutableStack<T>
{
    readonly ImmutableStack<T> previousStack;
    public readonly T Top;
    public readonly int Count;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ImmutableStack() : this(null, default(T), 0) { }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private ImmutableStack(ImmutableStack<T> prev, T top, int count)
    {
        previousStack = prev;
        Top = top;
        Count = count;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ImmutableStack<T> Push(T value) => new ImmutableStack<T>(this, value, Count + 1);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ImmutableStack<T> Pop() => previousStack == null ? null : previousStack;
}


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

int table[1001][1001] = {};

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

	for (int i = 0; i < a.size() + 1; i++)
	{
		table[i][0] = i;
	}
	for (int j = 0; j < b.size() + 1; j++)
	{
		table[0][j] = j;
	}
	for (int i = 1; i < a.size() + 1; i++)
	{
		for (int j = 1; j < b.size() + 1; j++)
		{
			if (a[i - 1] == b[j - 1])
				table[i][j] = min({ table[i - 1][j - 1], table[i - 1][j] + 1, table[i][j - 1] + 1 });
			else
				table[i][j] = min({ table[i - 1][j - 1] + 1, table[i - 1][j] + 1, table[i][j - 1] + 1 });
		}
	}

	cout << table[a.size()][b.size()] << endl;
}

Measured memory_bytes: 7108
N,K = map(int,input().split())
x=list(map(int,input().split()))
flag=0

ans=10**11
for i in range(0,len(x)-K+1):
    if x[i]*x[K-1+i] <0:
        anss=abs(x[i])+ abs(x[K-1+i])
        anss += min(abs(x[i]),abs(x[K-1+i]))
    else:
        anss=max(abs(x[i]), abs(x[K-1+i]))
    ans=min( ans, anss)

print(ans)

Measured memory_bytes: 14384
R = lambda: map(int, input().split())
 
n = int(input())
if n % 3:
    ans = 'YNeos'[any(R())::2]
else:
    a = sorted(R())
    m = n // 3
    if a[0] ^ a[m] ^ a[2 * m] or any(len(set(a[i:i + m])) > 1 for i in range(0, n, m)):
        ans = 'No'
    else:
        ans = 'Yes'
print(ans)

Measured memory_bytes: 14116
#include<cstdio>
#include<algorithm>
struct sushi{
    int neta;
    long long taste;
};
sushi v[100000];
//x[i]=(i種類目の寿司を選んだ時に得られる満足ポイントの最大値)
//    =(vをおいしさの降順でソートしたときにi種類目に初めて出てくる寿司のおいしさ)+(種類ボーナスポイントの差分)
//(種類ボーナスポイントの差分)=i^2-(i-1)^2=i^2-(i^2-2*i+1)=2*i-1
long long x[100001];
//y[i]=(x[]たちに選ばれなかった寿司のうちi番目においしい寿司のおいしさ)
long long y[100001];
bool isused[100001];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        int t;
        long long d;
        scanf("%d%lld",&t,&d);
        v[i]={t,d};
    }
    std::sort(
        v,v+n,
        [](const sushi& a,const sushi& b){
            return a.taste>b.taste;
        }
    );
    int xi=1,yi=1;
    for(int i=0;i<n;i++)isused[i]=false;
    for(int i=0;i<n;i++){
        if(!isused[v[i].neta]){
            isused[v[i].neta]=true;
            x[xi]=v[i].taste+2*xi-1;
            xi++;
        }else{
            y[yi]=v[i].taste;
            yi++;
        }
    }
    long long sum=0;
    for(int i=1;i<=k;i++)sum+=x[i];
    long long ans=sum;
    for(int m=1;m<=k;m++){
        sum+=y[m]-x[k+1-m];
        if(ans<sum)ans=sum;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
a = input()
b = input()
c = input()


counter=0
for i in range(n):
    if (len(set((a[i], b[i], c[i]))) == 3):
        counter+=2
    elif(len(set((a[i], b[i], c[i]))) == 2):
        counter+=1
    else:
        counter+=0

print(counter)

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

void solve()
{
	int n, x, t;
	cin >> n >> x >> t;
	cout << (ll)ceil(n/(long double)x) * t << "\n";
}

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


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

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int cnt=0,sum;
  rep(i,a+1)rep(j,b+1)rep(k,c+1) {
    sum = 500*i + 100*j + 50*k;
    if (sum==x) cnt+=1;
  }
  cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> v(n);
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    long long sum = 0;
    for(int i=n-1; i>=0; i--) {
        if(k > 0) {
            k--;
            continue;
        }
        sum = sum + v[i];
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.HashMap;

public class Main {
    private static final int MAXN = 2 * (int)10e5, MAXA = (int)10e9;
    private static int[] data = new int[3];
    private final static String[] str = {"A", "B", "C"};

    private static String calc(int i, int j, String next, String comp) {
        if (data[i] == 0 && data[j] == 0) {
            return "";
        }

        if (data[i] == 0) {
            ++data[i];
            --data[j];
            return str[i];
        } else if(data[j] == 0){
            --data[i];
            ++data[j];
            return str[j];
        } else {
            if(data[i] == 1 && data[j] == 1) {
                if (next.equals(comp)) {
                    --data[i];
                    ++data[j];
                    return str[j];
                } else {
                    ++data[i];
                    --data[j];
                    return str[i];
                }
            } else if (data[i] > data[j]) {
                --data[i];
                ++data[j];
                return str[j];
            } else {
                ++data[i];
                --data[j];
                return str[i];
            }
        }
    }

    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var n = scanner.nextInt();

        for (int i = 0; i < 3; ++i) {
            data[i] = scanner.nextInt();
        }

        var strs = new String[n];
        for (int i = 0; i < n; ++i) {
            strs[i] = scanner.next();
        }

        boolean ans = true;
        var rets = new String[n];
        for (int i = 0; i < n; ++i) {
            String next = "";
            if (i + 1 < n) {
                next = strs[i + 1];
            }

            if (strs[i].equals("AB")) {
                rets[i] = calc(0, 1, next, "BC");
                if (rets[i].equals("")) {
                    ans = false;
                    break;
                }
            }
            if (strs[i].equals("BC")) {
                rets[i] = calc(1, 2, next, "AC");
                if (rets[i].equals("")) {
                    ans = false;
                    break;
                }
            }
            if (strs[i].equals("AC")) {
                rets[i] = calc(0, 2, next, "BC");
                if (rets[i].equals("")) {
                    ans = false;
                    break;
                }
            }
        }

        if (ans) {
            System.out.println("Yes");
            for (int i = 0; i < n; ++i) {
                System.out.println(rets[i]);
            }
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {

    int n,x;
    cin >> x >> n ;
    unordered_set<int> v;
    for( int i = 0 ; i < n ; ++i) {
        int x;cin >> x ; v.insert(x) ;
    } 
    for ( int i = 0 ; ; ++i ) {
        if ( v.find(x-i)==v.end() ){
             cout << x-i << endl ;
             return 0 ;
        } 
        if ( v.find(x+i)==v.end() ){
             cout << x+i << endl ;
             return 0 ;
        } 
    } 

}

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

int main(){
  int r, c;
  cin >> r >> c;

  int mat[101][101]={};

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

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



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>

using namespace atcoder;
//typedef modint998244353 mint;

ll op(ll a,ll b){
  return max(a,b);
}

ll e(){
  return -1;
}

ll target;
bool f(ll a){
  return a<target;
}

int main(){
  int N,Q;
  cin>>N>>Q;
  VL A(N);
  rep(i,N) cin>>A[i];
  segtree<ll,op,e> seg(N);
  rep(i,N) seg.set(i,A[i]);
  while(Q--){
    ll T,B,C;
    cin>>T>>B>>C;
    if(T==1){
      seg.set(B-1,C);
    }else if(T==2){
      cout<<seg.prod(B-1,C)<<endl;
    }else{
      target=C;
      cout<<seg.max_right<f>(B-1)+1<<endl;
    }
  }
}

Measured memory_bytes: 10420
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, vector<ll> V, vector<ll> C) {
  int ans{};
  for (auto i=0; i!=N; ++i) {
    if(V[i]>C[i]) {
      ans += V[i] - C[i];
    }
  }
  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  vector<ll> C(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  solve(N, move(V), move(C));
  return 0;
}


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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    vector <int> g[n];
    for (int i = 1; i < n; ++i) {
        int v;
        cin >> v;
        --v;
        g[v].push_back(i);
        g[i].push_back(v);
    }
    cout << g[0].size() << '\n';
    for (int i = 1; i < n; ++i) cout << g[i].size() - 1 << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 16284
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e3 + 10;
int N;
char S[MAXN];

int main() {
	register int i, j, k;
	scanf("%s", S + 1); N = strlen(S + 1);
	for(i = N + 1; i; --i) {
		for(j = i == N + 1 ? 'a' : S[i] + 1; j <= 'z'; ++j) {
			for(k = 1; k < i; ++k)
				if(S[k] == j)
					break;
			if(k == i)
				break;
		}
		if(j <= 'z')
			break;
	}
	if(i)
		S[i] = j, S[i + 1] = 0, puts(S + 1);
	else
		puts("-1");
	return 0;
}

Measured memory_bytes: 128
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;


int main()
{ 

IOS;

ll x;cin>>x;
if(x>=30)cout<<"Yes";
else cout<<"No";


//end_routine();

return 0;
 
 }


Measured memory_bytes: 3648
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define pb push_back
#define mp make_pair
#define fill(x,y) memset(x,y,sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) {
	return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

//template<typename T>void swap(T &a, T &b) { T c = a; a = b; b = c; }

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; }

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	int Q; cin >> Q;
	REP(i, Q) {
		ll a, b; cin >> a >> b;
		if (a > b) swap(a, b);
		ll pab = a * b;
		ll c = (ll)sqrt(pab);
		if (c * c == pab) c--;
		ll ans = 2 * c;
		if (c != 0 and c == (pab - 1) / c) ans--;
		if (c >= min(a, b)) ans--;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ls=[]
cnt,cnt2,ans=0,0,0
for i in range(M):
    ls1=list(map(int,input().split()))
    ls.append(list(ls1))
    ls1.clear()
lsp = list(map(int,input().split()))
#print(ls)
#print(lsp)
for i in range(2**N):
    flg = True
    for j in range(M):
        cnt = 0
        for k in range(1,len(ls[j])):
            if i >> ls[j][k]-1 & 1:
                cnt += 1
        if cnt%2 != lsp[j]:
            flg = False
    if flg:
        ans += 1
print(ans)


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

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

	int time[n];
	for(int i = 0; i < n; i++){
		cin >> time[i];
	}

	int m;
	cin >> m;
	
	int ps[m][2];
	for(int i = 0; i < m; i++){
		cin >> ps[i][0];
		cin >> ps[i][1];
	}

	for(int i = 0; i < m; i++){
		int sum = 0;
		sum += ps[i][1];
		for(int j = 0; j < n; j++){
			if(ps[i][0] != j + 1)
				sum += time[j];
		}
		cout << sum << "\n";
	}
}

Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

////////////////いろいろあるよ//////////////////////////////////
int main(){
    int m; cin >> m;
    ll data[m];
    REP(i,m){
        data[i] = 0;
    }
    REP(i,m){
    	int piyo=0; cin >> piyo;
        data[piyo-1]++;
    }
    REP(i,m){
    	cout << data[i] << endl;
    }
  
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	map<int, int> si[100001];
	int n, m;
	cin >> n >> m;
	int p, y;
	pair<int, int> input[100001];
	for (int i = 0; i < m; ++i)
	{
		cin >> p >> y;
		si[p][y] = 1;
		input[i] = make_pair(p, y);
	}
	for (int i = 0; i <= n; ++i)
	{
		int count = 1;
		for (auto itr = si[i].begin(); itr != si[i].end(); ++itr)
		{
			itr->second = count++;
		}
	}
	for (int i = 0; i < m; ++i)
	{
		printf("%06d%06d\n", input[i].first, si[input[i].first][input[i].second]);
	}
	return 0;
}

Measured memory_bytes: 11776
#include<iostream>
using namespace std;
int  a[3000005], f[3000005];
int main() {
	long long m, n;
	cin >> n >> m;
	for (long long i = 1; i <= n; i++) {
		cin >> a[i];
		f[i] = 0;
	}

	long long k = 1, x = a[1];
	f[1] = 1;
	while (f[x] == 0) {
		if (k == m) {
			cout << x << endl;
			return 0;
		}
		f[x] = ++k;
		x = a[x];
		
	}
	long long t = k + 1 - f[x];
	k = (m - f[x] + 1) % t;

	for (long long i = 0; i < k; i++) {
		x = a[x];
	}
	cout << x << endl;
	return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                             \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL << 60;

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    init(n);
  }
  void init(int n=1) {
    data.assign(n, -1);
  }
  int root(int x) {
    if (data[x] < 0) return x;
    return (data[x] = root(data[x]));
  }
  bool issame(int x, int y) {
    return (root(x) == root(y));
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int size(int x) {
    return (-data[root(x)]);
  }
};

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

  UnionFind uf(n);

  for (int i = 0; i < m; i++) {
    ll a,b; cin>>a>>b; a--; b--;
    uf.merge(a, b);
  }

  ll ans = 0;
  rep(i, n) {
    ans = max(ans, (ll)uf.size(i));
  }

  cout << ans << endl;

  return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;
    ll K;
    cin >> K;
    bool one = true;
    char ans;
    REP(i, S.length()) {
        if (i == K) break;
        if (S[i] != '1') {
            one = false;
            ans = S[i];
            break;
        }
    }
    if (one) {
        print(1);
    } else {
        print(ans);
    }
}

signed main() {
    solve();
}


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

using namespace std;

int main() {
  int n;
  int a=-1, b=-1,c=-1;
  uint64_t y;
  cin >> n >> y;
  int good =false;
  for(int i=0; i<=n;i++){
    for(int j=0; j<=n-i; j++){
      if(10000*i + 5000*j +1000*(n-i-j) == y){
        a=i; b=j; c=(n-i-j);
        good= true; break;
      }
    }
    if(good) break;
  }
  cout << a << " " << b <<" " << c <<endl;
}


Measured memory_bytes: 256
from collections import deque

S = input()

pool_q=deque()
slope_q=deque()

for i,s in enumerate(S):
    if s=="\\":
        slope_q.append(i)
        pool_q.append((i,0))
    elif s=="/":
        if len(slope_q) > 0:
            pre_down=slope_q.pop()
            plus=i-pre_down
            while 1:
                pre_pool=pool_q.pop()
                if pre_pool[0] == pre_down:
                    pool_q.append((pre_down,plus))
                    break
                else:
                    plus+=pre_pool[1]
SUM = 0
ans=[0]
cnt=0
for i in range(len(pool_q)):
    pool=pool_q.popleft()[1]
    if pool > 0:
        ans.append(pool)
        SUM+=pool
        cnt+=1
ans[0]=cnt
print(SUM)
print(*ans)


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

int main(){
    int W, H;
    cin >> W >> H;
    
    
    vector<pair<ll, int>> pq;
    for (int i = 0; i < W; i++) {
        ll p;
        cin >> p;
        pq.push_back({p, 1});
    }
    for (int i = 0; i < H; i++) {
        ll q;
        cin >> q;
        pq.push_back({q, 2});
    }
    sort(pq.begin(), pq.end());
    
    int w, h;
    w = W + 1;
    h = H + 1;
    
    ll ans = 0;
    for (int i = 0; i < W+H; i++){
        ll cost = pq[i].first;
        int dir = pq[i].second;
        if (dir == 1) {
            if (w > 1) {
                ans += cost * h;
                w--;
            }
        }
        else {
            if (h > 1) {
                ans += cost * w;
                h--;
            }
        }
        if (w == 1 && h == 1) break;
        
    }
    
    cout << ans << endl;
    
}

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

using namespace std;
typedef long long ll;

const int N = 1e5+1;
const int MOD = 1e9+7;
ll dp[N][13];
string n;

void solve(int i) {
    if(i >= n.size()) return;
    if(n[i]=='?') {
        for(int num=0; num < 10; num++) {
            for(int j=0; j < 13; j++) {
                dp[i+1][(j*10+num)%13] += dp[i][j];
                dp[i+1][(j*10+num)%13] %= MOD;
            }
        }
    }
    else {
        int num = n[i]-'0';
        for(int j=0; j < 13; j++) {
            dp[i+1][(j*10+num)%13] += dp[i][j];
            dp[i+1][(j*10+num)%13] %= MOD;
        }
    }

    solve(i+1);
}

int main() {
	cin >> n;
    dp[0][0] = 1;

    solve(0);

    cout << dp[n.size()][5];

    return 0;
}

Measured memory_bytes: 10624
#include<algorithm>
#include<cmath>
#include<functional> //sortのgreater
#include<iostream>
#include<numeric> //iota(整数列の生成),gcdとlcm(c++17)
#include<string> //文字列
#include<vector>

#define rep(i,n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;

int main()
{
    // Input
    string in;
    cin >> in;

    if (in == "ABC") {
        cout << "ARC";
    } else {
        cout << "ABC";
    }

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main(int argc, char** argv)
{
    string S;
    cin >> S;
    while (S.find("/") != -1) {
        int idx = S.find("/");
        S.replace(idx, 1, "");
    }

    int compare = 20190430;
    int date = std::stoi(S);
    if (date <= compare) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;

	string a = s.substr(0, 4);
	string b = s.substr(4, 8);
	cout << a << ' ' << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[15];
    char t[15];
    scanf("%s",s);
    scanf("%s",t);
    int n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll func(ll x, ll k) {
  return min(x, min(x%k, k - (x%k)));
}

void solve() {
  ll n, k;
  cin >> n >> k;
  ll x = n;
  ll ans = func(x, k);
  cout << ans << endl;
}

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int q,h,s,d;
  cin>>q>>h>>s>>d;
  int n;
  cin>>n;
  int t[4];
  t[0] = 8*q;
  t[1] = 4*h;
  t[2] = 2*s;
  t[3] = d;
  sort(t,t+4);
  long long ans = (long long)t[0] * ((long long)n/2);
  if(n%2 == 0){
    cout<<ans<<endl;
    return 0;
  }
  int tt[3];
  tt[0] = 4*q;
  tt[1] = 2*h;
  tt[2] = s;
  sort(tt,tt+3);
  ans += (long long)tt[0];
  cout<<ans<<endl;
  return 0; 
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

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

  cout << b/x + 1 - (a==0 ? 0 : (a-1)/x + 1) << endl;

}





Measured memory_bytes: 256
n = gets.to_i
a = []
n.times do |i|
  a << gets.to_i
end
a.sort!
s = a.inject(:+)
b = a.reject{|r| r % 10 == 0}
if s % 10 == 0
  if b.empty?
    p 0
  else
    p s - b.shift
  end
else
  puts s
end


Measured memory_bytes: 1788
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}

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


Measured memory_bytes: 256
xy=[(1,0),(-1,0),(0,1),(0,-1)]
ans=chk=0
h,w=map(int,input().split())
d=[[0]*w for i in range(h)]
l=[]
for i in range(h):
    a=input()
    chk+=a.count("#")
    l.append(a)
p=set([(0,0)])
while len(p):
    a,b=p.pop()
    for y,x in xy:
        y+=a
        x+=b
        if 0<=y<h and 0<=x<w and l[y][x]!="#":
            if d[y][x]==0 or d[y][x]>d[a][b]+1:
                d[y][x]=d[a][b]+1
                p.add((y,x))

print(-1 if d[h-1][w-1]==0 else h*w-1-chk-d[h-1][w-1])


Measured memory_bytes: 40944
# AOJ 0220 Binary Digit A Doctor Loved
# Python3 2018.6.23 bal4u

while 1:
	s = input()
	if s[0] == '-': break
	if s.find('.') < 0: a, b = s, '0'
	else:
		a, b = s.split('.')
		if a == '': a = '0'
		if b == '': b = '0'
	k = 10**len(b)
	a, b = int(a), int(b)
	if a > 255:
		print("NA")
		continue
	sa = format(a, '08b')
	sb = ''
	for i in range(4):
		b *= 2
		if b >= k: sb += '1'
		else: sb += '0'
		b %= k
	if b == 0: print(sa, '.', sb, sep='')
	else: print("NA")



Measured memory_bytes: 5612
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int A[100][100];
int d[100], p[100], color[100];
void dijkstra(int);
int main() {
  int n,i,j,u,k,v,c;
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      A[i][j] = 100001;
    }
  }
  for (i = 0; i < n;i++) {
    scanf("%d",&u);
    scanf("%d",&k);
    for (j = 0; j < k;j++) {
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }/*
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
	printf("%6d ",A[i][j]);
      }
      printf("\n");
    }
   */
    dijkstra(n);
    for (i = 0; i < n;i++) {
      if(d[i] == 100001)d[i] += d[i-1] - 1;
      printf("%d %d\n",i, d[i]);
    }
}
void dijkstra(int n) {
  int i,j, v, u, mincost;
  for (i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = 100001;
  }
  d[0] = 0;
  
  while (1) {
    mincost = 100001;
    //WHITE&GRAYn-1以内で一番小さい値の番をu
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
	mincost = d[i];
	u = i;
      }
    }
    if (mincost == 100001)break;
    color[u] = BLACK;
    
    for (v = 0; v < n; v++) {
      if (color[v] != BLACK && A[u][v] < 100001) {
	if (d[u] + A[u][v] < d[v]) {
	  d[v] = d[u] + A[u][v];
	  color[v] = GRAY;
	}
      }
    }
    /*
    for (j = 0; j < n; j++) {
      printf(" %d",d[j]);
    }
    printf("\n");
    */
  }
}



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

int main(void){
    ll a, b, x;
    cin >> a >> b >> x;
    ll bigger, smaller;
    a--;
    if(a == -1){
        smaller = 0;
    }else{
        smaller = a / x + 1;
    }
    bigger = b / x + 1;
    cout << bigger - smaller << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n%10==7 || n/10%10==7 || n/100== 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, n, count;
    while(cin >> n){
        count = 0;
        for(a=0; a<=9; a++){
            for(b=0; b<=9; b++){
                for(c=0; c<=9; c++){
                    for(d=0; d<=9; d++){
                        if(a+b+c+d == n){
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define maxN 1005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
pi g1[1000006],g2[1000006];
int arr[maxN][maxN];

int32_t main(){
    fastio;
int n;in n;
//n--;
int ans;
ans=(n*(n-1))/2;
out ans;

}


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

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

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

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

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

#define INF 1e16
#define mod 1000000007

struct state{
  ll i, j, d;
};
bool operator<(const state& a,const state& b){
  return a.d > b.d;
}

ll di[]={-1,-1,-1,0,0,1,1,1};
ll dj[]={-1,0,1,-1,1,-1,0,1};

ll H,W,A,B;
string s[1000];
ll d[1000][1000];

bool valid(ll i,ll j){
  return i>=0&&i<H&&j>=0&&j<W;
}

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

  cin>>H>>W>>A>>B;
  rep(i,H)cin>>s[i];
  priority_queue<state> que;
  rep(i,H)rep(j,W){
    d[i][j]=INF;
    if(s[i][j]=='s'){
      que.push((state){i,j,0});
    }
  }

  while(que.size()){
    state crt=que.top(); que.pop();
    if(d[crt.i][crt.j]!=INF)continue;
    d[crt.i][crt.j]=crt.d;
    { // normal
      rep(dir,8){
        if(di[dir]!=0&&dj[dir]!=0)continue;
        ll ni=crt.i+di[dir],nj=crt.j+dj[dir];
        if(valid(ni,nj)&&s[ni][nj]!='#'){
          que.push((state){ni,nj,crt.d+A});
        }
      }
    }
    { // bomb
      bool ok=true;
      if(s[crt.i][crt.j]=='*')ok=false;
      rep(dir,8){
        ll ni=crt.i+di[dir],nj=crt.j+dj[dir];
        if(valid(ni,nj)&&s[ni][nj]=='*')ok=false;
      }
      if(ok){
        rep(dir,8){
          ll ni=crt.i+di[dir],nj=crt.j+dj[dir];
          if(valid(ni,nj)){
            if(di[dir]!=0&&dj[dir]!=0) que.push((state){ni,nj,crt.d+2*A+B});
            else que.push((state){ni,nj,crt.d+A+B});
          }
        }
      }
    }
  }

  rep(i,H)rep(j,W){
    if(s[i][j]=='g'){
      if(d[i][j]==INF)cout<<"INF"<<endl;
      else cout<<d[i][j]<<endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 12268
#include <iostream>
#include <climits>
#include <string>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <queue>
#include <cstdio>

using namespace std;

struct ProcInfo
{
    string name;
    int time;
};

istream& operator>> (istream& is, ProcInfo & proc)
{
    is >> proc.name;
    is >> proc.time;
    return is;
}


int main()
{
    int n, timelimit, c;
    int endtime = 0;
    cin >> n >> timelimit;
    queue<ProcInfo> q;
    while (n--)
    {
        ProcInfo p;
        cin >> p;
        q.push(p);
    }
    while (! q.empty())
    {
        ProcInfo p = q.front();
        q.pop();
        c = min(p.time, timelimit);
        endtime += c;
        p.time -= c;
        if (p.time > 0)
        {
            q.push(p);
        }
        else
        {
            cout << p.name << ' ' << endtime << endl;
        }
    }
}


Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll check(ll n)
{
    ll i;
    set <ll> s;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            s.insert(i);
            s.insert(n/i);
        }
    }
    s.insert(n);
    if(s.size()<=2)
     return 1;
    ll x=*s.begin(),y=*s.rbegin();
    dd res=log(y)/log(x);
    return (floor)(res)==(ceil)(res); 
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {   
       ll n,i,ans=0; 
       cin>>n;
       if(n==1)
       {
           cout<<"0";
           return 0;
       }
       set <ll> s;
       for(i=2;i*i<=n;i++)
       {
           if(n%i==0)
           {
               s.insert(i);
               s.insert(n/i);
           }
       }  
       s.insert(n);
       for(auto u:s)
       {
           if(check(u)&&n%u==0)
           {
               n/=u;
               ans++;
           }
       }
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 3992