akhauriyash/Code-Regression huggingface dataset:
using System;

namespace b
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            int len = S.Length;
            string ans = "";
            if(len <= K)
            {
                ans += S;
            }
            else
            {
                ans += S.Substring(0, K) + "...";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27440
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int n; cin >> n;
    vvi G(n, vi(n));
    rep(i, n)rep(j, n) cin >> G[i][j];

    vvi dp(n + 1, vi(n + 1));
    rep(i, n)rep(j, n){
        dp[i + 1][j + 1] = G[i][j] + dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
    }

    int ans = -(1LL << 31);
    loop(i1, 1, n + 1)loop(i2, 0, i1)loop(j1, 1, n + 1)loop(j2, 0, j1){
        int t = dp[i1][j1] - dp[i1][j2] - dp[i2][j1] + dp[i2][j2];
        ans = max(t, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1300
#include<stdio.h>

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

  if((a < b )&&(b < c)){
    printf("%s\n","Yes");
  }
  else{
    printf("%s\n","No");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    ans=LINF;
    rep(i,n)cin>>a[i];
    rep(i,n-k+1){
        tmp=a[i];tmpp=a[i+k-1];
        if((tmp<0&&tmpp>0)||(tmp>0&&tmpp<0)){
        cnt=min(abs(tmp),abs(tmpp))*2+max(abs(tmp),abs(tmpp));
        ans=min(ans,cnt);
        }
        else{
            cnt=max(abs(tmp),abs(tmpp));
            ans=min(ans,cnt);
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1024
S=gets.chomp
cursor_s=0
cursor_e=S.length-1
ret = 0
loop do
    break if cursor_s >= cursor_e
    s = S[cursor_s]
    e = S[cursor_e]
    if s==e
        cursor_s+=1
        cursor_e-=1
    elsif s=="x"
        cursor_s+=1
        ret+=1
    elsif e=="x"
        cursor_e-=1
        ret+=1
    else
        puts "-1"
        exit
    end
end
puts ret


Measured memory_bytes: 2044
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define il inline
#define rg register
#define gi read<int>
using namespace std;
typedef long long ll;
template<class TT>
il TT read() {
	TT o = 0,fl = 1; char ch = getchar();
	while (!isdigit(ch) && ch != '-') ch = getchar();
	if (ch == '-') fl = -1, ch = getchar();
	while (isdigit(ch)) o = o * 10 + ch - '0', ch = getchar();
	return fl * o;
}
ll n, ans;
int main() {
    n = read<ll>();
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i) continue;
        ans = i + n / i - 2;
    }
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#import numpy as np
N,M=map(int,input().split())
inf=10**9

class Node():
	def __init__(self, ix):
		self.ix = ix # ノード番号
		self.done = False # 確定ノードかどうか
		self.pay = {} # 頂点番号:コストの一覧を容れる辞書
		self.paid = -1 # ここに到達するための最小コスト(未定義なら-1)
		self.prev = -1 # 最小コストを与える親ノード(未定義なら-1)
	def __str__(self):
		# デバッグ用
		return '{} <- [{}] <- {}, done:{}, pay:{}'.format(self.ix, self.paid, self.prev, self.done, self.pay)

# ノードのリストを生成
nodes = []
for i in range(N):
	nodes.append(Node(i))

# エッジのリストを生成(これはこの問題用)
# edges = np.zeros((N,N), dtype=np.uint8) #NumPy
edges = []
for _ in range(N):
	edges.append([0]*N)

# エッジ情報を取得
# 全エッジを格納
# 注意: 標準入力は1-indexedだがここでは0-indexedに直す
for _ in range(M):
	a,b,c = map(int,input().split())
	nodes[a-1].pay[b-1] = c
	nodes[b-1].pay[a-1] = c
	edges[a-1][b-1] = 1
	edges[b-1][a-1] = 1
		
		
# 出発ノードを0からN-1まで変化させる
for i in range(N):
	nodes[i].prev = i # 出発点の最良親を自分自身に
	nodes[i].paid = 0 # 出発点のコストは0
	nodes[i].done = True # 出発点は確定済み
	n_done = 1 # 確定ノード数を1に
	while n_done < N: # 全部確定するまで続行
		to_conf_ix = -1 # 次に確定されるべきノード番号
		to_conf_paid = 10**9 # そのコスト
		for node in nodes:
			# 確定ノードすべてに対して操作を行う
			if node.done:
				# 接続先を全列挙
				for child in list(node.pay.keys()):
					# その接続先が未確場合のみ進む定なら処理続行
					if not nodes[child].done:
						# その接続先の仮の最小コストと仮の親を更新
						# まだ確定済みにはしない
						newcost = node.paid + node.pay[child]
						# 更新するための条件
						flag = (nodes[child].paid < 0) or (newcost < nodes[child].paid)
						# 条件をみたせば接続先の情報を更新
						# また次に確定されるノード候補の情報も更新
						if flag:
							nodes[child].paid = newcost
							nodes[child].prev = node.ix
						if newcost < to_conf_paid:
							to_conf_paid = newcost
							to_conf_ix = child
		# 操作が完了したら現段階の候補ノードを確定させる
		nodes[to_conf_ix].done = True
		# 確定ノード数を1増やす
		n_done += 1
		
	# 各ノードについてそれを親と連結するパスをedgeから削除
	for j in range(N):
		k = nodes[j].prev
		edges[j][k], edges[k][j] = 0, 0

	# 全ノードのpaid,prevをリセット
	for j in range(N):
		nodes[j].paid, nodes[j].prev = -1, -1
		nodes[j].done = False

# 最後にedgesに残っているエッジの本数を出力
# print(int(np.sum(edges)//2)) # NumPy
ans = 0
for i in range(N):
	ans += sum(edges[i])
print(ans//2)


Measured memory_bytes: 46940
#include<bits/stdc++.h>
#define ll long long
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

vector<int> tree[100001];
int dp[100001][2];
//color = 1 -> white
//color = 0 -> black

int solve(int node, bool color, vector<bool>& vis)
{
    vis[node] = 1;
    ll ans = 1;

    if(dp[node][color] != -1)
        return dp[node][color];

    for(int child : tree[node])
    {
        if(!vis[child])
        {
            ll ways = solve(child, 1, vis);
            if(color)
                ways = (ways + solve(child, 0, vis)) % mod;

            ans = (ans * ways) % mod;
            vis[child] = 0;
        }
    }

    return dp[node][color] = ans % mod;
}

int main(){
    ll i,j,t,n,m,p,k;
    fast_io;
    t = 1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i = 0; i < n - 1; i++)
        {
            int u,v;
            cin>>u>>v;
            tree[u].push_back(v);
            tree[v].push_back(u);
        }
        memset(dp, -1, sizeof dp);
        vector<bool> vis1(n + 1, 0);
        cout<<(solve(1, 0, vis1) + solve(1, 1, vis1 = vector<bool>(n + 1, 0)))%mod;
    }
    return 0;
}


Measured memory_bytes: 14848
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+1;

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

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

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

  int n; cin >> n;
  int mx = 0,ans = 0;
  for(int i = 0; i < n; i++){
    int h; cin >> h;
    if(i == 0){
      mx = h;
      ans++;
    }
    else {
      if(mx <= h){
        mx = h;
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int sum = 0;
		int sumsum = 0;
		int[][] matrix = new int[r][c];
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				matrix[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < r; i++) {
			sum = 0;
			for (int j = 0; j < c; j++) {
				System.out.print(matrix[i][j] + " ");
				sum += matrix[i][j];
				if (j == c - 1) {
					System.out.print(sum);
					sumsum += sum;
				}
			}
			System.out.println("");
		}
		for (int i = 0; i < c; i++) {
			sum = 0;
			for (int j = 0; j < r; j++) {
				sum += matrix[j][i];
			}
			System.out.print(sum + " ");
		}
		System.out.println(sumsum);
	}
}

Measured memory_bytes: 39504
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int H,A,B,N,R,M,K,X,Y,Z,C;
  string S,T,U;
  int N_tmp=0;
  cin >> R;
  

  cout << 2*M_PI*R << endl;
  return 0;
  


}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
const int maxn = 555;
int g[maxn][maxn];
int main(){
  int n, m, q; cin >> n >> m >> q;
  for(int i = 0; i < m; i++){
    int x, y; cin >> x >> y;
    g[x][y]++;
  }
  for(int i = 1; i <= n; i++){
  	for(int j = 0; j <= n; j++){
    	g[j][j+i] += g[j][j+i-1];
      	g[j][j+i] += g[j+1][j+i];
      	g[j][j+i] -= g[j+1][j+i-1];
    }
  }
  for(int i = 0; i < q; i++){
    int x, y; cin >> x >> y;
    cout << g[x][y] << endl;
  }
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

vector<int> abc(3, 0);

int main(void){
    
    scanf("%d %d %d", &abc[0], &abc[1], &abc[2]);
    sort(abc.begin(), abc.end());
    
    if(abc[0] == abc[1] && abc[1] == abc[2]){
        printf("0\n");
    }
    else if(abc[1] == abc[2]){
        int n = abc[1] - abc[0];
        printf("%d\n", (n % 2 == 0) ? n / 2 : (n / 2) + 1 + 1);
    }
    else if(abc[0] == abc[1]){
        printf("%d\n", abc[2] - abc[0]);
    }
    else{
        int n = abc[1] - abc[0], m = abc[2] - abc[1];
        if(n % 2 == 0){
            printf("%d\n", n / 2 + abc[2] - abc[1]);
        }
        else if(n % 2 != 0 && m % 2 == 0){
            n = abc[2] - abc[0]; 
            printf("%d\n", m / 2 + (n / 2 + 1) + 1);
        }
        else{
            n = abc[2] - abc[1];
            m = abc[2] - abc[0];
            printf("%d\n", m / 2 + (n / 2 + 1) + 1);
        }
    }
    
    return 0;
}

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

using ll = long long;
const int SEG_LEN = 1 << 20;
vector<ll> seg(2 * SEG_LEN);

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

void setv(int pos, ll val) {
    pos += SEG_LEN;
    seg[pos] = val;
    while (true) {
        pos /= 2;
        if (pos == 0) break;
        seg[pos] = gcd(seg[2 * pos], seg[2 * pos + 1]);
    }
}

ll prod(int l, int r) {
    l += SEG_LEN;
    r += SEG_LEN;
    ll res = 0;
    while (l < r) {
        if (l % 2) res = gcd(res, seg[l++]);
        if (r % 2) res = gcd(res, seg[--r]);
        l >>= 1;
        r >>= 1;
    }
    return res;
}

int main() {
    int N;  cin >> N;
    for (int i = 0; i < N; ++i) {
        ll a;  cin >> a;
        setv(i, a);
    }
    ll ans = -1;
    for (int i = 0; i < N; ++i) {
        ans = max(ans, gcd(prod(0, i), prod(i + 1, N)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 19408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N; cin >> N;
  for(int i=(int)sqrt((double)N); i>=1; i--){
    if(N%i==0){
      int n=N/i;
      string num1=to_string(i);
      string num2=to_string(n);
      cout << max(SZ(num1),SZ(num2)) << endl;
      return 0;
    }
  }
  return 0;
}


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

#define reps(i,s,n) for(int (i) = (s); (i) < (n) ;(i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long int;
const int INF = 1L << 50;
int main(){
    int N,W;
    cin >> N >> W;
    ll w0,v0,weight,value;
    vector<int> w1,w2,w3,w4;
    vector<int> w(N,0), v(N,0);
    vector<ll> s1(N+2,0),s2(N+2,0),s3(N+2,0),s4(N+2,0);
    cin >> w0;
    cin >> v0;
    w1.push_back(v0);
    rep(i,N-1){
        cin >> weight;
        cin >> value;
        switch(weight-w0){
            case 0:
                w1.push_back(value);
                break;
            case 1:
                w2.push_back(value);
                break;
            case 2:
                w3.push_back(value);
                break;
            case 3:
                w4.push_back(value);
                break;
        }
    }
    
    sort(w1.begin(),w1.end(),greater<>());
    sort(w2.begin(),w2.end(),greater<>());
    sort(w3.begin(),w3.end(),greater<>());
    sort(w4.begin(),w4.end(),greater<>());
    
    if(1 <= w1.size()){
        s1[1] = w1[0];
        reps(i,1,w1.size()) s1[i+1] += (s1[i] + w1[i]);
    }

    if(1 <= w2.size()){
        s2[1] = w2[0];
        reps(i,1,w2.size())s2[i+1] += (s2[i] + w2[i]);
    }

    if(1 <= w3.size()){
        s3[1] = w3[0];
        reps(i,1,w3.size())s3[i+1] += (s3[i] + w3[i]);
    }

    if(1 <= w4.size()){
        s4[1] = w4[0];
        reps(i,1,w4.size())s4[i+1] += (s4[i] + w4[i]);
    }

    
    ll ans = s1[0]+s2[0]+s3[0]+s4[0];
    reps(i,1,w1.size()+2){
        reps(j,1,w2.size()+2){
            reps(k,1,w3.size()+2){
                reps(l,1,w4.size()+2){
                   if(ans < s1[i-1] + s2[j-1] + s3[k-1] +s4[l-1]){
                        if((i+j+k+l-4)*w0 + (1*(j-1)+2*(k-1)+3*(l-1)) <= W){
                            ans = s1[i-1] + s2[j-1] + s3[k-1] + s4[l-1];
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]

if k == 0:
    print(n ** 2)
    exit()

ans = 0
for b in range(k + 1, n + 1):
    q, mod = divmod(n, b)
    ans += q * (b - k)
    if mod >= k:
        ans += mod - k + 1
print(ans)

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

int main() {

	long res;
	int A, B, K; cin >> A >> B >> K;
	long count = 0;

	for (int i = 100; i >= 1; i--){ if (A % i == 0 && B % i == 0) count++; 
		                            if (count == K) { res = i; break; }
	}

	cout << res << endl;

}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    if (S.substr(0, 4) == "YAKI") yes;
    else no;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  double ans = 0;
  FOR(i, N) {
    double A;
    cin >> A;
    ans += 1.0 / A;
  }
  printf("%.10f\n", 1.0 / ans);
  return 0;
}
#include <algorithm>


Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main()
{
	long a,b,i,ans;
  
	cin >> a >> b;
	for(i=a;i<=b;i++){
		if(i/10000 == i%10 && i/1000%10 == i/10%10){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		bool flag=false;
		for(int cnt = 1; cnt < 1<<10; cnt*=2)
		{
			if(cnt&n)
			{
				if(flag) cout<<" "<<cnt;
				else cout<<cnt;
				flag=true;
			}
		}
		cout<<endl;
	}
  return 0;
}

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

int check(string s1,string s2){
	int res = 0;
	bool flag = true;
	if(s1 == s2)return -1;
	for(int i = 0;i < min(s1.size(),s2.size());i++){
		res++;
		if(s1[i] != s2[i]){
			flag = false;
			break;
		}
	}
	if(flag && s1.size() == s2.size()){
		return -1;
	}
	else if(!flag){
		return res;
	}
	else return res+1;
}

string makes(string s){
	string s1 = "";
	s1 += s[0];
	for(int i = 0;i < s.size()-1;i++){
		if(s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'e' || s[i] == 'o'){
			s1 += s[i+1];
		}
	}
	return s1;
}

int main(){
	int n,res;
	string s;
	vector<string> vec;
	bool flag;
	while(1){
		res = 0;
		vec.clear();
		cin >> n;
		if(n == 0)break;
		flag = true;
		for(int i = 0;i < n;i++){
			cin >> s;
			vec.push_back(makes(s));
		}
		for(int i = 0;i < vec.size()-1;i++){
			for(int j = i+1;j < vec.size();j++){
				if(check(vec[i],vec[j]) == -1){
					res = -1;
					flag = false;
					break;
				}
				else{
					res = max(res,check(vec[i],vec[j]));
				}
			}
			if(!flag)break;
		}
		cout << res <<endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>

int main() {

	int n, m, i, j;
	int a, b;
	int A[100][100] = { 0 };
	int B[100] = { 0 };
	int c[100] = { 0 };

	scanf("%d %d ", &n, &m);

	for (i = 0; i<n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a);
			A[i][j] = a;
		}
	}

	for (i = 0; i<m; i++) {
		scanf("%d", &b);
		B[i] = b;
	}

	for (i = 0; i<n; i++) {
		for (j = 0; j<m; j++) {
			c[i] = c[i] + A[i][j] * B[j];
		}
	}

	for (j = 0; j<n; j++) {
		printf("%d\n", c[j]);
	}
	return 0;
}


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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var result = s == "a" || s == "i" || s == "u" || s == "e" || s == "o";
            Console.WriteLine(result ? "vowel" : "consonant");
        }
    }
}


Measured memory_bytes: 25852
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
a=[list(map(int,input().split())) for _ in range(h)]
def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
cost=warshall_floyd(c,10)
magic=0
for i in range(h):
  for j in range(w):
    if a[i][j]!=-1:
      magic+=cost[a[i][j]][1]
print(magic)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
       #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int n,m;
int l;
int a[10]={0};

int ch(int n){
	int u=n;
	while(1){
		if(u==0) break;
		if(a[u%10]==1) return false;
		u /=10;
	}
	return true;
	
}

signed main(){
int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int l;
		cin>>l;
		a[l]=1;
	}
	
	
	while(ch(n)==false) n++;
	cout<<n<<endl;
	
	
	return 0;
        }


Measured memory_bytes: 3592
#include <stdio.h>
#define TH 25

int main(int argc, char *argv[]){
     int n; double w, h;
     
     while(~scanf("%d,%lf,%lf",&n,&w,&h))
	  if(w/(h*h) >= 25) printf("%d\n",n);

     return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define inf 10e10

using namespace std;
struct edge{
    int v; //行き先
    int d; //重み
};
struct vdata{
    int v; //頂点
    int d; //距離
};
bool operator> (const vdata &vdata1,const vdata &vdata2)
{
    return vdata1.d > vdata2.d;
};
int main(){
    int N,M,R;
    int r[8];
    int i;
    int s,t,d;
    int u;//Dijkstra法計算用
    edge e;
    vdata vd;
    vector<edge> G[201];
    long long dis[201];
    long long rdis[8][8] = {};
    vector<int> buf;
    long long min,now;
    priority_queue<vdata,vector<vdata>,greater<vdata> > que;
    cin  >> N >> M >> R;
    for(i=0;i<R;i++) cin >> r[i];
    for(i=0;i<M;i++){
        cin >> s >> t >> d;
        e.v = t;
        e.d = d;
        G[s].push_back(e);
        e.v = s;
        G[t].push_back(e);
    }
    for(int j=0;j<R-1;j++){
        for(i=0;i<=N;i++){
            if(i == r[j]) dis[i] = 0;
            else dis[i] = inf;
        }
        vd.v = r[j];
        vd.d = 0;
        que.push(vd);
        while(!que.empty()){
            u = que.top().v;
            que.pop();
            for(i=0;i<G[u].size();i++){
                if(dis[u] < inf && dis[G[u][i].v]>dis[u]+G[u][i].d){
                    dis[G[u][i].v] = dis[u]+G[u][i].d;
                    vd.v = G[u][i].v;
                    vd.d = dis[G[u][i].v];
                    que.push(vd);
                }
            }
        }
        for(i=0;i<R;i++){
            rdis[i][j] = dis[r[i]];
            rdis[j][i] = dis[r[i]];
        }
    }
    min = inf;
    for(int i=0;i<R;i++) buf.push_back(i);
    do{
        now = 0;
        for(int i=0;i<R-1;i++) now += rdis[buf[i]][buf[i+1]];
        if(now < min){
            min = now;
        }
    }while(next_permutation(buf.begin(),buf.end()));
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main() {
	int N; cin >> N;
	int* ju;
	ju = new int[N];
	int* Cost;
	Cost = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> ju[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Cost[i];
	}
	for (int i = 0; i < N; i++) {
		ju[i] = ju[i] - Cost[i];
	}
	int stock;
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			if (ju[j] < ju[i]) {
				stock = ju[j];
				ju[j] = ju[i];
				ju[i] = stock;
			}
		}
	}
	stock = 0;

	for (long int i = 0;i<N; i++) {
		if (0 < ju[i]) {
			stock += ju[i];
		}
	}
	cout << stock;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)

int ordnum(int n)
{
    int ret = 0;
    while (n != 0)
    {
        ret++;
        n /= 10;
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n + 1)
    {
        if (ordnum(i) % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
	https://atcoder.jp/contests/abc139/tasks/abc139_c
	C-Lower
*/
package main

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

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

// 右隣のマスに移動できるか判定する
// (a地点のマスの高さがb地点のマスの高さ以下であるか判定する)
func canMove(a, b int) (result bool) {
	if a >= b {
		return true
	} else {
		return false
	}
}

var count int = 0 // 連続移動回数
var max int = 0   // 最大移動回数

// 最大移動回数を上回った場合に更新
func update() {
	if count > max {
		max = count
	}
}

// 連続移動回数をリセット
func reset() {
	count = 0
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)

	// マス N個
	N, _ := strconv.Atoi(readLine())

	// 要素数0、容量Nのスライスを作成
	Hs := make([]int, 0, N)

	// 各マスの高さ H1 H2 ... HNを取得しsliceに格納する
	for i := 0; i < N; i++ {
		h, _ := strconv.Atoi(readLine())
		Hs = append(Hs, h)
	}
	// 1マス目から順に右隣のマスに移動できるか確認し
	// 連続で移動できた回数が最大移動回数を上回っていたら更新する
	for i := 0; i < N-1; i++ {
		// 移動できるか確認
		// Hs[i]	プレイヤーが立っているマス
		// Hs[i+1]	右隣のマス
		if canMove(Hs[i], Hs[i+1]) {
			count++
			update()
			//fmt.Printf("canMove(true) : a=%d b=%d c=%d\n", Hs[i], Hs[i+1], count)
		} else {
			//fmt.Printf("canMove(false): a=%d b=%d c=%d\n", Hs[i], Hs[i+1], count)
			reset()
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
const int maxx = 110;
int n, m[maxx][maxx];
int u, num, v;
int d[maxx], f[maxx];
int flag[maxx];
int nowtime = 1;

void dfs(int u) {

    // 入栈时间
    flag[u] = 1;
    d[u] = nowtime++;
    for (int i = 1; i <= n; i++) {
        if (flag[i] == 0 && m[u][i] == 1) {
            dfs(i);
        }
    }
    //出栈时间
    f[u] = nowtime++;
}

int main()
{

    scanf("%d", &n);
    memset(m, 0, sizeof(m));
    memset(f, 0, sizeof(f));
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &u, &num);
        for (int j = 1; j <= num; j++) {
            scanf("%d", &v);
            m[u][v] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        if(flag[i] == 0)
            dfs(i);
    }
    for (int i = 1; i <= n; i++) {
        printf("%d %d %d\n", i, d[i], f[i]);
    }
    return 0;
}


Measured memory_bytes: 3284
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int q[1000000],C[100010];
int ta[100010],nt[200010],to[200010],co[200010];
int f[100010];
/*int dfs(int v,int e,int s){
  int i,max=C[s];
  for(i=ta[s];i+1;i=nt[i]){
    if(f[to[i]])continue;
    f[to[i]]=1;
    C[to[i]]=C[s]+co[i];
    max=MAX(max,dfs(v,e,to[i]));
  }
  return max;
}//*/
int bfs(int v,int e,int s){
  int t,r,i,max=0;
  for(i=0;i<v;i++)C[i]=1000000000;
  C[q[0]=s]=t=0;//printf("a\n");
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d %d\n",q[t],to[i],co[i]);
      if(C[to[i]]>C[q[t]]+co[i]){
	C[to[i]]=C[q[t]]+co[i];//printf("m%d->",max);
        if(max<C[to[i]])max=C[to[i]];//printf("m%d\n",max);
	q[r++]=to[i];
      }
    }//printf("\n");
  }//printf("%d\n",r);
  return max;
}//*/
int tyokkei(int v,int e,int *a){
  int i,max=0,g;
  for(i=0;i<v;i++){
    ta[i]=-1;
    C[i]=1000000000;
    f[i]=0;
  }
  C[0]=0;
  f[0]=1;
  for(i=0;i<e;i++){
    nt[i]=ta[a[i]];
    ta[a[i]]=i;
    nt[i+e]=ta[to[i]];
    to[i+e]=a[i];
    co[i+e]=co[i];
    ta[to[i]]=i+e;    
  }
  max=bfs(v,e*2,0);
  for(i=0;i<v;i++){
    if(max==C[i])g=i;
    C[i]=1000000000;
    f[i]=0;
  }
  C[g]=0;
  f[g]=1;//printf("g%d m%d\n",g,max);
  return bfs(v,e*2,g);
}
int main(){
  int n,a[100010],i;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)scanf("%d %d %d",&a[i],&to[i],&co[i]);
  printf("%d\n",tyokkei(n,n-1,a));
  return 0;
}

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

int main ()
{
    int a,b,count=0;
    cin >> a >> b;
    
    for (a;a<=b;a++)
    {
        if (a/10000 == a%10 && (a%10000)/1000 == (a%100)/10)
        count++;
    }
    
    cout<< count<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	
	int n,m;
	double table[101][101];
	double dp[2][101];
	while(cin>>n>>m&&!(n==0&&m==0)){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++)
				cin>>table[i][j];
		}
		fill(dp[0],dp[0]+101,1);
		fill(dp[1],dp[1]+101,0);

		double *prv=dp[0];
		double *nxt=dp[1];
		for(int k = 0; k < m-1; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					nxt[i]=max(nxt[i],prv[j]*table[j][i]);
				}
			}
			swap(prv,nxt);
			fill(nxt,nxt+101,0);
		}

		double maxNum=0;
		for(int i = 0; i < n; i++){
			maxNum=max(maxNum,prv[i]);
		}

		double ret=maxNum;
		printf("%.2f\n",ret);
	}

	return 0;
}

Measured memory_bytes: 0
A=int(input())
B=int(input())
C=int(input())
X=int(input())

from itertools import permutations, combinations,combinations_with_replacement,product
lA = list(range(A+1))
lB = list(range(B+1))
lC = list(range(C+1))
L = product(*[lA,lB,lC]) #choufuku junretu2
cnt=0
for i in L:
  if (i[0]*500+i[1]*100+i[2]*50)==X:
    cnt+=1
print(cnt)

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

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

    //good luck kittu!
    int n; cin>>n;
    vector<int> a(n+1);
    for(int i = 0; i<n; i++) cin>>a[i];

    ll ans = 0;
    map<int, int> m;
    for(int i = 0; i<n; i++){
        ans += m[i-a[i]];
        m[i+a[i]]++;
    }
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;
const double PAI = acos(-1);
constexpr long double eps = 1e-9;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    int n = (int)s.size();
    for(int i=0;i<n;++i){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    cout << s << endl;
    return 0;
}


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

int nr, alese, sol[25];
double total, culoare[25][10], maxim;

void back(int x)
{
    if(x == alese+1)
    {
        total = 0;
        for(int i=1; i <= alese; i++)
        {
            for(int j=i+1; j <= alese; j++)
            {
                for(x=1; x <= 3; x++)
                {
                    total += (culoare[sol[i]][x]-culoare[sol[j]][x])*(culoare[sol[i]][x]-culoare[sol[j]][x]);
                }
            }
        }
        maxim = max(maxim, total);
    }
    else
    {
        for(int i=sol[x-1]+1; i <= nr-(alese-x); i++)
        {
            sol[x] = i;
            back(x+1);
            sol[x] = 0;
        }
    }
}

int main()
{
    cin >> nr >> alese;
    for(int i=1; i <= nr; i++)
    {
        for(int j=1; j <= 3; j++)
        cin >> culoare[i][j];
    }

    back(1);
    cout << fixed;
    cout << setprecision(10);
    cout << maxim;
}



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

long long int gcd (long long int a, long long int b) {
	while (a % b != 0) {
		long long int a_hold = a;
		a = b;
		b = a_hold % b;
	}
	return b;
}

long long int lcm (long long int a, long long int b) {
	long long int ans = a / gcd(a,b) * b;
	return ans;
}

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

	long long int ans = lcm(a,b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
#define LF '\n'
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int n ,q;
  int a[1005];
  cin >> n;

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

  cin >> q;
  while(q--) {
    int s, e;
    cin >> s >> e;
    reverse(a+s, a+e);
  }

  for (int i= 0; i < n; ++i) {
    cout << a[i] << (i+1 < n ? ' ' : LF);
  }

  return 0;
}




Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 200005
using namespace std;
typedef long long ll;
int n,m,A,B;
ll sum[N],a[N],f[N],ans=1e18,mx[2][N<<2];
ll Abs(ll a){
	return a<0?-a:a;
}
ll query(int k,int l,int r,int L,int R,int op){
	if(L<=l&&R>=r){
		return mx[op][k];
	}
	int mid=l+r>>1;ll ans=1e18;
	if(L<=mid) ans=query(k<<1,l,mid,L,R,op);
	if(R>mid) ans=min(ans,query(k<<1|1,mid+1,r,L,R,op));
	return ans;
}
void update(int k,int l,int r,int x,int op,ll val){
	if(l==r){
		mx[op][k]=min(mx[op][k],val);
		return;
	}
	int mid=l+r>>1;
	if(x<=mid) update(k<<1,l,mid,x,op,val);
	else update(k<<1|1,mid+1,r,x,op,val);
	mx[op][k]=min(mx[op][k<<1],mx[op][k<<1|1]);
}
void solve(){
	memset(mx,0x3f,sizeof(mx));
	for(int i=1;i<=m;i++){
		sum[i]=sum[i-1]+Abs(a[i]-a[i-1]);
	}
	update(1,1,n,a[0],0,f[1]-sum[1]-a[0]);
	update(1,1,n,a[0],1,f[1]-sum[1]+a[0]);
	for(int i=2;i<=m;i++){
		f[i]=sum[i-1]+query(1,1,n,1,a[i],0)+a[i];
		f[i]=min(f[i],sum[i-1]+query(1,1,n,a[i],n,1)-a[i]);
		update(1,1,n,a[i-1],0,f[i]-sum[i]-a[i-1]);
		update(1,1,n,a[i-1],1,f[i]-sum[i]+a[i-1]);
	}
	for(int i=1;i<=m;i++) ans=min(ans,f[i]+sum[m]-sum[i]);
}
int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	for(int i=1;i<=m;i++){
		scanf("%lld",&a[i]);
	}
	a[0]=A;
	f[1]=Abs(B-a[1]);
	solve();
	a[0]=B;
	f[1]=Abs(A-a[1]);
	solve();
	printf("%lld",ans);
	return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back


//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


// printf ("%.9f\n",x);


bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    ll arr[n+4] = {0};
    ll maxnum = -1;
    for(ll i = 1; i<=n; i++)
    {
        cin >> arr[i];
        maxnum = max(maxnum,arr[i]);
    }
    sort(arr,arr+n+1);
    ll prime[maxnum+5] = {0};
    ll mul = 1;
    for(ll i = 1; i<=n; i++)
    {
        if(prime[arr[i]] == 0)
        {
            if(i != n)
            {
                if(arr[i] == arr[i+1])
                    mul = 1;
                else
                    mul = 2;
            }
            else
            {
                mul = 2;
            }
            ll temp = arr[i];
            for(ll j = mul * temp; j <= maxnum; j += temp)
            {
                prime[j] = 1;
            }
        }
    }
    ll c = 0;
    for(ll i = 1; i<=n; i++)
    {
        if(prime[arr[i]] == 0)
        {
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}   

Measured memory_bytes: 12956
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//System.Diagnostics.Debug.WriteLine(n);
			long ans = 0;
			for (int i = 1; i <= n; i++) {
				if (i % 10 != 0) {
					int h = i, t = i % 10;
					while (h >= 10) {
						h /= 10;
					}
					// 1桁
					if (h == t) {
						ans++;
						//System.Diagnostics.Debug.WriteLine($"  {i},{h}");
					}
					// 2桁
					if (t * 10 + h <= n) {
						ans++;
						//System.Diagnostics.Debug.WriteLine($"  {i},{t * 10 + h}");
					}
					// 3桁～
					int k = 100;
					while (true) {
						int tmp1 = t * k + h;
						int tmp2 = t * k + k - 10 + h;
						if (tmp1 <= n) {
							if (tmp2 <= n) {
								ans += k / 10;
								//System.Diagnostics.Debug.WriteLine($"  {i},{tmp1}-{tmp2}:{k / 10}");
							} else {
								int x = (n % k) / 10;
								tmp2 = t * k + x * 10 + h;
								if (tmp2 > n) {
									x--;
									tmp2 = t * k + x * 10 + h;
								}
								ans += x + 1;
								//System.Diagnostics.Debug.WriteLine($"  {i},{tmp1}-{tmp2}:{x + 1}");
							}
						} else {
							break;
						}
						k *= 10;
					}
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222







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


  
  ll a, b;
  cin >> n >> a >> b;
  cout << min(a*n, b) << endl;






  return 0;
}

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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()



int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    auto tx = x, ty = y;
    sort(ALL(x));
    sort(ALL(y));

    ll res = 1LL << 62;
    rep(xi, n) FOR(xj, xi + 1, n) rep(yi, n) FOR(yj, yi + 1, n) {
        int cnt = 0;
        ll minX = min(x[xi], x[xj]), maxX = max(x[xi], x[xj]);
        ll minY = min(y[yi], y[yj]), maxY = max(y[yi], y[yj]);
        rep(i, n) {
            if (minX <= tx[i] && tx[i] <= maxX && minY <= ty[i] && ty[i] <= maxY) cnt++;
        }
        if (cnt < k) continue;
        ll S = (maxX - minX)*(maxY - minY);
        res = min(res, S);
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main ()
{
	long long x, y;

	scanf("%lld %lld", &x, &y);

	long long r = y / x;
	x = 1;
	y = 1;
	int toto = 0;

	while(y <= r) {
		y = (y << 1);
		toto++;
	}

	printf("%d\n", toto);

	return 0;
}

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


typedef long long int ll;
# define PI 3.14159265358979323846
#define mod 1000000007

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
ll nCrModPFermat(ll n, ll r, ll p)
{
   // Base case
   if (r==0)
      return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    ll fac[n+1];
    fac[0] = 1;
    for (int i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  for(ll i=k;i<=n+1;i++){
    ll temp1=(i*n)%mod;
    ll temp2=(i*(i-1))%mod;
    ans=(ans+temp1-temp2+1)%mod;
  
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
bool isOutOfBounds(int y, int x, int h, int w) {
    return y < 0 || y >= h || x < 0 || x >= w;
}

int main() {
    int W, H;
    vs room;

    int sy, sx;
    while (cin >> W >> H) {
        if (W == 0) break;

        room.resize(H);
        REP(y, H) {
            cin >> room[y];
            REP(x, W) {
                if (room[y][x] == '@') { sy = y; sx = x; room[y][x] = '#'; }
            }
        }

        queue<int> que;
        que.push(sy);
        que.push(sx);
        int y, x, cnt=1;
        while (!que.empty()) {
            y = que.front(); que.pop();
            x = que.front(); que.pop();

            for (int i=0; i<4; i++) {
                if (isOutOfBounds(y+dy[i], x+dx[i], H, W)) continue;
                if (room[y+dy[i]][x+dx[i]] == '#') continue;

                cnt++;
                room[y+dy[i]][x+dx[i]] = '#';
                que.push(y+dy[i]);
                que.push(x+dx[i]);
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 3232
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}

int main()
{
    speed();
    ll a,i,ans=0;
    cin>>a;
    ll b[a];
    rep(i,a)
        cin>>b[i];
    rep(i,a)
    {
        if(i>0 && b[i]<b[i-1] )
            {
                ans+=(b[i-1]-b[i]);
                b[i] = b[i-1];
            }
    }
    cout<<ans<<endl;



return 0;
}



Measured memory_bytes: 5136