akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define rrep(i,a,b) for(int(i)=(a);(i)>(b);i--)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'
#define PHAS(_n) (pbits[(_n)>>5] & (1u << ((_n) & 0x1f)))
#define PSET(_n) (pbits[(_n)>>5] |= (1u << ((_n) & 0x1f)))
//unsigned int pbits[200000000/32+1];

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_N = 100001;

/*
struct data{
  string s;
  int p,i;
  data():s(""), p(0), i(0){};
  data(string s_, int p_, int i_) : s(s_),p(p_), i(i_){};
  bool operator < (data other) const {
	if(s==other.s)
		return p>other.p;
    return s < other.s;
  }
};
*/

int arr[3*MAX_N];

void rarr(int n){
        rep(i,0,n)
            cin>>arr[i];
}

int dp[MAX_N];
int mod = 1000000007;

int solve(int idx,int n)
{
    if(idx==n)return 1;
    if(idx>n)return 0;
    if(~dp[idx])return dp[idx];
    if(arr[idx]==-1) return dp[idx]=0;
    return dp[idx]=(solve(idx+1,n)%mod+solve(idx+2,n)%mod)%mod;
}

int main()
{
        init_io();
        int n,m;
        CL(dp,-1);
        cin>>n>>m;
        rep(i,0,m)
        {
            int x ;
            cin>>x;
            arr[x]=-1;
        }
        cout<<solve(0,n)<<endl;
        return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
typedef std::pair<int,int> P;
const int MAX=1e9;
int way[201][201];
int mi[201][201];
using namespace std;

int main(){
  int N,M,R;
  cin>>N>>M>>R;
  std::vector<int> r(R);
  for(int i=0;i<R;i++)cin>>r[i];
  int A,B,C;
  for(int i=0;i<201;i++)for(int j=0;j<201;j++)way[i][j]=MAX;
  for(int i=0;i<M;i++){
    cin>>A>>B>>C;
    way[A][B]=C;
    way[B][A]=C;
  }
  queue<int> que;
  std::vector<int> d(N+1,MAX);
  for(int i=0;i<R;i++){
    for(int j=i+1;j<R;j++){
      for(int k=0;k<N+1;k++)d[k]=MAX;
      d[r[i]]=0;
      que.push(r[i]);
      while(que.size()){
        int aa=que.front();
        que.pop();
        for(int k=0;k<N+1;k++){
          if(d[k]>d[aa]+way[aa][k]){
            d[k]=d[aa]+way[aa][k];
            que.push(k);
          }
        }
      }
      mi[r[i]][r[j]]=d[r[j]];
      mi[r[j]][r[i]]=d[r[j]];
    }
  }
  int ans=MAX;
  std::vector<int> v(R);
  for(int i=0;i<R;i++)v[i]=i;
  while(std::next_permutation(v.begin(),v.end())){
    int bbb=0;
    for(int i=1;i<R;i++)bbb+=mi[r[v[i-1]]][r[v[i]]];
    ans=min(ans,bbb);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin>>x;
	ll curr = 0;
	ll timer = 1;
	while(curr<=x) curr+=timer++;
	timer--;
	curr-=timer;
	timer--;
	if(curr==x) cout<<timer;
	else cout<<timer+1;
}

Measured memory_bytes: 3576
gets
s = gets.chomp
now = []
now[0] = "S"
mae = "S"
h = mae
s.size.times do |d|
  if((s[d] == "o" and now[d] == "S") or (s[d] == "x" and now[d] == "W"))
    now[d+1] = mae
  else
    now[d+1] = (mae == "S")? "W" : "S"
  end
  mae = now[d]
end
if (now[0] == now[-1] and h == now[-2])
  now.delete_at(-1)
  puts now.join("")
  exit
end
now = []
now[0] = "S"
mae = "W"
h = mae
s.size.times do |d|
  if((s[d] == "o" and now[d] == "S") or (s[d] == "x" and now[d] == "W"))
    now[d+1] = mae
  else
    now[d+1] = (mae == "S")? "W" : "S"
  end
  mae = now[d]
end
if (now[0] == now[-1] and h == now[-2])
  now.delete_at(-1)
  puts now.join("")
  exit
end
now = []
now[0] = "W"
mae = "S"
h = mae
s.size.times do |d|
  if((s[d] == "o" and now[d] == "S") or (s[d] == "x" and now[d] == "W"))
    now[d+1] = mae
  else
    now[d+1] = (mae == "S")? "W" : "S"
  end
  mae = now[d]
end
if (now[0] == now[-1] and h == now[-2])
  now.delete_at(-1)
  puts now.join("")
  exit
end
now = []
now[0] = "W"
mae = "W"
h = mae
s.size.times do |d|
  if((s[d] == "o" and now[d] == "S") or (s[d] == "x" and now[d] == "W"))
    now[d+1] = mae
  else
    now[d+1] = (mae == "S")? "W" : "S"
  end
  mae = now[d]
end
if (now[0] == now[-1] and h == now[-2])
  now.delete_at(-1)
  puts now.join("")
  exit
end
p -1

Measured memory_bytes: 7076
//
//  towns.cpp
//  
//
//  Created by Òscar Balcells on 09/02/2019.
//

#include <iostream>
#include <vector>

using namespace std;

vector<int> connections;

int main() {
    
    int a, b;
    
    vector<int> connections(5);
    
    scanf("%d %d", &a, &b);
    connections[a]++;
    connections[b]++;
    
    scanf("%d %d", &a, &b);
    connections[a]++;
    connections[b]++;
    
    scanf("%d %d", &a, &b);
    connections[a]++;
    connections[b]++;
    
    if(connections[1] == 2 && connections[2] == 2 && connections[3] == 1 && connections[4] == 1) {
        printf("YES\n");
    } else if(connections[1] == 2 && connections[2] == 1 && connections[3] == 2 && connections[4] == 1) {
        printf("YES\n");
    } else if(connections[1] == 2 && connections[2] == 1 && connections[3] == 1 && connections[4] == 2) {
        printf("YES\n");
        
    } else if(connections[1] == 1 && connections[2] == 2 && connections[3] == 2 && connections[4] == 1) {
        printf("YES\n");
    } else if(connections[1] == 1 && connections[2] == 2 && connections[3] == 1 && connections[4] == 2) {
        printf("YES\n");
    }
    
    else if(connections[1] == 1 && connections[2] == 1 && connections[3] == 2 && connections[4] == 2) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    
    
    return 0;
}


Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 2e5+10;

int main()
{
	_SAD()
	 int n,m;
	cin>>n>>m;
        int a[n];
	long long int  SUM=0;
	rep(i,n)
	{
          cin>>a[i];
	 // SUM+=a;
	}
	SRT(a,n);
	for(int i=0;i<n-m;i++)
	{
		SUM+=a[i];
	}
       /* if(SUM>=n)
	{
		cout<<"Yes"<<nl;
	}
	else
	   {
		cout<<"No"<<nl;
	   }*/
	cout<<SUM<<nl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    
    long long int n,k,ans=0,temp=0,min=0,max=0,counter,tool;
    cin>>n>>k;
    for(int i=k;i<=n+1;i++)
    {
        //cout<<(i-1)<<endl<<(n+n-i+1)<<endl;
        tool=i;
        //cout<<i<<endl<<max<<endl;
        min=(tool-1)*(tool)/2;
        max=(n+n-tool+1)*(tool)/2;
        //cout<<min<<endl<<max<<endl;
        temp=max-min+1;
        ans+=temp;
    }
    
    
    cout<<ans%1000000007<<endl;
    return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);
    static int[] t;
    static int n, q;
    public static void main(String[] args) {
        n = sc.nextInt();
        q = sc.nextInt();
        int[] colors = new int[n];
        int[] lastPos = new int[n];
        Arrays.fill(lastPos, -1);
        int[] next = new int[n];
        Arrays.fill(next, -1);
        t = new int[n];
        for (int i = 0; i < n; i++) {
            colors[i] = sc.nextInt() - 1;
            if (lastPos[colors[i]] != -1) {
                next[lastPos[colors[i]]] = i;
            } else {
                add(i, 1);
            }
            lastPos[colors[i]] = i;
        }
        Query[] queries = new Query[q];
        for (int i = 0; i < q; i++) {
            queries[i] = new Query(sc.nextInt() - 1, sc.nextInt() - 1, i);
        }
        Arrays.sort(queries, Comparator.comparingInt(o -> o.from));
        int curFr = 0;
        int[] res = new int[q];
        for (Query query : queries) {
            while (curFr != query.from) {
                int ne = next[curFr];
                if (ne != -1) {
                    add(ne, 1);
                }
                add(curFr, -1);
                curFr++;
            }
            res[query.id] = get(query.to);
        }
        for (int x : res) {
            pw.println(x);
        }
        pw.flush();
    }

    static void add(int pos, int x) {
        for (; pos < n; pos |= pos + 1) {
            t[pos] += x;
        }
    }

    static int get(int pos) {
        int r = 0;
        for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
            r += t[pos];
        }
        return r;
    }

    static class Query {
        int from, to, id;
        public Query(int from, int to, int id) {
            this.from = from;
            this.to = to;
            this.id = id;
        }
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 88064
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int xsize, ysize, k;
  cin >> ysize >> xsize >> k;
  vector<vector<char>> c(xsize, vector<char>(ysize));
  rep(y, ysize) {
    rep(x, xsize) { cin >> c[x][y]; }
  }
  int res = 0;
  for (int xflag = 0; xflag < (1 << xsize); xflag++) {
    for (int yflag = 0; yflag < (1 << ysize); yflag++) {
      int temp = 0;
      for (int x = 0; x < xsize; x++) {
        for (int y = 0; y < ysize; y++) {
          if ((xflag & (1 << x)) && (yflag & (1 << y))) {
            temp += c[x][y] == '#';
          }
        }
      }
      if (temp == k) res++;
    }
  }
  cout << res << endl;
  ret;
}


Measured memory_bytes: 3652
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

typedef pair<ll, ll> P;

int main() {
  int h, w; cin >> h >> w;
  vector<string> S(h);
  loop(i,0,h) cin >> S[i];
  loop(j,0,w+2) cout << '#'; cout << endl;
  loop(i,0,h) {
    cout << '#' << S[i] << '#' << endl;
  }
  loop(j,0,w+2) cout << '#'; cout << endl;
  return 0;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  int slen=S.length();
  int tlen=T.length();
  int cnt=0;
  int maxcnt=0;
  for(int i=0;i<slen-tlen+1;i++){
    cnt=0;
    for(int j=0;j<tlen;j++){
      if(T.at(j)==S.at(j+i)){
        cnt++;
      }
    }
    maxcnt=max(maxcnt,cnt);
  }
  cout<<tlen-maxcnt<<endl;
  return 0;
}

 

Measured memory_bytes: 3632
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

// 再帰関数による深さ優先探索
void dfs_visit(int u)
{
  int v;
  color[u] = GRAY;
  d[u] = ++tt; // 最初の訪問
  for (v = 0; v < n; v++)
  {
    if (M[u][v] == 0)
      continue;
    if (color[v] == WHITE)
    {
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs()
{
  int u;
  // 初期化
  for (u = 0; u < n; u++)
    color[u] = WHITE;
  tt = 0;

  for (u = 0; u < n; u++)
  {
    // 未訪問のuを始点として深さ優先探索
    if (color[u] == WHITE)
      dfs_visit(u);
  }
  for (u = 0; u < n; u++)
  {
    printf("%d %d %d\n", u + 1, d[u], f[u]);
  }
}

int main()
{
  int u, v, k, i, j;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      M[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++)
  {
    scanf("%d %d", &u, &k);
    u--;
    for (j = 0; j < k; j++)
    {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;
}



Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> happy(3, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> happy[0][i] >> happy[1][i] >> happy[2][i];
    }

    vector<vector<int>> dp(3, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            if (i == 0) {
                dp[j][0] = happy[j][0];
            }
            dp[j][i] = max(dp[(j+1)%3][i-1]+happy[(j+1)%3][i],dp[(j+2)%3][i-1]+happy[(j+2)%3][i]);
        }
    }
    int max = 0;
    for (int i = 0; i < 3; i++) {
        if (dp[i][n-1] > max) {
            max = dp[i][n-1];
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 2940
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


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

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

int main(){
    string s,t;
    cin >> s >>t;
    if(s==t.substr(0,s.size())){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}

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

const int MAX_N = 1<<17;
typedef pair<int,int> P;
int n;
P dat[2*MAX_N-1];

//?????????
void init(int n_){
  //????´???°n???2???????????????
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=P(INT_MAX,INT_MAX);
}

int update(int a,int b,int k,int l,int r,int x){
  if(r<=a||b<=l)return dat[k].second;
  if(a<=l&&r<=b){
    dat[k]=P(x,x);
    return x;
  }else{
    if(dat[k].first!=INT_MAX){
      dat[k*2+1].first=dat[k*2+1].second=dat[k].first;
      dat[k*2+2].first=dat[k*2+2].second=dat[k].first;
      dat[k].first=INT_MAX;
    }
    int m=(l+r)/2;
    int v1=update(a,b,k*2+1,l,m,x);
    int v2=update(a,b,k*2+2,m,r,x);
    return dat[k].second=min(v1,v2);
  }
}

int find(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return INT_MAX;
  if(a<=l&&r<=b)return dat[k].second;
  else{
    if(dat[k].first!=INT_MAX){
      dat[k*2+1].first=dat[k*2+1].second=dat[k].first;
      dat[k*2+2].first=dat[k*2+2].second=dat[k].first;
      dat[k].first=INT_MAX;
    }
    return min(find(a,b,k*2+1,l,(l+r)/2),find(a,b,k*2+2,(l+r)/2,r));
  }
}

int main(){
  int q;
  cin>>n>>q;
  
  init(n);
  int u,s,t,x;
  for(int i=0;i<q;i++){
    cin>>u;
    if(!u){
      cin>>s>>t>>x;
      update(s,t+1,0,0,n,x);
    }else{
      cin>>s>>t;
      cout<<find(s,t+1,0,0,n)<<endl;
    }
  }
  
  return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, a, b, c, d;
string s;

bool check_reach(int start, int end) {
  for (int i = start; i <= end - 1; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') {
      return false;
    }
  }

  return true;
}

bool check_triple() {
  bool ret = false;
  for (int i = b; i <= d; ++i) {
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') ret = true;
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

  cin >> s;

  a -= 1; b -= 1; c -= 1; d -= 1;

  if (!check_reach(a, c) || !check_reach(b, d)) {
    printf("No\n");
    return 0;
  }

  if (c < d) {
    printf("Yes\n");
    return 0;
  }

  if (check_triple()) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  return 0;
}


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF LONG_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pll pair<lli,lli>
//#define vector<lli> vl

lli sign(lli a){
  return (a>0)-(a<0);
}

int main(){
  lli x,y,ans;
  cin>>x>>y;
  ans = abs(abs(y)-abs(x));
  if(sign(y)==0 || sign(x)==0){
    if(y<x)
      ans++;
  }
  else if(sign(x)*sign(y)==-1)
    ans++;
  else
    if(y<x)
      ans+=2;

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


Measured memory_bytes: 256
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
dist = []
dist.append(N - A[-1] + A[0])
ans = 10**18
for i in range(0,K-1):
    dist.append(A[i+1]-A[i])

s = sum(dist)
for i in dist:
    ans = min(ans,s-i)
print(ans)

Measured memory_bytes: 24948
n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
k = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
      if all(list_A[v+i][t:t+m]==list_B[v] for v in range(m)):
        k = "Yes"
        break
print(k)
    

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 998244353


//逆元で二項係数を計算(MODは素数)　前処理O(n),本計算O(1)
#define MAXN 10000000
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init(int n) {
	inv[1] = 1;
	for (int i = 2; i <= n; i++) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}
//x^y%MOD
long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}


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

	

	int n;
	cin >> n;
	init(n);
	long long ans = pow_mod(3, n);

	for (int i = n / 2 + 1; i <= n; i++) {
		long long c = C(n, i) * 2;
		c *= pow_mod(2, n - i);
		ans -= c % MOD;
	}
	ans %= MOD;
	ans += MOD;
	ans %= MOD;

	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 234624
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long r[N]; //降雨量のハンブン
    long long sa = 0;
    for(int i =0; i < N - 1; i++){
        if(i%2 == 0) sa+= A[i];
        else sa -= A[i];
    }
    r[0] = (sa + A[N-1])/2;
    r[N - 1] = (A[N - 1] - sa)/2;
    for(int i = 1; i < N - 1; i++){
        r[i] = A[i - 1] - r[i -1];
    }
    for(int i =0; i < N; i++){
        cout << 2*r[i] << " ";
    }    
    cout << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include<cstdio>
#include <cmath>
#include <string>
using namespace std;

#define FACE 6

int DiceOctcome(struct Dice *p);

struct Dice {
	int a[FACE];
	string direction;
};

int main()
{
	int i;
	struct Dice dice;
	for(i=0;i<FACE;i++)scanf("%d", &dice.a[i]);
	

	cin >> dice.direction;
	printf("%d\n", DiceOctcome(&dice));

	return 0;
}

int DiceOctcome(struct Dice *p) {

	int octcome;//??????????¨???????
	int  b[FACE];
	octcome = p->a[0];//??????????????????????????????
	
	for (int i = 0; i < FACE; i++)  b[i] = p->a[i];
	//???????????????p???????????????????§???????Dice???dice?????????a[6]?????????????????§???????????????
	for (int i = 0; i <= (p->direction.size()-1); i++) {
		//string??????swtich????????????????????£?????????
		if (p->direction[i] == 'N') {
			p->a[0] = b[1];
			p->a[4] = b[0];
			p->a[5] = b[4];
			p->a[1] = b[5];
			octcome = p->a[0];
		}
		else if (p->direction[i] == 'W') {
			p->a[2] = b[5];
			p->a[0] = b[2];
			p->a[3] = b[0];
			p->a[5] = b[3];
			octcome = p->a[0];
		}
		else if (p->direction[i] == 'E') {
			p->a[2] = b[0];
			p->a[5] = b[2];
			p->a[3] = b[5];
			p->a[0] = b[3];
			octcome = p->a[0];
		}
		else {
			p->a[0] = b[4];
			p->a[1] = b[0];
			p->a[5] = b[1];
			p->a[4] = b[5];
			octcome = p->a[0];
		}

		for (int i = 0; i < FACE; i++)  b[i] = p->a[i];

	}
	
	return octcome;
}

Measured memory_bytes: 3348
function main()
  readline()
  S=chomp(readline())
  R=G=B=0
  for c=S
    if c=='R'
      R+=1
    elseif c=='G'
      G+=1
    else
      B+=1
    end
  end
  ans=R*G*B
  for i=1:length(S),j=i+2:2:length(S)
    x,y,z=S[i],S[div(i+j,2)],S[j]
    if x!=y!=z!=x
      ans-=1
    end
  end
  println(ans)
end
main()

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi m(n);
  int a = 0, b = 0, c = 0;
  rep(i,n){
    cin >> m[i];
    if(m[i] % 4 == 0) a++;
    else if(m[i] % 2 == 0) b++;
    else c++;
  }
  bool ans = (c <= a) || (b == 0 && c == a+1);
  YesorNo(ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    } 
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

int idx, target;
string s;

struct node {
	int repeat;
	long long len;
	vector<node> children;
	char c;

	node(int r):len(0ll), repeat(r){}
	node(int r, char c):len(1ll), repeat(r), c(c){}

	long long size() const {
		return len * repeat;
	}

	void add(const node& n) {
		children.push_back(n);
		len += n.size();
		chmin<int>(repeat, target / len + 1);
	}

	char get(int idx) const {
		const long long sum = len * repeat;
		if(idx < sum) {
			if(children.size()) {
				idx %= len;
				for(int i = 0; i < (int)children.size(); ++i) {
					const long long tmp = children[i].size();
					if(idx < tmp)
						return children[i].get(idx);

					idx -= tmp;
				}
			}
			else {
				return c;
			}
		}

		return '0';		
	}
};

int number() {
	int res = 0;
	while(isdigit(s[idx])) {
		res *= 10;
		res += s[idx++] - '0';
	}

	return res;
}

node parse(int repeat) {
	node res(repeat);
	while(idx < (int)s.size() && s[idx] != ')') {
		if(isdigit(s[idx])) {
			const int r = number();
			if(s[idx] == '(') {
				++idx;
				res.add(parse(r));
			}
			else {
				res.add(node(r, s[idx]));
			}
		}
		else {
			res.add(node(1, s[idx]));
		}

		++idx;
	}

	return res;
}

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

	while(cin >> s >> target, s != "0") {
		idx = 0;
		const node root = parse(1);
		cout << root.get(target) << endl;
	}

	return EXIT_SUCCESS;
}

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

const int dir_h[] = {-1, 0, 1, 0};
const int dir_w[] = { 0,-1, 0, 1};

int main(){
	int64_t N;
	cin >> N;
	vector<int64_t> A(N);
	vector<int64_t> sum(N);
	rep(i, N) cin >> A[i];
	rep(i, N){
		if(i != 0){
			sum[i] = sum[i-1] + A[i];
		}
		else{
			sum[i] = A[i];
		}
	}
	int64_t ans = -1;
	for(int i = 0; i < N-1; ++i){
		int64_t left = sum[i];
		int64_t right = sum[N-1] - left;
		if(ans == -1){
			ans = abs(right - left);
		}
		else{
			ans = min(ans, abs(right - left));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

const int MAX_N = 110;
int height, width;
char field[MAX_N][MAX_N];
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

inline bool VALID_POS(int x, int y) {
    return ( x >= 0 && x < width && y >= 0 && y < height);
}

void dfs(int x, int y, char fruit)
{
    if (!VALID_POS(x, y) || field[y][x] != fruit) return;
    field[y][x] = ' ';

    for (int i = 0; i < 4; ++i) {
        dfs(x + dx[i], y + dy[i], fruit);
    }  
}


int solve() {
    int ref = 0;

    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < width; ++x) {
            // ??°?????????
            if (field[y][x] == ' ') continue;

            dfs(x, y, field[y][x]);
            ref++;
        }
    }

    return ref;
}


int main()
{
    
    while (cin >> height >> width) {
        if (height == 0 && width == 0) break;

        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                cin >> field[y][x];
            }
        }

        int ans = solve();

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<30;

int a[26],b[26],c[26];

int dfs(int k,int l,int r,int s){
    if(k==-1) return l==r;
    if(!a[k]&&!b[k]) return dfs(k-1,l,r,s);
    int ret=0;
    for (int i = (c[k]?1:0); i <= 9; i++) {
        if(s&1<<i) continue;
        ret+=dfs(k-1,l+a[k]*i,r+b[k]*i,s|(1<<i));
    }
    return ret;
}


int main(){
    int N;
    while(cin >> N){
        if(!N) break;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        memset(c,0,sizeof(c));
        for (int i = 0; i < N; i++) {
            string s;cin >> s;
            int k=1;
            for (int j = s.length()-1; j >= 0; j--) {
                if(i==N-1) b[s[j]-'A']+=k;
                else a[s[j]-'A']+=k;
                if(j==0&&s.length()!=1) c[s[j]-'A']=1;
                k*=10;
            }
        }
        cout << dfs(25,0,0,0) << endl;
    }
    return 0;
}




Measured memory_bytes: 3148
n, m = map(int, input().split())

if n >= m:
    print(0)
    exit()

x = list(map(int, input().split()))
x = sorted(x)
diff = [x[i+1] - x[i] for i in range(0, m-1)]

sort_diff = sorted(diff, reverse=True)

sum = 0

if len(sort_diff) == 0:
    print(0)
    exit()

for i in range(n-1):
    sort_diff.pop(0)

for i in range(len(sort_diff)):
    sum += sort_diff[i]
print(sum)

Measured memory_bytes: 13960
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  for(var i = 1, len = input[0]-0; i <= len; i++){
    var c = input[i].split(' ');
    var x1 = c[0];
    var y1 = c[1];
    var x2 = c[2];
    var y2 = c[3];
    var x3 = c[4];
    var y3 = c[5];
    var x4 = c[6];
    var y4 = c[7];
    
    console.log(((y2-y1)/(x2-x1)).toFixed(6) == ((y4-y3)/(x4-x3)).toFixed(6) ? 'YES' : 'NO');
  }
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int a, b;   cin >> a >> b;

    int x = ceil(a / 0.08);
    int y = ceil(b / 0.1);

    if(x < y)   swap(x, y);

    if(int(x * 0.08) == a && int(x * 0.1) == b)   cout << x;
    else cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,A,B,minv=99999;
	cin>>n>>A>>B;
	int a[n+1],b[4]={0};
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=A)
		   b[1]++;
		else if(a[i]>A&&a[i]<=B)
		   b[2]++;
		else if(a[i]>B)
		   b[3]++;
	}
	for(int i=1;i<=3;i++)
	{
		if(b[i]<minv)
		{
			minv=b[i];
		}
	}
	cout<<minv;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>

using namespace std;

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

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	vector<bool> x(N);

	for (int i = 0; i < N; i++){
		if (A.at(i) % 2 == 0) {
			if (A.at(i) % 3 != 0) {
				if (A.at(i) % 5 != 0) {
					x.at(i) = false;
				}
				else x.at(i) = true;
			}
			else x.at(i) = true;
		}
		else x.at(i) = true;
	}

	int y = 0;

	for (int i = 0; i < N; i++) {
		if (x.at(i) == false) {
			y++;
		}
	}

	if (y > 0) cout << "DENIED" << endl;
	if (y == 0) cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readLong()
    var ans = 0L
    
    // O(n^2)
//    for (i in 1..n) {
//        for (j in 1..n) {
//            if (i % j == 0L) {
//                ans += i
//            }
//        }
//    }
    
    // O(nlogn)
    for (j in 1..n) {
        for (i in 0..n step j) {
            ans += i
        }
    }
    
    // O(n)
//    for (i in 1..n) {
//        val tmp = n / i
//        ans += (tmp + 1) * tmp / 2 * i
//    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 52152
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
# A, B, C = [int(n) for n in input().split()]
N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# INF = 10000000002
# EPS = 1e-9
# exit()
print(3*N**2)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
 
int K;

signed main() {
    IOS();
    cin>>K;
    int x=K/50,y=K%50;
    int N=50;
    vint a(N,49+x);
    rep(i,0,50){
        a[i]-=y;
        if(i<y)a[i]+=50;
    }
    cout<<50<<endl;
    rep(i,0,50){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  cin >> a;
  vector<tuple<int, int, int, int>> res;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w - 1; ++j) {
      if (a[i][j] % 2) {
        res.emplace_back(i + 1, j + 1, i + 1, j + 2);
        ++a[i][j + 1];
      }
    }
    if (i < h - 1 && a[i].back() % 2) {
      res.emplace_back(i + 1, w, i + 2, w);
      ++a[i + 1][w - 1];
    }
  }
  cout << res.size() << endl;
  for (auto i : res) cout << get<0>(i) << " " << get<1>(i) << " " << get<2>(i) << " " << get<3>(i) << endl;
}



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

int find(int X,vector<int> &U){
  if(U.at(X)<0){
    return X;
  }
  return U.at(X)=find(U.at(X),U);
}

void unite (int X,int Y,vector<int> &U){
  X=find(X,U);
  Y=find(Y,U);
  if(X==Y){
    return;
  }
  U.at(Y)+=U.at(X);
  U.at(X)=Y;
  return;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> U(N,-1);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    A--;
    B--;
    unite(A,B,U);
  }
  sort(U.begin(),U.end());
  cout << (-1)*U.at(0) << endl;
}
  
    

Measured memory_bytes: 4048
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void) 
{
  char *buf[10];
  int n = read(0,buf,10);
  int r = atoi(buf);
  printf("%lf\n", 2*3.1415*r);
  return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int N;
vector<int> d1,d2;
int main()
{

  cin >> N;
  d1.resize(N); d2.resize(N);
  for (int i=0; i<N; i++) {
    cin >> d1[i] >> d2[i];
  }
  for (int i=2; i<N; i++) {
    if (d1[i-2] == d2[i-2] && d1[i-1] == d2[i-1] && d1[i] == d2[i]) {
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");

  return 0;
}


Measured memory_bytes: 3632
def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  return gcd(b, a % b)

N = int(input())
A = list(map(int, input().split()))
 
ans = 0
MOD = 1000000007
 
LCM = A[0]
for i in range(1, N):
    LCM *= A[i] // gcd(LCM, A[i])
    
for a in A:
  ans += LCM // a
  
print(ans%MOD)


Measured memory_bytes: 4084
// 2019/12/03 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

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

	for(int j=1; j<=M; j++){
		for(int i=0; i<N-1; i++){
			if(A[i]%j>A[i+1]%j){
				swap(A[i], A[i+1]);
			}
		}
	}

	for(int i=0; i<N; i++){
		cout << A[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
using namespace std;
map<string,int>mp;
int main()
{
	mp["MON"]=6;
	mp["TUE"]=5;
	mp["WED"]=4;
	mp["THU"]=3;
	mp["FRI"]=2;
	mp["SAT"]=1;
	mp["SUN"]=7;
	string s;
	cin>>s;
	printf("%d\n",mp[s]);
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int n;
vector<int> to[MAX];

int tree_diameter(){
    int p;
    queue<P> q; q.push(P(0,-1));
    while(!q.empty()){
        P a = q.front(); q.pop(); p = a.fi;
        for(int b : to[a.fi]){
            if(b == a.se) continue;
            q.push(P(b, a.fi));
        }
    }
    vector<int> d(n);
    d[p]=0;  q.push(P(p,-1)); int ans = 0;
    while(!q.empty()){
        P a = q.front(); q.pop();
        for(int b : to[a.fi]){
            if(b == a.se) continue;
            d[b] = d[a.fi]+1;
            q.push(P(b, a.fi));
        }
        ans = max(ans, d[a.fi]);
    }
    return ans;
}

int main(){
    cin>>n;
    rep(i, n-1){
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int dm = tree_diameter();
    if((dm+1) % 3 == 2) out("Second");
    else out("First");
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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


int a,b,c,d;

int main(){
  cin >>a>>b>>c>>d;
  printf("%d\n", max(0,-max(a,c)+min(b,d)));
}


Measured memory_bytes: 256
// CppPractice.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include<algorithm>

using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	for (int n = 0; n < 3; n++) {
		if (n != 0) {
			cout << " ";
		}
		cout << a[n];
	}
	cout << endl;
    return 0;
}




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

using namespace std;

#define ll long long int
#define ld long double
#define pii pair<int,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define bit(a,b) ((a>>b)&1)
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

const ll mx = 3, Mod = 1e9+7;

struct Matrix
{
    int n;
    ll val[mx][mx];
    Matrix(int _base = 0, int _n = 3)
    {
        n = _n;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                val[i][j] = (i==j?_base:0);
    }
    ll* operator [](int x)
    {
        return val[x];
    }
    void print()
    {
        cout << "Matrix: {\n";
        for(int i=0;i<n;i++, cout << '\n')
            for(int j=0;j<n;j++)
                cout << val[i][j] << ' ';
        cout << "}\n";
    }
};

Matrix operator *(Matrix a, Matrix b)
{
    Matrix res;
    for(int i=0;i<res.n;i++)
        for(int j=0;j<res.n;j++)
            for(int k=0;k<res.n;k++)
                res[i][k] += a[i][j] * b[j][k];
    return res;
}

Matrix operator ^(Matrix a, ll b)
{
    Matrix res(1);
    while(b)
    {
        if(b&1)
            res = res * a;
        a = a * a;
        b /= 2;
    }
    return res;
}

int main()
{
    IOS;
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    Matrix base;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            base[i][j] = (i!=j);
    //base.print();
    base = base ^ k;
    //base.print();
    Matrix f;
    f[0][0] = a;
    f[0][1] = b;
    f[0][2] = c;
    //f.print();
    f = f*base;
    //f.print();
    cout << f[0][0] - f[0][1];
    return 0;
}












Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#define P pair<int, int>
using namespace std;

int main()
{	
	int w, n;
	cin >> w >> n;
	vector<int> v(w);
	for (int i = 1; i <= w; i++)
		v[i - 1] = i;
	P p;
	int t;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &p.first, &p.second);
		t = v[p.first - 1];
		v[p.first - 1] = v[p.second - 1];
		v[p.second - 1] = t;
	}
	
	for (int i = 0; i < w; i++)
		cout << v[i] << endl;
	
		
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool flag = true;
    int temp = 0;
    ll res=0;
    for(int i=a.size()-1;i>=0;--i){
        if(a[i]>=temp){
            if(i-a[i]>=0){
                //cout << "i:a[i]" << i << ":" << a[i] << endl;
                res+=a[i];
            }
            else{
                flag = false;
                break;
            }
        }
        else if(a[i]+1==temp){
             temp = a[i];
            continue;
        }
        else{
            flag = false;
            break;
        }
        temp = a[i];
    }
    if(flag) cout << res << endl;
    else cout << -1 << endl;
}

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

int main(){
  int W, a, b;
  cin >> W >> a >> b;
  if(b+W<a){
    cout << a-b-W << endl;
  }
  else if(b>a+W){
    cout << b-a-W << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
N=input()
s=input().split()
a = [int(j) for j in s]
lim=10**18

for i in range(int(N)):
    if(i==0):
      mul=int(a[0])
      if(0 in a):
          print(0)
          break
    else:
      mul=mul*int(a[i])
    if(mul>lim):
      print(-1)
      break
    if(i==int(N)-1):
      print(mul)
      break

Measured memory_bytes: 21640
Q=int(input())
M=10**5
from collections import defaultdict,deque
prime=defaultdict(int)
prime[2]=1
cnt=defaultdict(int)
def check(N):
    for k in range(2,int(N**0.5)+2):
        if N%k==0:
            return False
    return True
    
for N in range(2,10**5):
    cnt[N]+=cnt[N-1]
    if N%2==1:
        if check(N):
            prime[N]=1
            if prime[(N+1)//2]==1:
                cnt[N]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(cnt[r]-cnt[l-1])

Measured memory_bytes: 19240