akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	ll ans = 0;
	ans = min(n, k) * x + max(n - k, 0) * y;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<double> a(n);
    REP(i,n) cin>>a[i];
    sort(all(a));
    double ans = a[0];
    FOR(i,1,n){
        a[i] = (a[i-1] + a[i]) /2;
    }
    cout<<fixed;
    cout<<setprecision(5)<<a[n-1]<<endl;
    return 0;
}

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



int main() {
    ll k;
    string s;
    cin>>s>>k;
    for(int i=0;i<s.length();i++){
    if(s[i]-'0'>1){cout<<s[i]<<endl;}
    else{
        int c=0,j=0;
        while(s[j]=='1'){c++; j++;}
        if(k<=c){cout<<1<<endl;}
        else{cout<<s[j]<<endl;}
    }
    break;
    }
    
    return 0;
}

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

using namespace std;

int main() {
    string s; cin >> s;
    int ans_1 = 0, ans_2 = 0;
    bool is_odd = true;
    for(auto c : s) {
        if (is_odd) {
            if (c == '0') {
                ans_1++;
            } else {
                ans_2++;
            }
        } else {
            if (c == '1') {
                ans_1++;
            } else {
                ans_2++;
            }
        }
        is_odd = !is_odd;
    }

    if (ans_1 < ans_2) {
        cout << ans_1 << endl;
    } else {
        cout << ans_2 << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int front;
  cin >> front;
  int height;
  int64_t sum = 0;
  for (int i = 1; i < N; i++){
    cin >> height;
    if (height < front) sum += front - height;
    else front = height;
  }
  cout << sum << endl;
}


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

typedef pair<int, int> P;
const int IINF = INT_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n,ma,mb,a[2][45],b[2][45],c[2][45];
    map<P,int> mp[2];
    cin >> n >> ma >> mb;
    int m[] = {n/2,n-n/2};
    REP(k,2){
        REP(i,m[k]){
            cin >> a[k][i] >> b[k][i] >> c[k][i];
        }
        REP(i,(1<<m[k])){
            int at=0,bt=0,ct=0;
            REP(j,m[k]){
                if((i>>j)&1){
                    at += a[k][j];
                    bt += b[k][j];
                    ct += c[k][j];
                }
            }
            if(!mp[k].count({at,bt}) || mp[k][{at,bt}] > ct){
                mp[k][{at,bt}] = ct;
            }
        }
    }
    int ans = IINF;
    for(auto it1 : mp[0]){
        for(auto it2 : mp[1]){
            int as,bs;
            as = it1.first.first + it2.first.first;
            bs = it1.first.second + it2.first.second;
            if(as*bs>0 && as*mb == bs*ma){
                ans = min(ans, it1.second + it2.second);
            }
        }
    }
    cout << (ans!=IINF?ans:-1) << endl;
    return 0;
}


Measured memory_bytes: 896
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	var count int
	ok := false
	loc := 1
	for i := 0; i < n; i++ {
		loc = a[loc-1]
		count++
		if loc == 2 {
			ok = true
			break
		}
	}
	if ok {
		fmt.Println(count)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 5504
#include <algorithm>
#include <iostream>

using namespace std;

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

main(){
    int c[4][4];
    r(i,3)r(j,3)cin>>c[i][j];
    r(i,3){
        c[i][3]=c[i][0];
        c[3][i]=c[0][i];
    }
    c[3][3]=c[0][0];

    bool ans=true;
    r(i,3)r(j,3){
        if(c[i][j]-c[i+1][j]!=c[i][j+1]-c[i+1][j+1])ans=false;
        if(c[i][j]-c[i][j+1]!=c[i+1][j]-c[i+1][j+1])ans=false;
    }

    cout<<(ans?"Yes":"No")<<endl;
}


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

typedef long long ll;
const ll mod = 1000*1000*1000+7;
int N;
vector<int> X;

int main() {
    scanf("%d", &N);
    X.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &X[i]);
    }
    ll ans = 1;
    int cnt = 1;
    for(int i = 0; i < N - 1; i++) {
        if(X[i] >= 2*cnt - 1) cnt++;
        else {
            ans *= cnt;
            ans %= mod;
        }
    }
    for(int i = 1; i <= cnt; i++) {
        ans *= i;
        ans %= mod;
    }
    printf("%lld", ans);
}


Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

const int inf = 1e9 + 10;

void primes(int x) {
    int d = 2;
    while (d * d <= x) {
        if (x % d == 0) {
            cout << d << ' ';
            x /= d;
        } else {
            d++;
        }
    }
    if (x > 1) {
        cout << x << "\n";
    } else {
        cout << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int k;
    cin >> k;
    int x = 7;
    for (int i = 1; i <= 1e6; i++) {
        if (x % k == 0) {
            cout << i << "\n";
            return 0;
        }
        x = ((x * 10) + 7) % k;
    }
    cout << -1 << "\n";

    return 0;
}


Measured memory_bytes: 3620
# author:  Taichicchi
# created: 12.09.2020 19:26:19

import sys

N, Q = map(int, input().split())

S = input()

cum_ls = [0]

for i in range(1, N):
    if S[i - 1: i + 1] == "AC":
        cum_ls.append(cum_ls[i - 1] + 1)
    else:
        cum_ls.append(cum_ls[i - 1])

# print(cum_ls)

for i in range(Q):
    l, r = map(int, input().split())
    print(cum_ls[r - 1] - cum_ls[l - 1])


Measured memory_bytes: 11492
/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 200005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

ll rec(ll x){
    if(x == 1) return x;
    return ( (2 * rec(x/2)) + 1);
}

void solve(){
    ll x;
    cin >> x;
    cout << rec(x) << endl;
}


int main() {

    int tc;
    tc = 1;
    while(tc--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
/*
[abc127] A - Ferris Wheel
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int A, B;

ll solve() {
    if (A >= 13) {
        return B;
    }
    if (A >= 6) {
        return B / 2;
    }
    return 0;
}

int main() {
    cin >> A >> B;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
x = [i % 2019 for i in range(L, min(R + 1, L + 2019))]
ans = 10 ** 10
for i in x:
    for j in x:
        if i < j:
            ans = min(ans, i * j % 2019)
print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 2e9;



int main() {
	string s; cin >> s;
	int cnt = 0;
	rep(i, 0, s.size() - 1) if (s[i] != s[i + 1]) cnt++;
	printf("%d", cnt);
	return 0;
}


Measured memory_bytes: 512
a,b = map(int,input().split())
c = list(map(int, input().split()))
d = []
for i in range(b):
    if i != b-1:
        d.append(c[i+1]-c[i])
    else:
        d.append(a-c[i]+c[0])
print(sum(d) - max(d))


Measured memory_bytes: 26420
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int arraymax(int num[], int x, int y) {
  int ma = 0;
  for(int i = x; i <= y; i++) {
    ma = max(ma, num[i]);
  }
  return ma;
}

int main() {
  int n,h[200];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> h[i];
  
  int sum = 0;
  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j < n; j++) {
      if(h[j] == 0) continue;
      while (h[j] > 0) {
				h[j]--; j++;
			}
			sum++;
    }
  }
  
  cout << sum << endl;
}


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

int main(void)
{
    int a, b, c;
    int t;
    int hoge = ' ';
    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;
}


Measured memory_bytes: 3096
import scala.io.Source

object Main extends App {
  val in = Source.stdin.getLines
  for (line <- in; if line != "0 0") {
    val nk = line.split(' ').map(_.toInt)
    val n = nk(0)
    val s = in.next.split(' ').map(_.toInt)
    val b = in.take(n).map(x => x.split(' ').map(_.toInt)).toSeq

    if (b.foldLeft(s)(subtract).exists(x => x < 0)) {
      println("No")
    } else {
      println("Yes")
    }
  }

  def subtract(a: Array[Int], b: Array[Int]): Array[Int] = {
    a.zip(b).map(x => x._1 - x._2)
  }
}



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

int main() {
    int N, M;
    cin >> N >> M;
    int con[10][10] = {0};
    int ans = 0;
    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        con[a-1][b-1] = 1;
        con[b-1][a-1] = 1;
    }

    int node[N];
    for (int i=0; i<N; ++i) node[i] = i;

    bool can = true;
    for (int i=1; i<N; ++i) {
        if (con[node[i]][node[i-1]] == 0) {
            can = false;
            break;
        }
    }
    if (can) ++ans;
    
    while (next_permutation(node+1, node+N)) {
        bool can = true;
        for (int i=1; i<N; ++i) {
            if (con[node[i]][node[i-1]] == 0) {
                can = false;
                break;
            }
        }
        if (can) ++ans;
    }

    cout << ans << endl;

    return 0;
}

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

const int N_MAX = 200;
int graph[N_MAX + 1][N_MAX + 1];

void graph_init()
{
    for (int i = 0; i <= N_MAX; i++)
    {
        for (int j = 0; j <= N_MAX; j++)
        {
            graph[i][j] = 1 << 29;
            if (i == j)
            {
                graph[i][j] = 0;
            }
        }
    }
}

void warshall_floyd(int n_v)
{
    for (int k = 0; k < n_v; k++)
    {
        for (int i = 0; i < n_v; i++)
        {
            for (int j = 0; j < n_v; j++)
            {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

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

    vector<int> vi;
    for (int i = 0; i < R; i++)
    {
        int r;
        cin >> r;
        vi.push_back(r - 1);
    }

    graph_init();
    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        graph[a - 1][b - 1] = c;
        graph[b - 1][a - 1] = c;
    }

    warshall_floyd(N);

    int min_move_dist = INT_MAX;
    sort(vi.begin(), vi.end());
    do
    {
        int move_dist = 0;
        for (int i = 0; i < R - 1; i++)
        {
            int now = vi[i];
            int next = vi[i + 1];
            move_dist += graph[now][next];
        }
        min_move_dist = min(min_move_dist, move_dist);
    } while (next_permutation(vi.begin(), vi.end()));

    cout << min_move_dist << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   int num[n+10];
   for(int i=0;i<n;i++)
        cin>>num[i];

    int cnt=0;

    sort(num,num+n);
    int x = n/2;
    x--;
    if(num[x]==num[x+1])
        cnt=0;
    else{
        cnt = num[x+1]-num[x];


    }

    return cout<<cnt<<endl,0;


}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n,m;
  cin >> n>>m;
  if(n == m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	string coffee; cin >> coffee;

	if (
		coffee[2] == coffee[3] &&
		coffee[4] == coffee[5]
		) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#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 rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

bool solve(string s){
    if(s.length()<=3){
        return s=="ABC";
    }
    string s1,s2,s3;
    bool f[3]={};
    rep(i,s.length()){
        if(i<s.length()-2){
            if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
                s1+="A",s2+="B",s3+="C";
                i+=2;
            }
            else{
                s1+=s[i],s2+=s[i],s3+=s[i],f[s[i]-'A']=true;
            }
        }
        else{
            s1+=s[i],s2+=s[i],s3+=s[i],f[s[i]-'A']=true;
        }
    }
    if(s!=s1){
        bool ret=false;
        if(!f[0])ret|=solve(s1);
        if(!f[1])ret|=solve(s2);
        if(!f[2])ret|=solve(s3);
        return ret;
    }
    return false;
}

void run(){
    string s;
    cin>>s;
    Yes(solve(s));
}


Measured memory_bytes: 46328
import sys

#read = sys.stdin.buffer.read
#input = sys.stdin.buffer.readline
#inputs = sys.stdin.buffer.readlines

from collections import defaultdict
# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	li=[0]+list(map(int,input()))
	n=len(li)
	
	ans=0
	
	for i in range(n):
		a=li[n-1-i]
		if 6<=a:
			ans+=10-a
			li[n-2-i]+=1
		elif a==5:
			if li[n-2-i]<=4:
				ans+=a
			else:
				ans += 10 - a
				li[n - 2 - i] += 1
		else:
			ans+=a
	print(ans)
	
	
if __name__ == "__main__":
	main()


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int a; cin >> a;
    while(a>1000){
        a -= 1000;
    }
    cout <<  1000 - a << endl;
}

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


int main() {

    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

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

typedef long long ll;

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

    int arr[n];
    for(int i = 0; i < n; i++) cin >> arr[i];

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

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		long x = scan.nextLong();

		long  count = (x / 11) * 2;
		x = x % 11;
		if(x != 0){
			if(x - 6 <= 0){
				count ++;
			}
			else {
				count ++;
				count ++;
			}
		}
		System.out.println(count);
	}
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)(s1[0] + 'A' - 'a') << (char)(s2[0] + 'A' - 'a') << (char)(s3[0] + 'A' - 'a') << endl;
}


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

int main() {

    ll D, G;
    cin >> D >> G;

    vl p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];

    int ans = 1e9;
    rep(i, 1<<D) {
        vl P = p;
        int prob = 0;
        ll score = 0;
        rep(j, D) {
            if (i>>j&1) {
                score += ((j+1) * 100 * P[j]);
                score += c[j];
                prob += P[j];
                P[j] = 0;
            }
        }
        int itr = D-1;
        bool ok = true;
        while(score < G) {
            while (P[itr] < 1) {
                itr--;
                if (itr < 0) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                score += ((itr+1)*100);
                prob++;
                P[itr]--;
            }
            else break;
        }

        if (ok) ans = min(prob, ans);
        // cout << "i: " << i << "  score: " << score << "  prob: " << prob << endl;
        // rep(j, D) cout << (j+1)*100 << ": " << p[j] - P[j] << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  cout << n/(a+b)*a + min(n%(a+b), a) << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
i = 1
l = []
while i <= n:
    x = i
    if x % 3 == 0: l.append(i)
    elif x % 10 == 3: l.append(i)
    else:
        x /= 10
        x = int(x)
        while x:
            if x % 10 == 3:
                l.append(i)
                break
            x /= 10
            x = int(x)
    i += 1
print('',*l)


Measured memory_bytes: 5980
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int a,b,c;cin>>a>>b>>c;
  string res=(a+b+c>21)?"bust":"win";
  cout<<res<<endl;
}

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

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


Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL ans = 1;
LL N, P;
LL cnt;

void update(LL i) {
	LL x = (cnt / N);

	LL output = 1;

	while (x > 0) {
		if (x % 2 == 1) {
			output *= i;
		}

		i = i * i;
		x /= 2;
	}

	ans *= output;
}

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

	if (N == 1) {
		cout << P << endl;
		return 0;
	}

	for (LL i = 2; i*i <= P; i++) {
		
		cnt = 0;
		while (P%i == 0) {
			P /= i;
			cnt++;
		}

		if (cnt >= N) {
			update(i);
		}
	}

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

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

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

int n, m;
const int INF = 1e9 + 9;
int imos[21][100010];
int cnt[21];
int memo[1 << 20];

inline void chmin(int &a, const int& b) {
  a = min(a, b);
}

int dfs(int s) {
  if (s == (1 << m) - 1) return 0;
  if (memo[s] != -1) return memo[s];

  int c = 0;
  int res = INF;
  rep(i, m) {
    if (s & (1 << i)) c += cnt[i];
  }

  rep(i, m) {
    if (s & (1 << i)) continue;
    chmin(res, dfs(s | (1 << i)) + cnt[i] - (imos[i][c + cnt[i]] - imos[i][c]));
  }

  return memo[s] = res;
}

signed main() {
  fill(memo, memo + (1 << 20), -1);
  cin >> n >> m;
  rep(i, n) {
    int type;
    cin >> type;
    cnt[type - 1]++;
    imos[type - 1][i + 1] = 1;
  }
  rep(i, m) rep(j, n) {
    imos[i][j + 1] += imos[i][j];
  }
  /*
  rep(i, m) rep(j, n) {
    cerr << imos[i][j + 1] << (j != n - 1 ? ' ' : '\n');
  }
  */

  cout << dfs(0) << endl;
}

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

int main(){
    string s;
    cin>>s;
    map<char,int> mp;
    for(int i=0;i<s.size();i++){
        mp[s[i]] ++;
    }
    int flag=1;

    for(int i=0;i<mp.size();i++){
        if(mp[s[i]]>=2){
            cout<<"no"<<endl;
            flag=0;
            return 0;
        }
    }
    if(flag){
    cout<<"yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
        String s = scanner.nextLine();
        int n = s.length();
        int[] chars = new int[n];
        int[][] a = new int[n + 1][3];
        for (int i = n-1; i >=0; i--) {
            a[i][0] = a[i+1][0];
            a[i][1] = a[i+1][1];
            a[i][2] = a[i+1][2];
            char c = s.charAt(i);
            if (c == 'R') {
                chars[i] = 0;
            } else if (c == 'G') {
                chars[i] = 1;
            } else {
                chars[i] = 2;
            }
            a[i][chars[i]]++;
        }
        if (a[0][0] == 0 || a[0][1] == 0 || a[0][2] == 0) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        for (int i = 0; i < n - 3; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                if (chars[i] != chars[j]) {
                    int req = 3 - chars[i] - chars[j];
                    ans += a[j+1][req];
                    if (2 * j - i < n && chars[2 * j - i] == req) ans--;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
LL read() {
    LL k = 0; char c = getchar();
    while(c < '0' || c > '9') c = getchar();
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k;
}
int f[100010], c[100010], a[100010];
int main() {
    int n = read(), m = read();
    for(int i = 1; i <= m; ++i)
        a[i] = read(), c[i] = read();
    memset(f, 127/3, sizeof(f)); f[0] = 0;
    for(int i = 1; i <= 15000; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(a[j] <= i) f[i] = min(f[i], f[i-a[j]] + c[j]);
        }
    }
    int ans = 2147483647;
    for(int i = n; i <= 100000; ++i) ans = min(ans, f[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

long long N;

int main() {
	scanf("%lld", &N);
	
	for(long long h = 1; h <= 3500; h++)
		for(long long n = 1; n <= 3500; n++) {
		
			long long nom = N * h * n;
			long long den = 4 * h * n - N * (h + n);
			
			if(den == 0) continue;
			
			if(nom < 0 && den > 0 || den < 0 && nom > 0) continue;
			
			if(nom % den == 0) {
				long long ans = nom / den;
				printf("%lld %lld %lld\n", h, n, ans);
				return 0;
			}
		
		}
	
	return 0;
}

Measured memory_bytes: 128
_list = [int(input()) for i in range(5)]

last_order_candidate_value = _list[0]
minimum_mod_10 = 9
for i in range(len(_list)):
    minutes_mod_10 = _list[i] % 10
    if minutes_mod_10 != 0 and minimum_mod_10 > minutes_mod_10:
        minimum_mod_10 = minutes_mod_10
        last_order_candidate_value = _list[i]

_list.remove(last_order_candidate_value)

elaps = 0
for i in range(len(_list)):
    elaps = elaps + _list[i]
    if (elaps%10 != 0):
        elaps = elaps + (10 - elaps%10)
elaps = elaps + last_order_candidate_value

print(elaps)






Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,R;
int A[51];
int dp[51][50001];

int DP(int a,int b){
	if(dp[a][b]!=-1)return dp[a][b];
	if(a==N){
		if(b%2==R){
			return 1;
		}
		else return 0;
	}
	return dp[a][b]=DP(a+1,b)+DP(a+1,b+A[a]);
}

signed main(){
	cin>>N>>R;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,51)REP(j,50001){
		dp[i][j]=-1;
	}
	cout<<DP(0,0)<<endl;
	return 0;
}


Measured memory_bytes: 20224
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let c=read::<String>();
    println!("{}",if c=="A"{"T"}else if c=="T"{"A"}else if c=="G"{"C"}else{"G"})
}

Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

	vector<ll> a(n);
	vector<ll> b(n);

	for (ll i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}

	ull cnt = 0;
	ull add = 0;
	for (ll i = n - 1; i >= 0; i--)
	{
		ll o = cnt;
		a[i] += cnt;

		if (b[i] > 1 && a[i] % b[i] > 0)
		{


			cnt += b[i] - (a[i] % b[i]);
		}
	}

	println(cnt);
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define pb push_back
#define tam 120000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef  double lld;
int primos[tam];
int main()
{
    int n;
    cin>>n;
    forr(i,2,n+1)
    {
        int auxn=i;
        for(int j=2;j*j<=auxn;j++)
        {
            if (auxn%j==0)
            {
                while(auxn%j==0)
                {
                    primos[j]++;
                    auxn/=j;
                }
            }
        }
        if (auxn>1)
                primos[auxn]++;
    }
    ll tot=1;
    forr(i,2,n+1)
    {
        //cout<<primos[i]<<" ";
        tot*=(primos[i]+1)%MOD;
        tot%=MOD;
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using data = pair<int, pair<int, int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<data> xst(n);
    for (int i = 0; i < n; i++)
    {
        int s, t, x;
        cin >> s >> t >> x;
        xst[i] = data(x, make_pair(s, t));
    }
    sort(ALL(xst));
    set<pair<int, int>> d;
    for (int i = 0; i < q; i++)
    {
        int x;
        cin >> x;
        d.insert(make_pair(x, i));
    }
    vector<ll> tm(q, -1);
    for (int i = 0; i < n; i++)
    {
        int x = xst[i].first;
        int s = xst[i].second.first;
        int t = xst[i].second.second;
        auto start = d.lower_bound(make_pair(s - x, 0));
        auto end = d.upper_bound(make_pair(t - x - 1, q));
        for (auto it = start; it != end; it++)
        {
            tm[it->second] = x;
        }
        d.erase(start, end);
    }

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

Measured memory_bytes: 15232
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    string s;
    cin >> s;
    char srt = s[0];
    char fin = s[s.size() - 1];
    int ans = s.size() -2;
    string a;
    a = to_string(ans);
    cout << srt + a + fin << endl;
    return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N, M; cin >> N >> M;
    ll X[N]; ll Y[M];
    rep(i, N) cin >> X[i];
    rep(i, M) cin >> Y[i];
    ll keisuu = -N+1;
    ll acc_X = 0;
    rep(i, N){
        acc_X = (acc_X + keisuu*X[i]) % mod;
        keisuu += 2;
    }
    keisuu = -M+1;
    ll acc_Y = 0;
    rep(i, M){
        acc_Y = (acc_Y + keisuu*Y[i]) % mod;
        keisuu += 2;
    }
    ll ans = (acc_X*acc_Y) % mod;
    if(ans < 0) ans += mod;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <list>

using namespace std;

int main(int argc, char const *argv[])
{
    string s; cin >> s;
    list<char> z;
    for(unsigned int i=0;i<s.size();++i) {
        z.push_back(s[i]);
    }
    int count = 0;
    list<char>::iterator itr1, itr2, itr3;
    for(itr1 = z.begin();itr1!=z.end();) {
        itr2 = itr1; ++itr2;
        if(itr2!=z.end()) {
            if (*itr1 != *itr2) {
                if(itr1 == z.begin()) {
                    itr1 = itr2; ++itr1;
                } else {
                    --itr1;
                }
                itr3 = itr2; --itr2;
                z.erase(itr3);
                z.erase(itr2);
                count += 2;
            } else {
                ++itr1;
                continue;
            }
        } else {
            ++itr1;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3456
from collections import defaultdict

n, p = map(int,input().split())
s = input()

res = 0

if p not in [2,5]:
    crem = 0
    
    crem_10 = [1]
    for i in range(1,n):
        crem_10 += [(crem_10[-1] * (10%p)) % p]
        
    dic_p = defaultdict(lambda : 0)
    for i,subs in enumerate(s[::-1]):
        crem += (int(subs) % p * crem_10[i]) % p
        crem %= p

        if crem == 0:
            res += 1
        res += dic_p[crem]

        dic_p[crem] += 1
        
else:
    for i,subs in enumerate(s[::-1]):
        if int(subs) % p == 0:
            res += n - i
    
print(res)

Measured memory_bytes: 12284
from collections import deque

H,W=map(int,input().split())
mod=10**9+7
S=[]
for i in range(H):
  S.append(input())
  
total = [[0 for i in range(W)] for j in range(H)]
total[0][0] = 1

now = (0,0)
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':continue
    if i > 0 and S[i-1][j] != '#':
      total[i][j] += total[i-1][j]
    if j > 0 and S[i][j-1] != '#':
      total[i][j] += total[i][j-1]
    total[i][j] %= mod
        
print(total[-1][-1]%mod)

Measured memory_bytes: 50768
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int to, from, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

int a, b, c;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  if (b + a < c) cout << 2 * b + a + 1 << endl;
  else if (b + a >= c) {
    cout << b + c << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    bool ok = false;
    for (int a = 0; a <= X; ++a) {
        int b = X - a;
        if (a * 2 + b * 4 == Y) {
            ok = true;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

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

#include <atcoder/all>
using namespace atcoder;

int main() {
    int N, M;
    cin >> N >> M;
    scc_graph g(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ret = g.scc();
    cout << ret.size() << endl;
    for(auto vs: ret) {
        cout << vs.size() << " ";
        for (auto v: vs) {
            cout << v << " ";
        }
        cout << endl;
    }
    return 0;
}

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

#define sf scanf
#define pf printf
#define rep(i, n) for (i = 0; i < n; ++i)
#define rep0(i, n) for (i = 0; i <= n; ++i)
#define rep1(i, n) for (i = 1; i <= n; ++i)
#define repp(i, a, n) for (i = a; i <= n; ++i)
#define pb push_back

using namespace std;

typedef long long ll;

int main() {
    int n;
    sf("%d", &n);

    string s;
    cin >> s;
    char t = s[0];

    int c = 1;

    for (int i = 1; i < n; ++i) {
        if (s[i] == t) continue;
        t = s[i];
        ++c;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	
	public static long dfs(int rest, int start, int remain, long[][][] memo){
		if(rest == 0){
			return remain == 0 ? 1 : 0;
		}else if(start > 100){
			return 0;
		}else if(memo[rest][start][remain] != -1){
			return memo[rest][start][remain];
		}
		
		long ret = 0;
		
		final int limit = Math.min(100, remain);
		for(int cur = start; cur <= limit; cur++){
			ret += dfs(rest - 1, cur + 1, remain - cur, memo);
		}
		
		return memo[rest][start][remain] = ret;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long[][][] memo = new long[10][101][1001];
		for(int i = 0; i < 10; i++){
			for(int j = 0; j <= 100; j++){
				for(int k = 0; k <= 1000; k++){
					if(i == 0){
						memo[i][j][k] = k == 0 ? 1 : 0;
					}else{
						memo[i][j][k] = -1;
					}
				}
			}
		}
		
		while (true) {
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			if(n == 0 && k == 0){
				break;
			}
			
			System.out.println(dfs(n, 0, k, memo));
		}
	}

}

Measured memory_bytes: 29508
import math

def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    # 素数判定を5で割ったら1余るものだけ返すように変更
    if n % 5 == 1:
        return True
    else:
        return False

def main():
    N = int(input())
    num_list = []
    for i in range(1, 55556):
        if is_prime(i):
            num_list.append(i)
            if len(num_list) == N:
                print(*num_list)
                exit()

main()

Measured memory_bytes: 39024
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    char s[100001];
    cin>>s;
    char c='a';
    while(1){
        if(strchr(s,c)==NULL){cout<<c<<endl;break;}
        if(c=='z'){cout<<"None"<<endl;break;}
        c+=1;
    }
    return 0;
}

Measured memory_bytes: 384
# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def dfs(v: int, p: int) -> None:
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += cnt[v]  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q = tuple(map(int, input().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, (N+1: 1-idx -> 0-idx)
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 265808