akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class UF {
private:
    int sz; vector<int> par,nrank;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz); rep(i,sz){ par[i] = i; nrank[i] = 0; } }
    int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } }
    void unite(int x,int y)
    { x = find(x),y = find(y); if(x == y) return;
    	if(nrank[x] < nrank[y]){ par[x] = y; }else{ par[y] = x; if(nrank[x] == nrank[y]) nrank[x]++; } }
    bool same(int x,int y){ return find(x) == find(y); }
};

struct edge
{
    int from,to;
    ll cost;
    bool operator< (const edge& another) const {
        return cost < another.cost;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,K;
    cin >> n >> m >> K;
    vi c(n);
    int id = K;
    rep(i,n){
        cin >> c[i];
        if(c[i] == 0){
            c[i] = id++;
        }else{
            --c[i];
        }
    }
    UF uf(n+K);
    vector<edge> w(m);
    rep(i,m){
        int a,b,d;
        cin >> a >> b >> d;
        --a,--b;
        w[i] = (edge){c[a],c[b],d};
    }
    sort(all(w));
    set<int> st;
    int hen = 0;
    ll ans = 0;
    rep(i,m){
        edge& e = w[i];
        int a = w[i].from, b = w[i].to;
        if(!uf.same(a,b)){
            uf.unite(a,b);
            hen++;
            ans += w[i].cost;
        }
        if(hen == K-1){
            break;
        }
    }
    if(hen == K-1){
        cout << ans << "\n";
    }else{
        cout << "-1\n";
    }
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double a, b;
    cin >> a >> b;
    long double s = a * b;
    cout << (ll)s << endl;    
    return 0;
}


Measured memory_bytes: 3748
N,Y = (int(i) for i in input().split())

x = -1
y = -1
z = -1
for i in range(N+1):
    for j in range(N+1):
        money = Y - 10000*i - 5000*j - 1000*(N-i-j)
        if (N-i-j)>=0 and money == 0:
            x = i
            y = j
            z = N-i-j
            break

print(x,y,z)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    map<string,int> S;
    rep(i,n){
        string s; cin>>s;
        S[s]=0;
    }
    cout<<S.size()<<endl;
}

Measured memory_bytes: 19256
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;



void solve() {
	int a, b;
	cin >> a >> b;
	if(a > b) swap(a, b);
	string t(b, a + '0');
	cout << t << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 


Measured memory_bytes: 3668
// AOJ
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_C

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;

// change min/max
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> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

#define MAX 100001
const int NIL = -1;
struct Node { int parent = NIL, left = NIL, right = NIL; };
Node node[MAX];


int getSib(int currentNb) {
    const int nbParent = node[currentNb].parent;
    if (nbParent == NIL) return NIL;
    if (node[nbParent].left != currentNb) {
        return node[nbParent].left;
    }
    else {
        return node[nbParent].right;
    }
}

int getDegree(int currentNode) {
    int cnt = 0;
    if (node[currentNode].left != NIL) ++cnt;
    if (node[currentNode].right != NIL) ++cnt;
    return cnt;
}

string nodeType(int currentNb) {
    if (node[currentNb].parent == NIL) return "root";
    if (getDegree(currentNb) == 0) return "leaf";
    return "internal node";
}

void preParse(int nbNode) {
    // if (nbNode == NIL) return;
    cout << " " << nbNode;
    if (node[nbNode].left  != NIL) preParse(node[nbNode].left);
    if (node[nbNode].right != NIL) preParse(node[nbNode].right);
}

void intParse(int nbNode) {
    if (node[nbNode].left != NIL) intParse(node[nbNode].left);
    cout << " " << nbNode;
    if (node[nbNode].right != NIL) intParse(node[nbNode].right);
}

void postParse(int nbNode) {
    if (node[nbNode].left != NIL) postParse(node[nbNode].left);
    if (node[nbNode].right != NIL) postParse(node[nbNode].right);
    cout << " " << nbNode;
}


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

    int n; cin >> n;
    rep(i, n) {
        int nbNode;  cin >> nbNode;
        int nbLeft;  cin >> nbLeft;
        int nbRight; cin >> nbRight;
        node[nbNode].left = nbLeft;  node[nbLeft].parent = nbNode;
        node[nbNode].right = nbRight; node[nbRight].parent = nbNode;
    }

    // find the root
    int root;
    rep(i, n) {
        if (node[i].parent == NIL) root = i;
    }

    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;
    cout << "Inorder" << endl;
    intParse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;

    return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;

int main(){
    int n;
    int count[9]={};
    int all=0;
    int a=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >> a;
        for(int j=1;j<=8;j++){
            if(a<400*j && a>=400*(j-1))count[j-1]=1;
        }
        if(a>=3200)all++;
    }
    int ans_max=0;
    int ans_min=0;
    for(int i=0;i<=7;i++){
        if(count[i]>0)ans_min++;
    }
    ans_max=ans_min+all;
    if(n==all)ans_min=1;

    cout<<ans_min<<" "<<ans_max<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  ll x[n+1],y[n+1],z[n+1];
  for(int i=1;i<=n;i++){
    cin>>x[i]>>y[i]>>z[i];
  }
  int a[2]={1,-1};
  int b[2]={1,-1};
  int c[2]={1,-1};
  ll ans=0;
  for(int i=0;i<=1;i++){
    for(int j=0;j<=1;j++){
      for(int k=0;k<=1;k++){
        ll tmp=0;
        vector<ll> w;
        for(int l=1;l<=n;l++){
          w.push_back(x[l]*a[i]+y[l]*b[j]+z[l]*c[k]);
        }
        sort(w.begin(),w.end());
        ll mi=0,ma=0;
        for(int l=0;l<m;l++){
          mi+=w[l];
        }
        for(int l=n-1;l>=n-m;l--){
          ma+=w[l];
        }
        ans=max(ans,max(abs(mi),abs(ma)));
        /*for(int l=1;l<=n;l++){
          tmp=tmp+a[i]*x[l]+b[j]*y[l]+c[k]*z[l];
        }
        ans=max(ans,abs(tmp));*/
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> map = new HashMap<String, Integer>();
		String w = sc.next();
		for (int i = 0; i < w.length(); i++) {
			if (map.containsKey(String.valueOf(w.charAt(i)))) {
				map.put(String.valueOf(w.charAt(i)), map.get(String.valueOf(w.charAt(i))) + 1);
			} else {
				map.put(String.valueOf(w.charAt(i)), 1);
			}
		}
		Iterator<Map.Entry<String, Integer>> itr = map.entrySet().iterator();
		while (itr.hasNext()) {
			// nextを使用して値を取得する
			Map.Entry<String, Integer> entry = itr.next();
			if (entry.getValue() % 2 != 0) {
				System.out.println("No");
				return;
			}

		}
		System.out.println("Yes");
	}

}


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

int main(){
  int n, x, y;
  cin >> n;
  vector<pair<int, int>> p(n);
  for(int i = 0; i < n; i++){
    cin >> x >> y;
    p[i] = make_pair(x, y);
  }
  sort(p.begin(), p.end());
  for(int i = 0; i < n; i++){
    cout << p[i].first << " " << p[i].second << endl;
  }
  return 0;
}


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

int func(int64_t a){
    int ad;
    if(a<10) ad = 1;
    else if(a<100) ad = 2;
    else if(a<1000) ad = 3;
    else if(a<10000) ad = 4;
    else if(a<100000) ad = 5;
    else if(a<1000000) ad = 6;
    else if(a<10000000) ad = 7;
    else if(a<100000000) ad = 8;
    else if(a<1000000000) ad = 9;
    else if(a<10000000000) ad = 10;
    else ad = 11;
    return ad;
}

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

    int ans = 100;
    for (int64_t i = 1; i <= sqrt(N)+1; i++)
    {
        if(N%i == 0){
            int64_t A = i;
            int64_t B = N/i;
            int digit = func(max(A, B));
            if(digit < ans) ans = digit;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int c = 0;
    for (int i = 2; i < s.size() - 1; i++) {
        if (s[i] == 'C') {
            c++;
        }
    }
    if (c != 1) {
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || (s[i] >= 'a' && s[i] <= 'z')) {

        } else {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,k,a[N];
ll ans,sum,s1[N],s2[N];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s1[i]=s1[i-1]+a[i];
		s2[i]=s2[i-1]+max(a[i],0);
	}
	for (int i=1;i<=n-k+1;i++) ans=max(ans,s2[n]-s2[i+k-1]+s2[i-1]+max(s1[i+k-1]-s1[i-1],0ll));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(d==1) cout<<1<<endl;//保证 
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a, b;
	int count[5] = { 0 };
	for (int i = 0; i < 3; i++) {
		cin >> a >> b;
		count[a]++;
		count[b]++;
	}
	if (count[1] == 1 && count[2] != 3 && count[3] != 3 && count[4] != 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    vector<vector<double>> dp(N+1, vector<double> (M+2,0));
    double s = 0;
    for(int i=0; i<N; i++){
        s += A[i];
        dp[i+1][1] = s/(i+1);
    }
    for(int i=1; i<N; i++){
        for(int j=1; j<M; j++){
            if(dp[i][j] == 0) break;
            double sum = 0;
            for(int k=i+1; k<=N; k++){
                sum += A[k-1];
                chmax(dp[k][j+1],dp[i][j]+sum/(k-i));
            }
        }
    }
    // for(int i=0; i<=N; i++){
    //     for(int j=0; j<=M; j++){
    //         cout << dp[i][j] << " \n"[j==M];
    //     }
    // }
    cout << fixed << setprecision(10) << dp[N][M] << "\n";
    return 0;
}



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

int main() {
	string W;
	int num = 0;
	cin >> W;

	while (1) {
		string T;
		cin >> T;

		if (T == "END_OF_TEXT")
			break;

		for (int i = 0; i < T.size(); i++)
			if (T[i] <= 'Z' && T[i] >= 'A')
				T[i] = T[i] + 32;

		if (T == W)
			num++;

	}

	cout << num << endl;
}

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

int main(){

	string A, B, C;
	cin >> A >> B >> C;
	size_t Alen = A.length();
	size_t Blen = B.length();
	size_t Clen = C.length();

	string Alast = A.substr(Alen-1,1);
	string Bfirst = B.substr(0,1);
	string Blast = B.substr(Blen -1, 1);
	string Cfirst = C.substr(0,1);

	if(Alast == Bfirst && Blast == Cfirst){
		cout << "YES"<< endl;
	}
	else{cout << "NO" << endl;}


}

Measured memory_bytes: 256
#include <iostream>

using lint = long long;

void solve() {
    lint n, a, b;
    std::cin >> n >> a >> b;

    lint ans = n / (a + b) * a;
    n %= a + b;
    ans += std::min(a, n);

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        a: [[Usize1; m]; n]
    }

    let mut nums = vec![0; m];
    for i in 0..n {
        nums[a[i][0]] += 1;
    }

    let mut curs = vec![0; n];
    let mut removed = HashSet::new();
    let mut ans = n;
    for k in 0..m {
        let mut most = 0;
        let mut mm = m;
        for (i, &num) in (0..).zip(&nums) {
            if num > most {
                most = num;
                mm = i;
            }
        }
        removed.insert(mm);
        nums[mm] = 0;
        ans = min(ans, most);
        if k == m-1 {
            break;
        }
        for i in 0..n {
            if a[i][curs[i]] == mm {
                curs[i] += 1;
                while removed.contains(&a[i][curs[i]]) {
                    curs[i] += 1;
                }
                nums[a[i][curs[i]]] += 1;
            }
        }
    }
    println!("{}", ans);
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2;
}


Measured memory_bytes: 764
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
st = set(s+t)
ans = -10000

for i in st:
    count = 0
    for j in s:
        if i == j:
            count += 1
    for j in t:
        if i == j:
            count -= 1
    ans = max(ans, count)

if ans > 0:
    print(ans)
else:
    print(0)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int a,b,c,d,e;
	d=0;
	e=2;
	scanf("%d %d %d",&a,&b,&c);
	if(b<=c){
		d=d+2;
		b=c;
	}else{
		d=d+1;
	}
	while(a>e){
		int x;
		scanf("%d",&x);
		if(b<=x){
			d=d+1;
			b=x;
		}
		e=e+1;
	}
	printf("%d",d);
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

string s;

bool ok(int b, int e){
  bool f = b < e;
  for(int i = b; i < e; ++i){
    f &= (s[i] == 'A'||s[i] == 'G'||s[i] == 'C'||s[i] == 'T');
  }
  return f;
}

int main(){
  cin >> s;
  int n = (int)s.size();
  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(ok(i,n-j))ChangeMax(ans,n-j-i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
i = 0
ans = 0

while i < n and len(v) >= 2:
	v.sort()
	f = v.pop(0)
	s = v.pop(0)
	ans = (s+f)/2
	v.append(ans)
	i += 1

print(ans)




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

int main(){
  int a, b, c, i = 1;
  double d;
  cin >> a >> b;
  c = b;
  while(c){
    c /= 10;
    i *= 10;
  }
  c = a*i + b;
  for(int i = 1; i*i <= c; i++){
    if(i*i == c){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a;
  cin >> a;
  if (isupper(a))
  {
    cout << 'A' <<endl;
  }else
  {
    cout << 'a' << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3592
from operator import itemgetter
n=int(input())
A=[tuple(map(int,input().split())) for i in range(n)]
B=[tuple(map(int,input().split())) for j in range(n)]
A.sort()
B.sort()
count=0
for i in range(n):
    box=[A[j] for j in range(len(A)) if (A[j][0]<B[i][0]) and (A[j][1]<B[i][1])]
    if any(box):
        box=sorted(box, key=itemgetter(1))
        A.remove(box[-1])
        count +=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main(){
  lint X,Y,check,cont=1;
  cin>>X>>Y;
  check=X;

  while(2*check<=Y){
    cont++;
    check*=2;
  }

  cout<<cont<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    //cout<<"Hello World!";
    string s;
    cin>>s;
    int n = s.length();
    bool flag = true;
    for(int i=0;i<n;i++)
    {
        if(i%2==0 && s[i]=='L')
        {
            flag=false;
            break;
        }
        if(i%2==1 && s[i]=='R')
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
# 多分TLE
from scipy.sparse.csgraph import dijkstra
from itertools import combinations

N = int(input())
edge_id = {}
D = [[-float('inf')]*N for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  D[a-1][b-1] = D[b-1][a-1] = 1
  edge_id[(a-1, b-1)] = i
  edge_id[(b-1, a-1)] = i

paths = dijkstra(D, return_predecessors=True)[1]
M = int(input())
edges = [0] * M
for i in range(M):
  u, v = map(int, input().split())
  now, p = paths[u-1][v-1], v-1
  edges[i] += 1 << edge_id[(now, p)]
  while now != u-1:
    now, p = paths[u-1][now], now
    edges[i] += 1 << edge_id[(now, p)]

ans = pow(2, N-1)
coeff = -1
for m in range(1, M+1):
  for comb in combinations(edges, m):
    e = 0
    for c in comb:
      e |= c
    ans +=  coeff* pow(2, N-1-bin(e).count('1'))
  coeff *= -1

print(ans)

Measured memory_bytes: 15836
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[100005]= {0},c[100005]= {0};
    char b[100005];
    scanf("%s",b);
    int l=strlen(b);
    for(int i=0; i<l; i++)
    {
        a[i]+=1;
        if(b[i]=='R'&&b[i+1]=='R')
        {
            a[i+1]+=a[i];
            a[i]=0;
        }
    }
    for(int i=l-1; i>=0; i--)
        if(b[i]=='L'&&b[i-1]=='L')
        {
            a[i-1]+=a[i];
            a[i]=0;
        }
    for(int i=0; i<l; i++)
    {
        if(a[i]==0) continue;
        if(a[i]==1)
        {
            c[i]+=1;
            continue;
        }
         if(b[i]=='L')
        {
            c[i-1]+=a[i]/2;
            c[i]+=a[i]-a[i]/2;
        }
        if(b[i]=='R')
        {
            c[i]+=a[i]-a[i]/2;
            c[i+1]+=a[i]/2;
        }
    }
    for(int i=0; i<l-1; i++)
        printf("%d ",c[i]);
    printf("%d\n",c[l-1]);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define endl "\n"
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define mod (ll)(1e9+7)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define F first
#define S second
#define PB push_back
#define pb pop_back()
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a,b) for(int i=a;i>=b;i--)
#define MAX 500002
#define MOD 1000003
#define EPS 1e-6
#define PI 3.1415926535
using namespace std;

typedef long long ll;
typedef unsigned long long ull ;
typedef vector<int> vi;
typedef pair<int,int> pi;


int main(){
    ENGZ
    string s[3] = {"Sunny", "Cloudy", "Rainy"} , x;
    cin >> x ;
    REP(i,0,3){
        if(x==s[i]){
            cout << s[(i+1)%3] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ld> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    ld l=0, r=a[n-1];
    while(r-l > 0.0000001){
        ld mid = (r+l)/2;
        ll cut_count=0;
        rep(i,n){
            cut_count += int(a[i]/mid);
        }
        if(cut_count <= k){
            r = mid;
        }else{
            l = mid;
        }
    }
    // cout << l << " " << r << endl;
    ll ans = (ll)ceil(l);
    cout << ans << endl;
}



Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    int k;
    cin >> k;
    unsigned long int p = 10;
    unsigned long int L = 7;
    for(int i = 1; i < 100000000; ++i){
        if(L % k == 0){
            cout << i << endl;
            return 0;
        }

        L += (unsigned long int)7 * p;
        L %= k;
        p *= (unsigned long int)10;
        p %= k;
    }

    cout << -1 << endl;

    return 0;
}

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

int main(){
  string b;
  cin>>b;
  if(b=="A") cout<<"T"<<endl;
  else if(b=="T") cout<<"A"<<endl;
  else if(b=="C") cout<<"G"<<endl;
  else if(b=="G") cout<<"C"<<endl;

  return(0);
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    string s;
    cin>>s;
    int a[26]={};
    for(int i=0;i<s.size();i++){
        a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(a[i]==0){
            printf("%c\n",'a'+i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
    using namespace std;
     
    int main() {
	int h,w;
	while(1){
		cin>> h >> w;
		if(h == 0 && w == 0){
			break;
		}
	for (int j=0; j<h ; j++){
		for (int i=0; i<w ; i++){
			cout<< "#";
		};
		cout << endl;
	};
	cout << endl;
	}
    return 0;
    }

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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;}
 
int w,h;
int island[200][200];
int c=0;
bool searched[200][200];

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

void search(int x,int y){ 
  searched[x][y] = true;
  //island[i][j]==1?????????
  REP(i,8){
	int nx=x+dx[i]; int ny=y+dy[i];
	if(nx<0||ny<0||nx>h-1||ny>w-1) continue;
	//cout << nx << " " << ny << endl;
	if(island[nx][ny]&&searched[nx][ny]==false){
	  search(nx,ny);
	}
  }
}

int main(){

  while(1){
	c = 0;
	cin >> w >> h;

	if(w==0&&h==0) break;
	REP(i,h){
	  REP(j,w){
		searched[i][j] = false;
		cin >> island[i][j];
	  }
	}

	REP(i,h){
	  REP(j,w){
		if(island[i][j]&&searched[i][j]==false){
		  search(i,j);
		  c++;
		}

	  }}

	cout << c <<endl;

  }


}

Measured memory_bytes: 1284
#create date: 2020-08-11 09:28

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a, _ = na()
    b, _ = na()
    print(b-a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9120
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)..., (os << '\n', 0)}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__)
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Run() {
	int x;
	cin>>x;

	ll ans = 0;

	ans += x/500 * 1000;
	x %= 500;
	ans += x/5 * 5;
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	cin.exceptions(cin.failbit);
	cerr << fixed << setprecision(10);
	assert(freopen("./io/test.in", "r", stdin));
	// assert(freopen("./io/test.out", "w", stdout));
#endif

	Run();
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
// 1.素数であるか → 回答：$n-1 → x
// 2.素因数分解？ → x
// x <= √N で最小値を全探索 → o
$pattern = [];
$x = 1;
while ($x <= sqrt($n)) {
    if ($n % $x == 0) {
		$y = $n / $x;
    	$pattern[] = $x + $y -2;
    }
    $x++;
}
sort($pattern);
echo $pattern[0];

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<int> A(M), B(M);
  vector<ll> C(M);
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %lld", &A[i], &B[i], &C[i]);
  }

  ll LLMIN = -1 * LLINF;
  vector<ll> dist(N + 1, LLMIN);
  dist[1] = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = 0; j < M; ++j) {
      int u = A[j], v = B[j];
      ll cost = C[j];
      if (dist[u] > LLMIN) {
        dist[v] = max(dist[v], dist[u] + cost);
      }
    }
  }

  ll ans = dist[N];
  for (int i = 0; i < N - 1; ++i) {
    for (int j = 0; j < M; ++j) {
      int u = A[j], v = B[j];
      ll cost = C[j];
      if (dist[u] > LLMIN) {
        dist[v] = max(dist[v], dist[u] + cost);
      }
    }
  }
  if (dist[N] > ans) { printf("inf\n"); }
  else { printf("%lld\n", ans); }
  return 0;
}


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



int main() {
    int n, l;
    cin >> n >> l;
    
    int mn = 1000, sum = 0;
    rep(i,n) {
        int t = i + l;
        sum += t;
        mn = min(abs(t),abs(mn));
        if(t < 0)
            mn *= -1;
    }
    
    cout << sum - mn << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
int main(){
	long long int a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	long long int x=a;
	if(x<b)x=b;
	if(x<c)x=c;
	long long int y=a+b+c-x;
	for(int i=0;i<k;i++){
		x=x*2;
	}
	printf("%lld\n",x+y);
	return 0;
}


Measured memory_bytes: 128
use std::process;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn combination(d:Vec<i32>) -> Vec<Vec<i32>> {
    let mut com : Vec<Vec<i32>> = vec![];
    for i in 0..d.len() {
        for j in i+1..d.len(){
            com.push(vec![d[i],d[j]]);
        }
    }
    com
}

fn main() {
    input!{
        n: usize, 
        d: [i32; n],
    }   
    let com = combination(d);
    let mut sum = 0; 

    for i in com {
        sum += i[0]*i[1];
    }

    println!("{}", sum);

    
}


Measured memory_bytes: 4352
x1,x2,x3,x4,x5 = map(int,input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)

Measured memory_bytes: 9120
use std::io;
use std::cmp;

fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {

    let mut num = read::<usize>();
    num.sort();

    let d_a = num[2] - num[1];
    let d_b = num[2] - num[0];

    match ((d_a % 2 == 0), (d_b % 2 == 0)) {
        (true, true) => println!("{}", (d_a + d_b) / 2),
        (false, false) => {
            let d_a = d_a - 1;
            let d_b = d_b - 1;
            println!("{}", 1 + (d_a + d_b) / 2);
        },
        (false, true) => {
            let d_a = d_a + 1;
            println!("{}", 1 + (d_a + d_b) / 2);
        },
        (true, false) => {
             let d_b = d_b + 1;
            println!("{}", 1 + (d_a + d_b) / 2);
        }
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>

void ssort(int* a,int n){
	
	int minj,x,flag=0,cnt=0;
	
	for(int i=0;i<n;i++){
		minj=i;
		for(int j=i;j<n;j++){
			if(a[j]<a[minj]){
				minj=j;
				flag=1;
			}
		}
		x=a[i];
		a[i]=a[minj];
		a[minj]=x;
		if(flag==1)cnt++;
		flag=0;
	}
	for(int i=0;i<n;i++){
		printf("%d",a[i]);
		if(i!=n-1) printf(" ");
	}
	printf("\n");
	printf("%d\n",cnt);
}

int main(void){
	
	int n;
	int* a=(int*)malloc(sizeof(int)*n);
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	ssort(a,n);
	
}


Measured memory_bytes: 2092
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    bool array[52] = {false};
    char char_array[4] = {'S', 'H', 'C', 'D'};
    //s,h,c,d
    
    int  num;
    char let;
    
    for(int i=0; i<n; ++i){
        cin >> let >> num;
        if      (let == 'S') array[0*13 + num - 1] = true;
        else if (let == 'H') array[1*13 + num - 1] = true;
        else if (let == 'C') array[2*13 + num - 1] = true;
        else if (let == 'D') array[3*13 + num - 1] = true;
    }
    
    for(int i=0; i<52; ++i){
        if (array[i]==false){
            cout << char_array[i/13] << " " << (i%13) + 1 << endl;
        }
    }
    
    return 0;
}


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

int main(){
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	int res = 0;
	for(int i=0; i<=n; i++){
		for (int j=0; j<=n; j++){
			if (r*i + g*j <= n){
				if ((n-(r*i + g*j)) % b==0){
					res += 1;
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin>>n;

	vector<int> a(n);

	loop(i,n)
	{
		cin>>a[i];
	}

	cout<<*max_element(all(a)) - *min_element(all(a))<<endl;


}


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

using namespace std;

const int MAX_N = 100005;

int n;

int main()
{
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> v(n);
        for(int i=0;i<n;i++){
            cin >> v[i];
        }
        vector<char> vec;
        string s;
        cin >> s;
        for(int i=0;i<26;i++){
            vec.push_back((char)('a'+i));
        }
        for(int i=0;i<26;i++){
            vec.push_back((char)('A'+i));
        }
        for(int i=0;i<s.length();i++){
            int cnt;
            for(int j=0;j<52;j++){
                if(s[i] == vec[j]){
                    cnt = j;
                    break;
                }
            }
            cout << vec[(cnt+52-v[i%n])%52];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 3196
#include<stdio.h>
#include<math.h>
main()
{
	int a = 0, b = 0;
	while(scanf("%d %d", &a, &b) != EOF)
	{
		int sum = 0, n = 0;
		sum = a + b;
		n = log10(sum);
		n++;
		printf("%d\n", n);
	}
	return 0;
}

Measured memory_bytes: 644
def read_values():
    return map(int, input().split())
 
 
def read_list():
    return list(read_values())

def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
  
    u = {}
    for a in A:
      m = 2
      while m * m <= a:
        c = 0
        while a % m == 0:
          c += 1
          a //= m
        if c > 0:
          u[m] = max(u.get(m, 0), c)
        m += 1
      if a > 1:
        u[a] = max(u.get(a, 0), 1)

    lcm = 1
    for k, v in u.items():
      lcm *= pow(k, v, mod)
      lcm %= mod

    ans = 0
    for a in A:
      ans += lcm * pow(a, mod-2, mod)
      ans %= mod

    print(ans)

if __name__ == "__main__":
  main()

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll x, n; cin >> x >> n;
    vll p(n);
    rep(i, n) cin >> p[i];

    ll tmp1 = x;
    ll tmp2 = x;
    bool f1, f2;
    while(1){
        f1 = true;
        f2 = true;
        rep(i, n){
            if(p[i] == tmp1){
                f1 = false;
                break;
            }
        }
        rep(i, n){
            if(p[i] == tmp2){
                f2 = false;
                break;
            }
        }

        if(f1||f2) break;
        tmp1++;
        tmp2--;
    }

    if(f1&&f2){
        cout << (tmp1<tmp2?tmp1:tmp2) << endl;
    }
    else{
        if(f1){
            cout << tmp1 << endl;
        }
        else{
            cout << tmp2 << endl;
        }
    }


    

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int main(void){
    int x;
    cin >> x;
    while(true){
        int w=0;
        int low = sqrt(x);
        for(int i=2;i<=low;i++){
            if(x%i==0){
                w++;
                break;
            }
        }
        if(w==0){
            break;
        }
        x++;
    }

    cout << x << endl;
	return 0;
}


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

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

    bool flag = false;
    for (int i=0; i < N; i++) {
        string color;
        cin >> color;
        if (color == "Y") {
            flag = true;
            break;
        }
    }

    if(flag) cout << "Four" << endl;
    else     cout << "Three" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,kind,i,j,k;
    for(;;){
        int ice[11]={0,0,0,0,0,0,0,0,0,0,0};
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++){
            scanf("%d",&kind);
            ice[kind]++;
        }
        for(j=0;j<10;j++){
            for(k=0;k<ice[j];k++){
                if(ice[j]==0)printf("-\n");
                else if(ice[j]>0)printf("*");
            }
            if(ice[j]==0){
                printf("-\n");
                    continue;
            }
            printf("\n");
        }
    }
return 0;
}

Measured memory_bytes: 572
n = 3
c = []
for i in range(n):
    tmp = [int(num) for num in input().split()]
    c.append(tmp)

a = []
b = []

a.append(0)
for i in range(n):
    b.append(c[0][i] - a[0])
#print(b)
for i in range(1, n):
    a.append(c[i][0] - b[0])
#print(a)

ans = True
for i in range(n):
    for j in range(n):
        if(c[i][j] != (a[i] + b[j])):
            ans = False

if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>

using namespace std;

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

	vector<long long> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long x = accumulate(a.begin(), a.end(), 0LL);
	long long y = 0;
	long long ans = 1LL << 60;
	for (int i = 0; i < n - 1; i++) {
		x -= a[i];
		y += a[i];
		ans = min(ans, abs(x - y));
	}

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


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

using namespace std;
typedef long long ll;

int main(int, char**)
{
	int n[100];
	int a, b, k, ans = 0;
	cin >> a >> b >> k;

	int c = max(a, b);
	
	for (int i = 1; i <= c; i++) {
		if ((a % i == 0)&&(b%i==0)) {
			n[ans] = i;
			ans++;
		}
	}

	cout <<  n[ans - k] << endl;
	return 0;
}


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

bool flag = false;

/*
A:答えの配列
N:答えの文字列の長さ
max_:いままで出てきた数字の種類
vn:一個前に出た数字
*/
void dfs(vector<int> &A, int N, int max_, int vn) {
    if (A.size() == N) {
        //答えの出力
        for(int a : A) {
            //数字列を文字列に変換
            char s = 'a'+a;
            cout << s;
        }
        cout << endl;
        return;
    }
    //DFSでいままで出てきたアルファベット+1種類しか出ないようにするための処理
    //flag:一週目かどうかの判定
    if(max_ < vn+1 && flag) max_ = vn+1;
    
    //DFSを用いた全探索
    for (int v = 0; v <= max_; ++v) {
        flag = true;
        A.push_back(v);
        dfs(A, N, max_, v);
        A.pop_back();
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> A;
    dfs(A, n, 0, 0);
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int k = Integer.parseInt(tmpArray[1]);
		
		int c[] = new int[n];
		tmpArray = br.readLine().split(" ");
		
		long sum = 0;
		for(int i = 0; i < n ; i++) {
			c[i] = Integer.parseInt(tmpArray[i]);
		}
		
		Arrays.sort(c);
		
		for(int i = 0; i < n - k; i++) {
			sum += c[i];
		}
		
		System.out.println(sum);
	}

}


Measured memory_bytes: 57684