akhauriyash/Code-Regression huggingface dataset:
l = [0 for i in range(45)]
l[0] = 1
l[1] = 1
def F(n):
    if l[n] != 0:
        return l[n]
    else:
        l[n] = F(n-1) + F(n-2)
        return l[n]
print(F(int(input())))


Measured memory_bytes: 5600
#include <iostream>
using namespace std;
int main() {
	int D;
	cin >> D;
	if (D==25) {
		cout << "Christmas" << endl;
	}
	if (D==24) {
		cout << "Christmas Eve" << endl;
	}
	if (D==23) {
		cout << "Christmas Eve Eve" << endl;
	}
	if (D==22) {
		cout << "Christmas Eve Eve Eve " << endl;
	}

	return 0;
}

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

const int MAX_X = 1000, MAX_Y = 1000;

int main() {
  int n;
  int dp[MAX_X+1][MAX_Y+1];
  string X, Y;
  cin >> n;
  for (int k=0; k<n; k++) {
    cin >> X >> Y;
    for (int i=0; i<=X.length(); i++) {
      for (int j=0; j<=Y.length(); j++) {
        dp[i][j] = 0;
      }
    }

    for (int i=1; i<=X.length(); i++) {
      for (int j=1; j<=Y.length(); j++) {
        if (X[i-1] == Y[j-1]) {
          dp[i][j] = dp[i-1][j-1] + 1;
        } else {
          dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
      }
    }

    cout << dp[X.length()][Y.length()] << endl;
  }
  return 0;
}

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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var ab = Console.ReadLine().Split();
		var a = long.Parse(ab[0]);
		var b = decimal.Parse(ab[1]);
		Console.WriteLine(((long)Math.Floor(a * b)).ToString("D0"));
	}

	/// <summary>最大公約数</summary>
	long gcd(long a, long b) => (a == 0) ? b : gcd(b % a, a);

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


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

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

    for(size_t i = 0; i < s.size(); i++){
        if(i % 2 == 1){
            if(s.at(i) != 'L' && s.at(i) != 'U' && s.at(i) != 'D'){
                std::cout << "No" << std::endl;
                return 0;
            }
        }else{
            if(s.at(i) != 'R' && s.at(i) != 'U' && s.at(i) != 'D'){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yes" << std::endl;
    
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    int res = 0;
    int a = 0, b = 0, c = 0;
    cin >> n;
    rep (i, n) {
        string t;
        cin >> t;
        rep (j, t.size() - 1) if (t[j] == 'A' && t[j + 1] == 'B') res++;
        if (t[0] == 'B' && t[t.size() - 1] == 'A') a++;
        else if (t[0] == 'B') b++;
        else if (t[t.size() - 1] == 'A') c++;
    }
    if (!a) {
        res += min(b, c);
    } else {
        if (b + c == 0) res += a - 1;
        else res += a + min(b, c);
    }
    cout << res << endl;
    
    return 0;
}



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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i, n) cin >> h[i];

  int ans = 0;
  int l = 0, r = 1;
  while (r < n) {
    if (h[r] <= h[r - 1])
      ++r;
    else {
      l = r;
      ++r;
    }
    ans = max(ans, r - l - 1);
  }

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main()
{

	int H,W;
	int cnt = 0;
	cin >> H >> W;
	vector<vector<char>> s(H, vector<char>(W));
	vector<vector<int>> L(H, vector<int>(W));
	vector<vector<int>> R(H, vector<int>(W));
	vector<vector<int>> U(H, vector<int>(W));
	vector<vector<int>> D(H, vector<int>(W));
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> s[i][j];
			if (s[i][j] == '.')
			{
				cnt++;
				L[i][j] = cnt;
			}
			else
			{
				cnt = 0;
				L[i][j] = 0;
			}
			if (j == W-1)
			{
				cnt = 0;
			}
		}
		cnt = 0;
	}


	for (int i = 0; i < H; ++i)
	{
		for (int j = W-1; j >= 0; --j)
		{
			if (s[i][j] == '.')
			{
				cnt++;
				R[i][j] = cnt;
			}
			else
			{
				cnt = 0;
				R[i][j] = 0;
			}
			if (j == 0)
			{
				cnt = 0;
			}
		}
		cnt = 0;
	}


	for (int j = 0; j < W; ++j)
	{
		for (int i = 0; i < H; ++i)
		{
			if (s[i][j] == '.')
			{
				cnt++;
				U[i][j] = cnt;
			}
			else
			{
				cnt = 0;
				U[i][j] = cnt;
			}
			if (i == H-1)
			{
				cnt = 0;
			}
		}
		cnt = 0;
	}


	for (int j = 0; j < W; ++j)
	{
		for (int i = H-1; i >= 0; --i)
		{
			if (s[i][j] == '.')
			{
				cnt++;
				D[i][j] = cnt;
			}
			else
			{
				cnt = 0;
				D[i][j] = cnt;
			}
			if (i == 0)
			{
				cnt = 0;
			}
		}
		cnt = 0;
	}

	int ans = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if ((L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3) > ans)
			{
				ans = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 67072
def countingsort(a):
    max_num = max(a)
    min_num = min(a)
    count = [0]*(max_num - min_num + 1)
    for ele in a:
        count[ele - min_num] += 1

    return [ele for ele,cnt in enumerate(count,start = min_num) for _ in range(cnt)]

        

n = int(input())
A = [int(s) for s in input().split()]
print(" ".join(map(str,countingsort(A))))


Measured memory_bytes: 233996
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(998244353);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

#define MAX_ 500000
int inv_list[MAX_]; //inv_list[i-1] = inverse of i
int fac[MAX_];
int finv[MAX_];
void nCk_init() {
  inv_list[0] = fac[0] = finv[0] = 1;
  for (int i = 0; i < MAX_ - 1; i++) {
    inv_list[i + 1] = MOD - ((inv_list[(MOD % (i + 2)) - 1] * (MOD / (i + 2))) % MOD);
    fac[i + 1]      = (fac[i] * (i + 2)) % MOD;
    finv[i + 1]     = (finv[i] * inv_list[i + 1]) % MOD;
  }
}
int nCk(int n, int k) {
  if (n == k or k == 0) return 1;
  return (fac[n - 1] * ((finv[k - 1] * finv[n - k - 1]) % MOD)) % MOD;
}

class BRGBColoring {
public:
  static void solve(istream &cin, ostream &cout) {
    int N, A, B, K;
    cin >> N >> A >> B >> K;
    nCk_init();
    int ans = 0;
    REP(a, 0, N + 1) {
      int b = (K - A * a) / B;
      if (0 <= b and b <= N and B * b == (K - A * a)) {
        ans += nCk(N, a) * nCk(N, b);
        ans = mod(ans, MOD);
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  BRGBColoring solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 15368
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    int N;
    int A[100];
    int Num[101]={};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        Num[A[i]]++;
    }
    sort(A,A+N);
    int MAX=A[N-1];
    bool flag=true;
    for(int i=MAX;i>MAX/2;i--){
        if(Num[i]<2){
            flag=false;
            break;
        }
    }
    if(MAX%2==0){
        if(Num[MAX/2]!=1) flag=false;
    }else{
        if(Num[MAX/2+1]!=2) flag=false;
    }
    for(int i=(MAX-1)/2;i>0;i--){
        if(Num[i]!=0) flag=false;
    }
    if(flag){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        boolean b = true;
        int i;
        for (i=0; i<n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        for (i=0; i<n; i++) {
            if (i != 0) {
                if (array[i-1] == array[i]) {
                    b = false;
                    break;
                }
            }
        }
        System.out.println(b ? "YES" : "NO");
    }
}

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

const int MAX_SIZE = 50;
char A[MAX_SIZE][MAX_SIZE];
char B[MAX_SIZE][MAX_SIZE];

int main() {
  int N, M;
  scanf("%d%d", &N, &M);

  for (int y = 0; y < N; y++) {
    for (int x = 0; x < N; x++) {
      cin >> A[y][x];
    }
  }
  for (int y = 0; y < M; y++) {
    for (int x = 0; x < M; x++) {
      cin >> B[y][x];
    }
  }

  bool exist = false;
  for (int dy = 0; dy < N; dy++) {
    for (int dx = 0; dx < N; dx++) {
      // テンプレート画像が収まらない場合、判定を行わない
      if (dy + M - 1 >= N || dx + M - 1 >= N) continue;

      bool match = true;
      for (int y = 0; y < M; y++) {
        for (int x = 0; x < M; x++) {
          if (A[dy + y][dx + x] != B[y][x]) match = false;
        }
      }
      if (match) exist = true;
    }
  }

  if (exist) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(long long i = a; i < (b); ++i)
typedef long long ll;

int main() {
    long long N, K, MOD = 1000000007;
    cin >> N >> K;
    long long ANS = 0;
    for (long long k = K; k <= N + 1; k++) {
        long long int MIN = ( k - 1 + 0 ) * k / 2;
        long long int MAX = ( N + ( N - k + 1 ) ) * k / 2;
        ANS += MAX - MIN + 1;
        ANS %= MOD;
    }
    cout << ANS << endl;
    return 0;
}

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

int main()
{
    int n;
    map<int,int>m;
    cin>>n;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n-i;j++){
            for(int k=1;k<=n-j;k++){
                int v=i*i+j*j+k*k+i*j+j*k+k*i;
                if(v>n)
                    break;
                
                m[v]++;
            }
        }
    }

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

}


Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>

int main(){
    char a[15];
    char b[15];
    char c [15];
    scanf("%s%s%s", a,b,c);
    int d= strlen(a)-1;
    int e = strlen(b)-1;
    if (a[d]==b[0] && b[e]==c[0]){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
    int n,k;
    cin >> n>>k;
    if (n%k==0) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
    ll a,b,c,d,e,i,j,k=0,l=0;
    
    
    ll n,m;
    vector<ll>v;v.push_back(0);
    
    cin>>n>>m>>c;
    for(i=1;i<=m;i++)
    {cin>>a;v.push_back(a);}
    
  for(i=1;i<=n;i++)
  {l=0;
  for(j=1;j<=m;j++)
  {
  cin>>a;
   l+=v[j]*a;
  }
        if(l+c>0)k++;
  }
        cout<<k<<endl;
  }

Measured memory_bytes: 256
s = input()
if s[-1] == '2' or s[-1]=='4' or s[-1]== '5' or s[-1]=='7' or s[-1]== '9':
    print('hon')
elif s[-1] == '0' or s[-1] == '1' or s[-1]=='6' or s[-1]== '8':
    print('pon')
elif s[-1] == '3':
    print('bon')

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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n);
    int ans=INT_MAX;
    for (int i = 0; i < n; i++)
    {
        cin>>c[i];
        a[i].resize(m);
        for (int j = 0; j < m; j++)
        {
            cin>>a[i][j];
        }
    }
    for (int bit = 0; bit < (1<<n); bit++)
    {
        vector<int> know(m);
        int cost=0;
        for (int book = 0; book < n; book++)
        {
            if((bit&(1<<book))!=0)//use c[book]
            {
                cost+=c[book];
                for (int i = 0; i < m; i++)
                {
                    know[i]+=a[book][i];
                }
            }
        }
        bool ok=true;
        for (int i = 0; i < m; i++)
        {
            if(know[i]<x)
            {
                ok=false;
                break;
            }
        }
        if(ok)
        {
            ans=min(ans,cost);
        }
    }
    if(ans==INT_MAX)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<ans<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		System.out.println(String.valueOf(a.charAt(a.length() - 1)).equals(String.valueOf(b.charAt(0))) &&
				String.valueOf(b.charAt(b.length() - 1)).equals(String.valueOf(c.charAt(0)))? "YES" : "NO");

		sc.close();

	}

}

Measured memory_bytes: 35828
# -*- coding: utf-8 -*-
# B - A to Z String
# 標準入力の取得
s = input()

# 左から"A"、右から"Z"を検索すると、その位置の差が最大の長さになる
max_length = s.rfind("Z") - s.find("A") + 1
print(max_length)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
const long MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    long dp[4] = {1};
    for(char i : s){
        if(i == 'A') dp[1] = (dp[1] + dp[0]) % MOD;
        if(i == 'B') dp[2] = (dp[2] + dp[1]) % MOD;
        if(i == 'C') dp[3] = (dp[3] + dp[2]) % MOD;
        if(i == '?'){
            dp[3] = (dp[3] * 3 + dp[2]) % MOD;
            dp[2] = (dp[2] * 3 + dp[1]) % MOD;
            dp[1] = (dp[1] * 3 + dp[0]) % MOD;
            dp[0] = (dp[0] * 3) % MOD;
        }
    }
    cout << dp[3] << endl;
}


Measured memory_bytes: 512
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	int mn = min(n, (ll)m);
	vector<int> P; // (pre_sum)
	ll sum_p = 0; // sum of pre + cycle
	vector<int> X(m, -1); // for cycle check & pre_len
	rp(i, 0, mn){
		if(X[x] > -1){
			int cyc_len = P.size() - X[x];
			ll remain = P[X[x]];
			ll cyc = (sum_p - remain) * ((n - X[x]) / cyc_len);
			remain += P[X[x] + (n - X[x]) % cyc_len] - P[X[x]];
			cout<< cyc + remain <<endl;
			return 0;
		}
		P.push_back(sum_p);
		sum_p += x;
		X[x] = i;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


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

const long long MOD = 1e9 + 7;

long long fact(long long n) {
    long long ret = 1;
    while(n) {
        ret = (ret * n) % MOD;
        n--;
    }
    return ret;
}   

long long inv(long long n) {
    long long ret = 1;
    for(int p = MOD-2; p; p /= 2) {
        if(p & 1) ret = (ret * n) % MOD;
        n = (n * n) % MOD;
    }
    return ret;
}

int main() {
    long long h, w, a, b;
    cin >> h >> w >> a >> b;
    
    long long cnk1 = 1;
    long long cnk2 = (fact(w + h - b - 2) * inv(fact(w - b - 1))) % MOD * inv(fact(h - 1)) % MOD;
    long long answ = (cnk1 * cnk2) % MOD;
    for(long long k = 2; k <= h - a; k++) {
        cnk1 = (cnk1 * (k + b - 2)) % MOD * inv(k - 1) % MOD;
        cnk2 = (cnk2 * inv(h - k + w - b)) % MOD * (h-k+1) % MOD;
        answ = (answ + cnk1 * cnk2) % MOD;
    }
    
    cout << answ << "\n";
    
    return 0;
}

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

int main()
{
	long long int N, D;
	scanf("%lld%lld", &N, &D);
	
	int ans = 0;
	for(int i = 1; i <= N; i++)
	{
		long long int Xi, Yi;
		scanf("%lld%lld", &Xi, &Yi);
		
		if(Xi * Xi + Yi * Yi <= D * D)
			ans++;
	}
	
	printf("%d", ans);
}


Measured memory_bytes: 3816
S = str(input())
T = str(input())
import numpy as numpy
len_S = len(S)
len_T = len(T)
count = numpy.zeros(len_S-len_T+1)
for i in range(len_S-len_T+1):
  for j in range(len_T):
    if not S[i+j] == T[j]:
      count[i] +=1
print(int(min(count)))

Measured memory_bytes: 27144
{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import qualified Data.ByteString.Char8 as BS


readIntBS = fst . fromJust . BS.readInt

main = do
  n <- readLn :: IO Int
  ps <- map readIntBS . BS.lines <$> BS.getContents :: IO [Int]

  arr <- newArray (1,n) 0 :: IO (IOUArray Int Int)
  asc <- newArray (1,n) 0 :: IO (IOUArray Int Int)
  dsc <- newArray (1,n) 0 :: IO (IOUArray Int Int)

  forM_ (zip [1..] ps) $ \(i,p) -> do
    writeArray arr p i

  let
    aux1 i a = do
      when (i <= n) $ do
        x <- readArray arr i
        y <- readArray arr (i-1)
        if y < x then
          writeArray asc i a >> aux1 (i+1) a
          else
          writeArray asc i i >> aux1 (i+1) i

    aux2 i a = do
      when (i >= 1) $ do
        x <- readArray arr i
        y <- readArray arr (i+1)
        if y > x then
          writeArray dsc i a >> aux2 (i-1) a
          else
          writeArray dsc i i >> aux2 (i-1) i
          

  writeArray asc 1 1
  aux1 2 1

  writeArray dsc n n
  aux2 (n-1) n

  print =<< (n -) . maximum <$> (zipWith (\x y -> y-x+1) <$> getElems asc <*> getElems dsc)


Measured memory_bytes: 29948
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [h,w,m] = nexts(3);
  var y = xArray(0,h), x = xArray(0,w);
  var set = xArray("new Set()",h);
  for(var i = 0; i < m; i++){
    var u = next()-1, v = next()-1;
    set[u].add(v);
    y[u]++, x[v]++;
  }
  var mx = 0, xid = [], yx = 0, yid = [];
  for(var i = 0; i < h; i++){
    if(yx < y[i])yx = y[i], yid = [i];
    else if(yx === y[i])yid.push(i);
  }
  for(var i = 0; i < w; i++){
    if(mx < x[i])mx = x[i], xid = [i];
    else if(mx === x[i])xid.push(i);
  }
  for(var i = 0; i < yid.length; i++)for(var j = 0; j < xid.length; j++){
    var yy = yid[i], xx = xid[j];
    if(!set[yy].has(xx))return mx+yx;
  }
  return mx+yx-1;
}

Measured memory_bytes: 167796
#include <iostream>
using namespace std;
#define INF (1 << 30) - 1

int main(){
	int a[6] = {2, 3, 5, 10, 12, 15}, dp[51], n;
	int b[6] = {380, 550, 850, 1520, 1870, 2244};
	fill(dp, dp+51, INF);
	dp[0] = 0;
	
	for(int i =  0;i <= 50;i++)
		for(int j = 0;j < 6;j++)
			if(i >= a[j])dp[i] = min(dp[i], dp[i-a[j]] + b[j]);
	while(cin >> n, n)cout << dp[n/100] << endl;
	return 0;
}

Measured memory_bytes: 3000
N = int(input())
F = tuple(tuple(map(int, input().split())) for _ in range(N))
P = tuple(tuple(map(int, input().split())) for _ in range(N))
ans = -float("inf")
for n in range(1, 1024):
    indices = [0] * N
    for i in range(N):
        for j in range(10):
            if (n >> (9 - j)) & 1:
                indices[i] += F[i][j]
    ans = max(ans, sum(profit[idx] for profit, idx in zip(P, indices)))
print(ans)

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String b = sc.next();
		
		int max = 0;
		
		for (int i = 1; i < a; i++) {
			
			String c = b.substring(0, i);
			String d = b.substring(i, a);
			
			int count = 0;
			
			Set<String> words = new HashSet<>();
			words.addAll(Arrays.asList(c.split("")));
			words.remove(" ");
			
			for (String str: words) {
				if (d.contains(str)) {
					count++;
				}
			}
			
			if (count > max) max = count;
			
		}
		
		System.out.println(max);
		
		
	}	
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] weight = new int[n];
        for (int i=0; i<n; i++){
            weight[i] = sc.nextInt();
        }

        // ?????¨??????????´¢???????????§????????????solve???
        // n????????¶?????´???100,000???????????????????????´?????¶???100,000????????\???????????´???1~10^10
        System.out.println(solve1(n, k, weight));

    }

   
    // ??????????§???????????´¢????????????????????????????????´????????¢?????¶???????????????????´????
    private static long solve1(int n, int k, int[] weight) {
        long left = 1;
        long rihgt = 100000 * 100000;

        while(left < rihgt){
            long mid = (left+rihgt)/2;
            int temp = check(mid, n, k, weight);
            if (temp >= n){
                rihgt = mid;
            }
            else {
                left = mid+1;
            }
        }

        return rihgt;
    }


    private static int check(long p, int n, int k, int[] weight) {

        int i = 0;

        for (int j=0; j<k; j++){
            long s = 0;
            while (s+weight[i] <= p){
                s += weight[i];
                i++;
                if (i == n){
                    return n;
                }
            }
        }

        return i;
    }
}

Measured memory_bytes: 69228
N, Y = map(int, input().split())
res10000 =res5000 = res1000 = -1

for x in range(N+1):
    for y in range(N+1-x):
        z = N-x-y # zは決まっているので、ループを減らして、計算量を減らす！
        if 10000*x + 5000*y + 1000*z == Y:
            res10000 = x
            res5000 = y
            res1000 = z

print(res10000, res5000, res1000)

Measured memory_bytes: 3060
import std.stdio, std.conv, std.algorithm;
import std.range, std.array, std.math;

void dump(int[][] field, int n) {
  for(int i = 0; i <= n + 1; i++) {
    for(int j = 0; j <= n + 1; j++) {
      writef("%2d%s", field[i][j], j == (n + 1) ? "\n" : " ");
    }
  }
}

void main() {
  int edge;
  while(readf("%d\n", &edge), edge != 0) {
    int[][] field = new int[][](edge + 2, edge + 2);
    for(int i = 0; i <= (edge + 1); i++) {
      field[0][i] = -1;
      field[i][0] = -1;
      field[edge + 1][i] = -1;
      field[i][edge + 1] = -1;
    }
    for(int i = 1; i <= edge; i++) {
      string s;
      readf("%s\n", &s);
      for(int j = 0; j < edge; j++) {
        switch(s[j]) {
        case '*':
          field[i][j + 1] = -1;
          break;
        case '.':
          field[i][j + 1] = 1;
          break;
        default:
          throw new Exception("unknown value");
        }
      }
    }
    int square = 0;
    for(int i = edge; i >= 1; i--) {
      for(int j = edge; j >= 1; j--) {
        if (field[i][j] == -1) continue;
        if (field[i + 1][j] != -1 &&
            field[i][j + 1] != -1 &&
            field[i + 1][j + 1] != -1) {
          field[i][j] =
            min(field[i][j + 1], field[i + 1][j], field[i + 1][j + 1]) + 1;
        }
        square = max(square, field[i][j]);
      }
    }
    writeln(square);
  }
}

Measured memory_bytes: 12276
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u32 A, B;
    cin >> A >> B;
    cout << 1 + 2 + 3 - A - B << endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def abc162d(n, s):

    r_arr = []
    g_arr = []
    b_arr = []

    for i in range(n):
        if s[i] == 'R':
            r_arr.append(i)
        elif s[i] == 'G':
            g_arr.append(i)
        else: # 'B'
            b_arr.append(i)

    min1_arr = r_arr
    min2_arr = g_arr
    max_arr = b_arr
    if len(r_arr) < len(g_arr) and len(b_arr) < len(g_arr):
        min1_arr = r_arr
        min2_arr = b_arr
        max_arr = g_arr
    elif len(g_arr) < len(r_arr) and len(b_arr) < len(r_arr):
        min1_arr = g_arr
        min2_arr = b_arr
        max_arr = r_arr

    max_dict = dict()
    for elem in max_arr:
        max_dict[elem] = 1

    except_num = 0
    for r_i in min1_arr:
        for g_i in min2_arr:
            min_i = r_i
            max_i = g_i
            if g_i < r_i:
                min_i = g_i
                max_i = r_i
            diff = max_i - min_i
            minmin = min_i - diff
            maxmax = max_i + diff
            exists_central = (max_i + min_i) % 2

            if minmin in max_dict:
                except_num += 1
            if maxmax in max_dict:
                except_num += 1
            if exists_central == 0:
                central = (max_i + min_i) / 2
                if central in max_dict:
                    except_num += 1

    ans = len(r_arr) * len(g_arr) * len(b_arr) - except_num
    return ans

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    s = input()
    
    ans = abc162d(n, s)
    
    # output
    print(ans)
# else:
    # do nothing


Measured memory_bytes: 9336
fun main() {
    val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }

    val start =
        if (a < b) {
            var i = 2
            while (true) {
                if (a * i >= b) {
                    break
                }
                i += 1
            }
            i
        } else {
            1
        }

    val initial = (start * a) % b
    if (initial == c) {
        print("YES")
        return
    }

    var i = start + 1
    while (true) {
        val remainder = (a * i)  % b
        if (remainder == c) {
            print("YES")
            return
        }

        if (remainder == initial) {
            print("NO")
            return
        }
        i += 1
    }

}


Measured memory_bytes: 36472
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 1e5+10;
const int MAXM = 3e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;

int A[MAXN];
int chk[30];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;

    scanf("%d",&n);

    scanf("%s",&S);

    for(int i=0;i<n;i++)
        chk[S[i]-'a']++;

    for(int i=0;i<26;i++)
        chk[i]++;

    ll res = 1;

    for(int i=0;i<26;i++){
        res*=(ll)chk[i];
        res%=MOD;
    }
    res+=(MOD-1);
    res%=MOD;

    cout<<res;
    return 0;
}


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

int main(){

int n;
cin>>n;
int t=n%10;
vector<int> a{2,4,5,7,9};
int c=3;
if(find(a.begin(),a.end(),t)!=a.end())
    cout<<"hon";
else if(c==t)
    cout<<"bon";
else cout<<"pon";

}


Measured memory_bytes: 3620
function Main(input) {
  input = input.split("\n");
  n = Number(input[0]);
  a = input[1].split(" ").map(Number);
  o = new Array(n);
  for(var i=0;i<n;i++){
    o[a[i]-1] = i+1;
  }
  ans = o.join(" ");
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 38500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int a, b, x;
    cin >> a >> b >> x;
    chmin(a, b * 2);

    int ans = 0;
    ans += a * (x / 1000);
    x %= 1000;
    if (x == 0);
    else if (x > 500)ans += a;
    else ans += min(a, b);

    cout << ans << "\n";
}



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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
int main()
{
  long long N;
  int A,B;
  long long  sum=0;
  long long  ans=0;
  string S;
  bool flag=false;
  cin>>N;
  int count=0;
  for(int i=0;i<N;i++){
    cin>>A;
    cin>>B;
    if(A==B){
      count++;
    }else{
      count=0;
    }
    if(count==3)flag=true;
  }
  if(flag)cout<<"Yes";
  else cout<<"No";
  return 0;
}




Measured memory_bytes: 3628
K = int(input())
x=7
ans = 0
if K%2!=0 and K%5!=0:
    for i in range(K+1):
        if x%K == 0:
            ans = 1
            break
        x = (x*10+7) % K
        
if ans == 1:
    print(i+1)
else:
    print(-1)

Measured memory_bytes: 63208
import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

countMinusElem :: [Int] -> Int
countMinusElem = length . filter (< 0)

main = do
  n <- toInt <$> getLine
  a <- map toInt . words <$> getLine
  let l = sort . map abs $ a
  putStrLn $ show $ if mod (countMinusElem a) 2 == 0
    then sum l
    else (sum $ tail l) - (head l)


Measured memory_bytes: 40572
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void) {
	string s;
	for (int i = 0; i < 3; i++) {
		cin >> s;
		cout << char(s.front() - 'a' + 'A');
	}
	return 0;
}

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll A, B, C; cin >> A >> B >> C;
    ll K; cin >> K;

    cout << A + B + C + max(A, max(B, C)) * pow(2, K) - max(A, max(B, C)) << endl;
}

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

long f(long n, long x) // 0以上n以下の整数のうち条件を満たすものの個数
{
  if (n == -1)
    return 0;
  return n / x + 1;
}

int main()
{
  long a, b, x;
  cin >> a >> b >> x;
  cout << f(b, x) - f(a - 1, x) << endl;
  return 0;
}

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

int main(void){
    std::string s;
    std::cin >> s;

    int l = s.size();
    int countB = 0;
    long long ans = 0;

    for(int i = 0; i < l; i++){
        if(s.at(i) == 'B'){
            countB++;
        }
        else{
            ans += countB;
        }
    }
  
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define heap priority_queue
using namespace std;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MX = 1e6; 
bool isp[MX + 100]; 

int bp(int a, int n) {
	int ret = 1; 
	while(n) {
		if(n & 1) ret *= a; 
		a *= a; 
		n >>= 1; 
	}
	return ret; 
}

signed main()
{
	memset(isp, 1, sizeof isp); 
	isp[1] = 0; 	
	for(int i = 1; i <= MX; i++) {
		if(isp[i]) {
			for(int j = i * i; j <= MX; j += i) 
				isp[j] = 0; 
		}
	}
		
	int n, p; 
	cin >> n >> p; 
	int t = sqrt(p), ans = 1; 
	for(int i = 2; i <= t; i++) {
		if(p % i == 0 and isp[i]) {
			int cnt = 0; 
			while(p % i == 0) {
				p /= i; 
				cnt++; 
			}
			ans *= bp(i, cnt / n);  
		}
	}
	if(p > 1 and n == 1) ans *= p;  
	cout << ans;   
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;

    vector<tuple<int, int, int>> vs;
    vs.push_back(make_tuple(0, 0, 0));

    for (int i = 0; i < N; i++) {

        int t, x, y;
        cin >> t >> x >> y;

        vs.push_back(make_tuple(t, x, y));
    }

    bool ok = true;

    for (int i = 0; i < N; i++) {

        int dt = get<0>(vs[i+1]) - get<0>(vs[i]);
        int dist = abs(get<1>(vs[i+1]) - get<1>(vs[i])) + abs(get<2>(vs[i+1]) - get<2>(vs[i]));
        if (dist > dt) {
            ok = false;
            break;
        }
        if (dt % 2 != dist % 2) {
            ok = false;
            break;
        }
    }

    if (ok) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;

}

Measured memory_bytes: 1912
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

# n以下の整数でiで割り切れる数の総和
def sumofdivi(n,i):
    a = n//i
    b = (a*(a+1))//2*i
    return b

ans = 0
for i in range(1,n+1):
    v = sumofdivi(n,i)
    ans += v

print(ans)

Measured memory_bytes: 63688
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 2282282287;
const ll power = 49999;

/*
Нас по звукам узнавай:
Ня Кавай, Ня Кавай
Мы орем на весь трамвай:
Ня Кавай
Никогда не забывай:
Ня Кавай, Ня Кавай
Лучше к нам не приставай
Ня Кавай
*/

ll n;
string s;

int main()
{
	/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	*/
	cin >> s;
	ll cco1 = 0, cco2 = 0;
	forn(i, 0, s.size())
	{
		if (s[i] == 'C')
		{
			cco1++;
			continue;
		}
		if (s[i] > 'A' && s[i] <= 'Z')
		{
			cout << "WA";
			return 0;
		}
	}
	if (cco1 > 1)
	{
		cout << "WA";
		return 0;
	}

	forn(i, 2, s.size()-1)
	{
		cco2 += (s[i] == 'C');
	}
	if (cco2 != 1)
	{
		cout << "WA";
		return 0;
	}
	if (s[0] != 'A')
	{
		cout << "WA";
		return 0;
	}
	cout << "AC";
	return 0;
}


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



int main()
{
	int n;
	int p;
	int r = 0;
	cin >> n;
	cin >> p;
	for (int i = 1; i < n; i++) {
		int pn;
		cin >> pn;
		if (pn <= p) {
			r++;
			p = pn;
		}

	}
	cout << r + 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 3001;
 
int N, T;
ll ans = 0;
 
// # of dishes, time it takes to eat 
ll dp[MX][MX];
 
void solve() {
    cin >> N >> T;
    vector<l_l> dishes(N);
    for (int i = 0; i < N; i++) {
        cin >> dishes[i].first >> dishes[i].second;
    }
    sort(dishes.begin(), dishes.end());
    
    for (int dish = 1; dish <= N; dish++) {
        for (int time = 1; time <= T; time++) {
            dp[dish][time] = dp[dish - 1][time];
            chmax(ans, dp[dish - 1][time - 1] + dishes[dish - 1].second);
            
            ll maxWithDish = 0;
            
            if (time >= dishes[dish - 1].first) {
                maxWithDish = dishes[dish - 1].second;
                maxWithDish += dp[dish - 1][time - dishes[dish - 1].first];
            }
            
            
            chmax(dp[dish][time], maxWithDish);
        }
    }
    
    cout << ans;
}
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll Q = 1; // cin >> T;
    while (Q--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}
 
/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 70656
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n;
	cin >> n;
	int tn = n;
	int sum = 0;
	while (tn)
	{
		sum += tn % 10;
		tn /= 10;
	}
	cout << (n%sum ? "No" : "Yes");
	sp;
}

Measured memory_bytes: 504
import java.io.*;
 
public class Main {
        public static void main(String[] args){
       try{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String textline = br.readLine();
        double x = Math.pow(Integer.parseInt(textline), 3);
        System.out.println((int)x);
        br.close();
       }
      catch(IOException e){};
    }
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, C, ans=0, tmp=0;
vector<ll> A, X, S1, S2, SR1, SR2;

signed main(){
    cin >> N >> C;
    X.resize(N);
    A.resize(N);
    S1.resize(N+1,0);
    S2.resize(N+1,0);
    SR1.resize(N+1,0);
    SR2.resize(N+1,0);
    for(int i=0;i<N;i++) {
        cin >> X[i] >> A[i];
    }
    for(int i=0;i<N;i++) {
        S1[i+1] = S1[i] + A[i];
        S2[i+1] = S2[i] + A[i];
        SR1[N-i-1] = SR1[N-i] + A[N-i-1];    
        SR2[N-i-1] = SR2[N-i] + A[N-i-1];    
    }
    for(int i=0;i<N;i++) {
        S1[i+1] -= X[i];
        S2[i+1] -= 2*X[i];
        SR1[N-i-1] -= C-X[N-i-1];    
        SR2[N-i-1] -= 2*(C-X[N-i-1]);
    }
    for(int i=0;i<=N;i++) {
        //cout << S1[i] << " " << S2[i] << " " << SR1[N-i] << " " << SR2[N-i] << endl;
    }
    for(int i=0;i<N;i++) {
        S1[i+1] = max(S1[i+1],S1[i]);
        S2[i+1] = max(S2[i+1],S2[i]);
        SR1[N-i-1] = max(SR1[N-i-1],SR1[N-i]);
        SR2[N-i-1] = max(SR2[N-i-1],SR2[N-i]);;    
    }
    for(int i=0;i<=N;i++) {
        ans = max(ans, S1[i]+SR2[i]);
        ans = max(ans, S2[i]+SR1[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define pb(x)                       push_back(x)
#define pf(x)                       push_front(x)
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1e5 + 10;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

int main(){

    str s;
    cin >> s;
    ll k = 1 , ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            ll cnt = poww(3 , s.size() - i - 1 , MOD);
            ans = (ans + (cnt * k) % MOD) % MOD;
            k = (k * 2) % MOD;
        }
    }
    ans = (ans + k) % MOD;
    cout << ans;

}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final int result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int AB = sc.nextInt();
        int BC = sc.nextInt();
        int CA = sc.nextInt();

        sc.close();
        return new TestCase(AB, BC, CA);
    }

    public static int process(TestCase testCase) {
        int AB = testCase.AB;
        int BC = testCase.BC;
        int CA = testCase.CA;

        return AB * BC / 2;
    }

    private static void output(int result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int AB;
        final int BC;
        final int CA;

        public TestCase(int AB, int BC, int CA) {
            this.AB = AB;
            this.BC = BC;
            this.CA = CA;
        }
    }
}


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

using namespace std;

int main()
{
    string s;
    int ans = 700;
    cin >> s;
    if (s[0] == 'o') ans += 100;
    if (s[1] == 'o') ans += 100;
    if (s[2] == 'o') ans += 100;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256