akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A; cin >> A;
  for(int i=1; i<=9; ++i) {
    if(A%i==0 && A/i < 10) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stack>
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
struct edge{
  int  to;
  int cost;
  edge(int t,int w) : to(t),cost(w){}
};
int main(){
  vector<int> y,z;
  stack<int> s;
  int c[200010],ans1[200010],i,n,a,b,ans[200010],x;
  int INF=(1<<29);
  vector<vector<edge> > g(200010);
  scanf("%d\n",&n);
  for(i=0;i<n-1;i++){
    scanf("%d %d\n",&a,&b);
    a--,b--;
    g[a].push_back(edge(b,1));
    g[b].push_back(edge(a,1));
  }
  for(i=0;i<n;i++){
    ans[i]=0;
  }
  s.push(0),ans[0]=1;
  while(!s.empty()){
    x=s.top();
    s.pop();
    for(i=0;i<g[x].size();i++){
      if(ans[g[x][i].to]==0){
        ans[g[x][i].to]=-ans[x];
        s.push(g[x][i].to);
      }
    }
  }
  for(i=0;i<n;i++){
    if(ans[i]==1){
      y.push_back(i);
    }
    else{
      z.push_back(i);
    }
  }
  for(i=0;i<=n;i++){
    c[i]=0;
  }
  int d=0;
  if(y.size()<=n/3){
    for(i=1;i<=n;i++){
      if(y.size()==d){
        break;
      }
      if(i%3==0){
        c[i]=1;
        ans1[y[d]]=i;
        d++;
      }
   }
    d=0;
    for(i=1;i<=n;i++){
      if(c[i]==0){
        ans1[z[d]]=i;
        d++;
      }
    }
  }
  else if(z.size()<=n/3){
    for(i=1;i<=n;i++){
      if(z.size()==d){
        break;
      }
      if(i%3==0){
        c[i]=1;
        ans1[z[d]]=i;
        d++;
      }
   }
    d=0;
    for(i=1;i<=n;i++){
      if(c[i]==0){
        ans1[y[d]]=i;
        d++;
      }
    }
  }
  else{
    for(i=1;i<=n;i++){
      if(d==y.size()){
        break;
      }
      if(i%3==1){
      c[i]=1;
      ans1[y[d]]=i;
      d++;
      }
    }
    if(d<y.size()){
      for(i=1;i<=n;i++){
      if(d==y.size()){
        break;
      }
      if(i%3==0){
      c[i]=1;
      ans1[y[d]]=i;
      d++;
      }
      }
    }
    d=0;
    for(i=1;i<=n;i++){
      if(c[i]==0){
        ans1[z[d]]=i;
        d++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==0){
      printf("%d",ans1[i]);
      continue;
    }
    printf(" %d",ans1[i]);
  }
  return 0;
}

Measured memory_bytes: 18280
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    L = []
    for i in range(31):
        for j in range(31):
            if 100*(A*i+B*j) <= F:
                L.append(100*(A*i+B*j))
    L.sort()

    S = []
    for i in range(101):
        for j in range(101):
            if C*i+D*j<=F:
                S.append(C*i+D*j)
    S.sort()

    mx = 0
    ans = (A*100, 0)
    for l in L:
        for s in S:
            if l != 0 or s != 0:
                if l+s<=F and l*E/100 >= s and s/(l+s) > mx:
                    mx = s/(l+s)
                    ans = (l+s, s)
    print(ans[0], ans[1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5472
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

struct UnionFind {
    vector<int> parent;

    UnionFind(int n) : parent(n) {
        for (int i = 0; i < n; i++) parent[i] = i;
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rootX = root(x);
        int rootY = root(y);
        if (rootX == rootY) return;
        parent[rootX] = rootY;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

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

    UnionFind tree(n);
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        --p[i];
    }

    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        tree.unite(a, b);
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (tree.same(i, p[i])) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(int  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

bool is_palindrome(string s){
  string r = s;
  reverse(r.begin(), r.end());
  return s == r;
}
int main() {
  string s;
  cin >> s;
  int N = s.length();
  if(is_palindrome(s) and is_palindrome(s.substr(0,N/2)) and is_palindrome(s.substr(N/2+1))){
    puts("Yes");
  } else{
    puts("No");
  }
}


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

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

int  main(){
  ll n;cin>>n;
  vector<ll> vec(n+1);
  rep(i,n+1){cin>>vec.at(i);}
  sort(vec.begin(),vec.end());
  
  if(n==1){cout<<vec.at(1)-vec.at(0);}
  else{
  vector<ll> v(n);
  rep(i,n){
    v.at(i)=vec.at(i+1)-vec.at(i);
  }
  ll G=GCD(v[0],v[1]);
  ll g=G;
  ll i=1;
  while(i<=G){
    if(G%i!=0){i++;}
    else{
      g=G/i;
      bool b=true;
      rep(j,n){
        if(v.at(j)%g!=0){b=false;}
      }
      if(b){cout<<g;break;}
      i++;
    }
  }
  }
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B) {
	priority_queue<int> q;
	int res = 0;
	vector<pair<int, int>> v;
	rep(i, N) {
		v.emplace_back(M - A[i], B[i]);
	}
	sort(all(v));
	rrep(i, M) {
		while (!v.empty() && v.back().first == i) {
			q.emplace(v.back().second);
			v.pop_back();
		}
		if (!q.empty()) {
			res += q.top();
			q.pop();
		}
	}
	cout << res << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> A(N);
	std::vector<long long> B(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
	solve(N, M, std::move(A), std::move(B));
	return 0;
}


Measured memory_bytes: 5232
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

    }
}



Measured memory_bytes: 22612
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll


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

    int N,K,R[3];
    cin>>N>>K>>R[0]>>R[1]>>R[2];
    string T;
    cin>>T;
    map<char,int> M;
    M['s']=0;
    M['p']=1;
    M['r']=2;
    int ans=0;
    for(int i=0;i<(int)T.size();i++){
        char c=T[i];
        if(i<K || T[i]!=T[i-K]){
            ans+=R[M[c]];
        }else T[i]='?';

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a+c == b*2) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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


void f(int i, int j){

}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll mon = 1000;
    for(int i = 0; i < n-1; i++){
        if (a[i] < a[i+1]) {
            ll kabu = mon / a[i];
            mon = mon % a[i];
            mon += kabu * a[i+1];
        }
    }
    cout << mon << endl;
}

Measured memory_bytes: 3624
/*||>>>> Praveen Ojha <<<<>>>> 30 June 2019 <<<<>>>> 01:09:32 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(all(a));
	cout<<a[n/2]-a[n/2-1]<<"\n";
return 0;
}

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


void solve(long long A, std::string op, long long B){
  if (op == "+") {
      cout << A+B;
  } else {
      cout << A-B;
  }
  cout << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    std::string op;
    std::cin >> op;
    long long B;
    scanf("%lld",&B);
    solve(A, op, B);
    return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
input_lists = []
A = []
point = [0]

for _ in range(Q):
    input_lists.append([int(i) for i in input().split()])

for A in itertools.combinations_with_replacement(range(1, M+1), N):
    d_sum = 0
    for input_list in input_lists:
        a, b, c, d = input_list
        if A[b-1] - A[a-1] == c:
            d_sum += d
    point.append(d_sum)

print(max(point))

Measured memory_bytes: 12480
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

constexpr int MAX = 200006;
vi to[MAX];
int mark[MAX];

void dfs(int x, int p=-1) {
    for(int y : to[x]) {
        if(y==p) continue;
        mark[y] = x;
        dfs(y, x);
    }
}
signed main() {
    int n, m;
    cin>>n>>m;
    rep(i, m) {
       int x, y;
       cin>>x>>y;
       x--; y--;
       to[x].push_back(y);
       to[y].push_back(x);
    }
    rep(i, n) mark[i] = -1;
    
    vi dist(n, INT_MAX);
    queue<int> q;
    auto push = [&](int a, int d, int prev) {
        if(dist[a] != INT_MAX) return;
        q.push(a);
        dist[a] = d;
        mark[a] = prev;
    };
    q.push(0);
    dist[0] = 0;
    while(!q.empty()) {
        int v = q.front(); q.pop();
        int d = dist[v];
        for(int y : to[v]) {
            push(y, d+1, v);
        }
    }
    FOR(i, 1, n) {
        if(mark[i] == -1) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    FOR(i,1,n) cout<<mark[i]+1<<endl;

    return 0;
}

Measured memory_bytes: 12972
/*
 * 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())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
	int n,r;
	cin>>n>>r;
	if(n<10)
	{
		cout<<r+(100*(10-n))<<nl;
	}
	else
	{
		cout<<r<<nl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	cin>>A>>B;
	for (int C=1;C<=3;C++){
		if (A*B*C%2==1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct unionfind{
   vector<int> par;
   unionfind(int N):par(N){
       for(int i=0;i<N;i++) par[i]=i;
   }
   int root(int x){
       if(par[x]==x) return x;
       return par[x]=root(par[x]);
   }
   void unite(int x,int y){
       int rx=root(x);
       int ry=root(y);
       if(rx==ry) return;
       par[rx]=ry;
   }
   bool same(int x,int y){
       int rx=root(x);
       int ry=root(y);
       return rx==ry;
   }
};
int main(void){
    int N,M;
    cin>>N>>M;
    int a[M],b[M];
    for(int i=0;i<M;i++){
       cin>>a[i]>>b[i];
    }
    int ans=0;
    for(int i=0;i<M;i++){
        unionfind city(N+1);
        for(int j=0;j<M;j++){
           if(i==j) continue;
           else city.unite(a[j],b[j]);
        }
        int count=0;
        for(int j=1;j<=N;j++){
            if(city.same(1,j)) count++;
        }
        if(count!=N) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

VEC<VEC<int>> pos('z' - 'a' + 1);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  REP(i, 0, S.length()) { pos[S[i] - 'a'].reserve(1e5); }
  REP(i, 0, S.length()) { pos[S[i] - 'a'].push_back(i); }
  LL loopnum = 0;
  int prevpos = -1;
  // REP(i, 'a', 'z' + 1) { DUMP((char)i, pos[i - 'a']); }
  REP(i, 0, T.length()) {
    if (pos[T[i] - 'a'].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  REP(i, 0, T.length()) {
    auto poslist = &pos[T[i] - 'a'];
    // DUMP(poslist);
    if (prevpos >= (*poslist)[poslist->size() - 1]) {
      // DUMP("prevpos>max");
      loopnum++;
      prevpos = (*poslist)[0];
      continue;
    }
    int newpos = *upper_bound(ALL((*poslist)), prevpos);
    // DUMP("prev, new:", prevpos, newpos);
    prevpos = newpos;
  }
  // DUMP("loopnum:", loopnum);
  LL ans = loopnum * S.length() + prevpos + 1;
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1104
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[4];
cin>>a[0]>>a[1]>>a[2]>>a[3];
sort(a,a+4);
if(a[0]==a[1]&&a[2]==a[3]){
cout<<"yes"<<endl;
}else{
cout<<"no"<<endl;
}
return 0;
}


Measured memory_bytes: 3120
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = read_vec();
    a.sort();

    let max = a[n-1];
    let min = a[0];

    println!("{}", max - min);

}


Measured memory_bytes: 4352
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    for(;;)
    {
        string[] ss;
        for(string t; (t=readln().chomp())!="" && t!="0 0"; ss~=t){}
        if(ss.length==0) break;
        int[] c = new int[3];
        foreach(s;ss)
        {
            auto m = s.split().map!(to!int);
            immutable a=m[0], b=m[1];
            c.length = max(c.length,max(a,b)+1);
            ++c[a];
            ++c[b];
        }
        writeln(c[1..3].all!"a&1"() && !c[3..$].any!"a&1"()?"OK":"NG");
    }
}

Measured memory_bytes: 1296
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

string a, b;

inline void solve(){
  int N = SZ(a), M = SZ(b), repIdx = -1;
  
  auto check = [&](int idx){
    if(N - idx < M) return false;

    for(int rep = 0; rep < M; ++rep){
      if(a[idx + rep] == '?') continue;
      if(a[idx + rep] != b[rep]) return false;
    }
    
    return true;
  };

  for(int idx = 0; idx < N; ++idx){
    if(check(idx)) repIdx = idx;
  }

  if(repIdx == -1) cout << "UNRESTORABLE\n";
  else{
    for(int idx = 0; idx < N; ++idx){
      if(idx >= repIdx && idx <= repIdx + M - 1){
        cout << b[idx - repIdx];
        continue;
      }

      if(a[idx] == '?') cout << 'a';
      else cout << a[idx];
    }
  }
}

  


int main(){
  FAST_IO
  cin >> a >> b;

  solve();

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

b = defaultdict(int)
r = defaultdict(int)

n = int(input())
for i in range(n):
    b[input()] += 1
m = int(input())
for i in range(m):
    r[input()] += 1
ans = 0
for k, v in b.items():
    ans = max(ans, v - r[k])
print(ans)

Measured memory_bytes: 3444
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int[] H = new int[N];
		sc.fill(H);

		double diff = 9999999;
		int index = -1;
		for (int i = 0; i < H.length; i++) {
			double temp = T - H[i] * 0.006;
			if (Math.abs(A - temp) < diff) {
				diff = Math.abs(A - temp);
				index = i;
			}
		}

		System.out.println(index + 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21588
# -*- coding: utf-8 -*-
"""
Created on Sat May 30 16:42:23 2020

@author: Tofu
"""

#N = input()
#print(N)
def yomi(N):
    lst = N[-1]
#print(lst)
    x = ''
    if lst in ['2','4','5','7','9']:
        x = 'hon'
    elif lst in ['0','1','6','8']:
        x = 'pon'
    elif lst == '3':
        x = 'bon'
    
    print(x)
    return x


if __name__ == '__main__':
    N = input()
    
    ans = yomi(N)
    
    

Measured memory_bytes: 9132
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
if n == 22:
    print("Christmas Eve Eve Eve")
if n == 23:
    print("Christmas Eve Eve")
if n == 24:
    print("Christmas Eve")
if n == 25:
    print("Christmas")


Measured memory_bytes: 3060
n,y=map(int,input().split())
anslist=[]
for i in range(n+1):
    for j in range(n-i+1):
        if i*10000+j*5000+(n-i-j)*1000 == y :
            print(i,j,n-i-j)
            exit()
print("{} {} {}".format(-1,-1,-1))

Measured memory_bytes: 3060
n = 10**6
ps = [False]*(n+1)
for i in xrange(2, n+1):
    if i%2 != 0 or i == 2:
        ps[i] = True
for i in xrange(2, int(n**0.5+1)):
    if ps[i]:
        for j in xrange(i**2, n+1, i):
            ps[j] = False

while 1:
    a,d,n = map(int, raw_input().split())
    c = 0
    if a == 0 and d == 0 and n == 0: break
    m = 0
    while 1:
        tmp = a + m*d
        if tmp%2 != 0 or tmp == 2:
            if tmp%3 != 0:
                if ps[tmp] is True:
                    c += 1
        m += 1
        if n == c:
            print tmp
            break

Measured memory_bytes: 12144
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto X = RD!string;

	long ans;
	long cnt;
	foreach (c; X)
	{
		if (c == 'S')
			++cnt;
		else if (cnt != 0)
		{
			++ans;
			--cnt;
		}
	}
	
	writeln(X.length - ans*2);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 764
#include<iostream>

using namespace std;

	int vetor[105];
	int aux [105];
int main (){
	int i;
	int n,m,x;
	int  soma1,soma2;
	
	soma1 = 0;
	soma2 = 0;
	cin>>n>>m>>x;
	
	for(i=0;i<n+1;i++){
		
		vetor[i] = 0;
		
	}
	
	
	for(i=0;i<m;i++){
		cin>>aux[i];
	}
	
	for(i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i == aux[j]){
				vetor[i] =1;
	}
	}
	}
	
	
	for(i=x;i<n+1;i++){
		if(vetor[i] == 1){
			soma1 = soma1+ 1;
		}
	}
	
	for(i=x;i>0;i--){
		if(vetor[i] == 1){
			soma2 = soma2+1;
		}
	}
	
	
	if(soma1>soma2){
		cout<<soma2<<endl;}
		
	else{
		cout<<soma1<<endl;}
		
		
		
		
	
	return 0;
	
	
	
	
}


Measured memory_bytes: 256
function main()
  
  S = split(chomp(readline()),"")
  
  check1 = S[1]
  check2 = ""
  
  for i in 1:4
    
    if S[1] != S[i]
      check2 = S[i]
    end
    
  end
  
  count1 = 0
  count2 = 0
  
  for i in 1:4
    
    if S[i] == check1
      count1 += 1
    elseif S[i] == check2
      count2 += 1
    end
    
  end
  
  if count1 == 2 && count2 == 2
    println("Yes")
  else
    println("No")
  end
  
end

main()


Measured memory_bytes: 168840
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<int> dp(n + 2);
  for (int i = 1; i < n; ++i) {
    dp[i + 2] = dp[i - 1 + 2] + abs(h[i] - h[i - 1]);
    if (i >= 2) {
      dp[i + 2] = min(dp[i + 2], dp[i - 2 + 2] + abs(h[i] - h[i - 2]));
    }
  }

  cout << dp[n + 1] << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.ArrayDeque
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readIntegerList()
    var ans = Long.MAX_VALUE
    for (target in -100..100) {
        var tmp = 0L
        for (a in aList) {
            tmp += (target - a) * (target - a)
        }
        ans = min(ans, tmp)
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36528
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans,cnt;
    int f[200],nf[200];
    string s;
    cin>>n;
    getline(cin>>ws,s);
    fill(f,f+200,0);
    for (int i=0;i<n;i++){
        f[s[i]]++;
        fill(nf,nf+200,0);
        for (int j=i+1;j<n;j++)
            nf[s[j]]++;
        cnt=0;
        for (int j=0;j<200;j++)
        if (f[j]>0 && nf[j]>0){
            cnt++;
            //cout<<(char)j;
        }
        //cout<<cnt<<"\n";
        ans=max(ans,cnt);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<cctype>

using namespace std;

int n;
int main()
{
	long long ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i; j <= n; j += i)
		{
			ans += j;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val a = sc.nextInt
    val b = sc.nextInt
    val c = sc.nextInt
    val d = sc.nextInt

    if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d)) {
      "Yes"
    } else {
      "No"
    }
  }
}


Measured memory_bytes: 25764
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int x;
int main()
{
  cin>>x;
  if(x%10==9||x/10==9)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    ll x = 0;
    for(int i = 0; i < n; i++){
        if(i % 2) x -= a[i];
        else x += a[i];
    }

    V<ll> ans(n);
    ans[0] = x / 2;
    for(int i = 0; i < n - 1; i++){
        ans[i + 1] = a[i] - ans[i];
    }

    for(int i = 0; i < n; i++){
        if(i != n - 1) cout << ans[i] * 2 << " ";
        else cout << ans[i] * 2 << endl;
    }


    return 0;
}


Measured memory_bytes: 4844
N = int(input())
S = input()
Q = int(input())
K = list(map(int, input().split()))

for k in K:
    numD = 0
    numM = 0
    numDM = 0
    ans = 0
    for i in range(N):
        c = S[i]
        if c == 'D':
            numD += 1
        elif c == 'M':
            numM += 1
            numDM += numD
        elif c == 'C':
            ans += numDM

        if i >= k-1:
            c = S[i-k+1]
            if c == 'D':
                numD -= 1
                numDM -= numM
            elif c == 'M':
                numM -= 1
    print(ans)


Measured memory_bytes: 75520
n,k=gets.split.map &:to_i
as=gets.split.map &:to_i
k.times{
  imos=Array.new(n,0)
  as.each_with_index do |a,i|
    min=[i-a,0].max
    max=[i+a+1,n].min
    imos[min] += 1
    imos[max] -= 1 if max<n
  end
  1.upto(n-1) do |i|
    imos[i] += imos[i-1]
  end
  as=imos
  break if as.all?{|a|a==n}
  }
puts as.join(" ")

Measured memory_bytes: 80820
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 a, b, n; scanf("%lld%lld%lld", &a, &b, &n);

	i64 x = std::min(n, b - 1);
	printf("%lld\n", x * a / b - a * (x / b));
	return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;
int min(int a,int b)
{
	if(a>b)
	{
		return b;
	}
	else
	{
		return a;
	}
}
int main()
{
	int N,K;
	cin>>N>>K;
	string S;
	cin>>S;

	//連続する表を作る
	vector<int> list;
	list.push_back(0);
	int mode=0;
	for(int i=0; i<N; i++)
	{
		if(mode > 0)
		{
			if(S[i]=='1')
			{
				mode++;
			}
			else
			{
				list.push_back(mode);
				mode = -1;
			}
		}
		else if(mode < 0)
		{
			if(S[i]=='1')
			{
				list.push_back(mode);
				mode = 1;
			}
			else
			{
				mode--;
			}
		}
		else if(mode == 0)
		{
			if(S[i]=='1')
			{
				mode = 1;
			}
			else
			{
				mode = -1;
			}
		}
	}
	list.push_back(mode);
	list.push_back(0);

	vector<int> c;
	c.push_back(0);
	int initial = 0;
	int start = 0;
	if(list[1]>0)
	{
		start = 1;
	}
	else
	{
		start = 0;
	}

	for(int i=start; i<min(start+K*2+1,list.size()); i++)
	{	
		initial += abs(list[i]);
	}
	c.push_back(initial);
	int pos = K*2 + start;

	while(true)
	{
		pos+=2;
		if(pos>=list.size())
		{
			break;
		}
		
		initial+=abs(list[pos]);
		initial+=abs(list[pos-1]);

		initial-=abs(list[pos-K*2-2]);
		initial-=abs(list[pos-K*2-1]);

		c.push_back(initial);
	}
	

	int result = *max_element(c.begin(),c.end());
	cout<<result<<endl;

	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S,T;
    cin>>S>>T;
    int N=S.size();
    char a;
    for(int i=0;i<N;i++){
        if(S==T){cout<<"Yes"<<endl;exit(0);}
        a=S[0];
        S.erase(0,1);
        S.push_back(a);
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vi s(n-1);
  rep(i,n-1)cin>>s[i];
  vi a(m);
  rep(i,m)cin>>a[i];

  vi imos(n,0);//imos[i]:=宿iから宿i+1の間の移動回数

  int x=0;
  rep(i,m){
    int p=min(x,x+a[i]);
    int q=max(x,x+a[i]);

    imos[p]++;
    imos[q]--;

    x+=a[i];

  }

  rep(i,n-1)imos[i+1]+=imos[i];

  int ans=0;

  rep(i,n-1){

    ans=(ans+imos[i]*s[i])%100000;

  }

  cout<<ans<<endl;

}



Measured memory_bytes: 3776
#include <stdio.h>
#define MAXN 100
#define NIL -1
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))

struct Node{
  int p, l, r;
};

struct Node binTree[MAXN];

int getDepth(int u) // book p190
{
  int d = 0;
  while (binTree[u].p != NIL){
    u = binTree[u].p;
    d++;
  }
  return d;
}

int getHeight(int u)// book p195
{
  int h1 = 0;
  int h2 = 0;
  if (binTree[u].l!= NIL)
    h1 = getHeight(binTree[u].l) +1;
  if (binTree[u].r!= NIL)
    h2 = getHeight(binTree[u].r) +1;
  
  return MAX(h1,h2);
}

int getSibling(int u)// return l or r  book p196
{
  if ( binTree[u].p == NIL ) return NIL;
  if ( binTree[binTree[u].p].l != u && binTree[binTree[u].p].l != NIL ) return binTree[binTree[u].p].l;
  if ( binTree[binTree[u].p].r != u && binTree[binTree[u].p].r != NIL ) return binTree[binTree[u].p].r;
  return NIL;
}

void print(int N){
  int i, d,s,degree,h;
  for ( i = 0; i <N; i++ ){
    d = getDepth(i);
    s = getSibling(i);
    degree=0;
    if (binTree[i].l !=NIL) degree++;
    if (binTree[i].r !=NIL) degree++;
    h = getHeight(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,binTree[i].p, s, degree, d, h);// PE error, parent= to parent =

    if ( binTree[i].p == NIL ){
      printf("root\n");
    } else if ( binTree[i].l == NIL && binTree[i].r == NIL ){
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
}

int main(void)
{
  int n,i,v,l,r;
  scanf("%d", &n);
  
  // init binbinTreeree
  for ( i = 0; i < n; i++ ) {
    binTree[i].p=NIL;
    binTree[i].l=NIL;
    binTree[i].r=NIL;
  }

  //input v,l,r for current node
  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    binTree[v].l=l;
    binTree[v].r=r;
    if (l != NIL) binTree[l].p=v;
    if (r != NIL) binTree[r].p=v;
  }
  print(n);
  
  return 0;
}



Measured memory_bytes: 2068
#include<iostream>
#include<string>



using namespace std;

int main() {
	string st;
	cin >> st;
	for (int i = 0; i < 4; i++) {
		cout << st[i];
	}
	cout << " ";
	for (int i = 4; i < 12; i++) {
		cout << st[i];
	}cout << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <math.h>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

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

	for (int t = 1; t < 100000; t++)
	{
		int T = t *(t + 1) / 2;
		if (X <= T) {
			cout << t << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
N = gets.chomp.to_i
x,y = [],[]
1.upto(N) do |i|
  x[i],y[i] = gets.chomp.split.map(&:to_i)
end

sum = 0
(1..N).to_a.permutation(N) do |arr|
  (N-1).times do |n|
    start = arr[n]
    goal = arr[n+1]
    sum += (Math.sqrt((x[start]-x[goal])**2 + (y[start]-y[goal])**2))
  end
end

k = (1..N).to_a.inject(:*)

p sum.to_f / k


Measured memory_bytes: 14564
import java.util.*
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val p = sc.asSequence().take(n).map { it.toInt() }.toList()

    var min = Int.MAX_VALUE
    var r = 0
    p.forEach {
        if (it <= min) {
            r++
            min = it
        }
    }
    print(r)
}


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

int main(){
  string s;
  int k;
  while(cin>>s){
    k=0;
    s='1'+s;
    if(s[1]==s[2]&&s[2]==s[3]&&s[1]!='s')k=1;
    else if(s[4]==s[5]&&s[5]==s[6]&&s[4]!='s')k=4;
    else if(s[7]==s[8]&&s[8]==s[9]&&s[7]!='s')k=7;
    else if(s[1]==s[4]&&s[4]==s[7]&&s[1]!='s')k=1;
    else if(s[2]==s[5]&&s[5]==s[8]&&s[2]!='s')k=2;
    else if(s[3]==s[6]&&s[6]==s[9]&&s[3]!='s')k=3;
    else if(s[1]==s[5]&&s[5]==s[9]&&s[1]!='s')k=1;
    else if(s[3]==s[5]&&s[5]==s[7]&&s[3]!='s')k=3;

    if(k==0)cout<<'d'<<endl;
    else cout<<s[k]<<endl;

  }
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}


int main(){
    int n;
    cin >> n;
    for(int i = 0; i < (1 << n); i++){
        vector<int> as;
        for(int j = 0; j < n; j++){
            if(i & (1 << j)){
                as.push_back(j);
            }
        }
        cout << i << ":";
        for(int j = 0; j < as.size(); j++){
            cout << " " << as[j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
    int n,m; cin >> n >> m;
    vector<int> a(n); rep(i,n) cin >> a[i];
    //sort(all(p));
    int ans = 0;
    double sum = accumulate(all(a),0);
    rep(i,n) if(a[i] >= sum/4/m) ans++;

    if(ans >= m) cout << "Yes";
    else cout << "No";
    
return 0;
}

Measured memory_bytes: 256