akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
  ll n, res = 5, x[5], mi=1000000000000001;
  
  cin >> n;
  for(int i = 0; i < 5; i++){
    cin >> x[i];
    mi = min(mi, x[i]);
  }

  if(mi >= n){
  }else{
    n -= mi;
    res += ceil(n/(double)mi);
  }
  cout << res << endl;
}

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

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

vector<int> seive(int n){
  vector<bool> is_prime(n + 10, true);
  vector<int> res;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if(is_prime[i])res.push_back(i);
    for (int j = 2*i; j <= n; j+=i) is_prime[j] = false;
  }
  return res;
}

int main(){
  int n, m;
  vector<int> prime = seive(5e5 + 10);
  while(std::cin >> n >> m, n != -1 or m != -1){
    int a = upper_bound(prime.begin(), prime.end(), n) - prime.begin();
    multiset<int> ans;
    for (int i = 0; i < 108; i++) {
      for (int j = i; j < 108; j++) {
        ans.insert(prime[a + i] + prime[a + j]);
      }
    }
    auto x = ans.begin();
    for (int i = 0; i < m - 1; i++, x++);
    std::cout << *x << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3380
n=int(input())
X=list(map(int,input().split()))
S=list(sorted(X))
L=S[n//2-1]
R=S[n//2]
if L==R:
    for i in range(n):
        print(L)
else:
    for x in X:
        if x<=L:
            print(R)
        else:
            print(L)

Measured memory_bytes: 26772
N = gets.chomp.to_i
P = gets.chomp.split(" ").map(&:to_i)

min_list = []
min = Float::INFINITY
P.each do |n|
  min = [n, min].min
  min_list << min
end

cnt = 0
P.each.with_index do |n,i|
  cnt += 1 if P[i] <= min_list[i]
end

puts cnt

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n,m,a[2002],b[2002];

struct item{
ll wt,val;};
ll solve(vector<item>v,ll n,ll W){
   ll dp[n+1][W+1];
   for(int w=0;w<=W;w++){
    dp[1][w]=0;
   }
   dp[1][v[1].wt]=v[1].val;
   for(int i=2;i<=n;i++){
    for(int w=0;w<=W;w++){
        dp[i][w]=dp[i-1][w];
        if(v[i].wt>w)continue;
        dp[i][w]=max(dp[i][w],v[i].val+dp[i-1][w-v[i].wt]);
    }
   }
   return *max_element(dp[n],dp[n]+W+1);
}

int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ans,ck,k,p,q,r,t,add=0,w,x,y,z;
    cin>>n>>w;
    vector<item>v(n+1);

    for(int i=1;i<=n;i++){cin>>v[i].wt;cin>>v[i].val;}
    ck=solve(v,n,w);
    cout<<ck<<endl;





    return 0;
}



Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;  
  cin >> N;
  set<int> memo;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (memo.count(A)) {
      memo.erase(A);
    }
    else {
      memo.insert(A);
    }
  }
  cout << memo.size() << endl;
}

Measured memory_bytes: 8296
/* ええ加減、これもACしたい */
#include <stdio.h>

#define N 1000000
#define M 1000

int main(){
  int a,b,c;
  int tbl[N];
  for(a=1;a<N;a++) tbl[a]=-1;
  for(a=2;a<=M;a++) if(tbl[a]) for(b=2;a*b<=N;b++) tbl[a*b]=0;

  while(scanf("%d",&a)!=EOF){
    b=0;
    for(c=2;c<=a;c++) b-=tbl[c];
    printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 0
let i = readInts()
print(i[0] * i[1])


// MARK: -----------------------------------------------------------------------


func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    subscript(gen: Index) -> Element {
        _modify { yield &self[index(gen, offsetBy: -1)] }
        _read   { yield self[index(gen, offsetBy: -1)] }
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


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

using ll=long long;
using vi=vector<ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=k;i<(ll)(n);i++)
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}

int main(){
  int n,m; cin>>n>>m;
  vi a(n),b(m);
  rep(i,n) cin>>a[i];
  rep(i,m) cin>>b[i];
  vi c=convolution(a,b);
  outv(c);
}


Measured memory_bytes: 35436
#include <iostream>

void insertionSort(int * A, int N) {
    for(int i=1; i<N; i++) {
        std::cout << A[0];
        for(int k=1; k < N; k++) {
            std::cout <<  " " << A[k];
        }
        std::cout << std::endl;
        int v = A[i];
        int j = i-1;
        while (j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
    }
}

int main() {
    int num;
    std::cin >> num;
    int *arr = new int(num);
    for (int k=0; k< num; k++) {
        std::cin >> arr[k];
    }
    insertionSort(arr, num);
    std::cout << arr[0];
    for(int i=1; i < num; i++) {
        std::cout << " " << arr[i];
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
int L = 1000000007;
using namespace std;
string s[60] = {};
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	string ans;
	for (char c = 'a'; c <= 'z'; c++)
	{
		int small = 100;

		for (int i = 0; i < n; i++)
		{
			int cnt = 0;
			for (int j = 0; j < s[i].length(); j++)
			{
				if (s[i][j] == c)cnt++;
				
			}
			small = min(small, cnt);
		}
		for (int i = 0; i < small; i++)
		{
			ans += c;
		}
		
	}
	cout << ans << endl;
	
	return 0;
}

int dsum(ll a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int pow(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int dfs(vector<int> A,int &cnt){
  if(A.size() == 1 && A.at(0) == 1){
    return cnt + 1;
  }
  cnt += (A.at(0)-1)*pow(A.size()-1);
  vector<int> B(A.size()-1);
  REP(i,A.size()-1){
    if(A.at(i+1) > A.at(0)){
      B.at(i) = A.at(i+1) - 1;
    }else{
      B.at(i) = A.at(i+1);
    }
  }
  dfs(B,cnt);
  return cnt;
}

int main()
{
  int N;
  cin >> N;
  vector<int> P(N);
  REP(i, N) cin >> P[i];
  vector<int> Q(N);
  REP(i, N) cin >> Q[i];
  
  int cnt = 0;
  int p = dfs(P,cnt);
  cnt = 0;
  int q = dfs(Q,cnt);

  cout << max(p-q,q-p) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double rangea(double p,double q,double r){
  if(q*r<0&&fabs(q)+fabs(r)>M_PI){
    p+=2*M_PI*(p<0);
    q+=2*M_PI*(q<0);
    r+=2*M_PI*(r<0);
  }
  return range(p,q,r);
}
int range(double p,double q,double r){
  return (q<r?q:r)<p&&p<(q<r?r:q);
}
int main(){
  double x0,x1,x2,y0,y1,y2,xp,yp;
  while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2,&xp,&yp)!=-1){
    if(rangea(atan2(y0-yp,x0-xp),atan2(y0-y1,x0-x1),atan2(y0-y2,x0-x2))){
      if(rangea(atan2(y1-yp,x1-xp),atan2(y1-y0,x1-x0),atan2(y1-y2,x1-x2))){
	puts("YES");
	continue;
      }
    }
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int n;
    int d;
    int x;
    int a[100] = {};
    int sum = 0;

    cin >> n >> d >> x;

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

    for(int i = 0; i < n; i++)
    {
        int j = 0;
        while(j * a[i] + 1 <= d)
        {
            sum++;
            j++;
        }
    }
    sum += x;
    cout << sum << endl;

    return 0;
}


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

int main(void) {
	int N;
	scanf("%d", &N);
	string S;
	cin >> S;
	map<char, int> right, left;
	for (int i = 0; i < S.size(); i++) {
		right[S[i]]++;
	}
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		left[S[i]]++;
		right[S[i]]--;
		int cnt = 0;
		for (auto itr = left.begin(); itr != left.end(); itr++) {
			if (itr->second > 0 && right[itr->first] > 0) cnt++;
		}
		ans = max(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3760
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = 0;
            for(int i = 1; i <= n; i++)
            {
                if (Keta(i) % 2 == 1) ans++;
            }
            Console.WriteLine(ans);
        }
        static public int Keta(int i)
        {
            int cnt =0;
            while (i != 0)
            {
                i /= 10;
                cnt++;
            }
            return cnt;
        } 
    }
}


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

using namespace std;
typedef long long int l;
#define mod 1000000007
#define t1 l t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define vl vector<l>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

int main() {
fast;
l n;
cin>>n;
l a[n];
for(l i=0;i<n;i++)
cin>>a[i];
l c=0;
sort(a,a+n);
for(l i=0;i<n-2;i++)
{
    for(l j=i+1;j<n-1;j++)
    {
        for(l k=j+1;k<n;k++)
        {if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
            if(a[i]+a[j]>a[k])
            c++;
        }
    }
}
cout<<c<<"\n";

	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define LLI long long int

const int _mx = 2e6;
int a[_mx+5];

int main() {
    // freopen("in.txt", "r", stdin);

    int n, q, x, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    for (cin >> q; q--; ) {
        cin >> x;
        int pos = lower_bound(a, a+n, x) - a;
        if (a[pos] == x) ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3508
//#include <iostream>
//#using namespace std;
 
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    string st;
    cin >> st;
    int ans = 0;
    if(st == "SUN") ans = 7;
    if(st == "MON") ans = 6;
    if(st == "TUE") ans = 5;
    if(st == "WED") ans = 4;
    if(st == "THU") ans = 3;
    if(st == "FRI") ans = 2;
    if(st == "SAT") ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		Main soln = new Main();
		System.out.println((soln.jd(m,n))? "Yes":"No");
	}

	private boolean jd(int m, int n) {
		if(m==2 || n==2) return false;
		return (grp(m)*grp(n)>0)? true:false;
	}

	private int grp(int k) {
		if(k==4 || k==6 || k==9 || k==11) return 1;
		else return -1;
	}
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    


	int n;
	cin>>n;

	if(n%1000){
		int div = n/1000;
		div++;
		cout<<(div)*1000 - n;
	}
	else{
		cout<<"0";
	}
    
    
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int main(){
  int A, B, sum, minus, multi, ans;
  
  cin >> A >> B;
  
  sum = A + B;
  minus = A - B;
  multi = A * B;
  
  ans = max(sum, minus);
  ans = max(ans, multi);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A = [100000] + A + [0]


A_compress = []
val = 0
for a in A:
    if val != a:
        A_compress.append(a)
        val = a
#print(A_compress)

A = A_compress
status = [None] * (len(A))
#up down top bottom flat


for i in range(1, len(A_compress) - 1):
    if A[i-1] < A[i] and A[i] < A[i+1]:
        status[i] = "up"
    elif A[i-1] < A[i] and A[i] > A[i+1]:
        status[i] = "top"
    elif A[i-1] > A[i] and A[i] < A[i+1]:
        status[i] = "bottom"
    elif A[i-1] > A[i] and A[i] > A[i+1]:
        status[i] = "down"
#print(status)

money = 1000
kabu = 0
for a, s in zip(A, status):
    if s == "bottom":
        kabu += money // a
        money %= a
    if s == "top":
        money += a * kabu
        kabu = 0
print(money)

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

int main()
{
    int n,m;
    int sum=700;
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
        if(s[i]=='o') sum+=100;
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D, S, T;
    cin >> D >> S >> T;
    if (S * T >= D)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
	int n,x,r=1<<29;
	for(scanf("%d",&n);n--;){
		int r0=0;
		scanf("%d",&x);
		for(;x%2<1;x/=2)r0++;
		if(r>r0)r=r0;
	}
	printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define nl "\n"
ll n;
ll a[3002];
ll dp[3002][3002][2];
ll f(ll l,ll r,ll turn)
{
	if(l>r || l+1==n || r<0)
		return 0;
	if(dp[l][r][turn] == -1)
	{
		if(turn == 0)
			dp[l][r][turn] = max(a[l]+f(l+1,r,1),a[r]+f(l,r-1,1));
		else
			dp[l][r][turn] = min(f(l+1,r,0)-a[l],f(l,r-1,0)-a[r]);
	}
	return dp[l][r][turn];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	ll i,j,k;
	ll ans=0;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<3002;i++)
		for(j=0;j<3002;j++)
			for(k=0;k<2;k++)
				dp[i][j][k]=-1;
	f(0,n-1,0);
	if(n==1)
		cout<<a[0]<<nl;
	else
		cout<<dp[0][n-1][0]<<nl;
	return 0;
}

Measured memory_bytes: 141312
#include<iostream>
#include<string>
using namespace std;
string S;
int N;
int K;
int main(){
  cin >> N >> K;
  cin >> S;
  if (S[K-1] == 'A'){
    S[K-1] = 'a';
  }
  else if (S[K-1] == 'B'){
    S[K-1] = 'b';
  }
  else {
    S[K-1] = 'c';
  }
  cout << S << endl;
  return 0;
} 

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int main(void)
{
	//変数の宣言
	int h,w,a,b;
	static int dp[510][510];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;



	//データの読み込み


	scanf("%d %d %d %d",&h,&w,&a,&b);
//	scanf_s("%d %d %d %d",&h,&w,&a,&b);

/*	for(i=0;i<n;i++){
//		scanf("%d",&a);
		scanf_s("%d",&a);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	if(h%a==0&&w%b==0){
		printf("No");
		return 0;
	}

	if(h%a!=0){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i%a<h%a){
					dp[i][j]=300000/(h%a);
				}else{
					dp[i][j]=-300500/(a-h%a);
				}
			}
		}
	}else{
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(j%b<w%b){
					dp[i][j]=300000/(w%b);
				}else{
					dp[i][j]=-300500/(b-w%b);
				}
			}
		}
	}

	//	printf("計算部分終了\n");

	//出力

	printf("Yes\n");

	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(j!=0)printf(" ");
			printf("%d",dp[i][j]);
		}
		printf("\n");
	}

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    char c; cin >> c;
    cout << char(c + 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define A 0
#define B 1
#define C 2
#define P 3
#define N 4

int main(void) {
	double x[N], y[N];
	double s, t;
	while(scanf("%lf", &x[A]) != EOF) {
		scanf("%lf", &y[A]);
		scanf("%lf", &x[B]);
		scanf("%lf", &y[B]);
		scanf("%lf", &x[C]);
		scanf("%lf", &y[C]);
		scanf("%lf", &x[P]);
		scanf("%lf", &y[P]);
		x[B] -= x[A];
		y[B] -= y[A];
		x[C] -= x[A];
		y[C] -= y[A];
		x[P] -= x[A];
		y[P] -= y[A];
		s = (y[C]*x[P]-x[C]*y[P])/(x[B]*y[C]-y[B]*x[C]);
		t = (x[B]*y[P]-y[B]*x[P])/(x[B]*y[C]-y[B]*x[C]);
		if( (s > 0.0) && (t > 0.0) && (s+t < 1.0) ) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}

	return 0;
}

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

int solve(vector<int>&a){
  map<int,int>kazu;
  for(int i=0;i<a.size();i++){
    kazu[a.at(i)]++;
    kazu[a.at(i)-1]++;
    kazu[a.at(i)+1]++;
  }
  int ans=0;
  for(auto i:kazu){
    ans=max(ans,i.second);
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  cout << solve(a) << endl;
  return 0;
}

Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >>N;
    vector<int>vec1(N);
    for(int i=0;i<N;i++){
        cin>>vec1.at(i);
    }
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=vec1.at(i)-1;
    }
    cout <<sum<<endl;

}

Measured memory_bytes: 3636
a = []
i = 0
n = 0
calc = 0

while True:
    a.append(list(map(int, input().split())))
    if a[n][0] == -1 and a[n][1] == -1 and a[n][2] == -1:
        break
    n += 1

while i < n:
    calc = a[i][0] + a[i][1]

    if a[i][0] < 0 or a[i][1] < 0:
        print("F")
    else:
        if calc >= 80:
            print("A")
        elif calc >= 65 and calc < 80:
            print("B")
        elif calc >= 50 and calc < 65:
            print("C")
        elif calc >= 30 and calc < 50:
            if a[i][2] >= 50:
                print("C")
            else:
                print("D")
        elif calc < 30:
            print("F")
    i += 1
    



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
int main(){
	int n; cin>>n;
	int ar[100010];
	int ab[100010];
	for(int i=0;i<100010;i++){
		ar[i]=0; ab[i]=0;
	}
	
	int a;
	int odd=0,even=0,io=0,ie=0;
	int ods=0,evs=0,is=0,ies=0;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(i&1){
			ar[a]++;
			if(ar[a]>odd){
				odd=ar[a]; io=a;
			}else
			if(ar[a]>ods){
				ods=ar[a]; is=a;
			}
		}else{
			ab[a]++;
			if(ab[a]>even){
				even=ab[a]; ie=a;
			}else
			if(ab[a]>evs){
				evs=ab[a]; ies=a;
			}
		}
	}
	int ans=0;
	
	if(io==ie){
		int tmp=min(n-odd-evs,n-ods-even);
		ans=tmp;
	}else{
		//cout<<odd<<" "<<endl;
		ans=n-odd-even;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >>N;
  int M=N;
  int count=0;
  rep(i,9){
    count+=M%10;
    M/=10;
  }
  if (N%count==0){
    cout <<"Yes"<<endl;
  }
  else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        // 長さＮ
        int n = sc.nextInt();

        // 文字列Ｓ、Ｔ
        String s = sc.next();
        String t = sc.next();

        StringBuilder result = new StringBuilder();
        for (int index = 0; index < n; index++) {
            result.append(s.charAt(index));
            result.append(t.charAt(index));
        }

        // 出力
        System.out.println(result);
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int main(){
	int a=read(),p=read();
	printf("%d\n",(a*3+p)/2); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll mod=1e9+7;

int main(){
  ll i,j;
  ll k;
  string s;
  cin>>s>>k;

  string ss=s+s;

  ll l=s.size();

  if(l==1){
    cout<<k/2<<endl;
    return 0;
  }

  if(k==1){
    ll d=0;
    for(i=1;i<l;i++){
      if(s[i]==s[i-1]) {
        d++;
        i++;
      }
    }
    cout<<d<<endl;
    return 0;
  }

  if(k==2){
    ll d=0;
    for(i=1;i<2*l;i++){
      if(ss[i]==ss[i-1]) {
        d++;
        i++;
      }
    }
    cout<<d<<endl;
    return 0;
  }

  ll d=0;
  ll f=0;
  for(i=1;i<=l;i++){
    if(ss[i]==ss[i-1]) {
      d++;
      if(i==l) f=1;
      i++;
    }
  }
  string tt=ss;
  tt[0]='0';
  ll f2=0;
  ll dd=0;
  for(i=1;i<=l;i++){
    if(tt[i]==tt[i-1]) {
      dd++;
      if(i==l) f2=1;
      i++;

    }
  }


  if(f==0){
    cout<<d*k<<endl;
    return 0;
  }
  else{
    if(f2==0){
      ll ans=(d+dd)*(k/2);
      if(k%2==1) ans+=d-1;
      cout<<ans<<endl;
      return 0;
    }
    else{
      ll ans=d+dd*(k-1);
      ans--;
      cout<<ans<<endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CColoringColorfully {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            StringBuilder a = new StringBuilder(x);
            StringBuilder b = new StringBuilder(x);
            int a1 = 0;
            int a2 = 0;
            for (int i = 1; i < x.length(); i++) {
                if (a.charAt(i) == a.charAt(i - 1)) {
                    if (a.charAt(i) == '1') a.setCharAt(i, '0');
                    else a.setCharAt(i, '1');
                    a1++;
                }
            }
            for (int i = x.length() - 1; i > 0; i--) {
                if (b.charAt(i) == b.charAt(i - 1)) {
                    if (b.charAt(i - 1) == '1') b.setCharAt(i - 1, '0');
                    else b.setCharAt(i - 1, '1');
                    a2++;
                }
            }
            out.println(Math.min(a1, a2));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int h, n;

//inputします
void input() {
	cin >> h >> n;
}

//ライブラリ置き場


//main
int main() {
    input();
	i64 sum = 0;
	ff(i, 0, n) {
		int y;
		cin >> y;
		sum += y;
	}
	if (sum >= h)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdint.h>

#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int val[400000 + 1];
int count[400000 + 1];

int solve(std::vector<std::vector<int>> &list, int w, int k) {
  std::vector<int> current = std::vector<int>(list.size(), 0);
  int count = 0;
  for(int x = 0; x < w; x++){
    bool need_break = false;
    for(int y = 0; y < list.size(); y++){
      current[y] += list[y][x];
      if(current[y] > k) need_break = true;
    }
    if(need_break){
      count++;
      for(int y = 0; y < list.size(); y++){
        current[y] = list[y][x];
      }
    }
    for(int y = 0; y < list.size(); y++){
      if(current[y] > k) return w * 10; // impossible
    }
  }
  return count;
}

int main(int argc, char *argv[]) {
  int h, w, k;
  std::cin >> h >> w >> k;
  std::vector<std::vector<bool>> is_white;
  for(int y = 0; y < h; y++){
    is_white.push_back({});
    for(int x = 0; x < w; x++){
      char c;
      std::cin >> c;
      is_white[y].push_back(c == '1');
    }
  }
  int best = w + h;
  for(int i = 0; i < (1 << h); i++){
    std::vector<std::vector<int>> list = {std::vector<int>(w, 0)};
    for(int y = 0; y < h; y++){
      for(int x = 0; x < w; x++){
        list[list.size() - 1][x] += (is_white[y][x] ? 1 : 0);
      }
      if((i >> y) & 1) {
        list.push_back(std::vector<int>(w, 0));
      }
    }
    int cost = list.size() - 1 + solve(list, w, k);
    if(cost < best) {
      best = cost;
    }
  }
  std::cout << best << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define int ll
using namespace std;
typedef long long ll;
signed main(){
	int n;cin>>n;
  	string s;cin>>s;
  	if(n<4){cout<<0<<endl;return 0;}
  	int r=0,g=0,b=0;
	rep(i,n){
      if(s[i]=='R')r++;
      else if(s[i]=='G')g++;
      else if(s[i]=='B')b++;
    }
  ll sum=0;
  rep(i,n){
    rep(dif,n){
      if( (i+(dif+1)*2)>(n-1))break;
      if(s[i]!=s[i+(dif+1)] && s[i+(dif+1)]!=s[i+(dif+1)*2]&&s[i]!=s[i+(dif+1)*2])sum++;
    }
  }
  
  
  cout<<r*g*b-sum<<endl;
  
  return 0;
}


Measured memory_bytes: 3640
# D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd

# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

# nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass #sortされていない

ans = 0
gcd1 = gcd(A, B)
for i in divisor(gcd1):
    if is_prime(i):
        ans += 1

print(ans+1)

Measured memory_bytes: 5332
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<ll> b(N);
    for (int i = 0; i < N; i++) b[i] = max(0ll, a[i]);
    vector<ll> asum(N + 1, 0), bsum(N + 1, 0);
    for (int i = 0; i < N; i++) asum[i + 1] = asum[i] + a[i];
    for (int i = 0; i < N; i++) bsum[i + 1] = bsum[i] + b[i];
    ll res = 0;
    for (int i = 0; i + K <= N; i++) {
      int j = i + K;
      res =
          max(res, bsum[N] - (bsum[j] - bsum[i]) + max(0ll, asum[j] - asum[i]));
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
N=int(input())
P=list(map(int,input().split()))
count=0
P_new=[]
for index in range(N):
    P_new.append(P[index])
    if P_new[0]>P_new[index]:
        P_new[0]=P_new[index]
    if P_new[0]==P[index]:
        count+=1
print(count)

Measured memory_bytes: 26012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(alphabet(sc.nextLong()));
	}
	
	public static String alphabet(long num) {
		int firstAlpha = (int)'a';
		int sizeAlpha = 26;

		if (num <= sizeAlpha) {
			return String.valueOf((char)(firstAlpha + num - 1));
		} else {
			long offset = num - 1;
			long tmp = offset;
			String str = "";
			while(true) {
				long div = tmp / sizeAlpha;
				long m = tmp % sizeAlpha;
				str = alphabet(m + 1) + str;
				if (div <= 0)
					break;
				tmp = (div - 1);
			}
			return str;
		}
	}
}


Measured memory_bytes: 39372
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  string s;cin>>s;
  for(int i=0;i<s.length();i++){
    if(i%2==0&&s[i]=='L'){
      cout<<"No"<<endl;
      return 0;
    }else if(i%2==1&&s[i]=='R'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int x,i;
int a[4];
for(i=0;i<4;i++){
scanf("%d",&a[i]);
x =a[0]+a[1]+a[2]+a[3];
}
printf("%d\n", x/60);
printf("%d\n", x%60);
return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		// System.out.println(Main.fibonacciNumber(scan.nextInt()));
		System.out.println(Main.fibonacciNumberDP(scan.nextInt()));
	}

	// 再帰
	static int fibonacciNumber(int n) {
		if (n == 0) {
			return 1;
		} else if (n == 1) {
			return 1;
		} else {
			return fibonacciNumber(n - 1) + fibonacciNumber(n - 2);
		}
	}

	// DP
	static int fibonacciNumberDP(int n) {
		int[] fib = new int[n + 1];
		fib[0] = 1;

		if (fib.length >= 2){
			fib[1] = 1;
		}

		for (int i = 2; i < fib.length; i++) {
			fib[i] = fib[i - 1] + fib[i - 2];
		}

		return fib[n];
	}

}

Measured memory_bytes: 12000
S = input()
T = input()
s = len(S)
t = len(T)
f = True
ans = []
for i in range(s):
    tmp = list(S)
    if t+i>s:
        continue
    else:
        for j in range(t):
            tmp2 = list(T)
            if tmp[i+j]=='?':
                tmp[i+j] = tmp2[j]
            elif tmp[i+j]== tmp2[j]:
                continue
            else:
                f = False
        if f:
            ans.append(tmp)
    f = True
res = []
for a in ans:
    for i in range(len(a)):
        if a[i]=='?': a[i]='a'
    res.append(''.join(a))
print(min(res) if res else 'UNRESTORABLE')
        


Measured memory_bytes: 63512
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int index = -1;
		for (int i = s.length - t.length; i >= 0; i--) {
			boolean find = true;
			for (int j = 0; j < t.length; j++) {
				if (s[i + j] == '?') continue;
				if (t[j] != s[i + j]) {
					find = false;
					break;
				}
			}
			if (find) {
				index = i;
				break;
			}
		}

		if (index == -1) {
			System.out.println("UNRESTORABLE");
			return;
		}
		for (int i = 0; i < s.length; i++) {
			if (i < index) {
				if (s[i] == '?') s[i] = 'a';
			} else if (i < index + t.length) {
				s[i] = t[i - index];
			} else {
				if (s[i] == '?') s[i] = 'a';
			}
		}

		System.out.println(s);
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
main()
{
  int n,a,b;
  int x;
 
  scanf("%d%d%d",&n,&a,&b);
  x=n*a;
 
  if(x<b){
    printf("%d\n",x);
  }else if(x>=b){
    printf("%d\n",b);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b,c,x,ans;
    while(cin >> a >> b >> c >> x)
    {
        ans = 0;
        for(int i = 0; i <= a; i++)
            for(int j = 0; j <= b; j++)
                for(int k = 0; k <= c; k++)
                    if(i*500 + j*100 + k*50 == x)
                        ans++;
        cout << ans << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int min, max;

	cin >> min >> max;

	if (min > max)
	{
		int a = min;
		min = max;
		max = a;
	}

	for (int i = 0; i < max; ++i)
	{
		cout << min;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a ,i , j , sw = 0, c = 0;
  scanf("%d\n", &a);
  int x[a];

  for (i = 0;i < a; i++) {
    scanf("%d\n", &x[i]);
  }

  for (i = 0;i == i ; i++) {
    for(j = 0; j < a; j++){
      if(x[j] % 2 == 0){
        //printf("%dなので%dは割れました\n",x[j],j);
        x[j] /= 2;
        sw ++;
        //printf("%dsw\n", sw);
      }else{
        break;
      }
    }
    if(sw == a){
      sw = 0;
      c ++;
    }else{
      printf("%d\n",c);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
int main()
{
  int N,pos=0;
  LL A=0,top=0,one=0,two=1;
  cin>>N;
  vector<LL> x(N,0);
  rep(i,N){cin>>x.at(i);top=max(top,x.at(i));if(top==x.at(i))pos=i;}
  while(x.at(pos)>0)
  {
    one=0;
    rep(i,N)one+=x.at(i)%2==1,x.at(i)/=2;
    A=(A+((N-one)*one%MOD)*two%MOD)%MOD;two=two*2%MOD;
  }
  return cout<<A<<endl,0;
}

Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;

int main(){
    int l, r, i, j, mod, mini=2500, a, b, mini2;
  cin >> l >> r;

  a = l/2019;
  b = r/2019;

  if(b-a>0)
      mini=0;
  else{

      for(int i=l; i<=r; i++){
	  for(int j=i+1; j<=r; j++){
	      int tmp = ((i%2019)*(j%2019))%2019;
	      mini = min(mini, tmp);
	  }   
      }

      // mini2 = ((l%2019)*((l+1)%2019)) %2019;
      
  }


  cout << mini << endl;
  // cout << mini2 << endl;

  return 0;
}


Measured memory_bytes: 256
///-BISMILLAHIR RAHMANIR RAHIM-///
#include <bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define pb push_back
#define scn(n) scanf("%lld",&n)
#define pi acos(-1)
#define ll long long
#define llu unsigned long long
#define mod 1000000007
int main()
{
    ll n,x;
    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        if(i%3==0)
            cout<<" "<<i;
        else
        {
            x=i;
            while(x)
            {
                if(x%10==3)
                {
                    cout<<" "<<i;
                    break;
                }
                x/=10;
            }
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    long long int a[n] = {};
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    for(int i = 0;i < n;i++)
    {
        if(n % 2 == 0 && (a[i] == 1 || a[i] > 2) || n % 2 == 1 && a[0] != 1)
        {
            cout << "0\n";
            return 0;
        }
    }
    n /= 2;
    long long int ans = 1;
    while(n > 0)
    {
        ans = ans * 2;
        ans = ans % MOD;
        n--;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e10
#define mod 1000000007
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
#define lcm(x,y)  (x*y)/__gcd(x,y)

int  fact(int n)
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * fact(n - 1);
}
int nCr(int n, int r)
{
	if (r == 0)
		return 1;
	else
		return fact(n) / (fact(n - r) * fact(r));
}

int32_t main()
{
	//c_p_c();
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=35;
ll f[N];
ll dis(ll x1,ll y1,ll x2,ll y2){return abs(x1-x2)+abs(y1-y2);}
ll solve(ll x1,ll y1,ll x2,ll y2,ll level)
{
    if(level==0) return abs(y1-y2);
    ll w=f[level-1];
    if(x1/w!=x2/w) return dis(x1,y1,x2,y2);
    if(x1/w==1&&abs(y1/w-y2/w)>=2)
        return abs(y1-y2)+min(x1%w+x2%w+2,2*w-x1%w-x2%w);
    return solve(x1%w,y1,x2%w,y2,level-1);
}
int main()
{
    f[0]=1;for(int i=1;i<N;i++) f[i]=f[i-1]*3;
    int q;scanf("%d",&q);
    while(q--)
    {
        ll x1,y1,x2,y2;
        scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
        x1--;y1--;x2--;y2--;
        if(abs(x1-x2)>abs(y1-y2)) swap(x1,y1),swap(x2,y2);
        printf("%lld\n",solve(x1,y1,x2,y2,30));
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int cnt[N + 1];
  fill(cnt, cnt + N + 1, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    cnt[A]++;
  }
  sort(cnt, cnt + N + 1);
  int ans = 0;
  for (int i = 0; i <= N - K; i++) ans += cnt[i];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4388
a = []
for i in range(3):
  s,t = map(int, input().split())
  a.append(s)
  a.append(t)
b = [a.count(i)%2 for i in a]
if 0 not in a and b.count(1) == 2 or b.count(1) == 0:
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3064
#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 N,M;
  cin >> N >> M;
  long long int x[N],y[N],z[N];
  rep(i,N) cin >> x[i] >> y[i] >> z[i];
  vector<long long int> a(N);
  rep(i,N) a[i]=(x[i]+y[i]+z[i]);
  sort(a.begin(),a.end());
  long long aa=0;
  rep(i,M)aa+=a[N-1-i];
  vector<long long int> b(N);
  rep(i,N) b[i]=(-x[i]+y[i]+z[i]);
  sort(b.begin(),b.end());
  long long bb=0;
  rep(i,M)bb+=b[N-1-i];
  vector<long long int> c(N);
  rep(i,N) c[i]=(x[i]-y[i]+z[i]);
  sort(c.begin(),c.end());
  long long cc=0;
  rep(i,M)cc+=c[N-1-i];
  vector<long long int> d(N);
  rep(i,N) d[i]=(x[i]+y[i]-z[i]);
  sort(d.begin(),d.end());
  long long dd=0;
  rep(i,M)dd+=d[N-1-i];
  vector<long long int> e(N);
  rep(i,N) e[i]=(x[i]-y[i]-z[i]);
  sort(e.begin(),e.end());
  long long ee=0;
  rep(i,M)ee+=e[N-1-i];
  vector<long long int> f(N);
  rep(i,N) f[i]=(-x[i]+y[i]-z[i]);
  sort(f.begin(),f.end());
  long long ff=0;
  rep(i,M)ff+=f[N-1-i];
  vector<long long int> g(N);
  rep(i,N) g[i]=(x[i]-y[i]+z[i]);
  sort(g.begin(),g.end());
  long long gg=0;
  rep(i,M)gg+=g[N-1-i];
  vector<long long int> h(N);
  rep(i,N) h[i]=(-x[i]-y[i]-z[i]);
  sort(h.begin(),h.end());
  long long hh=0;
  rep(i,M)hh+=h[N-1-i];
  cout << max({aa,bb,cc,dd,ee,ff,gg,hh}) <<endl;

  return 0;
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let s: Vec<char> = iter.next().unwrap().chars().collect();
    let n = s.len() as usize;
    let mut dp = vec_md![0u64;n + 1;4];
    dp[0][0] = 1;
    for i in 0..n {
        let k = match s[i] {
            'A'|'B'|'C' => 1,
            _ => 3
        };
        for j in 0..4 {
            dp[i+1][j] = k * dp[i][j] % M;
        }
        match s[i] {
            'A' => {
                dp[i+1][1] += dp[i][0];
                dp[i+1][1] %= M;
            },
            'B' => {
                dp[i+1][2] += dp[i][1];
                dp[i+1][2] %= M;
            },
            'C' => {
                dp[i+1][3] += dp[i][2];
                dp[i+1][3] %= M;
                
            },
            _ => {
                for j in 0..3 {
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= M;
                }
            }
        }
    }
    println!("{}", dp[n][3]);
}


Measured memory_bytes: 10492
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

L = [0]*(N+2)
R = [0]*(N+2)
for i in range(N):
  L[i+1] = gcd(L[i], A[i])
for i in range(N, 0, -1):
  R[i] = gcd(R[i+1], A[i-1])
ans = 1
for i in range(1, N+1):
  ans = max(ans, gcd(L[i-1], R[i+1]))
print(ans)

Measured memory_bytes: 16112