akhauriyash/Code-Regression huggingface dataset:
/******
	~site:    atcoder.jp
	~user:    Turkhuu
	~problem: AtCoder Beginner Contest 177 - C (abc177_c)
** **/

#include<bits/stdc++.h>

#define FFOR(i,s,e,k) for(int i=s;(k==1?i<=e:i>=e);i+=k)
#define FOR(i,n) FFOR(i,0,n-1,1)
#define FORR(i,s,e) FFOR(i,s,e,1)
#define ll long long
#define PQ priority_queue
#define pb push_back
#define ppb pop_back()
#define pp push
#define MIN(v) *min_element(v.begin(),v.end())
#define MAX(v) *max_element(v.begin(),v.end())
#define SORT(v) sort(v.begin(),v.end())
#define TROS(v) sort(v.rbegin(),v.rend())
#define CNT(v,x) count(v.begin(),v.end(),x)

using namespace std;

const ll MOD=1000000007;

ll a[200001];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	FOR(i,n){
		cin>>a[i];
		if(i>0) a[i]+=a[i-1];
	}
	ll sum=0;
	FORR(i,0,n-2){
		int k=(i==0?a[i]:a[i]-a[i-1]);
		sum+=(k*((a[n-1]-a[i])%MOD))%MOD;
		sum%=MOD;
	}
	cout<<sum;
}

Measured memory_bytes: 5184
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define pb push_back
#define endl '\n';
#define sz(s) int(s.size())
#define Ceil(x,y)  ((x+y-1)/y)
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define I64 int
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const ll mod = ll(1e9 + 7);
const double PI = acos(-1.0);
const int N = (int)1e6 * 2;
using namespace std;
void Selim()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll LCM(ll a, ll b) { return a / gcd(a, b)*b; }
//ll Mod(ll x, ll m){ return ((x % m) + m) % m; }
//ll fact(long long  n) { return !n ? 1 : n * fact(n - 1); }
//transform(s.begin(), s.end(), s.begin(), ::tolower);
//palindrom if(s==string(s.rbegin(),s.rend()))
//memset(arr,0,sizeof arr)
/*
*********************************************************************************************

If you want something you've never had, you must be willing to do something you've never done

*********************************************************************************************
*/
int main()
{
	Selim();
	/*int t;
	cin >> t;
	while (t--){
		ll a, b, mnA, mnB, n;
		cin >> a >> b >> mnA >> mnB >> n;
		ll cur_A = a - mnA, cur_B = b - mnB;
		if (cur_A >= cur_B){
			if (a <= b){
				a -= min(n, cur_A);
				n -= min(n, cur_A);
				b -= min(n, cur_B);
			}
			else{
				b -= min(n, cur_B);
				n -= min(n, cur_B);
				a -= min(n, cur_A);
			}
		}
		else{
			if (b <= a){
				b -= min(n, cur_B);
				n -= min(n, cur_B);
				a -= min(n, cur_A);
			}
			else{
				a -= min(n, cur_A);
				n -= min(n, cur_A);
				b -= min(n, cur_B);
			}
		}
		/*if (cur_A + cur_B <= n){
			cout << mnA*mnB << endl;
			continue;
		}
		ll m = min(n / 2, cur_A);
		n -= m;
		a -= m, b -= min(n, cur_B);
		if (n & 1){

		}
		cout << a*b << endl;
	}*/
	int n;
	cin >> n;
	vector<pair<int, int>>v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i].first >> v[i].second;
	}
	for (int i = 0; i < n; i++){
		if (i + 2 < n){
			if (v[i].first == v[i].second &&
				v[i + 1].first == v[i + 1].second &&
				v[i + 2].first == v[i + 2].second){
				return cout << "Yes", 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3656
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    string a;
    while(cin>>a)
    {
        map<char,int> mp;
        char ch;
        rep(i,a.sz)
        {
            ch=a.at(i);
            mp[ch]++;
        }
        if(mp.sz==2)
        {
            map<char,int> ::iterator it;
            bool f=0;
            for(it=mp.B;it!=mp.E;it++)
            {
                if(it->second!=2) f=1;
            }
            if(f) cout<<"No"<<en;
            else cout<<"Yes"<<en;
        }
        else cout<<"No"<<en;
    }
}



Measured memory_bytes: 256
using System;

namespace AOJ0035
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                string[] num = input.Split(',');

                Point a = new Point(num[0], num[1]);
                Point b = new Point(num[2], num[3]);
                Point c = new Point(num[4], num[5]);
                Point d = new Point(num[6], num[7]);

                Vector BA = new Vector(b, a);
                Vector AC = new Vector(a, c);
                Vector BD = new Vector(b, d);

                decimal p = (BD.vx * BA.vy - BA.vx * BD.vy) / (AC.vx * BD.vy - BD.vx * AC.vy);
                decimal q = (BA.vx * AC.vy - AC.vx * BA.vy) / (BD.vx * AC.vy - AC.vx * BD.vy);
                string output = "NO";

                if ((p > 0)&&(p < 1))
                {
                    if ((q > 0) && (q < 1))
                    {
                        output = "YES";
                    }
                }

                Console.WriteLine(output);

            }
        }

        public struct Point
        {
            public decimal x, y;

            public Point(string x, string y)
            {
                this.x = decimal.Parse(x);
                this.y = decimal.Parse(y);
            }

        }

        public struct Vector
        {
            public decimal vx, vy;

            public Vector (Point p, Point q)
            {
                this.vx = q.x - p.x;
                this.vy = q.y - p.y;
            }
        }
    }
}

Measured memory_bytes: 9276
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> count(n + 1, 0);

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

    for (int i = 1; i <= n; i++)
    {
        if (k - q + count[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
# describe Abc131A do
#   context 'test' do
#     it 'sample' do
#       expect(Abc131A.calc('3776')).to be_falsey
#       expect(Abc131A.calc('8080')).to be_truthy
#       expect(Abc131A.calc('1333')).to be_falsey
#       expect(Abc131A.calc('0024')).to be_falsey
#     end
#   end
# end

class Abc131A
  def self.input()
    password_string = STDIN.gets
  end

  def self.output(result)
    puts (result ? "Good": "Bad")
  end

  def self.calc(password_string)
    !password_string.split(//).map.each_cons(2).map{ |a, b|
      a == b
    }.any?
  end

  def self.main()
    password_string = input()
    result = calc(password_string)
    output(result)
  end
end

if __FILE__ == $0
  Abc131A.main
  exit
end

Measured memory_bytes: 1788
import java.util.*;
import java.lang.*;

public class Main {

    static int n;
    static int[] a;
    static HashSet<Integer> sums;
    
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sums = new HashSet<>();
        bitFullSearch();
        
        int mnum = sc.nextInt();
        for (int i = 0; i < mnum; i++) {
            System.out.println(sums.contains(sc.nextInt()) ? "yes" : "no");
        }
        //System.out.println(sums);
    }
    
    static void bitFullSearch() {
        for (int i = 0; i < Math.pow(2, n); i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                if ((i >> j & 1) == 1) { // iのj桁目が立ってたら
                    sum += a[j];
                }
            }
            sums.add(sum);
        }
    }
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll a, b;
    cin >> a >> b;
    ll num = __gcd(a, b);
    int ans = 1;
    ll cur = num;
    for (ll i = 2; i * i <= num; i++)
    {
        if (num % i == 0)
        {
            ans++;
            while (num % i == 0)
            {
                num /= i;
            }
        }
    }
    if (num > 1)
        ans++;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX],n;
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>R[i];
	
	int maxv = -1000000000;
	int minv = R[0];
	
	for(int j=1;j<n;j++){
		maxv = max(maxv,R[j]-minv);
		minv = min(minv,R[j]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 1940
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    var(string, s);
    unordered_map<char, bool> exist;
    for (auto &e : s) exist[e] = true;
    for (char c = 'a'; c <= 'z'; ++c) {
        if (!exist[c]) {
            outn(s, c, "\n");
            return 0;
        }
    }
    repr(i, s.length() - 2, 0) {
        if (s[i] < s[i + 1]) {
            char best = s[i + 1];
            reps(j, i + 1, s.length() - 1) {
                if (s[j] > s[i]) {
                    chmin(best, s[j]);
                }
            }
            s[i] = best;
            outl(s.substr(0, i + 1));
            return 0;
        }
    }
    outl(-1);
    return 0;
}


Measured memory_bytes: 256
import scala.math._

object Main {
  val sc = new java.util.Scanner(System.in)
  val dx = Seq(0, -1, 0, 1, 0)
  val dy = Seq(0, 0, 1, 0, -1)
  val dxy = dx.zip(dy)
  val b = Array.ofDim[Int](10, 10)
  val c = Array.ofDim[Int](10, 10)
  val change = (a: Array[Array[Int]], x: Int, y: Int) => {
    for {
      d <- dxy
      xi = x + d._1
      yi = y + d._2
      if 0 <= xi
      if xi < 10
      if 0 <= yi
      if yi < 10
    } {
      a(xi)(yi) = (a(xi)(yi)+1)%2
    }
  }
  def test (a: Array[Array[Int]], n: Int) = {
    for(i <- 0 until 10; j <- 0 until 10) {
      b(i)(j) = a(i)(j)
      c(i)(j) = 0
    }
    for(i <- 0 until 10) {
      if((n & (1 << i)) != 0) {
        change(b, 0, i)
        c(0)(i) = 1
      }
    }
    for(i <- 1 until 10) {
      for(j <- 0 until 10) {
        if(b(i-1)(j) == 1) {
          change(b, i, j)
          c(i)(j) = 1
        }
      }
    }
    b.forall(_.forall(_ == 0))
  }
  def solve(a: Array[Array[Int]]): Array[Array[Int]] = {
    var i = 0
    while(i < (1 << 10)) {
      if(test(a, i)) {
        return c
      }
      i += 1
    }
    return c
  }
  def main(args: Array[String]) {
    val n = sc.nextInt()
    val a = Array.ofDim[Int](10, 10)
    for(_ <- 1 to n) {
      for(i <- 0 until 10; j <- 0 until 10) {
        a(i)(j) = sc.nextInt
      }
      solve(a).foreach(s => println(s.mkString(" ")))
    }
  }
}

Measured memory_bytes: 266832
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    int l=s.length();
    if(l<=k){
        cout<<s<<endl;
    }
    else {
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int ans = 100, maxs = 0, cnt;
  string s;
  cin >> s;

  for (char c = 'a'; c <= 'z'; ++c) {
    int now = 0, mx = 0;
    for (auto ch : s) {
      if (ch == c)
        now = 0;
      else
        mx = max(mx, ++now);
    }
    ans = min(ans, mx);
  }

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


Measured memory_bytes: 256
[n,m] = list(map(int,input().split(" ")))

if m%2 == 0:
    t = int(m/2)
    for i in range (t):
        print(i+1,2*t-i)
    for i in range (t):
        print(2*t+1+i,4*t+1-i)
else:
    t = int(m/2)+1
    for i in range (t):
        print(i+1,2*t-i)
    for i in range (t-1):
        print(2*t+1+i,4*t-1-i) 


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 10;
char c[N][N];
bool is[N][N];

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	string qwe;
	getline(cin, qwe);
	forn(i, n) {
		forn(j, m) {
			scanf("%c", &c[i][j]);
		}
		getline(cin, qwe);
	}
	int kol = 0;
	forn(i, n)
		forn(j, m) {
			if (c[i][j] == '#')
				kol++;
		}
	if (kol == n + m - 1) {
		puts("Possible");
	} else {
		puts("Impossible");
	}
	return 0;
}


Measured memory_bytes: 384
N = int(input())
P = list(reversed(list(map(int, input().split()))))

s, t = 2, 2
for i in P:
    p = max((s + i - 1) // i, 1)
    q = t // i
    if q < p:
        print(-1)
        quit(0)
    s, t = p * i, q * i + i - 1

print(s, t)


Measured memory_bytes: 14224
import numpy as np
n, d = input().split()
N = int(n)
D = int(d)
x = []
for i in range(N):
    x.append([int(i) for i in input().split()])
x = np.array(x)
def calc_distance(l1, l2):
    return np.sqrt(np.sum((l1 - l2)** 2))
count = 0
for i in range(N):
    for j in range(i + 1, N):
        dd = calc_distance(x[i], x[j])
        # print(dd)
        if dd.is_integer():
            count += 1
print(count)

Measured memory_bytes: 12408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	char o[64], e[64];
	char buf[128], *ch;

	fgets(o, sizeof(buf), stdin);
	fgets(e, sizeof(buf), stdin);

	i = 0;
	while(e[i] != '\n' && e[i] != '\0') {
		printf("%c%c", o[i], e[i]);
		i += 1;
	}
	if(o[i] != '\n' && o[i] != '\0') {
		printf("%c\n", o[i]);
	} else {
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2056
N = int(input())
def divisor_list(num):
  ans = []
  for i in range(1, int(num**0.5)+1):
    if num % i == 0:
      ans.append(i)
      if i != num // i:
        ans.append(num//i)
  return ans
d_list = sorted(divisor_list(N))
ans = 10**12
for i in d_list:
    if ans > i+N//i-2:
      ans = i+N//i-2
print(ans)

Measured memory_bytes: 3280
type mang=array[0..1000005] of longint;
     mang1=array[0..1000005] of boolean;
var a:mang;
    kt:mang1;
    dem,n,sang:longint;
procedure nhap;
var i:longint;
begin
   read(n);
   for i:=1 to n do
      read(a[i]);
end;

procedure xuly;
begin
   dem:=0;
   fillchar(kt,sizeof(kt),true);
   sang:=1;
      while (sang<>2) and (kt[sang]=true) do
         begin
         kt[sang]:=false;
         sang:=a[sang];
         inc(dem);
         end;
end;

procedure xuat;
begin
   if sang=2 then write(dem)
      else write('-1');
end;

begin


   nhap;
   xuly;
   xuat;
end.

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  string s;
  cin >> s;
  bool flag = true;
  int left = 0;
  int right = s.size()-1;
  int x = 0;
  while(left != right){
    if(s[left] == 'x' && s[right] != 'x'){
      left++;
      x++;
    }
    else if(s[left] != 'x' && s[right] == 'x'){
      right--;
      x++;
    }
    else if(s[left] == s[right]){
      left++;
      if(left == right) break;
      right--;
    }
    else{
      flag = false;
      break;
    }
  }
  if(flag) cout << x << endl;
  else cout << -1 << endl;
}

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


int main()
{
    int n;
    cin>>n;
    string x= to_string(n);
    
    if(x[x.length()-1]=='2'||x[x.length()-1]=='4'||x[x.length()-1]=='5'||x[x.length()-1]=='7'||x[x.length()-1]=='9'){
        cout<<"hon"<<endl;
    }
    
    if(x[x.length()-1]=='0'||x[x.length()-1]=='1'||x[x.length()-1]=='6'||x[x.length()-1]=='8'){
        cout<<"pon"<<endl;
    }
    if(x[x.length()-1]=='3'){
        cout<<"bon"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;


int main() {
    string str;
    int count[26]{0}, c;
    char a;

    while(getline(cin, str)){

        for (int i=0; i<str.length();i++){
            if ( 64 < str[i] && str[i] <  91){
                c = str[i] - 65;
                count[c] += 1;
            }
            else if( 96 < str[i] && str[i] <  123){
                c = str[i] - 97;
                count[c] += 1;
            }
        }
    }
    for (int i=0; i<26;i++){
        a = i + 97;
        cout <<  a << " : " << count[i] << endl;
    }


}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=1e5+3;
//string s,p;
//vector<int>v;
map<ll,ll>mp;
ll a[N];
int main()
{
    ft
    ll t,i,j,n,m,x,l,r,s=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
        s+=a[i];
    }
    cin>>m;
    while(m--)
    {
        cin>>l>>r;
        if(mp[l]>0)
        {
            x=r-l;
            s+=mp[l]*x;
            mp[r]+=mp[l];
            mp[l]=0;
        }
        cout<<s<<"\n";
    }
    return 0;
}



Measured memory_bytes: 10072
import std.array;
import std.conv;
import std.string;
import std.algorithm;
import std.stdio;

void main() {
	auto length = readln.chomp.to!uint;
	auto a = readln.chomp.split(" ").map!(to!uint).array;
	assert(length >= 1);
	assert(a.length == length);

	auto sieve = new uint[1000008];

	foreach (size_t i, e;a) {
		if (sieve[e] >= 2) {
			continue;
		}
		for (uint j = e;j < sieve.length;j += e) {
			++sieve[j];
		}
	}

	uint answer;
	foreach (e;a) {
		if (sieve[e] == 1) {
			++answer;
		}
	}
	writeln(answer);
}


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

int main() {
  string N; cin >> N;
  bool flag = false;
  
  if (N.at(0) == N.at(1) && N.at(1) == N.at(2)) {
    flag = true;
  }
  else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)) {
    flag = true;
  }
  
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int TEST=0,CASE=1;
#define         pf              printf
#define         si(x)           scanf("%d",&x)
#define         sl(x)           scanf("%lld",&x)
#define         sd(x)           scanf("%lf",&x)
#define         pb(x)           push_back(x)
#define         mp(x,y)         make_pair(x,y)
#define         clr(x,y)        memset(x,y,sizeof(x))
#define         all(x)          x.begin(),x.end()
#define         MX              401000
#define         left            (indx<<1)
#define         right           left+1
#define         mid             ((l+r)>>1)
#define         speed           (ios::sync_with_stdio(false),cin.tie(0))
#define         fpoint(x)       (cout.precision(x),cout<<fixed)
#define         FOR(i,a,n)      for(int i=(a);i<=n;i++)
long long int         mod  =    1000000007LL;
const long double     pi   =    2.0*acos(0.0);
typedef long long int ll;
typedef long double ld;
struct vpair{
        int a,b;
        vpair(int a,int b){this->a=a,this->b=b;}
};
bool cmp(int &a,int &b){
        return a<b;                ///ascending order
///        return a>b;                ///descending order
}
ll n,m,a,b,c,d,k,x,y,z,ans=0,total=0;
string s;
int main(void){
        cin>>a>>b>>c;
        for(int i=0;i<=10000000;++i){
                if(a%2==1 || b%2==1 || c%2==1){
                        cout<<i<<endl;
                        exit(0);
                }else{
                        x=(b+c)>>1,y=(a+c)>>1,z=(a+b)>>1;
                        a=x,b=y,c=z;
                }
        }
        cout<<-1<<endl;
        return 0;
}


/**
G:\Work Station\OnlineJudge\VirtualContest\B.cpp
**/

Measured memory_bytes: 256
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    h1,m1,h2,m2,k = mi()
    ans = (h2-h1)*60+m2-m1-k
    print(ans)




main()




Measured memory_bytes: 10024
#include <bits/stdc++.h>
#define forinc(i,a,b) for (int i = a ; i <= b ; i ++)
#define fordec(i,a,b) for (int i = a ; i >= b ; i --)
#define forv(j,u) for (int j = 0 ; j < u.size() ; j++)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define ooll (long long) 1e18
#define ooit (int) 2e9
#define maxN 100005

using namespace std ;

int n , a[3 * maxN] ;

void enter() {
    cin >> n ;
    forinc(i,1,3*n) cin>> a[i] ;
}

long long f[3 * maxN] , g[3 * maxN] ;

void build_1() {
    priority_queue<int> q ;
    long long sum = 0 ;
    forinc(i,1,n) sum += a[i] , q.push(-a[i]) ; f[n] = sum ;
    forinc(i,n+1,3*n) {
        int tmin = -q.top() ;
        if (tmin < a[i]) sum -= tmin , sum += a[i] , q.pop() , q.push(-a[i]) ;
        f[i] = sum ;
    }
    while (!q.empty()) q.pop() ;
    sum = 0 ; fordec(i,3*n,2*n+1) sum += a[i] , q.push(a[i]) ; g[2 * n + 1] = sum ;
    fordec(i,2*n,1) {
        int tmax = q.top() ;
        if (tmax > a[i]) sum -= tmax , sum += a[i] , q.pop() , q.push(a[i]) ;
        g[i] = sum ;
    }
}

void process() {
    build_1() ;
    long long res = -ooll ;
    forinc(i,n,2*n) res = max(res,f[i] - g[i+1]) ;
    cout << res << endl ;
}

int main() {
    //freopen("arc074_b.inp" , "r" , stdin) ;
    //freopen("arc074_b.out" , "w" , stdout) ;
    enter() ;
    process() ;
    return 0 ;
}


Measured memory_bytes: 6136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll gcd(ll x,ll y)
{
    ll r;
    if(x < y){
        swap(x,y);
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    ll g = c * d / gcd(c,d);
    ll numc = b/c - a/c;
    ll numd = b/d - a/d;
    ll numg = b/g - a/g;
    cout << b-a-(numc+numd-numg);
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i<7; ++i){
        if(n < pow(2,i)){ cout << pow(2,i-1) << endl; return 0;}
    }
    cout << "64" << endl; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[55];

int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	long long sum = 0;
	for(int i=n-1;i>=n-k;i--){
		sum += a[i];
	}
	cout << sum <<endl;
	return 0;
}

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

int main () {
    int n;
    string ans;
    cin >> n;
    if (n < 100) {
        if (n < 10) {
            ans = "ABC00" + to_string(n);
        } else {
            ans = "ABC0" + to_string(n);
        }
    } else {
        ans = "ABC" + to_string(n);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void){
char s1[10];
char s2[10];
char s3[10];

  scanf("%s %s %s",s1,s2,s3);

  s1[0]=toupper(s1[0]);
  s2[0]=toupper(s2[0]);
  s3[0]=toupper(s3[0]);

  printf("%c%c%c\n",s1[0],s2[0],s3[0]);

  return 0;

}

Measured memory_bytes: 128
'''
#ABC101 B
#nを10進数で表したときの各桁の和をS(n)とする
#整数NがS(N)で割り切れるかどうか判定せよ
'''

N = int(input())
Nstr = str(N)
SN = 0
for i in range(len(Nstr)):
	SN += int(Nstr[i])

if N%SN == 0:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int i,j,k;
  int A[5];
  for(i=0;i<5;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&k);
  for(i=0;i<5;i++){
    for(j=0;j<5;j++){
      if(abs(A[j]-A[i])>k){
        puts(":(");
        return 0;
      }
    }
  }
  puts("Yay!");
  return 0;
}

Measured memory_bytes: 128
import Data.List
main :: IO()
main = do
  _ <- getLine
  v <- map read . words <$> getLine
  c <- map read . words <$> getLine
  print $ slv v c

slv :: [Integer] -> [Integer] -> Integer
slv v c = sum $ dropWhile (<0) $ sort $ map (\(x, y) -> x - y) $ zip v c

Measured memory_bytes: 636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new HashMap<>());
		}
		for (int i = 0; i < n; i++) {
		    int from = sc.nextInt();
		    int count = sc.nextInt();
		    for (int j = 0; j < count; j++) {
		        graph.get(from).put(sc.nextInt(), sc.nextInt());
		    }
		}
		int[] costs = new int[n];
		Arrays.fill(costs, Integer.MAX_VALUE);
		PriorityQueue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(0, 0));
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    if (costs[p.idx] <= p.value) {
		        continue;
		    }
		    costs[p.idx] = p.value;
		    for (Map.Entry<Integer, Integer> entry : graph.get(p.idx).entrySet()) {
		        queue.add(new Path(entry.getKey(), entry.getValue() + p.value));
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    sb.append(i).append(" ").append(costs[i]).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 39976
#include<bits/stdc++.h>
#define MAX_N 100005
#define inf (1LL<<60)
#define LL long long
#define pb push_back
#define MOD 1000000007LL
using namespace std;
struct node{
	LL y,cost;
};
struct cmp{
	bool operator()(node x,node y){
		if(x.cost==y.cost)	return x.y<y.y;
		return x.cost>y.cost;
	}
};
LL n,m;
LL dst[2][MAX_N],t[2][MAX_N];
LL ans;
priority_queue<node,vector<node>,cmp> Q;
vector<node> net[MAX_N];
void dijkstra(LL s,LL z){
	LL sz,i;
	node p,q;
	for(i=1;i<=n;i++)	dst[z][i]=inf;
	dst[z][s]=0;
	t[z][s]=1;
	Q.push({s,0});
	while(!Q.empty()){
		p=Q.top();Q.pop();
		if(dst[z][p.y]!=p.cost)	continue;
		sz=net[p.y].size();
		while(sz--){
			q=net[p.y][sz];
			if(dst[z][q.y]==p.cost+q.cost){
				t[z][q.y]=(t[z][q.y]+t[z][p.y])%MOD;
			}
			if(dst[z][q.y]>p.cost+q.cost){
				dst[z][q.y]=p.cost+q.cost;
				t[z][q.y]=t[z][p.y];
				Q.push({q.y,dst[z][q.y]});
			}
		}
	}
}
int main(){
	LL s,e,i,x;
	node p;
	scanf("%lld %lld",&n,&m);
	scanf("%lld %lld",&s,&e);
	for(i=1;i<=m;i++){
		scanf("%lld %lld %lld",&x,&p.y,&p.cost);
		net[x].pb(p);
		swap(x,p.y);net[x].pb(p);
	}
	dijkstra(s,0);
	dijkstra(e,1);
	ans=(t[0][e]*t[0][e])%MOD;
	for(i=1;i<=n;i++){
		if(dst[0][i]==dst[1][i] && dst[0][i]+dst[1][i]==dst[0][e])	ans=(ans-(((t[0][i]*t[1][i])%MOD)*((t[0][i]*t[1][i])%MOD)%MOD)+MOD)%MOD;
	}
	LL sz;
	for(i=1;i<=n;i++){
		sz=net[i].size();
		while(sz--){
			p=net[i][sz];
			if(dst[0][i]+dst[1][p.y]+p.cost!=dst[0][e])	continue;
			if(dst[1][p.y]+p.cost>dst[0][i] && dst[0][i]+p.cost>dst[1][p.y])	ans=(ans-((((t[0][i]*t[1][p.y])%MOD)*((t[0][i]*t[1][p.y])%MOD))%MOD)+MOD)%MOD;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  bool f=false;
  if(z>=x&&z<=y)
    f=true;
 
  if(f)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int p[n];
    ll pos[n + 1];
    REP(i,n){
        cin >> p[i];
        pos[p[i]] = i;
    }
    multiset<ll> s;
    s.insert(-1);
    s.insert(-1);
    s.insert(n);
    s.insert(n);
    s.insert(pos[n]);
    ll ans = 0;
    for(ll i = n - 1; i >= 1; i--){
        auto itr = s.upper_bound(pos[i]);
        ll r1 = *itr;
        itr++;
        ll r2 = *itr;
        for(int j = 0; j < 2; j++) itr--;
        ll l1 = *itr;
        itr--;
        ll l2 = *itr;
        ans += i * ((r2 - r1) * (pos[i] - l1) + (l1 - l2) * (r1 - pos[i]));
        s.insert(pos[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
char s[200005],t[200005];
int h,w,n,sr,sc;
int walk1(){
	int l=1,r=h;
	for(int i=n;i>=1;i--){
		if(t[i]=='U')
			r=min(h,r+1);
		else if(t[i]=='D')
			l=max(l-1,1);
		if(s[i]=='U')
			l++;
		else if(s[i]=='D')
			r--;
		if(l>r)
			return 1;
	}
	return (sr<l||sr>r); 
}
int walk2(){
	int l=1,r=w;
	for(int i=n;i>=1;i--){
		if(t[i]=='L')
			r=min(w,r+1);
		else if(t[i]=='R')
			l=max(l-1,1);
		if(s[i]=='R')
			r--;
		else if(s[i]=='L')
			l++;
		if(l>r)
			return 1;
	}
	return (sc<l||sc>r); 
}
int main(){
	scanf("%d%d%d",&h,&w,&n);
	scanf("%d%d",&sr,&sc);
	scanf("%s",s+1);
	scanf("%s",t+1);
	if(walk1()||walk2())
		puts("NO");
	else puts("YES");
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 998244353;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二項係数 前処理必要*/
const ll binomialmax = 510000;
ll fac[binomialmax], finv[binomialmax], inv[binomialmax];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < binomialmax; i++){
        fac[i] = modu(fac[i - 1] * i);
        inv[i] = modu(-inv[mod%i] * (mod / i));
        finv[i] = modu(finv[i - 1] * inv[i]);
    }
}

/* 二項係数計算 */
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return modu(fac[n] * (modu(finv[k] * finv[n - k])));
}


/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cominit();
    ll N,M,K;
    cin >> N >> M >> K;
    ll sum = 0;
    REP(i,K+1){
        sum += (modu(M*modpow(M-1,N-1-i))*com(N-1,N-1-i));
        sum %= mod;
    }
    cout << sum << "\n";
}

Measured memory_bytes: 15568
import math
n,k = map(int, input().split())
ans = 0
exp = 1
right = n
while right > 0:
  left = math.ceil(k / exp)
  ans += max(right - left+1,0) / (exp * n)
  right = min(left-1,n)
  exp *= 2
print(ans)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn main() {
   input! {
      n: usize,
      a: [i64; n]
   }
   let mut b = vec![0; n + 1];
   for i in 0..n {
      b[i + 1] = b[i] + a[i];
   }
   let mut ans = std::i64::MAX;
   for s2 in 2..=n - 2 {
      let mut high = s2;
      let mut low = 0;
      while high - low > 1 {
         let mid = (high + low) / 2;
         if b[s2] - b[mid] > b[mid] {
            low = mid;
         } else {
            high = mid;
         }
      }
      let s1 = low;

      high = n;
      low = s2;
      while high - low > 1 {
         let mid = (high + low) / 2;
         if b[n] - b[mid] > b[mid] - b[s2] {
            low = mid;
         } else {
            high = mid;
         }
      }
      let s3 = low;

      for &(d1, d3) in [(0, 0), (1, 0), (0, 1), (1, 1)].iter() {
         let s1 = s1 + d1;
         let s3 = s3 + d3;
         if s1 == 0 || s1 == s2 || s3 == s2 || s3 == n {
            continue;
         }
         let mut x = vec![b[s1], b[s2] - b[s1], b[s3] - b[s2], b[n] - b[s3]];
         x.sort();
         ans = std::cmp::min(ans, x[3] - x[0]);
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 6576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, s := scanInt(), scanInt()
	a := scanInts(n)

	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, 6010)
		dp[i][0] = 1
	}
	dp[0][0] = 0
	ans := 0

	for i := 0; i < n; i++ {
		dp[i+1][a[i]]++
		for j := 0; j < 3001; j++ {
			dp[i+1][j] += dp[i][j]
			dp[i+1][j+a[i]] += dp[i][j]
			dp[i+1][j] %= mod
			dp[i+1][j] %= mod
		}
		ans += dp[i+1][s]
		ans %= mod
	}
	fmt.Fprintln(wr, ans)
}

const mod = 998244353


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

int main(){
    int n;
    long long a,min=1000000,max=-1000000,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<min)min=a;
        if(a>max)max=a;
        sum+=a;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}    


Measured memory_bytes: 3092
#include<stdio.h>
#define ll long long

ll max(ll a, ll b)
{
	if(a>b)
		return a;
	return b;
}


ll dp[3][100005];

int main()
{
	ll n;
    scanf("%lld",&n);
    ll a[n] ,b[n] ,c[n];
    for(ll i = 0; i < n; i++) 
        scanf("%lld %lld %lld",&a[i],&b[i],&c[i]);

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
   
    for(ll i = 1; i < n; i++) 
    {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
    }
    printf("%lld\n",max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]));
}

Measured memory_bytes: 4864
#include<stdio.h> 
#include<stdlib.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a > b)
    {
		printf("a > b\n");
    }   
	else if(a < b)
    {
    	printf("a < b\n");
	}	
	else
	{
		printf("a == b\n");
	}
		
	return 0;
}


Measured memory_bytes: 2128
import itertools, math
N = int(input())
A = list(map(int,input().split()))
C = [A[i] - (i+1) for i in range(N)]

def SAD(C,b):
	S = 0
	for i in range(N):
		S += abs(C[i] - b)
	return S

MAX, MIN = max(C)+1, min(C)

i = 0
while MAX - MIN > 1:
	mid = (MIN + MAX)//2
#	print((MIN,mid,MAX,":",SAD(C,mid) - SAD(C,mid-1)))
	if 	SAD(C,mid) - SAD(C,mid-1) < 0:
		MIN = mid
	else:
		MAX =mid
print(SAD(C,MIN))


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define DFOR(i, a, n) for(int i = a; i < (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[2][100], sum = 0, sumup = 0, sumdown;
  cin >> n;
  rep(i, 2) {
    rep(j, n) {
      cin >> a[i][j];
    }
  }
  rep(i, n) {
    sumdown = 0;
    sumup += a[0][i];
    FOR(j, i, n) {
      sumdown += a[1][j];
    }
    if (sum < sumup + sumdown) sum = sumup + sumdown;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define case_for(n) for(int i = 1 ; i <= n ; i ++) { cout<<"Case "<<i<<": "<<endl; solve();}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll power(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p, b /= 2; }return ans; }
int hw_check(string a, int l, int r) { int ans = r - l + 1; for (l, r; l < r; l++, r--)if (a[l] != a[r]) return 0; return ans; }
string movesubstr(string a, int l, int r) { string s = "";	for (int i = l; i <= r; i++) s.push_back(a[i]);	return s; }


vector<int>b[100005];
void solve()
{
	
	int n, m; cin >> n >> m;
	vector<int>a;
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		int s; cin >> s;
		a.push_back(s);
	}
	for (int i = 0; i < m; i++)
	{
		int x, y; cin >> x >> y;
		b[x].push_back(y);
		b[y].push_back(x);
	}
	for (int i = 1; i <= n; i++)
	{
		bool falg = false;
		for (int j = 0; j < b[i].size(); j++)
		{
			//cout << b[i][j] << " ";
			if (a[i - 1] <= a[b[i][j] - 1])
			{
				falg = true;
				break;
			}
		}
		if (!falg)
		{
			res++;
			//cout << i << endl;
		}
	}
	cout << res << endl;
}
	
/*
3 3
3 3 3
4 1 3
4 1 3
*/
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(0);

	/*int t; cin >> t;
	while (t--) 
	{
		solve();
	}*/
	solve();
	return 0;
}
/*

*/

Measured memory_bytes: 8668
#include<stdio.h>
#define Max(x,y) ((x>y)?x:y)
int an[5005],bn[5005];
int main(){
	int i,j,k,a,b,ans=0;
	scanf("%d%d",&a,&b);
	for(i=0;i<a;i++)scanf("%d",&an[i]);
	for(i=0;i<b;i++)scanf("%d",&bn[i]);
	for(i=0;i<b;i++){
		k=i;
		for(j=0;j<a;j++)
			if(an[j]==bn[k])k++;
		ans=Max(ans,k-i);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = 1;
  while (b / c) {
    c *= 10;
  }
  int d = a * c + b;
  int sd = sqrt(d);
  cout << (sd * sd == d ? "Yes" : "No") << endl;
  return 0;
}


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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

arr = prime_factorize(N)
print(len(list(set(arr))) + 1)

Measured memory_bytes: 5048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        if(nums[0]==nums[1]) Console.WriteLine(nums[2]);    
        else if (nums[1] == nums[2]) Console.WriteLine(nums[0]);
        else Console.WriteLine(nums[1]);
	}
}

Measured memory_bytes: 13268
#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

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

int main()
{
	int a, b;

	a = in(), b = in();
	printf("%d\n", gcd(a, b));
	return 0;
}




Measured memory_bytes: 2060
# solution

data=int(input())
array=list(map(int,input().split()))

result=[]
box=[0]*data

for i in reversed(range(1,data+1)):
  asum=sum(box[i-1::i])
  if asum%2+array[i-1]==1:
    box[i-1]=1
    result.append(i)

print(len(result))
print(*result)

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;

	int n=s.length();
	int m=t.length();
	int lcs[n+1][m+1];
	memset(lcs,0,sizeof lcs);

	for(int i=1;i<=n;i++)
	{
	for(int j=1;j<=m;j++)
	{
	if(s[i-1]==t[j-1])
	lcs[i][j]=1+lcs[i-1][j-1];
	else
	lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
	}
	}

	int l=lcs[n][m];
	//cout<<"l"<<l;
	int i=n,j=m,k=0;
    char arr[l];

	while(i>0&&j>0)
	{
    if(s[i-1]==t[j-1])
    {
    arr[k]=s[i-1];
    k++;
    i--;
    j--;
    //cout<<arr[l];
    //cout<<"i"<<i<<"j"<<j<<" ";
    }
    else if(lcs[i][j]==lcs[i-1][j])
    i--;
    else if(lcs[i][j]==lcs[i][j-1])
    j--;   
   // cout<<"i"<<i<<"j"<<j<<" ";
    }
    
    for(int i=l-1;i>=0;i--)
    cout<<arr[i];

	return 0;
}

Measured memory_bytes: 38692
#include <iostream>

using namespace std;

const int N = 200;

int n;
int a[N];

int main() {
	
	cin >> n;
	for (int i = 1; i < n; ++i)	cin >> a[i];
	
	int res = a[n - 1] + a[1];
	for (int i = n - 1; i > 1; --i)	res += min(a[i], a[i - 1]);
	
	cout << res << endl;
	
	return 0;
}

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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; i++)

int main ()
{
    int x; cin >> x;
    cout << x * x << endl;
    return 0;
}


Measured memory_bytes: 256