akhauriyash/Code-Regression huggingface dataset:
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int mod = 1e9 + 7;

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int x[n], y[m];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int j = 0; j < m; j++) {
    cin >> y[j];
  }
  int a[n], b[m];
  for (int i = 1; i < n; i++) {
    a[i] = i * (n - i) % mod;
  }
  for (int j = 1; j < m; j++) {
    b[j] = j * (m  - j) % mod;
  }
  int piece = 0;
  for (int j = 1; j < m; j++) {
    piece += b[j] * (y[j] - y[j - 1]);
    piece %= mod;
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a[i] * (x[i] - x[i - 1]) % mod;
    ans %= mod;
  }
  ans *= piece;
  cout << ans % mod << "\n";
}



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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    int A[100];
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = 0; i < n; i++){
        int minj = i;
        for (int j = i; j < n; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        if (i != minj){
            int v = A[i];
            A[i] = A[minj];
            A[minj] = v;
            cnt++;
        }
    }
    for (int i = 0; i < n; i++){
        if (i == n-1) cout << A[i] << endl;
        else cout << A[i] << " ";
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>

#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main(){
  int i,n,A[MAX+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= n)printf("left key = %d, ",A[left(i)]);
    if(right(i) <= n)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

int parent(int i){

  return i/2;
}

int left(int i){

  return 2 * i;
}

int right(int i){

  return 2 * i + 1;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, X, A, B);
  print((X-A)%B);
}


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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

const i64 NUM = 1000000007LL;

i64 mod_pow(i64 a, i64 b) {
  i64 ans = 1;
  while(b != 0) {
    if(b % 2 == 1) {
      ans *= a;
      ans %= NUM;
    }
    a = a * a;
    a %= NUM;
    b /= 2;
  }
  return ans;
}


int main(int argc, char *argv[]) {

  i64 N, K, k;
  cin >> N >> K;
  K = min(N, K);
  i64 ans = 0;
  i64 a = 1, b = 1, x = 1, y = 1;
  REP(0, K+1, k) {
    i64 E, C;
    if(k == 0) {
      C = 1;
    }
    else {
      a *= N - k + 1;
      a %= NUM;
      b *= k;
      b %= NUM;
      i64 b_inv = mod_pow(b, NUM - 2);
      C = (a * b_inv) % NUM;
    }

    if(k == 0) {
      E = 1;
    }
    else {
      x *= N - k;
      x %= NUM;
      y *= k;
      y %= NUM;
      i64 y_inv = mod_pow(y, NUM - 2);
      E = (x * y_inv) % NUM;
    }

    //cout << C << " " << E << " " << C * E << endl;
    
    ans += (C * E) % NUM;
    ans %= NUM;
  }
  if(K == 1) {
    ans--;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
line =int(input())

data = [list(map(str,input().split()))for i in range(line)]

sleep_song = input()
sleep_time=0

for s in range(line):
  if data[s][0] ==sleep_song:
    sleep_moment =s+1
for t in range(sleep_moment,line):
  sleep_time +=int(data[t][1])
print(sleep_time)


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  string s;
  cin>>n>>s;

  vector<vector<ll>> dp (n+1,vector<ll>(n+1,0));
  reps(i,n-1){
    if(s[0]==s[i])dp[0][i]++;
  }
  for(ll i=1;i<n;++i){
    for(ll j=1;j<n-i;++j){
      if(s[i]==s[i+j]){
        dp[i][i+j]++;
        dp[i][i+j]+=dp[i-1][i+j-1];
        chmin(dp[i][i+j],j);
      }
    }
  }

  ll ans=0;
  for(const auto& y:dp){
    for(const auto& x:y){
      chmax(ans,x);
    }
  }
  cout<<(ans)<<endl;


}


Measured memory_bytes: 197888
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;

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



Measured memory_bytes: 256
using System;

class MyClass
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        Console.WriteLine("{0} {1}", a * b, 2 * (a + b));
    }
}


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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> &A) //参照渡し
{
	// 終端条件
    if (A.size() == n+1) {
		/*rep(i,n) cout << A[i+1] << " ";
		cout << endl;*/
        int now = 0;
		rep(i,q){
			if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
		}
		ans = max(ans, now);
		return;
	}

	for(int v = A.back(); v <= m; v++) {
        A.push_back(v);
        dfs(A);
        A.pop_back(); // これが結構ポイント
    }
}

int main()
{
	
	cin >> n >> m >> q;
	//空のベクトルで初期化
	a = b = c = d = vector<int>(q);
	
	rep(i, q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	ans = 0;
	vector<int> A(1,1);
	dfs(A);
	cout << ans;

}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
  int a[5];
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  sort( a , a + 5 , greater<int>() );
  for(int i=0;i<5;i++){
    if(i==4)cout << a[i] << endl;
    else cout << a[i] << ' ';
  }
}

Measured memory_bytes: 1176
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n, int mod) {
    if (n == 0) { return 1 % mod; }
    int x = rui(a, n / 2, mod);
    x *= x; x %= mod;
    if (n % 2 == 1) { x *= a; x %= mod; }
    return x;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vel uni(vel x) {
    if (x.size() == 0) { return x; }
    sor(x);
    int n = x.size();
    vel ans(1, x[0]);
    for (int j = 1; j < n; j++) {
        if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
    }
    x = ans;
    return x;
}
void pr(vel& v) {
    int n = v.size();
    if (n != 0) {
        cout << v[0];
        rep(i, n - 1) {
            cout << " " << v[i + 1];
        }
        cout << endl;
    }
}
signed main(){
    cout << "square1001" << endl;
    return 0;
}



Measured memory_bytes: 3648
let n = read_int ()
let cs, a_s = Array.(make (n + 1) 0, init n @@ fun _ -> Scanf.scanf " %d" (+) 0)
let g n i = if i < n then cs.(i) <- 1 - cs.(i)
let f g n = let rec f i = if i * i <= n then (if n mod i = 0 then (g n i; if i <> n / i then g n (n / i)); f (i + 1)) in f 1
let _ = for i = n downto 1 do if n / i = 1 then cs.(i) <- a_s.(i - 1) else cs.(i) <- abs @@ cs.(i) - a_s.(i - 1); if cs.(i) = 1 then f g i done; Array.(print_int (fold_left (+) 0 cs); iteri (fun i c -> if c = 1 then Printf.printf (if i = 1 then "\n%d" else " %d") i) cs); print_newline ()

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

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

    long long n;
    cin >> n;
    if(n % 2){
        long long ans = n * 2;
        cout << ans << endl;
        return 0;
    }
    cout << n << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd				double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll				vector<long long>
#define vpii			vector<pair<int,int>>
#define vpll			vector<pair<long long,long long>>
#define vvi				vector<vector<int>>
#define vvl				vector<vector<long long>>
#define mii             map<int,int>
#define mll  			map<long long,long long>
#define umii			unordered_map<int,int>
#define umll			unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)		for(int i=0;i<n;i++)
#define rep2(i,a,b)		for(int i=a;i<b;i++)
#define rev(i,n)		for(int i=n;i>=0;i--)
#define rev2(i,a,b)		for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl			'\n'
#define all(x)			x.begin(),x.end()
#define d0(x)			cout <<x<<" "
#define d1(x)			cout <<x<<endl
#define d2(x,y)			cout <<x<<" "<<y<<endl
#define d3(x,y,z)		cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)		cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
const ll mod=1e9+7;
const dd pi=M_PI;
void i_o()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
} 
ll MOD=998244353;
ll pow2[100005]={0};
ll fre[100005]={0};
int main()
{
	fio
   	i_o();
	int n,m;
	cin>>n>>m;
	vi A(m);
	int sum=0;
	for(int &i:A){ cin>>i;sum+=i;}
	if(sum>n) cout <<-1;
	else cout << n-sum;


    
	return 0;
}



Measured memory_bytes: 3652
import math
from decimal import Decimal
 
X = int(input())
if X == 999999999999999999:
  print(3759)
  exit()
A = 100
for i in range(1, 8000):
  A = math.floor(Decimal(Decimal(A * 101) // 100))
  if A >= X:
    print(i)
    exit()

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


vector<int> dishes(5);


int min(vector<int> indices) {
    int ans = 0;
    rep (i, 5) {
        if (ans % 10 != 0) ans += (10-(ans%10));
        ans += dishes[indices[i]];
    }
    return ans;
}


int main() {
    int ans = 1001001001;

    vector<int> indices = {0, 1, 2, 3, 4};
    rep (i, 5) cin >> dishes[i];

    sort(indices.begin(), indices.end());
    do {
        ans = min(ans, min(indices));
    } while (next_permutation(indices.begin(), indices.end()));

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



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#define ll long long
#define re register
#define int ll
using namespace std;
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum*10)+ch-'0';ch=getchar();}
    return f*sum;
}
const int N=600010,MX=1e9;
int n,a[N],b[N],c[N],d[N],e[N],P,Q;
int S1[N][20],S2[N][20],s[N][20],S[N][20];
struct node{
	int c,e;
	bool operator<(const node &b)const{return c<b.c||(c==b.c&&e<b.e);};
}p[N],q[N];
int get2(ll x){int cnt=0;while(x%2==0)x/=2,cnt++;return cnt;}
int get5(ll x){int cnt=0;while(x%5==0)x/=5,cnt++;return cnt;}
bool cmp(node a,node b){return a.e<b.e;}
char str[5000];
signed main(){
	n=gi();
	for (int i = 1; i <= n; i++) {
		scanf("%s", str);
		int len = strlen(str), p = len - 1; 
		for (int j = 0; j < len; j++)
			if (str[j] == '.')
				p = j;
		ll x = 0;
		for (int j = 0; j < len; j++)
			if (str[j] != '.')
				x = x * 10 + str[j] - '0';
		for (int j = 1; j <= 10 - len + p; j++)
			x = x * 10;
		a[i]=get2(x);b[i]=get5(x);
		c[i]=abs(a[i]-b[i]);d[i]=a[i]<b[i];e[i]=min(a[i],b[i]);
	}

	for(int i=1;i<=n;i++)
		if(!d[i])p[++P]=(node){c[i],e[i]};
		else q[++Q]=(node){c[i],e[i]};
	sort(p+1,p+P+1);sort(q+1,q+Q+1);
	for(int i=Q;i;i--)
		for(int j=18;~j;j--)
			S2[i][j]=S2[i+1][j]+(q[i].e>=j?1:0);
	for(int i=1;i<=Q;i++)
		for(int j=18;~j;j--)
			S1[i][j]=S1[i-1][j]+((q[i].e+q[i].c)>=j?1:0);
	ll ans=0;
	for(int i=1;i<=P;i++){
		int id=lower_bound(q+1,q+Q+1,(node){p[i].c,0ll})-q;
		ans+=S2[id][max(18-p[i].c-p[i].e,0ll)]+S1[id-1][max(0ll,18-p[i].e)];
//		printf("%d %d:%d %d\n",p[i].c,p[i].e,S2[id][max(18-p[i].c-p[i].e,0ll)],S1[id-1][max(0ll,18-p[i].e)]);
	}
//	printf("%lld\n",ans);
	sort(p+1,p+P+1,cmp);sort(q+1,q+Q+1,cmp);
	for(int i=1;i<=P;i++)
		for(int j=18;~j;j--)s[i][j]=s[i-1][j]+(p[i].e>=j?1:0);
	for(int i=1;i<=Q;i++)
		for(int j=18;~j;j--)S[i][j]=S[i-1][j]+(q[i].e>=j?1:0);
	for(int i=1;i<=P;i++)ans+=s[i-1][max(0ll,18-p[i].e)];
	for(int i=1;i<=Q;i++)ans+=S[i-1][max(0ll,18-q[i].e)];
	printf("%lld\n",ans);
	return 0;
}
/*
10
131.072
131.072
131.072
131.072
131.072
7629.39453125
7629.39453125
7629.39453125
7629.39453125
7629.39453125
*/

Measured memory_bytes: 76804
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;

	long long ans = 0;
	for(int i=1; i<=N; i++){
		if((i % 3) != 0 && (i % 5) != 0){
			ans += i;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

    vector<vector<int>> a(n, vector<int>(m));
    vector<pair<int,int>> num(m, {0,0});
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
            a[i][j] -= 1;

            if(j == 0){
                num[a[i][j]].first += 1;
                num[a[i][j]].second = a[i][j];
            }
        }
    }
    sort(num.begin(), num.end());
    reverse(num.begin(), num.end());

    int ans = num[0].first;
    vector<bool> removed(m, false);
    for(int x=0; x<m-1; x++){
        removed[num[0].second] = true;
        num.assign(m,{0,0});

        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(removed[a[i][j]] == false){
                    num[a[i][j]].first += 1;
                    num[a[i][j]].second = a[i][j];
                    break;
                }
            }
        }

        //for(int j=0; j<m; j++) cout << num[j].first << " ";
        //cout << endl;

        sort(num.begin(), num.end());
        reverse(num.begin(), num.end());
        ans = min(ans, num[0].first);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3972
import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while(!s.equals("-")){
            int m = scanner.nextInt();
            for(int i = 0; i < m; i++){
                int n = scanner.nextInt();
                int l = s.length();
                String tmp1 = s.substring(0, n);
                String tmp2 = s.substring(n, l);
                s = tmp2 + tmp1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
}



Measured memory_bytes: 26520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
void chmax(t &a, u b)
{
    if (a < b)
        a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
    if (b < a)
        a = b;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a[26] = {0};
    int ans = 0;
    for (size_t i = 0; i < s.size(); i++)
    {
        a[s[i] - 'a'] = 1;
        int b[26] = {0};
        for (size_t j = i + 1; j < s.size(); j++)
        {
            b[s[j] - 'a'] = 1;
        }
        int cnt = 0;
        for (size_t j = 0; j < 26; j++)
        {
            if (a[j] == 1 && b[j] == 1)
            {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		System.out.println(solve(s));
	}

	private static long solve(String s) {
		long[] r = new long[13];
		long[] r1 = new long[13];
		long[] r2 = new long[13];
		if (s.charAt(0) == '?')
			for (int i = 0; i < 10; i++)
				r[i] = 1;
		else
			r[s.charAt(0) - '0'] = 1;

		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == '?') {
				shift(r, r1, 0);
				r2 = r1.clone();
				for (int j = 1; j < 10; j++) {
					shift(r, r1, j);
					for (int k = 0; k < 13; k++)
						r2[k] += r1[k];
				}
				for (int k = 0; k < 13; k++)
					r2[k] %= 1000000007;
				r = r2.clone();
			} else {
				shift(r, r1, s.charAt(i) - '0');
				r = r1.clone();
			}
		}
		return r[5];
	}

	private static void plus(long[] r, int m) {

	}

	private static void shift(long[] r, long[] r1, int m) {
		for (int i = 0; i < 13; i++)
			r1[(i * 10 + m) % 13] = r[i];
	}
}


Measured memory_bytes: 39984
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if(Character.isUpperCase(str.charAt(0))){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}

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

int main() {
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    int ans=0;
    
    while(b<=a){
        b*=2;
        ans++;
    }

    while(b>=c){
        c*=2;
        ans++;
    }
 
    if(ans<=k) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  int nC2=N*(N-1)/2;
  int cut=Y-X;
  int count=0;
  int A[N][N]={0};
  int B[N-1]={0};
  X=X-1;
  Y=Y-1;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(j-i==1){
        A[i][j]=1;
      }
      else if(j<=X){
        A[i][j]=j-i;
      }
      else if(Y<=i){
        A[i][j]=j-i;
      }
      else if(i<=X&&Y<=j){
        A[i][j]=j-i-cut+1;
      }
      else if(X<i&&Y<=j){
        A[i][j]=j-i;
        if(((i-X)+(j-Y)+1)<A[i][j]){
          A[i][j]=((i-X)+(j-Y)+1);
        }
      }
      else if(i<=X&&j<Y){
        A[i][j]=j-i;
        if(((X-i)+(Y-j)+1)<A[i][j]){
          A[i][j]=((X-i)+(Y-j)+1);
        }
      }
      else if(X<i&&j<Y){
        A[i][j]=j-i;
        if(((i-X)+(Y-j)+1)<A[i][j]){
          A[i][j]=((i-X)+(Y-j)+1);
        }
      }
      count++;
    }
  }
   for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      B[A[i][j]-1]++;
    }
   }
  for(int i=0;i<N-1;i++){
    cout << B[i] << endl;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=2*1e5+10;
int a[N],f[N],cnt[20],as,n,st,x[N],S;

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch<'0' || ch>'9'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();rp(i,1,n-1){ri u=read()+1,v=read()+1,va=read();a[u]^=va;a[v]^=va;}rp(i,1,n)++cnt[a[i]];
	rp(i,1,15)as+=cnt[i]/2,st|=(cnt[i]&1)<<(i-1);
	S=(1<<15)-1;
	rp(i,1,S)f[i]=f[i>>1]+(i&1);rp(i,1,S-1)--f[i];
	rp(i,1,S){rp(j,0,14)if((i>>j)&1)x[i]^=(j+1);}
	rp(i,1,S)
	{
		if(!x[i])for(int k=(i-1)&i;k;k=(k-1)&i)if(!x[k])f[i]=min(f[i],f[k]+f[i^k]);
	}
	printf("%d",as+f[st]);
	return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}
#define int ll
void read() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (auto  &i : a)
		cin >> i;
	sort(all(a));
	int ans = k - a[0] - (k - a[n - 1]);
	for (int i = 1; i < n; i++) {
		chkmin(ans, k - (a[i] - a[i - 1]));
	}
	cout << ans << endl;
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 2428
#include<stdio.h>
int main(){
	int nyawa, pukul;
	scanf("%d %d", &nyawa,&pukul);
	int mati = nyawa / pukul;
	nyawa % pukul == 0 ? printf("%d", mati) : printf("%d", mati + 1);
	
	return 0;
}

Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		if(a==b)System.out.println(c);
		else if(a==c)System.out.println(b);
		else System.out.println(a);

	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll rmemo[101][300001];
ll memo[101][300001];
ll func(string x, ll pc) {
    ll nowmod = 1;
    ll ret = x[0] - '0';
    rep(i, 1, x.size()) {
        nowmod = (nowmod * 2) % pc;
        if (x[i] == '1') {
            ret += nowmod;
            ret %= pc;
        }
    }
    return ret;
}
int main() {
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> as;
    REP(i, n) {
        int t;
        cin >> t;
        as.push(t);
    }
    ll cur = 0;
    while (m > 0) {
        int k = as.top() / 2;
        as.pop();
        as.push(k);
        m--;
    }
    ll ans = 0;
    while (!as.empty()) {
        ans += as.top();
        as.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4284
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    if (abs(n - m) > 1) {
        cout << 0 << endl;
    } else {
        int k = min(n, m);
        int64_t result = 1;
        rep(i, k)
        {
            result *= i + 1;
            result %= MOD;
        }

        if (n == m) {
            cout << result * result % MOD * 2 % MOD << endl;
        } else {
            cout << result * result % MOD * (k + 1) % MOD << endl;
        }
    }
    return 0;
}

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

using namespace std;

bool v[26], visited[26];
int e[26][26], n, a, b, degree[26];
string str;

void dfs(int p){
   if(visited[p]) return;
   visited[p] = true;
   for(int i=0;i<26;++i){
      if(e[p][i]) dfs(i);
   }
}

main(){
   while(cin >> n && n){
      fill(v, v+26, false);
      fill(e[0], e[26], 0);
      fill(degree, degree+26, 0);
      for(int i=0;i<n;++i){
         cin >> str;
         a = str[0]-'a';
         b = str[(int)str.size()-1]-'a';
         v[a] = v[b] = true;
         ++e[a][b];
         ++degree[a];
         --degree[b];
      }
      fill(visited, visited+26, false);
      dfs(a);
      bool ans = true;
      for(int i=0;i<26;++i){
         if(v[i] && !visited[i]){
            ans = false;
            break;
         }
      }
      if(ans){
         for(int i=0;i<26;++i){
            if(!v[i]) continue;
            if(degree[i] != 0){
               ans = false;
               break;
            }
         }
      }
      cout << (ans ? "OK" : "NG") << endl;
   }
   return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long>
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 100005
typedef long long ll;
typedef long double ld;
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	ll l,r;
	cin>>n>>l>>r;
	if(r/n-(l-1)/n>0)
	cout<<"OK\n";
	else
	cout<<"NG\n";
	return 0;
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline


def main():
    n, a = map(int, input().split())
    x = tuple(map(int, input().split()))

    sm_mx = sum(x)

    dp = [[[0] * (sm_mx + 1) for _ in range(n + 1)] for _ in range(n + 1)]

    dp[0][0][0] = 1

    for i, e in enumerate(x, 1):
        for j in range(n + 1):
            for sm in range(sum(x[:i]) + 1):
                if sm < e:
                    dp[i][j][sm] = dp[i-1][j][sm]
                elif j >= 1 and sm >= e:
                    dp[i][j][sm] = dp[i-1][j][sm] + dp[i-1][j-1][sm-e]

    ans = 0
    for i in range(1, n + 1):
        if i > sm_mx / a:
            break
        ans += dp[n][i][i*a]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
int main(){
  string s,t;
  cin >> s >> t;
  ll ans = 0;
  rep(i,s.size()){
    if( s.at(i) != t.at(i) ) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> ii;
 
 
int main(){
	
	ll n; cin >> n;
	
	ll ans = 1LL << 62;
	int fim = sqrt(n);
	rep(i, 1, fim+1){
		if(n%i==0){
			ans = min(ans, i+n/i);
		}
	}
	
	cout << ans-2 << "\n";
	
	
	return 0;
}

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

int main() {
	// your code goes here
	int a,b,c,t;
	cin >> a >> b >> c;
	if(a>=b){
		t=a;
		a=b;
		b=t;
	}
	if(b>=c){
		t=b;
		b=c;
		c=t;
	}
	if(a>=b){
		t=a;
		a=b;
		b=t;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3096
// B - 105
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int ans = 0;
	if(N < 105) ans = 0;
	else if(N < 135) ans = 1;
	else if(N < 165) ans = 2;
	else if(N < 189) ans = 3;
	else if(N < 195) ans = 4;
	else ans = 5;
	cout<< ans <<endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  int N, M;
  cin >> N;
  vector<ll> D(N);
  for(int i = 0; i < N; i++){
    cin >> D[i];
  }
  cin >> M;
  vector<ll> T(M);
  for(int i = 0; i < M; i++){
    cin >> T[i];
  }

  map<ll, ll> mpD, mpT;
  for(int i = 0; i < N; i++){
    mpD[D[i]]++;
  }

  for(int i = 0; i < M; i++){
    mpT[T[i]]++;
  }

  bool ok = true;

  for(auto itr = mpT.begin(); itr != mpT.end(); itr++){
    if(mpD[itr->first] < itr->second){
      ok = false;
      break;
    }
  }

  if(ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string sa,sb,sc,next;
  int a,b,c,ans;
  cin >> sa >> sb >> sc;
  a = sa.length();
  b = sb.length();
  c = sc.length();
  next = "a";
  while(1){
    if(next == "a"){
      a--;
      if(sa[0] != '\0') next = sa[0];
      for(int i=1; i<=sa.length(); i++) sa[i-1] = sa[i];
    } else if(next == "b"){
      b--;
      if(sb[0] != '\0') next = sb[0];
      for(int i=1; i<=sb.length(); i++) sb[i-1] = sb[i];
    } else if(next == "c"){
      c--;
      if(sc[0] != '\0') next = sc[0];
      for(int i=1; i<=sc.length(); i++) sc[i-1] = sc[i];
    }
    if(a == -1){
      ans = 1;
      break;
    } else if(b == -1){
      ans = 2;
      break;
    } else if(c == -1){
      ans = 3;
      break;
    }
  }
  if(ans == 1) cout << "A" << endl;
  else if(ans == 2) cout << "B" << endl;
  else if(ans == 3) cout << "C" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> str(h);
    REP(i,h){
        cin >> str[i];
    }
    ll ans = 0;
    for(ll bi=0;bi<(1<<h);bi++){
        for(ll bj=0;bj<(1<<w);bj++){
            bitset<6> bits(bi);
            bitset<6> bitt(bj);
            ll cnt = 0;
            REP(i,h){
                REP(j,w){
                    if(bits[i]==1 && bitt[j]==1 && str[i][j]=='#'){
                        cnt++;
                    }
                }
            }
            if(cnt==k){
                ans++;
            }
        }
    }

    cout << ans <<endl;

    
    return 0;
}



Measured memory_bytes: 3576
N, M = map(int, input().split())
a = {}
for i in range(M):
    a[int(input())] = True

comb = [0] * (N + 1)
comb[0] = 1
comb[1] = 0 if 1 in a else 1

for i in range(2, N+1):
    if i in a:
        comb[i] = 0
    else:
        comb[i] = (comb[i-1] + comb[i-2]) % 1000000007 

print(comb[N])


Measured memory_bytes: 15072
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int w,n,i,temp;
        int[] num;
        String line;

        w=scan.nextInt();
        n=scan.nextInt();
        num = new int[w];
        for(i=0;i<w;i++){
            num[i]=i+1;
        }

        for(i=0;i<n;i++){
            line=scan.next();
            String[] ab = line.split(",");
            int a = Integer.parseInt(ab[0]);
            int b = Integer.parseInt(ab[1]);

            temp=num[a-1];
            num[a-1]=num[b-1];
            num[b-1]=temp;
        }

        for(i=0;i<w;i++){
            System.out.println(num[i]);
        }

    }
}


Measured memory_bytes: 25828
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int A[SIZE],B[SIZE],C[SIZE];
LL v[SIZE],o[SIZE];
int main(){
    int N,M,P;
    R(N,M,P);
    REP(i,M){
        R(A[i],B[i],C[i]);
    }
    FOR(i,1,N)v[i]=-MOD;
    v[1]=0;
    REP(i,N){
        REP(j,M){
            if(v[A[j]]!=-MOD)v[B[j]]=max(v[B[j]],v[A[j]]+C[j]-P);
        }
    }
    FOR(i,1,N)o[i]=v[i];
    REP(i,N){
        REP(j,M){
            if(v[A[j]]!=-MOD)v[B[j]]=max(v[B[j]],v[A[j]]+C[j]-P);
        }
    }
    FOR(i,1,N){
        if(v[i]>o[i])v[i]=1e12;
    }
    REP(i,N){
        REP(j,M){
            if(v[A[j]]!=-MOD)v[B[j]]=max(v[B[j]],v[A[j]]+C[j]-P);
        }
    }
    if(v[N]>o[N])W(-1);
    else W(max(0LL,v[N]));
    return 0;
}


Measured memory_bytes: 8448
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    n = int(input())
    aa = input_ints()
    aa.sort()
    r = 1
    for a in aa:
        r *= a
        if r > 1000000000000000000:
            print(-1)
            return
    print(r)


main()


Measured memory_bytes: 21624
#include<iostream>

using namespace std;

struct Node{
	int b;
	int rank = 0;
};

Node Tree[10000];

int Find(int x) {
	int y = Tree[x].b;
	while (y != Tree[y].b) { y = Tree[y].b; }
	return y;
}

void Unite(int x, int y) {
	int x0 = Find(x), y0 = Find(y);
	Tree[x0].b = y0;
	if (Tree[x0].rank == Tree[y0].rank) Tree[y0].rank++;
	else if (Tree[x0].rank == 0) Tree[x0].rank++;
}

int main() {
	int n, q, com, x, y;
	cin >> n >> q;
	for (int i = 0; i < n; i++) Tree[i].b = i;
	for (int i = 0; i < q; i++) {
		cin >> com >> x >> y;
		if (com == 0) Unite(x, y);
		else if (com == 1) {
			if (Find(x) == Find(y)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
}


Measured memory_bytes: 3168
N = int(input())
s = [input() for _ in range(N)] 

M = int(input())
t = [input() for _ in range(M)] 

#print(N, M)
#print(s, t)

from collections import Counter
S = Counter(s)
#print(S)
T = Counter(t)
x = S-T
#print(x)
count = (x.most_common(1))
try:
  if (count[0][1]):
    print(count[0][1])
except IndexError:
  print('0')
  

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
int main(void){
int n,l,min=1000;
  scanf("%d%d",&n,&l);
  int a[n],sum=0,flag=0;
  for(int i=0;i<n;i++){
	a[i]=l+i;
    //printf("%d ",a[i]);
    sum+=a[i];
   if(abs(a[i])<abs(min))min=a[i];
  }
  
 // printf("%d\n",min);
  sum-=min;
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
while True:
    n,x = map(int,input().split())

    if n==0 and x == 0:
        break

    result = 0

    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    result += 1

    print(result)

Measured memory_bytes: 7612
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
ll n,m,k;
int main()
{
    //IOS;
    while(cin>>n>>k)
    {
        ll sum=0;
        rep(i,n)
        {
            ll tmp;
            cin>>tmp;
            if(tmp>=k) sum++;
        }
        cout<<sum<<'\n';
    }
        
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int fibonacci(int);
int dp[44];

int main(){
  int n,i;

  for(i=0;i<=44;i++){
    dp[i]=-1;
  }

  scanf("%d",&n);

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

  return 0;
}

int fibonacci(int n){
  if(n==0||n==1)return 1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fibonacci(n-2)+fibonacci(n-1);
}
    



Measured memory_bytes: 2112
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long N;
    cin >> N;

    string res;
    int M = 26;
    vector<long long> cnts;
    cnts.push_back(1);
    while (cnts.back() < N) {
        cnts.push_back(cnts.back() * M);
    }
    
    int len = 1;
    long long sum = M;
    while (sum < N) {
        sum += cnts[++len];
    }
    for (int i = 1; i < len; ++i) {
        N -= cnts[i];
    }
    --N;
    // cout << len << " " << cnts[len - 1] << " " << N << endl;
    for (int i = len - 1; i >= 0; --i) {
        for (char ch = 'a'; ch <= 'z'; ++ch) {
            if (N < cnts[i]) {
                res += ch;
                break;
            } else {
                N -= cnts[i];
            }
        } 
    }

    cout << res << '\n';

    return 0;
}

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

int main(){
  string S,T;
  cin >> S >> T;
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());
  if(S<T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            

            int[] array = new int[]{in.nextInt(), in.nextInt(), in.nextInt()};

            Arrays.parallelSort(array);    // 5 5 7 になっていれば正解

            out.append(Arrays.equals(array, new int[]{5, 5, 7}) ? "YES" : "NO");


        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,i,ans;
  cin >>n;
  int d[n];
  for(i=0;i<n;i++)
    cin>>d[i];
  ans=1;
  sort(d,d+n);
  for(i=0;i<n-1;i++)
    if(d[i+1]!=d[i])
      ans++;
  cout << ans;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split.to!(int[]);
	auto N = data[0], C = data[1];
	int[][] D, c;
	foreach (i; 0 .. C) { D ~= readln.split.to!(int[]); }
	foreach (i; 0 .. N) { c ~= readln.split.to!(int[]); }
	
	// mod_i[color] = (the number of grids that have the color)
	int[30] mod0, mod1, mod2;
	int mod0_n, mod1_n, mod2_n;
	foreach (x; 0 .. N) foreach(y; 0 .. N) {
		final switch ( (x+y)%3 ) {
			case 0: mod0[c[x][y]-1]++, mod0_n++; break;
			case 1: mod1[c[x][y]-1]++; mod1_n++; break;
			case 2: mod2[c[x][y]-1]++; mod2_n++; break;
		}
	}
	
	
	// the cost that is needed to re-paint
	int cost(int[30] mod, int color) {
		int result;
		foreach (i; 0 .. C) {
			result += mod[i] * D[i][color];
		}
		return result;
	}
	
	int solve(int[30] m0, int[30] m1, int[30] m2) {
		int result;
		auto m0s = C.iota.map!(x => cost(m0,x));
		auto index0 = C - m0s.minPos.length;
		auto m1s = C.iota.map!(x => x != index0 ? cost(m1,x) : int.max);
		auto index1 = C - m1s.minPos.length;
		auto m2s = C.iota.map!(x => x != index0 && x != index1 ? cost(m2,x) : int.max);
		auto index2 = C - m2s.minPos.length;
		
		return m0s[index0] + m1s[index1] + m2s[index2];
	}
	
	min(solve(mod0, mod1, mod2), solve(mod0, mod2, mod1), solve(mod1, mod0, mod2), solve(mod1, mod2, mod0), solve(mod2, mod0, mod1), solve(mod2, mod1, mod0)).writeln;
	
}

Measured memory_bytes: 8956