akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll arr[2000005], arr2[100000] ;
ll MOD = 1e9 + 7;

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

  if( (a < 0 or a > 9) or (b < 0 or b > 9) )  cout<<-1<<endl;
  else  cout<<(a*b)<<endl;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut ans = 0;

    if k & 1 == 0 {
        ans += {
            let v = (n + (k / 2)) / k;
            v * v * v
        };
    }
    ans += {
        let v = n / k;
        v * v * v
    };
    println!("{}", ans);
}


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

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

    int max = 0;
    int cur = 0;
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
            cur++;
            max = cur > max ? cur : max;
        } else {
            cur = 0;
        }
    }
    if (cur > max) {
        max = cur;
    }

    cout << max << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int a[100000], n, b[100001];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		b[a[i]]++;
		b[a[i] - 1]++;
		b[a[i] + 1]++;
	}
	int ma = 0, y = 0;
	for (int i = 0; i < 100001; i++)
		ma = max(ma, b[i]);
	cout << ma << endl;
	getchar(); getchar();
}

Measured memory_bytes: 1792
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

nn = inputs[0][0]
print "nn:" if $debugFlag
pd nn
consts = []
for i in 1..inputs.size-2 do
  consts << [inputs[i][1..-1], inputs[-1][i-1]]
end

pd consts

cnt = 0
for i in 0..2**nn-1 do
  pd "i=#{i}"
  flag = true
  for j in 0..consts.size-1 do
    pd "j=#{j}"
    tmp = 0
    tmpstr = ""
    consts[j][0].size.times do |k|
      tmp += i[consts[j][0][k]-1]
      tmpstr += i[consts[j][0][k]].to_s + "+"
    end
    pd tmpstr
    if (tmp % 2) != consts[j][1]
      flag = false
      break
    end
  end
  if flag == true
    pd "i=#{i}: true"
    cnt += 1
  else
    pd "i=#{i}: false"    
  end
end

puts cnt


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



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

    if (len(T) == 1 and T[0] == '?') {
        cout << 'D' << endl;
        return 0;
    } else if (len(T) == 1 and T[0] != '?') {
        cout << T[0] << endl;
        return 0;
    }

    if (T[0] == '?' and T[1] == 'D') {
        T[0] = 'P';
    } else if (T[0] == '?' and T[1] == 'P') {
        T[0] = 'D';
    } else if (T[0] == '?' and T[1] == '?') {
        T[0] = 'P';
    }
    rep(i, 1, len(T)-1) {
        if (T[i] != '?') continue;

        if (T[i-1] == 'D' and T[i+1] == 'D') {
            T[i] = 'P';
        } else if (T[i-1] == 'D' and T[i+1] == '?') {
            T[i] = 'P';
        } else {
            T[i] = 'D';
        }
        /*
        if (T[i-1] == 'P') {
            T[i] = 'D';
        } 
        
        else if (T[i+1] == 'D') {
            T[i] = 'P';
        } else if (T[i+1] == '?') {
            T[i] = 'P';
        } else if (T[i-1] == 'D') {
            T[i] = 'D';
        } else {
            T[i] = 'P';
        }
        */
    }
    if (T[len(T)-1] == '?') {
        T[len(T)-1] = 'D';
    }

    cout << T << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define int long long 
vector<int> ary357={3,5,7};
int n;
int ret=0;
int addDigit(int a,int b){
    return a*10+b;
}
int getDigit(int a){
    return to_string(a).size();
}
bool is357(int i){
    string s=to_string(i);
    int n3,n5,n7;
    n3=count(begin(s),end(s),'3');
    n5=count(begin(s),end(s),'5');
    n7=count(begin(s),end(s),'7');
if(n3>=1 && n5>=1 && n7>=1)return true;
else return false;
}


void dfs(int i){
    
   // cout<<i<<" " <<ret<<endl;
    if (i>n)return;
    if (is357(i)){
        ret++;
       // cout<<ret<<" "<<i<<endl;
    }
    for(auto&& j:ary357){
        i=i*10+j;
        dfs(i);
        i/=10;
    }

}

signed main(){
    cin>>n;
    dfs(0);
    cout <<ret<<endl;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n,m;
const int maxn=300111;
vector<int> con[maxn];
char s[maxn];
int cnt[maxn][2];
bool f[maxn];
void dfs(int x)
{
	f[x]=1;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i];
		cnt[u][s[x]-'A']--;
		if(!f[u]&&!cnt[u][s[x]-'A'])
		{
			dfs(u);
		}
	}
}
int main()
{
	getii(n,m);
	for(int i=1;i<=n;i++)s[i]=getreal();
	for(int i=1;i<=m;i++)
	{
		int x,y;
		getii(x,y);
		con[x].PB(y);
		con[y].PB(x);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<con[i].size();j++)
		{
			cnt[i][s[con[i][j]]-'A']++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!f[i]&&(!cnt[i][0]||!cnt[i][1]))
		{
			dfs(i);
		}
	}
	bool ans=0;
	for(int i=1;i<=n;i++)ans|=!f[i];
	if(ans)puts("Yes");else puts("No");
	return 0;
}


Measured memory_bytes: 18560
#!/usr/bin/python3
# ABC120: B
import sys
sys.setrecursionlimit(10000)

input = sys.stdin.readline

def debug(*args, **kdws): print(*args, file=sys.stderr, **kdws)

A, B, K = [int(x) for x in input().split()]
debug("*******")
debug(A, B, K)
c = 0

div = []
for i in range(1, max(A, B)+1):
    #debug(A, B, i, "c=",c, ", A%i=",  A%i, ",B%i=", B%i)
    if A % i == 0 and B % i == 0:
        div.append(i)
debug(div)
print(div[-K])
debug("*******")



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

int main() {
  string S, T;
  cin >> S >> T;
  if (T.substr(0, S.length()) == S)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (x, a, b) = get!(i64, i64, i64);
    let r = a - b;
    if r >= 0 {
        println!("delicious");
    } else if x + r >= 0 {
        println!("safe");
    } else {
        println!("dangerous");
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
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;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) { cin >> a[i]; }
    sort(a.begin(), a.end());
    int R = (a[n - 1] + 1) / 2;
    int sa = 1000000000;
    int res2;
    rep(i, 0, n) {
        if(abs(R - a[i]) < sa) {
            sa = abs(R - a[i]);
            res2 = a[i];
            //cout<<"aaa"<<a[i]<<",sa"<<sa<<endl;
        }
    }
    cout << a[n - 1] << " " << res2 << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a;
	string s;

	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	int N, M;cin>>N>>M;
    vector<int> X(M, 0);
    for (int i = 0; i < M; ++i)cin >> X[i];
    sort(X.begin(), X.end());
    vector<int> d(M - 1);
    for (int i = 0; i < M-1; ++i)d[i] = X[i + 1] - X[i];
    sort(d.rbegin(), d.rend());
    int ans = 0;
    for (int i = N-1; i < M-1; ++i)ans += d[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,m,k,i;
  cin>>n;
  for (i=0;i<n;i++) {
    cin>>a;
    k=0;
    while (a%2==0) {
      k++;
      a/=2;
    }
    if (i==0 || k<m) m=k;
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
data = input().split(' ')
n = int(data[0])
a = int(data[1])
b = int(data[2])
cnt = 0
for i in range(1, n + 1):
    num_1 = i % 10 // 1
    num_2 = i % 100 // 10
    num_3 = i % 1000 // 100
    num_4 = i % 10000 // 1000
    num_5 = i % 100000 // 10000
    s = sum([num_1, num_2, num_3, num_4, num_5])
    if a <= s <= b:
        cnt += i
print(cnt)

Measured memory_bytes: 3064
//h15-1 鉄道旅行(Atcoder)
//2^100000 それぞれの鉄道会社を持っている場合で総当り
//またも累積和か！？
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int P[100005];
int A[100005],B[100005],C[100005];
LL T[100005];
 
int main(){
    int N,M;
    cin >> N >> M;

    for(int i=0; i<N-1; i++){
        T[i] = 0;
    }

    cin >> P[0];
    P[0]--;
    for(int i=1; i<M; i++){
        cin >> P[i];
        P[i]--;

        int s = P[i-1];
        int g = P[i];
        T[min(s,g)]++;
        T[max(s,g)]--;
    }

    for(int i=1; i<N; i++){
        T[i] += T[i-1];
    }

    CINT ans = 0;
    for(int i=0; i<N-1; i++){
        cin >> A[i] >> B[i] >> C[i];
        ans += min(A[i]*T[i] , B[i]*T[i]+C[i]);
    }
    
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 5588
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,m,ans=0,ki=0,fo=0;
	cin>>n;
	vector<int>s(n);
	rep(i,n){
	    cin>>s[i];
	    if(s[i]%2)ki++;
	    else if(s[i]%4==0)fo++;
	}
	if(fo>=ki)ans=1;
	else if(fo+ki==n&&fo>=ki-1)ans=1;
	if(ans)cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;

const int N = 200200;
const int mod = 1e9 + 7;

int par[N], d[N], distance;
int q[N];
int dist[N];
int ans[3];
vector<int> g[N];
int col[N], used[N];
int n;

inline void bfs()       
{
	int qs = 0, qt = 0;              
	q[qt++] = 1;
	q[qt++] = n;
	used[1] = used[n] = 1;
	col[1] = 1;
	col[n] = 2;
	while(qs < qt)
	{
		int v = q[qs++];
		for(int to : g[v])	
		{
			if(!used[to])
			{
				used[to] = 1;
				dist[to] = dist[v] + 1;
				col[to] = col[v];
				q[qt++] = to;
			}
		}
	}
	fo(i, n)
		ans[col[i]]++;
	if(ans[1] > ans[2])
		cout << "Fennec\n";
	else
		cout << "Snuke\n";
}

inline void dfs(int v, int p = -1)
{
	par[v] = p;
	for(int to : g[v])
		if(to != v)
			dfs(to, v);	
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	fo(i, n - 1)
	{
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	bfs();

	return 0;
}

Measured memory_bytes: 10880
N = int(input())
S = []
nagasa = 51
for i in range(N):
    dam = input()
    S.append(dam)
    if len(list(dam)) < nagasa:
        nagasa = len(list(dam))
        saisyo=i
# print(S,saisyo)

flg=[0]*len(S[saisyo])
for i in range(len(S[saisyo])):
    for j in range(N):
        if j==saisyo:
            continue
        else:
            for k in range(len(S[j])):
                if S[saisyo][i] == S[j][k]:
                    flg[i] +=1
                    l = list(S[j])
                    l[k] = 'A'
                    S[j] = ''.join(l)
                    # print(i,j,k,S)
                    break

out=[]
for i in range(len(S[saisyo])):
    if flg[i]==N-1:
        out.append(S[saisyo][i])
out=sorted(out)
# print(flg,oust)
print(''.join(out))


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int N , A , B ;
    cin >> N >> A >> B ;
    int z = N * A ;

    cout << min({z , B}) ;


    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    bool maki=false;
    cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i==0){
            if(1<= n/i && n/i <=9){
                maki=true;
            }
        }
    }
    cout << ((maki)?"Yes":"No") <<endl;
    return 0;
}


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

int main(){
  long int n,a,b;
  scanf("%ld%ld%ld",&n,&a,&b);
  
  if(n%(a+b)==0){
    printf("%ld",a*(n/(a+b)));
  }else if(n%(a+b)<a){
    printf("%ld",a*(n/(a+b))+n%(a+b));
  }else{
    printf("%ld",a*(n/(a+b))+a);
  }
    
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def dfs(d, tight, str_N, pre):
    if d >= len(str_N) - 1:
        if int(pre) <= int(str_N[-1]):
            return 1
        else:
            return int(not tight)

    ans = 0
    if tight:
        for i in range(0, int(str_N[d]) + 1):
            ans += dfs(d + 1, str(i) == str_N[d], str_N, pre)
    else:
        for i in range(0, 10):
            ans += dfs(d + 1, False, str_N, pre)

    return ans


def solve():
    N = int(input())
    str_N = str(N)
    D = len(str_N)

    memo = [-1] * 10
    ans = 0
    for A in range(1, N + 1):
        a = str(A)
        pre = a[0]
        post = a[-1]

        if pre == "0" or post == "0":
            continue

        for d in range(1, D + 1):
            if d == 1:
                if pre == post:
                    ans += 1
            elif d != D:
                ans += 10 ** (d - 2)
            else:
                # B = post, xxx, pre
                if post == str(N)[0]:
                    if memo[int(pre)] == -1:
                        memo[int(pre)] = dfs(1, True, str_N, pre)
                    ans += memo[int(pre)]
                elif int(post) < int(str_N[0]):
                    ans += 10 ** (d - 2)

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 76032
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    string t;
    int isA = false;
    for(int i=0; i<n; ++i){
        if(!isA && s[i] == 'A'){
            isA = true;
        }
        else if(isA && s[i] == 'Z'){
            isA = false;
            t += "AZ";
        }
    }

    if(t.size() == 0)
        cout << -1 << endl;
    else
        cout << t << endl;

    return 0;
}

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

int main(){
  long long X;
  cin >> X;
  
  long long sum = 100;
  int counter = 0;
  while(true){
    if(sum>=X){
      break;
    }
    sum += sum/100;
    counter++;
  }
   cout << counter << endl;
}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
const int N=1e5;
int main()
{
    int n,m,a,sum=0,x;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a;
        sum+=a;
    }
    x=n-sum;
    if(x>=0)
        cout<<x<<endl;
    else
        cout<<-1<<endl;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }

  vector<vector<int>> X(3, vector<int>(3, 0));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < N; k++) {
        if (A.at(i).at(j) == b.at(k)) {
          X.at(i).at(j) = 1;
        }
      }
    }
  }

  bool result = false;
  int sum = 0;

  for (int i = 0; i < 3; i++) {
    sum = 0;
    for (int j = 0; j < 3; j++) {
      sum += X.at(i).at(j);
    }
    if (sum == 3) {
      result = true;
    }
  }

  for (int i = 0; i < 3; i++) {
    sum = 0;
    for (int j = 0; j < 3; j++) {
      sum += X.at(j).at(i);
    }
    if (sum == 3) {
      result = true;
    }
  }

  sum = 0;
  for (int i = 0; i < 3; i++) {
    sum += X.at(i).at(i);
  }
  if (sum == 3) {
    result = true;
  }

  sum = 0;
  for (int i = 0; i < 3; i++) {
    sum += X.at(i).at(2 - i);
  }
  if (sum == 3) {
    result = true;
  }

  if (result) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        vi a;
        s=0;
        rep(i,n)
        {
            vp(a,x);
            s+=x;
        }
        c=INT_MAX,x=0;
        for(i=0;i<n-1;i++)
        {
            x+=a[i];
            y=s-x;
            c=min(c,abs(x-y));
        }
        cout<<c<<en;
    }
}




Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int h, w;
	cin >> h >> w;

	char T[h][w];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> T[i][j];
	
	bool ans = true;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (T[i][j] == '.')
				continue ;

			bool flag = false;
			if (i != 0)	
				(T[i-1][j] == '#') ? (flag = true) : 0;
			if (i != h-1)
				(T[i+1][j] == '#') ? (flag = true) : 0;
			if (j != 0)
				(T[i][j-1] == '#') ? (flag = true) : 0;
			if (j != w-1)
				(T[i][j+1] == '#') ? (flag = true) : 0;
			if (!flag)
				ans = false;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}



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

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i=1;i<=H;i++) {
			for (int j=1;j<=W;j++) {
				if (i==1 || i==H || j==1 || j==W) {
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout <<endl;
		}
		cout <<endl;
	}


}

Measured memory_bytes: 1152
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    n, m = MI()
    mlist = LI()
    d = [[float('inf') if i != 0 else 0 for i in range(n+1)] for j in range(m+1)]
    for i, value in enumerate(mlist):
        for j in range(n+1):
            if j < value:
                d[i+1][j] = d[i][j]
            else:
                d[i+1][j] = min(d[i][j], d[i+1][j-value]+1)
    print(d[m][n])

        
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 45800
#include <stdio.h>

int main(){
	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	if(A + B > C + D){
		printf("Left\n");
	}
	if(A + B == C + D){
		printf("Balanced\n");
	}
	if(A + B < C + D){
		printf("Right\n");
	}
	return 0;
}

Measured memory_bytes: 128
x,n= map(int,input().split(' '))
if n!=0:
    arr= list(map(int,input().split(' ')))
    for j in range(x+1):
        for i in range(-1,2):
            if arr.count(x+i*j)==0:
                print(x+i*j)
                exit(0)
else:
    print(x)

Measured memory_bytes: 9124
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define INF 1e18
signed main(){
  init_io();
  ll q,a,b,t,bsum=0,ans=0;
  multiset<ll> l_st,r_st;
  cin >> q;
  l_st.insert(-INF);
  r_st.insert(+INF);
  for(int i=0;i<q;i++){
    cin >> t;
    if(t==1){
      cin >> a >> b;
      if(*l_st.rbegin()>a||*r_st.begin()<a){
        ans += min(abs(a-*l_st.rbegin()),abs(a-*r_st.begin()));
      }
      if(*r_st.begin()>a){
        l_st.insert(a);
        l_st.insert(a);
      }else{
        r_st.insert(a);
        r_st.insert(a);
      }
      if(l_st.size()<r_st.size()){
        l_st.insert(*r_st.begin());
        r_st.erase(r_st.begin());
      }else{
        r_st.insert(*l_st.rbegin());
        l_st.erase(l_st.find(*l_st.rbegin()));
      }
      bsum += b;
    }else{
      cout << *l_st.rbegin()<<" "<<ans+bsum << endl;
    }
  }
}


Measured memory_bytes: 19072
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll lcm(ll a, ll b)
{
   return a / gcd(a, b) * b;
}

ll memo[1000010];

ll fib(ll x){
  if(x == 0) return 1;
  else if(x <= 2) return x;
  else if(memo[x] != 0) return memo[x];
  return memo[x] = fib(x-2) + fib(x-1);
}

int main()
{
  ll a,b,x;
  cin >> a >> b >> x;
  ll first;
  ll ax;
  if(a % x == 0) first = a;
  else{
      ax = a/x;
      first = (ax + 1)*x;
  }
  ll ans;
  if(first > b) ans = 0;
  else ans = (b-first)/x + 1;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int a[100010];
    int sum = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;

            sum += a[i] * a[j];
        }
    }

    cout << sum/2 << endl;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s.at(i) == t.at(i)) ++ ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    long long int x,y,ans=0,min = 100000000,count=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i] < 0){
            a[i] *= -1;
            count++;
        }
        ans += a[i];
        if(min > a[i]) {
            min = a[i];
        }
    }
    if(count%2==1){
        printf("%lld",ans-min-min);
    }else{
        printf("%lld",ans);
    }
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<deque>
#include<climits>
#include<map>
using namespace std;
typedef pair<long long,int> P;
struct Pox
{
  P p;
  int met;
  Pox(P p,int met):p(p),met(met){}
};

bool check(int a,int b)
{
  for(int i=6;i<=22;i++)
    {
      if(((a>>i) & 1) && ((b>>i) & 1))
	return false;
    }
  return true;
}

int main()
{
  int N;
  while(cin >> N,N)
    {
      //clock_t st,ed;
      //st = clock();
      vector<P> info;
      for(int i=0;i<N;i++)
	{
	  int M;
	  long long L;
	  cin >> M >> L;
	  int time = 0;
	  for(int j=0;j<M;j++)
	    {
	      int S,E;
	      cin >> S >> E;
	      int pre = 0;
	      pre = (1<<E)-1;
	      pre ^= (1<<S)-1;
	      time |= pre;
	    }
	  info.push_back(P(L,time));
	}
      long long ans = 0;
      deque<Pox> deq;//Pox(P(満足度、使った時間),会った人)
      for(int i=0;i<N;i++)
	deq.push_back(Pox(info[i],(1<<i))),ans = max(ans,info[i].first);
      /*
      int mex[(1<<23)-1];
      for(int i=0;i<(1<<23)-1;i++)
	mex[i] = 0;
      */
      map<int,long long> mex;
      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();
	
	  P p = pox.p;
	  int met = pox.met;
	  for(int i=0;i<N;i++)
	    {
	      if((met >> i) & 1)
		continue;
	      if(!check(p.second,info[i].second))
		continue;
	      int pes = p.second|info[i].second;
	      if(mex[pes] < p.first+info[i].first)
		{
		  mex[pes] = p.first+info[i].first;
		  deq.push_back(Pox(P(p.first+info[i].first,pes),met|(1<<i)));
		  ans = max(ans,p.first+info[i].first);
		}
	    }

	}	
      cout << ans << endl;
      //ed = clock();
      //cout << setiosflags(ios::fixed) << setprecision(10) << (double)(ed-st)/CLOCKS_PER_SEC << endl;
    }
  return 0;
}

Measured memory_bytes: 5228
/**
 * Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define psb push_back
template<class T> T read() { T x; cin >> x; return x; }
typedef long long ll;
#define wyzi() read<int>()

int main() {
  ll n = read<ll>(), ans = n - 1;
  fore(i, 2, sqrt(n))
    if (n % i == 0)
      ans = min(ans, i + n / i - 2);
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MAX=2e5+10;
const int modn=1e9+7;
typedef long long ll ;
#define int ll
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
int n,m,d,t,s;
string p,q;
int a[MAX],b[MAX];
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=b[i-1]+a[i];
        b[i]%=modn;
    }
    ll sum=0;
    for(int i=2;i<=n;i++){
        ll now=a[i]*b[i-1]%modn;
        sum+=now;
        sum%=modn;
    }
    cout<<sum;
}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,s;
    int co=0;
    cin >> k >> s;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(((s-i-j)<=k)&&(0<=(s-i-j))){
                co++;
            }
        }
    }
    cout << co << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <cmath>

using namespace std;
#define ARRAY_BUFFER_SIZE 10000

int main()
{
	int n = 0;
	scanf("%d", &n);


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

	int counter = 0;

	for (int i = 0; i < n; ++i) {
		int value = Array[i];

		// 2は素数.
		if (value == 2) {
			counter++;
			continue;
		}

		// 偶数は素数ではない.
		if (value < 2 || (value % 2 == 0)) {
			continue;
		}

		// 判定する値の,平方根以下で割り切れるか.
		int j = 3;
		bool isPrime = true;
		const int sqrtValue = sqrt(value);
		while ( j <= sqrtValue) {
			if (value % j == 0) {
				isPrime = false;
				break;
			}
			j += 2;
		}

		if (isPrime) {
			counter++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
int main(){
    ll n, k, ans=0;
    cin >> n >> k;
    while(n!=0){
        n /= k;
        ans++;
    }
   
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,m,l0,r0;
  cin >> n >> m;
  int l=0,r=n;
  for(int i=0;i<m;i++){
    cin >> l0 >> r0;
    if(l0>l){
      l=l0;
    }
    if(r0<r){
      r=r0;
    }
  }
  if(r<l){
    cout << 0 << endl;
  }
  else{
    cout << r-l+1 << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
ary = [int(input()) for _ in range(n)]
dp = [[0]*10001 for _ in range(n+1)]
dp[0][0] = 1
ans = 0
for i in range(n):
    for j in range(10001):
        if dp[i][j] == 1:
            dp[i+1][j] = 1
            dp[i+1][j+ary[i]] = 1

for i in range(10001):
    if dp[n][i] != 0:
        if i % 10 != 0:
            ans = max(ans,i)
print(ans)

Measured memory_bytes: 10868
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<unsigned long long>a(n, 0);
	vector<unsigned long long>b(n, 0);
	vector<unsigned long long>c(n, 0);
	for (long long i = 0; i < n; i++) cin >> a[i];
	for (long long i = 0; i < n; i++) cin >> b[i];
	for (long long i = 0; i < n; i++) cin >> c[i];

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	unsigned long long sum = 0;
	for (long long j = 0; j < n; j++) {
		auto albite = lower_bound(a.begin(), a.end(), b[j]);//b[j]以上の値の最初の要素のイテレータ得られる
		auto cubite = upper_bound(c.begin(), c.end(), b[j]);
		long long i = distance(a.begin(), albite);
		long long k = distance(cubite, c.end());
		sum += i*k;
	}
	cout << sum;
	return 0;
}





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

int main(){
  long int N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  long int M;
  M = min(A,min(B,min(C,min(D,E))));
  if(N % M != 0){
  cout << N / M + 5 << endl;
  }
  else{
    cout << N / M + 4 << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
ll dp[3010][3010][4] = {};
ll item[3010][3010] = {};
int main(){
    cout << fixed << setprecision(10);
    int r,c,k;
    cin >> r >> c >> k;
    rep(i,k){
        ll x,y,z;
        cin >> x >> y >> z;
        x--; y--;
        item[x][y] = z;
    }
    dp[0][0][1] = item[0][0];
    rep(i, r){
        rep(j, c){
            rep(k, 4){
                if(j - 1 >= 0){
                    chmax(dp[i][j][0], dp[i][j-1][0]);
                    chmax(dp[i][j][1], dp[i][j-1][1]);
                    chmax(dp[i][j][1], dp[i][j-1][0] + item[i][j]);
                    chmax(dp[i][j][2], dp[i][j-1][2]);
                    chmax(dp[i][j][2], dp[i][j-1][1] + item[i][j]);
                    chmax(dp[i][j][3], dp[i][j-1][3]);
                    chmax(dp[i][j][3], dp[i][j-1][2] + item[i][j]);
                }
                rep(l, 4){
                    if(i - 1 >= 0){
                        chmax(dp[i][j][0], dp[i-1][j][l]);
                        chmax(dp[i][j][1], dp[i-1][j][l] + item[i][j]);
                    }
                }
            }
        }
    }
    ll ans =  max({dp[r-1][c-1][0],dp[r-1][c-1][1],dp[r-1][c-1][2],dp[r-1][c-1][3] });
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 356228
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int rev = 0;
		String s=sc.next();
		int Q=sc.nextInt();
		int[] mae = new int[200001];
		int maecnt=0;
		int[] ato = new int[200001];
		int atocnt=0;
		for(int i=0; i<Q; i++) {
			int q = sc.nextInt();
			if( q ==1) {		//rev
				rev++;
			}
			else if(q ==2) {
				int fi = sc.nextInt();
				if(rev %2 == 0) {
					if(fi == 1) {
						mae[maecnt] = (sc.next()).charAt(0) - 'a';
						maecnt++;
					}
					else if(fi ==2) {
						ato[atocnt] = (sc.next()).charAt(0) - 'a';
						atocnt++;
					}
				}
				else {
					if(fi == 1) {
						ato[atocnt] = (sc.next()).charAt(0) - 'a';
						atocnt++;
					}
					else if(fi ==2) {
						mae[maecnt] = (sc.next()).charAt(0) - 'a';
						maecnt++;
					}
				}
			}
		}
		StringBuilder sb=new StringBuilder();
		if(rev % 2 == 0) {
			for(int i=maecnt -1; i>= 0 ; i--) {
				sb.append((char)(mae[i] + 'a'));
			}
			sb.append(s);
			for(int i=0; i< atocnt ; i++) {
				sb.append((char)(ato[i] + 'a'));
			}
		}
		else {
			for(int i=atocnt -1; i>= 0 ; i--) {
				sb.append((char)(ato[i] + 'a'));
			}
			StringBuffer str = new StringBuffer(s);
			sb.append(str.reverse().toString());
			for(int i=0; i< maecnt ; i++) {
				sb.append((char)(mae[i] + 'a'));
			}
		}
		pl(sb.toString());
	}
	public static void pl(Object o) {
		System.out.println(o);
	}

}

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

constexpr int64_t mod = 1'000'000'007;
int64_t fact[10000], finv[10000];

int64_t mpow(int64_t x, int64_t y){
    if(y == 0) return 1;
    if(y == 1) return x%mod;
    if(y%2 == 0) return mpow(x*x%mod, y/2)%mod;
    return mpow(x*x%mod, y/2)%mod * x % mod;
}

int64_t comb(int64_t n, int64_t r){
    if(n < r) return 0;
    return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

int main(){
    fact[0] = 1;
    for(int i=1;i<10000;++i) fact[i] = i*fact[i-1]%mod;
    finv[9999] = mpow(fact[9999], mod-2);
    for(int i=9998;i>=0;--i) finv[i] = (i+1)*finv[i+1]%mod;

    int n, k;
    cin >> n >> k;

    for(int i=1;i<=k;++i){
        if(n-k < i-1){
            cout << 0 << endl;
            continue;
        }
        int64_t b = comb(k-1, k-i);
        int64_t r = comb(n-k+1, i);
        cout << b*r%mod << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)        (x).begin(), (x).end()    //昇順
#define rall(x)       (x).rbegin(), (x).rend()  //降順
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes           out("Yes");
#define no            out("No");

bool flag = false;

void check(ll a, ll b, ll c, ll k) {
    if (a < b && b < c) {
        flag = true;
    }
    if (k != 0) {
        check(a * 2, b, c, k - 1);
        check(a, b * 2, c, k - 1);
        check(a, b, c * 2, k - 1);
    }
}

int main() {
    in(a);
    in(b);
    in(c);
    in(k);
    check(a, b, c, k);
    if (flag) {
        out("Yes");
    } else {
        out("No");
    }
}

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

void solve() 
{
    int x;cin>>x;
    if(x<600)x=8;
    else if(x<800)x=7;
    else if(x<1000)x=6;
    else if(x<1200)x=5;
    else if(x<1400)x=4;
    else if(x<1600)x=3;
    else if(x<1800)x=2;
    else x=1;
    cout<<x<<endl;
}

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

Measured memory_bytes: 3624
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int n,ans=0;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++) {
    for(int j=0;j<3;j++) {cin>>a[i][j];}
  }
  for(int i=1;i<n;i++) {
  	a[i][0]=a[i][0]+max(a[i-1][1],a[i-1][2]);
    a[i][1]=a[i][1]+max(a[i-1][0],a[i-1][2]);
    a[i][2]=a[i][2]+max(a[i-1][1],a[i-1][0]);
  }
  for(int i=0;i<3;i++) {ans=max(ans,a[n-1][i]);}
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 4792
L = input()
waru = 1000000007
lis1 = 1
lis2 = 2
for i in range(1,len(L)):
    if L[i] == "0":
        lis1 = (lis1*3) % waru
        lis2 = lis2 % waru
    elif L[i] == "1":
        lis1 = (lis1*3+lis2) % waru
        lis2 = (lis2*2) % waru

print((lis1+lis2) % waru)


Measured memory_bytes: 3188