akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int max(int a, int b) {
	return a > b ? a : b;
}

int max_happiness(int n, int points[][3], int i, int prev, int dp[][3]) {
	if (i >= n) return 0;

	if (dp[i][prev] != -1) return dp[i][prev];

	int ans = 0, j;
	for (j = 0; j < 3; j++) {
		if (prev == j) continue;
		ans = max(ans, points[i][j] + max_happiness(n, points, i+1, j, dp));
	}
	dp[i][prev] = ans;
	return dp[i][prev];
}

int main() {
	int n, i;
	scanf("%d", &n);
	int points[n][3];
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &points[i][0], &points[i][1], &points[i][2]);
	}
	int happiness = 0;
	int dp[n][3];
	for (i = 0; i < 3; i++) {
		memset(dp, -1, sizeof(int)*n*3);
		happiness = max(happiness, points[0][i] + max_happiness(n, points, 1, i, dp));
	}
	printf("%d\n", happiness);
	return 0;
}

Measured memory_bytes: 11904
//circle2.cpp
#include<iostream>
#include<iomanip>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;

int main()
{
    double r;
    cin>>r;
    cout << std::fixed << std::setprecision(10) <<M_PI*pow(r,2.0)<<" "<<2*M_PI*r<<endl;
}


Measured memory_bytes: 3228
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [-A[0]]
def solve():
    import bisect
    for i in range(1, N):
        a = bisect.bisect_left(dp, -A[i]+0.1) #入れるべき場所
        # print (a)
        if a == len(dp):
            dp.append(-A[i])
        else:
            dp[a] = -A[i]
        # print (dp)
    return len(dp)


print (solve())

Measured memory_bytes: 11036
#include<stdio.h>
int main(){
 int m,n,i,j;
 int N[101][101];
 int S[101];
 int R[101];
 int total;


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


 for(i=0;i<m;i++){

  for(j=0;j<n-1;j++){
   scanf("%d ",&N[i][j]);
  }
   scanf("%d\n",&N[i][n-1]);

 }


 for(i=0;i<m;i++){
  
  S[i]=0;

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

 for(i=0;i<n;i++){
  R[i]=0;

  for(j=0;j<m;j++){
   R[i]+=N[j][i];
  }
 printf("%d ",R[i]);
 }
 
 total=0;

 for(i=0;i<n;i++){
  total+=R[i];
 }
  printf("%d\n",total);



return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
  int n,a;
  cin >> n;
  if( n < 10) {
      a = n;
  }
  else if(n >= 10 && n <100){
      a = 9;
  }
  else if(n >=100 && n <1000){
      a = n - 90;
  }
  else if(n >=1000 && n <10000){
      a = 909;  
  }
  else if(n >= 10000 && n <100000){
      a = n - 9090;
  }
  else if(n == 100000)a = 90909;
  cout << a <<endl;
}



Measured memory_bytes: 256
#include<stdio.h>



void main(){
  int N;
  do{
     scanf("%d", &N);
  }while(N < 2 || N > 100);


  int rabbit[N];

  for(int i = 0; i<N; i++){
    scanf("%d", &rabbit[i]);
  }



  int max = rabbit[0];
  int min = rabbit[0];
  for(int i = 1; i < N; i++){

    if(max < rabbit[i])   max = rabbit[i];
    if(rabbit[i] < min)   min = rabbit[i];
  }


  int tank = max - min;

  printf("%d", tank);

  return;

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string.h>
#include <climits>
#include <algorithm>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int N, M;
int a[1010], b[1010], c[1010];
int d[110][110];

signed main()
{
    cin >> N >> M;

    REP(i,N) REP(j,N) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = INF;
    }

    REP(i,M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
    }

    REP(k,N) REP(i,N) REP(j,N) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int ans = 0;
    REP(i,M) {
        if (d[a[i]][b[i]] < c[i]) ans++;
    }

    cout << ans << endl;
}


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

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	int r[2] = {n, n};
	for(int i = 0; i < n; i++) r[s[i] - '0'] = min(r[s[i] - '0'], max(i, n - 1 - i));
	cout << max(r[0], r[1]) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(all(s));
    s.erase(unique(all(s)),s.end());
    cout << s.size() << endl;
}

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

int main() {
	int n, m; cin >> n >> m;
	int a = m / n;
	for (int i = a; i>0; i--) {
		if (m % i == 0) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
   int n,i,j,k,l;
   int dice[24][6];
   int label[24][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
   {2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},{4,1,5,2,6,3},
   {4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
   {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}};
   
   scanf("%d", &n);
   int dices[n][6];
   
   for(i=0; i<n; i++){
       for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
   }
   
   
   for(i=0; i<n-1; i++){
       for(j=i+1; j<n; j++){
           for(k=0; k<24; k++){
               for(l=0; l<6; l++) dice[k][l]=dices[j][label[k][l]-1];
           }
           for(k=0; k<24; k++){
               for(l=0; l<6; l++) {
                   if(dice[k][l]!=dices[i][l]) {
                       break;
                   }
               }
               if(l==6){
                    printf("No\n");
                    return 0;
               }
           }
       }
   }
   printf("Yes\n");
   return 0;
}




Measured memory_bytes: 2104
n, W = map(int, input().split())

INF = int(1e16)

dp = [[INF] * (int(1e5) + 1) for _ in range(n + 1)]
# dp[i][v] minimum total weight of the first i items that sum value is exactly v

dp[0][0] = 0

for i in range(1, n + 1):
    weight, value = map(int, input().split())
    for v in range(int(1e5) + 1):
        dp[i][v] = min(dp[i-1][v], dp[i][v])
        if v >= value:
            dp[i][v] = min(dp[i][v], dp[i-1][v-value] + weight)

#print(*dp, sep = '\n')

for v in range(int(1e5), -1, -1):
    if dp[n][v] <= W:
        print(v)
        break

Measured memory_bytes: 148680
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();

    if a+b >= c {
        println!("{}", b+c);
    } else {
        println!("{}", a+b+b+1);
    }
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vec a(n);
    init(a);
    print((n - 1 + k - 1 - 1) / (k - 1));

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;

int N;
int A[101];         

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

  	double sum1;
	for (int i = 0; i < N; ++i) {
       sum1 += 1.0 / A[i];
    }  
    double sum2;
    sum2 = 1 / sum1;
    cout << setprecision(16) << sum2;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  map<int, int> c;
  rep(i, 0, n) c[a[i]]++;

  cout << ([&](){
    if(c.size() == 1){
      if(c.begin()->first != 0) return false;
      return true;
    }else if(c.size() == 2){
      if(n%3){
        return false;
      }else{
        bool zero = false, one = false;
        for(auto i : c){
          if(i.first == 0){
            if(i.second != n/3) return false;
            zero = true;
          }else{
            if(i.second != 2*n/3) return false;
            one = true;
          }
        }
        if(!zero or !one) return false;
        return true;
      }
    }else if(c.size() == 3){
      if(n%3){
        return false;
      }else{
        vi v;
        for(auto i : c){
          if(i.second != n/3) return false;
          v.emplace_back(i.first);
        }
        if((v[0] ^ v[1] ^ v[2]) != 0) return false;
        return true;
      }
    }else{
      return false;
    }
  }() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 5632
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int []a = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        scan.close();
        long ans = mergeSort(a, N, 0, N);
        System.out.println(ans);
    }
    static long merge(int []A, int n, int left, int mid, int right) {
    	int i, j, k;
        long cnt = 0;
        int n1 = mid- left;
        int n2 = right - mid;
        int[] L = new int[n1+1];
        int[] R = new int[n2+1];
        for(i = 0; i < n1; i++) {
        	L[i] = A[left + i];
        }
        for(i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
        L[n1] = 2000000000;           
        R[n2] = 2000000000;
        i = 0;
        j = 0;
        for(k = left; k < right; k++) {
            if(L[i] <= R[j]) {
                A[k] = L[i++];
            }else {
                A[k] = R[j++];
                cnt += n1 - i;  // mid + j - k - 1
            }
        }
        return cnt;
    }
    static long mergeSort(int []A, int n, int left, int right) {
        int mid;
        long v1, v2, v3;
        if(left + 1 < right) {
            mid = (left + right) / 2;
            v1 = mergeSort(A, n, left, mid);
            v2 = mergeSort(A, n, mid, right);
            v3 = merge(A, n, left, mid, right);
            return v1 + v2 + v3;
        }else {
            return 0;
        }
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

const int MAX = 2e5+10;

ll N, M, K;
ll A[MAX], B[MAX];

ll solve() {
    vi ruiA(N+1), ruiB(M+1);
    REP (i, N) ruiA[i+1] = ruiA[i] + A[i];
    REP (i, M) ruiB[i+1] = ruiB[i] + B[i];
    ll ret = 0;

    REP (a, N+1) {
        if (ruiA[a] > K) break;
        int ok = 0, ng = M+1;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (ruiA[a] + ruiB[mid] <= K) ok = mid;
            else ng = mid;
        }
        CHMAX(ret, a+ok);
    }

    return ret;
}

int main() {
    cout << fixed << setprecision(15);
    cin >> N >> M >> K;
    REP (i, N) cin >> A[i];
    REP (i, M) cin >> B[i];
    cout << solve() << endl;
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int ans = INF;
    for (int i = 1; i * i <= n; i++)
        if (n % i == 0)
            ans = min(ans, i + n / i - 2);
    cout << ans << endl;
}


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

using namespace std;

template <typename T>
struct segtree{
    int n;
    T UNIT;
    vector<T> dat;
    segtree(int n_, T unit){
        UNIT = unit;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(2*n);
        for(int i = 0; i < 2*n-1; i++) dat[i] = UNIT;
    }

    //これを変更
    T calc(T a, T b){
        T ans = a+b;
        return ans;
    }
    void insert(int k, T a){
        dat[k+n-1] = a;
    }
    void update_all(){
        for(int i = n-2; i >= 0; i--){
            dat[i] = calc(dat[i*2+1], dat[i*2+2]);
        }
    }
    
    void update(int k){
        k += n-1;
        dat[k]++;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = calc(dat[k*2+1], dat[k*2+2]);
        }
    }

    //[a, b)
    //区間[a, b]へのクエリに対してはquery(a, b+1, 0, 0, segtree.n)と呼ぶこと
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return UNIT;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return calc(vl, vr);
        }
    }
};

typedef pair<int, int> P;

int main(){
    int N, M;
    vector<P> sec[100000];
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        sec[r-l].push_back(P(l, r));
    }
    segtree<int> sgtl(M, 0);
    segtree<int> sgtr(M, 0);
    int large_sec = N;
    int narrow_sec = 0;
    for(int i = 1; i <= M; i++){
        int out_sec = 0;
        int narrow_sec_all = 0;
        for(int j = 0; j <= M; j+=i){
            if(j-1 >= 0) out_sec += sgtr.query(0, j, 0, 0, sgtr.n);
            if(j+1 <= M) out_sec += sgtl.query(j+1, M+1, 0, 0, sgtl.n);
            narrow_sec_all += narrow_sec;
        }
        int ans = large_sec+narrow_sec_all-out_sec;
        cout << ans << endl;
        for(int j = 0; j < sec[i-1].size(); j++){
            //cout << sec[i-1][j].first << ' ' << sec[i-1][j].second << endl;
            sgtl.update(sec[i-1][j].first);
            sgtr.update(sec[i-1][j].second);
            narrow_sec++;
            large_sec--;
        }
    }
}

Measured memory_bytes: 11264
a, b, c, d = 4.times.map { gets.to_i }

count = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      count += 1 if i*500 + j*100 + k*50 == d
    end
  end
end

puts count


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define endl "\n" 
#define ll long long 
#define sp " "
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	ll q=1;//cin>>q;
	while(q--){
		int n,a,b(-1),p(0);string s;cin>>n>>s;
		a=n;
		for(int i=0;s[i];i++){
			if(s[i]=='W'){
				a=i;break;
			}
		}
		for(int i=n-1;i>=0;i--){
			if(s[i]=='R'){
				b=i;break;
			}
		}
		for(int i=a;i<=b;i++){
			if(s[i]=='W'){
				for(int j=b;j>=i;j--){
					if(s[j]=='R'){
						p++;b=j-1;
						break;
					}
				}
			}
		}
		cout<<p<<endl;
	}
}


Measured memory_bytes: 3700
def whatIsRight(u,f):	
    r = 0
    if u == 1:
        if f == 2:
            r = 3
        elif f == 3:
            r = 5
        elif f == 4:
            r = 2
        elif f == 5:
            r = 4
	
    elif u == 2:
        if f == 6:
            r = 3
        elif f == 3:
            r = 1
        elif f == 1:
            r = 4
        elif f == 4:
            r = 6

    elif u == 3:
        if f == 5:
            r = 1
        elif f == 1:
            r = 2
        elif f == 2:
            r = 6
        elif f == 6:
            r = 5
			
    elif u == 4:
        if f == 6:
            r = 2
        elif f == 2:
            r = 1
        elif f == 1:
            r = 5
        elif f == 5:
            r = 6 
			
    elif u == 5:
        if f == 3:
            r = 6
        elif f == 6:
            r = 4
        elif f == 4:
            r = 1
        elif f == 1:
            r = 3
		
    elif u == 6:
        if f == 5:
            r = 3
        elif f == 3:
            r = 2
        elif f == 2:
            r = 4
        elif f == 4:
            r = 5
    return r
			
n = list(map(int,input().split()))
N = int(input())

for i in range(N):
    m = list(map(int,input().split()))
    num = []

    for j in range(len(m)):
        for k in range(len(n)):
            if m[j] == n[k]:
                num.append(k+1)
                break
	
    print(n[whatIsRight(num[0],num[1]) -1])

Measured memory_bytes: 7700
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T = long long>
class Union_Find {
  using size_type = std::size_t;
  using _Tp = T;
public:

  vector<_Tp> par;

  const _Tp & operator[] (size_type child) {
    return -par[root(child)];
  }

  Union_Find(size_type n) : par(n, -1) {}
  void init(int n) {
    par.assign(n, -1);
  }

  _Tp root(size_type x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(size_type x, size_type y) {
    return root(x) == root(y);
  }

  bool merge(size_type x, size_type y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  _Tp size(int x) {
    return -par[root(x)];
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(m), b(m);
  vector<int> c(k), d(k);
  vector<vector<int>> friends(n), block(n);

  Union_Find<int> uf_friend(n);
  int t, s;
  rep(i, m) {
    cin >> t >> s;
    t--, s--;
    friends[t].push_back(s);
    friends[s].push_back(t);
    uf_friend.merge(s, t);
  }
  rep(i, k) {
    cin >> t >> s;
    t--, s--;
    block[t].push_back(s);
    block[s].push_back(t);
  }

  rep(i, n) {
    int ans = uf_friend.size(i) - friends[i].size() - 1;
    for (auto it : block[i]) {
      if (uf_friend.issame(it, i)) ans --;
    }
    // cout << ans << " " << uf_friend.size(i) << " " << block[i].size() << endl;
    cout << ans << " ";
  }
}

Measured memory_bytes: 13816
import java.util.*;

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

        int n = sc.nextInt();
        long[] a = new long[n];

        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
        }

        long ans = 0;
        long sum = 0;
        for(int i = 1; i < n; i++){
            sum += a[i - 1];
            sum %= 1000000007;
            ans += (a[i] * sum);
            ans %= 1000000007L;
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 62512
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main() {
	int num[100], max = 0, n;
	for (int w = 0; w < 100; w++) {
		num[w] = 0;
	}
	while (cin >> n) {
		if (n == 0)break;
		num[n - 1]++;
		if (num[n - 1] > max)max = num[n - 1];
	}
	for (int w = 0; w < 100; w++) {
		if (num[w] == max)cout << w + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

bool prime(ll t){
    if(t%5!=1)return false;
    for(ll i=2;i*i<=t;i++){
        if(t%i==0)return false;
    }
    return true;
    
}

int main(){fastio
    ll n;cin>>n;
    vector<ll>ans;
    ll c=0;
    rep(i,10,55555){
        if(prime(i)){
            ans.pb(i);c++;
        }
        if(c==n)break;
    }
    for(auto x:ans)cout<<x<<" ";cout<<endl;
    
    return 0;
}



Measured memory_bytes: 384
from operator import mul
from functools import reduce

from operator import mul
from functools import reduce

N,K=map(int,input().split())

mod=10**9+7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under%mod

for i in range(K):
    if i<N-K+1:
        print((cmb(N-K+1,i+1)*cmb(K-1,i))%mod)
    else:
        print(0)


Measured memory_bytes: 3944
#include<stdio.h>
int main(){
	int n,b,f,r,v,i,j,k;
	int infor[4][3][10]={{{0}}};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		infor[b-1][f-1][r-1]+=v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" ");
				printf("%d",infor[i][j][k]);
				if(k==9){
					printf("\n");
				}
			}
			if(j==2){
				if(i==3){
					break;
				}
				printf("####################\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int h,w;
	cin>>h>>w;
	string s[h];
	rep(i,h)cin>>s[i];
	rep(i,w+2)cout<<'#';
	cout<<endl;
	rep(i,h){
		rep(j,w+2){
			if(j==0 || j==w+1)cout<<'#';
			else cout<<s[i][j-1];
		}
		cout<<endl;
	}
	rep(i,w+2)cout<<'#';
	cout<<endl;
	return 0;
}

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

vector<int> a[100001];
bool visited[100001];
void dfs(int x){
	visited[x]=true;
	fr(i,0,a[x].size())
	if(visited[a[x][i]]==false)
		dfs(a[x][i]);
}
int main(){
	int n,m;
	cin>>n>>m;
	int x,y,z;
	fr(i,0,m){
		cin>>x>>y>>z;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	fr(i,0,n)
	visited[i]=false;

	int cc=0;
	fr(i,1,n+1){
		if(visited[i]==false){
			cc++;
			dfs(i);
		}
	}
	cout<<cc<<endl;


}			

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<ll> d(n);
    ll d_sum = 0;
    ll count = 0;
    rep(i, n){
        d[i] = a[i] - b[i];
        if(d[i] < 0){
            count++;
            d_sum += d[i];
        }
    }

    sort(d.begin(), d.end(), greater<>());
    //rep(i, n) cout << d[i] << endl;
    if(d_sum == 0){
        cout << 0 << endl;
        return 0;
    }
    rep(i, n){
        d_sum += d[i];
        count++;
        //cout << d_sum << endl;
        if(d_sum >= 0){
            cout << count << endl;
            return 0;
        }
    }
    cout << -1 <<  endl;    
}

Measured memory_bytes: 2560
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1<<30)

class Edge{
public:
    int t, w;
    Edge(){}
    Edge(int t, int w):t(t), w(w){}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
    for(int i=0; i<n; i++) d[i] = INFTY;
    queue<int> Q;
    Q.push(s);
    d[s] = 0;
    int u;
    while(!Q.empty()){
        u = Q.front(); Q.pop();
        for(int i=0; i<G[u].size(); i++){
            Edge e = G[u][i];
            if(d[e.t] == INFTY){
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve(){
    // 適当な視点sから最も遠い接点tgtを求める
    bfs(0);

    int maxv = 0;
    int tgt = 0;
    for(int i=0; i<n; i++){
        if(d[i] == INFTY) continue;
        if(maxv < d[i]){
            maxv = d[i];
            tgt = i;
        }
    }

    // tgtから最も遠い接点の距離 maxv を求める
    bfs(tgt);
    maxv = 0;
    for(int i=0; i<n; i++){
        if(d[i]==INFTY) continue;
        maxv = max(maxv, d[i]);
    }

    cout << maxv << endl;
}

int main(int argc, char const *argv[])
{
    int s, t, w;
    cin >> n;

    for(int i=0; i<n-1; i++){
        cin >> s >> t >> w;
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }
    solve();

    return 0;
}



Measured memory_bytes: 9900
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
n = int(input())
k = []
ans = ""
for _ in range(n):
    s = list(str(input()))
    ALs = [0]*26
    for i in range(len(s)):
        ALs[alpha.index(s[i])] += 1
    k.append(ALs)
for i in range(26):
    tmp = float("inf")
    for j in range(n):
        tmp = min(tmp,k[j][i])
    if tmp > 0:
        ans += alpha[i]*tmp
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int main() {
	int n, a, ans;
	scanf("%d %d", &n, &ans);
	rep(i, n-1) {
		scanf("%d", &a);
		ans = gcd(ans, a);
	}
	printf("%d", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
  
	map<int,int> mp;
  rep(i,0,3){
    int a; cin>>a;
    mp[a]++;
  }
  if(mp[5]==2 && mp[7]==1) cout<<"YES";
  else cout<<"NO";

  
	
	return 0;
}

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

int main(){
	
	char str;
	int n[26] = {0};

	while( cin >> str ){
		if( cin.eof() ) break ;
		
		if(str >= 'a'){
			++n[str - 'a'];
		}
		
		else if(str >= 'A'){
			++n[str - 'A'];
		}
		
	}
	
	for(int i = 0; i < 26; ++i){
		
		cout << char('a' + i) << " : " << int(n[i]) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e4+5;
const int maxn = 1e9+5;
const dd eps = 1e-6;
const ll mod = 1e9+7;

struct edge{
  int to,id;
  edge(int to,int id): to(to),id(id){}  
};

vector<edge> p[55];
vector<ll> s;

bool dfs(int u,int v,int fa){
  if(u == v) return true;
  for(auto e:p[u]){
    if(e.to == fa) continue;
    if(dfs(e.to,v,u)){
      s.push_back(e.id);
      return true;
    }
  }
  return false;
}

int n,m,u,v;
ll check[55];

int main(){
  // freopen("input.txt","r",stdin);
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i = 1;i < n;i++){
    cin>>u>>v;
    p[u].emplace_back(v,i);
    p[v].emplace_back(u,i);
  }
  cin>>m;
  for(int i = 1;i <= m;i++){
    cin>>u>>v;
    ll mask = 0;
    s.clear();
    dfs(u,v,-1);
    for(auto now:s){
      check[i] |= 1ll<<(now-1);
    }
  }
  ll ans = (1ll<<(n-1));
  // ll ans = 0;
  for(int i = 1;i < (1<<m);i++){
    ll mask = 0,cnt = 0;
    for(int j = 1;j <= m;j++){
      if(i&(1<<(j-1))) mask |= check[j],cnt++;
    }
    ll white = __builtin_popcountll(mask);
    ll now = 1ll<<(n-1-white);
    if(cnt&1) ans -= now;
    else ans += now;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val inputs: IndexedSeq[String] = scala.io.Source.stdin.getLines().toIndexedSeq
 
  val n = inputs(0).toInt
  val nums = inputs(1).split(" ").map(_.toInt)

  println(solve(n, nums))

  def solve(n: Int, nums: IndexedSeq[Int]): Int = {
    val sortedNums = nums.sorted
    val max = sortedNums(sortedNums.size - 1)
    var divSeq = sortedNums
    // 不要な配列が増えるが、添字で直接処理できるように入力の最大値分のデータを用意
    val results = scala.collection.mutable.IndexedSeq.fill(max + 1)(0)

    (1 to n).foreach { i =>
      // 分母
      val div = divSeq(i-1)

      // <= 1にしてelseなしでも良い
      if(results(div) == 0) {
        Range.inclusive(div, max, div).foreach { j =>
          results.update(j, results(j) + 1)
        }
      } else {
        results.update(div, 2)
      }
    }

    // 入力に関係ない範囲を無視するためにsortedNumsのデータでアクセスしてチェック
    var result = 0
    sortedNums.foreach { v =>
      if (results(v) == 1) {
        result = result + 1
      }
    }
    return result
  }
}

Measured memory_bytes: 86356
#include <bits/stdc++.h>
#define JN ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define mod 1000000007

#define pb push_back
#define mp make_pair

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

int n, m;

vector< vector<int> > adj;

vector<bool> visited;

int dp[100005];


int ans = 0;

void dfs(int v)
{
    

    visited[v]=true;

    int cc=0;
    for(auto u:adj[v])
    {
        if(!visited[u])
        {
            dfs(u);
        }
        
        cc = max(cc, dp[u]+1);

        
    }
    dp[v] = cc;
    ans = max(ans, dp[v]);

}




int main()
{
    JN;

    cin >> n >> m;

    adj.resize(n+1);
    visited.resize(n+1);


    while(m--)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }

    for(int i=1; i<=n; i++)
    {
        if(!visited[i])
            dfs(i);
    }

    cout << ans << "\n";
    
    return 0;

}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<ll> a(n+1);
  rep(i, n + 1) cin >> a[i];
  vector<ll> Lower(n + 1);
  vector<ll> Upper(n + 1);
  Lower[n] = Upper[n] = a[n];
  for (int i = n - 1; i >= 0; i--){
    Lower[i] = a[i] + (Lower[i + 1] + 1) / 2;
    Upper[i] = a[i] + Upper[i + 1];
  }
  if(Lower[0] > 1){
    cout << -1 << endl;
    return 0;
  }
  ll cur = 1;
  ll ans = 0;
  rep(i, n+1){
    ans += cur;
    cur -= a[i];
    cur = min(cur * 2, Upper[i + 1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5700
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = []

for _ in range(m):
    l.append(list(map(int, input().split())))

a.sort()
l.sort(key=lambda x: x[1], reverse=True)

focus = 0
for b, c in l:
    for j in range(focus, min(focus+b, n)):
        a[j] = max(c, a[j])
    focus += b

print(sum(a))


Measured memory_bytes: 82328
def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    A = [a for a, _ in AB]
    B = [b for _, b in AB]
    A.sort()
    B.sort()
    if N & 1:
        return B[N // 2] - A[N // 2] + 1
    return (B[N // 2] + B[N // 2 - 1]) - (A[N // 2] + A[N // 2 - 1]) + 1

print(main())


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

int main() {
    int x;
    cin >> x;
    x /= 200;
    x = 10 - x;
    cout << x << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;

int main(int argc, char** argv) {
	int a, b, c, K;
	scanf("%d%d", &a, &b);
	scanf("%d%d", &c, &K);
	while(K && b <= a) b *= 2, K--;
	while(K && c <= b) c *= 2, K--;
	printf("%s\n", (b > a && c > b) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3732
# coding: utf-8
num = int(input())
target = input()

def next_char(c, n):
    tmp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    new = tmp.find(c) + n
    if new >= 26:
        new -= 26
    return tmp[new]

out = ""
for i in range(len(target)):
    new_char = next_char(target[i], num)
    out = out + new_char

print(out)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0361>
?????????============================================================
?????????????£?????????§??????????????????????????£????????¢???????????¶?????????????????¢????£??????¢?????????????????´??£????????¨????????°????????????????????????
 ??????????????????????¨??????????????????????????????????????????????????????¢??§????¨??????????x ??????????????????y ???????????§????????????
 ???????£?????????????????????????????????§????????£??????????????????????????¨?????????????????????

 ?????????????¨?????????¨?????????????????°????????????????????¨??????
 ?????????????¶?????????¨????????????????????°????±???????????????°????????????????????????
 ?????????????????????????¶??????????????????¨??????????????????????????????????????¨?????????
 
=================================================================

?§£??¬=============================================================

================================================================
*/
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll x,y; cin >> x >> y;
    cout << x + y + 2 - (gcd(x,y) + 1) << endl;
	return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <cstring>
#define nmax 3005
using namespace std;
char s[nmax], t[nmax];
int last[nmax][nmax];
int dp[nmax][nmax];

int main()
{
    int i, j;
    cin >> s + 1 >> t + 1;
    int n = strlen(s + 1);
    int m = strlen(t + 1);

    for (i = 1; i <= n; i++)
        for (j = 1; j <= m; j++) {
            if (s[i] == t[j])
                if (dp[i - 1][j - 1] + 1 > dp[i][j]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    last[i][j] = 1;
                }

            if (dp[i - 1][j] > dp[i][j]) {
                dp[i][j] = dp[i - 1][j];
                last[i][j] = 2;
            }

            if (dp[i][j - 1] > dp[i][j]) {
                dp[i][j] = dp[i][j - 1];
                last[i][j] = 3;
            }
        }
    int k = dp[n][m] - 1;
    i = n; j = m;
    char sol[nmax] = {0};
    while (k >= 0) {

        if (last[i][j] == 1)
            sol[k --] = s[i], i--, j--;
        else
            if (last[i][j] == 2)
                i--;
            else
                j--;
    }
    cout << sol << '\n';
    
    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n;
std::cin >> n;
std::vector<int> s(8,0);
int f = 0;
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    if(temp < 400){
        s[0]++;
    } else if(temp < 800){
        s[1]++;
    } else if(temp < 1200){
        s[2]++;
    } else if(temp < 1600){
        s[3]++;
    } else if(temp < 2000){
        s[4]++;
    } else if(temp < 2400){
        s[5]++;
    } else if(temp < 2800){
        s[6]++;
    } else if(temp < 3200){
        s[7]++;
    } else {
        f++;
    }
}
int sum = 0;
for(int i = 0; i < 8; i++){
    if(s[i] > 0){
        sum++;
    }
}
std::cout << max(sum,(int)1) << " " << sum + f << std::endl;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
string s[3];
int This=0,Next=0;
int main()
{
	cin>>s[0]>>s[1]>>s[2];
	while(s[Next].size())
    {
        This=Next;
        Next=s[This][0]-'a';
        s[This].erase(0,1);
    }
    printf("%c",'A'+Next);
}


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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n / 2 << endl;
    }else{
        cout << n / 2 + 1 << endl;
    }
}

Measured memory_bytes: 256
import bisect
n=int(input())
s=list(str(input()))
cnt=0
index={}
for i in range(n):
  v=s[i]
  if v not in index.keys():
    index[v]=[]
  index[v].append(i)
for i in range(1000):
  i_str='0'*(3-len(str(i)))+str(i)
  x,y,z=i_str[0],i_str[1],i_str[2]
  if x in index.keys() and y in index.keys() and z in index.keys():
    a=index[x][0]
    v=bisect.bisect_left(index[y],a+1)
    if v<len(index[y]):
      b=index[y][v]
      if b<=a or b>=n:
        pass
      else:
        v=bisect.bisect_left(index[z],b+1)
        if v<len(index[z]):
          c=index[z][v]
          if c<=b or c>=n:
            pass
          else:
            cnt+=1
print(cnt)

Measured memory_bytes: 4596
use std::io;

fn main() -> io::Result<()>{
    let mut buf = String::new();
    let mut stdin = io::stdin();

    stdin.read_line(&mut buf)?;
    buf.retain(|c| c!='\n');
    
    let times : usize = buf.parse().unwrap();
    for _ in 0..times{
	print!("ACL");
    }
    println!();    
    Ok(())
}


Measured memory_bytes: 2152
#include <stdio.h>

int main(){
	int a,b;
	int i;
	char c;

	while(1){
		scanf("%d %c %d",&a,&c,&b);
		if(c == '+')
			printf("%d\n",a+b);
		else if(c == '-')
			printf("%d\n",a-b);
		else if(c == '*')
			printf("%d\n",a*b);
		else if(c == '/')
			printf("%d\n",a/b);
		else if(c == '?')
			break;
	}

	return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG

#include "iostream"
#include "vector"
#include "numeric"

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    
    ll n;
    cin >> n;

    vector<ll> b;
    REP(i,n-1){
        ll tmp;
        cin >> tmp;
        b.push_back(tmp);
    }
    b.push_back(b[n-2]);
    //cout << b[n-1] << endl;

    
    ll total=0;//b[n-1];
    vector<ll> a;
    a.push_back(b[0]);
    for(ll i=n-2; i>=0; i--){
        ll MIN = min(b[i],b[i+1]);
        a.push_back(MIN);
        //total += MIN;
        //cout << total << endl;
    }
    total = accumulate(a.begin(),a.end(),0);
    cout << total << endl;
    
    return 0;

}

Measured memory_bytes: 3596
#include <iostream>
#include <set>
#include <string>
using namespace std;


int main() {

	int N, M;
	cin >> N >> M;

	int A[55] = {};
	int B[55] = {};

	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}
	
	int bucket[55] = {};

	for (int i = 0; i < M; i++) {
		bucket[A[i] -1] ++;
		bucket[B[i] -1] ++;
	}

	for (int i = 0; i < N; i++) {
		cout << bucket[i] << '\n';
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>

using namespace std;



int main() {
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n+1);
	vector<int> b(m+1);

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

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

	long long sum = 0;
	vector<long long> c(m+1);

	for (int i = 1; i <= m;i++) {
		sum += b[i];
		c[i] = sum;
	}

	int ans = 0;
	long long tmp = k;

	for (int i = 0;i <= n;i++) {
		
		tmp -= a[i];
		if (tmp < 0) {
			break;
		}

		auto Iter = upper_bound(c.begin(), c.end(), tmp);
		if (Iter <= c.end()) {
			int j = (Iter - c.begin());
			ans = max(ans, j + i - 1);
		}
		
		
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6340
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

def gcd(x, y):
    if x <= y:
        x, y = y, x
    if y == 1:
        return 1
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

res_1 = 0
for i in range(n-1):
    if i == 0:
        res_1 = gcd(a[i], a[i+1])
    else:
        res_1 = min(gcd(a[i], a[i+1]), res_1)

print(res_1)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2e5+5;
const long long inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){  
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}


void solve(){
	
	ll a,b;
	cin>>a>>b;
	ll ans=a*b;
	cout<<ans<<endl;
	
	return;
}

 
int main(){ 
    
    #ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	
	
	return 0;
	
}

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

int main() 
{
   string s,t;
   cin>>s;
   cin>>t;
   long int n=s.length();
   long int i,count=0;
   for(i=0;i<n;i++)
   {
     if(s[i]!=t[i])
     count++;
   }
   cout<<count<<endl;
}

Measured memory_bytes: 3904