akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  k: u64,
  }

  let mut  x = 7 % k ;
  let mut cnt = 1;

  let mut s = HashSet::new();
  while !s.contains(&x){
    if  x == 0 {
      println!("{}", cnt);
      return;
    }
    s.insert(x);
    x = (x*10+7) % k;
    cnt += 1;
  }

  println!("{}", "-1");

}


Measured memory_bytes: 29672
x1, y1, x2, y2 = gets.split.map(&:to_i)
a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x1 - b
y4 = y1 + a
puts x3.to_s + " " + y3.to_s + " " + x4.to_s + " " + y4.to_s

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

int gcd(int x, int y) {
  if (y == 0) { return x; }
  return gcd(y, x%y);
}

int A, B, C, D;

int main() {
  cin >> A >> B >> C >> D;  

  int dx = abs(C-A);
  int dy = abs(D-B);

  if (dx == 0) { cout << dy-1 << endl; return 0; }
  if (dy == 0) { cout << dx-1 << endl; return 0; }

  int v = gcd(dx, dy);

  cout << ((( dx + dy - v ))) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string S, T, U;
  int A, B;
  cin>>S>>T>>A>>B>>U;
  if(S==U){
    cout<<A-1<<" "<<B<<endl;
  }else{
    cout<<A<<" "<<B-1<<endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = [int(x)-1 for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = 0
for i, a in enumerate(A):
    ans += B[a]
    if i < N-1 and a + 1 == A[i+1]:
        ans += C[a]
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main() {
  ll N; cin>>N;
  ll ans=0;
  vector<ll> d=divisor(N);
  for(ll v : d){
      ll m=v-1;
      if(m==0) continue;
      if(N/m==N%m) ans+=m;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import itertools

N, M, R = [int(i) for i in input().split()]
rr = [int(i) for i in input().split()]

d = [[1 << 60 for j in range(N)] for i in range(N)]
for i in range(M):
    a, b, c = [int(i) for i in input().split()]
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

ans = 1 << 60
for plan in itertools.permutations(rr):
    cnt = 0
    for i in range(R - 1):
        cnt += d[plan[i] - 1][plan[i + 1] - 1]
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 47320
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,h[N];
main() {
    file("cowdate");
    ios;
    cin>>n;
    fo(i,1,n,1) cin>>h[i];
    fo(i,1,n,1) {
        if (h[i]<h[i-1]) return !(cout<<"No");
        if (h[i]-1>=h[i-1]) --h[i];
    }
    cout<<"Yes";
    return 0;
}
/**

*/


Measured memory_bytes: 640
/*  ex7_3
    takafumi_ueki*/
#include <stdio.h>
#include <stdlib.h>
#define LIMIT 101
int main(void){
    int i, j, length, width;
    char **field;
    int row[LIMIT]={0};
    int col[LIMIT]={0};
    scanf("%d %d\n", &length, &width);
    //各行の配列へのポインタ分のメモリ領域を確保
    field = (char**)calloc(length, sizeof(char*));
    if(field == NULL){
        fprintf(stderr, "calloc error.\n");
        exit(1);
    }
    //各行の要素分のメモリ領域を確保
    for(i = 0; i < length; i++){
        field[i] = (char*)calloc(width, sizeof(char));
        if(field[i] == NULL){
            fprintf(stderr, "calloc error.\n");
            exit(1);
        }
    }
    //マス目が'.'か'#'かを受け取る
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&field[i][j]);
        }
    }
    //列ごとに'#'が含まれているかどうかを調べる
    //もし含まれていたらrow[i]が1になる
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            if(field[i][j]=='#'){
                row[i]=1;
                break;
            }
        }
    }
    //次に行ごとに'#'が含まれていないか調べる
    for(j=0;j<width;j++){
        for(i=0;i<length;i++){
            if(field[i][j]=='#'){
                col[j]=1;
                break;
            }
        }
    }
    //もし,'#'がひとつでも含まれていたらその行、列は書き出すようにする
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            if(row[i]==1&&col[j]==1){
                printf("%c",field[i][j]);
            }
        }
        printf("\n");
    }
    //メモリ領域の解放，各行の要素分の領域を開放し，
    //各行の配列へのポインタの領域を解放
    //（メモリ領域の確保と逆順）
    for(i = 0; i < length; i++){
        free(field[i]);
    }
    free(field);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

typedef long long ll;

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

  int n = s.size();
  rep(i,n){
    s[i] = 'x';
  }

  cout << s << endl;

}

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

long long int gcd (long long int a,long long int b )
{
  long long int c;
  while ( a != 0 ) {
     c = a; a = b%a;  b = c;
  }
  return b;
}

long long int lcm(long long int x, long long int y)
{
  return x/gcd(x,y)*y;
}

int main(){
  long long int n;
  cin>>n;
  vector<long long int> t(n);
  for(long long int i=0;i<n;i++)cin>>t[i];

  long long int ans=t[0];
  for(int i=1;i<n;i++)ans=lcm(ans,t[i]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
r1,c1,r2,c2=map(int,input().split())
INF=10**9+7
def modcomb(n,k,m):
    fac=[0]*(n+1)
    finv=[0]*(n+1)
    inv=[0]*(n+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,n+1):
        fac[i]=fac[i-1]*i%m
        inv[i]=m-inv[m%i]*(m//i)%m
        finv[i]=finv[i-1]*inv[i]%m
    return fac[n]*(finv[k]*finv[n-k]%m)%m
def modinv(a,m):
    b=m
    (x,lastx)=(0,1)
    (y,lasty)=(1,0)
    while not b==0:
        q=a//b
        (a,b)=(b,a%b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%m
ans=modcomb(r1+c1,r1,INF)
c=modcomb(r2+c1,c1,INF)
for i in range(c1+1,c2+1):
    c=c*(i+r2)
    x=modinv(i,INF)
    c=(c*x)%INF
    ans=(ans+c)%INF
c=modcomb(r1+c2,r1,INF)
for i in range(r1+1,r2+1):
    c=c*(i+c2)
    x=modinv(i,INF)
    c=(c*x)%INF
    ans=(ans+c)%INF
print(ans)

Measured memory_bytes: 126840
n=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(1,n):
    if i%2==1:
        s.append(a[i])
A=sum(a)
ans=[0]*n
ans[0]=A-2*sum(s)
for i in range(1,n):
    ans[i]=2*a[i-1]-ans[i-1]
print(*ans)

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n),b(n-1);
    for (int i = 0; i < n-1; i++)
    {
        cin>>b[i];
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    for (int i = 1; i < n-1; i++)
    {
        a[i]=min(b[i-1],b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        ans+=a[i];
    }
    
    
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int i=0,j=0, x, y, sd[3000],ld[3000];
    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x > y) {
            sd[i] = y;
            ld[i] = x;

        }else{
            sd[i] = x;
            ld[i] = y;
        }
        i++;
    }
    while (j != i) {
        cout << sd[j] <<" "<< ld[j] << endl;
        j++;
    }
    return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    VEC(ll,a,N);
    REP(i,N){
        cin>>a[i];
    }
    REP(i,(N+1)/2){
        cout<<a[N-1-i*2]<<" ";
    }
    REP(i,(N)/2){
        cout<<a[(N%2==0?0:1)+i*2]<<" ";
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll x, y;
    in2(x,y);
    if(abs(x)==abs(y)){
        puts("1");
        return 0;
    }
    if(!x || !y){
        if(x<y) put(abs(y)+abs(x));
        else put(abs(y)+abs(x)+1);
    }
    else if(x*y>0){
        if(x<y) put(y-x);
        else put(x-y+2);
    }
    else {
        if(x<y){
            if(abs(x)>y) put(-y-x+1);
            else put(y-abs(x)+1);
        }
        else {
            if(x>abs(y)) put(x-abs(y)+1);
            else put(abs(y)-x+1);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  ll ans = 0LL;

  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < 60; i++) {
    ll t = 0;
    for(int j = 0; j < N; j++) {
      if(A[j] & (1LL << i)) t++;
    }
    ans = (ans+(((t*(N-t))%mod)*((1LL<<i)%mod))) % mod;
  }
  cout << ans << endl;
  return 0;
}


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

int H,W,C;
int INF=1e8;

vector<int> Gy,Gx;
char t[60][60];
int dp[50][50][50][50];

int dfs(int ay,int ax,int by,int bx){
  if(ay<0||ax<0||by<0||bx<0)return -INF;
  if(ay>=H||ax>=W||by>=H||bx>=W)return -INF;
  if(by<ay||bx<ax)return -INF;
  if(t[ay][ax]=='#'||t[by][bx]=='#')return -INF;
  if(ay==by&&ax==bx)return 0;

  if(dp[ay][ax][by][bx]!=-1)return dp[ay][ax][by][bx];
  int res=-INF;
  
  if('a'<=t[ay][ax]&&t[ay][ax]<='z'&&t[ay][ax]-'a'+'A'==t[by][bx]){
    if( (by-ay) + (bx-ax) == 1 )res=max(res,1);
    res=max(res,dfs(ay+1,ax,by-1,bx)+1);
    res=max(res,dfs(ay+1,ax,by,bx-1)+1);
    res=max(res,dfs(ay,ax+1,by-1,bx)+1);
    res=max(res,dfs(ay,ax+1,by,bx-1)+1);
  }
  
  res=max(res,dfs(ay+1,ax,by,bx));
  res=max(res,dfs(ay,ax+1,by,bx));
    
  for(int i=0;i<(int)Gy.size();i++){
    int y=Gy[i],x=Gx[i];
    if(y==ay&&x==ax)continue;
    if(y==by&&x==bx)continue;
    
    if(ay<=y && y<=by)
      if(ax<=x && x<=bx)
        res=max(res,dfs(ay,ax,y,x)+dfs(y,x,by,bx));
  }

  return dp[ay][ax][by][bx]=res;
}

int main(){
  while(1){
    cin>>H>>W;
    if(H==0&&W==0)break;
    Gy.clear();
    Gx.clear();
    memset( dp , -1 , sizeof(dp) );
    for(int i=0;i<H;i++){
      scanf("%s",t[i]);
      for(int j=0;j<W;j++){
        if('A'<=t[i][j]&&t[i][j]<='Z'){
          Gy.push_back(i);
          Gx.push_back(j);
        }
      }
    }
    cout<< max(-1,dfs(0,0,H-1,W-1)) <<endl;
  }
  return 0;
}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll a, b, c;
  cin >> a >> b >> c;
  //cout << fixed << setprecision(10) << sqrt(1e9*(1e9-1)) << endl;
  if (c-a-b <= 0) {
    puts("No");
  }
  else {
    if (4*a*b < (c-a-b)*(c-a-b)) yn;
  }
  return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5+5;

void solve() {

  int n,k,ans=0;
  cin>>n>>k;
  vi a(n);
  rep(i,0,n)
    cin>>a[i];
  sort(all(a));
  rep(i,0,k)
    ans+=a[i];
  cout<<ans;
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}







int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


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

using namespace std;

const int MAXN = 1e5+3;
int f[MAXN];

int main() {
	int n, q, l, r;
	string s;
	cin >> n >> q;
	cin >> s;
	for (int i=1; i<n; i++)
	{
		if (s[i] == 'C' && s[i-1] == 'A') {
			f[i] = f[i-1] + 1;
		} else f[i] = f[i-1];
	}
	for (int qq=0; qq<q; qq++) {
		cin >> l >> r;
		l--; r--;
		if (s[l] == 'C') l++;
		if (l == 0) cout << f[r] << endl; else cout << f[r] - f[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
n = int(input())
ans = ""
while n > 0:
    re = n % 26
    if re != 0:
        ans = chr(ord('a') + (re - 1)) + ans
        n = n // 26
    else:
        ans = 'z' + ans;
        n = n // 26 - 1
print(ans)

Measured memory_bytes: 9076
/*
Author : N_o_o_B
Created : April 22 2020 16:01:40 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    set<char> S={'A','T','G','C'};

    string s;
    cin >> s;
    int n = sz(s);
    int best = 0;
    fori(i,n){
        int len = 0;
        rep(j,i,n-1){
            if(S.count(s[j])) len++;
            else break;
        }
        best = max(best,len);
    }
    cout << best << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

   int arr[200];

   ll sum=0;

   int n,m;
   cn n>>m;

   for(int k=0; k<n ; k++){
       
       cn arr[k];

       sum+=arr[k];
   
   }

   int cnt=0;

   for(int k=0; k<n ; k++){
       
       if(arr[k]*4*m>=sum)cnt++;
   
   }

   if(cnt>=m)ct "Yes";
   else ct "No";
   nl;





    return 0;
}


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

namespace AtCoder
{
    class Abc162F
    {
        public static void Main()
        {
            var n = Double.Parse(Console.ReadLine());
            var pai = 22.0 / 7.0;
            var ans = Convert.ToDouble(2*pai * n);
            Console.Write(ans);
        }
    }
}


Measured memory_bytes: 18628
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


template <typename T>
inline std::string to_bin_str(T n, std::size_t digit_num) {
    std::string str;
    while (n > 0) {
        str.push_back('0' + (n & 1));
        n >>= 1;
    }
    str.resize(digit_num, '0');
    std::reverse(str.begin(), str.end());
    return str;
}

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


int main(void){
	int N;	cin >> N;
  int A[N];

  int ans = 0;

  rep(i,N)  {
    int a;
    cin >> a;
    A[i] = a;
  }
  sort(A, A+N);

  int one = A[0];
  int two = A[1];
  int g_m = INF;
  int min_idx_1 = 0;
  int min_idx_2 = 0;
  rep(i,N)  {
    int a;
    a = gcd(one, A[i]);
    if (a <= g_m) {
        min_idx_1 = i;
        g_m = a;
    }
  }
  // cout << min_idx_1 << endl;
  g_m = INF;
  reps(i,N-1)  {
    int a;
    a = gcd(two, A[i]);
    if (a <= g_m) {
        min_idx_2 = i;
        g_m = a;
    }
  }
  // cout << min_idx_2 << endl;

  if (min_idx_1 == 1) ans = 1;
  else if (min_idx_1 == min_idx_2)  ans = min_idx_1;
  else ans = 0;

  int b = A[0];
  if (ans == 0) b = A[1];
  reps(i,N-1)  {
    if (i != ans) {
      b = gcd(b,A[i]);
    }
  }
  int c = A[1];
  reps(i,N-1)  {
    c = gcd(c,A[i]);
  }
	cout << max(b, c) << endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string> // to_string()
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define scan(argument) cin>>argument

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string n;
  int k;
  scan(n); scan(k);
  int di = n.length();

  int dp0[di+1][k+1];
  int dp1[di+1][k+1];

  REP1(i, di){
    dp0[i][0] = 1; // 0, 00, 000, ...
    dp1[i][0] = 0;
  }

  dp0[1][1] = (int)(n[0]-'0')-1; // 1 ~ n[0]-1
  dp1[1][1] = 1; // n[0]
  FOR(j, 2, k+1){
    dp0[1][j] = 0;
    dp1[1][j] = 0;
  }

  REP1(i ,di-1){ // 上からi桁目まで決めて
    REP(j, k){ // 0でない桁がj個ある
      int ni = (int)(n[i]-'0'); // 上からi+1番目
      if(ni == 0){
        dp0[i+1][j+1] = dp0[i][j]*9 + dp0[i][j+1]; // 1~9, 0
        dp1[i+1][j+1] = dp1[i][j+1]; // 0
      }
      else{
        dp0[i+1][j+1] = dp0[i][j]*9 + dp0[i][j+1]  // 1~9, 0
                      + dp1[i][j]*(ni-1) + dp1[i][j+1]; // 1~ni-1, 0
        dp1[i+1][j+1] = dp1[i][j];
      }
    }
  }

  cout << dp0[di][k] + dp1[di][k] << "\n";

  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
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 gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    vector<ll> A(3);
    cin >> A[0] >> A[1] >> A[2];

    sort(A.begin(), A.end());

    ll diff = (A[2]-A[1] + A[2]-A[0]);
    
    if(diff%2 == 0){
        cout << diff/2 << endl;
    }
    else{
        cout << (diff+3)/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
bbn=1000000007
	
#+++++
		
def main():
	s = input()
	n=0
	for i,c in enumerate(s[:(len(s)//2)]):
		#pa((c,s[-1*(i+1)]))
		if c != s[-1*(i+1)]:
			n+=1
	
	print(n)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9

let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let s = Array.init (n + 1) @@ fun i -> i

let to_s arr = arr |> Array.map string_of_int |> Array.to_list |> String.concat " " |> print_endline

let () =
  Array.iteri(fun i _ -> if i > 0 then s.(i) <- s.(i) + s.(i - 1)) s;
  let ans = Array.init (n - k + 2) @@ fun i -> i + k in
  ans 
    |> Array.map (fun i -> s.(n) - s.(max (n - i) 0) - s.(i - 1) + 1)
    |> Array.fold_left ( +^) 0
    |> print_int;
  print_newline ()


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

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

    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    int ans = 1LL<<62;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
        for (int k = 0; k < N; k++) for (int l = 0; l < N; l++) {
            int cnt = 0;
            for (int a = 0; a < N; a++) {
                cnt += !(x[a] < x[i] || x[a] > x[j] || y[a] < y[k] || y[a] > y[l]);
            }
            if (cnt >= K) {
                ans = min(ans, abs(x[i] - x[j]) * abs(y[k] - y[l]));
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(N + M);
	for (int i = 0; i < N; i++) {
		A.at(i) = 2;
	}
	for (int i = N; i < N + M; i++) {
		A.at(i) = 1;
	}
	int ans = 0;
	for (int i = 0; i < N + M - 1; i++) {
		for (int j = i + 1; j < N + M; j++) {
			if ((A.at(i) + A.at(j)) % 2 == 0) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  println(readIs().indexOf(0) + 1)
}


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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

int main(void) {
    int K, X;

    cin >> K >> X;

    for (int i = X - K + 1; i < X + K; i++) {
        cout << i << " ";
    }
    
    cout << endl;

    return 0;
}


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

bool check(vector<pair<int, int>> s) {
    int h = 0;
    for (auto p : s) {
        int b = h + p.first;
        if (b < 0)
            return false;
        h += p.second;
    }
    return true;
}

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

    vector<pair<int, int>> pl, mn;
    int sum = 0;
    rep(i, n) {
        string s;
        cin >> s;

        int h = 0, mi = 0;
        for (auto c : s) {
            if (c == '(')
                ++h;
            else
                --h;
            mi = min(mi, h);
        }

        if (h > 0)
            pl.emplace_back(mi, h);
        else
            mn.emplace_back(mi - h, -h);
        sum += h;
    }

    sort(pl.rbegin(), pl.rend());
    sort(mn.rbegin(), mn.rend());

    if (sum == 0 && check(pl) && check(mn))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 18852
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

a#b = abs$a-b
main = B.interact$B.pack.show.f.unfoldr(B.readInt.B.dropWhile isSpace)
f (n:h1:h2:hr)=s 0 (h2#h1) (take n (h1:h2:hr))
s _ c [_,_] = c
s c1 c2 (h1:h2:h3:hr)=s c2 (min (c1+h3#h1) (c2+h3#h2)) (h2:h3:hr)


Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
const int maxn=3e3+5;
typedef long long ll;
inline ll fpm(ll a,ll p,ll mod){
	ll res=1;
	while(p){
		if (p&1) res=res*a%mod;
		a=a*a%mod;
		p/=2;
	}
	return res;
}
int n;
int mod;
ll s[maxn][maxn];
ll fac[maxn],inv[maxn];
inline void init(){
	s[0][0]=1;
	for (int i=1;i<=n+1;i++){
		for (int j=1;j<=i;j++){
			s[i][j]=(s[i-1][j-1]+1ll*j*s[i-1][j]%mod)%mod;
		}
	}
	fac[0]=inv[0]=1;
	for (int i=1;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=fpm(fac[i],mod-2,mod);
		//cout<<"print fac inv "<<fac[i]<<' '<<inv[i]<<endl;
	}
}
inline ll getc(ll n,ll m){
	if (n<m||n<0||m<0) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
inline ll f(int i){
	ll cur=1,a=fpm(2,n-i,mod);
	ll b=fpm(2,fpm(2,n-i,mod-1),mod);
	ll ans=0;
	for (int k=0;k<=i;k++){
		ans=(ans+s[i+1][k+1]*cur%mod*b%mod)%mod;
		cur=cur*a%mod;
	}
	return ans;
}
int main(){
	cin>>n>>mod;
	init();
	ll ans=0;
	for (int i=0;i<=n;i++){
		ll tp=getc(n,i)*f(i)%mod;
		//cout<<"print getc f "<<getc(n,i)<<' '<<f(i)<<endl;
		if (i%2==0) ans=(ans+tp)%mod;
		else ans=(ans+mod-tp)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 49804
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  ll k,n,ans=0; cin>>k>>n;
  vector<ll> a(n),d(n);
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=1; i<n; i++){
    d[i] = a[i] - a[i-1];
    ans += d[i];
  }
  d[0] = k - a[n-1] + a[0];
  ans += d[0];
  sort(d.begin(),d.end());
  cout<<ans-d[n-1];
}

Measured memory_bytes: 3328
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]-=1
visit=[False for i in range(n)]
visit[0]=True
looplist=[False for i in range(n)]
mark=-1
i=0
num=0
loop=0
count=0
while True:
  num+=1
  i=a[i]
  if mark<0 and visit[i]:
    mark=a[i]
  else:
    visit[i]=True
  if mark>-1 and looplist[i]:
    count=num-loop*2
    break
  elif mark>-1:
    loop+=1
    looplist[i]=True
if k < count:
  pass
else:
  k-=count
  k%=loop
  k+=count
ans=0
for i in range(k):
  ans=a[ans]
print(ans+1)

Measured memory_bytes: 32408
def perm(k,x):
    v=[]
    for i in range(x):
        c=k%x+2
        if c not in v:
            v.append(c)
            k//=x
        else:
            return []
    return v       

N,M=map(int,input().split())
e=[[False for i in range(N+1)] for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    e[a][b]=e[b][a]=True

if N==2:
    ans=1 if e[1][2] else 0
else:
    ans=0
    for k in range((N-1)**(N-1)):
        v=perm(k,N-1)
        if v and e[1][v[0]]:
            f=True
            for j in range(N-2):
                if not e[v[j]][v[j+1]]:
                    f=False
                    break
                if j==N-3:
                    ans+=1

print(ans)

Measured memory_bytes: 43868
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
import math
import fractions
from heapq import heappush, heappop


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
    # return (x * y) * modinv(fractions.gcd(x, y), MOD)


N = int(input())
A = list(map(int, input().split()))

lm = 1
s = 0

for i in range(N):
    lm = lcm(A[i], lm)
    #s += lm // MOD
    #lm %= MOD

lm %= MOD
# print(lm)
ans = 0
for i in range(N):
    m = modinv(A[i], MOD)
    ans += lm * m
    ans %= MOD

print(ans)


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

int n;
int t[12][12];

int main(void){
	while(cin>>n,n){
		memset(t,0,sizeof(t));
		for(int i=0;i<=n;i++){
			for(int j=0;j<n;j++){
				if(i != n){
					cin>>t[i][j];
					t[n][j] += t[i][j];
				}
				t[i][n] += t[i][j];
			}
		}

		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				printf("%5d",t[i][j]);
			}
			cout<<endl;
		}
	}

	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

const ll MOD = ll(1e9 + 7);

vector<ll> dp1;
vector<ll> dp2;

ll solve(const string L, const int len) {
    for (int i = 0; i < len; i++) {
        int bit = (L[i + 1] == '1') ? 1 : 0;
        // dp1
        if (bit == 1) {
            dp1[i + 1] = (dp1[i + 1] + 2 * dp1[i]) % MOD;
            dp2[i + 1] = (dp2[i + 1] + dp1[i]) % MOD;
        } else {
            dp1[i + 1] = (dp1[i + 1] + dp1[i]) % MOD;
        }

        // dp2
        dp2[i + 1] = (dp2[i + 1] + 3 * dp2[i]) % MOD;
    }

    return (dp1[len] + dp2[len]) % MOD;
}

int main(void) {
    string L;
    cin >> L;
    int len = (int) L.size();
    L = " " + L;

    dp1.resize(len + 1, 0);
    dp2.resize(len + 1, 0);
    dp1[0] = 1;

    cout << solve(L, len) << endl;

    // cout << "dp1: " << endl;
    // for (int i = 0; i <= len; i++) {
    //     cout << dp1[i] << " ";
    // }
    // cout << endl;

    // cout << "dp2: " << endl;
    // for (int i = 0; i <= len; i++) {
    //     cout << dp2[i] << " ";
    // }
    // cout << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a;
  int t;
  bool odd = (bool)n%2;
  for(int i = 0; i< n ;i++) {
		cin >> t;
    	if(odd)
    		a.push_back(t);
    	else
        	a.insert(a.begin(),t);
    	odd = !odd;
  }
  if(n%2 != 0)
    reverse(a.begin(),a.end());
  for(int i = 0; i< n-1 ;i++) {
		cout << a[i] <<" ";
  }
  cout<< a[n-1] << endl;
}


Measured memory_bytes: 3060
/**
 *    created by : PawPaw       
**/

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

using namespace __gnu_pbds;  
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,  
        tree_order_statistics_node_update>  
        ordered_set;  

#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LL long long
#define N 1000001
#define PB push_back
#define MP make_pair
#define FbO find_by_order
#define OoK order_of_key

int solve(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust\n";
  else cout << "win\n";
  return 0;
}

void fun(){
  int t = 1;
  // cin >> t;
  while(t--) solve();
} 

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

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, a, count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &a);
		if (i % 2 == 1 && a % 2 == 1) count++;
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1688
t = int(input())
mod = 10**9 + 7

if t==1:
  print(0)
else:
  kans = 1
  for i in range(t):
    kans *= 10
    kans = kans % mod
  
  ans = 1
  for i in range(t):
    ans *= 9
    ans = ans % mod
    
  bans = 1
  for i in range(t):
    bans *= 8
    bans = bans % mod
    
  f = kans - ans*2 + bans
  f = f%mod
  
  print(f)


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

typedef long long int ll;



int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
 
    return 0;
}


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

using namespace std;

int main()
{
	int n, m, c[10][10], a[200][200];
	long long s = 0;
	cin >> n >> m;
	
	for (int i = 0; i < 100; i++)
		cin >> c[i/10][i%10];
		
	for (int k = 0; k < 10; k++)
		for (int i = 0; i < 10; i++)
			for (int j = 0; j < 10; j++)
				c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
			
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
			
			if (a[i][j] >= 0)
				s += c[a[i][j]][1];
		}
		
	cout << s;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    ll power = 1;
    ll mod;
    for (int i = 2; i <= N; i++)
    {
        mod = i % (1000000000 + 7);
        power = (mod * power) % (1000000000 + 7);
    }

    cout << power << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iterator>
#include <list>
#include <algorithm>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  // const string 
  //   str_insert = "insert",
  //   str_delete = "delete",
  //   str_delete_first = "deleteFirst",
  //   str_delete_last = "deleteLast";

  int N;
  cin >> N;
  
  list<int> l;
  // typedef enum{INS, DEL, DEL_F, DEL_L}
  // command;
  
  for(int i = 0; i < N; ++i){
    string s;
    cin >> s;

    //command c;
    if (s[0] == 'i'){
      int n;
      cin >> n;
      l.push_front(n);
      //break;
    }
    else if(s.size() == 6){
      int n;
      cin >> n;
      auto itr = find(l.begin(), l.end(), n);
      if(itr != l.end()){l.erase(itr);}
      //break;
    }
    else if(s[6] == 'F'){
      l.pop_front();
      //break;
    }
    else if(s[6] == 'L'){
      l.pop_back();
      //break;
    }

    // cout << *(l.begin());
    // for(std::list<int>::iterator itr = next(l.begin()); itr!=l.end(); ++itr){
    //   cout << ' ' << *itr;
    // }
    // cout << endl;

  }

  cout << *(l.begin());
  for(std::list<int>::iterator itr = next(l.begin()); itr!=l.end(); ++itr){
    cout << ' ' << *itr;
  }
  cout << endl;

  return 0;
}

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


int main() {
  string A, B, ans;
  cin >> A >> B;
  ans = B + A;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long i,a=0,b=0;
  char s[200010];
  scanf("%s",s);
  for(i=0;s[i];i++){
    if(s[i]=='B')a++;
    else         b+=a;
  }
  printf("%lld\n",b);
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
   public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
  		String t = scanner.nextLine();
  		String t1 = t.replaceAll("eraser", "");
        String t2 = t1.replaceAll("erase", "");
        String t3 = t2.replaceAll("dreamer", "");
        String t4 = t3.replaceAll("dream", "");
     boolean flag = false;	
      if(t4.isEmpty()){
      System.out.println("YES");
      }else{
      System.out.println("NO");
        }
      }
   }

Measured memory_bytes: 28756
#include<iostream>

int main(void){
    int n;
    std::cin >> n;
    int a;
    for(int i = 0; i < n; i++){
	std::cin >> a;
	if(a % 2 == 0){
	    if(a % 3 != 0 && a % 5 != 0){
		std::cout << "DENIED" << std::endl;
		return 0;
	    }
	}
    }
    std::cout << "APPROVED" << std::endl;
    return 0;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>

long solve(long a, long b, long c, long d)
{
  long max = -std::numeric_limits<long>::max();
  max = std::max(max, a * c);
  max = std::max(max, a * d);
  max = std::max(max, b * c);
  max = std::max(max, b * d);
  return max;
}

int main()
{
  long a, b, c, d;
  std::cin >> a >> b >> c >> d;

  std::cout << std::setprecision(20);
  std::cout << solve(a, b, c, d) << std::endl;
}


Measured memory_bytes: 3668
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <map>
#include <set>
using namespace std;
int a[100005];
int gcd(int a,int b) {return b==0?a:gcd(b,a%b);}
int main()
{
    //reopen("2.txt","w",stdout);
    int n,k;
    scanf("%d%d",&n,&k);
    bool ok1=false,ok2=false;
    for(int i=0;i<n;++i) 
    {
        scanf("%d",&a[i]);
        if(a[i]>k) ok2=true;
        if(a[i]==k) ok1=true;
    }
    if(ok1) printf("POSSIBLE\n");
    else if(ok2)
         {
            int g=a[0];
            for(int i=0;i<n;++i) g=gcd(g,a[i]);
            if(k%g) printf("IMPOSSIBLE\n");
            else printf("POSSIBLE\n");
         }
         else printf("IMPOSSIBLE\n");
    return 0;
}

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

int main(){
  int64_t a,b,c;
  cin >> a >> b >> c;
  int64_t d = c-a-b;
  if(d>0 && 4*a*b<d*d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256