akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var dict1 = new Dictionary<char, char>();
            var dict2 = new Dictionary<char, char>();
            for (var i = 0; i < s.Length; i++)
            {
                if (dict1.ContainsKey(s[i]))
                {
                    if (dict1[s[i]] != t[i])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    dict1[s[i]] = t[i];
                }

                if (dict2.ContainsKey(t[i]))
                {
                    if (dict2[t[i]] != s[i])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    dict2[t[i]] = s[i];
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


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

using namespace std;

string s, t;

vector<vector<int>> memo(2000, vector<int>(2000,-1));

//s???i??????????????§???t???j??????????????§?????£?????¨??????LCS
int solve(int i, int j) {
	if (memo[i][j] != -1)return memo[i][j];

	if (i == 0 && j == 0)return (s[0] == t[0]);
	if (i == 0)return memo[i][j] = (bool)(solve(i, j - 1) + (s[i] == t[j]));
	if (j == 0)return memo[i][j] = (bool)(solve(i - 1, j) + (s[i] == t[j]));
	if (s[i] == t[j]) return solve(i - 1, j - 1) + 1;
	return memo[i][j] = max(solve(i - 1, j), solve(i, j - 1));
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		cin >> s >> t;
		memo = vector<vector<int>>(2000, vector<int>(2000,-1));
		cout << solve(s.size() - 1, t.size() - 1) << endl;
	}
}

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

main(){
  string s;
  cin >> s;
  if(s=="SUN"){cout << 7 << endl;}
  else if(s=="MON"){cout << 6 << endl;}
  else if(s=="TUE"){cout << 5 << endl;}
  else if(s=="WED"){cout << 4 << endl;}
  else if(s=="THU"){cout << 3 << endl;}
  else if(s=="FRI"){cout << 2 << endl;}
  else{cout << 1 << endl;}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll A;
    string B;
    cin >> A >> B;
    ll c = 100 * (B[0] - '0') + 10 * (B[2] - '0') + (B[3] - '0');
    ll ans = A * c / 100;
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
using namespace std;
typedef long long int ll;

int main() {
  	int n;
    double d;
  cin >> n >> d;
  int cnt= 0;
  for(int i=0; i<n; i++) {
   	ll x, y;
    cin >> x >> y;
    double dist = sqrt(x*x + y*y);
    if(dist <= d) {
      cnt += 1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main {
	int [][] map;
	int ans;
	String [][] boards;
	boolean isused [];

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String inputline = sc.next();
			String [] inputarray = inputline.split(",");
			int [] dis = new int[10];
			for(int i = 0; i < 10; i++){
				dis[i] = Integer.parseInt(inputarray[i]);
			}
			int [] accdis = new int[10];
			accdis[0] = dis[0];
			for(int i = 1; i < 10; i++){
				accdis[i] = accdis[i-1] + dis[i];
			}
			int v1 = Integer.parseInt(inputarray[10]);
			int v2 = Integer.parseInt(inputarray[11]);
			int sumdis = accdis[9];
			double t = (double)sumdis / (v1 + v2);
			int nowdis = (int) Math.round(v1 * t);
			int ans = -1;
			for(int i = 0; i < 10; i++){
				if(nowdis > accdis[i]){
					ans = i + 2;
				}
				else{
					break;
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;

int main() {
	int X, Y;
	cin >> X >> Y;
	if ((X + Y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	else if ((2*Y < X) || (Y > 2*X)) {
		cout << 0 << endl;
		return 0;
	}
	
	int n = (X + Y) / 3;
	int k = (n - abs(X - Y)) / 2;
	// Calculate nCk
	long long ans = 1;
	for (int i = n; i >= n-k+1; i--) {
		ans = (ans * i) % MOD;
	}
	vector<long long> inv(k+1);
	inv[0] = 1;
	inv[1] = 1;
	for (int i = 2; i <= k; i++) {
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
	}
	for (int i = 1; i <= k; i++) {
		ans = (ans * inv[i]) % MOD;
	}
	cout << ans << endl;
}


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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    int n; in >> n;

    vector<int> d(1505, 0);
    vector<int> prime;
    REPE(i,2,n)
    {
        bool flag = true;
        REPE(j,2,i-1) if(i % j == 0) flag = false;
        if(flag) prime.pb(i);
    }

    ll res = 1LL;
    REPE(i,2,n)
    {
        int t = i;
        for(int v : prime)
        {
            while(t % v == 0)
            {
                d[v]++;
                t /= v;
            }
        }
    }

    for(int v : prime)
    {
        res = (res * (d[v]+1)) % MOD;
    }

    out << res << endl;

    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++)
    {
        cin >> A[i];
    }

    long long sum = 0;
    int m = 0;
    for (int i=0; i<N; i++)
    {
         m= max(m, A[i]);
        int s = m;
        sum += s - A[i];
    }

    cout << sum <<'\n';
}


Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(void){
    int a, b, x=0;

    cin >> a >> b;

    if(a > b){
        x += a;
        a--;
    }
    else{
        x += b;
        b--;
    }

    if(a > b){
        x += a;
        a--;
    }
    else{
        x += b;
        b--;
    }

    cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
const int N = 1e3 + 5;
const int MOD = 1e9 + 7;
int dp[N][N];
char arr[N][N];

class HGrid1 {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;
        in >> n >> m;
        for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) in >> arr[i][j];
        dp[n][m] = 1;
        for (int i = n; i >= 1; --i) {
            for (int j = m; j >= 1; --j) {
                if (i == n and j == m) continue;
                int path = 0;
                if (arr[i + 1][j] != '#') path += dp[i + 1][j];
                if (arr[i][j + 1] != '#') path += dp[i][j + 1];
                if (arr[i][j] != '#') dp[i][j] = path % MOD;
            }
        }
        out << dp[1][1];
    }
};


int32_t main() {
    HGrid1 solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 9088
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

n = get_int()
ls = get_list()
peak_pts = []
inc = True if ls[1]>ls[0] else False
if ls[1]>ls[0]:
    peak_pts.append(0)
i = 1
while i<n:
    if ls[i]>=ls[i-1]:
        if not inc:
            peak_pts.append(i - 1)
            inc = not inc
    else:
        if inc:
            peak_pts.append(i-1)
            inc = not inc
    i += 1
if ls[-1]>=ls[-2]:
    peak_pts.append(n-1)

#print(peak_pts)
profit = 1000
le = len(peak_pts)
ava_bought,ava_sell = 1000,0
for ind in range(0,le,2):
    i = peak_pts[ind]
    if ind+1<le:
        midprofit = 0

        # Buy
        j = i
        totalshares = 0
        while j<peak_pts[ind+1]:
            shares = (ava_bought//ls[j])
            ava_bought -= shares*ls[j]
            midprofit -= shares*ls[j]
            ava_sell += shares*ls[j]
            totalshares += shares
            if ava_bought==0: break
            if j+1<n and ls[j+1]>ls[j]: break
            j += 1

        #Sell
        j = peak_pts[ind+1]
        midprofit += ls[j]*totalshares
        if midprofit>0:
            profit += midprofit
        ava_bought = profit
        #print(ava_bought, ava_sell, midprofit,totalshares)
print(profit)


Measured memory_bytes: 9300
import numpy as np
l = np.zeros(5)
t = np.zeros(5)
k = True
for i in range(5):
    l[i] = int(input())
    t[i] = l[i] - (l[i]//10)*10
    if t[i] != 0 :
        k = False
t.sort()
for i in range(5):
    if t[i] != 0:
        s = t[i]
        break
l = np.ceil(l/10)*10
if k :
    ans = int(np.sum(l))
else :
    ans = int(np.sum(l)+s)-10
print(ans)




Measured memory_bytes: 12396
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N;
  std::cin >> N;

  std::vector<int> W(N), S(N+1, 0);
  for(int i=0; i<N; i++) {
    std::cin >> W[i];
  }

  S[0] = W[0];
  for(int i=1; i<N; i++) {
    S[i] = S[i-1] + W[i];
  }

  int diff = std::numeric_limits<int>::max();
  for(int i=0; i<N-1; i++) {
    int A = S[i];
    int B = S[N-1] - A;
    if ( diff > std::abs(A-B) ) {
      diff = std::abs(A-B);
    }
  }

  std::cout << diff << std::endl;

  return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key = lambda x: x[0])

    tot, budget = 0, 0
    for i in range(N):
        if tot + AB[i][1] <= M:
            tot += AB[i][1]
            budget += AB[i][0] * AB[i][1]
            if tot == M:
                return budget
        else:
            budget += (M - tot) * AB[i][0]
            return budget

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 21972
#include <stdio.h>

int main()
{
long long int i,n,v,sum,c[100000];

scanf("%lld",&n);
v=n;
while(n!=0)
    {
        c[i]=n%10;
        n=n/10;
    
  sum+=c[i];  
}
if(v%sum==0) printf("Yes");    
else printf("No");
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

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

int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }
   
   for (int i = 1; i < n; ++i)
   {
      if (a[i] > a[i-1]){
         --a[i];
      }
      // if (a[i] > a[i+1]){
      //    a[i]--;
      //    if(a[i] > a[i+1]){
      //       no();
      //    }
      //    if (i-1 >= 0 and a[i] < a[i-1]){
      //       no();
      //    }
      // }
   }

   bool good = 1;
   for (int i = 0; i+1 < n; ++i)
   {
      good &= a[i] <= a[i+1];
   }

   if (good){
      yes();
   }
   else{
      no();
   }

   return 0;
}

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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int l = 0, r = 0;
	for(int i = 0; i < m; i++) {
	    int y;
	    cin >> y;
	    l += (y < x);
	    r += (y > x);
	}
	cout << min(l, r);
	return 0;
}


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

#define REP(i, a, n) for(int i=a; i<n; i++)
#define sortv(v) sort(v.begin(), v.end());
#define sortg(v) sort(v.begin(), v.end(), greater<>());
int main() {
  int n;
  cin >> n;
  map<int, int> m;
  REP(i, 0, n){
    int tmp;
    cin >> tmp;
    m[tmp]++;
  }
  cout << m.size() << endl;  
}


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

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

vector <pii> v1;
int n, k;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	if (k > (n - 1) * (n - 2) / 2)
		return cout << "-1\n", 0;
	for (int i = 2; i <= n; i++)
		v1.PB(MP(1, i));
	for (int i = 2; i <= n; i++)
		for (int t = i + 1; t <= n; t++) {
			if (k) {
				k--;
				continue;
			}
			v1.PB(MP(i, t));
		}
	cout << sz(v1) << "\n";
	for (auto x : v1)
		cout << x.F << " " << x.S << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n;
vector<int> a = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int dp[100010];
	
int main(){
	int i,j,k,ans;
	cin >> n;
	dp[0] = 0;
	for(i=1;i<=n;i++){
		dp[i] = 100010;
		k = upper_bound(a.begin(),a.end(),i) - a.begin();
		for(j=0;j<k;j++){
			dp[i] = min(dp[i-a[j]]+1,dp[i]);
		}
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll p = 1e9 + 7;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

int n, x, t;
void run(){
    cin >> n >> x >> t;
    DEBUG((n + x - 1) / x * t);
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include<stdlib.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	char s, sum = 0;
	FOR(i,0,3) {
		scanf("%c",&s);
		if(atoi(&s)) sum++;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
struct P {
	int x, y;//??????
};
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int minx = 0, maxx = 1;
		int miny = 0, maxy = 1;
		map<int, P>a;
		a.insert(map<int, P>::value_type(0, P{ 0,0 }));
		for (int z = 1; z < n; z++) {
			int m, d;
			cin >> m >> d;
			P t = a[m];
			if (d == 0) {
				t.x--;
				minx = min(t.x, minx);
			}
			else if (d == 1) {
				t.y++;
				maxy = max(t.y + 1, maxy);
			}
			else if (d == 2) {
				t.x++;
				maxx = max(t.x + 1, maxx);
			}
			else {
				t.y--;
				miny = min(t.y, miny);
			}
			a.insert(map<int, P>::value_type(z, t));
		}
		cout << maxx - minx << " " << maxy - miny << endl;
	}
}

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

int main(){
  	string S;
  	cin >> S;
  	if(S == "SUN"){
    	cout << 7 << endl;
    }else if(S == "MON"){
    	cout << 6 << endl;
    }else if(S == "TUE"){
    	cout << 5 << endl;
    }else if(S == "WED"){
    	cout << 4 << endl;
    }else if(S == "THU"){
    	cout << 3 << endl;
    }else if(S == "FRI"){
    	cout << 2 << endl;
    }else if(S == "SAT"){
    	cout << 1 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
import sys
 
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]+[0] #jがはみ出ないように最後に付け足しておく
MOD=7+10**9 #%MODを忘れない

dp=[1]+[0]*n

j=0
#iにのぼることができるかを考える
for i in range(1,n+1):
  if i==a[j]:
    j+=1
  elif i>1:
    dp[i] = (dp[i-1] + dp[i-2])%MOD #-1,-2からの遷移を考える
  else:
    if i!=a[0]:
      dp[i] = dp[i-1]
print((dp[-1])%MOD)

Measured memory_bytes: 8552
#133_C
l,r=map(int,input().split())

if r//2019>l//2019: print(0)
else:
    r%=2019
    l%=2019
    ans=2019
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans=min(ans,(i*j)%2019)
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

int main(int argc, char const *argv[]) {
    int N;
    cin>>N;
    vector<int> a(N);
    REP(i,N) cin>>a[i];

    int ans=INF;
    for(int i=-100; i<=100; i++) {
        int t=0;
        REP(j,N) {
            t+=(i-a[j])*(i-a[j]);
        }
        ans=min(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int64 n; cin >> n;
		vector<int64> a(n);
		rep (i, n) {
			cin >> a[i];
		}
		int64 ans = 0;
		for (int64 i = 0; i < 60; ++i) {
			int64 cnt = 0;
			rep (j, n) {
				cnt += (a[j] >> i & 1);
			}
			int64 num = cnt * (n - cnt);
			for (int64 j = 0; j < i; ++j) {
				num = (num * 2) % MOD;
			}
			ans += (num % MOD);
		}
		cout << ans % MOD << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 2560
n,m = map(int,input().split())
lis =[0 for i in range(1,n+1)]
ac = 0
wa = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    if lis[p-1] != -1:
        if s == "AC":
            wa += lis[p-1]
            ac += 1
            lis[p-1] = -1
        else:
            lis[p-1] += 1
print(ac,wa)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll d;
ll m, ans;

int main()
{
	cin >> m >> d;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 20; j <= d; j++)
		{
			if (j % 10 >= 2 && (j / 10) * (j % 10) == i)
			{
				ans++;
			}
		}
	}

	cout << ans << endl;

	int www;
	cin >> www;
}


Measured memory_bytes: 256
program em
implicit none
integer::N,M
integer::i
read*,N,M
do i=1,M
select case(mod(i,2))
case(0)
  print"(i0,A,i0)",M/2+1-i/2," ",M/2+1+i/2
case(1)
  print"(i0,A,i0)",(3*M)/2+1-i/2," ",(3*M)/2+2+i/2
end select
end do
contains
end program em

Measured memory_bytes: 2924
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const double PI = 3.14159265358979323846264338327950288;

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

ll lcm(ll a, ll b)
{
	return a * (b / gcd(a, b));
}

int main()
{
	int N;
	ll A;
	cin >> N >> A;
	ll ans = A;
	for (int i = 1; i < N; i++) {
		cin >> A;
		ans = lcm(ans, A);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
         r %= 1000000007;
         rr %= 1000000007;
    }
    r /= rr;
     r %= 1000000007;
    return r;
}
#define rep(a,b,c) for(ll a = b; a < c; ++i)
ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[101010];
void init() {
    f[0] = 1;
    rep(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
}
//---------------------------------------------------------------------------------------------------
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = f[n-k]; // = (n-k)!
    ll c = f[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * inv(bc)) % mod;
}
ll pow2_(ll n){
  
  ll div = 1000000007ll;
  ll ans = 0,k=2;
  {
    bitset<48> b(n);
    FOR(i,32){
      ans+=b[i]*k%div;
      ans%=div;
      k*=k;
      k%=div;
    }
  }
  return ans;
}
int main(){
  string S;
  cin>>S;
  putYN(S[2]==S[3]&&S[4]==S[5]);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

signed main()
{
  char c[5][10];
  for ( int i = 1; i <= 2; ++i ) {
    for ( int j = 1; j <= 3; ++j ) {
      scanf(" %c", &c[i][j]);
    }
  }

  char tmp;
  tmp = c[1][1];
  c[1][1] = c[1][3];
  c[1][3] = tmp;

  if( c[1][1] == c[2][1] && c[1][2] == c[2][2] && c[1][3] == c[2][3] ){
    puts("YES");
  }

  else puts("NO");

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int  x,i,j,t;
  x = A[r];
  i = p-1;
  for (j=p; j<r;j++ ){
  if(A[j] <= x){
    i++;
    t = A[i]; A[i] =A[j]; A[j]=t; 
     }
    }
   t=A[i+1];A[i+1]=A[r];A[r]=t;
   return i+1;
}
int main(){

   
   int i,q;
   scanf("%d",&n);
  

   for(i=0; i < n; i++){
   scanf("%d",&A[i]);
   }
 
   q = partition(0,n-1);
    
   for(i=0; i < n; i++){
   if(i) printf(" ");
   if(i == q)printf("[");
   printf("%d",A[i]);
   if(i == q)printf("]");
   }
   printf("\n");
   return 0;
  }




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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int loop = (1 << N);
    ll A[N]; rep(i, N) cin >> A[i];
    ll B[N];
    ll mxA[N+1] = {}; //mx[i]: A[0]~A[i-1]までのmax.ただしmx[0]=0
    rep(i, N) mxA[i+1] = max(mxA[i], A[i]);
    ll mxB[N+1];
    ll ans = LLINF;
    rep(i, loop){
        rep(j, N) B[j] = A[j];
        rep(j, N+1) mxB[j] = mxA[j]; 
        bitset<15> bs;
        int val = i;
        rep(j, N){
            if(val%2) bs.set(j);
            val/=2;
        }
        if(bs.count() == K){
            ll res = 0;
            ll prev = 0;
            for(int j = 0; j <= N-1; j++){
                if(bs[j]){
                    //A[j]をA[0]-A[j-1]より大きくする
                    if(B[j] <= mxB[j]){
                        res += mxB[j]-B[j]+1;
                        B[j] = mxB[j]+1;
                        for(int k = j+1; k <= N; k++) mxB[k] = max(mxB[k],B[j]);
                    }
                }
            }
            //cout << i << ": " << res << endl;
            ans = min(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
#define INF (1<<30)
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

ll N;

int main() {
        int ans = INF;
        scanf("%lld", &N);
        for(ll i = 1LL; i < sqrt(N) + 1; ++i) {
                if(N % i == 0) {
                        string s1 = to_string(i);
                        string s2 = to_string(N / i);
                        int tmp = max(s1.size(), s2.size());
                        ans = min(ans, tmp);
                }
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = 2147483647;

int main() {
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;

    // cout << a << endl;
    // cout << b << endl;

    int mn = size(a) + size(b);
    for (int k = size(a); k >= 0; k--) {
        // bool ok = true;
        // rep(i,0,size(b)) {
        //     if (k+i < size(a) && a[k+i] != b[i]) {
        //         ok = false;
        //         break;
        //     }
        // }
        // cout << a.substr(k) << " " << b.substr(0,size(a)-k) << endl;
        if (a.substr(k) == b.substr(0,size(a)-k)) {
            // cout << k << endl;
            // cout << k << " " << size(a)+size(b) << endl;
            mn = min(mn, k + size(b));
        }
    }
    cout << mn << endl;

    return 0;
}



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

int main() {
  int A, B, count;
  cin >> A >> B;
  string S;
  for (int i = A; i < B+1; i++) {
    S = to_string(i);

    if (S.at(0) == S.at(4)) {
      if (S.at(1) == S.at(3)) {
        count++;
      }
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long diff = b - a;
  for(int i = 0; i < n; ++i) {
  	long long l = -i * d + (n - i - 1) * c;
  	long long r = -i * c + (n - i - 1) * d;
  	// cout << l << ' ' << r << endl;
  	if(l <= diff && diff <= r) {
  		puts("YES");
  		return 0;
  	}
  }
  puts("NO");
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input1 = readLine()!!
    val len = input1.toInt()
    val input2 = readLine()!!.split(" ")
    val s = input2[0]
    val t = input2[1]

    println(s.zip(t)
        .map { "${it.first}${it.second}" }
        .joinToString(""))
}

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

using namespace std;

int main(void) {
	int num, c, i, j, k, l, aa, bb, cc, ans = 1e9;
	cin >> num >> c;
	vector<vector<int>> cost(c, vector<int>(c)), d(3, vector<int>(c, 0));
	for (i = 0; i < c; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &cost[i][j]);
		}
	}
	for (i = 1; i <= num; i++) {
		for (j = 1; j <= num; j++) {
			scanf("%d", &aa);
			d[(i + j) % 3][aa - 1]++;
		}
	}
	for (i = 0; i < c; i++) {
		for (aa = 0, l = 0; l < c; l++)
			aa += d[0][l] * cost[l][i];
		for (j = 0; j < c; j++) {
			if (i == j)
				continue;
			for (bb = 0, l = 0; l < c; l++)
				bb += d[1][l] * cost[l][j];
			for (k = 0; k < c; k++) {
				if (i != k && j != k) {
					for (cc = 0, l = 0; l < c; l++)
						cc += d[2][l] * cost[l][k];
					ans = min(ans, aa + bb + cc);
				}
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	string str;
	cin >> str;
	int len = SZ(str);
	int a=-1,b=-1;
	rep(i,0,len-1) {
		if(str[i]==str[i+1]) a=i+1, b=i+2;
		else if(i+2<len && str[i]==str[i+2]) a=i+1, b=i+3;
		if(a!=-1) break;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
 
#define MAX 24414070
 
void insert(char []);
int find(char []);
int getNum(char []);
 
int hash[MAX];
 
int main(){
  int i, n;
  char str[15], cmd[10];
   
  for(i=0; i<MAX; i++) hash[i] = 0;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s%s", cmd, str);
    if(cmd[0] == 'i') insert(str);
    else printf(find(str)?"yes\n":"no\n");
  }
   
  return 0;
}
 
void insert(char str[]){
  int num;
  num = getNum(str);
  hash[num] = 1;
}
 
int find(char str[]){
  int num;
  num = getNum(str);
  if(hash[num] == 1) return 1;
  return 0;
}
 
int getNum(char str[]){
  int i, sum = 0, code, x = 1;
  for(i=0; i<strlen(str); i++){
    switch(str[i]){
    case 'A':
      code = 1;
      break;
    case 'C':
      code = 2;
      break;
    case 'G':
      code = 3;
      break;
    case 'T':
      code = 4;
      break;
    }
    sum += code * x;
    x *= 5;
  }
  return sum;
}



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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
vector<int> c[400];
ll ans = 0;

vector<int> rotate(vector<int> vec) {
    vector<int> tmp[4];
    rep(i,4) tmp[i].resize(4);
    tmp[0] = vec;
    for (int j = 1; j < 4; j++) {
        rep(k,4) tmp[j][k] = tmp[j-1][(k+3)%4];
    }
    sort(tmp, tmp+4);
    return tmp[0];
}

int main() {
    cin >> n;
    rep(i,n) {
        vector<int> tmp;
        tmp.resize(4);
        rep(j,4) cin >> tmp[j];
        c[i] = rotate(tmp);
    }
    sort(c, c+n);
    rep(i,n) for (int j = i+1; j < n; j++) {
        rep(k,4) {
            vector<int> e[4];
            rep(l,4) e[l].resize(4);
            e[0][0] = c[i][0]; e[0][1] = c[i][1]; e[0][2] = c[j][k]; e[0][3] = c[j][(k+1)%4];
            e[1][0] = c[i][1]; e[1][1] = c[i][2]; e[1][2] = c[j][(k+3)%4]; e[1][3] = c[j][k];
            e[2][0] = c[i][2]; e[2][1] = c[i][3]; e[2][2] = c[j][(k+2)%4]; e[2][3] = c[j][(k+3)%4];
            e[3][0] = c[i][3]; e[3][1] = c[i][0]; e[3][2] = c[j][(k+1)%4]; e[3][3] = c[j][(k+2)%4];
            rep(l,4) reverse(e[l].begin(), e[l].end());
            rep(l,4) e[l] = rotate(e[l]);
            sort(e, e+4);
            ll cnt[4];
            rep(l,4) cnt[l] = upper_bound(c, c+n, e[l]) - lower_bound(c, c+n, e[l]);
            rep(l,4) cnt[l] -= (int)(c[i]==e[l])+(int)(c[j]==e[l]);
            bool ok = true;
            rep(l,4) if (cnt[l] <= 0) ok = false;
            if (!ok) continue;
            ll add = 1;
            rep(l,4) {
                if (l >= 3 && e[l] == e[l-1] && e[l] == e[l-2] && e[l] == e[l-3]) {
                    add *= cnt[l]-3;
                } else if (l >= 2 && e[l] == e[l-1] && e[l] == e[l-2]) {
                    add *= cnt[l]-2;
                } else if (l >= 1 && e[l] == e[l-1]) {
                    add *= cnt[l]-1;
                } else {
                    add *= cnt[l];
                }
                if (e[l][0] == e[l][1] && e[l][1] == e[l][2] && e[l][2] == e[l][3]) {
                    add *= 4;
                } else if (e[l][0] == e[l][2] && e[l][1] == e[l][3]) {
                    add *= 2;
                }
            }
            ans += add;
        }
    }
    cout << ans/3 << endl;
}
































Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] SW = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		if(SW[0] <= SW[1]) {
			System.out.print("un");
		}
		System.out.println("safe");
	}
}


Measured memory_bytes: 32628
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)


# # # # class Segtree # # # #

#      0
#   1     2
# 3   4  5  6
#       :
# leaf i - n-1+i
# parent   - (i-1)//2
# children - 2*i+1, 2*i+2

class Segtree:
    # modify UNIT and oper depending on the reduce operation

    #UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 ..

    #@classmethod
    #def oper(c,x,y):
    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same)

    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y))

    def __init__(s,l,unit,oper):
        s.unit = unit
        s.oper = oper
        s.n = 1
        while s.n<l:
            s.n *= 2
        s.ary = [s.unit for i in range(2*s.n-1)]

    def get(s,i):
        return s.ary[i+s.n-1]

    def set(s,i,v):
        k = i+s.n-1
        s.ary[k] = v
        while k>0:
            k = (k-1)//2
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def setary(s,a):
        for i,v in enumerate(a):
            s.ary[i+s.n-1] = v
        for k in range(s.n-2,-1,-1):
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def query(s,x,y):
        l = x+s.n-1
        r = y+s.n-1
        res = s.unit
        while l<r:
            if not l%2:
                res = s.oper(res,s.ary[l])
                l += 1
            if not r%2:
                r -= 1
                res = s.oper(res,s.ary[r])
            l >>= 1
            r >>= 1
        return res


# # # # class Segtree end # # # #
import heapq
n = inn()
a = inl()

lmax = a[:n]
lsum = sum(lmax)
heapq.heapify(lmax)

r = a[n:]
r = [(r[i],i) for i in range(2*n)]
r.sort()
rsum = sum([x[0] for x in r[:n]])
rmax = [BIG]*(2*n)
h = {}
for v,i in r[n:]:
    if v not in h:
        h[v] = []
    h[v].append(i)
    rmax[i] = v
sgt = Segtree(2*n,BIG,lambda x,y: min(x,y))
sgt.setary(rmax)

if False:
    ddprint(a)
    #ddprint(f"{n=} {lsum=} {rsum=}")
    ddprint(lmax)
    ddprint(rmax)
    ddprint(h)

mx = lsum - rsum
for i in range(n):
    v = a[n+i]
    v2 = heapq.heappushpop(lmax,v)
    lsum += v-v2
    if sgt.get(i)==BIG:
        vnew = sgt.query(i+1,2*n)
        rsum += vnew-v
        suf = h[vnew].pop()
        sgt.set(suf,BIG)
        #ddprint(f"{i=} {v=} {v2=} {vnew=} {suf=} {lsum=} {rsum=}")
    mx = max(mx,lsum-rsum)

print(mx)


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void printArray(const int *arr, int n);
void printArray(const vector<int> &arr);

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
int a[200];
int c[200];

int main(){
	scanf("%d", &n);
	int sum = n * (n+1) / 2;
	for(int i=2; sum / i >= n;++i){
		if(sum % i) continue;
		memset(c, 0, sizeof c);
		int tmp;
		bool bisa = false;
		std::vector<std::vector<int>> v;
		for(int j=0;j<i;++j){
			std::vector<int> wew;
			tmp = sum / i;
			for(int k=n;k>0 && tmp > 0;--k){
				if(!c[k] && k<=tmp){
					tmp -= k;
					c[k] = 1;
					wew.pb(k);
				}
			}
			reverse(wew.begin(), wew.end());
			v.pb(wew);
			bisa |= tmp > 0;
		}
		if(!bisa){
			set<pii> s;
			std::vector<std::vector<int>> adj;
			for(const std::vector<int> &w : v){
				std::vector<int> wew;
				for(int i=1, j=0;i<=n;){
					if(w[j] == i){
						++i, ++j;
					}
					else if(w[j] < i){
						++j;
					}
					else{
						wew.pb(i);
						++i;
					}
				}
				adj.pb(wew);
			}
			for(int i=0;i<adj.size();++i){
				for(int x : adj[i]){
					for(int y : v[i]){
						if(x < y)
							s.insert({x, y});
						else
							s.insert({y, x});
					}
				}
			}
			printf("%d\n", (int) s.size());
			for(const pii &x : s){
				printf("%d %d\n", x.fi, x.se);
			}
			break;
		}
	}
	return 0;
}

/* Template Function */
void printArray(int * a, int n){
	for(int i=0;i<n;++i){
		printf("%d ", a[i]);
	}
	puts("");
}

void printArray(const vector<int> &arr){
	for(int x : arr){
		printf("%d ", x);
	}
	puts("");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int A,B;
    cin >> A >>B;
    string S;
    cin >> S;
    bool w=true;
    if(A+B+1!=S.size()){
        w=false;
    }else{
        rep(i,S.size()){
            if(i==A){
                if(S[i]!='-'){
                    w=false;
                    break;
                }
            }else if(S[i]<'0' || S[i]>'9'){
                w=false;
                break;
            }
        }
    }
    cout << (w ? "Yes":"No") << endl;
    return 0;
}


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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll unsigned long long 
 
using namespace std;

 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int d;
	cin>>d;
	if(d==25)
	cout<<"Christmas";
	else if(d==24)
	cout<<"Christmas Eve";
	else if(d==23)
	cout<<"Christmas Eve Eve";
	else 
     cout<<"Christmas Eve Eve Eve";
	return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
#include<stdlib.h>

 struct node{
   struct node *right;
   struct node *left;
   struct node *parent;
   int key;
};

typedef struct node * Node;

Node root = NULL;

void insert(int k)
{
  Node x = root;
  Node y = NULL;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL)
    {
      y = x;
      
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else x = x->right;
    }

  z->parent = y;

  if(y == NULL)root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;

  return;
}

void inorder(Node x)
{
  if(x != NULL)
    {
      inorder(x->left);
      printf(" %d", x->key);
      inorder(x->right);
    }
  return;
}

void preorder(Node x)
{
  if(x == NULL)return;

  printf(" %d", x->key);
  preorder(x->left);
  preorder(x->right);

  return;
}

int main()
{
  int i;
  int m, k;
  char com[10];

  scanf("%d", &m);

  for(i = 0; i < m; i++)
    {
      scanf("%s", com);
      
      if(com[0] == 'i')
	{
	  scanf("%d", &k);
	  insert(k);
	}
      if(com[0] == 'p')
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}     
    }
  
  return 0;
}



Measured memory_bytes: 25144
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	while (true){
		int n, m;
		cin >> m >> n;
		vector<vector<tuple<int, int, int>>> inputs;
		REP(i, m) {
			int a;
			cin >> a;
			vector<tuple<int, int, int>> e;
			REP(q, a) {
				int b;
				string c;
				int d;
				cin >> b >> c >> d;
				b--;
				if (c == ">=") {
					e.push_back(make_tuple(b, d, 0LL));
				}
				else {
					e.push_back(make_tuple(b, d, 1LL));
				}
			}
			inputs.push_back(e);
		}
		int erased = 1;
		while (erased) {
			erased = 0;
			vector<int> cnt(n, 100000);
			REP(q, inputs.size()) {
				REP(t, inputs[q].size()) {
					if (get<2>(inputs[q][t]) == 1) {
						cnt[get<0>(inputs[q][t])] = min(cnt[get<0>(inputs[q][t])], get<1>(inputs[q][t]));
					}
				}
			}

			REP(q, inputs.size()) {
				int ok = 1;
				REP(j, inputs[q].size()) {
					if (get<2>(inputs[q][j]) == 0) {
						if (cnt[get<0>(inputs[q][j])] < get<1>(inputs[q][j])) {
							ok = 0;
						}
					}
				}
				if (ok == 1) {
					erased = 1;
					inputs.erase(inputs.begin() + q);
					q--;
				}
			}
		}
		if (inputs.empty() == true) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return;
	}
}

#undef int

int main() {
	init();
	solve();
}


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

#define int long long

string s;
int calc(int p, int q){
    int ans = 0;
    int mult = 1;
    for(int i = 0; i < q-p; i++)
        mult *= 10;
    for(int i = p; i <= q; i++){
        ans += (s[i]-'0')*mult;
        mult /= 10;
    }
    return ans;
}

void solve(){
    cin >> s;
    long long sum = 0;
    for(int i = 0; i < (1 << (s.size()-1)); i++){
        int q = 0, p = 0;
        long long round = 0;
        for(int j = 0; j < s.size()-1; j++){
            if(i & (1 << j)){
                round += calc(p, q);
                p = q+1;
                q++;
            }
            else{
                q++;
            }
        }
        round += calc(p, q);
        sum += round;
    }
    cout << sum << "\n";
}

#undef int

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
   // multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






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

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

def main():
    mod=10**9+7
    N=I()
    a=LI()
    
    ans=10**10
    for t in range(-100,101,1):
        temp=0
        for i in range(N):
            temp+=(t-a[i])**2
        ans=min(ans,temp)
        
    print(ans)

main()


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

int main() {
    int X;
    cin >> X;
    if (X>=1800) {
        cout << "1" << endl;
    } else if (X>=1600) {
        cout << "2" << endl;
    } else if (X>=1400) {
        cout << "3" << endl;
    } else if (X>=1200) {
        cout << "4" << endl;
    } else if (X>=1000) {
        cout << "5" << endl;
    } else if (X>=800) {
        cout << "6" << endl;
    } else if (X>=600) {
        cout << "7" << endl;
    } else {
        cout << "8" << endl;
    }
    return 0;
}



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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n){
        if(i % 2 == 0){
            if(a[i] % 2 != 0) ans++;
        }
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    //vector<int> a(100005);
  	vector<int> a(200005);
    REP(i, n) cin >> a[i];
    //vector<int> b(100005, 0);
  	vector<int> b(200005, 0);
    REP(_, min(k, 42)){
        vector<int> b(200005, 0);
        REP(i, n){
            int l = max(0, (int)i-a[i]);
            int r = min(n-1, (int)i+a[i]);
            b[l] += 1;
            b[r+1] -= 1;
        }
        REP(i, n-1) b[i+1] += b[i];
        REP(i, n) a[i] = b[i];
    }
    REP(i, n) cout << a[i] << " ";
}


Measured memory_bytes: 5788