akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

int main() {
  ll H,W;
  cin>>H>>W;
  char tab[H][W];
  bool high=true;
  bool side=true;
  ll will=0;
  for(ll i=0;i<H;i++) {
    for(ll j=0;j<W;j++) {
      char a;
      cin>>a;
      tab[i][j]=a;
    }
  }
  for(ll i=0;i<H;i++) {
    for(ll j=0;j<W;j++) {
      if(tab[i][j]!='.') {
        high=false;
        break;
      }
    }
    if(high) {
      for(ll j=0;j<W;j++) {
        tab[i][j]='0';
      }
    }
    high=true;
  }
  for(ll i=0;i<W;i++) {
    for(ll j=0;j<H;j++) {
      if(tab[j][i]=='#') {
        side=false;
        break;
      }
    }
    if(side) {
      for(ll j=0;j<H;j++) {
        tab[j][i]='0';
      }
    }
    side=true;
  }
  for(ll i=0;i<H;i++) {
    for(ll j=0;j<W;j++) {
      if(tab[i][j]!='0'){
        cout<<tab[i][j];
      }
      else {
        will++;
      }
    }
    if(will!=W) {
      cout<<endl;
    }
    will=0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >>S;
    int count=0;
    if(S.at(0)=='A'){
     if(islower(S.at(1))){
      for(int i=2;i<S.size()-1;i++){
          if(S.at(i)=='C'){
              count ++;
          }
          else if(isupper(S.at(i))){
              cout <<"WA"<<endl;
              return 0;
          }
      }
     }
     else{
         cout<<"WA"<<endl;
         return 0;
     }
    }
    else{
        cout <<"WA"<<endl;
        return 0;
    }
    if(islower(S.at(S.size()-1))){
        if(count==1){
        cout <<"AC"<<endl;
        }
    else{
        cout <<"WA"<<endl;
        return 0;
    }    
    }
    else{
        cout <<"WA"<<endl;
        return 0;
    }
}

Measured memory_bytes: 3624
import math
N = int(input())
arr = list(map(int, input().split()))
gcd_right = [arr[0]]
for i in range(1,N-1):
    gcd_right.append(math.gcd(gcd_right[i-1],arr[i]))
arr = arr[::-1]
gcd_left = [arr[0]]
for i in range(1,N-1):
    gcd_left.append(math.gcd(gcd_left[i-1],arr[i]))
gcd_left = gcd_left[::-1]
ans = max(gcd_right[-1],gcd_left[0])
for i in range(N-2):
    ans = max(ans,math.gcd(gcd_left[i+1],gcd_right[i]))
print(ans)

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

using namespace std;

#define int long long
#define pb push_back

struct data{
	int x , y , val;
};
const int N = 1e5 + 1;

int n , pa[N] , ans[N] ,lazy[N];
vector<data> inp;
vector<int> par[N];

bool how_sort(data a , data b){
	return a.val > b.val;
}
signed main(){
	cin >> n;
	pa[n] = n; par[n].pb(n);
	for(int i = 1 ; i < n ; ++ i){
		pa[i] = i ; par[i].pb(i);
		int u , v , w;
		cin >> u >> v >> w;
		inp.pb( data{ u , v , w });
	}	
	sort(inp.begin() , inp.end() , how_sort);
	for(int i = 0 ; i < inp.size() ; ++ i){
		int u = inp[i].x , v = inp[i].y , w = inp[i].val; 
		if(par[pa[u]].size() > par[pa[v]].size()) swap(u,v);
		int z = pa[u];
		lazy[pa[v]] += w * par[z].size();
		int add = w * par[pa[v]].size();
		for(int i = 0 ;i < par[z].size() ; ++ i){
			int k = par[z][i];
			pa[k] = pa[v];
			par[pa[v]].pb(k);
			ans[k] += lazy[z] - lazy[pa[v]] + add;
		}
	}
	for(int i = 0 ;i < par[pa[1]].size() ; ++ i){
		int k = par[pa[1]][i];
		ans[k] += lazy[pa[1]];
	}
	for(int i = 1 ; i <= n ; ++ i)
		cout << ans[i] << "\n";
}

Measured memory_bytes: 19760
#include<stdio.h>
int main(){
int a, b, c, d, e;
e = 0;
scanf("%d %d %d", &a, &b, &c);
for(int x = a; x <= b; x++){
d = c % x;
if(d == 0){
e += 1;
}
}
printf("%d\n",e);
 
return 0;
}


Measured memory_bytes: 2132
x, y, n = map(int, input().split())
wlist = []
for i in range(n):
    wlist.append(list(map(int, input().split())))
dst = []
x = [0, x]
y = [0, y]
for i in wlist:
    if i[2] == 1:
        x[0] = i[0] if i[0] > x[0] else x[0]
    elif i[2] == 2:
        x[1] = i[0] if i[0] < x[1] else x[1]
    elif i[2] == 3:
        y[0] = i[1] if i[1] > y[0] else y[0]
    else:
        y[1] = i[1] if i[1] < y[1] else y[1]
x = x[1]-x[0] if x[1]-x[0] > 0 else 0
y = y[1]-y[0] if y[1]-y[0] > 0 else 0
dst = x*y
print(dst)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    string o, e;
    cin >> o >> e;
    for (int i = 0; i<o.size(); i++){
        cout << o[i];
        if (i < e.size()) cout << e[i];
        }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#define Max(a,b) a=max(a,b);
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int h,w;
int dp[3010][3];
char m[3010][3010];
int main(){
	cin>>h>>w;
	lol(i,h)lol(j,w)cin>>m[i][j];
	int ans=0;
	for(int k=0;k<=h+w-2;k++){
		memset(dp,0,sizeof(dp));
		int last=0;
		for(int y=0;y<=k;y++){
			int x=k-y;
			if(x>=w||y>=h){
				continue;
			}
			bool tate=false,yoko=false;
			if(y>0)if(m[y-1][x]=='R'&&m[y][x]=='G'&&m[y+1][x]=='W')tate=1;
			if(x>0)if(m[y][x-1]=='R'&&m[y][x]=='G'&&m[y][x+1]=='W')yoko=1;
			Max(dp[last+1][0],dp[last][0]);
			Max(dp[last+1][0],dp[last][1]);
			Max(dp[last+1][0],dp[last][2]);
			if(tate){
				Max(dp[last+1][1],dp[last][0]+1);
				Max(dp[last+1][1],dp[last][1]+1);
			}
			if(yoko){
				Max(dp[last+1][2],dp[last][0]+1);
				Max(dp[last+1][2],dp[last][2]+1);
			}
			last++;
		}
		ans+=max(dp[last][0],max(dp[last][1],dp[last][2]));
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 11928
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int main() {
    ll n;
    ll s;
    std::cin >> n;
    std::cin >> s;
    
    if(s > n){
        std::cout << -1 << std::endl;
        return 0;
    }
    if( s == n){
        std::cout << n+1 << std::endl;
        return 0;
    }

    for (int i = 2; i <= (ll)sqrt(n); i++) {
        ll result = 0;
        ll tmp_n = n;
        while(tmp_n>0){
            result += tmp_n%i;
            tmp_n /= i;
        }
        if(result == s){
            std::cout << i << std::endl;
            return 0;
        }
    }
    
    vector<ll> ans;
    for (int i = 1; i <= (ll)sqrt(n); i++) {
        if( (n-s+i)%i == 0 ){
            ll b = (n-s+i)/i;
            if(  b >= (ll)sqrt(n) && b <= n && i < b && s-i < b && 0 <= s-i){
                ans.push_back(b);
            }
        } 
    }
    sort(ans.begin(),ans.end());
    if(ans.empty()){
        std::cout << -1 << std::endl;
        return 0;
    }else{
        std::cout << ans[0] << std::endl;
    }
    
}
// 100000000000
// 99999999999


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  ll N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<ll> ac(N+1,0);
  ll tmp = 0;
  for(ll i=0;i<N-1;++i){
    ac[i+1] = ac[i]+(S[i]=='A' && S[i+1]=='C');
  }
  for(ll i=0;i<Q;++i){
    ll l,r;
    cin>>l>>r;
    l--,r--;
    cout << ac[r]-ac[l] << endl;
  }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
main()
{
    int i,n;
    char a[10001];
    while(scanf("%d",&n)==1){
        scanf("\n");
        scanf("%s",&a);
        for(i=0;i<strlen(a);i++){
            a[i]+=n;
            if(a[i]>90)
                a[i]-=26;
            printf("%c",a[i]);
        }
        printf("\n");
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var n = firstLine[0];
            var m = firstLine[1];

            var paths = new Dictionary<int, List<int>>();
            for(var i = 0; i < n; i++)
            {
                paths.Add(i, new List<int>());
            }
            for(var i = 0; i < m; i++)
            {
                var path = ReadLine().Split(' ').Select(value => int.Parse(value) - 1).ToArray();
                paths[path[0]].Add(path[1]);
                paths[path[1]].Add(path[0]);
            }
            var costs = new int[n];
            var from = new int[n];
            for (var i = 0; i < n; i++)
            {
                costs[i] = int.MaxValue;
                from[i] = int.MaxValue;
            }
            costs[0] = 0;
            var isFound = new bool[n];
            var queue = new Queue<int>();
            queue.Enqueue(0);
            isFound[0] = true;

            while(queue.Count > 0)
            {
                var node = queue.Dequeue();
                var nextNodes = paths[node];
                foreach(var nextNode in nextNodes)
                {
                    if(!isFound[nextNode])
                    {
                        queue.Enqueue(nextNode);
                        isFound[nextNode] = true;
                        costs[nextNode] = costs[node] + 1;
                        from[nextNode] = node;
                    }
                }
            }

            if(from.Count(value => value == int.MaxValue) > 1)
            {
                WriteLine("No");
            }
            else
            {
                WriteLine("Yes");
                for(var i = 1; i < n; i++)
                {
                    WriteLine(from[i] + 1);
                }
            }
        }
    }
}


Measured memory_bytes: 41032
import java.util.Scanner;

public class Main {

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

        int a = input/500;
        int b = (input%500)/5;


        System.out.println(a*1000 + b*5);
        scanner.close();
    }

}


Measured memory_bytes: 22740
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        String[] array = new String[n];
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            char[] c = str.toCharArray();
            Arrays.sort(c);
            
            String str2 = "";
            for (int j = 0; j < 10; j++) {
                str2 += c[j];
            }
            array[i] = str2;
        }
        Arrays.sort(array);
        String now = array[0];
        long ans = 0;
        long count = 0;
        for (int i = 1; i < n; i++) {
            if (array[i].equals(now)) {
                count++;
                ans += count;
            } else {
                now = array[i];
                count = 0;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 71448
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

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

using namespace std;

int H, W, A, B;
int const mod = 1e9+7;
int const MAX = 200000;
vector<int> fact(MAX+1);
vector<int> ifact(MAX+1);

int extgcd(int a, int b, int &x, int &y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b)*x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

// m is a large prime integer. Usually 1000000007 is used.
int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x%m)%m;
}

int comb(int n, int r) {
  return (ll)fact.at(n)*ifact.at(r)%mod*ifact.at(n-r)%mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> H >> W >> A >> B;


  fact.at(0) = 1;
  for(int i=1; i<=MAX; i++) {
    fact.at(i) = ((ll)fact.at(i-1)*i)%mod;
  }
  rep(i, 200001) {
    ifact.at(i) = mod_inverse(fact.at(i), mod);
  }

  ll ans = 0;

  for(int i=B; i<=W-1; i++) {
    int comb1 = comb(H-A-1+i, i);
    int comb2 = comb(A-2+W-i, A-1);
    // cout << comb1 << ',' << comb2 << endl;
    ans = (((ll)comb1*comb2%mod)+ans)%mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;

const MOD : u64 = 1_000_000_000 + 7;

fn main() {
    
    let a = read::<usize>();
    let b = read::<usize>();
    //let mut b : Vec<bool> = vec![false; 2*n];

    let mut tmp = 1;
    let mut ans = 0;
    
    while (tmp < b) {
        tmp += a - 1;
        ans += 1;
    }
    
    println!("{}",ans);
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> p(n);
  int d = 0;
  rep(i, n) {
    cin >> p[i];
    if (i + 1 != p[i]) ++d;
  }
  out(d <= 2 ? "YES" : "NO");
}


Measured memory_bytes: 3596
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
E=[]
for _ in range(m):
  E.append(tuple(int(i) for i in input().split()))
q=int(input())
Q=[]
for _ in range(q):
  Q.append(tuple(int(i) for i in input().split()))

DP=[[[0]*2 for i in range(n)] for j in range(11)]
for i in range(q):
  v,d,c=Q[i]
  DP[d][v-1][0]=i+1
  DP[d][v-1][1]=c

for d in range(10)[::-1]:
  for v in range(n):
    if DP[d+1][v][0]>DP[d][v][0]:
      DP[d][v]=DP[d+1][v]
  for e in range(m):
    a,b=E[e]
    a-=1
    b-=1
    if DP[d+1][a][0]>DP[d][b][0]:
      DP[d][b]=DP[d+1][a]
    if DP[d+1][b][0]>DP[d][a][0]:
      DP[d][a]=DP[d+1][b]
for i in range(n):
  print(DP[0][i][1])




Measured memory_bytes: 154248
#include <iostream>
#include <iomanip>
#include <map>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    repi(i,n,0){
        int k;
        cin >> k;
        repi(j,k,0){
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    int ans = 0;
    for(auto itr = mp.begin();itr != mp.end();itr++){
        if(itr->second == n)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int a[N]; 
void solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    } 
    vector <int> v;
    int mn = 1;
    for(int i = 1; i <= n; ++i) {
        if(a[i] == mn) {
            v.pb(mn ++);
        }
    }  
    if(v.size() == 0){
        cout << "-1";
        
    }
    else {
        cout << n - (int)v.size();
    }
}

 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 2168
/*
Nが大きいので、フェルマーテストはしない
 
”もし N が素数x と素数y とに割り切れる（つまり N=xy）とすると、x と y のいずれかは N の平方根よりも小さくなければならない。もし x と y の両方ともが N の平方根よりも大きいとすると、xy（=N）は N よりも大きいということになり、これは不条理である。したがって、もし N が素数でないとすると、N は「N の平方根よりも小さい素数」で割り切れる。 ”
↑より、調べるのはNの平方根まで
 
n以下のすべての数でなく、素数で割ったほうが早いけど、面倒なのでそれはしない
やるとしたら
（１）入力の中で最大の数を探す
（２）エラトステネスの篩で素数を求めておく
（３）それぞれ素数判定
 
*/
 
#include <iostream>
#include <math.h>
 
using namespace std;
 
int main() {
    int N;
    int i,j;
    int element;
    //int prime_count=0;
    int Composite_number_count=0; //合成数の数
    
    cin >> N;
    
        //合成数の数を数えて、全体から引けば　素数の数になる
    for(i=0; i<N; i++){
        cin >> element;
        for(j=2; j<=(int)(sqrt((double)element)); j++){
            if(element%j==0){Composite_number_count++; break;} //合成数ならカウントして抜ける
        }
    }
    cout << N - Composite_number_count << endl;
        
        return 0;
}

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

/*
右側の塊を考えて、なるべく現在と逆のを書きつつ、やばそうなら右側のと逆を書く
*/
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  string s;cin>>s;
  int n=s.size();
  vector<int> o(n+1,0),z(n+1,0);
  int ot=0,zt=0;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='0')z[i]=++zt;
    else{chmax(--zt,0);z[i]=zt;}
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='1')o[i]=++ot;
    else{chmax(--ot,0);o[i]=ot;}
  }
  int ans=0;
  ot=zt=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0'){
      chmax(ans,++zt);
      chmax(--ot,0);
    }
    else if(s[i]=='1'){
      chmax(ans,++ot);
      chmax(--zt,0);
    }
    else{
      if(zt+z[i+1]>ot+o[i+1]){
        chmax(ans,++ot);
        chmax(--zt,0);
      }
      else{
        chmax(ans,++zt);
        chmax(--ot,0);
      }
    }
  }
  int ans2=ans;
  ans=ot=zt=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0'){
      chmax(ans,++zt);
      chmax(--ot,0);
    }
    else if(s[i]=='1'){
      chmax(ans,++ot);
      chmax(--zt,0);
    }
    else{
      if(zt+z[i+1]>=ot+o[i+1]){
        chmax(ans,++ot);
        chmax(--zt,0);
      }
      else{
        chmax(ans,++zt);
        chmax(--ot,0);
      }
    }
  }
  cout<<min(ans,ans2)<<endl;
}


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

using namespace std;

int main() {
    unsigned long n,q,a[1000000],c,b,sum=0;
    cin>>n;
    map<unsigned long,unsigned long>m;
    for(unsigned long i=0;i<n;i++)
    {
        cin>>a[i];
        sum +=a[i];
        m[a[i]]++;
    }
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        if(m[b]!=0)
        {
        int k = m[b];
        m[b]=0;
        sum = sum - (k*b) + (k*c);
            m[c]+=k;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 10020
def main():
  n, *A = map(int, open(0).read().split())
  A.sort()
  m = A[-1]
  lst = [0] * (m + 1)
  prep = 0
  for i in A:
    if i == prep:
      lst[i] = 1
      continue
    lst[2 * i::i] = [1] * len(lst[2 * i::i])
    prep = i
  res = 0
  for i in A:
    if lst[i] == 0:
      res += 1
  print(res)

if __name__ == '__main__':
  main()


Measured memory_bytes: 40932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

double calDis(pair<int,int> p1, pair<int,int> p2){
  return sqrt(pow(p1.first-p2.first,2)+pow(p1.second-p2.second,2));
}

int fac(int n){
  if(n == 1) return 1;
  else if(n >= 2) return n*fac(n-1);
}

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<pair<int,int> > vp(n);
  rep(i,n){
    v[i] = i;
    cin >> vp[i].first >> vp[i].second;
  }

  double sum = 0.;
  do{
    for(int i=0; i<n-1; i++){
      sum += calDis(vp[v[i]],vp[v[i+1]]);
    }
  }while(next_permutation(v.begin(), v.end()));
    
  printf("%.10f", sum/fac(n));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n,m;
    ll ma=0,x,y;
    cin>>n>>m;
    vector<vector<bool>> v(n,vector<bool>(m,false));
    vector<vector<bool>> u2(n,vector<bool>(m,false));
    rep(i,n){
        string c;cin>>c;
        rep(j,m)if(c[j]=='.')v[i][j]=true;
    }
    rep(i,n){
        rep(j,m){
          if(!v[i][j])continue;
    queue<PP> q;
    vector<vector<bool>> u(n,vector<bool>(m,false));
        q.push(PP(i,j,0));
        while(!q.empty()){
        auto p=q.front();q.pop();
        ll i=get<0>(p),j=get<1>(p),d=get<2>(p);
        u[i][j]=true;
        chmax(ma,d);
        if(i+1<n)if(!u[i+1][j]&&v[i+1][j]){
            u[i+1][j]=true;
            q.push(PP(i+1,j,d+1));
        }
        if(i-1>=0)if(!u[i-1][j]&&v[i-1][j]){
            u[i-1][j]=true;
            q.push(PP(i-1,j,d+1));
        }
        if(j+1<m)if(!u[i][j+1]&&v[i][j+1]){
            u[i][j+1]=true;
            q.push(PP(i,j+1,d+1));
        }
        if(j-1>=0)if(!u[i][j-1]&&v[i][j-1]){
            u[i][j-1]=true;
            q.push(PP(i,j-1,d+1));
        }
    }
        }
        }
    out(ma);
}


Measured memory_bytes: 256
n=0
m=input()
c=[0 for i in xrange(m)]
ts=[0 for i in xrange(m)]


def d(u):
    global n
    if ts[u]:return
    n = n + 1
    ts[u]=[u+1,n]
    for i in c[u]:d(i-1)
    n = n + 1
    ts[u][2:]=[n]

def dfs():
    for i in range(m):
     l=map(int,raw_input().split())
     c[l[0]-1]=l[2:]
    for i in range(m):
     d(i)
     print " ".join(map(str,ts[i]))

dfs()

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
	ll n, m;
	cin >> m >> n;
	if(m <= 10)
		cout << n + (100 * (10 - m));
	else
		cout << n;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

int main () {

  string input;

  while( true ) {

    getline( cin, input );

    if ( input == "." ) break;

    string s = " ";

    for ( long long int i = 0; i < input.size(); i++ ) {

      if ( input[i] == '(' ) {
	s += "(";
      }else if ( input[i] == '[' ) {
	s += "[";
      }else if ( input[i] == ')' ) {
	if ( s[ s.size() - 1 ] != '(' ) {
	  cout << "no" << endl;
	  break;
	}else {
	  s.erase( s.size() - 1 );
	}
      }else if ( input[i] == ']' ) {
	if ( s[ s.size() - 1 ] != '[' ) {
	  cout << "no" << endl;
	  break;
	}else {
	  s.erase( s.size() - 1 );
	}
      }

      if ( i == input.size() - 1 ) {
	if ( s == " " ) {
	  cout << "yes" << endl;
	}else {
	  cout << "no" << endl;
	}
      }

    }

  }

  return 0;

}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
int main(){
    //FL;
    fin;
    int  a, b, c;
    cin >> a >> b >> c;
    a -= b;
    if(c > a)
        cout << c - a << '\n';
    else
        cout << 0 << '\n';
    time;
    return 0;
}   

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

using namespace std;

int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;

	int max_pos = max({ a,b,c,d,e });
	int min_pos = min({ a,b,c,d,e });

	if (max_pos - min_pos <= k) {
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
}






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

int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	string s; 
	cin>>s;
	ll dp[n+1][n+1];
	dp[1][1]=1;
	ll mod=1e9+7;
	for(int i=2;i<=n;i++){
		ll arr[i];
		arr[0]=0;
		for(int j=1;j<=i-1;j++){
			arr[j]=(arr[j-1]+dp[i-1][j])%mod;
		}
		for(int j=1;j<=i;j++){
			if(s[i-2]=='>'){
				dp[i][j]=(arr[i-1]-arr[j-1]+mod)%mod;
			}	
			else{
				dp[i][j]=arr[j-1];
			}		
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++) ans=(ans+dp[n][i])%mod;
	cout<<ans;
}

Measured memory_bytes: 70272
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int mod = 1e9+7;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  if (n-m < -1 || 1 < n-m) {
    printf("0\n");
    return 0;
  }
  ll ans = 1;
  rep (i, n) {
    ans *= (n-i);
    ans %= mod;
  }
  rep (i, m) {
    ans *= (m-i);
    ans %= mod;
  }
  if (n == m) {
    ans *= 2;
    ans %= mod;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 888
import sys
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a) + min(b)
w = [list(map(int,input().split())) for i in range(M)]
for i in range(M):
    if a[w[i][0]-1] + b[w[i][1]-1] - w[i][2] < ans:
        ans = a[w[i][0]-1] + b[w[i][1]-1] - w[i][2]
print(ans)


Measured memory_bytes: 38572
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007LL
#define eps 1e-8

using namespace std;

int main()
{
	cin.tie(0),ios::sync_with_stdio(0);
	ll n,a,b; cin>>n>>a>>b;
	if((b-a)&1) cout<<min(a-1+1+(b-a)/2,(n-b)+1+(b-a)/2)<<"\n";
	else cout<<(b-a)/2<<"\n";
	return 0;
}

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

int N, K;
vector<int> a(100);
vector<int> dp(100001);

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    dp.at(0) = 1;
    for (int i = 1; i <= K; i++) {
        for (int j = 0; j < N; j++) {
            if (a.at(j) > i) {
                dp.at(i) = 1;
                break;
            }
            if (dp.at(i - a.at(j)) == 1) {
                dp.at(i) = 0;
                break;
            }
            dp.at(i) = 1;
        }
    }
    if (dp.at(K) == 0) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cmath>
typedef long long ll;
int a,b,c,k,num = 0;

template<typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}

int main(){
    read(a); read(b); read(c); read(k);
    while(b <= a) b <<= 1, num++;
    while(c <= b) c <<= 1, num++;
    if(num <= k) printf("Yes\n");
    else printf("No\n");
    return 0;
}
/*
3
1
-1
-1

2
*/

Measured memory_bytes: 3000
#include <iostream>
#include <set>
#include <numeric>
using namespace std;

using int64 = long long;

int main() {
  int64 n, m;
  cin >> n >> m;
  multiset<int64, greater<int64>> p;
  for (int64 i = 0; i < n; ++i) {
    int64 a;
    cin >> a;
    p.insert(a);
  }
  for (int i = 0; i < m; ++i) {
    int64 q = *p.begin();
    p.erase(p.begin());
    p.insert(q / 2);
  }
  cout << accumulate(p.begin(), p.end(), 0LL) << "\n";
  return 0;
}


Measured memory_bytes: 4992
from math import factorial

N, M = map(int, input().split())
a = 0
b = 0
if N >= 2:
    a = factorial(N) / factorial(2) / factorial(N - 2)
if M >= 2:
    b = factorial(M) / factorial(2) / factorial(M - 2)
print(int(b + a))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C;
	if(A+B+C>=22) cout<<"bust"<<endl;
	else cout<<"win"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream> 
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(int argc,char *argv[]){
	int n;
	cin >> n;
	call(n);
	return 0;
}

Measured memory_bytes: 3088
a = int(input())
x  = 0
lists = []
ass =[]
#bが気温c、standardが平均気温の基準
b,standard = map(int,input().split())
#標高
elev = list(map(int,input().split()))

for i in range(a):
    lists.append(abs(b - elev[i] * 0.006 - standard))

m = min(lists)
mindex = lists.index(m)
print(mindex + 1)


Measured memory_bytes: 3060
//Bugged

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,a);
    int t = accumulate(range(a),0);
    if(t%10==0){
        sort(range(a));
        rep(i,0,n){
            if(a[i]%10!=0){
                cout<<t-a[i]<<nnn;
                return 0;
            }
        }
        cout<<0<<nnn;
    }else{
        cout<<t<<nnn;
    }
    return 0;
}

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

int main(){
  int h,a;
  cin >> h >> a;
  int cnt = 0;
  while(h>0){
    h -=a;
    cnt++;
  }
  cout << cnt << endl;
  return 0;

}


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

namespace AtCorder
{
    class Program
    {

        static void Main(string[] args)
        {

            //var input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            decimal n = decimal.Parse(Console.ReadLine());
            var ls = new List<decimal>();
            ls.Add(decimal.Parse(Console.ReadLine()));
            ls.Add(decimal.Parse(Console.ReadLine()));
            ls.Add(decimal.Parse(Console.ReadLine()));
            ls.Add(decimal.Parse(Console.ReadLine()));
            ls.Add(decimal.Parse(Console.ReadLine()));

            ls.Sort();
            var min = ls[0];

            var result = Math.Ceiling(n / min) + 4;
            Console.WriteLine(result.ToString());
        }
    }
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    
	int n, k;
	cin >> n >> k;
	
    vector<int> f;
    
	for (int i = 0; i < n; i++) {
            int j;
            cin >> j;
            f.push_back(j);
    }
    sort(f.begin(), f.end());
    
    long long ans = 0;
    
    for (int i = 0; i < k; i++)
        ans += f[i];
    cout << ans << endl;
}


Measured memory_bytes: 3656
using System;
class c
{
    static void Main()
    {
        var s = Array.ConvertAll(Console.ReadLine().Split('/'), int.Parse);
        if (s[0] <= 2018) Console.WriteLine("Heisei");
        else if (s[0] == 2019 && s[1] <= 4) Console.WriteLine("Heisei");
        else Console.WriteLine("TBD");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <complex>

using namespace std;

int main(){
    int n;
    int cnt=1;
    while(cin >> n && n){
        complex<double> p[n];
        double ret = 0;
        for(int i=0;i<n;i++){
            double x;
            double y;
            cin >> x >> y;
            p[i] = complex<double>(x,y); 
        }

        for(int i=0;i<n;i++){
            if(i != n-1){
                ret += 0.5*imag(conj(p[i])*p[i+1]);
            }else{
                ret += 0.5*imag(conj(p[i])*p[0]);
            }
        }
        printf("%d %.1lf\n", cnt++, abs(ret));
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <bitset>

using namespace std;

typedef long long ll;

const char T[] = "MARCH";

int cnt[5];

int main() {
    ll ans = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < 5; ++j) {
            if (T[j] == s[0]) cnt[j]++;
        }
    }

    for(int bit = 0; bit < 1<<5; ++bit){
        bitset<8> bs(bit);
        if (bs.count() == 3){
            ll temp = 1;
            for (int j = 0; j < 5; ++j) {
                if (bit >> j & 1) temp *= cnt[j];
            }
            ans += temp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_right

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	A.sort()
	ai = -1
	tmp = -1
	for i in range(N-1):
		tmptmp = abs(A[i] - A[i+1])
		if tmptmp == 0:
			continue
		if tmp == -1 or tmp > tmptmp:
			tmp = tmptmp
			ai = i
			
	if tmp == -1:
		print(A[0])
		sys.exit()
		
	a = A[ai]		
	b = A[ai+1]
	
	while True:
		#print("{} {}".format(a, b))
		tmp_min = min(a, b)
		tmp_max = max(a, b)
		tmp = tmp_max % tmp_min
		if tmp == 0:
			print(tmp_min)
			sys.exit()
		else:
			if a < b:
				b = tmp
			else:
				a = tmp
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 14480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int t = sc.NextInt();
        int[] times = sc.IntArray();

        int answer = t;
        int before = times[0];
        for (int i = 1; i < n; i++)
        {
            int after = times[i];
            if (after - before < t)
            {
                answer += after - before;
            }
            else
            {
                answer += t;
            }
            before = after;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 26592
#include <bits/stdc++.h>
#define lli long long
#define z 1000000007
using namespace std;
int main() {
	lli n , k , i , cnt = 0 ;
	cin >> n >> k ;
	for(i=k;i<=n+1;++i){
	    lli st = (i*(i-1))/2 , end = (i*(n+n-i+1))/2 ;
        //cout << st << " " << end << "\n" ;
	    cnt = (cnt+end-st+1)%z ;
	}
	cout << cnt << "\n" ;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    int n;
    cin>>n;
    if(n==3||n==5||n==7) 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 scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int mat1[][] = new int[n][m];
		int mat2[][] = new int[m][l];
		long res;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				mat1[i][j] = scan.nextInt();
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				mat2[i][j] = scan.nextInt();
			}
		}
		scan.close();
		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				res = 0;
				for(int k = 0; k < m; k++){
					res += mat1[i][k] * mat2[k][j];
				}
				System.out.print(res);
				if(j != l - 1){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 55364
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}

char mp[1200][1200];
ll dp[1200][1200];
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%s",mp[i]+1);
    }
    dp[1][1]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(mp[i][j]=='#'||(i==1&&j==1)) continue;
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    printf("%lld\n",dp[n][m]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
bool vis[200000 + 10];
vector<int> q[200000 + 10];
int main() {
	int N, M;
	ios::sync_with_stdio ( false );
	cin >> N >> M;
	for ( int j = 0; j < M; j++ ) {
		int x,y;
		cin>>x>>y;
		if(y!=N)
			q[x].push_back(y);
		else q[y].push_back(x);
	}
	for(int j=0;j<q[1].size();j++)
		vis[q[1][j]]=true;
	int flag=0;
	for(int j=0;j<q[N].size();j++){
		if(vis[q[N][j]]==true){
			flag=1;
			break;
		}
	}
	if(flag>0)
		cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAX_N = 100000;
ll fact[MAX_N + 1];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll ans;
	fact[0] = 0;
	fact[1] = 1;
	ll fs = 1;
	for (int i = 2; i < MAX_N + 1; i++){
		fs = (fs*i) % MOD;
		fact[i] = (fact[i - 1] + fs) % MOD;
	}
	while (1){
		int N, R;
		cin >> N;
		if (N == 0) break;
		vector<int> word(N);
		for (int i = 0; i < N; i++) word[i] = i;
		word.push_back(0);
		ans = 0;
		cin >> R;
		vector<int> s(4 * R + 2, 0);
		s[2 * R + 1] = N;
		for (int i = 0; i < R; i++){
			int s1, s2;
			cin >> s1 >> s2;
			s[4 * i] = s1;
			s[4 * i + 1] = s2;
			s1--; s2--;
			s[4 * i + 2] = s1;
			s[4 * i + 3] = s2;
			swap(word[s1], word[s2]);
		}
		s[4 * R] = 0; s[4 * R + 1] = N;
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		for (int i = 0, R = s.size() - 1; i < R; i++){
			ans = (ans + word[s[i]] * (fact[N - s[i] - 1] - fact[N - s[i + 1] - 1] + MOD)) % MOD;
			for (int j = i + 1, dif = s[i + 1] - s[i]; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[s[i]] ? dif : 0);
			}
		}
		cout << ans % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 2788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,A,B,C,D,E;
  cin>>N>>A>>B>>C>>D>>E;
  int64_t mini=min(A,min(B,min(C,min(D,E))));
  cout<<(N+mini-1)/mini+4<<endl;

  
  return 0;}

Measured memory_bytes: 256
import sys

import numpy as np


def search_y(x, points):
    l = np.complex128(x + 0.0j)
    r = np.complex128(x + 1000.0j)

    d1, d2 = 0, 0
    while abs(r - l) > 3e-7:
        m = (l + r) / 2
        p1 = m - 1e-7j
        p2 = m + 1e-7j
        d1 = abs(points - p1).max()
        d2 = abs(points - p2).max()
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


def search(points):
    l = 0.0
    r = 1000.0

    d1, d2 = 0, 0
    while r - l > 3e-7:
        m = (l + r) / 2
        p1 = m - 1e-7
        p2 = m + 1e-7
        d1 = search_y(p1, points)
        d2 = search_y(p2, points)
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


n = int(input())
points = np.array([complex(*map(int, line.split())) for line in sys.stdin], dtype=np.complex128)
print(search(points))


Measured memory_bytes: 12580
#include <bits/stdc++.h>
 
#define IO ios::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define up(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define down(a,b,c) for(ll (a)=(b)-1;(a)>=(c);(a)--)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define mii map<int,int>
#define mll map<ll,ll>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define debug(x) cout << "\t" << (#x) << " = " << (x) << endl
#define debugl(x,y) cout << "on loop " << (#x) << " : " << (x) << ", " << (#y) << " = " << (y) << endl 
#define N 300050

using namespace std;

int pali(string s){
	string temp=s;
	reverse(temp.begin(),temp.end());
	if(temp==s) return 1;
	return 0;
}

int main(){
	IO;
	double n;
	cin >> n;
	double s=n/3;
	cout <<fixed << setprecision(12)<< s*s*s << endl;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))

xyz = [[0,0,0]for _ in range(n)]
xyz[0] = [0,0,0]

mod = 10**9+7

for i in range(n-1):
    if li[i] not in xyz[i]:
        print(0)
        exit()
    ix = xyz[i].index(li[i])
    for j in range(3):
        if j == ix:
            xyz[i+1][j] = xyz[i][j] + 1
        else:
            xyz[i+1][j] = xyz[i][j]

point = 3

for i in range(1,n):
    point *= xyz[i].count(li[i])
    point %= mod
print(point)

Measured memory_bytes: 21992
n=int(input())
count=0
for i in range(1,15):
  count+=26**i
  if count>=n:
    keep=i
    break

for i in range(1,keep):
  n-=26**i

n-=1
lis=[]
for i in range(0,keep):
  t=keep-i-1
  one=n//(26**t)
  lis.append(one)
  n-=one*26**t

ans=""
for i in range(len(lis)):
  ans+=chr(97+lis[i])
print(ans)

Measured memory_bytes: 9212