akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Drawing Lots
 * (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0011&lang=jp)
 * 
 * @author ikaruga
 */
class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			List<String> lines = br.lines().collect(Collectors.toList());
			
			// ?????\??????????????????
			String[] result = proccessAmidakuji(Integer.parseInt(lines.get(0)),
					Integer.parseInt(lines.get(1)),
					lines.stream().skip(2).map(l -> new Yokosen(l.split(",")))
							.collect(Collectors.toList()));

			Stream.of(result).forEach(System.out::println);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * ?????\???????????????????????????
	 * 
	 * @param tatesenNum
	 * @param yokosenNum
	 * @param yokosenList
	 */
	private static String[] proccessAmidakuji(int tatesenNum, int yokosenNum,
			List<Yokosen> yokosenList) {
		String[] result = new String[tatesenNum];

		// ????????°?????????????????????
		for (int tatesenNo = 1; tatesenNo <= tatesenNum; tatesenNo++) {
			int amidaNo = tatesenNo;
			for (Yokosen yokosen : yokosenList) {
				if (yokosen.isContain(amidaNo))
					amidaNo = yokosen.getExchangeNumber(amidaNo);
			}
			result[amidaNo - 1] = String.valueOf(tatesenNo);
		}
		return result;
	}

	/**
	 * ?¨????????????????
	 * 
	 * @author ikaruga
	 */
	static class Yokosen {
		int startNo = 0;
		int endNo = 0;

		public Yokosen(String[] numbers) {
			startNo = Integer.parseInt(numbers[0]);
			endNo = Integer.parseInt(numbers[1]);
		}

		public boolean isContain(int number) {
			return startNo == number || endNo == number;
		}

		public int getExchangeNumber(int number) {
			return startNo + endNo - number;
		}
	}
}

Measured memory_bytes: 30888
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;

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

    int count = 0;
    for(int i = 1; i < n -1; i++){
        if(
            (p[i-1] < p[i] && p[i] < p[i+1]) ||
            (p[i-1] > p[i] && p[i] > p[i+1])
            ){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	
	int a,b;cin>>a>>b;
	
	cout << max(0,a-b)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N; cin >> N;

  int ans = N*(N-1)/2;
  cout << ans << endl;
}

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


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,m,a=0,b=0;
    cin>>n;
    m=n;
    while(n!=0){
        a=n%10;
        b=b*10+a;
        n/=10;
    }
    if(b==m) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
/*...................bismillahir rahmanir rahim.....................*/
/*
  author :
    Muhammad Najmul hasan Nayeem
    Sust Math 17
*/
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/trie_policy.hpp>
// using namespace __gnu_pbds;
 
using namespace std;

#define m_p make_pair
#define PB push_back
#define eb emplace_back
#define FF first
#define SS second
#define MX5 100005
#define MX6 1000006
#define MOD 1000000007
#define in()({int a;scanf("%d",&a);a;})
#define SI(a) scanf("%d",&a)
#define SII(a,b) scanf("%d%d",&a,&b)
#define SIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SC()({char a;scanf("%c",&a);a;})
#define SL()({long long a;scanf("%lld",&a);a;})
#define SD()({double a;scanf("%f",&a);a;})
#define nl '\n'
#define For(_,n) for(int i=_;i<=n;i++)
#define once "once upon a time\n"
#define FI freopen("input.txt","r+",stdin);
#define FO freopen("output.txt","w+",stdout);
 
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<string,string> PSS;
// typedef tree<PII,null_type,less<PII>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out << "(" << a.FF << ", " << a.SS << ")";
}
 
template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
    out << "[";
    for(int i=0;i<v.size();i++) {
        if(i) out << ", ";
        out << v[i];
    }
    return out << "]";
}
 
#define chk(a) cout<<(#a)<<" = "<<a<<endl;
#define chka(a,_) cout<<(#a)<<"["<<_<<"] = "<<a[_]<<"\n";

// int Set(int n,int pos){ return n | (1<<pos); }
// int Reset(int n,int pos){ return n=n & ~(1<<pos); }
// bool Check(int n,int pos){ return (bool)(n & (1<<pos)); }
 
/*............start.............*/

void solve()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<nl;;
}
int main()
{
    // clock_t time_start=clock();
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int q=1;
    // cin>>q;
    // SI(q);
    for(int kase=1;kase<=q;kase++)
    {
        // cout<<"Case "<<kase<<": ";
        // printf("Case %d: ",kase );
        solve();
    }
    // clock_t time_end=clock();
    // cerr<<float((time_end-time_start)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> x(m), y(m);
	vector<int> cnt(n, 1);
	vector<int> on(n, 0);
	on[0] = 1;
	
	for(int i = 0; i < m; ++i) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		
		if( on[x[i]] && !on[y[i]] ) {
			on[y[i]] = 1;
		}
		
		cnt[x[i]]--; cnt[y[i]]++;
		
		if( cnt[x[i]] == 0 ) {
			on[x[i]] = 0;
		}
	}
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if( on[i] ) ans++;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
 
#define pb push_back
 
 
using namespace std;
 
int32_t main()
{
    string a,b;
    cin>>a>>b;
 
    int n=a.length();
    int m=b.length();
    vector<vector<int>>d(n+1,vector<int>(m+1));
    for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=m;j++)
    {  d[i][j]=0;
    }
   }
    for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=m;j++)
    {
         d[i][j]=0;
        if(i==0||j==0)
            d[i][j]=0;
 
        else if(a[i-1]==b[j-1])
        {
            d[i][j]+=d[i-1][j-1]+1;
        }
        else
        {   if(d[i-1][j]>=d[i][j-1])
            d[i][j]+=d[i-1][j];
            else
            d[i][j]+=d[i][j-1];
        }
    }
   }
   int ind=d[n][m];
   char ans[ind+1];
   int i=n;
   int j=m;
   ans[ind]='\0';
   while(i>0&&j>0)
   {
       if(a[i-1]==b[j-1])
       {
           ans[ind-1]=a[i-1];
           ind--;
           i--;j--;
       }
       else if(d[i-1][j]>d[i][j-1])
        i--;
       else
        j--;
 
   }
   cout<<ans;
 
}


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



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

using namespace std;
int a,b,c;

int main(){
  cin >> a >> b >> c;
  if(a>=b && a>=c) cout << b*c/2 << endl;
  else if(b>=c && b>=a) cout << a*c/2 << endl;
  else if(c>=b && c>=a) cout << a*b/2 << endl;
  return 0;
}


Measured memory_bytes: 256
N,D = map(int,input().split())
xy = []
for i in range(N):
    x,y = map(int,input().split())
    xy.append([x,y])
ans = 0
for i in range(N):
    x = xy[i][0]
    y = xy[i][1]
    if(D*D >= (x*x + y*y)):
        ans+=1
print(ans)

Measured memory_bytes: 39056
N = int(input())

CSF = [[int(i) for i in input().split()] for _ in range(N-1)]
for i in range(N-1) :
    x = 0
    for j in range(i, N-1) :
        C, S, F = CSF[j]
        if x < S :
            x = S + C
        else :
            x = S + F * ((x - S + F - 1) // F) + C
    print(x)
print(0)

Measured memory_bytes: 41964
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<int> v(n);

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

        vector<int> c(n);

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

    vector<int> diff(n);

    for(int i=0;i<n;i++){
        diff[i]=v[i]-c[i];
    }

    int ans=0;

    for(int i=0;i<n;i++){
        if(diff[i] > 0){
            ans +=diff[i];
        }
    }

    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
#define MAX_N 1500
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
bool isPrime(int x)
{
	if(x < 2) return false;
	if(x == 2) return true;
	if(x % 2 == 0) return false;
	for(int i = 3; i * i <= x; i += 2)
	{
		if(x % i == 0) return false;
	}
	return true;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll ans = 1;
	vector<int> prime;
	for(int i = 0; i <= 5000; i++)
		if(isPrime(i)) prime.push_back(i);
	vector<int> cnt(prime.size() + 1, 1);
	for(int i = 2; i <= n; i++)
	{
		int tmp = i;
		int pos = 0;
		while(tmp >= 2)
		{
			if(tmp % prime[pos] == 0)
			{
				tmp /= prime[pos];
				cnt[pos]++;
			}
			else
			{
				pos++;
			}
		}
	}
	for(int i = 0; i < cnt.size(); i++)
	{
		ans = (ans * cnt[i]) % MOD;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def combinations_count(n, r, mod=MOD):
    def factorial_mod(N, mod=MOD):
        ret = 1
        for n in range(1, N + 1):
            ret *= n
            ret %= mod
        return ret

    q = factorial_mod(n + r, mod)
    b = factorial_mod(n, mod)
    d = factorial_mod(r, mod)
    b = pow(b, mod - 2, mod)
    d = pow(d, mod - 2, mod)
    return (q * b * d) % mod


def Base_10_to_n(X, n):
    if (int(X / n)):
        return Base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    print(len(Base_10_to_n(N, K)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 74912
import math
 
rad = math.radians(60)
 
class coordinates:
  def __init__(self, x, y):
    self.x = x
    self.y = y
  
def koch(n, a, b):
  if n == 0:
    return
  s = coordinates((2.0*a.x + b.x)/3.0, (2.0*a.y + b.y)/3.0)
  t = coordinates((a.x + 2.0*b.x)/3.0, (a.y + 2.0*b.y)/3.0)
  ux = (t.x - s.x)*math.cos(rad) - (t.y - s.y)*math.sin(rad) + s.x
  uy = (t.x - s.x)*math.sin(rad) + (t.y - s.y)*math.cos(rad) + s.y
  u = coordinates(ux, uy)
   
  koch(n-1, a, s)
  print  s.x, s.y
  koch(n-1, s, u)
  print  u.x, u.y
  koch(n-1, u, t)
  print  t.x, t.y
  koch(n-1, t, b)
   
n = input()
   
p1 = coordinates(0.0, 0.0)
p2 = coordinates(100.0, 0.0)
   
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y

Measured memory_bytes: 6660
#!/bin/sh

while true;
do
        read line1

        if [ -z "$line1" ]; then
                break
        fi

        hand=`echo $line1 | awk '{print $1+$2+$3}'`
        if [ $hand -gt 21 ]; then
                echo "bust"
        else
                echo "win"
        fi

done

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;


const int mod = 1e9+ 7;

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

    int len = s.size();

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

    int dp[110000][13];

    if(s[0]=='?') {
        for(int i=0; i<10; i++){
            dp[0][i] = 1;
        }
        } else {
            int index = s[0]-'0';
            dp[0][index] = 1;
        }

    int num = 1;
    for(int i= 1; i<len; i++){
        num *=10;
        num %=13;

        if(s[i]=='?'){
            rep(j, 10){
                rep(k, 13){
                    int index = (j*num + k)%13;
                    dp[i][index] += dp[i - 1][k];
                    dp[i][index] %=mod;
                }
            }

        }else{
            rep(k,13){
                int j = (s[i]-'0');
                int index = (j*num+k)%13;
                dp[i][index] += dp[i - 1][k];
                dp[i][index] %mod;
            }

        }

    }

    cout<< dp[len -1][5]<<endl;

    return 0;


}

Measured memory_bytes: 5504
from collections import Counter
n=int(input())
s=[list(input()) for i in range(n)]
for i in range(n):
  s[i].sort()
s=["".join(s[i]) for i in range(n)]
c=Counter(s)
ans=0
for i in c.values():
  ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 31800
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n ;
    vector<int> x(n);
    for(int i = 0; i < n ; i ++){
        cin >> x[i];
    }
    int ans = 1e+9;
    int sm = 0;
    for(int i=0;i<=100;i++){
        sm = 0;
        for (auto v:x){
            sm += pow(v - i, 2);
        }
        ans = min(ans, sm);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    while(true){
        int H,W;
        cin>>H>>W;
        if(H==0 && W==0)return 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++)cout<<'#';
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int D = Integer.parseInt(sc.next());
        var c = new int[27];
        for(int i = 1; i <= 26; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        var s = new int[D+1][27];
        for(int d = 1; d <= D; d++){
            for(int i = 1; i <= 26; i++){
                s[d][i] = Integer.parseInt(sc.next());
            }
        }
    
        var last = new int[27];
        var sb = new StringBuilder();
        for(int d = 1; d <= D; d++){
            int max = Integer.MIN_VALUE;
            int contest = 1;
            for(int i = 1; i <= 26; i++){
                int score = s[d][i];
                for(int j = 1; j <= 26; j++){
                    if(i == j) continue;
                    score -= c[j] * (d - last[j]);
                }
                if(score > max){
                    max = score;
                    contest = i;
                }
            }
            last[contest] = d;
            sb.append(contest).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 42152
#include<stdio.h>
int main(void){
  int n,count=0;
  scanf("%d",&n);

  while(n!=0){
    count = 0;
    while(n!=1){
      if(n%2 == 0) n /= 2;
      else n = n*3 + 1;
      count ++;
    }
    printf("%d\n",count);
    scanf("%d",&n);
  }
  return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i, n){
        int x;
        cin >> x;
        a[i] = x - 1;
    }
    REP(i, n) cin >> b[i];
    REP(i, n-1) cin >> c[i];

    int ans = 0;
    REP(i, n){
        ans += b[a[i]];
        if(i < n-1 && a[i+1] == a[i] + 1){
            ans += c[a[i]];
        }
    }

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


Measured memory_bytes: 256
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}

const int N = 2000;
int table[N][N];

ll solve(int n, vector<int>&in, ll x){
  rep(i,n){
    rep(j,n){
      table[i][j] = in[(i-j+n)%n];
    }
    REP(j,1,n){
      table[i][j] = min(table[i][j], table[i][j-1]);
    }
  }

  ll ret = accumulate(begin(in), end(in), 0LL);
  rep(j,n){
    ll tmp = j * x;
    rep(i,n){
      tmp += table[i][j];
    }
    ret = min(ret, tmp);
  }
  return ret;
}
 
int main(){
  int n;
  ll x;
  cin >> n >> x;
  vector<int> in(n);
  rep(i,n)cin>>in[i];
  cout << solve(n, in, x) << endl;
  return 0;
}
 
 


Measured memory_bytes: 15872
X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
a = sorted(p)[A-X:]+sorted(q)[B-Y:]+r
print(sum(sorted(a)[C:]))

Measured memory_bytes: 22720
#include <stdio.h>

int main(void){
    int i, n, a[100000], b[100000];
    
    scanf("%d", &n);
    for( i = 0; i < n; i++ ){
        scanf("%d ", &a[i]);
        b[a[i]] = i+1;
    }
    
    for( i = 1; i <= n; i++ ){
        printf("%d ", b[i]);
    }

    return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;
    char a[110][110];
    imfor(i, h) {
        imfor(j, w) {
            cin >> a[i][j];
        }
    }
    int rows[110];
    int cols[110];
    fill(rows, rows + 100, 0);
    fill(cols, cols + 100, 0);
    imfor(i, h) {
        bool f = true;
        imfor(j, w) {
            if (a[i][j] == '#') {
                f = false;
                break;
            }
        }
        if (f) {
            rows[i] = 1;
        }
    }
    imfor(i, w) {
        bool f = true;
        imfor(j, h) {
            if (a[j][i] == '#') {
                f = false;
                break;
            }
        }
        if (f) {
            cols[i] = 1;
        }
    }

    imfor(i, h) {
        if (rows[i] == 1) {
            continue;
        }
        bool f = true;
        imfor(j, w) {
            if (cols[j] == 0) {
                cout << a[i][j];
                f = false;
            }
        }
        if (!f) {
            cout << endl;
        }
    }
}

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


int main() {
    long long int A, B, V, W, T;
    std::cin >> A >> V >> B >> W >> T;

    if (V - W <= 0) {
        std::cout << "NO" << std::endl;
        return 0;
    }


    if (std::abs(B - A) <= (V - W) * T) {
        std::cout << "YES"  << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 3620
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
char c1[N][N];
char c2[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> c1[i];
	for (int i = 0; i < m; i++) cin >> c2[i];
	for (int i = 0; i + m <= n; i++)
	{
		for (int j = 0; j + m <= n; j++)
		{
			int tot = 0;
			for (int x = 0; x < m; x++)
			{
				for (int y = 0; y < m; y++)
				{
					tot += c1[i + x][j + y] == c2[x][y];
				}
				if (tot % m) break;
			}
			if (tot == m * m) puts("Yes"), exit(0);
		}
	}
	puts("No");
	return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    vi v ( n ) ;
    int s = 0 ;

    for ( int i=0 ; i < n ; i ++ )
        cin >> v[i] , s += v[i] ;

    int ans = 0 ;
    for ( int i=0 ; i < n ; i ++ )
    {
        int temp = s - v[i] ;
        if ( temp % 10 ) ans = max ( ans , temp ) ;
    }

    if ( s % 10 ) ans = max ( ans , s ) ;

    cout << ans ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll k,n; cin >> n >> k;
  vector<double> e(n);
  double ans = 0.0;
  rep(i,n){
    int p; cin >> p;
    e.at(i) = (p+1)/2.0;
    if(i<k) ans+=e.at(i);
  }

  double E = ans;

  for(int i=0;i<n-k;i++){
    E = E + e.at(i+k) - e.at(i);
    ans = max(ans,E);
  }

  printf("%.11f",ans);

}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
x, y = map(int,input().split())

ans = 0
if x == 3:
    ans += 100000
if y == 3:
    ans += 100000
if x == 2:
    ans += 200000
if y == 2:
    ans += 200000
if x == 1:
    ans += 300000
if y == 1:
    ans += 300000
if x == 1 and y == 1:
    ans += 400000
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main
{
	public  static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[][] = new int[n][n];
			a[(n/2)+1][n/2]=1;
			int c=2;
			int x=(n/2)+1;
			int y=n/2;
			x++;
			y++;
			while(c<=n*n)
			{
				if(x<n&&y>=0&&y<n&&a[x][y]==0)
				{
					a[x][y]=c;
					x++;
					y++;
					c++;
				}
				if(y==n)
				{
					y=0;
				}
				if(x==n)
				{
					x=0;
				}
				if(y==-1)
				{
					y=n-1;
				}
				if(a[x][y]!=0)
				{
					y--;
					x++;
				}
			}
			for(int i=0; i<n;i++)
			{
				for(int j=0; j<n; j++)
					System.out.printf("%4d",a[i][j]);
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
int main(){
    int k,a,b;
    string ans;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            ans="OK";
            break;
        }
        else ans="NG";
        
    }
    cout<<ans;
}


Measured memory_bytes: 3592
# include <bits/stdc++.h>
# define rr
const int N=100010,INF=0x3f3f3f3f;
struct Edge{
	int to,next;
}edge[N<<1];
int head[N],sum;
int h[N];
int ans;
int n,m;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
inline void add(int x,int y){
	edge[++sum].to=y;
	edge[sum].next=head[x];
	head[x]=sum;
	return;
}
int main(void){
	n=read(),m=read();
	for(rr int i=1;i<=n;++i){
		h[i]=read();
	}
	for(rr int i=1;i<=m;++i){
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	for(rr int i=1;i<=n;++i){
		if(!head[i]){
			++ans;
			continue;
		}
		for(rr int j=head[i];j;j=edge[j].next){
			if(h[edge[j].to]>=h[i]){
				goto End;
			}
		}
		++ans;
		End:;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 6040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long a[] = new long[n];
		long b[] = new long[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}

		long add = 0;
		for(int i = n - 1; i >= 0; i--){
			if((a[i] + add)%b[i] != 0){
				add += b[i] - (a[i] + add)%b[i];
			}
		}

		System.out.println(add);
	}
}


Measured memory_bytes: 52332
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
using P = pair<int,int>;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> xx(n);
    rep(i,n) {
        cin >> x[i];
        xx[i] = x[i]*x[i];
    }
    int ans = INF;
    int sum_x = accumulate(x.begin(), x.end(), 0);
    int sum_xx = accumulate(xx.begin(), xx.end(), 0);
    for(int i=1; i<=100; i++){
        int sum_hp = sum_xx - 2*i*sum_x+n*i*i;
        ans = min(sum_hp, ans);
    }
    cout << ans << endl;
}

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

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

    int alf[26] = {};
    for (auto x : s) alf[x - 'a']++;

    for (int i = 0; i < 26; i++) {
        if (!alf[i]) {
            return cout << char(i + 'a') << endl, 0;
        }
    }
    cout << "None" << endl;

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC156
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }
        
        public static void a()
        {
            int[] nr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if(nr[0] > 9)
            {
                Console.WriteLine(nr[1]);
            }
            else
            {
                Console.WriteLine(100 * (10 - nr[0]) + nr[1]);
            }
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    if(S.equals(T.substring(0,T.length()-1))){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vi memo(100, 0);

int fib(int n)
{
    if(memo[n] != 0) return memo[n];
    return memo[n] = fib(n-1)+fib(n-2);
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n; cin >> n;
    memo[0] = memo[1] = 1;
    cout << fib(n) << endl;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		int time = in.nextInt();
		int hours;
		int minuts;
		int second;

		hours = time/3600;
		minuts = (time%3600)/60;
		second = (time%360)%60;

		System.out.println(hours + ":" + minuts + ":" + second);






	}

}



Measured memory_bytes: 26384
#include <bits/stdc++.h>     
using namespace std;
typedef long long int ll;
typedef long long int lli;
typedef vector < ll > vi;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DBG(c) cout << #c << " = " << c << endl;
#define Mod 1000000007
#define INF 1e18L+5
lli find_min(lli a,lli b){if(a>b) return b; return a;}
lli find_max(lli a,lli b){if(a<b) return b; return a;}

int main()
{
    fastio
    string s,t;
    cin>>s>>t;
    int len1 = s.length();
    int len2 = t.length();
    int dp[len1+1][len2+1];
    for(int i = 0;i <= len1; i++) dp[i][0] = 0;  
    for(int j = 0;j <= len2; j++) dp[0][j] = 0;
    // string res = "";
    for(int i = 1;i <= len1; i++)
    {
        for(int j = 1; j<=len2 ; j++) 
        {
            if(s[i-1] == t[j-1])
               {
                  dp[i][j] = 1 + dp[i-1][j-1];
                  // res+=s[i];
               } 
            else
                {
                    dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);    //not included
                    // res -= s[i];
                }
        }  
    }
    // int tot = dp[len1][len2];
    int len = dp[len1][len2]; 
    char ans[len+1];
    ans[len]= '\0';
    while(len1>0 && len2>0)         //backtracing 
    {
        if(s[len1-1] == t[len2-1])
        {
            ans[len-1] = s[len1-1];
            len1--;
            len2--;
            len--;
        }
        else if(dp[len1-1][len2] > dp[len1][len2-1])
            len1--;
        else
            len2--;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 35456
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new KK(); }
class KK
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public KK()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N;
	int[] cnt;
	void Solve()
	{
		var I = GL;
		N = (int)I[0];
		var K = ToBits(I[1]);
		var A = GL.Select(ToBits).ToArray();
		cnt = new int[50];
		var good = new bool[50];
		for (var a = 0; a < 50; a++)
		{
			for (var i = 0; i < N; i++) if (A[i][a]) cnt[a]++;
			good[a] = cnt[a] <= N - cnt[a];
		}
		var ans = Max(Calc(new bool[50]), Calc(K));
		for (var i = 0; i < 50; i++) if (K[i])
			{
				var x = new bool[50];
				for (var j = 0; j < i; j++) x[j] = good[j];
				for (var j = i + 1; j < 50; j++) x[j] = K[j];
				ans = Max(ans, Calc(x));
			}
		WriteLine(ans);
	}
	long Calc(bool[] x)
	{
		var sum = 0L;
		for (var a = 0; a < 50; a++) sum += (x[a] ? N - cnt[a] : cnt[a]) * (1L << a);
		return sum;
	}
	static bool[] ToBits(long x)
	{
		var ans = new bool[50];
		for (var i = 0; i < 50; i++) ans[i] = (x & (1L << i)) != 0;
		return ans;
	}
}


Measured memory_bytes: 38572
n,a,b = map(int, input().split())
MOD = 10**9+7

def cmb(n,r):
    a,b = 1,1
    for i in range(r):
        a = a * (n-i) % MOD
        b = b * (i+1) % MOD
    return a * pow(b, MOD-2, MOD)%MOD

print((pow(2,n,MOD) - cmb(n,a) - cmb(n,b) - 1)%MOD)

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

const int dx[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
const int dy[9] = { 0, -1, 0, 1, 1, 1, 0, -1, -1 };

long long ans[10];
map<pair<int, int>, int> cnt;

int main( void ) {
    
    int h, w, n;
    cin >> h >> w >> n;
    
    ans[0] = 1LL * (h - 2) * (w - 2);
    for( int i = 1; i <= n; i ++ ) {
        pair<int, int> pr;
        cin >> pr.first >> pr.second;
        
        for( int d = 0; d <= 8; d ++ ) {
            pair<int, int> npr = make_pair( pr.first + dx[d], pr.second + dy[d] );
            
            if( npr.first <= 1 || npr.second <= 1 ) continue;
            if( npr.first >= h || npr.second >= w ) continue;
            
            ans[cnt[npr]] --;
            cnt[npr] ++;
            ans[cnt[npr]] ++;
        }
    }
    
    for( int i = 0; i <= 9; i ++ )
        cout << ans[i] << endl;
    
    return 0;
}

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

using namespace std;
# define rep(i, a, b) for(int i = a; i < (b); ++i)
# define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    n--;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += n / i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>

int main()
{
    int x;
    std::cin >> x;
    const size_t x_max = 1001;
    int exponential[x_max];
    for(auto i = 0; i <= x_max; ++i)
        exponential[i] = 0;
    exponential[1] = 1;

    for(auto b = 2.0; b <= sqrt(x); ++b) {
        for(auto p = 2.0; ; ++p)
        {
            auto v = static_cast<int>(pow(b, p));
            if(v > x)
                break;
            else
                exponential[v] = 1;
        }
    }

    for(auto i = x; i >= 1; --i) {
        if(exponential[i] == 1)
        {
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 512
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    long MOD = 1_000_000_007;
    String[] s = br.readLine().split(" ");
    long n = Long.parseLong(s[0]);
    long m = Long.parseLong(s[1]);

    if (m>n+1 || m<n-1) {
      System.out.println(0);
      System.exit(0);
    }
    long fact1 = 1;
    long fact2 = 1;
    for (int i=0; i<m; i++) {
      fact1*=(i+1);
      fact1%=MOD;
    }
    for (int i=0; i<n; i++) {
      fact2*=(i+1);
      fact2%=MOD;
    }
    long ans = (fact1*fact2)%MOD;
    if (m==n)
      ans*=2;
    ans%=MOD;
    System.out.println(ans);
  }
}


Measured memory_bytes: 21588
A, B, C = map(int, input().split())

# A,B,Cのうち 2つは 同じ整数であり、残りの 1つだけ異なる整数
# A,B,Cのうち、1つだけ異なる整数を出力

if A == B and A != C and B != C:
    print(C)
elif A == C and A != B and C != B:
    print(B)
else:
    print(A)

Measured memory_bytes: 9168
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//約数の列挙O(√n)
vector<ll>divisor(ll n){
  vector<ll>res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}

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

ll comb(ll n, ll r){
  ll res=1;
    for(ll i=0;i<r;i++){
      res*=n-i;
      res%=MOD;
    }
  res*=modpow(factorial(r),MOD-2,MOD);
  res%=MOD;
  return res;
}

int main(){
  
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  rep(i,n){
    while(a[i]%2==0){
      a[i]/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;


long long M = 1000000007;

int main(int argc, char const *argv[]) {
	int n;cin>>n;
	vector<int> a(n);
	int ma=0;
	for(int i=0;i<n;++i){
		cin>>a[i];
		ma = max(ma,a[i]);
	}
	vector<int> b(n);
	for(int i=0;i<n;++i){
		b[a[i]]++;
		if(a[i]<(ma+1)/2){
			cout<< "Impossible"<<endl;
			return 0;
		}
	}
	string res="Possible";
	if(ma%2==0){
		for(int k=ma;k>ma/2;--k)if(b[k]<2)res="Impossible";
		if(b[ma/2]!=1)res="Impossible";
	}
	else{
		for(int k=ma;k>ma/2+1;--k)if(b[k]<2)res="Impossible";
		if(b[ma/2+1]!=2)res="Impossible";
	}
	cout<<res<<endl;

	return 0;
}


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

a = 1
p = 1

while p < 1e6:
    c = 0
    t = 0
    p += 1
    while n%p == 0:
        n /= p
        x=c==t
        t += x
        c += 1-t*x
        a += x

print(a-(n<2))

Measured memory_bytes: 9248
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

int main() {
    int N; cin >> N;
    string S1; cin >> S1;
    string S = S1 + S1;

    vector<int> res(2*N,0);
    //0...羊 1...狼
    for (int k = 0; k < 4; k++) {
        for (int i = 0; i < 2*N; i++) res[i] = 0;
        res[0] = k&1;
        res[1] = (k&2)/2;

        for (int i = 2; i < N; i++) {
            if (S[i-1] == 'o') res[i] = res[i-2] ^ res[i-1];
            else res[i] = !(res[i-2] ^ res[i-1]);
        }
        bool flag = true;
        
        if (S[0] == 'o' && (res[1] != res[N-1] ^ res[0])) flag = false;
        if (S[0] == 'x' && (res[1] == res[N-1] ^ res[0])) flag = false;
        if (S[N-1] == 'o' && (res[0] != res[N-2] ^ res[N-1])) flag = false;
        if (S[N-1] == 'x' && (res[0] == res[N-2] ^ res[N-1])) flag = false;

        if (flag) {
            for (int i = 0; i < N; i++) {
                if (res[i] == 0) cout << 'S';
                else cout << 'W';
            } 
            cout << endl; return 0;
        }
    }
    cout << "-1\n";

    

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    vector<ll> vec(3);
    rep(i, 3) cin >> vec[i];
    sort(vec.begin(), vec.end());

    ll ans = 0;
    if (!(vec[0] % 2 == vec[1] % 2 && vec[1] % 2 == vec[2] % 2)) {
        if ((vec[0] - vec[1]) % 2 == 0) {
            vec[0]++;
            vec[1]++;
        } else if ((vec[0] - vec[2]) % 2 == 0) {
            vec[0]++;
            vec[2]++;
        } else if ((vec[1] - vec[2]) % 2 == 0) {
            vec[1]++;
            vec[2]++;
        }
        ans++;
    }
    // rep(i, 3) { cout << vec[i] << endl; }
    sort(vec.begin(), vec.end());

    ans += (vec[2] - vec[0]) / 2;
    ans += (vec[2] - vec[1]) / 2;

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

Measured memory_bytes: 3572
import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
  ten %= 2019 
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

Measured memory_bytes: 16652
N = int(input())
T = [[0] * (N+1) for _ in range(N+1)]
for i in range(N):
    tmp = [int(ele) for ele in input().split()]
    from_ = tmp[0]
    for j in tmp[2:]:
        T[from_][j] = 1


def main():
    for i in T[1:]:
        ans = ""
        for j in i[1:]:
            ans += str(j) + " "
        print(ans[:-1])


if __name__ == "__main__":
    main()



Measured memory_bytes: 5672