akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String x = sc.next();
      int sum = 0;
      int cnt = 1;
      Queue<Integer> que = new ArrayDeque<Integer>();
      for(int i = 1;i < x.length();i++){
      	if(x.substring(i,i+1).equals(x.substring(i-1,i)))cnt++;
        else{
          que.add(cnt);
          cnt = 1;
        }
      }
      que.add(cnt);
      int s = 0;
      if(x.substring(0,1).equals("T"))sum += que.poll();
      if(que.size()%2==0){
      	while(que.size()!=0){
      		int k = que.poll()+s;
        	int l = que.poll();
        	if(l>=k){
              sum+=l-k;
              s = 0;
            }
        	else s = k-l;
      	}
      }else{
        while(que.size()!=1){
        	int k = que.poll()+s;
            int l = que.poll();
            if(l>=k){
              sum+=l-k;
              s = 0;
            }
            else s = k-l;
        }
        if(que.size()==1)s+=que.poll();
      }
      sum += s;
      System.out.println(sum);
    }
}

Measured memory_bytes: 40692
s = input()
K = int(input())
lis =[]
for i in range(len(s)-4):
    lis.append(s[i:i+5])
    
for i in range(len(s)-3):
    lis.append(s[i:i+4])
    
for i in range(len(s)-2):
    lis.append(s[i:i+3])
    
for i in range(len(s)-1):
    lis.append(s[i:i+2])
    
for i in range(len(s)):
    lis.append(s[i:i+1])
    
nlist = list(set(lis))
nlist.sort()
print(nlist[K-1])
    
    

Measured memory_bytes: 5068
#include<iostream>
#include<map>
#include<queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
using namespace std;
typedef pair<int,int> pi;

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

int main()
{
	int t,n;
	
	while(cin>>t>>n,t||n){
		int obj[200][200]={}, sx,sy, x,y;
		int v[200][200]={};
		rep(i,n)cin>>x>>y,obj[y+100][x+100]=1;
		cin>>sx>>sy;
		
		queue<pair<int,pi> > q; q.push(mp(0,mp(sy+100,sx+100)));
		v[sy+100][sx+100]=1;
		
		while(!q.empty()){
			y=q.front().second.first, x=q.front().second.second;
			int ct=q.front().first; q.pop();
			
			if(ct>=t)continue;
			
			rep(d,6){
				int ny=y+dy[d], nx=x+dx[d];
				if(obj[ny][nx]||v[ny][nx])continue;
				q.push(mp(ct+1,mp(ny,nx)));
				v[ny][nx]=1;
			}
		}
		
		int ans=0;
		rep(i,200)rep(j,200)if(v[i][j])ans++;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

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

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

    vector<int> nums(N);
    rep(i, N){
        cin >> nums.at(i);
    }
    sort(nums.begin(), nums.end(), greater<int>());
    int Alice = 0;
    int Bob = 0;
    rep(i, N){
        if(i % 2 == 0) Alice += nums.at(i);
        else Bob += nums.at(i);
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
gCD :: Int -> Int -> Int
gCD a 0 = a
gCD a b = gcd b (mod a b)

lCM :: Int -> Int -> Int
lCM a b = (a * b) `div` (gCD a b)

chomp :: [a] -> [a]
chomp (x:[]) = []
chomp (x:xr) = x : (chomp xr)

split :: String -> String -> [String]
split _ "" = [""]
split t (s:sr)
  |t == [s] = [] : (split t sr)
  |otherwise = (s : (head (split t sr))) : (tail (split t sr))

main = do
  input <- getContents
  let line = map (\l -> map (\n -> (read n)::Int) l) (map (\n -> split " " n) (split "\n" (chomp input)))
  mapM_ (putStr . (++"\n")) (map (\a -> (show $ gCD (a !! 0) (a !! 1)) ++ (" " ++ (show $ lCM (a !! 0) (a !! 1)))) line)

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

int main(){
	int A, B, K; std::cin >> A >> B >> K;

	if (B - A + 1> K * 2) {
		for (int i = A; i < A + K; ++i)
			std::cout << i << std::endl;
		for (int i = B - K + 1; i <= B; ++i)
			std::cout << i << std::endl;
	}
	else
		for (int i = A; i <= B; ++i)
			std::cout << i << std::endl;

	return 0;
}

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

int main() {
  int d, n;
  cin >> d >> n;
  vector<int> t(d);
  vector<vector<int>> abc(n, vector<int>(3));
  int i, j, k;
  for (i = 0; i < d; i++) {
    cin >> t[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      cin >> abc[i][j];
    }
  }

  int dp[d][n];
  for (i = 0; i < d; i++) {
    for (j = 0; j < n; j++) {
      // cout << abc[j][i] << ' ' << abc[j][2] << ' ' << t[i] << endl;
      dp[i][j] = (abc[j][0] <= t[i] && t[i] <= abc[j][1] ? 0 : -1);
    }
    // cout << endl;
  }
  for (i = 1; i < d; i++) {
    for (j = 0; j < n; j++) {
      if (dp[i][j] != -1) {
        for (k = 0; k < n; k++) {
          if (dp[i - 1][k] != -1) {
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(abc[j][2] - abc[k][2]));
          }
        }
      }
    }
  }
  int result = 0;
  for (i = 0; i < n; i++) {
    result = max(result, dp[d - 1][i]);
  }
  cout << result << endl;

  // cout << endl;
  // for (i = 0; i < d; i++) {
  //   for (j = 0; j < n; j++) {
  //     cout << setw(3) << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  return 0;
}



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

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

  int ans = 0;
  int p;
  int max_p;
  rep(i, N) {
    cin >> p;
    ans += p;
    max_p = max(p, max_p);
  }
  cout << ans - max_p / 2 << endl;
  return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  vector<int> dice;

  for (int i = 0; i < 6; i++) {
    int in; cin >> in;
    dice.push_back(in);
  }
  
  string action; cin >> action;
  int len = action.length();

  int d[6] = {1, 5, 3, 2, 4, 6};  // top, N, E, S, W, bottom
  for (int i = 0; i < len; i++) {
      int top = d[0];
      int N = d[1];
      int E = d[2];
      int S = d[3];
      int W = d[4];
      int bottom = d[5];
      if (action[i] == 'N') {
	d[5] = N; d[3] = bottom; d[1] = top; d[0] = S;
      } else if (action[i] == 'S') {
	d[5] = S; d[3] = top; d[1] = bottom; d[0] = N;
      } else if (action[i] == 'E') {
	d[2] = top; d[4] = bottom; d[5] = E; d[0] = W;	
      } else if (action[i] == 'W') {
	d[2] = bottom; d[4] = top; d[5] = W; d[0] = E;		
      }
  }

  cout << dice[d[0]-1] << endl;
  return 0;
}

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

int main(){
  int a, b, ans;
  cin >> a >> b;
  if(abs(a + b) % 2 == 0){
    ans = abs(a + b) / 2;
    cout << ans << endl;
  } else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[]
C=[]
for i in range(Q):
	b,c=list(map(int,input().split()))
	B.append(b)
	C.append(c)

X=collections.Counter(A)

ans=sum(A)
for i in range(Q):
	a=X[B[i]]
	X.subtract({B[i]:a})
	X.update({C[i]:a})
	ans+=a*(C[i]-B[i])
	print(ans)

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

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, i = 0;
    string str;
    cin >> str;
    N = str.length();
    string str1 = string(N, '1');
    string str0 = string(N, '0');
    for(;(str0.substr(i,N-2*i) != str.substr(i, N-2*i)) && (str1.substr(i, N-2*i) != str.substr(i, N-2*i)) && (i <= N/2);++i){}
    cout << N-i << "\n";
    return 0;
}


Measured memory_bytes: 1024
n = int(input());
h = input().split(" ");

for i in range(n) :
	h[i] = int(h[i]);

check = [0] * n;
for i in range(n-1) :
	if h[i] >= h[i+1] :
		check[i] = 1;


i = 0;
ans = 0;
times = 0;
while i < n :
	if check[i] == 1 :
		times += 1;
		if check[i+1] == 0 :
			if times > ans :
				ans = times; 
			times = 0;
	i += 1;

print(ans);

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

using namespace std;

template<typename TH>
void _dbg(const char* sdbg, TH h)
{
	cerr << sdbg << " = " << h << "\n";
}

template<typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t)
{
	while (*sdbg != ',') cerr << *sdbg++;
	cerr << " = " << h << ",";
	_dbg(sdbg + 1, t...);
}

#define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define chkpt cerr << "--- Checkpoint here ---\n";

int k,a,b;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>k>>a>>b;
	for(int i=a;i<=b;++i){
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
	}
	cout<<"NG";
    return 0;
}


Measured memory_bytes: 3648
// solv_E.cpp : 
//

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;


ull N, K;


const ull mod = ull(1E9) + 7;

ull my_plus(ull a, ull b) {
    return ((a % mod + b % mod) % mod);
}

ull my_minus(ull a, ull b) {
    ll ans;
    ans = (a % mod - b % mod);

    if (ans < 0) {
        ans += mod;
    }

    return ull(ans);
}


ull my_mult(ull a, ull b) {
    return ((a % mod * b % mod) % mod);
}

ull my_power(ull x, ull n) {
    ull p, ans;
    ull b;
    ull i;

    ans = 1;

    p = x;
    b = n;

    // cout << "--- x=" << x << " n=" << n << endl;

    while (b != 0){
        if (b & 1) {
            ans = my_mult(ans, p);
        }
        b = b >> 1;
        p = my_mult(p, p);

        // cout << b << " p=" << p << " ans=" << ans<< endl;
    }


    return ans;

}


ull result1;
ull counter[100001];

int main()
{
    ull result1, result2, result3;
    ull num_primes, num_coprimes = 0;

    cin >> N >> K;

    ull i, j;

#ifdef CHECK
    ll tmp = 1;
    for (i = 1; i <= N; i++) {
        cout << "K^"<< i << "=" << my_power(K, i) << endl;
        tmp = my_mult(tmp, K);
        cout << "tmp=" << tmp << endl;
    }

    exit(0);
#endif


    ull result12 = 0;
    for (ull k = K; k >= 1; k--) {
        ull p = ull(K / k);

#ifdef ORIG
        result1 = 1;
        for (ll i = 1; i <= N; i++) {
            result1 = my_mult(result1, p);
        }
#endif
        result1 = my_power(p, N);

        // cout << result1 << endl;

        for (ull i = k*2; i <= K; i+=k) {
            // result1 = result1 - counter[i];
            result1 = my_minus(result1, counter[i]);
            // cout << "i=" << i << " counter[i]=" << counter[i] << " result1=" << result1 << endl;
        }

        counter[k] = result1;
        result12 = my_plus(result12, my_mult(counter[k], k));

        //cout << "k=" << k << " counter[k]=" << counter[k] << " result12=" << result12 << endl;
    }

    cout << result12 << endl;
}



Measured memory_bytes: 4360
from sys import stdin
input = stdin.readline

n, q = map(int, input().split())
edges = list(tuple(map(int, input().split())) for _ in range(n-1))
adj = [[] for _ in range(n+1)]
cnt = [0] * n
for u, v in edges:
    adj[u].append(v)
    adj[v].append(u)

def dfs(p, u):
    vis = [0] * n
    stk = [(p, u)]
    while stk:
        p, u = stk[-1]
        stk.pop()
        if vis[u-1]:
            continue
        for v in adj[u]:
            if v != p:
                cnt[v-1] += cnt[u-1]
                stk.append((u, v))

quries = list(tuple(map(int, input().split())) for _ in range(q))
for u, p in quries:
    cnt[u-1] += p
dfs(-1, 1)
print(*cnt)


Measured memory_bytes: 122280
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <set>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

long long mymax(long x, long y){ return x>y? x: y;}

int main(void){
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    printf("%lld\n", mymax(a*c, mymax(a*d, mymax(b*c, b*d))));
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>

using namespace std;

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

	bool f=true;
	int hb=0;
	for(int i=0; i<n; ++i){
		int h;
		cin >> h;
		if(h<hb){
			f=false;
		}else if(hb==h){
			hb=h;
		}else {
			hb=h-1;
		}
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}




Measured memory_bytes: 256
s=input()
t=input()
if len(s)<len(t):
    print("UNRESTORABLE")
else:
    x=[]
    for i in range(len(s)-len(t)+1):
        k=0
        for j in range(len(t)):
            if s[i+j]!=t[j] and s[i+j]!="?":
                k+=1
        if k==0:
            x.append((s[:i]+t+s[(i+len(t)):]).replace("?","a"))
    if len(x)==0:
        print("UNRESTORABLE")
    else:
        x.sort()
        print(x[0])

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)

H,W = map(int,input().split())
grid = [["&"] * (W+2) for i in range(H+2)]
visited = [[False] * (W+2) for i in range(H+2)]
# debug: visited_count = [[0] * (W+2) for i in range(H+2)]
start = []
for i in range(H):
    s = input()
    for j in range(W):
        grid[i+1][j+1] = s[j]

ans = 0
b = 0
w = 0
def dfs(p_i,p_j):
    if visited[p_i][p_j] is True:
        global ans
        return
    visited[p_i][p_j] = True
    if grid[p_i][p_j] == "#":
        # debug: visited_count[p_i][p_j] += 1
        global b
        b += 1
    elif grid[p_i][p_j] == ".":
        # debug: visited_count[p_i][p_j] += 1
        global w
        w += 1
    around = [[p_i,p_j+1],[p_i+1,p_j],[p_i,p_j-1],[p_i-1,p_j]]
    for i,j in around:
        if grid[p_i][p_j] == "#" and grid[i][j] == ".":
            dfs(i,j)
        elif grid[p_i][p_j] == "." and grid[i][j] == "#":
            dfs(i,j)

for i in range(1,H+1):
    for j in range(1,W+1):
        if visited[i][j] is False:
            dfs(i,j)
            ans += b * w
            b = 0
            w = 0

print(ans)

""" debug
print(start)
for line in visited_count:
    print(line)
print("b = {}".format(b))
print("w = {}".format(w)) """

Measured memory_bytes: 232556
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int> 
#define X first
#define Y second
int MOD = 1e9 + 7;

lli mymod (lli A) {
    A %= MOD;
    if (A < 0) A += MOD;
    return A;
}

int main () {
    int n, k;
    cin >> n >> k;
    int a[n];
    fop (i,0,n) cin >> a[i];
    lli dp[n][k+1]; // n people with <= k candies
    dp[0][0] = 1;
    fop (i,1,k+1) {
        if (i <= a[0]) dp[0][i] = dp[0][i-1] + 1;
        else dp[0][i] = dp[0][i-1];
    }
    fop (i,1,n) {
        fop (j,0,k+1) {
            if (j - a[i] - 1 < 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = mymod(dp[i-1][j] - dp[i-1][j-a[i]-1]);
            if (j > 0) dp[i][j] = mymod(dp[i][j-1] + dp[i][j]);
        }
    }
    if (k == 0) cout << dp[n-1][k] << endl;
    else cout << mymod(dp[n-1][k] - dp[n-1][k-1]) << endl;
}

Measured memory_bytes: 78336
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int[] fac;
	boolean[] used;
	int rank(int[] aa, int n) {
		Arrays.fill(used, false);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int k = 0;
			for (int a = 0; a < aa[i]; a++)
				if (!used[a])
					k++;
			sum += fac[n - 1 - i] * k;
			used[aa[i]] = true;
		}
		return sum;
	}
	void main() {
		int n = sc.nextInt();
		int[] pp = new int[n];
		for (int i = 0; i < n; i++)
			pp[i] = sc.nextInt() - 1;
		int[] qq = new int[n];
		for (int i = 0; i < n; i++)
			qq[i] = sc.nextInt() - 1;
		fac = new int[n];
		for (int i = 0, f = 1; i < n; i++) {
			fac[i] = f;
			f *= (i + 1);
		}
		used = new boolean[n];
		println(Math.abs(rank(pp, n) - rank(qq, n)));
	}
}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int r = sc.nextInt();
		final int c = sc.nextInt();
		int[][] table = new int[r + 1][c + 1];
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				int v = sc.nextInt();
				table[i][j] = v;
				table[i][c] += v;
				table[r][j] += v;
				table[r][c] += v;
			}
		}
		sc.close();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i <= r; i++) {
			for (int j = 0; j <= c; j++) {
				sb.append(table[i][j]);
				if (j == c) {
					sb.append("\n");
				} else {
					sb.append(" ");
				}
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 40164
#include "bits/stdc++.h"
using namespace std;
const int maxn = 1024;
int main(){
	int n, k;
	cin >> n >> k;
	vector<long long> a(n);
	for(auto & v : a) cin >> v;
	vector<long long> ways;
	for(int e = 0; e < n; e++){
		long long s = 0;
		for(int f = e; f < n; f++){
			s += a[f];
			ways.push_back(s);
		}
	}
	long long as = 0;
	for(int e = 60; e >= 0; e--){
		int cnt = 0;
		for(auto & v : ways) if(v&(1ll<<e)) cnt++;
		if(cnt >= k){
			vector<long long> nxt;
			for(auto & v : ways) if(v&(1ll<<e)) nxt.push_back(v);
			as |= 1ll<<e;
			ways = nxt;
		}
	}
	cout << as << endl;
	return 0;
}


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

using namespace std;



int main(){
    int a, b;
    cin >> a >> b;
    string s1, s2;
    for(int i = 0; i < b; i++) s1 += (a+48);
    for(int i = 0; i < a; i++) s2 += (b+48);
    if(s1 > s2) cout << s2 << endl;
    else cout << s1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  string a,b,c;
  cin >> a >> b >> c;
  if (a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
  {
    cout << "YES" << endl;
  }else
  {
    cout << "NO" << 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 a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3576
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
print('Yes' if s[2]==s[3] and s[4]==s[5] else 'No')

Measured memory_bytes: 3060
#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 a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans;
    while(1) {
        c -= b;
        if(c <= 0) {
            ans = "Yes"; break;
        }
        a -= d;
        if(a <= 0) {
            ans = "No"; break;
        }
    }
    cout << ans << "\n";
} 

Measured memory_bytes: 3584
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int flag=0;
	for(int i=1;i<=10000;i++){
		if((int)(i*0.08)==a&&(int)(i*0.1)==b){
			cout<<i<<endl;
			flag=1;
			break;
		}
	}
	if(flag==0)cout<<-1<<endl;
}

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

int main(){
	int d[32] = {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 << d[k-1] << endl;
    return 0;
}



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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main(void) {
  int chars[(int)'z' + 1]={0};

  char ch;
  while(cin >> ch) {
    ch = tolower(ch);
    if('a' <= ch <= 'z') chars[(int)ch]++;
  }

  for(int i='a'; i <= 'z'; i++) cout << (char)i << " : " << chars[i] << endl;
}



Measured memory_bytes: 3088
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        ball = N - r * R - g * G
        check = (ball / B)
        if check.is_integer() and check >= 0:
            ans += 1
print(ans)

Measured memory_bytes: 40812
#include "bits/stdc++.h"
using namespace std;
 
int main() {
  int N,ans=0;
  vector<int> A(N),B(N-1);
  cin >> N;
  for(int i=0;i<N-1;i++) cin >> B.at(i);
  
  A.at(0)=B.at(0);
  ans+=A.at(0);
  for(int i=1;i<N-1;i++) {
    A.at(i)=min(B.at(i-1),B.at(i));
    ans+=A.at(i);
  }
  A.at(N-1)=B.at(N-2);
  ans+=A.at(N-1);
  
  cout << ans << endl;
  return 0;
}


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

int main(){
	string s;
  	cin >> s;
  	int t=s.size();
  	if (t%2==0) t--;
  	for (int i=t-1;i>0;i-=2){
    if (s.substr(0,(i/2))==s.substr((i/2),(i/2))) {
      	cout << i << endl;
      	break;}
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    int total = 0;
    rep(i,n){ 
        cin >> l[i];
        total += l[i];
    }

    rep(i,n){
        if(total - l[i] <= l[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

inline void Main() {
  // code
  string s;
  cin >> s;

  int res[(int)1e5] = {0};

  int r = 0;
  rep(i, s.size()) {
    if(s.at(i) == 'L') {
      if(r % 2 == 0) {
        res[i-1] += r / 2;
        res[i] += r / 2;
      } else {
        res[i-1] += r / 2 + 1;
        res[i] += r / 2;
      }
      r = 0;
    } else {
      r++;
    }
  }

  int l = 0;
  for (int i = s.size()-1; i >= 0; i--) {
    if(s.at(i) == 'R') {
      if(l % 2 == 0) {
        res[i] += l / 2;
        res[i+1] += l / 2;
      } else {
        res[i] += l / 2;
        res[i+1] += l / 2 + 1;
      }
      l = 0;
    } else {
      l++;
    }
  }

  rep(i, s.size()) {
    if(i != 0) cout << ' ';
    cout << res[i];
  }
  cout << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 1104
n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0

for p in range(k, n+2):
    minimum = p * (p-1) // 2  # 0〜(p-1)の和
    maximum = p * (2*n - p + 1) // 2  # (n-p+1)〜nの和
    ans += maximum - minimum + 1
    ans %= mod

print(ans)


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


int main(void){
    string O,E;
    cin >> O >> E;
    string ans="";

    for(int i=0; i<E.size(); i++){
        ans+=O[i];
        ans+=E[i];
    }

    if(O.size()!=E.size()) ans+=O[O.size()-1];

    cout << ans << endl;

    return 0;
}

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

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

	int ans = 0;

	for (int i = 0; i < s.size(); i++) 	{	
		if (s.at(i) == t.at(i)) ans++;	
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  int n,k;
  int a[1000000];

  for(;;){
    scanf("%d %d",&n,&k);
    if(!n && !k)break;

    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int sum = 0;
    for(int i=0;i<k;i++)sum += a[i];
    int m = sum;
    for(int i=k;i<n;i++){
      sum += a[i] - a[i-k];
      m = max(m,sum);
    }
    printf("%d\n",m);
  }
}

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

int main()
{
int n;
cin>>n;
map<string,set<pair<int,int>>>m;
for( int i=1;i<=n;i++)
{
	string s;
	int a;
	cin>>s>>a;
	m[s].insert({(a*-1),i});
}	
for(auto it : m)
{
	//cout<<(it.first);
	for(auto v: it.second)
		cout<<v.second<<endl;
}
}

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


void solve(long long N, const string& S){
    vector<ll> d(N);
    REP(i, N){
        d.at(i) = S.at(i) - '0';
    }
    reverse(d.begin(), d.end());

    set<ll> s1, s2, s3;
    for(auto x : d){
        for(auto y : s2){
            s3.insert(y * 10 + x);
        }
        for(auto y : s1){
            s2.insert(y * 10 + x);
        }
        s1.insert(x);
    }
    cout << s3.size() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
def factorize(n):
    res = []
    i = 2
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        if cnt > 0:
            res.append([i, cnt])
        i += 1
    if n != 1:
        res.append([n, 1])
    return res

n = int(input())
nlist = factorize(n)
ans = 0
for j in range(0, len(nlist)):
    sum_ = 1
    i = 2
    while nlist[j][1] >= sum_:
        sum_ += i
        i += 1
    ans += i-2
print(ans)

Measured memory_bytes: 62936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  vector<long long> A;
  cin >> N;
  for(int n=0;n<N;n++){
    long long k;
    cin >> k;
    A.push_back(k-n);
  }
  sort(A.begin(),A.end());
  int b=N/2;
     b=A[b];
  if(N%2==1){
    unsigned long long sum=0;
   for(int n=0;n<N;n++){
   	sum+=abs(A[n]-b);
   }
    cout << sum <<endl;
  }else{
    unsigned long long sum=0;
   for(int n=0;n<N;n++){
   	sum+=abs(A[n]-b);
   }
   unsigned long long min=0;
   b=N/2+1;
   b=A[b];
   for(int n=0;n<N;n++){
   	min+=abs(A[n]-b);
   }
   if(min<sum){
   	cout << min <<endl;
   }else{
   	cout << sum <<endl;
   }
  }
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
    string s;
    cin>>s;
string a;
for (int i = 0; i < s.size(); i++)
{
   char c=s.at(i);
   if (c=='B'&&a.size()>0)
   {
       a.pop_back();
   }
   else if(c!='B'){
       a+=c;
   }
}
cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 5010
using namespace std;
ll n,k,p[N],c[N];
bool vis[N];
ll mxsum(vector<ll> x,ll ed,ll tp)
{
	ll i,mx=0;
	if(tp==0)
	{
		mx=-LINF;
	}
	for(i=0;i<ed;i++)
	{
		mx=max(mx,x[i]);
	}
	return mx;
}
ll fdmax(ll st)
{
	ll i,sc=0,mx=-LINF;
	vector<ll> sum;
	memset(vis,false,sizeof(vis));
	for(i=st;!vis[i];)
	{
		vis[i]=true;
		sc+=c[p[i]];
		sum.push_back(sc);
		mx=max(mx,sc);
		i=p[i];
	}
	if(k<sum.size())
	{
		return mxsum(sum,k,0);
	}
	return max((ll)mx,(ll)sc*((k-1)/(ll)sum.size())+(ll)mxsum(sum,(k-1)%(ll)sum.size()+1,(k-1)/(ll)sum.size()));
}
int main(){
	ll i,ans=-LINF;
	scanf("%lld%lld",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&p[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&c[i]);
	}
	for(i=1;i<=n;i++)
	{
		ans=max(ans,fdmax(i));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3968
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=2010,MOD=1e9+7;

int a[N];

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

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int x=0,y=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]>a[j])
                x++;
            if(a[i]!=a[j])
                y++;
        }
    cout<<(k*x+k*(k-1)/2%MOD*y)%MOD;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int tmp = a;
        int answ = 0;
        for(int i =0;i<String.valueOf(a).length();i++){
            answ += tmp%10;
            tmp /= 10;
        }
        if(a%answ == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;

/*
        @@@@@@           @@@@@@
      @@@@@@@@@@       @@@@@@@@@@ 
    @@@@@@@@@@@@@@   @@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      @@@@@@@@@@@@@@@@@@@@@@@@@@@
        @@@@@@@@@@@@@@@@@@@@@@@
          @@@@@@@@@@@@@@@@@@@
            @@@@@@@@@@@@@@@
              @@@@@@@@@@@
                @@@@@@@
                  @@@
                   @ 
*/
public class Main {
	public static void main(String[] args) throws Exception{
		int k = i(); int x = i();
		for (int i=x-k+1; i<x+k; i++) {
			if (i==x+k-1) System.out.println(i);
			else System.out.print(i + " ");
		}
	}
	
	static BufferedReader in;
	static StringTokenizer st = new StringTokenizer("");
	//static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static PrintWriter out;
	static {
		try {
			in = Files.newBufferedReader(Paths.get("TEMPLATE.in"));
			out = new PrintWriter(new BufferedWriter(new FileWriter("TEMPLATE.out")));
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		}
	}
	/*static {
		in = new BufferedReader(new InputStreamReader(System.in));
	}*/
	static void check() throws Exception {
		while (!st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
	}
	static String s() throws Exception { check(); return st.nextToken(); }
	static int i() throws Exception { return Integer.parseInt(s()); }
	static long l() throws Exception { return Long.parseLong(s()); }
	static double d() throws Exception { return Double.parseDouble(s()); }
}


Measured memory_bytes: 21328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int ans;
    int cmp = (n/100)*100+(n/100)*10+(n/100);
    if(n<=cmp){
        cout<<cmp<<endl;
    }
    else{
        cout<<cmp+111<<endl;
    }
}

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

using namespace std;

int main() {
        string T, S;
        cin >> S >> T;
        int ls = S.size();
        int lt = T.size();
        int m = INT_MAX;
        for(int i = 0; i < ls - lt + 1; i++) {
                int res = 0;
                for(int j = 0; j < lt; j++) {
                        if(T[j] != S[i+j]) res ++;
                }
                m = min(m, res);
        }
        cout << m << endl;
}


Measured memory_bytes: 3616
/*  -*- coding: utf-8 -*-
 *
 * 1583.cc: Equivalent Vertices
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 3000;
const int MAX_GN = MAX_N * (MAX_N + 1) / 2;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

int vs[MAX_N], nbrs[MAX_N][2], cs[MAX_N];
vi gnbrs[MAX_GN];
int pids[MAX_N][MAX_N], pis[MAX_GN], pjs[MAX_GN];
bool ds[MAX_GN];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < n; i++)
    scanf("%d%d%d", vs + i, nbrs[i], nbrs[i] + 1);

  memset(pids, -1, sizeof(pids));
  for (int i = 0, p = 0; i < n; i++)
    for (int j = i; j < n; j++, p++)
      pids[i][j] = p, pis[p] = i, pjs[p] = j;

  qi q;
  for (int i = 0, p = 0; i < n; i++)
    for (int j = i; j < n; j++, p++) {
      for (int di = 0; di < 2; di++) {
	int ri = nbrs[i][di], rj = nbrs[j][di];
	if (ri > rj) swap(ri, rj);
	gnbrs[pids[ri][rj]].push_back(p);
      }
      if (vs[i] != vs[j]) {
	ds[p] = true;
	q.push(p);
      }
    }

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int ui = pis[u], uj = pjs[u];
    vi &gnbru = gnbrs[u];

    for (vi::iterator vit = gnbru.begin(); vit != gnbru.end(); vit++) {
      int &v = *vit;
      if (! ds[v]) {
	ds[v] = true;
	q.push(v);
      }
    }
  }

  for (int i = 0, p = 0; i < n; i++)
    for (int j = i; j < n; j++, p++)
      if (! ds[p]) cs[i]++, cs[j]++;

  while (m--) {
    int q;
    scanf("%d", &q);
    printf("%d\n", cs[q] - 1);
  }
  return 0;
}



Measured memory_bytes: 341132
#include "bits/stdc++.h"

using namespace std;

int main()
{

  int N;
  cin >> N;
  vector<int> A(N+1);

  for (int i = 1; i < N + 1; ++i) {
    cin >> A[i];
  }

  vector<int> B(N + 1);
  for (int i = N; i > 0; --i) {
    int cnt = 0;
    for (int j = 2*i; j <= N; j += i) {
      cnt += B[j];
    }
    if (cnt % 2 == A[i]) {
      B[i] = 0;

    }
    else {
      B[i] = 1;
    }
  }
  
  int sum = 0;
  for (int i = 1; i < B.size(); ++i) {
    sum += B[i];
  }
  cout << sum << endl;
  for (int i = 1; i < B.size(); ++i) {
    if (B[i] != 0) {
      cout << i << " ";
    }
  }
  return 0;
}


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

int main(void) {
	
	int N, M, X;
	cin >> N >> M >> X;
	int c1=0,c2=0;

	for(int i=0; i<M; i++) {
		int A;
		cin >> A;
		if(A < X) {
			c1++;
		} else {
			c2++;
		}
	}
	
	cout << (c1 < c2 ? c1 : c2);

	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	VI d(n), e(n);
	rep(i, n) cin >>d[i] >>e[i];
	
	int c=0, ok=0;
	rep(i, n){
		if(d[i]==e[i]) c++;
		else c=0;
		if(c>=3) ok=1;
	}
	puts(ok? "Yes":"No");
	return 0;
}



Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, x, ix, jx, kx, count[], m;
        count = new int[100000];

        m = 0;
        while(true){

            count[m]=0;
            n = sc.nextInt();
            x = sc.nextInt();

            if(n == 0 && x == 0){break;}

            for(i=1;i<=n;i++){
                ix = x;
                ix -= i;

                for(j=i;j<=n;j++){ //jはiから始まる
                    jx = ix;
                    jx -= j;
                    if(j == i){continue;}

                    for(k=j;k<=n;k++){ //kはjから始まる
                        kx = jx;
                        kx -= k;
                        if(k==j){continue;}
                        if(k==i){continue;}

                        if(i + j + k == x){
                            count[m]++;
                        }
                    }
                }
            }
            m++;
        }

        for(i=0;i<m;i++){
            System.out.println(count[i]);
        }
    }
}



Measured memory_bytes: 27540
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <numeric>
#include <sstream>

using namespace std;

string itos(int n) {
    ostringstream s;
    s << n;
    return s.str();
}


int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int n;
        cin >> n;
        set<int> s;
        bool flag = false;
        int cnt = 0;
        while(true) {
     
            string n_str;
            n_str = itos(n);
            if (n < 10) break;
            if (s.find(n) != s.end()) {
                flag = true;
                break;
            }
            s.insert(n);

            
            // cout << "l:" << l << endl;
            int max_v = 0;
            for (int j = 1; j < n_str.length(); j++) {
                int head = 0, tail = 0;
                head = stoi(n_str.substr(0, j));
                tail = stoi(n_str.substr(j));
                // cout << head << " " << tail << endl;
                max_v = max(max_v, head * tail);
            }
            // cout << "max: " << max_v << endl;
            n = max_v;
            cnt++;
        }

        if (flag) {
            cout << -1 << endl;
        } else {
            cout << cnt << endl;
        }
    }

}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	int l=s.size();
	int ok=0,p;
	for(int i=0;i<l;i++){
		if(s[i]=='C'){
			ok=1,p=i;
			break;
		}
	}
	if(ok==0){
		printf("No\n");
		return 0;
	}
	ok=0;
	for(int i=p;i<=l;i++){
		if(s[i]=='F'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    int d[50];
  
    scanf("%d", &N);
  
    for(int i = 0;i < N; i++) {
       scanf("%d", &d[i]);
    }
  
    int sum = 0;
    
    for(int i = 1; i < N; i++) {
       for(int j = 0; j < i; j++) {
          sum += d[j] * d[i];
       }
    }
  
    printf("%d\n", sum);
  
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
int a[33]={0,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};
inline void solve()
{
	int n;cin>>n;
	cout<<a[n]<<endl;

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




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int A, B, C, D;
long long dptable[3001][3001];
const long long mod = 998244353;
long long dp(int i, int j) {
	if (i == A && j == B) return 1;
	if (dptable[i][j] != 0) return dptable[i][j];
	if (i == A) return dptable[i][j] = i * dp(i, j - 1) % mod;
	if (j == B) return dptable[i][j] = j * dp(i - 1, j) % mod;
	return dptable[i][j] = (i * dp(i, j - 1) + j * dp(i - 1, j) - (i - 1) * (j - 1) * dp(i - 1, j - 1)) % mod;
}
int main() {
	scanf("%d %d %d %d", &A, &B, &C, &D);
	printf("%lld", (dp(C, D) + mod) % mod);
	return 0;
}

Measured memory_bytes: 72528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  ll r=n%10;
  if(r==2||r==4||r==5||r==7||r==9)
    cout<<"hon";
  else if(r==1||r==0||r==6||r==8)
    cout<<"pon";
  else if(r==3)
    cout<<"bon";
  
	
  	
	return 0;
}


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

void buy(long long price){
  s+=m/price;
  m-=price*s;
  //cout<<"buy s:"<<s<<"m"<<m<<endl;
}

void sell(long long price){
  m+=s*price;
  s=0;
  //cout<<"sell s:"<<s<<"m"<<m<<endl;
}

int main(){
  cin>>n;
  vector<long long> x,p;
  long long i=0,a,b;cin>>a;x.emplace_back(a);

  while(i<n-1){
    cin>>b;
    if(a!=b) x.emplace_back(b);
    if(a<b) p.emplace_back(1);
    else if(a>b)p.emplace_back(-1);
    a=b;
    i++;
  }

  //REP(i,x.size()) cout<<x.at(i)<<" ";
  //REP(i,p.size()) cout<<p.at(i)<<" ";

  i=0;
  while(i<x.size()-1){
    while(i<x.size()-1&&p.at(i)==-1) i++;
    if(i!=x.size()-1) buy(x.at(i));
    while(i<x.size()-1&&p.at(i)==1) i++;
    sell(x.at(i));
    //cout<<i<<" "<<m<<" "<<s<<" "<<endl;
  }

  cout<<m;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  ll a,b;
  cin>>n>>a>>b;
  ll z=modpow(2,n,1000000007);
  vec inv(200001);
  loop(i,200001)inv[i]=modinv(i,1000000007);
  ll x=1,y=1;
  loop(i,a){
    ll t=i+1;
    x*=inv[t];
    x%=1000000007;
    x*=n-i;
    x%=1000000007;
  }
  loop(i,b){
    ll t=i+1;
    y*=inv[t];
    y%=1000000007;
    y*=n-i;
    y%=1000000007;
  }
  z-=x+y;
  while(z<0){
    z+=1e9+7;
  }
  putout(z-1);
}

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

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
	int n, q;
    ll k;
    cin >> n >> k >> q;
    vector<ll> p(n, 0);
    
    /*for(int i = 0; i < q; i++){
        int a;
        cin >> a;
        rep(j, n){
            p[j]--;
        }
        p[a-1]++;
    }*/

    rep(i, q){
        int a;
        cin >> a;
        p[a-1]++;
    }

    rep(i, n){
        if(k - (q - p[i]) > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1536
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            if [nh,nw]==[H-1,W-1]:
                return min_dist[qh][qw]+1
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
    else:
        return -1
min_dist = bfs()
print(H*W-black_count-min_dist if min_dist!=-1 else -1)


Measured memory_bytes: 3316