akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//typedef int64_t int;
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define pb push_back
#define mk make_pair
#define endl "\n"
#define int int64_t
#define ll long long
const ll Inf = 1e9 + 7;
int n, k;


void solve() {
    int n, co = 0;
    cin >> n;
    std::map<int, int> mp;
    std::vector<int> num;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
        //cout << mp[x] << " ";
        if (mp[x] % 2 == 0 && mp[x] != 0) {
            num.pb(x);
            //cout << "xx" << endl;
        }
    } sort(all(num), greater<int>());
    if (num.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << num[0]*num[1] << endl;
    }

}
int32_t main()
{
    fastio;
    precise;

    //int test; cin >> test; while (test--)
    solve();
    return 0;
}


Measured memory_bytes: 9832
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define mod 1000000007

int main()
{
	int n;
	cin>>n;
	int a[n+10];
	int sum=0;
	for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
	sort(a,a+n);
	if(sum%10==0)
	{
		for(int i=0;i<n;i++)
		{
			//sum-=a[i];
			if((sum-a[i])%10!=0)
			{
				cout<<sum-a[i]<<endl;
				return 0;
			}
		}
		cout<<0<<endl;
	}
	else
	{
		cout<<sum<<endl;
	}
	//cout<<sum<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int s; cin >> s;
	int s1 = s / 100;
	int s2 = s % 100;
	if (s1 > 0 && s1 < 13) {
		if (s2 > 0 && s2 < 13) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else if (s2 > 0 && s2 < 13) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c,x,y;

    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);

    long long ans = a * x + b * y;

    long long buf,i;
    if(x < y)
    {
        for (i = 0; i <= x; i++)
        {
            buf = a * (x - i) + b * (y - i) + c * 2 * i;
            if(buf < ans)ans = buf;
        }
        for (; i <= y; i++)
        {
            buf = b * (y - i) + c * 2 * i;
            if(buf < ans)ans = buf;
        }
    }
    else
    {
        for (i = 0; i <= y; i++)
        {
            buf = a * (x - i) + b * (y - i) + c * 2 * i;
            if(buf < ans)ans = buf;
        }
        for (; i <= x; i++)
        {
            buf = a * (x - i) + c * 2 * i;
            if(buf < ans)ans = buf;
        }
    }
    
    printf("%lld",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int c,b,e;
    cin>>c>>b>>e;
    if(c==0) cout<<*min_element(a.begin()+b,a.begin()+e)<<endl;
    if(c==1) cout<<*max_element(a.begin()+b,a.begin()+e)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,L=MI()
    S=[]
    for i in range(N):
        s=input()
        S.append(s)
        
    S.sort()
    print(''.join(map(str, S)))

main()


Measured memory_bytes: 38256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
s = input()
t = input()
ans = 0

for i in range(len(s) - (len(t) - 1)):
    num = 0
    k = i
    for j in range(len(t)):
        if s[k] == t[j]:
            num += 1
        k += 1

    if ans < num:
        ans = num

print(len(t) - ans)


Measured memory_bytes: 8972
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

signed main()
{
   int N; cin >> N;
   V<int> a(N);
   REP(i, N) cin >> a[i];

   int MAX = -1, I = -1;
   REP(i, N)
      if (MAX < abs(a[i])) {
         MAX = abs(a[i]);
         I = i;
      }

   V<P<int,int>> ans;
   REP(i, N) ans.PB(MP(I, i));

   if (a[I] >= 0) FOR(i, 0, N-1) ans.PB(MP(i, i+1));
   else RFOR(i, 0, N-1) ans.PB(MP(i+1, i));

   cout << SZ(ans) << endl;
   EACH(i, ans) cout << i->first+1 << " " << i->second+1 << endl;

   return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A == 1)
        A = 14;
    if (B == 1)
        B = 14;
    if (A < B)
        cout << "Bob" << endl;
    else if (A == B)
        cout << "Draw" << endl;
    else
        cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll exp(ll x,ll y){if(y==0) return 1;if(y%2 == 1) return x*exp(x,y/2)*exp(x,y/2);return exp(x,y/2) * exp(x,y/2);}
ll exp(ll x,ll y,ll modd) {if(y==0) return 1;ll t=exp(x,y/2,modd);t = t%modd;t=t*t;t=t%modd;if(y % 2 == 1) return (x*t)%modd ;return t%modd;}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("sse4")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0ll, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define revn(i,a,b) for(ll i=a;i>=b;--i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vs vector<string>
#define vsi vector<pair<string,int>>
#define vll vector<pair<ll,ll> >
#define vlll vector<pair<ll,pair<ll,ll>>>
#define vlvl vector<pair<pair<ll,ll>,ll>>>
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

vector<int> graph[110000];
vector<int> dp;

int solve(int i)
{
	if(dp[i]!=-1)
		return dp[i];
	int res = 0;
	for(int j=0;j<graph[i].size();j++)
	{
		res = max(res, solve(graph[i][j])+1);
//		cout<<res<<endl;
	}
	return dp[i] = res;
}

int main()
{
    ios;
	int n,m;
	cin>>n>>m;
	dp.resize(n+1, -1);
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		
		graph[u-1].push_back(v-1);
	}
	int ans =0;
	
	for(int i=0;i<n;i++)
	{
		ans = max(ans, solve(i));
	}
		
    cout<<ans;
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    char X,Y,ans;
    
    cin >> X >> Y;
    
    int x,y;
    string N("ABCDEF");
    
    for(int i = 0; i <= 5; i++){
        
        if(N[i] == X) x = i;
    }
    for(int i = 0; i <= 5 ; i++){
        
        if(N[i] == Y) y = i;
    }
   
    if(x < y) ans = '<';
    else if(x == y) ans = '=';
    else ans = '>';
    
    
    cout << ans << endl;
    
    return 0;
}

    

Measured memory_bytes: 384
#include <stdio.h>  
    #include <string.h>  
    #include <queue>  
    #include <iostream>  
    #include <algorithm>  
    using namespace std;  
    const int maxn=10050;  
    const int maxe=2005000;  
    const int INF=1e9;  
    struct note  
    {  
        int to;  
        int w;  
        int c;  
        int next;  
    };  
    note edge[maxe];  
    int head[maxn];  
    int ip;  
    void init()  
    {  
        memset(head,-1,sizeof(head));  
        ip=0;  
    }  
    void addedge(int u,int v,int w,int c)  
    {  
        edge[ip].to=v;  
        edge[ip].c=c;  
        edge[ip].w=w;  
        edge[ip].next=head[u];  
        head[u]=ip++;  
    }  
    int cost[maxn];  
    int dis[maxn];  
    bool vis[maxn];  
    queue<int>q;  
    void spfa(int s,int n)  
    {  
        while(!q.empty())q.pop();  
        for(int i=1;i<=n;i++)  
            cost[i]=dis[i]=INF;  
        memset(vis,false,sizeof(vis));  
        dis[s]=0;  
        cost[s]=0;  
        vis[s]=true;  
        q.push(s);  
        while(!q.empty())  
        {  
            int u=q.front();  
            q.pop();  
            vis[u]=false;  
            for(int i=head[u];i!=-1;i=edge[i].next)  
            {  
                int to=edge[i].to;  
                int val=edge[i].w;  
                if(dis[to]>dis[u]+val||(dis[to]==dis[u]+val&&cost[to]>edge[i].c))//有多条最短路?，取花?最小的  
                {  
                    dis[to]=dis[u]+val;  
                    cost[to]=edge[i].c;  
                    if(!vis[to])  
                    {  
                        q.push(to);  
                        vis[to]=true;  
                    }  
                }  
            }  
        }  
    }  
    int main()  
    {  
       // freopen("cin.txt","r",stdin);  
        int n,m;  
        int u,v,w,c;  
        while(~scanf("%d%d",&n,&m))  
        {  
            if(n==0&&m==0) break;  
            init();  
            for(int i=0;i<m;i++)  
            {  
                scanf("%d%d%d%d",&u,&v,&c,&w);  
                addedge(u,v,c,w);  
                addedge(v,u,c,w);  
            }  
            spfa(1,n);  
            int ans=0;  
            for(int i=1;i<=n;i++)  
                ans+=cost[i];  
            printf("%d\n",ans);  
        }  
        return 0;  
    }  

Measured memory_bytes: 4056
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	
	if (n / 100 == 7){
		puts("Yes");
	}
	
	else if((n % 100) / 10 == 7){
	 	puts("Yes");
	}
	 
	else if(n % 10 == 7){
		puts("Yes");
	} 
	
	else{
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int n, s[110], dp[110][11000], res;

void dfs(int num, int sum) {
    if (dp[num][sum] == 1) return;
    if (num == n) {
        if (sum % 10) res = max(res, sum);
    } else {
        dfs(num + 1, sum);
        dfs(num + 1, sum + s[num]);
    }
    dp[num][sum] = 1;
}

int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    dfs(0, 0);
    cout << res << endl;
}


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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	cout << n+n*n+n*n*n << '\n';
	return 0;
}



Measured memory_bytes: 3648
k=int(input())
def exit():
    import sys
    sys.exit()
if k%10 in [0,2,4,5,6,8,]:
    print(-1)
    exit()
i=1
if k%7==0:
    a=10%(9*k/7)
else:
    a=10%(9*k)
while 1:
    if k%7==0:
        if a==1:
            print(i)
            exit()
        a=(a*10)%(9*k/7)
    else:
        if a==1:
            print(i)
            exit()
        a=(a*10)%(9*k)
    i+=1

Measured memory_bytes: 9172
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    int score[8]={400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
    int cnt[8], any=0;
    memset(cnt, 0, sizeof(cnt));
    for(int i=0; i<N; i++){
        if(a[i]>=3200){
            any++;
            continue;
        }
        for(int j=0; j<8; j++){
            if(a[i]<score[j]){
                cnt[j]++;
                break;
            }
        }
    }

    int ans_min=0;
    for(int i=0; i<8; i++){
        if(cnt[i]>0) ans_min++;
    }
    cout << max(1,ans_min) << ' ' << ans_min+any << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
                    vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }
};
int char2int(char c) {
  return (int)(c-'a');
}
int main() {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<vector<int> > init_vector(26, vector<int>(N));
  rep(i, N) init_vector[char2int(S[i])][i]++;
  vector<SegmentTree<int, int> > A;
  rep(alph, 26) {
    A.push_back(SegmentTree<int, int>(N,
                                      [](int a,int b){return a+b;},
                                      [](int a,int b){return b;},
                                      0,
                                      init_vector[alph]));
  }
  rep(q, Q) {
    int type;
    cin >> type;
    if(type == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      if(S[i] != c) {
        A[char2int(S[i])].update(i, 0);
        A[char2int(c)].update(i, 1);
        S[i] = c;
      }
    } else {
      int l, r;
      cin >> l >> r;
      l--; r--;
      int cnt = 0;
      rep(alph, 26) {
        if(A[alph].query(l, r+1)) cnt++;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 188756
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        List<Long> a = new ArrayList<>();
        a.add(0L);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                a.add(a.get(i) + 1);
                continue;
            }
            a.add(a.get(i));
        }

        List<Long> c = new ArrayList<>();
        c.add(0L);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'C') {
                c.add(c.get(i) + 1);
                continue;
            }
            c.add(c.get(i));
        }

        List<Long> hatena = new ArrayList<>();
        hatena.add(0L);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '?') {
                hatena.add(hatena.get(i) + 1);
                continue;
            }
            hatena.add(hatena.get(i));
        }

        long ans = 0;
        long MOD = 1000000007;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '?' || s.charAt(i) == 'B') {
                long aCnt = a.get(i);
                long cCnt = c.get(s.length()) - c.get(i + 1);
                long hatenaLeft = hatena.get(i);
                long hatenaRight = hatena.get(s.length()) - hatena.get(i + 1);
                ans += aCnt * cCnt % MOD * pow(3, hatenaLeft + hatenaRight, MOD) % MOD;
                ans %= MOD;
                ans += aCnt * hatenaRight % MOD * pow(3, hatenaLeft + hatenaRight - 1, MOD) % MOD;
                ans %= MOD;
                ans += hatenaLeft * cCnt % MOD * pow(3, hatenaLeft + hatenaRight - 1, MOD) % MOD;
                ans += hatenaLeft * hatenaRight % MOD * pow(3, hatenaLeft + hatenaRight - 2, MOD)
                    % MOD;
            }
            ans %= MOD;
        }
        System.out.println(ans);
    }
    public static long pow(long x, long n, long mod) {
        long ans = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                ans = ans * x % mod;
            }
            x = x * x % mod;
            n >>= 1;
        }
        return ans;
    }
}


Measured memory_bytes: 32576
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, b, a[N];

ll abs(ll p) {return p > 0 ? p : -p;}

ll f(ll p) {
  ll i, q = 0, s = 0;
  for (i = 0; i < n; i++, p = -p) {
    q += a[i];
    if (p > 0) {
      if (q <= 0) s += -q + 1, q = 1;
    } else {
      if (q >= 0) s += q + 1, q = -1;
    }
  }
  return s;
}

int main()
{
  ll i;
  cin >> n;
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  cout << min(f(1), f(-1));
  return 0;
}



Measured memory_bytes: 1024
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Bugged
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_S = 100;
const int MAX_NS = MAX_N * MAX_S;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int ss[MAX_N];
bool dp[MAX_NS + 1];

/* subroutines */

/* main */

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

  dp[0] = true;

  for (int i = 0; i < n; i++) {
    int &si = ss[i];
    for (int j = MAX_NS - si; j >= 0; j--) dp[j + si] |= dp[j];
  }

  int maxs = MAX_NS;
  for (; maxs > 0; maxs--)
    if (maxs % 10 != 0 && dp[maxs]) break;
  printf("%d\n", maxs);
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
home = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
for l in range(int(input())):
    data = list(map(int,input().split()))
    b = data[0]
    f= data[1]
    r= data[2]
    v= data[3]
#b棟、f階、r番目の部屋にr人
    home[b-1][f-1][r-1]+=v

for n in range(0,4):
    for m in home[n]:
        for o in m:
            print(" "+str(o),end="")
            
        print()
    if n<3:
        print("#"*20)



Measured memory_bytes: 5628
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int N;
  cin >> N;
  cout << pow(N,3) <<endl;
}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		var X = int.Parse(Console.ReadLine());
		if (X == 3 || X == 5 || X == 7)
		{
			Console.WriteLine("YES");
		}
		else
		{
			Console.WriteLine("NO");
		}
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int n = sc.nextInt();

		int max = 0;

		int first = sc.nextInt();

		int prev = first;
		int now = 0;

		for (int i = 1; i < n; i++) {
			now = sc.nextInt();
			max = Math.max(max, now - prev);
			prev = now;
		}
		sc.close();

		max = Math.max(max, k - now + first);

		print(k - max);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define pii pair < int , int >

const int N = 200005;
ll t[N * 4] = {};

void update(int v, int tl, int tr, int pos, ll val)
{
    if (tl == tr)
    {
        t[v] = val;
        return;
    }

    int tm = (tl + tr) >> 1;
    if (pos <= tm)
        update(v + v, tl, tm, pos, val);
    else
        update(v + v + 1, tm + 1, tr, pos, val);
    t[v] = max(t[v + v], t[v + v + 1]);
}

ll solve(int v, int tl, int tr, int l, int r)
{
    if (l > r)
        return 0;

    if (tl == l && tr == r)
    {
        return t[v];
    }

    int tm = (tl + tr) >> 1;
    return max(solve(v + v, tl, tm, l, min(tm, r)),
               solve(v + v + 1, tm + 1, tr, max(tm + 1, l), r));
}


int main()
{
    #ifdef Estb_probitie
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n;
    cin >> n;
    ll h[n], a[n];

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

    for (int i = 0 ;i < n; ++i)
    {
        dp[i] = solve(1, 0, n, 0, h[i] - 1) + a[i];
        update(1, 0, n, h[i], dp[i]);
    }

    cout << solve(1, 0, n, 0, n);
}


Measured memory_bytes: 11008
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        int Q = NextInt();
        string S = NextString();
        int[] dp = new int[N + 1];
        dp[0] = 0;
        for (int i = 1; i < N; i++)
        {
            if (S[i - 1] == 'A' && S[i] == 'C') dp[i + 1] = dp[i] + 1;
            else dp[i + 1] = dp[i];
        }
        for (int i = 0; i < Q; i++)
        {
            int l = NextInt();
            int r = NextInt();
            Console.WriteLine(dp[r] - dp[l]);
        }
        //dp.ToList().ForEach(v => Console.Write(v + " "));
        //Console.WriteLine();
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 16844
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M, K;
    cin >> N >> M >> K;

    vector<ll> A(N + 1), B(M + 1);
    rep(i, N) {
        cin >> A[i + 1];
        A[i + 1] += A[i];
    }
    rep(i, M) {
        cin >> B[i + 1];
        B[i + 1] += B[i];
    }

    ll ans = 0;
    rep(i, N + 1) {
        ll res = K - A[i];
        ll cnt = i;
        if (res < 0) continue;
        int pos = upper_bound(all(B), res) - B.begin();
        // cout << pos << " " << i << endl;
        cnt += pos - 1;
        chmax(ans, cnt);
    }

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

Measured memory_bytes: 6360
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
import sys
sdin = sys.stdin.readline

n = int(sdin())
graph = np.array([[0 for _ in range(n)] for _ in range(n)], dtype=float)
for i in range(n):
    graph[i] = np.array(list(map(int, sdin().split())))
    
# ワーシャルフロイドで最短距離出す
shortest = floyd_warshall(graph, directed=False)


if any([graph[i,j] != shortest[i,j] for i in range(n) for j in range(n)]):
    print(-1)
    
else:
    total = 0
    INF = float("inf")
    
    for i in range(n):
        graph[i,i] = INF
    
    for i in range(n):
        for j in range(i+1,n):
            via_k = np.min(graph[i] + graph[j])
            
            if via_k > graph[i,j]:
                total += graph[i,j]
                
    print(int(total))

Measured memory_bytes: 16704
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const long long MOD = 10*10*10*10*10*10*10*10*10+7;

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    long long N = inputValueLongLong();
    long long K = inputValueLongLong();
    long long i = 0;
    long long sum = 0;
    long long kou = 1;

    for(i=1;i<=N+1;i++){
        kou = kou - 2*(i-1);
        if(i<K){
            
        }else{
            sum = (sum + (N*i + kou))%MOD;
        }
        //cout << sum << endl;
    }
    cout << sum << endl;

    
    return 0;
}

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

int main() {
  int n, y;
  cin >> n >> y;
  vector<int> ans = {-1, -1, -1};
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      int k = n - i - j;
      if (10000 * i + 5000 * j + 1000 * k == y) {
        ans = {i, j, k};
      }
    }
  }
  cout << ans.at(0) << ' ' << ans.at(1) << ' ' << ans.at(2) << endl;
}

Measured memory_bytes: 384
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion
lint n, k;
int solve(lint &N) {
	lint cnt = 0;
	if (N % k == 0) {
		cnt = 1;
	}
	if (N % k == k / 2) {
		cnt = 2;
	}
	return cnt;
}
bool solve2(lint &N) {
	bool h = false;
	if (N % k == 0) h = true;
	return h;
}


int main(void) {
	cin >> n >> k;
	if (k == 1) {
		cout << n * n * n << endl;
		return 0;
	}
	if (k % 2 == 0) {
		lint ans1 = 0;
		lint ans2 = 0;
		for (lint i = 1; i <= n; i++) {
			lint g = solve(i);
			if (g == 1) ans1++;
			if (g == 2) ans2++;
		}
		printf("%lld\n", ans1 * ans1 * ans1 + ans2 * ans2 * ans2);
		return 0;
	}
	lint ans = 0;
	for (lint i = 1; i <= n; i++) {
		if (solve2(i)) 
			ans++;
	}
	printf("%lld\n", ans * ans * ans);
	
	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

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

int cost[111][111];

int main() {
  int n, m, l;
  while (true) {
    cin >> n >> m >> l;
    if (n == 0 && m == 0 && l == 0) break;
    vector<pair<int, pair<int, int> > > edge[n];
    rep (i, m) {
      int a, b, d, e;
      cin >> a >> b >> d >> e;
      --a; --b;
      edge[a].push_back(make_pair(b, make_pair(d, e)));
      edge[b].push_back(make_pair(a, make_pair(d, e)));
    }
    rep (i, 111) rep (j, 111) cost[i][j] = 1000000000;
    priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > que;
    que.push(make_pair(0, make_pair(0, l)));
    while (!que.empty()) {
      pair<int, pair<int, int> > now = que.top();
      que.pop();
      if (cost[now.second.first][now.second.second] <= now.first) continue;
      cost[now.second.first][now.second.second] = now.first;
      rep (i, edge[now.second.first].size()) {
	que.push(make_pair(now.first + edge[now.second.first][i].second.second, make_pair(edge[now.second.first][i].first, now.second.second)));
	if (now.second.second >= edge[now.second.first][i].second.first) {
	  que.push(make_pair(now.first, make_pair(edge[now.second.first][i].first, now.second.second - edge[now.second.first][i].second.first)));
	}
      }
    }
    int res = 1000000000;
    rep (i, 111) res = min(res, cost[n - 1][i]);
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 10840
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M, C  = sc.nextInt()
    val B = Array.fill(M)(sc.nextInt())
    val A = Array.fill(N, M)(sc.nextInt())

    println((0 until N) count { i =>
      A(i).zip(B).foldLeft(C) { (r, n) =>
        r + n._1 * n._2
      } > 0
    })
  }

}



Measured memory_bytes: 27700
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e6+5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int H, W, K; cin >> H >> W >> K;
	vector<string> chc(H);
	for (int i = 0; i < H; i++) {
		cin >> chc[i];
	}

	int mx = pow(2, H-1), ans = 1e7;
	for (int i = 0; i < mx; i++) {
		bool br = true, re = true;
		int cnt = 0;
		vector<int> id(H);
		int temp = 0;

		for (int j = 0; j < H; j++) {
			id[j] = temp;
			if (i & (1 << j))temp++, cnt++;
		}
		//cout << "i=" << i << endl;
		vector<int> nwh(H);
		for (int a = 0; a < W && br; a++) {
			//cout << "a=" << a << endl;
			vector<int> cwh(H);
			for (int b = 0; b < H; b++) {
				if (chc[b][a] == '1') {
					nwh[id[b]]++;
					cwh[id[b]]++;
				}
			}
			for (int c = 0; c <= temp; c++) {
				if (cwh[c] > K) {
					br = false;
					break;
				}

				if (nwh[c] > K) {
					re = false;
					nwh = vector<int>(H);
					a--, cnt++;				
					break;
				}
			}

			

		}
		if (br) {
			ans = min(ans, cnt);
		}
	}
	//sorry 
	cout << ans << endl;

}



Measured memory_bytes: 4020
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n;
	cin>>n;

	vector<pair<long long,int> > a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first;
		a[i].second=i;
	}

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

	set<int> idx;
	idx.insert(-1);
	idx.insert(n);
	long long res=0;
	for(int i=0;i<n;i++){
		
		auto it=idx.insert(a[i].second).first;
		auto left=prev(it);
		auto right=next(it);

		//cout<<*left<<" "<<*right<<endl;

		res+=a[i].first*(a[i].second-(*left))*((*right)-a[i].second);

	}

	cout<<res<<endl;


}

Measured memory_bytes: 12800
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long I = 1L;
        int c  = 1000000007;
        for(int i = 1;i <= N; i++){
            I = I * i;
            I = I % c;
        }
        System.out.println(I);
    }
}

Measured memory_bytes: 23124
/*================= *\
|  ID : aman__guta__ |
|      LANG: C++     |
\*==================*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double 
#define pb push_back
#define mk make_pair
#define fs first
#define sc second 
#define mod 1000000007
#define sp <<" "<<
#define JOKER ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
int spf[10000001];
long long int fac[200005]; 
void sieve(int n)
{
    spf[1]=1;
    for(int i=2;i<=n;i++) spf[i]=i;
    for(int i=4;i<=n;i+=2) spf[i]=2;
    for(int i=3;i*i<=n;i++)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}
long long int power(long long int x, long long int y, long long int p) 
{ 
    long long int res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
}
long long int modInverse(long long int n, long long int p) 
{ 
    return power(n, p-2, p); 
} 
long long int nCrModPFermat(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
int lps(string s)
{
    int n=s.size();
    int lps[n];
    lps[0]=0;
    int i=1;
    int j=0;
    while(i<n)
    {
        if(s[i]==s[j])
        {
            j++;
            lps[i]=j;
            i++;
        }
        else 
        {
            if(j)
            {
                j=lps[j-1];
            }
            else 
            {
                lps[i]=0;
                i++;
            }

        }
    }
    return min(n/2,lps[n-1]);
}
main()  
{
    JOKER
    ll n;
    cin>>n;
    ll k=n/500;
    n-=k*500;
    ll k2=n/5;
    cout<<k*1000+k2*5<<endl;

    cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
    return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int a, b;
	cin >> a >> b;
	cout << ceil((double)(a + b) / (double)2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,c=0,m=0;
  char s[5]={"ACGT"};
  while(~scanf("%c",&s[4])){
    for(i=0;s[4]-s[i];i++);
    if(i==4)c=0;
    else    c++;
    if(m<c)m=c;
  }
  printf("%d\n",m);
  return 0;
}
  


Measured memory_bytes: 128
import numpy as np
n=int(input())
a=list(map(int,input().split()))+[10**6+1]
a=sorted(a)
flag=np.array([0 for i in range(10**6+1)])
ans=0
for i in range(n):
    if flag[a[i]]==0:
        flag[::a[i]]=1
        if a[i]!=a[i+1]:
            ans+=1
print(ans)

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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int N, M;
std::vector<int> arr;
std::vector<std::vector<int> > g;

int color[100005];
bool used[100005];

void dfs(int x, int c) {
    used[x] = true;
    color[x] = c;

    for (auto nv : g[x]) {
        if (!used[nv]) {
            dfs(nv, c);
        }
    }
}

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

    cin >> N >> M;
    arr.resize(N);
    g.resize(N);

    for (int i = 0; i < N; ++i) {
        cin >> arr[i], arr[i]--;
    }

    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v, u--, v--;

        g[u].push_back(v);
        g[v].push_back(u);
    }

    int c = 1;

    for (int i = 0; i < N; ++i) {
        if (!used[i]) {
            dfs(i, c++);
        }
    }

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        if (color[arr[i]] == color[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8576
#include<iostream>

using namespace std;
typedef unsigned long long ullong;

int n, it;
ullong s;

ullong power( ullong b, int t ){
    int v = 1;
    for ( int i = 0; i < t; i++ ) v *= b;
    return v;
}

void compute(){
    n = 4;
    it = 10;
    cin >> s;

    for ( int i = 0; i < it; i++ ){
	s = s*s;
	s = s % ( power( 10, n + n/2) );
	s = s / ( power( 10, n/2) );
	cout << s << endl;
    }
}

main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ) {
	cout << "Case " << i+1 << ":" << endl;
	compute();
    }
}

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

int main() {
  string M;
  cin >> M;
  if (M=="hi" || M=="hihi" ||M=="hihihi" || M=="hihihihi" || M=="hihihihihi") {
    cout <<"Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cassert>

using namespace std;
using ll = long long int;

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

ll A, B, N;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cin >> A >> B >> N;

  ll x = min(B - 1, N);
  ll result = static_cast<ll>(A * x / B);

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3196
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main() {
    string s;
    while (cin >> s) {
        cout << s.substr(0, 4) << ' ' << s.substr(4) << endl;
    }

}

Measured memory_bytes: 764
import java.util.Scanner;

class MOD {
    static final int mod = 1000000007;

    static int add(int a, int b){
        int x = a + b;
        return (x >= mod) ? x - mod : x;
    }

    static int sub(int a, int b){
        int x = a - b;
        return (x < 0) ? x + mod : x;
    }

    static int mul(int a, int b){
        long x = (long)a * (long)b;
        return (int)(x % mod);
    }

    static int div(int a, int b){
        return mul(a, modinv(b));
    }

    static int modinv(int a) {
        int b = mod;
        int u = 1;
        int v = 0;
        while (b != 0) {
            int t = a / b;
            a -= t * b;
            int temp = a; a = b; b = temp; // swap(a, b)
            u -= t * v;
            temp = u; u = v; v = temp; // swap(u, v)
        }
        u %= mod;
        if (u < 0) u += mod;
        return u;
    }
}

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

        int ten_hat_n = 1;
        for(int i=0; i<n; i++)
            ten_hat_n = MOD.mul(ten_hat_n, 10);

        int nine_hat_n = 1;
        for(int i=0; i<n; i++)
            nine_hat_n = MOD.mul(nine_hat_n, 9);

        int eight_hat_n = 1;
        for(int i=0; i<n; i++)
            eight_hat_n = MOD.mul(eight_hat_n, 8);

        int ans = 0;
        ans = MOD.add(ans, ten_hat_n);
        ans = MOD.sub(ans, nine_hat_n);
        ans = MOD.sub(ans, nine_hat_n);
        ans = MOD.add(ans, eight_hat_n);
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 35696
#include<bits/stdc++.h>
using namespace std;
long gcd(long x,long y){return (x%y==0?y:gcd(y,x%y));}
int main(){
  long N;cin>>N;
  vector<long>T(N);for(long i=0;i<N;i++)cin>>T[i];
  if(N==1){cout<<T[0];return 0;}
  long l=T[0]*(T[1]/gcd(T[0],T[1]));
  for(long i=2;i<N;i++){
    l=l*(T[i]/gcd(l,T[i]));
  }
  cout<<l;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,i;
    cin >> n;
    string s1,s2;
    int t=0,h=0;
    
    for(i=0;i<n;i++){
        cin >> s1 >> s2;
        if(s1.compare(s2)==0) { //元の文と比較する文が同じなら０辞書順で早ければ0より大きい数を返す
            t++;h++;
        }else if(s1.compare(s2)>0){
            t+=3;
        }else {
            h+=3;
        }
    }
    cout << t << " " << h << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<long> L(N);
    for (auto& l : L) {
        cin >> l;
    }
    sort(L.begin(), L.end());
    auto LL = L;
    auto it = unique(LL.begin(), LL.end());
    LL.erase(it, LL.end());
    vector<int> countL(LL.size());
    for (int i = 0; i < LL.size(); ++i) {
        countL[i] = count(L.begin(), L.end(), LL[i]);
    }

    ll count = 0;
    for (int i = 0; i < LL.size(); ++i) {
        for (int j = i + 1; j < LL.size(); ++j) {
            for (int k = j + 1; k < LL.size(); ++k) {
                if (LL[i] + LL[j] > LL[k]) {
                    count += countL[i] * countL[j] * countL[k];
                }
            }
        }
    }
    cout << count << endl;
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == s[k - 1]) {
            cout << s[i];
        } else {
            cout << "*";
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())

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

int main() {
    int n,p;
    LL ans=1;
    cin>>n >>p;
    VI bis(n);
    bool even = true;
    for(int i=0;i<n;i++){
        cin>>bis[i];
        if(bis[i]%2==1)even=false;
        ans*=2;
    }
    
    
    if(even){
        if(p==1){
            cout<<0<<endl;
        }else{
            cout<<ans<<endl;
        }
    }else{
        cout<<ans/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
alp=[0 for i in range(0, 28)]
for j in s:
	if j>='a' and j<='z':
		alp[(ord(j)-ord('a'))]=alp[(ord(j)-ord('a'))]+1
f=0
for i in range(0 ,26):
	if alp[i]%2!=0:
		f=1
if f==1:
	print("No")
else:
	print("Yes")

Measured memory_bytes: 61616
#include <stdio.h>
#include <math.h>
 
int main() {
 
double x1,x2,y1,y2;
double x,y,z;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
 
x = (x2-x1) * (x2-x1);
y = (y2-y1) * (y2-y1);
 
printf("%.11lf",sqrt(x+y));
 
return 0;
 
}


Measured memory_bytes: 2108
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();

			for (int i = 1; i <= n; i++) {
				if (i%3 == 0) System.out.print(" " + i);
				else {
					int x = i;
					do {
						if (x%10 == 3) {
								System.out.print(" " + i);
								break;
							}
							x /= 10;
						} while(x !=0);
				}
			}
			System.out.print('\n');
		}
	}
}


Measured memory_bytes: 28804
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  ll N, i;
  cin >> N;
  char s[N];
  scanf("%s", s);
  if(N%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = 0; i < N/2; i++){
    if(s[i] != s[i + N/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256