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

int q[11]={6,5,4,3,2,7,6,5,4,3,2};
int p[12];

int check(){
	int s=0;
	for(int i=0;i<11;i++)s+=p[i]*q[i];
	int d=11-(s%11);
	if(d>=10)d=0;
	return p[11]==d;
}
int main(){
	int idx;
	for(int i=0;i<=11;i++){
		int c=getchar();
		if(c=='?')idx=i;
		else p[i]=c-'0';
	}
	int ans=-1;
	for(int i=0;i<10;i++){
		p[idx]=i;
		if(check()){
			if(ans==-1)ans=i;
			else ans=-1;
		}
	}
	if(ans==-1)puts("MULTIPLE");
	else printf("%d\n",ans);
	
}


Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    double x;
    cin >> x;
    printf("%.10lf\n", x*acos(-1)*2);
    return 0;
}

Measured memory_bytes: 3748
N = int(input())
MOD = 10**9 + 7

c = 1
c0 = 0
c1 = 0
c01 = 0

for _ in range(N):

    c01 = (c0+c1+c01*10)%MOD
    c0 = (c + c0*9)%MOD
    c1 = (c + c1*9)%MOD
    c = (c*8)%MOD

print(c01)

Measured memory_bytes: 63560
use std;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn d_sum_of_divisors() {
    let n = read::<i64>();
    let ans: i64 = (1..n+1).map(move |x| {
        let y = n / x;
        y * (y + 1) * x / 2
    }).sum();

    println!("{}", ans);
}

fn main() {
    d_sum_of_divisors();
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
#define rept(i,L,R) for(int i=(L);i<(R);i++)
#define isc(n) scanf("%d",&n)
#define llsc(n) scanf("%lld",&n)
#define dsc(n) scanf("%lf",&n)
#define enl cout<<endl
#define pb(x) push_back(x)
#define xx first
#define yy second
typedef long long ll;
typedef pair<int,int>PI;
typedef pair<pair<int,int>,int>PII;

map<int,int>a;
int main()
{
    int n,t;
    cin>>n;
    rept(i,0,n){cin>>t;a[t]++;}
    ll ans=0;
    for(auto i:a)
    {
        if(i.xx>i.yy)ans+=i.yy;
        else ans+=min((i.yy-i.xx),i.yy);
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;
double dp[3010][3010];

int main(){
    int n;
    cin >> n;
    vector<double> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            dp[i + 1][j] += dp[i][j] * p[i];
            dp[i + 1][j + 1] += dp[i][j] * (1 - p[i]);
        }
    }
    double ans = 0;
    for(int i = 0; i <= n / 2; i++){
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 69120
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n, k; scan(n, k);
    writeln(k == 1 ? 0 : n - k);
}


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

typedef long long ll;

const int maxn = 2e5 + 1e2;
int val[maxn];
int indices[maxn];
bool used[maxn];
ll res = 0;

bool cmp(int a, int b){
	return val[a] > val[b];
}

int main(){
	std::ios::sync_with_stdio(false);

	int n;
	std::cin >> n;

	for(int i = 0; i < n; i++){
		std::cin >> val[i];
		indices[i] = i;
	}

	std::sort(indices, indices + n, cmp);
	bool possible = true;

	for(int i = 1; i < n; i++){
		if(val[i] - val[i - 1] > 1){
			possible = false;
		}
	}

	for(int i = 0; i < n; i++){
		int start_from = indices[i] - val[indices[i]];
		if(start_from < 0){
			possible = false;
			break;
		} 

		if(!used[start_from]){
			used[start_from] = true;
			res += (ll) val[indices[i]];
		}
	}

	if(!possible){
		std::cout << "-1\n";
		return 0;
	}

	std::cout << res << '\n';

 }

Measured memory_bytes: 2048
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var arg   = input.split("\n");
  var line0 = arg[0].split(" ");
//  var line1 = arg[1].split(" ");
//  var line2 = arg[2].split(" ");
//  var line3 = arg[3].split(" ");

  var a = Number(line0[0]);
  var b = Number(line0[1]);
  var c = Number(line0[2]);
//  var d = Number(line1[1]);

  var ans = "initial_answer";
  //console.log( "[INPUT] "+ input1 +" "+ input2 +" "+ input3 + " " + input4 );
  
  // LOGIC //
  ans = "NO";
  
  if(b-a == c-b) ans="YES";
  


  console.log(ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

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

  int x = (N+1000-1)/1000;
  int ans = x*1000 - N;
  
  cout << ans << endl;
  
  return 0;

}


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


int main(){
    int n;
    bool flag=true;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2==0){
            if(!(a%3==0||a%5==0)) flag=false;
        }
        else continue;
    }
    if(flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

x = [a, b]
y = [c, d]
if a <= 0 <= b:
    x.append(0)
if c <= 0 <= d:
    y.append(0)

ans = -10 ** 19
for p in x:
    for q in y:
        ans = max(ans, p * q)

print(ans)

Measured memory_bytes: 9084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

int main(int argc, char* argv[])
{
  std::string s;
  std::cin >> s;

  int n = std::atoi(s.c_str());
  std::string ans = "ABC";
  if (n >= 1000) {
    ans = "ABD";
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string.h>
#include <deque>
using namespace std;
const int N = 3005;
string s, t;
int dp[N][N];
main() {
	cin >> s >> t;
	for(int i = 1; i <= (int)s.size(); i++) {
		for(int j = 1; j <= (int)t.size(); j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(s[i - 1] == t[j - 1]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}

	deque < char > ans;
	int n = s.size(), m = t.size();
	while(n && m) {
		if(dp[n][m] == dp[n - 1][m]) n--;
		else if(dp[n][m] == dp[n][m - 1]) m--;
		else if(dp[n][m] == dp[n - 1][m - 1] + 1) {
			ans.push_front(s[n - 1]); n--; m--;
        }
	}

	for(int i = 0; i < ans.size(); i++) printf("%c", ans[i]);
}

Measured memory_bytes: 35456
#include<cstdio>

int n, A[50];

int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 1;
  if (n%2 == 0){
    for (int i=0 ; i<n/2 ; i++){
      if (s.at(i) != s.at(n/2+i)){
        ans = 0;
        break;
      }
    }
  }
  else
    ans = 0;
  
  if (ans == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll calcNumOfCombination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll calcNumOfPermutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  ll n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  ll nc, mc;
  if ((n + m) % 2 == 0) {
    nc = calcNumOfPermutation(n, n);
    mc = calcNumOfPermutation(m, m) % mod;
    cout << 2 * (nc * mc) % mod << endl;
  } else {
    nc = calcNumOfPermutation(n, n) % mod;
    mc = calcNumOfPermutation(m, m) % mod;
    cout << nc * mc % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(p) for p in input().split()]

x = 0
y = 0
z = 0
for i in range(N):
    if A[i]%4 == 0:
        x += 1
    elif A[i]%2 == 0:
        y += 1
    else:
        z += 1
        
if y == 0 and z <= x+1:
    ans = "Yes"
elif y != 0 and z <= x:
    ans = "Yes"
else:
    ans = "No"
    
print(ans)

Measured memory_bytes: 14252
#define _ 2<<17
n,i;A[_],B[_],T[_],F[_];long M,D[_],P[_],R[_];s(u,p,i,I){D[u]=1;for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;}S(u,x,p,i,I){for(m(i=F[u],p);I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}m(i,p){i?m(T[i],p),R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M:0;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,0);S(1,1);for(;i++<n;)printf("%d\n",P[i]);}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 14592
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 h, w, m;

void solve() {
	cin >> h >> w >> m;
    vector<int> cnth(h, 0), cntw(w, 0);
    map<P, bool> mp;
    rep(i, m) {
        int x, y; cin >> x >> y;
        -- x, -- y;
        mp[P{x, y}] = 1;
        cnth[x] ++, cntw[y] ++;
    }
    set<int> sex, sey;
    int mah = -1;
    rep(i, h) {
        if(chmax(mah, cnth[i])) {
            sex.clear();
            sex.insert(i);
        } else if(mah == cnth[i]) {
            sex.insert(i);
        }
    }
    int maw = -1;
    rep(i, w) {
        if(chmax(maw, cntw[i])) {
            sey.clear();
            sey.insert(i);
        } else if(maw == cntw[i]) {
            sey.insert(i);
        }
    }
    int ans = mah + maw;
    bool check = 1;
    for(auto x: sex) {
        for(auto y: sey) {
            if(!mp[P{x, y}]) {
                check = 0;
                break;
            }
        }
    }
    if(check) -- ans;
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
	int n, a[100005], ans = 0, now = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	while (now != 2) {
	    now = a[now];
	    ans++;
	    if (ans > n) break;
	}
	if (ans < n) cout << ans;
	else cout << -1;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define forn(i, n) for(int i = 0; i < int__(n); i++) 
#define sz(a) int__(a.size())
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int x,int y){return y!=0 ? gcd(y,x%y) : x;}

const int nax = 3005;
const int mod = 1e9 + 7;

int__ main() {
	fast;
	
	int n; cin >> n;
	string a; cin >> a;

	vvi dp(n+1, vi(n+1 , 0));

	dp[1][1] = 1;

	for(int i=2;i<=n;i++) {
		for(int j = 1; j <= n ; j++) {dp[i-1][j] += dp[i-1][j-1]; dp[i-1][j] %= mod;}

		for(int j=1;j<=i;j++) {
			if(a[i-2] == '<') dp[i][j] = Mod(dp[i-1][j-1] - dp[i-1][0]);
			else dp[i][j] = Mod(dp[i-1][n] - dp[i-1][j-1]);
		}
	}

	int ans = 0;

	for(int i=1;i<=n;i++) ans = Mod(ans + dp[n][i]);

	cout << ans << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;
ll mod;

class RSQ2{
public:
  ll n,dat[2*MAX_N-1],td[2*MAX_N-1];
  RSQ2(){n=MAX_N,memset(dat,0,sizeof(dat)),memset(td,0,sizeof(td));};
  RSQ2(int n_){
    n=1;
    while(n<n_)n*=2; //????´???°n???2???????????????
    for(int i=0;i<2*n-1;i++)dat[i]=td[i]=0;
  }
  
  ll add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if(r==-1) r=n;
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b){
      dat[k]=(dat[k]+(r-l)*x)%mod; 
      td[k]=(td[k]+x)%mod;
      return dat[k];
    }

    dat[k]=(dat[k]+(min(r,b)-max(l,a))*x)%mod;
    ll kl=k*2+1,kr=k*2+2,t=td[k]*(r-l)/2;
    dat[kl]=(dat[kl]+t)%mod, dat[kr]=(dat[kr]+t)%mod;
    td[kl]=(td[kl]+td[k])%mod, td[kr]=(td[kr]+td[k])%mod;
    td[k]=0;

    ll vl=add(a,b,x,k*2+1,l,(l+r)/2);
    ll vr=add(a,b,x,k*2+2,(l+r)/2,r);
    return (vl+vr)%mod;
  }
  
  ll sum(int a,int b){return add(a,b,0);}
};

string i2S(ll num){
  string res;
  if(num==0)return "0";
  while(num) res=(char)(num%10+'0')+res,num/=10;
  return res;
}


int main(){
  while(1){
  ll A,B;
  cin>>A>>B>>mod;
  if(!A&&!B&&!mod)return 0;
  RSQ2 T(B-A+1);
  vector<string> num;
  for(ll i=A;i<=B;i++)num.push_back(i2S(i));
  sort(num.begin(),num.end());
  
  ll ans = 0;
  T.add(0,T.n,1);
  for(ll i=A;i<=B;i++){
    int idx = lower_bound(num.begin(),num.end(),i2S(i))-num.begin();
    ll val = T.sum(idx,idx+1);
    ans=(ans+val)%mod;
    T.add(idx,T.n,val);
  }
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 12596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // [9,223,372,036,854,775,807 to -9.....808] 19 digits
typedef long double ld;
#define inc(i, a, b) for (long long int i = a; i <= b; i++)
#define dec(i, a, b) for (long long int i = a; i >= b; i--)
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define lv vector<ll>
#define cv vector<char>
#define dv vector<ld>
#define rall(c) (c).rbegin(), (c).rend()
#define lpr pair<ll, ll>
#define mp make_pair
#define cin(c) \
    ll c;      \
    cin >> c;
#define lmap unordered_map<ll, ll>
#define vinp(a, n) \
    inc(i, 1, n)   \
    {              \
        cin(k);    \
        a.pb(k);   \
    }
#define LIM 1000000007
#define F first
#define S second
#define fr(i, n) inc(i, 0, n - 1)
#define fri(n, a) \
    inc(i, 0, n - 1) { cin >> a[i]; }
//#define end cout << "\n";
#define debug(p) cout << p;
#define umap unordered_map
#define uset unordered_set
#define fill(a, val, n) \
    inc(i, 0, n - 1) { a[i] = val; }
void i_love_Accepted()
{
    ll n,k;
    cin>>n>>k;
    lv a(n);
    fri(n,a);
    sort(all(a));
    ll ans=0;
    inc(i,0,k-1)
    ans+=a[i];
    cout<<ans;
}   
int main()
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        i_love_Accepted();
        //end;
    } 
}


Measured memory_bytes: 3656
<?php
list($n, $l) = ints();
for ($i = 0; $i < $n; ++$i) list($s[]) = strs();
natsort($s);
echo implode('', $s);
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4728
a=[]
while True:
    x,y = map(int,input().split())
    if x==0 and y==0:
        break
    if x<y:
        a.append([x,y])
    if x>y:
        a.append([y,x])
    if x==y:
        a.append([x,y])
for i in range(len(a)):
    print(a[i][0],a[i][1])


Measured memory_bytes: 6240
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			long[] arr = new long[N];
			for(int i = 0; i < N; i++) { arr[i] = sc.nextLong(); }
			
			long[] DP = new long[N + 1];
			Arrays.fill(DP, Integer.MAX_VALUE);
			DP[0] = 0;
			
			for(int i = 0; i < N; i++) {
				for(int next = 1; next <= 2; next++) {
					if(i + next >= N) { continue; }
					
					DP[i + next] = Math.min(DP[i + next], DP[i] + Math.abs(arr[i] - arr[i + next]));
				}
			}
			
			System.out.println(DP[N - 1]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main() { 
  int n;
  cin>>n;
  int s = 0;
  int q = (n/500);
  n = n - (q*500);
  int r = (n/5)*5;
  cout<<(q*1000)+r<<endl;
  return 0; 
} 

Measured memory_bytes: 256
use std::cmp::min;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<u32>();
    let mut v = Vec::new();
    for _ in 0..n {
        v.push(read::<String>());
    }
    let mut  ans_vec = vec![51;26];
    for i in 0..n{
        let a_size = 'a' as usize;
        let sub = v[i as usize].chars().fold(vec![0;26],|mut x,y| {x[y as usize - a_size] +=1; x});
        for i in 0..26 { ans_vec[i] = min(sub[i],ans_vec[i]); }
    }
    let ans:String = ans_vec.iter().enumerate().flat_map(|(i,x)| vec![(i as u8 + 'a' as u8) as char;*x]).collect();
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i,j,m,r[1024],c;
	ll ans,v[10],sm,tmp;
	bool flag;
	string s[12];
	vector<int> p(10);
	cin >> n;
	while(n){
		for(i=0; i<10; ++i){
			v[i] = 0ll;
			p[i] = i+1;
		}
		fill(r,r+256,-1); c = 0; ans = 0;
		for(i=0; i<n; ++i){
			cin >> s[i];
			m = s[i].l_ength();
			for(j=0; j<m; ++j){
				if(r[s[i][j]]<0){
					r[s[i][j]] = c;
					++c;
				}
			}
		}
		for(i=0; i<n; ++i){
			m = s[i].l_ength();
			tmp = (i==n-1)?(-1ll):1ll;
			for(j=(m-1); j>=0; --j){
				v[r[s[i][j]]] += tmp;
				tmp *= 10;
			}
		}
		do{
			flag = true;
			for(i=c; i<9; ++i){
				if(p[i]>p[i+1]){
					flag = false;
					break;
				}
			}
			for(i=0; i<n; ++i){
				m = s[i].l_ength();
				if(m>1 && p[r[s[i][0]]]==1){
					flag = false;
					break;
				}
			}
			if(!flag){
				continue;
			}
			sm = 0ll;
			for(i=0; i<10; ++i){
				sm += v[i]*(p[i]-1);
			}
			if(!sm){
				++ans;
			}
		}while(next_permutation(p.begin(),p.end()));
		cout << ans << endl;
		cin >> n;
	}
	return 0;
}



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

typedef long long int ll;
typedef long double ld;
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;
    
    ll n,k;
    cin>>n>>k;
    
    vector<ll> arr(n+1);
    for(ll u=1;u<=n;u++)
        cin>>arr[u];
    
    vector<ll> brr;
    ll vis[n+1] = {0};
    
    ll i=1;
    
    while(1){
        i = arr[i];
        
        if(vis[i])
            break;
        
        brr.push_back(i);
        vis[i] = 1;
    }
    
    ll cnt = brr.size();

    ll j = 0;
    while(brr[j]!=i)
        j++;
    
    ll ans;
    
    if(k<=j){
        ans = brr[k-1];
    } else {
        ans = brr[(k-j-1)%(cnt-j) + j];
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}

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


#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)
bool visited[500][500];
int level[500][500],r,c,i,j,eR,eC,dx[]= {+1,-1,+0,+0},dy[]= {0,0,+1,-1};
char grid[500][500];
int pR,pC;

int bfs(int sr,int sc)
{
    int in;
    queue<pii > q;
    q.push({sr,sc});
    level[sr][sc]=0;
    visited[sr][sc]=1;

    while(!q.empty())
    {
        pii u=q.front();
        q.pop();

        fr(in,0,3)
        {
            int vr=u.first+dx[in], vc=u.second+dy[in];
            if(vr<0 || vr>=r || vc<0 || vc>=c)
                continue;

            if(!visited[vr][vc] && grid[vr][vc]!='#')
            {
                visited[vr][vc]=1;
                q.push({vr,vc});
                level[vr][vc]=level[u.first][u.second]+1;
            }
        }

    }

    return level[eR][eC];
}

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
    cin>>r>>c;

    vector<pii > pos;

    fr(i,0,r-1)
    {
        getchar();
        fr(j,0,c-1)
        {
            scanf("%c",&grid[i][j]);
            if(grid[i][j]=='%')
                eR=i, eC=j;
            else if(grid[i][j]=='@')
                pR=i, pC=j;
        }
    }
//    fr(i,0,r-1)
//    {
//        fr(j,0,c-1)
//        printf("%c ",grid[i][j]);
//
//        cout<<'\n';
//    }
    int tim1=bfs(pR,pC),tim2=10000;

    memset(visited,0,sizeof(visited));

    bfs(eR,eC);

    fr(i,0,r-1)
     fr(j,0,c-1)
      {
          if(grid[i][j]=='$')
          tim2=min(tim2,level[i][j]);
      }

    //cout<<tim1<<' '<<tim2<<'\n';

    printf(tim1<tim2?"Yes\n":"No\n");

    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main() {
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;//设置一个足够小的初始值存放利益
	int minv = R[0];

	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define __fd cout.setf(ios::fixed); cout.precision(18)
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;


int n,k;
int a[5000+1];

bool valid(int x){
	bool there[k];
	rep(i,0,k){
		there[i]=0;
	}
	there[0]=1;
	rep(i,0,n){
		if(i!=x && a[i]<k){
			vector<int> temp;
			rep(j,0,k){
				if(there[j]){
					if(a[i]+j<k){
						temp.pb(a[i]+j);
						// there[a[i]+j]=1;
					}
				}
			}
			iter(it,temp){
				there[(*it)]=1;
			}
		}
	}
	rep(i,max(0,k-a[x]),k){
		if(there[i]){
			return 1; //necessary
		}
	}
	return 0;
}




int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int lo = 0;
	int hi = n-1;
	int mid;
	if(valid(lo)){
		preturn(0);
	}
	if(!valid(hi)){
		preturn(n);
	}
	while(hi-lo>1){
		mid=(lo+hi)/2;
		if(!valid(mid)){
			lo = mid;
		}
		else{
			hi = mid;
		}
	}
	preturn(lo+1);
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		ll n, k, m; scanf("%lld %lld %lld", &n, &k, &m); if (n == 0 && k == 0 && m == 0) break;
		vector<int> v(n); for (int i = 0; i < n; i++) v[i] = i + 1;
		int now = m - 1;
		v.erase(v.begin() + now);
		while (v.size() > 1) {
			now = (now + k - 1) % v.size();
			v.erase(v.begin() + now);
		}
		cout << v[0] << "\n";
	}
	return 0;

}


Measured memory_bytes: 3244
n, a, b = map(int, input().split())

ans = 0

if (b - a) % 2 == 0:
    ans = (b - a) // 2
else:
    first_move = min(a - 1, n - b)
    second_move = (b - a - 1) // 2 + 1
    ans = first_move + second_move

print(ans)

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;

lli q,h,s,d;
lli n;
lli l2[4];
lli l1[3];

int main(){
	cin >> q >> h >> s >> d;
	cin >> n;
	l2[0] = q*8;
	l2[1] = h*4;
	l2[2] = s*2;
	l2[3] = d*1;
	l1[0] = q*4;
	l1[1] = h*2;
	l1[2] = s*1;
	cout << n/2*(*min_element(l2,l2+4))+n%2*(*min_element(l1,l1+3)) << endl;
}


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

int main () {
    int n, m;
    cin >> n >> m;
    int maxL = 1;
    int minR = n;
    int l, r;
    int ans = 0;

    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }

    ans = max(minR - maxL + 1, 0);
    cout << ans << endl;

}




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

using namespace std;

const int MX = 100000;

int a[MX], b[MX];
long long s[2 * MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	
	long long sa = 0, sb = 0;
	vector<tuple<int, int, int>> vec;
	for (int i = 0; i < n; i++) {
		ignore = scanf("%d %d", a + i, b + i);
		sa += a[i];
		sb += b[i];
		vec.emplace_back(a[i], i, 0);
		vec.emplace_back(b[i], i, 1);
	}
	
	sort(vec.begin(), vec.end());
	s[0] = get<0>(vec[0]);
	for (int i = 1; i < 2 * n; i++) {
		s[i] = s[i - 1] + get<0>(vec[i]);
	}
	
	long long ans = min(sa, sb);
	for (int i = 0; i < n; i++) {
		int x = lower_bound(vec.begin(), vec.end(), make_tuple(a[i], i, 0)) - vec.begin();
		int y = lower_bound(vec.begin(), vec.end(), make_tuple(b[i], i, 1)) - vec.begin();
		int k = n - 2;
		while (k + (x < k ? 0 : 1) + (y < k ? 0 : 1) < n) k++;
		
		long long cur = s[k - 1];
		if (x >= k) cur += a[i];
		if (y >= k) cur += b[i];
		ans = min(ans, cur);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


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

using namespace std;

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

    /*味の入力 */
    vector<pair<int, int>>T(n);
    for(int i = 0; i < n; i++) {
        T[i] = make_pair(l + i, i);
    }
    
    /*絶対値が最小のものを探す */
    vector<pair<int, int>>a(n);
    for(int i = 0; i < n; i++) {
        a[i] = make_pair(abs(T[i].first), T[i].second);
    }
    sort(a.begin(), a.end());

    /*合計値ー絶対値最小のリンゴ */
    int sum = 0;
    for(int i = 0; i < n; i++) {
        sum += T[i].first;
    }

    sum = sum - T[a[0].second].first;

    cout << sum << endl;

    return 0;
}

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

bool several(vector<string> w){
  bool isSeveral = false;
  for(int i=0; i<w.size(); i++){
    for(int j=i+1; j<w.size(); j++){
      if(w.at(i) == w.at(j)){
        isSeveral = true;
        return isSeveral;
      }
    }
  }
  return isSeveral;
}
int main(){
  int n; cin>>n;
  vector<string> w(n);
  for(int i=0; i<n; i++){
    cin>>w.at(i);
  }
  
  bool shiritori=true;
  for(int i=1; i<n; i++){
    if(w.at(i).front() != w.at(i-1).back()){
      shiritori=false;
      break;
    }
    if(several(w)){
      shiritori=false;
      break;
    }
  }
  
  if(shiritori)
    cout<<"Yes";
  else
    cout<<"No";
}


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

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> ans(N);
  rep(i, N) {
    ans[N - A[i]] = i + 1;
  }

  reverse(ans.begin(), ans.end());

  rep(i, N) {
    printf("%d%c", ans[i], (i != N - 1) ? ' ' : '\n');
  }
}

Measured memory_bytes: 1536
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int d;

vector<int> c;
vector<vector<int>> s;
vector<int> t;
//set<pair<int, int>> st;
vector<int> st;

int last(int d, int i) {
  int j;

  for (j=d; j>=0; j--) {
    if (t[j] == i) return d-j;
  }
  return d+1;
}

int cdiff(int, int);

int main()
{
  int i, j;

  c.resize(26);
  cin >> d;
  for(i=0; i<26; i++) {
    cin >> c[i];
  }

  s.resize(d);
  for (i=0; i<d; i++) {
    s[i].resize(26);
    for (j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  /*
  for (j=0; j<26; j++) {
    int ssum;
    ssum=0;
    for (i=0; i<d; i++) {
      ssum += s[i][j];
    }
    st.insert(make_pair(ssum, j));
  }
    */
  st.resize(d);
  for (i=0; i<d; i++) {
    int smax; int smi;
    smax=0;
    for (j=0; j<26; j++) {
      if (s[i][j] > smax) {
        smax = s[i][j];
        smi = j;
      }
    }
    st[i] = smi;
  }

  t.resize(d);

//  auto its = st.rbegin();
//printf("its->second = %d %d\n", its->second, its->first);
  for (i=0; i<d; i++) {
//    t[i] = i%26;
//    t[i] = 0;
//    t[i] = its->second;
    t[i] = st[i];
  }
  int conf = 0;

  for (i=0; i<d; i++) {
    conf += s[i][t[i]];
//printf("+ %d\n", s[i][t[i]]);
    for (j=0; j<26; j++) {
      int cm;
      cm = c[j] * last(i, j);
      conf -= cm;
//printf("- %d\n", cm);
    }
  }

//printf("conf = %d\n", conf);

  int maxconf, pmax;
  maxconf = conf;

  for (int loop=0; loop<100; loop++) {

    pmax = maxconf;
    for (i=0; i<d; i++) {
      int oc;
      int mc;
      oc = t[i];
      mc = oc;
//printf("t[%d] = %d conf = %d\n", i, oc, conf);
      for (j=(oc+1)%26; j!=oc; j=(j+1)%26) {
        conf += cdiff(i, j);
//printf("t[%d] = %d conf = %d\n", i, t[i], conf);
        if (conf > maxconf) {
          maxconf = conf;
          mc = j;
//printf("%d %d %d\n", i, j, conf);
        }
      }
      t[i] = mc;
      conf = maxconf;
    }
    if (maxconf == pmax) break;
    pmax = maxconf;
//printf("maxconf = %d\n", maxconf);
  }

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

  return 0;
}
int cdiff(int xd, int xq) {
  int rdiff;
  int oq;
  int j;

  oq = t[xd];

  rdiff = s[xd][xq] - s[xd][oq];
//printf("s[%d][%d] = %d -> s[%d][%d] = %d\n", xd ,oq, s[xd][oq], xd, xq, s[xd][xq]);

  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff += c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff += c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }

  t[xd] = xq;
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff -= c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff -= c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }
  return rdiff;
}


Measured memory_bytes: 3788
import math
N = int(input())

# 素因数分解が必要？
# 約数の個数 N = a^x + b^y +c^z+ ...（a, b, cは素因数）の時、
# 約数の個数は(x+1)*(y+1)*(z+1)*...

factor = dict()
#素因数分解した素因数と個数をリストにしたリストを返す関数
def trial_division(n):
    tmp = int(math.sqrt(n)) + 1
    a = n
    flag = False
    for num in range(2, tmp):
        while a%num == 0:
            a //= num
            if num in factor:
                factor[num] += 1
            else:
                factor[num] = 1
            flag = True
    
    if not flag and n != 1:
        factor[n] = 1
    if flag:
        if a in factor:
            factor[a] += 1
        else:
            factor[a] = 1

    # print (n, factor)
    return True

for i in range(1, N+1):
    trial_division(i)

ans = 1
for i in factor:
    if i == 1:
        pass
    else:
        ans *= (factor[i]+1)
print (ans%(7 + 10 ** 9))

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	long long n,m,ans=0;

	scanf("%lld %lld",&n,&m);
	if(n*2>m){
		ans += m/2;
	}
	else{
		ans += n;
		m -= n*2;

		ans += m/4;

	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
 
    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import collections 
N , K , Q = map(int, input().split())
A = [input() for i in range(Q)]
A = sorted(A)

L = [K for i in range(N)]

C = collections.Counter(A)

V = C.values()
I = C.items()
LI = list(I)


BOR = 0
M = []

for i in range(len(LI)):
    BOR = K - (Q - LI[i][1])
    if BOR > 0:
        M.append(LI[i][0])
        


M = [int(str) for str in M]


if K > Q:
    for i in range(1, N+1, 1):
        print("Yes")
    exit()

for i in range(1, N+1, 1):
    if i in M:
        print("Yes")
    else:
        print("No")
    

Measured memory_bytes: 113872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int table[] = new int[128];
        String work[] = new String[2];
        String outPut[] = {"S","H","C","D"};
 
        table['S'] = 0;
        table['H'] = 1;
        table['C'] = 2;
        table['D'] = 3;
 
        boolean check[][] = new boolean[4][14];
        for(int row = 0; row < 4; row++){
            for(int col = 1; col <= 13; col++)check[row][col] = false;
        }
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            for(int loop = 0; loop < N; loop++){
                work = br.readLine().split("\\s+");
                check[table[work[0].charAt(0)]][Integer.parseInt(work[1])] = true;
            }
 
            for(int row = 0; row < 4; row++){
                for(int col = 1; col <= 13; col++){
                    if(!check[row][col]){
                        System.out.printf("%s %d\n", outPut[row],col);
                    }
                }
            }
 
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,m,p[105],ans;
vector<int>s[105];
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int a;
			cin>>a;
			a--;
			s[i].PB(a);
		}
	}
	for(int i=0;i<m;i++)cin>>p[i];
	for(int i=0;i<1<<n;i++){
		bool ok=true;
		for(int j=0;j<m;j++){
			int q=0;
			for(int k=0;k<s[j].size();k++){
				int x=s[j][k];
				if(i>>x&1)q++;
			}
			if(q%2!=p[j])ok=false;
		}
		if(ok)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
long long int dis[105][105],path1[1005],path2[1005],value[1005];
int main()
{
    long long int n,m,i,j,k,a,b;
    scanf("%lld%lld",&n,&m);
    for(i=0;i<105;i++)
        for(j=0;j<105;j++)
        dis[i][j]=99999999;
    for(i=0;i<m;i++)
    {
        scanf("%lld%lld%lld",&a,&b,&j);
        dis[a][b]=dis[b][a]=j;
        path1[i]=a;
        path2[i]=b;
        value[i]=j;
    }
    for(k=1;k<=n;k++)
        for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        if(dis[i][k]+dis[k][j]<dis[i][j])
        dis[i][j]=dis[i][k]+dis[k][j];
    int sum=0;
    for(i=0;i<m;i++)
        if(dis[path1[i]][path2[i]]<value[i])
        sum++;
    printf("%lld",sum);


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int n;
	cin>>n;
	auto d = vector<ll>(n,0);
	for(int i=0;i<n;i++){
		cin >> d[i];
	}

	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(i==j) continue;
			ans+=d[i]*d[j];
		}	
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int a,b;
  cin >> a >> b;
  if(a<10&&b<10){
  	cout << a*b << endl;
  }else{
  	cout << -1 << endl;
  }
}


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

class dijkstra{
  constructor(n){
    this.graph = Array(n).fill().map(a=>[]);
  }
  add(u,v,cost){
    this.graph[u].push(v,cost);
  }
  add2(u,v,cost){
    this.graph[u].push(v,cost);
    this.graph[v].push(u,cost);
  }
  solve(start){
    const INF = 1e18;
    const g = this.graph;
    var pq = new priorityQueue();
    pq.push([0,start]);
    var dp = Array(g.length).fill(INF);
    dp[start] = 0;
    while(pq.size){
      var [t,v] = pq.pop();
      if(dp[v] < t)continue;
      for(var i = 0; i < g[v].length; i+=2){
        var V = g[v][i], c = g[v][i+1] + t;
        if(dp[V] <= c)continue;
        dp[V] = c;
        pq.push([c,V]);
      }
    }
    return dp;
  }
}

class priorityQueue{
  constructor(){
    this.a=[];
  }
  push(x){
    const a = this.a;
    var i = a.length;
    while(i){
      var j = i - 1 >> 1;
      if(x[0] >= a[j][0])break;
      a[i] = a[j];
      i = j;
    }
    a[i] = x;
  }
  pop(){
    const a = this.a;
    var r = a[0];
    var x = a.pop();
    var i = 0;
    var k = a.length >> 1;
    while(i < k){
      var j = (i << 1) + 1;
      if(a[j+1] && a[j][0] > a[j+1][0])j++;
      if(a[j][0] >= x[0])break;
      a[i] = a[j];
      i = j;
    }
    if(a.length)a[i] = x;
    return r;
  }
  get size(){
    return this.a.length;
  }
  get top(){
    return this.a[0];
  }
}

const mx = 2500;

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

function main(){
  var [n,m,s] = nexts(3);
  var g = new dijkstra(mx * n);
  for(var i = 0; i < m; i++){
    var [u,v,a,b] = nexts(4);
    u--,v--;
    u *= mx, v *= mx;
    for(var j = mx; j-- > a;){
      g.add(u+j,v+j-a,b);
      g.add(v+j,u+j-a,b);
    }
  }
  for(var i = 0; i < n; i++){
    var [c,d] = nexts(2);
    var v = i * mx;
    for(var j = 0; j < mx-1; j++)g.add(v+j,v+Math.min(mx-1,j+c),d);
  }
  var dp = g.solve(Math.min(mx-1,s));
  var ans = xArray(1e18,n);
  for(var i = 1; i < n; i++){
    var v = i*mx;
    for(var j = 0; j < mx; j++){
      ans[i] = Math.min(ans[i],dp[v+j]);
    }
  }
  return ans.slice(1).join("\n");
}

Measured memory_bytes: 112308
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


int cnt[110];
void err() {
	puts("Impossible");
	exit(0);
}

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

	int N;
	cin >> N;
	int ma = -1;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
		ma = max(ma, a);
	}

	for (int i = 0; i <= ma; i++) {
		cnt[max(i,ma-i)]--;
		if (cnt[max(i,ma-i)] < 0)err();
	}
	for (int i = 1; i < ma; i++) {
		cnt[max(i,ma-i)+1] = 0;
	}
	fore(x, cnt)if (x != 0)err();
	puts("Possible");


	return 0;
}

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

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

    long long ans = 0;
    for(long long i = 0; i < n; i++){
        long long l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

// list up all prime factors, including how many times does it have the prime
template <typename T = int>
void primeFactors(T a, map<T, int> &facs) {
    double sqrtA = sqrt(a);
    for (int i = 2; i <= sqrtA + 1e-10; ++i) {
        while (a % i == 0) {
            facs[i]++;
            a /= i;
        }
    }
    if (a > sqrtA)
        facs[a]++;
    return;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    map<lint, int> facs;
    primeFactors(n, facs);
    lint ret = 0;
    for (auto &p : facs) {
        int c = 1;
        while (p.second >= c) {
            ret++;
            p.second -= c;
            c++;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3676