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

int func(int x){
    if(x==0)
        return 0;
    if(x==1)
        return 1;
    else
        return x*func(x-1);
}

int main(){
    int n;
    int aa[10],bb[10],c[10]={0};
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>aa[i];
    }
    for(int i=1;i<=n;i++){
        cin>>bb[i];
    }
    int sum1=1,sum2=1;
    for(int i=1;i<=n;i++){
        int temp=0;
        c[aa[i]]=1;
        for(int j=1;j<aa[i];j++){
            if(c[j]==1)
                temp++;
        }
        int k=func(n-i);
        if(aa[i]-temp-1>0)
            sum1=sum1+(aa[i]-1-temp)*k;
    }
    memset(c,0,sizeof(c));
    for(int i=1;i<=n;i++){
        int temp=0;
        c[bb[i]]=1;
        for(int j=1;j<bb[i];j++){
            if(c[j]==1)
                temp++;
        }
        int k=func(n-i);
        if(bb[i]-temp-1>0)
            sum2=sum2+(bb[i]-1-temp)*k;
    }
    if(sum1>sum2)
        cout<<sum1-sum2;
    else
        cout<<sum2-sum1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int main() {
	string s;
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < b + 2; i++)cout << '#';
	cout << endl;
	for (int i = 0; i < a; i++) {
		cin >> s;
		s = '#' + s + '#';
		cout << s << endl;
	}
	for (int i = 0; i < b + 2; i++)cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string ans;
	int w, pw[12];
	pw[0] = 1; rep(i, 11) pw[i+1] = pw[i] * 3;
	cin >> w;
	
	for(int i = 11; i >= 0; i--){
		int tmp = abs(abs(w) - pw[i]);
		if(abs(w) > tmp){
			if(w < 0){
				ans += "-";
				w += pw[i];
			}
			else{
				ans += "+";
				w -= pw[i];
			}
		}
		else ans += "0";
	}
	while(ans[0] == '0') ans.erase(ans.begin());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void printVec(std::vector<string> &vec) {
    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    int K;
    cin >> K;
    vector<string> subs;
    REP(i,s.size()) {
        FOR(j,1,min(6,int(s.size()-i+1))) {
            subs.push_back(s.substr(i,j));
        }
    }
    sort(ALL(subs));
    subs.erase(unique(ALL(subs)),subs.end());

    // printVec(subs);
    cout << subs[K-1]<< endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  bool isVowel=false;
  char c;
  cin>>c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    isVowel=true;
  }
  
  if(isVowel){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }
  return 0;
}


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


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

    if (str == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (str == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
n,y = [int(x) for x in input().split()]


possible = False
for i in range(n+1):
    for j in range(n+1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y and (n-i-j) >= 0:
            possible = True
            ans = [i,j,(n-i-j)]
            break

if possible:
    print(*ans, sep=" ")
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include<stdio.h>
#define W 0
#define G 1
#define B 2
  
int main(){
  int i,j,n,k,u,v,c;
  int A[100][100],wei[100],col[100];
  int ver,min_wei;
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    for(j=0;j<n;j++) A[i][j]=-1;

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v]=c;
    }
  }
  for(i=0;i<n;i++){
    wei[i]=2147483647;
    col[i]=W;
  }
  
  wei[0] = 0;
  col[0] = G;
  
  while(1){
    ver = -1;
    min_wei = 2147483647;
    
    for(i=0;i<n;i++){
      if(col[i] == G && wei[i] < min_wei){
	min_wei = wei[i];
	ver = i;
      }
    }

    if(ver == -1) break;

    col[ver] = B;

    for(i=0;i<n;i++){
      if(col[i] != B && A[ver][i] != -1){
	col[i] = G;
	if(wei[i] > (A[ver][i]+wei[ver])) wei[i] = A[ver][i]+wei[ver];
      }
    }
  }

  for(i=0;i<n;i++) printf("%d %d\n",i,wei[i]);

  return 0;
}



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

const int mod = 1e9 + 7;
int a[100005];
int main()
{
    int n;
    bool flag = 1;
    ll res = 1;
    while(cin >> n)
    {
        int t;
        res = 1;
        flag = 1;
        for(int i = 0;i < n;i++)
        {
            cin >> t;
            a[t]++;
        }
        if(n % 2 == 0)//偶数
        {
            for(int i = 1;i < n;i += 2)
            {
                if(a[i] != 2)
                {
                    flag = 0;
                    break;
                }
                else
                    res = (res * 2) % mod;
            }
        }
        else
        {
            if(a[0] == 1)
            {
                for(int i = 2;i < n;i += 2)
                {
                    if(a[i] == 2)
                    res = (res * 2) % mod;
                    else
                    {
                        flag = 0;
                        break;
                    }
                }
            }
            else
            flag = 0;
        }
        if(flag)
        cout << res << endl;
        else
        cout << 0 << endl;
    }
    return 0;
}


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

int main(){
    int N,X;
    cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        B[A[i]-1]=i+1;
    }
    for(int i=0;i<N;i++){
        cout<<B[i]<<" ";
    }
}


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

int main() {
    int n, a, b; scanf("%d%d%d", &n, &a, &b);
    long long ret;
         if (a>b)          {ret = 0;}
    else if (a!=b && n==1) {ret = 0;}
    else if (a==b && n==1) {ret = 1;}
    else                   {ret = (long long)(b-a)*(n-2)+1;}
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    ll k;
    cin >> k;

    cout << "50\n";
    ll c = k/50;
    ll d = k%50;
    for (int i = 0; i < d; i++) {
        cout << 49 + c + 51 - d << " ";
    }
    for (int i = d; i < 50; i++) {
        cout << 49 + c - d << " ";
    }
    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A_B=[]
for i in range(M):
  a, b = list(map(int, input().split()))
  A_B.append([a,b])
flag=[1 for i in range(N)]
for i in range(len(A_B)):
  if H[A_B[i][0]-1] - H[A_B[i][1]-1] >0:
    flag[A_B[i][0]-1] *= 1
    flag[A_B[i][1]-1] *= 0
  elif H[A_B[i][0]-1] - H[A_B[i][1]-1]==0:
    flag[A_B[i][0]-1] *= 0
    flag[A_B[i][1]-1] *= 0
  else:
    flag[A_B[i][0]-1] *= 0
    flag[A_B[i][1]-1] *= 1
print(sum(flag))

Measured memory_bytes: 28800
# ABC066
# B
# ss

from collections import deque

s = deque(input())
ans = 0
while len(s) > 0:
    s.pop()
    s.pop()
    _ = list(s)
    _l = len(s)
    _f = _[:int(_l/2)]
    _b = _[int(_l/2):]
    if _f == _b:
        ans = _l
        break
        
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int c[n];
for(int i=0;i<n;i++){
cin>>c[i];
}
sort(c,c+n);
int ans=1;
for(int i=1;i<n;i++){
if(c[i]!=c[i-1]){ans++;}
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
import sys
from functools import lru_cache
Q = int(input())
LR = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]

@lru_cache(maxsize=None)
def isprime(x):
    if x == 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True

s = [0] * (10 ** 5 + 1)
for x in range(1, len(s)):
    s[x] = s[x-1]
    if isprime(x) and isprime((x + 1) // 2):
        s[x] += 1

for l, r in LR:
    ans = s[r] - s[l-1]
    print(ans)

Measured memory_bytes: 30004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << w * h / 2 << " " << ((x * 2 == w && y * 2 == h) ? 1 : 0);
}


Measured memory_bytes: 256
S = input()
a = 0
for i in range(len(S)):
    if S[i] == S[len(S)-i-1]:
        a += 1

b = 0
x = int((len(S)-1)/2)
for j in range(x):
    if S[j] == S[x -1 -j]:
        b += 1

c = 0
y = int((len(S)+3)/2)
for k in range(y-1,len(S)):
    if S[k] == S[y-k-2]:
        c += 1

if a == len(S):
    if b == x:
        if c == len(S) - y + 1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
def main():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    point = 0
    m_temp = abs((T - H[0] * 0.006) - A);

    for i in range(1, N):
        temp = abs((T - H[i] * 0.006) - A);
        if temp < m_temp:
            point = i
            m_temp = temp
    print(point+1)
   

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
//https://atcoder.jp/contests/dp/tasks/dp_d
// this time total weights are huge so we will use values for the dp definition instead of weights
// each state defines minimum total weight of items total value exactly j
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[102][100001];
ll n=0,w=0;
ll weights[102];
ll values[102];
int main() {
    // we can decrease space complexity only considering two rows 
    cin>>n>>w;
    for(int i=0;i<102;++i){
        for(int j=0;j<100001;++j){
            dp[i][j]=INT_MAX;
        }
    }
    memset(weights,0,sizeof(weights));
    memset(values,0,sizeof(values));
    ll valuesum=0;
    for(ll i=1;i<=n;++i){
        cin>>weights[i]>>values[i];
        valuesum+=values[i];
    }
    //for(int i=0;i<=valuesum;++i)
        //dp[0][i]=0;
    for(int i=0;i<=n;++i)
        dp[i][0]=0;
    for(ll i=1;i<=n;++i){
        for(ll j=1;j<=valuesum;++j){
            if(j<values[i]){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-values[i]]+weights[i]);
            }
        }
    }
    // for(ll i=0;i<=n;++i){
    //     for(ll j=0;j<=valuesum;++j){
    //        cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;
    ll ans=0;
    for(ll i=1;i<=valuesum;++i)
        if(dp[n][i]<=w)
            ans=i;
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
    int mat[100][100], vec[100], ans[100], n, m;
    cin >> n >> m;

    for(int i = 0; i < n; i++){
        ans[i] = 0;
        for(int j = 0; j < m; j++){
            cin >> mat[i][j];
        }
    }
    for(int i = 0; i < m; i++) cin >> vec[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            ans[i] += mat[i][j] * vec[j];
        }
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
from collections import deque

N,K=map(int,input().split())
D=list(map(int,input().split()))
like=list(range(1,10))
dislike0=False

for s in D:
    if s==0:
        dislike0=True
    else:
        like.remove(s)

like.sort()
q=deque(like)

if dislike0==False:
    like.insert(0,0)

while q:
    num=q.popleft()

    if num>=N:
        print(num)
        exit()
    for i in range(len(like)):
        q.append((int(str(num)+str(like[i]))))

Measured memory_bytes: 5692
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,s1,s2,s3,s4;
  cin>>N;
  s1=N/1000;
  N=N%1000;
  s2=N/100;
  N=N%100;
  s3=N/10;
  s4=N%10;
  if((s1==s2&&s2==s3)||(s2==s3&&s3==s4)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
    

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_130
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var WHxy = Sarray();
            var W = WHxy[0];
            var H = WHxy[1];
            var x = WHxy[2];
            var y = WHxy[3];

            Write((double)W * H / 2);
            if (2*x == W & 2*y==H) { Write(" 1"); }
            else { WriteLine(" 0"); }
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 2e5 + 4;
ll a,b,g;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    g = llabs(a - b);
    if(g & 1) cout<<"IMPOSSIBLE";
    else
        cout<<min(a, b) + g / 2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

ll dig[30];
ll two[31];

void solve(long long N, vector<long long> a, vector<long long> b){
	two[0] = 1;
	repn(i, 30) {
		two[i] = two[i-1]*2; 
	}
	rep(i, 30) {
		vector<ll> amod(N), bmod(N);
		rep(j, N) {
			amod[j] = a[j]%two[i+1];
			bmod[j] = b[j]%two[i+1];
		}
		SORT(amod);
		rep(j, N) {
			// if (i < 5) {
			// 	cout << i << endl;
			// 	cout << POSL(amod,two[i+1]-bmod[j])-POSL(amod,two[i]-bmod[j]) << " " << (POSL(amod,two[i+1]*2-bmod[j])-POSL(amod,two[i+1]+two[i]-bmod[j])) << endl;
			// 	cout << endl;
			// }
			
			dig[i] += (POSL(amod,two[i+1]-bmod[j])-POSL(amod,two[i]-bmod[j]))%2+(POSL(amod,two[i+1]*2-bmod[j])-POSL(amod,two[i+1]+two[i]-bmod[j]))%2;
			dig[i] %= 2;
		}
	}
	ll res = 0;
	rep(i,30) {
		res += dig[i]*two[i];
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	vector<long long> b(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&b[i]);
	}
	solve(N, a, b);
	return 0;
}



Measured memory_bytes: 9680
require 'bigdecimal'
require 'bigdecimal/util'

n = gets.chomp.to_i
ans=0
arr = gets.chomp.split(" ").map(&:to_i).each_cons(3) do |a,b,c|
  if [a,b,c].sort[1]==b 
      ans += 1
  end
end
puts ans

Measured memory_bytes: 14404
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int maxn = 1e5+7,mod = 1e9+7;
char s[333][333];
int n,ans;
bool jude(int k){
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            if(s[(i+k)%n][j] != s[(j+k)%n][i])
                return false;
    return true;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%s",s[i]);
    for(int k=0;k<n;k++){
        if(jude(k))
            ans += n;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

const int N = 16;
const int INF = 10000000;

int n;
int data[N][N+1]; //0 is null
int dp[2][1<<N];
int cost[N][1<<N];

int solve(){
  fill(dp[0], dp[2], INF);
  for(int i=0;i<n;i++) dp[0][(1<<i)] = cost[i][0];
  for(int k=0;k<n;k++){
    for(int i=0;i<(1<<n);i++){
      //if(dp[k%2][i] == INF) continue;
      dp[(k+1)%2][i] = min(dp[(k+1)%2][i], dp[k%2][i]);
      for(int j=0;j<n;j++){
        //if(i & (1<<j)) continue;
        dp[(k+1)%2][i|(1<<j)] = min(dp[(k+1)%2][i|(1<<j)], dp[k%2][i] + cost[j][i]);
      }
    }
  }
  return dp[n%2][(1<<n)-1];
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) for(int j=0;j<=n;j++) cin >> data[i][j];
    for(int k=0;k<(1<<n);k++){
      for(int i=0;i<n;i++){
        cost[i][k] = data[i][0];
        for(int j=0;j<n;j++) if(k & (1<<j)) cost[i][k] = min(cost[i][k], data[i][j+1]);
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 5768
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int t = sc.nextInt();
    int cnt = 0;
    for (int i = 0;i<t+0.5;i++){
      if(i%a==0 && i!=0){
        cnt = cnt + b;
      }
    }
    System.out.println(cnt);
  }
}
    


Measured memory_bytes: 22228
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    hs <- VU.fromList <$> getIntList
    abs <- VU.replicateM m $ do
        [a,b] <- getIntList
        return (a-1,b-1)
    let neighbors = V.create $ do
            vec <- VM.replicate n []
            VU.forM_ abs $ \(a,b) -> do
                VM.modify vec (b:) a
                VM.modify vec (a:) b
            return vec
        counts = map (\i -> all (< hs VU.! i) $ map (hs VU.!) (neighbors V.! i)) [0..n-1]
    print . length $ filter id counts

Measured memory_bytes: 27124
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;

  ll ans = 1;
  ll num = 1;

  while(num <= N){
    num *= K;
    ans++;
  }

  cout << ans - 1 << "\n";
  
  return 0;
}


Measured memory_bytes: 3584
N=int(input())
S=input()
Sf=S[:N]
Sb=S[N:2*N]
Sb=Sb[::-1]
ans=0
for i in range(2**N):
  R=[]
  B=[]
  for k in range(N):
    if i&(1<<k):
      R.append(Sf[k])
    else:
      B.append(Sf[k])
  dp=[[0]*(N+1) for i in range(N+1)]
  dp[0][0]=1
  f=True
  for k in range(1,N+1):
    for j in range(k):
      if j<len(R):
        if Sb[k-1]==R[j]:
          dp[k][j+1]+=dp[k-1][j]
      if 0<=k-j-1<len(B):
        if Sb[k-1]==B[k-j-1]:
          dp[k][j]+=dp[k-1][j]
  ans+=sum(dp[N])
print(ans)
   
      
    

Measured memory_bytes: 56268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define mp make_pair
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for(int ii = jj; ii < ll; ii += ss)
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;

int n;
vector <int> a;
vector <int> s;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	rep(i, 0, n, 1) {
		int x; cin >> x;
		a.pb(x);
		s.pb(x);
	}
	sort(s.rbegin(), s.rend());
	int max = s[0];
	rep(i, 0, n, 1) {
		if (max != a[i]) cout << max << '\n';
		else cout << s[1] << '\n';
	}
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;
lli prime[100000];    // i 番目の素数
lli is_prime[100000]; // i 番目が素数かどうか

// n以下の自然数に何個素数が含まれるのかを返す
// sieve(10) => 4
lli sieve(lli n) {
    lli p = 0;
    REPE(i, 0, n) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;

    REPE(i, 2, n) {
        if (is_prime[i]) {
            prime[p] = i;
            p++;
            for (lli j = 2*i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return p;
}


int main() {
    lli n;
    cin1(n);
    sieve(100000);


    vlli ans;

    lli count = n;
    REP(i,0,100000) {
        if (prime[i] % 5 == 1) {
            ans.push_back(prime[i]);
            count++;
        }
        if (count == 0)
            break;
    }
    REP(i,0,n) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
    string s;
    cin>>s;
    ll n = s.size();
    vector<ll> v(n,0);
    vector<ll> R(n,0);
    vector<ll> L(n,0);
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            R[i]=i;
        }
        else
        {
            R[i]=R[i-1];
        }
    }
    for(ll i=n-1;i>=0;i--)
    {
        if(s[i]=='L')
        {
            L[i]=i;
        }
        else
        {
            L[i]=L[i+1];
        }
    }
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            ll ind = L[i];
            ll moves = ind-i;
            if(moves&1)
            {
                v[ind-1]++;
            }
            else
            {
                v[ind]++;
            }
        }
        else
        {
            ll ind = R[i];
            ll moves = i-ind;
            if(moves&1)
            {
                v[ind+1]++;
            }
            else
            {
                v[ind]++;
            }
        }
    }
    for(auto x:v)
    {
        cout<<x<<' ';
    }
    return 0;
}


Measured memory_bytes: 3072
($H,$W,$h,$w)=glob<>;
if($H%$h|$W%$w){
	print"Yes\n";
	for$y(1..$H){
		for$x(1..$W){
			print$x>1&&$",~-$x%$w|~-$y%$h?$x%$w|$y%$h?0:-1e9:9x9
		}
		print$/
	}
}else{
	print"No\n"
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

int n,x,ans;
int a[105];

int main()
{
	cin >> n >> x;
	for (int i = 1;i <= n;i++)
		cin >> a[i];
	sort(a + 1,a + n + 1);
	while (ans < n)
	{
		if (a[ans + 1] <= x)
			x -= a[++ans];
		else
			break;
	}
	if (ans == n && x)
		ans--;
	cout << ans << endl;
	return 0;
}

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

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

int main() {
  int h, w;
  std::vector<std::string> a;

  cin >> h >> w;
  a.resize(h);
  for (int i = 0; i < h; ++i) {
    cin >> a[i];
  }

  bool row[101], col[101];
  
  std::fill(row, row + h, false);
  std::fill(col, col + w, false);

  for (int i = 0; i < h; ++i) {
    int cnt = 0;
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#') {
        cnt++;
      }
    }

    if (cnt == 0) {
      row[i] = true;
    }
  }

  for (int i = 0; i < w; ++i) {
    int cnt = 0;
    for (int j = 0; j < h; ++j) {
      if (a[j][i] == '#') {
        cnt++;
      }
    }

    if (cnt == 0) {
      col[i] = true;
    }
  }
  for (int i = 0; i < h; ++i) {
    if (row[i]) {
      continue;
    }
    for (int j = 0; j < w; ++j) {
      if (col[j]) {
        continue;
      }

      cout << a[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			var dic = new Dictionary<int, int>();
			for (int i = 0; i < n; i++) {
				for (int j = -1; j <= 1; j++) {
					int b = a[i] + j;
					if (dic.ContainsKey(b)) {
						dic[b]++;
					} else {
						dic[b] = 1;
					}
				}
			}

			int ans = 0;
			foreach (var key in dic.Keys) {
				ans = Math.Max(ans, dic[key]);
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 39920
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 2005;
int a[N];
bool blocked[N];
void solve(){
	int n, k, q;
	cin >> n >> k >> q;
	vector<pii> b;
	fr(i, 0, n - 1){
		cin >> a[i];
		b.push_back({a[i], i});
	}
	sort(all(b));
	int ans = b[q - 1].fi - b[0].fi;
	blocked[n] = 1;
	for(int i = 0; i < n;){
		int val = b[i].fi;
		while(i < n && b[i].fi == val){
			blocked[b[i].se] = 1;
			i++;
		}
		vector<int> temp, global;
		fr(j, 0, n - 1){
			if(!blocked[j]){
				temp.clear();
				fr(l, j, n){
					if(!blocked[l]){
						temp.pb(a[l]);
					}
					else{
						j = l;
						break;
					}
				}
				if(sz(temp) < k)
					continue;
				int get = sz(temp) - k + 1;
				sort(all(temp));
				fr(l, 0, get - 1){
					global.pb(temp[l]);
				}
			}
		}
		if(sz(global) < q) break;
		sort(all(global));
		ans = min(ans, global[q - 1] - global[0]);
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
const MOD: usize = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: isize,
        b: isize,
        c: isize,
    }
    let mut a: isize = a;
    let mut b: isize = b;
    let mut c: isize = c;
    let eo = a % 2 + b % 2 + c % 2;
    let mut ans = 0;
    if eo == 1 || eo == 2 {
        if (a + b) % 2 == 0 {
            a += 1;
            b += 1;
        } else if (b + c) % 2 == 0 {
            b += 1;
            c += 1;
        } else if (a + c) % 2 == 0 {
            a += 1;
            c += 1;
        }
        ans += 1;
    }
    let maxn = std::cmp::max(std::cmp::max(a, b), c);
    ans += (maxn - (a)) / 2 + (maxn - (b)) / 2 + (maxn - (c)) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
# import bisect
from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)



def main():
    n = int(input())
    a = list(map(int,ipti().split()))

    count_0 = 0
    count_2 = 0
    count_4 = 0

    for i in range(n):
        elem = a[i]
        if a[i] % 4 == 0:
            count_4 += 1
        elif a[i] % 2 == 0:
            count_2 += 1
        else:
            count_0 += 1

    if (count_0 + count_4) % 2 == 0:
        if count_4 >= count_0:
            print('Yes')
        else:
            print('No')
    else:
        if count_4 >= count_0:
            print('Yes')
        elif (count_4 + 1) == count_0:
            if count_2 == 0:
                print('Yes')
            else:
                print('No')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 58608
<?php
# 入力部
fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%d %d", $n, $m);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%s", $s2);

# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
$r = "Yes";
if ($s == "AAA" || $s == "BBB") {
  $r = "No";
}

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
echo $r . "\n";


Measured memory_bytes: 16100
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    int i;
    int a = 0;
    int b = 0;
    int ab = 0;
    int o = 0;
    char str[10];
    while(1){
        if(scanf("%d,%s",&i,str) == EOF)break;
        if(str[0] == 'A'){
            if(str[1] == 'B'){
                ab = ab + 1;
            }
            else{
                a = a + 1;
            }
        }
        else if(str[0] == 'B'){
            b = b + 1;
        }
        else if(str[0] == 'O'){
            o = o + 1;
        }
    }
    printf("%d\n",a);
    printf("%d\n",b);
    printf("%d\n",ab);
    printf("%d\n",o);
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int cnt = input.nextInt();
        int grade_T = 0, grade_H = 0;
        for(int i = 0; i < cnt; i ++ ){
            String sub_T = input.next();
            String sub_H = input.next();
            if(sub_T.compareTo(sub_H) < 0)
                grade_H += 3;
            if(sub_T.compareTo(sub_H) == 0){
                grade_T ++;
                grade_H ++;
            }
            if(sub_T.compareTo(sub_H) > 0)
                grade_T += 3;
        }
        System.out.println(grade_T + " " + grade_H);
    }
}


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

int main() {

	int n;
	string s;

	cin >> n >> s;

	string resp = "";

	for(int i = 0; i < s.size(); i++) {
		int num = s[i] - 'A';
		num += n;
		num %= 26;
		resp += 'A' + num;
	}

	cout << resp << endl;

	return 0;
}

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

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

#define all(x) x.begin(), x.end()
#define imie(x) cout << "[" << #x " = " << x << "] "
#define nl cout << "\n"

void solve() {
	string s;
	cin >> s;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << 3;
	}
	else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
		cout << 2;
	}
	else if(s[1] == 'R' || s[0] == 'R' || s[2] == 'R') {
		cout << 1;
	}
	else cout << 0;
}
int main(void) {
    
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
  
    //int t;
    //cin >> t;

	//for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	//}

	return 0;
}


Measured memory_bytes: 3648
use std::io::stdin;

fn doit(arr: &mut Vec<usize>) -> usize {
    // Split by zero
    arr.split_mut(|&a| a == 0).map(|a| {
        // Get minimum height
        let mut min = None;
        for &h in a.iter() {
            min = match min {
                None => Some(h),
                Some(x) if h < x => Some(h),
                _ => min,
            };
        }

        // Each values subtract by the minimum height
        if let Some(x) = min {
            for h in a.iter_mut() {
                *h -= x;
            }
            // Doit!!
            x + doit(a.to_vec().as_mut())
        } else {
            0
        }
    }).sum()
}

fn main () {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let mut harr = String::new();
    stdin().read_line(&mut harr).unwrap();
    println!("{}", doit(&mut harr.trim().split_whitespace().flat_map(str::parse).collect()));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include <vector>  
using namespace std;
int a,house[4][3][10],b,c,d,e;
int main(){
	cin>>a;
	for(int i=0;i<a;i++){
	cin>>b>>c>>d>>e;
	house[b-1][c-1][d-1]+=e;}
	for(int p=0;p<4;p++){
	for(int pp=0;pp<3;pp++){
	for(int ppp=0;ppp<10;ppp++){
	cout<<" "<<house[p][pp][ppp];}
	cout<<endl;}
	if(p<3){cout<<"####################"<<endl;}}
return 0;}
	


Measured memory_bytes: 1164
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
int rev[3100][3100];
int dp[3100][3100];
char s[3100];
char t[3100];
char ans[3100];
int main(){
	scanf("%s%s",s,t);
	int N=strlen(s);
	int M=strlen(t);
	for(int i=0;i<3100;i++)for(int j=0;j<3100;j++)
		dp[i][j]=-mod;
	dp[0][0]=0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			if(i+1<=N){
				if(dp[i+1][j]<dp[i][j]){
					dp[i+1][j]=dp[i][j];
					rev[i+1][j]=0;
				}
			}
			if(j+1<=M){
				if(dp[i][j+1]<dp[i][j]){
					dp[i][j+1]=dp[i][j];
					rev[i][j+1]=1;
				}
			}
			if(i+1<=N&&j+1<=M&&s[i]==t[j]){
				if(dp[i+1][j+1]<dp[i][j]+1){
					dp[i+1][j+1]=dp[i][j]+1;
					rev[i+1][j+1]=2;
				}
			}
		}
	}
	int ns=N;
	int nt=M;
	int at=dp[N][M]-1;
	while(ns||nt){
		if(rev[ns][nt]==0)ns--;
		else if(rev[ns][nt]==1)nt--;
		else{
			ns--;nt--;
			ans[at]=s[ns];
			at--;
		}
	}
	printf("%s\n",ans);
}


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

typedef long long int ll;

ll N;

int count753(ll x){
    int ret = 0;
    if(x > N) return 0;
    char s[10];
    sprintf(s, "%lld", x);
    if(strstr(s, "3") != NULL && strstr(s, "5") != NULL && strstr(s, "7") != NULL) ret = 1;
    return ret + count753(x*10 + 3) + count753(x*10 + 5) + count753(x*10 + 7);
}

int main(){
    scanf("%lld", &N);
    printf("%d\n", count753(0));
    return 0;
}

Measured memory_bytes: 128
fun main() = Thread(null, ::abc169c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc169c() {
    val (a, b) = readLine()!!.split(' ')

    val answer = a.toLong() * (b.replace(".", "").toLong()) / 100

    println(answer)
}


Measured memory_bytes: 40116
#include <iostream>
using namespace std;
int main(void){
   string s;
   int nc[26]={};
    
   while(getline(cin,s)){
       for(int i=0;i<(int)s.length();i++){
           if('a'<=s[i]&&s[i]<='z') nc[s[i]-'a']++;
           if('A'<=s[i]&&s[i]<='Z') nc[s[i]-'A']++;
       }
   }
   for(int i=0; i<26 ;i++){
       cout<<(char)('a'+i)<<" : "<<nc[i]<<endl;
   }
    
}


Measured memory_bytes: 3192
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: str):
    tmp = 0
    for c in N:
        tmp += int(c)
    if tmp % 9 == 0:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: str
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67992
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int ans,i;
	
	for(i=1;i<6;i++)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			ans=i;
		}
	
	}
	cout<<ans;
}

Measured memory_bytes: 3572
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



def run():
    N, *A = map(int, read().split())

    SUM = sum([abs(a) for a in A])
    if A.count(0):
        print(SUM)
        return

    do = [0]
    for a in A[:-1]:
        if not do[-1]:
            if a > 0:
                do.append(0)
            else:
                do.append(1)
        else:
            if a > 0:
                do.append(1)
            else:
                do.append(0)

    if A[-1] > 0:
        if do[-1]:
            base_ans = SUM - abs(A[-1]) * 2
        else:
            print(SUM)
            return
    else:
        if do[-1]:
            print(SUM)
            return
        else:
            base_ans = SUM - abs(A[-1]) * 2
    ans = base_ans
    for i in range(N-1):
        ans = max(ans, base_ans - abs(A[i]) * 2 + abs(A[-1]) * 2)

    print(ans)





if __name__ == "__main__":
    run()

Measured memory_bytes: 18252
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int a[n],i,j=0;
	for(i=0;i<n;i++){
		scanf("%d",a+i);
	}
	
	int max,min;
	int total=0;
	i=0;
	while(1){
		max=INT_MIN,min=INT_MAX;
		for(j=0;j<m;j++){
			if(a[i%n]>max){
				max=a[i%n];
			}
		
			if(a[i%n]<min){
				min=a[i%n];
			}	
			i++;
		}
		
		total+=(max-min);
		
		//printf("%d\n",max-min);
		
		if(i%n==0){
			break;
		}
	}
	
	printf("%d\n",total);

	return 0;
}

Measured memory_bytes: 2696
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

const MOD: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: [i64; n],
        y: [i64; m],
    }

    let mut w = 0;
    for i in 0..x.len() {
        w += (2 * i as i64 - (n - 1) as i64) * x[i];
        w %= MOD;
    }

    let mut h = 0;
    for i in 0..y.len() {
        h += (2 * i as i64 - (m - 1) as i64) * y[i];
        h %= MOD;
    }
    println!("{}", w * h % MOD);
}


Measured memory_bytes: 5528
def lcm(a,b):
    if a%b !=0:
        return lcm(b,a%b)
    else:
        return b
def gcm(a,b):
    l=lcm(a,b)
    return a*b//l

def main():
    n=int(input())
    t=[int(input()) for i in range(n)]
    ans = t[0]
    if n==1:
        print(t[0])
        exit()
    for i in t[1:]:
        ans=gcm(ans,i)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064