akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#define int long long
using std::__gcd;
int n,prime[10100000],a[510][510],len;
bool isPrime[10001000];
int lcm(int a,int b){
	return a/__gcd(a,b)*b;
}
signed main(){
	scanf("%lld",&n);
	if(n==2){
		puts("4 7\n23 10");
		return 0;
	} 
	for(int i=2;i<=1000000;i++)
		isPrime[i]=true;
	for(int i=2;i<=10000;i++){
		if(!isPrime[i])continue;
		for(int j=i*2;j<=1000000;j+=i)
			isPrime[j]=false;
	}
	for(int i=2;i<=1000000;i++)
		if(isPrime[i])prime[++len]=i;
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			a[i][j]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if((i+j)%2==1)continue;
			int x=(i+j)/2,y=(i+n*3-j+1)/2;
			a[i][j]=prime[x]*prime[y];
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if((i+j)%2==0)continue;
			if(i==1&&j==n)a[i][j]=lcm(a[i+1][j],a[i][j-1]);
			else if(i==n&&j==1)a[i][j]=lcm(a[i-1][j],a[i][j+1]);
			else if(i==1||i==n)a[i][j]=a[i][j-1]*a[i][j+1]; 
			else a[i][j]=a[i-1][j]*a[i+1][j];
			a[i][j]++; 
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			printf("%lld",a[i][j]);
			if(j==n)puts("");
			else putchar(' ');
		}
}

Measured memory_bytes: 10240
N = int(input())
A = [int(x) for x in input().split()]
maxA, minA = max(A), min(A)
if maxA >= abs(minA):
    OP = [(A.index(maxA)+1, i+1) for i in range(N)] + [(i, i+1) for i in range(1,N)]
else:
    OP = [(A.index(minA)+1, i+1) for i in range(N)] + [(i+1, i) for i in reversed(range(1,N))]
print(len(OP))
for op in OP: print(*op)       

Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String s = (new Main()).run();
		System.out.println(s);
	}

	public String run() {

		Entity e = input();
		int a = e.getA();
		int b = e.getB();
		int c = e.getC();

		int eaten = 0;
		while (true) {

			// eatc
			if (c > 0) {
				c--;
				eaten++;
			} else {
				break;
			}

			if (b > 0) {
				b--;
				eaten++;

				continue;
			}

			if (a > 0) {
				a--;
				continue;
			}

			if (a == 0 && b == 0) {
				break;
			}

		}

		// eaten += c;
		eaten += b;

		return "" + eaten;

	}

	private Entity input() {

		Scanner scan = new Scanner(System.in);
		String tmp = scan.nextLine();

		scan.close();

		String[] tmps = tmp.split("\\s");
		int[] a = new int[tmps.length];

		for (int i = 0; i < tmps.length; i++) {
			a[i] = Integer.parseInt(tmps[i]);
		}

		Entity e = new Entity();
		e.setA(a[0]);
		e.setB(a[1]);
		e.setC(a[2]);

		return e;

	}

	private class Entity {

		int a = -1;
		int b = -1;
		int c = -1;

		public int getA() {
			return a;
		}

		public void setA(int a) {
			this.a = a;
		}

		public int getB() {
			return b;
		}

		public void setB(int b) {
			this.b = b;
		}

		public int getC() {
			return c;
		}

		public void setC(int c) {
			this.c = c;
		}

	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int GetDigit(int num)
{
	int i = 0;
	for (; num != 0; num /= 10, ++i) {

	}
	return i;
}

int main()
{
	long long N = 0;
	cin >> N;

	if (N == 1) {
		cout << 1;
		return 0;
	}

	long long r = sqrt(N) + 1; 
	// cout << sqrt(N) << ", r = " << r << endl;


	
	int minDigitNum = 1000;
	for (long long i = 1; i < r; ++i) { // ★ 1の場合の検討
		if (N % i) {
			continue;
		}
		int s1 = N / i;
		int d1 = GetDigit(i);
		int d2 = GetDigit(s1);
		// cout << i << "," << d1 << "," << s1 << "," << d2 << endl;
		minDigitNum = min(minDigitNum, max(d1, d2));
	}

	cout << minDigitNum << endl;

	return 0;
}

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

int main()
{
  int a, b;
  char op;
  cin >> a >> op >> b;

  if (op == '+') cout << a + b << endl;
  else if (op == '-') cout << a  - b << endl;

}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

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

  ll n = S.length();
  map<int ,ll> mp;
  ll fac = 1;
  ll cur = 0;
  mp[cur]++;
  rep(i, n){
    ll add = S[n - 1 - i] - '0';
    cur = (cur + fac * add) % 2019;
    fac = (fac * 10) % 2019;
    mp[cur]++;
  }
  ll ans = 0;
  rep(i, 2019){
    ans += mp[i] * (mp[i] - 1) / 2;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3764
//#pragma GCC optimize("-O2")
#include<bits/stdc++.h>
//#define getchar nc
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define sight(c) ('0'<=c&&c<='9')
#define swap(a,b) a^=b,b^=a,a^=b
#define LL long long
#define deg printf
#define dput put
#define dputc putchar
#define db double 
#define eho(x) for(int i=head[x];i;i=net[i])
inline char nc(){
static char buf[1000000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline void read(int &x){
    static char c;
    for (c=getchar();!sight(c);c=getchar());
    for (x=0;sight(c);c=getchar())x=x*10+c-48;
}
void write(int x){if (x<10) {putchar('0'+x); return;} write(x/10); putchar('0'+x%10);}
inline void writeln(int x){ if (x<0) putchar('-'),x*=-1; write(x); putchar('\n'); }
inline void writel(int x){ if (x<0) putchar('-'),x*=-1; write(x); putchar(' '); }
using namespace std;
bitset<4210007> X;
int n,tog,x,s;
signed main() {
	read(n);
	X.set(0);
	for (int i=1;i<=n;i++) read(x),X|=X<<x,s+=x;
	tog=s/2+(s&1?1:0);
	for (;!X[tog];tog++);
	writeln(tog);
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	if (s[1] == 'R')
	{
	cout << "ABC" << "\n";
	} else {
	cout << "ARC" << "\n";

	}



	return 0;
}


Measured memory_bytes: 3628
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    C = B - A
    D = A + (N - B + 1)
    print(min((C-1)//2 + A, (N-D)//2 + (N - B + 1))) 

Measured memory_bytes: 3060
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
 
using namespace std;
 
int main(){
  int n,q,A[3000],M[3000];
  int dp[3000];
 
  cin >> n;
  rep(i,n)cin >> A[i];
  cin >> q;
  rep(h,q){
    cin >> M[h];
    rep(i,M[h]+1)dp[i]=-1;
    dp[0] = 0;
    rep(i,n){
      for(int j=0;j<=M[h];j++){//0からM[h](確かめたい値)まで１つずつ増やして作れるか確かめていく
	if(dp[j] >= 0){//もし0 or 1ならばその値は作れているので１をいれる
	  dp[j] = 1;
	}
	else if(dp[j-A[i]] <= 0 || j<A[i]){//今の値の場所からA[i]（与えられた値）を引いたところが０orマイナスならもう既に使っているかもとよりつくれないのでスルー　jがA[i]より小さいのであれば作れないので明らかなのでスルー
	  dp[j]=-1;
	}else{//以上の条件を満たしていないなら作れるので配列DPにいれる　マイナス１しているのは使った値をまた使わないため
	  dp[j] = dp[j-A[i]]-1;
	}
	//  cout << dp[j] << endl;
      }
    }
    if(dp[M[h]] >= 0)cout << "yes" << endl;
    else cout << "no" << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 0
import math

N, K = (int(x) for x in input().split())
ans = 0
for i in range(1, N+1):
    if i >= K:
        n = 0
    else:
        n = math.ceil(math.log2(K/i))
    ans += (1/N)*(1/(2**n))

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int j=min(A,B);
  int i=0;
  while(i<K){
    if(A%j==0&&B%j==0){
      i++;
    }
    j--;
  }
  cout << j+1 << endl;
  return 0;
}


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

using namespace std;

#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x; cin>>x;
    int ans=0;
    ll cnt=1;
    while(cnt*cnt<x){
        int syo=x/cnt;
        if(x%cnt==0)syo--;
        ans+=2*(syo-cnt+1)-1;
        cnt++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
n,m = map(int,input().split())
L = list(map(int,input().split()))
li = []
for i in range(len(L)):
    li.append(L[i] >=sum(L)/(4*m) )
cnt = 0
for i in range(len(li)):
     if sum(li)>=m:
         cnt +=1
if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int main(){
	int N;
	cin >> N;
	int H[100000];
	for(int i=0; i<N; i++) cin >> H[i];

	for(int i=N-2; i>=0; i--){
		if(H[i] > H[i+1]){
			H[i]--;
		}
		if(H[i] > H[i+1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
int main(){
  ll N;cin>>N;
  vll A(N),B(N);rep(i,N)cin>>A[i]>>B[i];
  sort(all(A));sort(all(B));
  ll ans;
  if(N%2==1){
    ll cut = (N-1)/2;
    ll left = A[cut];
    ll right = B[cut];
    ans = right - left + 1;    
  }
  else{
    //to cut+1
    ll cut = N/2-1;
    ll a = A[cut]+A[cut+1];
    ll b = B[cut]+B[cut+1];
    ll left = a/2;
    ll right = b/2;
    if(a%2==1 && b%2==1){
      ans = right - left + 1 + right - left;
    }
    else if(a%2==1){
      ans = 2 * (right - left);
    }
    else if(b%2==1){
      ans = 2 * (right - left + 1);
    }
    else ans = right - left + right - left + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6268
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
//#define MAX ((ull)1e9)
#define MAX ((int)1e5)

int main(){
	int oc[MAX+1], ec[MAX+1];
	for(int i=0; i<MAX+1; i++){
		oc[i]=0; ec[i]=0;
	}

	int n;
	cin >> n;
	int m=n/2;
	int oc1=0, oc2=0, ec1=0, ec2=0;
	for(int i=0; i<m; i++){
		int ov, ev;
		cin >> ov >> ev;
		oc[ov]++; ec[ev]++;
		if(oc[oc1]<oc[ov]) oc1=ov;
		if(ec[ec1]<ec[ev]) ec1=ev;
	}
	for(int i=0; i<MAX+1; i++){
		if(oc[oc2]<oc[i] && i!=oc1) oc2=i;
		if(ec[ec2]<ec[i] && i!=ec1) ec2=i;
	}

	int ans=n-oc[oc1]-ec[ec1];
	if(oc1==ec1){
		if(oc[oc1]>ec[ec1]) ans=n-oc[oc1]-ec[ec2];
		else if(oc[oc1]<ec[ec1]) ans=n-oc[oc2]-ec[ec1];
		else{
			ans=min(n-oc[oc1]-ec[ec2], n-oc[oc2]-ec[ec1]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int h,w;
cin>>h>>w;
vector<vector<char>> canvas(h+2,vector<char>(w+2,'#'));
reps(i,h+1,1){
    reps(j,w+1,1){
        cin>>canvas[i][j];
    }
}
rep(i,h+2){
    rep(j,w+2){
        cout<<canvas[i][j];
    }
    cout<<endl;
}
return 0;
}

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

bool used[4][4];
int rel_x[4], rel_y[4];

int patnum(int depth, int x, int y) {
	if (depth == 0) return 1;

	while (used[y][x]) {
		x++;
		if (x == 4)
			x = 0, y++;
	}

	int ret = 0;
	for (int i = 0; i < 4; i++) {
		int xx = x+rel_x[i], yy = y+rel_y[i];
		if (xx < 0 || xx >= 4 || yy >= 4 || used[yy][xx])
			continue;
		used[yy][xx] = true;
		int x1 = x+1, y1 = y;
		if (x1 == 4)
			x1 = 0, y1++;
		ret += patnum(depth-1, x1, y1);
		used[yy][xx] = false;
	}
	return ret;
}

int main() {
	while (cin >> rel_x[0], rel_x[0] <= 4) {
		cin >> rel_y[0] >> rel_x[1] >> rel_y[1]
			>> rel_x[2] >> rel_y[2] >> rel_x[3] >> rel_y[3];
		for (int y = 0; y < 4; y++)
			for (int x = 0; x < 4; x++)
				used[y][x] = false;
		cout << patnum(8, 0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		String str = s.nextLine();
		String[] l = str.split(" ");
		int N = Integer.parseInt(l[0]);
		double H = Double.parseDouble(l[1]);
		double W = Double.parseDouble(l[2]);
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			str = s.nextLine();
			l = str.split(" ");
			double a = Double.parseDouble(l[0]);
			double b = Double.parseDouble(l[1]);
			if (a >= H && b >= W)
				cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 27732
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str  = sc.nextLine();
        int n = Integer.parseInt(str);
        sc.close();
        int flag =0;
        for(int i=1;i<=n;i++){
            flag += check(Integer.toString(i));
        }
        System.out.println(flag);
    }

    public static int check(String a){
        String[] tmp = a.split("");
        if(tmp.length %2 == 0){
            return  0;
        }
        else{
            return 1;
        }
    }
}

Measured memory_bytes: 61524
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a <= x && a + b > x) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools

nums = [int(e) for e in input().split()]

list0 = []
for i in range(0,nums[2]):
    list1 = [int(e) for e in input().split()]
    list0.append(list1)

A = []
A0 = list(range(1,nums[1]+1))
for x in itertools.combinations_with_replacement(A0,nums[0]):
    A1 = list(x)
    A1.sort()
    A.append(A1)

d = []
for i in range(0,len(A)):
    d0 = 0
    for j in range(0,nums[2]):
        if A[i][list0[j][1]-1] - A[i][list0[j][0]-1] == list0[j][2]:
            d0 = d0 + list0[j][3]
    d.append(d0)

print(max(d))

Measured memory_bytes: 26616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

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

    vector<string> s(n);

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

    sort(s.begin(), s.end());  

    for(int i = 0; i < n; ++i) {
        cout << s[i];
    } 
    cout << endl;
}

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

int a[1000000], n;

int binarySearch(int k) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (a[mid] == k) return 1;
		else if (a[mid] > k) right = mid;
		else left = mid + 1;
	}
	return 0;
}

int main() {
	int i, q, k, sum = 0;
	cin >> n;
	rep(i, n) cin >> a[i];

	cin >> q;
	rep(i, q) {
		cin >> k;
		if (binarySearch(k)) sum++;
	}
	cout << sum << endl;
	return 0;

}


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

int main(){
vector<int> A(5),B(5);
 int sum=0;
  for(int i=0; i<5;i++){
    cin >> A.at(i);
    B.at(i)=10-A.at(i)%10;
    if(B.at(i)==10){B.at(i)=0;
                  }
    sum+=A.at(i)+B.at(i);
  }
  sort(B.begin(),B.end());
  cout << sum-B.at(4) << endl;}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		int x = 0;
		int y = 0;
		int z = 0;
		for(int i = 0; i < n; i++){
		    x = y;
		    y = z;
		    z = sc.nextInt();
		    if(i > 1){
		        if(x < y && y < z) result++;
		        if(x > y && y > z) result++;
		    }
		}
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 23764
import sys
import numpy as np

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    X = int(readline())
    A = range(1, 201)
    B = range(-201, 201)
    for a in A:
        for b in B:
            tmp = pow(a, 5) - pow(b, 5)
            if X == tmp:
                print(a, b)
                return


if __name__ == "__main__":
    main()




Measured memory_bytes: 27160
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

N, M = get_int_line()
X = get_int_line()

if (M <= N):
  print(0)
  exit(0)

X.sort()
x_dist = []
for i in range(M - 1):
  x_dist.append(X[i + 1] - X[i])
x_dist.sort()

sub = 0
for i in range(N - 1):
  sub += x_dist[-(i + 1)]

print(sum(x_dist) - sub)

Measured memory_bytes: 13696
n = int(input())
a = list(map(int,input().split()))

# 移動先xi
# p[i] = a[i]*|i-xi|
# if i > xi:ans = sum(p[i]) = sum(a[i]*(i-xi)) -> a[i]の大きい順にxiを小さくする
# if i < xi:ans = sum(p[i]) = sum(a[i]*(xi-i)) -> a[i]の小さい順にxiを小さくする
# dp[i][j]:i人がi-xi（左にいく）,j人がxi-i（右にいく）で計算（i*xi = j*xi)

A=[]
for i in range(n):
    A.append((a[i],i))
A.sort(key = lambda x:x[0], reverse=True)
dp = [[-float("inf")]*(n+1) for i in range(n+1)]
dp[0][0] = 0

for i in range(n):
    a,w = A[i]
    for x in range(n+1):
        y = i-x+1
        if x>0:
            dp[i+1][x]=max(dp[i+1][x],dp[i][x-1]+a*abs(w-(x-1)))
        if y>=0:
            dp[i+1][x]=max(dp[i+1][x],dp[i][x]+a*abs(w-(n-y)))

print(max(dp[n]))

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

/**
 * @brief プログラムのエントリーポイントです
 * 
 * @return int 終了後、0を返却しなければなりません。
 */
int main()
{
    // 入力
    int N;
    string S, T;
    cin >> N >> S >> T;

    string answer;

    for(int i = 0; i < N ; ++i)
    {
      	// cerr << S[i] << "," << T[i] << endl;
        answer = answer + S[i] + T[i];
    }

    // 出力
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

A,B,C,X,Y = map(int, input().split())

ans = min(X,Y)*min(A+B, 2*C)
if X > Y:
    ans += (X-Y)*min(A, 2*C)
else:
    ans += (Y-X)*min(B, 2*C)

print(ans)

Measured memory_bytes: 12072
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<string,int> p;
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
        string s;
        cin>>s;
        p[s]++;
    }
    cout<<sz(p)<<endl;
    
    return 0;
}

Measured memory_bytes: 19196
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        
        Scanner sc = new Scanner(System.in);

        long x = sc.nextInt();

        long memx=0;
        long memy=0;
        for(long i=1; i<=200; i++){
            boolean flag = false;
            for(long j= -200; j<=200; j++){
                if(i*i*i*i*i - j*j*j*j*j == x){
                    memx = i;
                    memy = j;
                    flag = true;
                    break;
                }
            }
            if(flag)break;
        }
        System.out.println(memx + " " + memy);
    }
}


Measured memory_bytes: 38896
K, S = map(int,input().split())

ans = 0
for x in range(0, K+1) :
    for y in range(x, K+1) :
        z = S - x - y
        if z < 0 or z > K :
            continue
        if x == y :
            ans += 1
        else :
            ans += 2

print(ans)

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(){
	string s;
	cin >> s;
	if(s == "SUN")
		cout << 7 << "\n";
	else if(s == "SAT")
		cout << 1 << "\n";
	else if(s == "MON")
		cout << 6 << "\n";
	else if(s == "TUE")
		cout << 5 << "\n";
	else if(s == "WED")
		cout << 4 << "\n";
	else if(s == "THU")
		cout << 3 << "\n";
	else if(s == "FRI")
		cout << 2 << '\n';

	return 0;
}

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

int main()
{
  long long int a, b, c, d, maxi = -1e18, crux[4];
  cin >> a >> b >> c >> d;
  maxi = max({maxi,a*c,b*d,a*d,b*c});
  cout << maxi << "\n";
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



ll n, s[110000], ans, mi = INF, mto;
vector<P>p;
int main() {
	cin >> n;
	REP(i, n) {
		cin >> s[i];
		if (s[i] < 0) {
			p.push_back(P(s[i], i));
		}
		else {
			if (mi > s[i]) {
				mi = s[i];

				mto = i;
			}
		}
	}
	sort(ALL(p));
	REP(i, p.size() - p.size() % 2) {
		s[p[i].second] *= -1;
	}
	if (p.size() % 2 == 1 and mi < INF) {
		//cout << s[p[p.size() - 1].second] << endl;
		//cout << s[mto] << endl;
		if (abs(s[p[p.size() - 1].second]) > s[mto]) {
			
			s[p[p.size() - 1].second] *= -1;
				s[mto] *= -1;
		}
	}
	REP(i, n) {
		ans += s[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3060
/* Author: shivangi0802 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
#define ll long long int
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)

using namespace std;

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b);
 ll gcd(ll a, ll b) ;
 int prime(int n);
ll ma;
ll dfs(int n,vector<vector<ll> > v, vector <ll> &dp){
ll temp=0;
    if(v[n].size()==0){dp[n]=1;return 1;}
  for(int j=0;j<v[n].size();j++){
            if(dp[v[n][j]]==-1) dfs(v[n][j],v,dp);
    temp=max(dp[v[n][j]]+1,temp);
}dp[n]=temp;
ma=max(ma,dp[n]);
return ma;
}
//else cout<<dp[n];



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

   ll n,m,x,y;
   cin>>n>>m;
  char a[n][m];ll b[n][m];
   memset(b,0,sizeof(b));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        cin>>a[i][j];
       if(a[i][j]=='#')b[i][j]=-1;}
  }b[0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if(i!=0||j!=0){
        if(b[i][j]==-1)b[i][j]=0;
        else{
            if(i>0&&j>0)b[i][j]=(b[i-1][j]%mod+b[i][j-1]%mod)%mod;
            else if(i>0)b[i][j]=b[i-1][j]%mod;
            else b[i][j]=b[i][j-1]%mod;
        }
        }
    }
  }
  cout<<b[n-1][m-1]%mod;
}




bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int prime(int n){
    int flag=1;
for(int i=2;i<=sqrt(n);i++){
    if(n%i==0){flag=0;break;}
}
  return flag;
}



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

int main() {
	int k;
	int a[] = { 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 };
	scanf("%d",&k);
	printf("%d", a[k-1]);
	
}

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

class Progaram
{
    static void Main(String[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var aes = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x)).ToArray();
        var ord = aes.Where(x => x % 2 != 0).ToArray().Length;
        if (ord % 2 != 0)
        {
            Console.WriteLine("NO");
        }
        else
        {
            Console.WriteLine("YES");
        }
    }
}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

ll dp[100005],a[100005],N,k,vis[100005];

ll f(ll n) {
	if(n > N)
		return INF;
	if(n == N)
		return 0;
	if(vis[n])
		return dp[n];
	ll best = INT_MAX;
	fori(i,1,k,1) {
		if(n+i <= N)
			best = min(best,abs(a[n]-a[n+i])+f(n+i));
	}
	vis[n] = 1;
	return dp[n] = best;
}

int main() {
	IOS
	cin >> N >> k;
	fori(i,1,N,1) {
		cin >> a[i];
	}
	cout << f(1) << endl;
}


Measured memory_bytes: 7296
main =
    interact (inBounds . map read . words)
    where
    inBounds :: [Int] -> String
    inBounds [w,h,x,y,r]
        | 0 <= (x-r) && (x+r) <= w && 0 <= (y-r) && (y+r) <=h = "Yes\n"
        | otherwise = "No\n"

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    string color;
    cin >> color;
    
    if (color == "Y") {
      sum++;
    }
  }
  
  if (sum == 0) {
    cout << "Three" << endl;
  }
  
  else {
    cout << "Four" << endl;
  }
}
    
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
const int N = 3e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
int cntx[N],cnty[N],n,m,q,x[N],y[N],ans;
int mx1,mx2,num1,num2,tree[N*8];map<pii,int>mp;
int main()
{
	cin>>n>>m>>q;vii a,b;a.clear();b.clear();
	for(int i=0;i<q;i++)
	{
		cin>>x[i]>>y[i];
		cntx[x[i]]++;
		cnty[y[i]]++;
		mp[MP(x[i],y[i])]++;
	}
	for(int i=1;i<=n;i++)a.pb(MP(cntx[i],i));
	for(int i=1;i<=m;i++)b.pb(MP(cnty[i],i));
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	int ans=0;
	for(int i=0;i<a.size();i++)
	{
		for(int j=0;j<b.size();j++)
		{
			if(a[i].F+b[j].F<=ans)break;
			ans=max(ans,a[i].F+b[j].F-mp[MP(a[i].S,b[j].S)]);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35080
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b,c;
  cin>>a>>b;
  if(b==1) co(0);
  else co(a-b);
  return 0;
}

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

using namespace std;

const int md = 1e9 + 7;
const int mxn = 1e5;

int dp[mxn + 11];
int a[mxn + 11];

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		int x;
		scanf("%d", &x);
		a[x] = 1;
	}
	dp[0] = 1;
	if (a[1] == 0)
		dp[1] = 1;
	if (a[2] == 0)
		dp[2] = dp[1] + dp[0];
	for (int i = 3; i <= n; i++){
		if (a[i] & 1)
			continue;
		dp[i] = (dp[i - 1] % md + dp[i - 2] % md) % md;
	}
	printf("%d\n", dp[n]);
	return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(true){
    C=C-B;
    if(C<=0){
      cout <<"Yes" <<endl;
    break;
    }
    A=A-D;
    if(A<=0){
      cout << "No" <<endl;
    break;
    }
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> v(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> v[i][j];
    vector<vector<int>> ans(h, vector<int>(w, 0));
    rep(i, h) {
        rep(j, w) {
            if(v[i][j] == '#') {
                rep(k, 8){
                    int nh = i + dh[k];
                    int nw = j + dw[k];
                    if(nh < 0 || h <= nh || nw < 0 || w <= nw) continue;
                    ans[nh][nw]++;
                }
            }
        }
    }
    rep(i, h) {
        rep(j, w) {
            if(v[i][j] == '#') cout << '#';
            else cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define all(v) v.begin(),v.end()
#define SZ(x) (int)x.size()
#define endl "\n"
#define thunder ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(15);
using namespace std;
typedef long long int ll;
#ifdef ONLINE_JUDGE
#define debug(...)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
void debug_out() { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
int main()
{
    thunder
    auto start = chrono::high_resolution_clock::now();
    int n,t;cin>>n>>t;
    vector<ll>v(n+1);
    for(auto &x:v)cin>>x;
    v[n]=INT_MAX;
    ll ans=0;
    for(int i=0;i<n;++i)
    {
        if(v[i+1]-v[i]>=t)
        {
            ans+=ll(t);
        }
        else
        {
            ans+=ll(v[i+1]-v[i]);
        }
    }
    cout<<ans<<endl;
   
   





   auto end = chrono::high_resolution_clock::now(); 
   double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
   time_taken *= 1e-9;
   debug(time_taken);
}

Measured memory_bytes: 4724
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 100000
bool red[MAXN+5];
int count[MAXN+5];
int main(){
    int n,m,cnt=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) count[i]=1;
    red[1]=1;
    for(int i=1;i<=m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        if(red[a]==1&&count[a]==1){
        	red[a]=0;red[b]=1;
		}else if(red[a]==1) red[b]=1;
        count[a]--;count[b]++;
    }
    for(int i=1;i<=n;i++)
        if(count[i]>0&&red[i]==1)
            cnt++;
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
#include<iostream>

using namespace std;
  string a,b="",c="";
  cin >> a;
  int x = a.size() -1;
  while(1){
    if(x %2 == 0){
      for(int i = 0;i < x;i++){
        if(i <= x/2-1)
          b += a[i];
        else
          c += a[i];
      }
      if(b == c){
        cout << x << endl;
        break;
      }
    }
    b = "";c = ""; x--;
  }
}


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

ll a[100009];ll dp[100009];
int n;
int k;
ll  bt(int pos)
{if(pos==n)
return 0;
if(dp[pos]!=-1)
    return dp[pos];
ll ans=10000000000009;

for(int i=1;i<=k &&pos+i<=n;i++)
    ans=min(ans,bt(pos+i)+abs(a[pos+i]-a[pos]));
    dp[pos]=ans;
    return ans;

}

int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
        cout<<bt(1);
}

Measured memory_bytes: 6528
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

/*
連続する部分文字列と思った
fn check(sum: &Vec<Vec<u64>>, front: usize, back: usize) -> bool {
    for i in 0..26 {
        if sum[back][i] - sum[front][i] > 1 {
            return false;
        }
    }
    return true;
}
fn main() {
    input! {
        n: usize,
        s: chars,
    }

    let mut sum = vec![vec![0; 26]; n + 1];

    for i in 0..n {
        sum[i + 1] = sum[i].clone();
        sum[i + 1][(s[i] as u8 - 'a' as u8) as usize] += 1;
    }
    for i in 0..n {
        let mut ok = i as i64;
        let mut ng = n as i64;
        while (ng - ok).abs() > 1 {
            let mid = (ok + ng) / 2;
            if check(&sum, i, mid as usize) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        println!("{} {}", i, ok as usize - i + 1);
    }
    println!("{:?}", sum);
}
*/

fn main() {
    input! {
        n: usize,
        s: chars,
    }

    let mut cnt = vec![0; 26];
    for i in 0..n {
        cnt[(s[i] as u8 - 'a' as u8) as usize] += 1;
    }

    let mut ans = 1u64;
    for e in cnt {
        ans *= e + 1;
        ans %= 1_000_000_007u64;
    }
    ans -= 1;
    ans %= 1_000_000_007u64;

    println!("{}", ans);
}


Measured memory_bytes: 4352
def bubblesort(array):
    flag = True
    res = 0
    while flag:
        flag = False
        for i in range(len(array)-1, 0, -1):
            if array[i] < array[i-1]:
                array[i], array[i-1] = array[i-1], array[i]
                res += 1
                flag = True
    return (array, res)
    
int(input())
arr, c = bubblesort([int(i) for i in input().split()])
print(*arr,sep=' ')
print(c)


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=w[i];
    }
    int leftsum=0;
    int min=10000;
    for(int i=0;i<n-1;i++){
        leftsum+=w[i];
        int def=abs(sum-2*leftsum);
        if(def<min){
            min=def;
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define wmax 10000
int f[wmax + 1], V[101], W[101];
int We , n;

void compute(int v, int w)
{
	for (int i = We; i >= w; i--)
		f[i] = max(f[i], f[i - w] + v);
}

int main()
{
	cin >> n >> We;
	for (int i = 1; i <= n; i++)
		cin >> V[i] >> W[i];
	for (int i = 0; i <= n; i++)f[i] = 0;

	for (int i = 1; i <= n; i++)
		compute(V[i], W[i]);

	cout << *max_element(f, f + We + 1) << endl;
	return 0;
}

			
 
	


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
    return a>b;
}
int main()
{
    int h[55],n,k,sum=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&h[i]);
    }
    sort(h+1,h+n+1,cmp);
    for(int i=1;i<=k;i++){
        sum+=h[i];
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
	int total;
	cin>>total;
	
	int input[total];	
	for (int i=0; i<total; i++){
		cin >> input[i];
	}

	double pairNumber=0;
	for(int i=0; i<total; i++){
	if (i == input[input[i]-1]-1) {pairNumber += 0.5;} 	
	}
	cout<<pairNumber<<endl;
}

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

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

    int i=0,j=-1,k=-1;

    char tmp = a[0],t=0;

    int A=a.length(),B=b.length(),C=c.length();

    while(i<A && j<B && k<C){
        t = tmp;
        if(tmp=='a'){
            i++;
            tmp=a[i];
            //cout << "i:" << i << " tmp=" << tmp << endl;
            continue;
        }
        else if(tmp=='b'){
            j++;
            tmp = b[j];
            //cout << "j:" << j << " tmp=" << tmp << endl;
            continue;
        }
        else if(tmp=='c'){
            k++;
            tmp=c[k];
            //cout << "k:" << k << " tmp=" << tmp << endl;
            continue;
        }
        else if(tmp==0){
            break;
        }
    }
    cout << char(t-32) << endl;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

typedef long long ll;

int main(){

  int q;
  scanf("%d",&q);
  ll ans = 0;
  while(q--){
    int p,n;
    char c;
    scanf("%d %c %d",&p,&c,&n);
    if(c == ')') ans -= n;
    else ans += n;
    if(ans == 0) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1016
class Dice:
    
    def __init__(self, lst):
        self.val=[]
        self.val.append(lst[0])
        self.val.append(lst[1])
        self.val.append(lst[2])
        self.val.append(lst[3])
        self.val.append(lst[4])
        self.val.append(lst[5])

    def rotate(self,dir):
        if dir=="N":
            tmp=self.val[0]
            self.val[0]=self.val[1]
            self.val[1]=self.val[5]
            self.val[5]=self.val[4]
            self.val[4]=tmp
        if dir=="E":
            tmp=self.val[0]
            self.val[0]=self.val[3]
            self.val[3]=self.val[5]
            self.val[5]=self.val[2]
            self.val[2]=tmp
        if dir=="S":
            tmp=self.val[0]
            self.val[0]=self.val[4]
            self.val[4]=self.val[5]
            self.val[5]=self.val[1]
            self.val[1]=tmp
        if dir=="W":
            tmp=self.val[0]
            self.val[0]=self.val[2]
            self.val[2]=self.val[5]
            self.val[5]=self.val[3]
            self.val[3]=tmp

def int_to_dir(n):
    if n==0:
        return "N"
    if n==1:
        return "E"
    if n==2:
        return "S"
    if n==3:
        return "W"
    

x = list(map(int,input().split()))
y = list(map(int,input().split()))

#print(x)
#print(y)

D1 = Dice(x) #generate instance

D2 = Dice(y)
#print(D1.val)
#print(D2.val)

import random 

Determin=False
for i in range(1000):

    D2.rotate(int_to_dir(random.randint(0,4)))
    
    #count+=1
    if D1.val==D2.val:
        #print(D1.val)
        #print(D2.val)
        Determin=True
        #print(i)
    
if Determin:
    print("Yes")
else:
    print("No")
                        
        


Measured memory_bytes: 8188
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n << endl;
  } else {
    cout << n * 2 << endl;
  }
  return 0;
}


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

int main(){
    int N;
    vector<int> A(3),B(3),C(3);
    for(int i=0;i<3;i++){
        cin>>A.at(i);
    }
    
    for(int i=0;i<3;i++){
        cin>>B.at(i);
    }
    
    for(int i=0;i<3;i++){
        cin>>C.at(i);
    }
    cin>>N;
    vector<int> b(N);
    for(int i=0;i<N;i++){
        cin>>b.at(i);
        for(int j=0;j<3;j++){
            if(A.at(j)==b.at(i)){
                A.at(j)=0;
            }
            if(B.at(j)==b.at(i)){
                B.at(j)=0;
            }
            if(C.at(j)==b.at(i)){
                C.at(j)=0;
            }
        }
    }
    bool flag = false;
    for(int i=0;i<3;i++){
        if(A.at(i)==B.at(i)&&B.at(i)==C.at(i)&&A.at(i)==0){
            flag = true;
        }
    }
    if(A.at(0)==A.at(1)&&A.at(1)==A.at(2)&&A.at(2)==0){
        flag = true;
        
    }
    if(B.at(0)==B.at(1)&&B.at(1)==B.at(2)&&B.at(2)==0){
        flag = true;
    }
    if(C.at(0)==C.at(1)&&C.at(1)==C.at(2)&&C.at(2)==0){
        flag = true;
    }
    if(A.at(0)==B.at(1)&&B.at(1)==C.at(2)&&C.at(2)==0){
        flag = true;
    }
    if(A.at(2)==B.at(1)&&B.at(1)==C.at(0)&&C.at(0)==0){
        flag = true;
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else if(!flag){
        cout<<"No"<<endl;
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define in(x, data) (data).find(x) != (data).end()

typedef long long ll;

long long f(long long x, long long y) {
    return max(to_string(x).length(), to_string(y).length());
}

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

    ll N; cin >> N;
    int n = (int)sqrt(N);
    RREP(i,n,0) {
        if(N%i == 0) {
            cout << f(i, N/i) << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
lst = []
N = int(input())
for i in range(N):
    lst.append(input())
if len(set(lst)) != N:
    print("No")
else:
    for i in range(N - 1):
        if lst[i][-1] != lst[i + 1][0]:
            print("No")
            break
    else:
        print("Yes")

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

int main(int argc, char const *argv[])
{
	std::vector<int> v;
	int a = 1;
	while (a != 0)
	{
		std::cin >> a;
		v.push_back(a);
	}
	for (int i = 0; i < v.size()-1; ++i)
	{
		std::cout << "Case " << i+1 << ": " << v[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int h,w,n,x1[1000],y1[1000],x2[1000],y2[1000],cnt,X,Y,dp[2002][2002],dx[]={1,-1,0,0},dy[]={0,0,1,-1},nx,ny,ans;
map<int,int> mpx,mpy;
queue<P> que;
int main(void){
    while(1){
    cin>>h>>w;
    if(h==0&&w==0)return 0;
    cin>>n;
    ans=0;
    for(int i=0;i<2002;i++)for(int j=0;j<2002;j++)dp[i][j]=0;
    mpx.clear();
    mpy.clear();
    h--,w--;
    mpx[h]=0;
    mpy[w]=0;
    mpx[0]=0;
    mpy[0]=0;
    for(int i=0;i<n;i++){
        cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
        mpx[x1[i]]=0;
        mpx[x2[i]]=0;
        mpy[y1[i]]=0;
        mpy[y2[i]]=0;
    }
    cnt=0;
    for(auto x:mpx)mpx[x.first]=cnt++;
    X=cnt;
    cnt=0;
    for(auto x:mpy)mpy[x.first]=cnt++;
    Y=cnt;
    for(int i=0;i<n;i++){
        dp[mpx[x1[i]]][mpy[y1[i]]]++;
        dp[mpx[x2[i]]][mpy[y1[i]]]--;
        dp[mpx[x1[i]]][mpy[y2[i]]]--;
        dp[mpx[x2[i]]][mpy[y2[i]]]++;
    }
    for(int i=0;i<X;i++){
        for(int j=0;j<Y-1;j++){
            dp[i][j+1]+=dp[i][j];
        }
    }
    for(int i=0;i<X-1;i++){
        for(int j=0;j<Y;j++){
            dp[i+1][j]+=dp[i][j];
        }
    }
    X--;
    Y--;
    for(int i=0;i<X;i++){
        //cout<<endl;
        for(int j=0;j<Y;j++){
            //cout<<dp[i][j]<<" ";
            if(dp[i][j]==0){
                ans++;
                dp[i][j]=1;
                que.push({i,j});
                while(que.size()){
                    P q=que.front();
                    que.pop();
                    for(int k=0;k<4;k++){
                        nx=q.first+dx[k];
                        ny=q.second+dy[k];
                        if(0<=nx&&nx<X&&0<=ny&&ny<Y&&dp[nx][ny]==0){
                            que.push({nx,ny});
                            dp[nx][ny]=1;
                        }
                    }
                }
                
                
                
            }
        }
    }
    cout<<ans<<endl;
    }
}



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

const int N = 110;

int q[N];

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

    for (int i = 0; i < n ; i ++ )
        cin >> q[i];

    int sum = 0;

    sort(q,q+n);

    for (int i = 0; i < n; i ++ )
        sum += q[i];

        if(sum % 10 == 0)
        {
            for (int j = 0; j < n; j ++ )
            {
                if(q[j] % 10 != 0)
                    {
                        sum -= q[j];
                        cout << sum << endl;
                        return 0;
                    }
            }
        }
        else  cout << sum << endl;
        if(sum % 10 == 0) cout << "0" << endl;
    return 0;
}


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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

int N;
void input() { cin >> N; }
void solve() {
  N += N * N + N * N * N;
  cout << N << endl;
}

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

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

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> H(N);

    ll sum = 0;
    rep(i,N){
        cin >> H[i];
        //sum += A[i];
    }
    if(K >= N){
        cout << 0 << endl;
        return 0;
    }
    sort(H.begin(), H.end());
    ll cnt =0;
    rep(i, N-K){
        sum += H[i];
    }

    cout << sum  << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define maxn 100005
#define INF 2123456789
typedef long long ll;

int main() {
	ll n;
	cin >> n;
	ll t = 100, i;
	for (i = 1;; i++) {
		t += t / 100;
		if (t >= n)break;
	}
	cout << i << endl;
}

Measured memory_bytes: 3644