akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;
/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}



int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0)cnt++;
		}
		if (cnt == 8)ans++;
	}
	cout << ans;
	return 0;
}













Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <stdexcept>
#include <utility>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; i <= h; ++i)
using namespace std;


    int main() {
        double n;
        cin >> n;
        int k = ceil(n / 111.0);
        cout << k * 111 ;
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N;

    cin >> N;

    int ans, dp, dc;
    for(int div = 100; div > 1; div /= 10)
    {
        dp = N / div;
        dc = (N % div) / (div / 10);
        if(dp > dc)
        {
            ans = dp;
            break;
        }
        else if(dp < dc)
        {
            ans = dp + 1;
            break;
        }
        else
        {
            ans = dp;
        }
        N %= div;
    }

    cout << ans << ans << ans << endl;

    return 0;
}

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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s, t, ans;
    int n;
    cin >> n >> s >> t;

    for (int i = 0; i < n; ++i) ans.pb(s[i]), ans.pb(t[i]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int n,p,x;
long long a[2]={1,0};
int main(){
	scanf("%d%d",&n,&p);
	while(n--){
		scanf("%d",&x);
		if(x&1){
			a[0]+=a[1];
			a[1]=a[0];
		}else{
			a[0]<<=1;
			a[1]<<=1;
		}
	}
	printf("%lld\n",a[p]);
	return 0;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
    x = 100;
  }
  else if(x == 4 || x == 6 || x == 9 || x == 11){
    x = 200;
  }
  else{
    x = 300;
  }
  if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
    y = 100;
  }
  else if(y == 4 || y == 6 || y == 9 || y == 11){
    y = 200;
  }
  else{
    y = 300;
  }
  if(x == y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()

main(){
  int b,r,g,c,s,t;
  while(cin>>b>>r>>g>>c>>s>>t){
    if (b+r+g+c+s+t == 0)break;
    int ge=100,lo=0;
    lo=3*t;
    lo-=s*3;
    lo-=b*5;
    lo-=r*3;
    

    ge+=b*5*15;
    ge+=r*3*15;
    ge+=c*2;
    ge+=g*7;
    ge+=r*15;
    ge+=b*15;
    cout << ge-lo << endl;
    //cout << ge <<" " << lo << endl;
  }
  return false;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    int d[107]={0};
    int k;
    for(int i=1;i<=m;i++)
    {
        cin>>k;
        d[k]=1;
    }
    int S=0;
    for(int i=x;i<=n;i++)
    {
        S+=d[i];
    }
    int S1=0;
    for(int i=x;i>=0;i--)
    {
        S1+=d[i];
    }
    cout<<min(S,S1);
}

Measured memory_bytes: 256
# C - Train Ticket
import sys
num = input()

for i in range(2**3):
    ope = ''
    for j in range(3):
        if i >> j & 1:
            ope += '+'
        else:
            ope += '-'
    if eval(num[0]+ope[0]+num[1]+ope[1]+num[2]+ope[2]+num[3]) == 7:
        print(num[0]+ope[0]+num[1]+ope[1]+num[2]+ope[2]+num[3]+'=7')
        sys.exit()


Measured memory_bytes: 9060
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int main(void) {
	int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    
    printf("%d\n", min(B/A, C));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll n)
{
    ll ans = 0;
    while(n%2!=1)
    {
         ans++;
         n=n/2;
    }
    return ans;
}
int main()
{
  int a,b;
  cin>>a>>b;
  int x = ceil((1.0*(a+b))/2);
  cout<<x;
   //cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...

string s,t;
void test_case(){
	cin>>s>>t;
	int cnt = 0;
	for(int i = 0;i<sz(s);++i){
		if(s[i]!=t[i]) ++cnt;
	}
	cout<<cnt;
}





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,ans,k,j,temp;
    cin>>n>>k;
    vector<int> v(n),dp(n);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    dp[n-1]=0;
    dp[n-2]=abs(v[n-1]-v[n-2]);
    for(i=n-3;i>=0;i--)
    {
        ans=INT_MAX;
        for(j=0;j<k;j++)
        {
            if((i+j+1)<(n))
            {
                temp=abs(v[i]-v[i+j+1])+dp[i+j+1];
                ans=min(ans,temp);
            }
        }
        dp[i]=ans;
    }
    cout<<dp[0];
}


Measured memory_bytes: 1152
import java.io.*;
import java.math.*;

class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] str_Numbers = br.readLine().split(" ");

    BigDecimal divident = new BigDecimal(str_Numbers[0]);
    BigDecimal divisor = new BigDecimal(str_Numbers[1]);
    BigDecimal int_quotient = divident.divide(divisor,BigDecimal.ROUND_DOWN);
    BigDecimal remainder = divident.remainder(divisor);
    BigDecimal real_quotient = divident.divide(divisor,5,BigDecimal.ROUND_HALF_UP);

    System.out.println(int_quotient + " " + remainder + " " + real_quotient);;
  }
}



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

int t0[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int t1[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool isLeap(int y){
  return y % 4 == 0 && (y % 400 == 0 || y % 100 != 0);
}

class Date{
public:
  int y, m, d;

  Date(){}
  Date(int _y, int _m, int _d){
    y = _y;
    m = _m;
    d = _d;
  }

  bool operator==(const Date &date)const{
    return y == date.y && m == date.m && d == date.d;
  }

  void inc(){
    d++;

    if(isLeap(y) && t1[m] < d || !isLeap(y) && t0[m] < d){
      d = 1;
      m++;
    }
    if(12 < m){
      m = 1;
      y++;
    }
  }
};

int main(){
  Date date1, date2;

  while(cin >> date1.y >> date1.m >> date1.d >> date2.y >> date2.m >> date2.d){
    if(date1.y == -1) break;

    int ans = 0;

    while(!(date1 == date2)){
      date1.inc();
      ans++;
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>
void Swap(int x[],int l,int r){
	int temp;
	temp=x[l];
	x[l]=x[r];
	x[r]=temp;
}
void Qsort(int x[],int l,int r){
	int i,j,p;
	i=l;
	j=r;
	p=x[(i+j)/2];
	while(1){
		while(x[i]<p)i++;
		while(x[j]>p)j--;
		if(i>=j)break;
		Swap(x,i,j);
		i++;
		j--;
	}
	if(i-l>1)Qsort(x,l,i-1);
	if(r-j>1)Qsort(x,j-1,r);
}
int main(){
	int a[3], n,i,j;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		for(j=0; j<3; j++){
			scanf("%d",&a[j]);
		}
		//Qsort(a,0,2);
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]||a[2]*a[2]+a[1]*a[1]==a[0]*a[0]||a[0]*a[0]+a[2]*a[2]==a[1]*a[1])printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
  static int[] par;
  static int[] rank;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    par = new int[n];
    rank = new int[n];

    int M = sc.nextInt();
    init(n);
    
    for(int i = 0; i < M; i++) {
      int x = sc.nextInt() - 1;
      int y = sc.nextInt() - 1;
      int z = sc.nextInt();
      unite(x, y);
    }
    HashSet<Integer> set = new HashSet<Integer>();
    for(int i = 0; i < n; i++) {
      set.add(find(i));
    }
    System.out.println(set.size());
  }
  static void init(int m) {
      for(int i = 0; i < m; i++) {
        par[i] = i;
        rank[i] = 1;
      }
  }
  static int find(int x) {
      if(par[x] == x) {
        return x;
      } else {
        return par[x] = find(par[x]);
      }
  }
  static void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if(x == y) return;

      if(rank[x] < rank[y]) {
        par[x] = y;
      } else {
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
      }
  }
  static boolean same(int x, int y) {
      return find(x) == find(y);
  }
}

Measured memory_bytes: 92296
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel par;
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
signed main() {
	int h, w; cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	vvel lef(h, vel(w,0));
	vvel ri = lef;
	vvel up = lef;
	vvel dw = lef;
	rep(i, h) {
		if (s[i][0] == '.') { lef[i][0] = 1; }
		rp(j, w) {
			if (s[i][j] == '.') { lef[i][j] = lef[i][j - 1] + 1; }
		}
		if (s[i][w - 1] == '.') { ri[i][w - 1] = 1; }
		for (int j = w - 2; j >= 0; j--) {
			if (s[i][j] == '.') { ri[i][j] = ri[i][j + 1] + 1; }
		}
	}
	rep(i, w) {
		if (s[0][i] == '.') { up[0][i] = 1; }
		rp(j, h) {
			if (s[j][i] == '.') { up[j][i] = up[j-1][i] + 1; }
		}
		if (s[h-1][i] == '.') { dw[h-1][i] = 1; }
		for (int j = h - 2; j >= 0; j--) {
			if (s[j][i] == '.') { dw[j][i] = dw[j+1][i] + 1; }
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			mmax(ans, lef[i][j] + ri[i][j] + up[i][j] + dw[i][j] - 3);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 129664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int tap = 1;
		int ans = 0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		while(tap < b) {
			tap += a-1;
			ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

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

    vector<vector<int>> c(M+1);
    int a,b;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        if(a<=M){
            c[a].emplace_back(b);
        }
    }

    int ans=0;
    priority_queue<int> q;
    for(int i=1;i<=M;i++){
        for(auto p:c[i]){
            q.push(p);
        }
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 8328
module Main where

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    s <- getLine
    putStrLn $ map (convert n) s

convert :: Int -> Char -> Char
convert n c =
    case fromEnum c + n of
        i | i > fromEnum 'Z' -> toEnum $ i - 26
        i                    -> toEnum i


Measured memory_bytes: 1404
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  cin >> a >> b;
  
  if(a + b == 15)
    cout << "+" << endl;
  else if(a * b == 15)
    cout << "*" << endl;
  else
    cout << "x" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import math
import numpy as np

def main():
    N= int(input())
    Bs = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if i == 0:
            A_max = Bs[0]
        elif i == N-1:
            A_max = Bs[-1]
        else:
            A_max = min(Bs[i-1], Bs[i])

        ans += A_max

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14504
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	string s;
	cin >> s;
	for(int i = 1; i < 4; i++) {
		if(s[i] == s[i - 1]) {
			cout << "Bad" << endl;
			return;
		}
	}
	
	cout << "Good" << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        decimal rate = decimal.Parse(Reader.ReadLine());
        decimal goal = decimal.Parse(Reader.ReadLine());
        decimal ans = goal * 2 - rate;
        Console.WriteLine(ans);
    }



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



2002
2017


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 

const long long int mod=1000000007;
const long long int INF=99999999999999999;




string S;
vector<long long int>Q;
long long int res=0,memo=0;
int main() {
	cout << fixed << setprecision(18);
    cin>>S;
    for(int i=0;i<(1<<(S.length()-1));i++){
        memo=0;
        for(int j=0;j<S.length();j++){
            memo=10*memo+S[j]-'0';
            if((i&(1<<j))==0){
                res+=memo;
                memo=0;
            }else{
                
            }
        }
        res+=memo;
    }
    cout<<res<<endl;
} 


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 ALL(v) v.begin(), v.end()
 
using namespace std;
 
auto main() -> int
{
   string S;  cin >> S;
   
   auto n = S.length();
   
   REP(i, n) cout << "x";
   
   cout << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	int k,q;
	cin>>k>>q;
	vector<int> d(k);
	for (int i = 0; i < k; i++)cin>>d[i];
	for (int i = 0; i < q; i++){
		int n,x,m;
		cin>>n>>x>>m;
		vector<int> d_mod_m(k);
		int zero=0;
		ll sum=0;
		for (int j = 0; j < k; j++){
			d_mod_m[j]=d[j]%m;
			sum+=d_mod_m[j];
			if(d_mod_m[j]==0){
				zero+=(n-1)/k;
				if(j<(n-1)%k)zero++;
			}
		}
		sum*=(n-1)/k;
		for (int i = 0; i < (n-1)%k; i++){
			sum+=d_mod_m[i];
		}
		sum+=x;
		int large=sum/m-x/m;
		cout<<n-1-zero-large<<endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll d[110]; // 距離
ll w[110][110];
queue<int> qu;
ll White = 0, Gray = 1, Black = 2;
ll color[110];

void solve() {
    Rep(i, 1, 100) d[i] = -1;

    ll n; cin >> n;
    Rep(i, 1, n){
        ll u, k;
        cin >> u >> k;
        Rep(j, 1, k){
            ll v; cin >> v;
            w[i][v] = 1;
        };
    }

    qu.push(1);
    d[1] = 0;
    while(!qu.empty()){
        int u = qu.front(); qu.pop();
        Rep(v, 1, n){
            if(w[u][v] == 1 && color[v] == 0){
                d[v] = d[u] + 1; 
                qu.push(v);
                color[v] = Black;
            }
        }
        color[u] = Black;
    }

    Rep(i, 1, n) cout << i << " " << d[i] << endl;

    return;
}

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

    solve();
    return 0;
}



Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long  A, B, K;
  cin >> A >> B >> K;
  if (A > K) {
    cout << A - K << " " << B;
  } else {
    K -= A;
    if (B > K) {
      cout << 0 << " " << B - K;
    } else {
      cout << 0 << " " << 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
if digitSum(n) % 9 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 80124
# -*- coding: utf-8 -*-


def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]

    # See:
    # https://img.atcoder.jp/abc119/editorial.pdf
    # http://drken1215.hatenablog.com/entry/2019/02/24/224100?_ga=2.107425799.427838713.1551485650-1201012407.1527836447#fnref:1
    def dfs(i, cur_a, cur_b, cur_c):
        if i == n:
            if cur_a == 0 or cur_b == 0 or cur_c == 0:
                return float('inf')
            return abs(a - cur_a) + abs(b - cur_b) + abs(c - cur_c) - 30

        result0 = dfs(i + 1, cur_a, cur_b, cur_c)
        result1 = dfs(i + 1, cur_a + l[i], cur_b, cur_c) + 10
        result2 = dfs(i + 1, cur_a, cur_b + l[i], cur_c) + 10
        result3 = dfs(i + 1, cur_a, cur_b, cur_c + l[i]) + 10

        return min(result0, result1, result2, result3)

    print(dfs(0, 0, 0, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n=int(input())
md=10**9+7
ft=[1,1]
for i in range(2,10**6+2):
  ft.append((i*ft[-1])%md)
def ncr(n,r,p=10**9+7):
  a=(ft[n])*((pow(ft[n-r],md-2,md)*pow(ft[r],md-2,md)))%md
  return a%md
if n==1:
  print(0)
else:
  an=pow(10,n,md)
  pan=1
  for i in range(1,n):
    pan+=(ncr(n,i)*pow(8,n-i,md))
  print((an-2*pan-pow(8,n,md))%md)

Measured memory_bytes: 144120
N=int(input())
W=list(map(int, input().split()))
 
sum1,sum2=0,0
ans=0
dif=1000
 
for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now
 
print(dif)

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

using namespace std;

int tilecount(int x, string &tile) {
	int counttile = 0;
	if (tile.size() > 1) {
		for (int i = 0; i < tile.size(); i++) {
			//タイルの枚数の奇数偶数で場合分け
			if (i % 2 == 0) {
				//i枚目の数字が1-xなら1を足す
				if ((int)(tile.at(i) - '0') == 1 - x) {
					//cout << "●" << endl;
					counttile++;
				}
			}
			else {
				//i枚目の数字がxなら1を足す
				if ((int)(tile.at(i) - '0') == x) {
					//cout << "●" << endl;
					counttile++;
				}
			}
		}
	}
	return counttile;
}

int main() {
	string tile;
	cin >> tile;
	int test1 = tilecount(1, tile);
	//cout << "★" << endl;
	int test2 = tilecount(0, tile);
  	//visual studio2019だとmax/minはエラーが出て使えない
  	//rubbish
	cout << min(test1, test2) << endl;
}



Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] input = scan.nextLine().split(" ");
	int[] a = new int[5];
	for (int i = 0; i < 5; i++) {
	    a[i] = Integer.parseInt(input[i]);
	}
	for (int i = 0; i < 5; i++) {
	    int key = i;
	    for (int j = i+1; j < 5; j++) {
		if (a[key] < a[j]) {
		    key = j;
		}
	    }
	    int tmp = a[key];
	    a[key] = a[i];
	    a[i] = tmp;
	}
	for (int i = 0; i < 4; i++) {
	    System.out.print(a[i] + " ");
	}
	System.out.println(a[4]);
    }
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG 0x3fffFFFFffffFFFFL
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef pair<int, int> ipair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

//C++17からstd::に含まれた
//ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
//ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
//    cout << fixed << setprecision(9);

    int N; cin >> N;
    vector<string> S(N);
    vector<int> P(N);
    rep(i, N) cin >> S[i] >> P[i];

    set<string> uniqueS;
    rep(i, N) uniqueS.insert(S[i]);

    for (auto i = uniqueS.begin(); i != uniqueS.end(); ++i){
        priority_queue<int> p;
        rep(j, N){
            if (S[j] == *i) p.push(P[j] * 1000 + j + 1);
        }
        while(!p.empty()){
            cout << p.top() % 1000 << endl;
            p.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007

using namespace std;

int main() {
    int N; cin >> N;
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << A[N-1] << endl;
}



Measured memory_bytes: 256
N = int(input())
keta = len(str(N))
cnt = 0
for i in range(keta):
  if i%2 == 1:
    cnt += 9*10**(i-1)

if keta%2 == 0:
  print(cnt)
else:
  print(cnt + N-10**(keta-1) + 1)

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

using namespace std;

typedef long long ll;
const int Nmax = 1e5 + 5;

int n, i, A, B;
bool ok[Nmax];
vector< pair<int,int> > v;
ll sA, sB, sum, ans;

int main()
{
   /// freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=0; i<n; ++i)
    {
        cin >> A >> B;
        v.push_back({A, i});
        v.push_back({B, i});
        sA += A; sB += B;
    }

    ans = min(sA, sB);

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

    for(i=0; i<n; ++i) ok[v[i].second] = 1, sum += v[i].first;

    for(i=0; i<n && ok[i]; ++i);

    if(i != n) ans = min(ans, sum);
        else
        {
            if(v[n-1].second != v[n].second) ans = min(ans, sum + v[n].first - v[n-1].first);
                else ans = min(ans, min(sum + v[n].first - v[n-2].first, sum + v[n+1].first - v[n-1].first));
        }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>

using namespace std;

int main(){
  int a[33]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

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

int main(){
    int N, Q;
    string S;

    cin >> N >> Q;
    cin >> S;
    //累積和をつくってしまう

    // A G C a C T a C A G a C
    //0 0 0 0 1 1 1 2 2 2 2 3 3                   
    if(S.size() > 1){
        for(int i=0; i<S.size()-1; i++){
            if(S.at(i)=='A' && S.at(i+1) =='C')
            S.at(i) = 'a';
        }
    }

//    cout << S <<endl;

    int R[100100]; // aの数を数えるやつ

    R[0]=0;
    for(int i=0; i<N; i++){
        R[i+1]=R[i];
        if(S.at(i)== 'a') R[i+1]++;
    }
/*
    for(int i=0; i<N+1; i++){
        cout << R[i] << endl;
    }
*/
    for(int j=0; j<Q; j++){
        int l, r;
        cin >> l >> r;

    cout << R[r-1] -R[l-1] << endl;
    }
}

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

int	main() {
	int N;
	cin >>N;
	vector<int> d(N, 0);
	for (int i=0; i<N; i++)
		cin >>d.at(i);
	int S=0;
	for (int i=0; i<N-1; i++)
		for (int j=i+1; j<N; j++)
			S +=d.at(i)*d.at(j);
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
#include<stdio.h>
int main( ){
  int a,b,c,d;
  double e;
  scanf("%d %d",&a,&b);
  c=a/b;
  d=a%b;
  e=(double)a/b;
  printf("%d %d %f\n",c,d,e);
  return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
ll ans;
vecl arr(N);
ll dp[509][509];
ll pre[N];



void test_case() {

    
   int  n;
   cin>>n;

   set<int> st;
   rep(i,n) {
       int x;
       cin>>x;

       st.insert(x);
   }

   if(st.size() == n) {
       yes;
   } else {
       no;
   }








}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 13424
from sys import stdin                                                                                                                                                                                       
A = [int(x) for x in stdin.readline().rstrip().split()]                                                                                                                                                     
                                                                                                                                                                                                            
a1 = abs(A[0] - A[1])                                                                                                                                                                                       
a2 = abs(A[0] - A[2])                                                                                                                                                                                       
a3 = abs(A[1] - A[2])                                                                                                                                                                                       
x = [a1,a2,a3]                                                                                                                                                                                              
cost1 = min(x)                                                                                                                                                                                              
x.remove(cost1)                                                                                                                                                                                             
cost2 = min(x)                                                                                                                                                                                              
ans = cost1 + cost2                                                                                                                                                                                         
print(ans)

Measured memory_bytes: 3060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.para = [-1] * (n + 1)
    
    def find(self, x):
        if self.para[x] < 0:
            return x
        else:
            self.para[x] = self.find(self.para[x])
            return self.para[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x > y:
            x, y = y, x
        if x == y:
            return
        else:
            self.para[x] += self.para[y]
            self.para[y] = x
    def isSame(self, x, y):
        return self.find(x) == self.find(y)
    
    def count(self,x):
        return -self.para[self.find(x)]
N, M = map(int, input().split())
un_orginal = UnionFind(N)
A = [tuple(map(int, input().split())) for _ in range(M)]
for a,b in A:
    un_orginal.unite(a,b)
ans = 0
for i in range(M):
    un = UnionFind(N)
    for k in range(M):
        if i == k:
            continue
        else:
            un.unite(A[k][0], A[k][1])
    cnt = 0
    for k in range(N+1):
        if un_orginal.count(k) == un.count(k):
            cnt += 1
    if cnt == N+1:
        ans += 1
print(M-ans)

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

typedef long long lint;

struct Edge {
	int to;
	lint c;
	bool operator > (const Edge& e) const { return c > e.c; }
};

int N, M, s, t;
vector< vector< Edge > > edge;

void addEdge(int a, int b, int d) {
	edge[a].push_back(Edge{b, d});
	edge[b].push_back(Edge{a, d});
}

int main() {
	cin >> N >> M >> s >> t;
	--s; --t;
	
	edge.assign(N, vector< Edge >());
	for (int i=0; i<M; ++i) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		--a; --b; --c;
		addEdge(a, b, d);
		addEdge(a, c, d);
		addEdge(b, c, d);
	}
	
	priority_queue< Edge, vector< Edge >, greater< Edge > > que;
	que.push(Edge{s, 0});
	
	vector< lint > dst(N, -1);
	dst[s] = 0;
	
	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		if (dst[e.to] < e.c) continue;
		for (const Edge& ei : edge[e.to]) {
			lint nc = e.c + ei.c;
			if (dst[ei.to] == -1 || dst[ei.to] > nc) {
				dst[ei.to] = nc;
				que.push(Edge{ei.to, nc});
			}
		}
	}
	
	cout << dst[t] << endl;
}


Measured memory_bytes: 23736
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    int w;
    cin >> w;

    string temp = "";
    rep(i, s.length()) {
        if (i % w == 0) {
            temp += s[i];
        }
    }
    cout << temp << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mm[100005];
int pen[100005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,m;
   cin>>n>>m;
   pair<int,string>p[m];
   
   for(int i=0;i<m;i++)
   {
      cin>>p[i].first>>p[i].second;
      if(mm[p[i].first]==0)
      {
         if(p[i].second=="WA")
            pen[p[i].first]++;
         else
         {
            mm[p[i].first]=1;
         }         
      }            
   }
   int ans=0,x=0;
   for(int i=1;i<=n;i++)
   {
      if(mm[i])
      {
         x++;
         ans+=pen[i];
      }
   }
   cout<<x<<" ";
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int H,W,K;cin>>H>>W>>K;
    char C[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>C[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<(1<<H);i++){
        for(int j=0;j<(1<<W);j++){
            int black=0;
            for(int k=0;k<H;k++){
                for(int l=0;l<W;l++){
                    if(((i>>k)&1)==0&&((j>>l)&1)==0&&C[k][l]=='#'){
                        black++;
                    }
                }
            }
            if(black==K){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3548
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;


int32_t main(){
    FAST;
    int n,a,b;  cin >> n >> a >> b;
    cout << min(a*n , b) << endl;

    return 0;
}


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

typedef long long ll;

int n;
ll p[4000];
std::vector<int> ord;

int main()
{
	while( std::cin >> n, n )
	{
		memset( p, 0, sizeof( p ) );
		ord.clear();

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			if( p[a-1] == 0 )ord.push_back( a - 1 );	
			p[a-1] += b * c;
		}
		bool fl = false;
		for( int i = 0; i != ord.size(); ++i )
			if( p[ord[i]] >= 1000000 )
				std::cout << ord[i] + 1 << std::endl, fl = true;

		if( !fl )
			std::cout << "NA" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1272
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
-- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Int
getIntTuple = (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector

main = do
  (a,b) <- getIntTuple
  let set = [x | x <- [1..1000], a == (floor $ (fromIntegral x) * 0.08) && x `div` 10 == b]
      ans = if null set then -1 else head set

  print $ ans


Measured memory_bytes: 380
// Practice AtCoder
// author: Leonardone @ NEETSDKASU
// 解説読後

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let l = get!();
    let a = get!();
    let b = get!();
    let m = get!();
    
    let mut d = 1;
    let mut c = 0;
    let mut x = 0;
    let mut s = a;
    for _ in 0..18 {
        d *= 10;
        let t = bin(a, b, d);
        let cd = std::cmp::min(l, t) - c;
        let v = vec![d % m, 0, 0, 1, 1, 0, 0, b % m, 1];
        let w = pow(v, cd, m);
        let z = vec![x, s, 1, 0, 0, 0, 0, 0, 0];
        let e = mul(z, w, m);
        x = e[0];
        s = e[1];
        // println!("{} {} {} {} {} {}", i+1, c, t, cd, x, s);
        c = t;
        if c >= l {
            break;
        }
    }
    println!("{}", x);
}

fn bin(a: i64, b: i64, d: i64) -> i64 {
    let mut lp = 0;
    let mut rp = (1e18 as i64 - a) / b + 1;
    while lp < rp {
        let hp = (rp - lp) / 2 + lp;
        let v = a + b * hp;
        if v < d {
            lp = hp + 1;
        } else {
            rp = hp;
        }
    }
    rp
}

fn mul(a: Vec<i64>, b: Vec<i64>, m: i64) -> Vec<i64> {
    let mut ret = vec![0; 9];
    for y in 0..3 {
        for x in 0..3 {
            let mut r = 0;
            for i in 0..3 {
                r += a[y*3+i] * b[i*3+x] % m;
                r %= m;
            }
            ret[y*3+x] = r;
        }
    }
    ret
}


fn pow(v: Vec<i64>, p: i64, m: i64) -> Vec<i64> {
    if p == 0 {
        vec![1, 0, 0, 0, 1, 0, 0, 0, 1]
    } else {
        let t = v.clone();
        if p == 1 {
            t
        } else if p % 2 == 0 {
            pow(mul(v, t, m), p / 2, m)
        } else {
            mul(t, pow(v, p - 1, m), m)
        }
    }
}

Measured memory_bytes: 4352
// abc169_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        long mod = (long)1e9+7;
        int[] left = new int[200001];
        Arrays.fill(left, -1);
        long[] dp = new long[n+1];
        dp[0] = 1;
        int prev = -1;
        for(int i = 1; i <= n; i++){
            int now = sc.nextInt();
            dp[i] += dp[i-1];
            dp[i] %= mod;
            //pw.println(dp[i]);
            if(prev == now) continue;
            if(left[now] != -1){
                dp[i] += dp[left[now]];
                dp[i] %= mod;
            }
            left[now] = i;
            prev = now;
        }
        pw.println(dp[n]%mod);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int n, m;
  cin >> n >> m;
  int s = 0;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    s += v[i];
  }
  sort(all(v));
  if (double(v[n - m]) >= s / double(4 * m)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
n=0
while True:
    if S[n:n+5]=="dream":
        if S[n:n+7]=="dreamer":
            if n+7<len(S) and S[n+7]=="a":
                n = n+5
            else:
                n = n+7
        else:
            n = n+5
    elif S[n:n+5]=="erase":
        if S[n:n+6]=="eraser":
            if n+6<len(S) and S[n+6]=="a":
                n = n+5
            else:
                n = n+6
        else:
            n = n+5
    else:
        print("NO")
        break
    if n==len(S):
        print("YES")
        break


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  cout << string(tx - sx, 'R') << string(ty - sy, 'U')
       << string(tx - sx, 'L') << string(ty - sy, 'D')
       << "D" << string(tx - sx + 1, 'R') << string(ty - sy + 1, 'U') << "L"
       << "U" << string(tx - sx + 1, 'L') << string(ty - sy + 1, 'D') << "R"
       << "\n";
  return 0;
}


Measured memory_bytes: 256