akhauriyash/Code-Regression huggingface dataset:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)
 
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    # print(B) 
    
    Hit = [[False] * 3, [False] * 3, [False] * 3]
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if A[i][j]== B[k]:
                    Hit[i][j] = True
                    break
    
    ans = False
    for i in range(3):
            if (Hit[i][0] and Hit[i][1] and Hit[i][2]) or (Hit[0][i] and Hit[1][i] and Hit[2][i]):
              ans = True
              break  
    if (A[0][2] and Hit[1][1] and Hit[2][0]) or (Hit[0][0] and Hit[1][1] and Hit[2][2]):
        ans = True

    if ans:
        print('Yes')
    else:
        print('No')
main()

Measured memory_bytes: 27212
package main

import "fmt"

func main() {
	var day string
	fmt.Scan(&day)
	switch day {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	default:
		fmt.Println(0)
	}
}

Measured memory_bytes: 512
#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;
using P = pair<int,int>;
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 main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3572
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			String s = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(s + " " + (a + b) + " " + (a * 200 + b * 300));
		}
	}
}

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

int main()
{
   int n,k,sum=0,ans=1e9;
   vector<int>v;
   cin>>n>>k;
   for(int i=1;i<=n;i++){ 
       v.push_back(i+k-1);
       sum+=(i+k-1);
   } 
   int pr;
   for(int i=0;i<v.size();i++){ 
        int cur=sum-v[i];
        if( (abs(sum-cur))<ans){
            ans=(abs(sum-cur));
            pr=cur;
        } }
   cout<<pr;
   
   
   
    return 0;
}


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

int main(){
  int a[10010],i=0;
  while(true){
    scanf("%d",&a[i]);
    if(a[i]==0)break;
    i++;
  }
  i=0;
  while(a[i]!=0){
    printf("Case %d: %d\n",i+1,a[i]);
    i++;
  }
}



Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

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

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {

	ll N, K;
	cin >> N >> K;

	mint ans = 0;

	for (ll i = K; i <= N + 1; i++) {
		ans += i * (N - i + 1) + 1;
	}

	cout << ans;
	system("PAUSE");
}


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

int mpow(int a, int b, int m) {
  int res = 1;
  do {
    if(b & 1) res = 1LL * res * a % m;
    a = 1LL * a * a % m;
  } while(b >>= 1);
  return res;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> f(n + 1);
  for(int i = 1; i <= n; ++i) {
    f[i] = 1 + f[i % __builtin_popcount(i)];
  }
  int on = 0;
  for(char c : s) if(c == '1') on += 1;

  int neg = 0, plus = 0;
  for(int i = 0; i < n; ++i) {
    if(s[i] == '1') {
      if(on > 1) neg += mpow(2, n - 1 - i, on - 1);
      plus += mpow(2, n - 1 - i, on + 1);
      if(on > 1) neg %= on - 1;
      plus %= on + 1;
    }
  }
  for(int i = 0; i < n; ++i) {
    if(s[i] == '0') {
      int ans = plus;
      ans += mpow(2, n - 1 - i, on + 1);
      ans %= on + 1;
      cout << 1 + f[ans] << '\n';
    } else {
      if(on == 1) {
        cout << 0 << '\n';
        continue;
      }
      int ans = neg;
      ans -= mpow(2, n - 1 - i, on - 1);
      ans %= on - 1;
      if(ans < 0) ans += on - 1;
      cout << 1 + f[ans] << '\n';
    }
  }

}

Measured memory_bytes: 4376
# coding: utf-8
for i in range(3000):
    line = input().rstrip().split()
    a = int(line[0])
    b = int(line[1])
    if (a == 0 and b == 0):
        break
    if (b < a):
        a,b = b,a
    print(str(a) + " " + str(b))


Measured memory_bytes: 5624
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(ll i=a;i<b;i++)
#define rfor(i,a,b)     for(ll i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

ll _gcd(ll a, ll b)
{
    if(b == 0) return a;
    return _gcd(b,a%b);
}

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

vector<int> fwd,bwd,arr,ans;
void solve()
{
    int n,k,c; cin>>n>>k>>c;
    rep(i,1,n+1)
    {
        char x; cin>>x;
        if(x!='x') arr.pb(i);
    }
    n = arr.size();
    rep(i,0,n)
    {
        if(fwd.size() == k) break;
        if(fwd.empty()) { fwd.pb(arr[i]); continue; }
        if(arr[i] - c > fwd.back()) fwd.pb(arr[i]);
    }
    rfor(i,n-1,0)
    {
        if(bwd.size() == k) break;
        if(bwd.empty()) { bwd.pb(arr[i]); continue; }
        if(arr[i] + c < bwd.back()) bwd.pb(arr[i]); 
    }
    if(fwd.size()!=k or bwd.size()!=k) return;
    reverse(all(bwd));
    rep(i,0,k)
    {
        if(fwd[i] == bwd[i]) ans.pb(fwd[i]);
    }
    for(int i:ans) cout<<i<<endl;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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

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

int N;
int C;
int D[30][30];
int cnt[3][30];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C;
	FOR(y,C) FOR(x,C) cin>>D[y][x];
	FOR(y,N) FOR(x,N) {
		cin>>j;
		cnt[(y+x)%3][j-1]++;
	}
	
	ll ret=1LL<<60;;
	int a,b,c;
	FOR(a,C) FOR(b,C) FOR(c,C) {
		if(a==b || a==c || b==c) continue;
		ll tot=0;
		FOR(y,C) tot+=cnt[0][y]*D[y][a];
		FOR(y,C) tot+=cnt[1][y]*D[y][b];
		FOR(y,C) tot+=cnt[2][y]*D[y][c];
		ret=min(ret,tot);
	}
	
	cout<<ret<<endl;
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b and b == c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200010],A[200010];
int main()
{
	int n,k,ans=0;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=k-1;i++)
		A[i]=a[i+1]-a[i];
	A[k]=n-a[k]+a[1];
	sort(A+1,A+1+k);
	for(int i=1;i<=k-1;i++)
		ans=ans+A[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

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

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

  bool res = false;
  if (abs(a - c) <= d) res = true;
  else if (abs(a - b) <= d && abs(b - c) <= d) res = true;
  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var m = int.Parse(spl[2]);

        var hash = new HashSet<Tuple<int, int>>();

        var vbom = new int[w];
        var hbom = new int[h];

        int vmax = 0;
        int hmax = 0;

        var vmaxPoint = new List<int>();
        var hmaxPoint = new List<int>();

        for (int i=0; i<m; i++) {
            spl = input.ReadLine().Split(' ');
            var ph = int.Parse(spl[0]) -1;
            var pw = int.Parse(spl[1]) -1;

            //hash.Add(((long)ph << 32) | (long)pw);
            hash.Add(Tuple.Create(ph, pw));

            hbom[ph]++;
            vbom[pw]++;

            if (vbom[pw] > vmax) {
                vmax = vbom[pw];
            }

            if (hbom[ph] > hmax) {
                hmax = hbom[ph];
            }
        }

        for(int i=0; i<vbom.Length; i++) {
            if(vbom[i] == vmax) vmaxPoint.Add(i);
        }
        for (int i = 0; i < hbom.Length; i++) {
            if (hbom[i] == hmax) hmaxPoint.Add(i);
        }

        foreach (var ph in hmaxPoint) {
            foreach(var pw in vmaxPoint) {
                //long p = ((long)ph << 32) | (long)pw;
                //string p = ph + ":" + pw;
                var p = Tuple.Create(ph, pw);
                if (!hash.Contains(p)){
                    return (long)vmax + (long)hmax;
                }
            }
        }

        return (long)vmax + (long)hmax - 1;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 68368
#include <iostream>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using Wbool = std::vector<Vbool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;
template <class T>
using Vec = std::vector<T>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define DEBUG(x) std::cerr << #x << " = " << x << '\n';
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())
#define RSORT(A) std::sort((A).rbegin(), (A).rend())
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())



template <class T> inline int argmin(std::vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(std::vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){if(a < b) a = b;}
template <class T> inline void chmin(T &a, T b){if(a > b) a = b;}
template <class T> inline void reverseSORT(Vec<T> &Array){
  std::sort(Array.begin(), Array.end(), std::greater<T>());
}
inline int BitI(int k){return 1 << k;}
inline lli BitL(int k){return 1LL << k;}
inline void putsDouble(double d){printf("%.16lf\n", d);}
inline int toInt(const string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res;
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
    int n, k; cin >> n >> k;
    std::string s; cin >> s;
    s.at(k - 1) += ('a' - 'A');
    cout << s << BR;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout << "vowel" <<endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main(){
    fastio;
    file();
    int n,k;
    cin>>n>>k;
    if(n*500>=k){
        test("Yes");
    }
    else{
        test("No");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<a.size();){
    bool flag=true;
    for(int j=0;j<a[0].size();j++){
      if(a[i][j]=='#') flag=false;
    }
    if(flag) {
      a.erase(a.begin()+i);
      continue;
    }
    i++;
  }
  for(int i=0;i<a[0].size();){
    bool flag=true;
    for(int j=0;j<a.size();j++){
      if(a[j][i]=='#') flag=false;
    }
    if(flag) {
      for(int j=0;j<a.size();j++){
        a[j].erase(a[j].begin()+i);
      }
      continue;
    }
    i++;
  }
  for(auto &e:a){
    for(auto &i:e) cout<<i;    
    cout<<endl;
  }
}

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

typedef long long ll;

struct Node {
    string pattern;
    ll len,factor;
    vector<Node*> child;
};

int p;

Node *parse(string &s) {
    if(isdigit(s[p])) {
        int r = 0;
        while(isdigit(s[p])) {
            r *= 10;
            r += s[p] -'0';
            p++;
        }

        Node *node = new Node();
        node->factor = r;
        if(s[p] == '(') {
            p++;
            while(s[p] != ')') {
                Node *nr = parse(s);
                node->child.push_back(nr);
            }
            p++;
            node->len = 0;
            for(int i=0; i<node->child.size(); ++i)
                node->len += node->child[i]->len;

            node->len *= node->factor;
            return node;
        }else{
            node->pattern = string(1,s[p]);
            p++;
            node->len = r;
            return node;
        }
    }

    Node *node = new Node();
    string pattern = "";
    while(p < s.length() && isalpha(s[p])) {
        pattern += string(1,s[p]);
        p++;
    }
    node->pattern = pattern;
    node->len = pattern.length();
    node->factor = 1;
    return node;
}

char dfs(Node *v,ll idx) {
    if(v->child.empty()) {
        string pat = v->pattern;
        if(idx < v->factor*pat.length()) return pat[idx%(pat.length())];
        v->len = pat.length()*(v->factor);
        return '-';
    }

    ll offset = 0;
    for(int i=0; i<v->child.size(); ++i) {
        char c = dfs(v->child[i],idx-offset);
        if(c != '-') return c;
        offset += v->child[i]->len;
    }
    if(idx/offset < v->factor) {
        idx %= offset;
        return dfs(v,idx);
    }
    v->len = offset*v->factor;
    return '-';
}

int main() {
    int n;
    string s;
    while(cin>>s) {
        cin>>n;
        if(s == "0" && n == 0) break;
        p = 0;
        s += ")";
        s = "1(" + s;
        Node *root = parse(s);
        char ans = dfs(root,n);
        if(ans == '-') cout<<"0"<<endl;
        else cout<<ans<<endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  bool nazo=true;
  for(int i=0;i<S.size();i++){
  	if(i%2==0){
    	if(S.at(i)== 'R' || S.at(i)=='U' || S.at(i)=='D' ){
        continue;
        }
      	else{
        nazo=false;
        }
    }
    else{
    if(S.at(i)== 'L' || S.at(i)=='U' || S.at(i)=='D' ){
        continue;
        }
      	else{
        nazo=false;
        }
      
    }
  }
  
  
  
  if(nazo){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);

  vector<int> ck(n);
  int btn = 0;
  int cnt = 1;
  while (true) {
    if (a.at(btn) == 2) {
      cout << cnt << endl;
      exit(0);
    }
    else if (ck.at(btn) == 1) {
      cout << -1 << endl;
      exit(0);
    }
    else {
      ck.at(btn) = 1;
      btn = a.at(btn) - 1;
      cnt++;
    }
  }
}

Measured memory_bytes: 1024
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define repe(i,a) for(auto &i:a)

void in(){} template<typename Head,typename... Tail> void in(Head&& head,Tail&&... tail){cin>>head;in(forward<Tail>(tail)...);}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int a,b,c,k;
  in(a,b,c,k);
  rep(s,k+1){
    rep(t,k+1){
      rep(u,k+1){
        int x=a*(1<<s),y=b*(1<<t),z=c*(1<<u);
        if(s+t+u<=k && x<y && y<z){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  int n;
  int counter = 0;
  string pattern;
  cin >> pattern >> n;
  for( int i = 0; i < n; i++ ) {
    string line, rline;
    cin >> line;
    if(
        ( line + line ).find( pattern ) != string::npos
    ) {
      counter++;
    }
  }
  cout << counter << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1212
as = 3.times.map{gets.chomp.split.map(&:to_i)}
n = gets.to_i
bs = n.times.map{gets.to_i}
bingo = Array.new(3){Array.new(3,0)}
bs.each do |b|
  (0..2).each do |i|
    (0..2).each do |j|
      if as[i][j] == b
        bingo[i][j] = 1
      end
    end
  end
end
flag = false
(0..2).each do |i|
  if bingo[i].all?{|v| v == 1}
    flag = true
  end
  if bingo.transpose[i].all?{|v| v == 1}
    flag = true
  end
  if bingo[0][0] == 1 && bingo[1][1] == 1 && bingo[2][2] == 1
    flag = true
  end
  if bingo[0][2] == 1 && bingo[1][1] == 1 && bingo[2][0] == 1
    flag = true
  end
end
puts flag ? "Yes" : "No" 

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	

    int N, M; cin >> N >> M;
    VI adjlist[N];
    REP(i,M)
    {
        int tmpa,tmpb; cin >> tmpa >> tmpb;
        tmpa--; tmpb--;
        adjlist[tmpa].pb(tmpb);
        adjlist[tmpb].pb(tmpa);
    }
    bool ok = 0;

    for(auto i : adjlist[0])
    {
        dump(i)
        for(auto j : adjlist[i])
        {
            if(j == N-1) ok = 1;
        }

    }

    if(ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

}


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

int main(){
  int N, K;
  cin >> N >> K;
  double pr = 0.0;//確率
  int score;
  for(int i=0;i<N;i++){
    int count = 0;
    score = i + 1;
    while(score < K){
      score *= 2;
      count++;
    }
    if(count != 0)
      pr += 1.0 / N * pow(0.5, count);
    else
      pr += 1.0 / N;
  }
  cout << fixed << setprecision(10) << pr << endl;
  return 0;
}


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

int main (){
       int a,b,c,t;
       cin>>a>>b>>c;

       if(a>b){
	      t=a; a=b; b=t;
       }
       if(b>c){
	      t=b; b=c; c=t;
       }
       if(a>b){
	      t=a; a=b; b=t;
       }

       cout<<a<<' '<<b<<' '<<c<<endl;

       return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

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

    string s, t;
    cin >> s >> t;

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

    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t ) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    
modKey  = (`mod` 1000003)

yakusuBetween :: Int -> Int -> Int -> Int
yakusuBetween l h n = h `div` n - ((l - 1) `div` n )

solve :: Int -> Int -> Int -> Int -> Int
solve a b c d = let
    cYakusu = yakusuBetween a b c
    dYakusu = yakusuBetween a b d
    cdYakusu = yakusuBetween a b $ lcm c d
    totalYakusu = cYakusu + dYakusu - cdYakusu
    in
        b - a + 1 - totalYakusu

main = do
    [a,b,c,d] <- readInts
    print $ solve a b c d




Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MAXN 100009
int points[MAXN][3], dp[MAXN][3];

int solve(int i, int a){
    if (dp[i][a] != -1)
        return dp[i][a];
    if (i == 1)
        return dp[i][a] = max(points[i][(a+1)%3], points[i][(a+2)%3]);
    return dp[i][a] = max(points[i][(a+1)%3] + solve(i - 1, (a+1)%3), 
                            points[i][(a+2)%3] + solve(i - 1, (a+2)%3));

}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    rep(i, 1, n + 1){
        cin >> points[i][0] >> points[i][1] >> points[i][2]; 
    }
    cout << max(solve(n, 0), max(solve(n, 1), solve(n, 2))) << '\n';
    return 0;
}

Measured memory_bytes: 8832
N,M,X = map(int,input().split())

A = []
C = []
for i in range(N):
    b = list(map(int,input().split()))
    C.append(b[0])
    A.append(b[1:])

money = []
for i in range(M):
    money.append(0)

res = 10**10
for bits in range(2**N):
    tmp = 0
    for i in range(M):
        money[i] = 0

    for i in range(N):
        if (bits>>i)&1:
            tmp+=C[i]
            for j in range(M):
                money[j]+=A[i][j]
    jadge = True
    for i in range(M):
        if money[i] < X:
            jadge = False

    if jadge:
        res = min(tmp,res)

if res == 10**10:
    print(-1)
else:
    print(res)


Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> const int inf<int> = 1e9;
template <> const ll inf<ll> = 1e18;
 
char winner(string const& s, int& p, vector<int>& cnt) {
    if('a' <= s[p] && s[p] <= 'z') {
        return s[p++];
    } else {
        int p1 = winner(s, ++p, cnt) - 'a';
        p++;
        int p2 = winner(s, p, cnt) - 'a';
        p++;
        int lose, win;
        if(cnt[p1] > cnt[p2]) {
            lose = p2; win = p1;
        } else {
            lose = p1; win = p2;
        }
        if(cnt[lose] > 0 || cnt[win] <= 0) {
            throw runtime_error("hoge");
        }
        cnt[win]--;
        cnt[lose]--;
        return 'a' + win;
    }
}
 
int main() {
    string S;
    cin >> S;
    vector<int> cnt(26);
    char c; int win;
    while(cin >> c >> win) {
        cnt[c - 'a'] = win;
    }
    int p = 0;
    try {
        winner(S, p, cnt);
        if(*max_element(cnt.begin(), cnt.end()) > 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } catch(...) {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3276
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  string S;
  cin>>S;
  
  long int AAA=0,BC=0,ans=0;
  for(int i=0; i<S.size()-1; ++i){
    if(S.at(i)=='A') AAA++;
    else if(S.at(i)=='B' && S.at(i+1)=='C'){
      ans+=AAA;
      ++i;
    }
    else AAA=0;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int inmu, yj, hide, kiji, db, hage[10000] = {};
	cin >> inmu;
	cin >> yj >> hide;
	cin >> kiji;
	for(int i = 0; i < inmu; i++){
		cin >> hage[i];
	}
	sort(hage, hage + inmu, greater<int>());
	for(int i = 0; i < inmu; i++){
		db = kiji / (yj + hide * i);
		kiji += hage[i];
		if(db > kiji / (yj + hide * (i + 1))){
			cout << db << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}
int t[100][100];

int main(){
	int n,m,a,s,i=0,j=0;
	cin>>n>>m>>s;
	rep(tt,s){
		cin>>a;
		bool end = false;
		int d= 0;
		for(;i<n&&!end;){
			if(j==m)j=0;
		for(;j<m&&!end;j++){
			d++;
			t[i][j]=tt+1;
			if(d==a)end = true;
		}
		if(j==m)i++;
	}
	}
	rep(i,n){
	if(i%2)	rep(j,m)cout<<t[i][j]<<' ';
	else	for(int j=m-1;j>=0;j--)cout<<t[i][j]<<' ';
	cout<<endl;}
	return 0;
 }

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e8+1, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,w;
	cin>>n>>w;
	int x[n],y[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	
	ll dp[w+1][n];
	memset(dp,0,sizeof dp);
	for(int i=x[0];i<=w;i++){
		dp[i][0]=y[0];
	}
	
	for(int i=1;i<n;i++){
		for(int wt=0;wt<=w;wt++ ){
			dp[wt][i]=dp[wt][i-1];
			if(wt>=x[i])dp[wt][i]=max(dp[wt][i], dp[ wt-x[i] ][i-1]+ y[i] );
		}
	}
	
	cout<<dp[w][n-1];
}
// check for any potential overflow before submitting



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

rest = []
for i in range(m):
  a, b = input().split()
  rest.append((int(a), b))

done = False

for i in range(0, 1000):
  x = str(i)
  if (len(x) == n):
    ok = True
    for t in rest:
      if x[t[0]-1] != t[1]:
        ok = False
    if ok:
      if not done:
        print(i)
        done = True

if not done:
  print(-1)



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int N2 = int.Parse(str[1]);
		string ans = ":(";
		if(N<=8 && N2<= 8){
			ans = "Yay!";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <stdio.h>
int main(void){ 
  int i=0,j,k;
  scanf ("%d",&i);
  if (i==1){
    printf("Hello World");
  }else {
    scanf ("%d",&j);
    scanf ("%d",&k);
 
    printf("%d",j+k);
    return 0;
  }
}


Measured memory_bytes: 128
using System;

class Problem
{
  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int A = inputs[0], B = inputs[1], C = inputs[2];
    if (C >= A && C <= B) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  string s;
  int n, cnt;
  cin >> n >> s;
  cnt = 0;
  for (int i = 0; i < 1000; i++) {
    int c[3] = {i / 100, i / 10 % 10, i % 10};
    int f = 0;
    for (int j = 0; j < n; j++) {
      if (c[f] == s[j] - '0') f++;
      if (f == 3) break;
    }
    if (f == 3) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3560
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
ddd = get_nums_l()

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += ddd[i] * ddd[j]

print(ans)

Measured memory_bytes: 3568
# import itertools
# import math
# import fractions
# import functools
# import copy
# from collections import deque
# from functools import reduce
# from decimal import Decimal


def main():
    n = int(input())
# a, b = map(int, input().split())
# l = list(map(int, input().split()))
# s = input()

    if n == 1:
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61664
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+10;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
int main()
{
	int n;cin>>n;
	int z=n%10;
	if(z!=1&&z!=3&&z!=7&&z!=9)
	cout<<-1<<endl;
	else
	{
		int ans=1;
		ll sum=7;
		while(sum%n!=0)
		{
			sum=sum*10+7;
			sum%=n;
			ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    int s = 0;
    vector<int> A(n);
    rep(i, n) {
        cin >> A[i];
        s ^= A[i];
    }
    rep(i, n) {
        int b = s ^ A[i];
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 4020
def fennec_vs_monster():
    # 入力
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    # 体力リストを降順でソート
    H.sort(reverse=True)
    # 体力リストを先頭からK個だけ除外
    H = H[K:]
    # 残りの体力リストを合計
    sum_H = sum(H)
    # 攻撃の回数の最小値
    return sum_H

result = fennec_vs_monster()
print(result)

Measured memory_bytes: 31608
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
ll MOD = 1000000007;
const int mod = 1000000007;
ll INF = 1LL << 60;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
   for (auto &v : vec)
      is >> v;
   return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
   os << "[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
   os << "deq[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
   os << "(" << pa.first << "," << pa.second << ")";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
   fill((T *)array, (T *)(array + N), val);
}


bool is_prime(int v){
   for(int i=2; i*i <= v; i++){
      if(v%i==0)
         return false;
   }
   return true;
}

int rui[101010];
int solve()
{
   int q;
   cin >> q;
   
   for(int i=2; i < 100001; i++){
      if(is_prime(i) && is_prime((i+1)/2) && i % 2 == 1){
         rui[i] = rui[i - 1] + 1;
      }else{
         rui[i] = rui[i - 1];
      }
   }

   for(int i=0; i < q; i++){
      int l, r;
      cin >> l >> r;
      cout << rui[r] - rui[l - 1] << endl;
   }

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

   solve();
}

Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))

mod = 10**9+7

cs = [0]
for a in A:
    cs.append(cs[-1]+a)
cs = cs[1:]

ans = 0
for i in range(n):
    ans += A[i] * (cs[-1]-cs[i])
    ans %= mod
print(ans)

Measured memory_bytes: 31636
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list> 
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int S[1000] = { 0 };


int main() {
	ll Q;
	cin >>Q;
	list<ll>Y;
	list<ll>::iterator itr = Y.end();
	rep(i,Q) {

		int a;
		cin >> a;
		if (a==0) {
			int b;
			cin >> b;
			itr=Y.insert(itr,b);
		}
		else if (a == 1) {
			int b;
			cin >> b;
			if (0 < b)rep(j, b)itr++;
			else {
				int c = abs(b);
				rep(j, c)itr--;
			}
		}
		else {
			itr=Y.erase(itr);
		}
	}
	for (list<ll>::iterator flg = Y.begin(); flg != Y.end();++flg) {
		cout << *flg << endl;
	}
	return 0;
}





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

int main() {
  int N, M;

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

  cin >> M;
  vector<string> y(M);
  for (int i = 0; i < M; i++)
  {
    cin >> y.at(i);
  }
  

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int cnt = 0;

    for (int j = 0; j < N; j++)
    {
      if (x.at(i) == x.at(j))
      {
        cnt++;
      }
    }
    for (int k = 0; k < M; k++)
    {
      if (x.at(i) == y.at(k))
      {
        cnt--;
      }
    }
    
    ans = max(ans, cnt);
  }

  cout << ans << endl;
}

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

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    
    if(a>k){
        cout << a-k << " " << b << " " << endl;
    }
    else if(a<=k){
        if((k-a)<b){
            cout << 0 << " " << b-(k-a) << " " << endl;
        }
        else{
            cout << 0 << " " << 0 << endl;
        }
    }

        //cout << a <<" "<<b<<" "<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n,m,ans;
double ANS;
int a[101][101];
int g[101];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ANS=0;
			for(int k=1;k<=m;k++) ANS+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			ANS=sqrt(ANS);
			if(ANS==(int)ANS) ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

a,b,c=ii()

x=[a]
if b not in x:
    x.append(b)
if c not in x:
    x.append(c)

print len(x)


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    // テレポートするなら歩かない
    // xi < xi+1
    
    int n, a, b;
    cin >> n >> a >> b;
    
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    
    ll sum = 0;
    rep3(i, 1, n) {
        sum += min((ll)b, (ll)(x[i] - x[i - 1]) * a);
        
    }
    cout << sum << endl;
}


Measured memory_bytes: 768