akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<string> st(n);
    for(int i=0;i<n;i++){
        cin>>st[i];
        sort(st[i].begin(),st[i].end());

    }
//    set<string> setSt;
    map<string,long long int> mapSt;
    for(int i=0;i<n;i++){
        if(!mapSt.empty()){
            if(mapSt.find(st[i])!=mapSt.end()){
                mapSt[st[i]]++;
            } else{
                mapSt.insert({st[i],1});
            }
        }else{
            mapSt.insert({st[i],1});
        }
    }
    long long int totalcount = 0;
    for(const auto& i:mapSt){
        if(i.second>1){
            totalcount+=((i.second*(i.second-1))>>1);
        }
//        cout<<i.second<<endl;
    }
    cout<<totalcount<<endl;
    return 0;
}


Measured memory_bytes: 18176
N,X,M=map(int,input().split())
l=[X]
p=[-1]*(M+1)
p[X]=0
x=0
for i in range(N-1):
    x=(l[-1]**2)%M
    if p[x]>=0:
        break
    l.append(x)
    p[x]=i+1
x=p[x]
y=len(l)-x
print(sum(l[:x])+(N-x)//y*sum(l[x:])+sum(l[x:x+(N-x)%y]))

Measured memory_bytes: 13736
#include <stdio.h>

int gcd(int a, int b){
	int r;
	while(b > 0){
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}
int lcm(int a, int b){
	return a / gcd(a, b) * b;
}

int main(){
	int a,b,n,m;
	
	while( scanf("%d %d", &a, &b) != EOF){
		n = gcd(a,b);
		m = lcm(a,b);
		printf("%d %d\n", n , m);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

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

  /* */
  int n, t;
  cin >> n >> t;

  int max_dv = 0;
  int min_v;
  cin >> min_v;
  int ctr = 0;
  for (int i = 1; i < n; ++i) {
    int v;
    cin >> v;
    if (max_dv < v - min_v) {
      max_dv = v - min_v;
      ctr = 1;
    } else if (max_dv == v - min_v) {
      ctr++;
    }

    if (min_v > v) {
      min_v = v;
    }
  }
  cout << ctr << endl;
  /* */

  return EXIT_SUCCESS;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(x - a) < abs(x - b) ? "A" : "B");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define int long long

int32_t main()
{
      ios::sync_with_stdio(false);
      cin.tie(0); 
      string s,t;
      cin>>s>>t;
      int sl = (int)s.length();
      int tl = (int)t.length();
      vector<vector<int> > dp(sl+1, vector<int> (tl+1));
      for(int i = 1; i < sl+1; i++) {
            for(int j = 1; j < tl+1; j++) {
                  if(s[i-1] == t[j-1]){
                        dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
                  }
                  else{
                        dp[i][j] =  max(dp[i-1][j],dp[i][j-1]);
                  }
            }
      } 
      string temp;
      int i = sl, j= tl;
      while( i>0 && j>0){
          if(dp[i][j] == dp[i-1][j]){
                  i--;
          }
          else if(dp[i][j] == dp[i][j-1]){
                  j--;
          }
          else temp = temp + s[i-1], i--, j--;
      }
      reverse(temp.begin(), temp.end());
      cout<<temp<<endl;

      return 0;
}

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

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

    if (n[0]==n[2])
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        lr: [(u32, u32); n],
    }
    println!("{}",
        lr.iter().map(|&(l,r)| r - l + 1).sum::<u32>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n][3], dp[n][3], i, j;
    for(i = 0; i < n; i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }
    dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2];
    for(i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i][0], dp[i-1][1] + arr[i][0]);
        dp[i][0] = max(dp[i][0], dp[i-1][2] + arr[i][0]);
        dp[i][1] = max(dp[i][1], dp[i-1][0] + arr[i][1]);
        dp[i][1] = max(dp[i][1], dp[i-1][2] + arr[i][1]);
        dp[i][2] = max(dp[i][2], dp[i-1][0] + arr[i][2]);
        dp[i][2] = max(dp[i][2], dp[i-1][1] + arr[i][2]);
    }
    cout<<max(max(dp[n-1][0], dp[n-1][1]), max(dp[n-1][1], dp[n-1][2]));
}

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

int main() {
	vector<int> a(5);
	int k;
	for (int i = 0; i < a.size(); i++) {
		cin >> a.at(i);
	}
	cin >> k;

	bool judge = false;
	for (int i = 0; i < a.size() - 1; i++) {
		for (int j = i + 1; j < a.size(); j++) {
			if (a.at(j) - a.at(i) > k) {
				judge = true;
				break;
			}
		}
		if (judge) {
			break;
		}
	}
	cout << (judge ? ":(" : "Yay!") << endl;
}


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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string a,b,c; cin >> a >> b >> c;
    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
    return 0;
}

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

int main(){
  int a,odd=0,N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    if(a%2==1){odd++;}
  }
  if(odd%2==1){cout << "NO" << endl;}
  else{cout << "YES" << endl;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 998244353;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll x[110];
int main() {
  ll n,k,ans=0;
  cin>>n>>k;
  rep(i,0,n)cin>>x[i];
  rep(i,0,n){
    ll z=labs(x[i]-k);
    ans+=min(x[i],z)*2;
  }
  cout<<ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
//#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=520;
ll dis[N][N];
pii nod[N*N];
ll n;
ll vis[N][N];
ll upd(ll v,ll u,ll val){
    if (v>n || v<1 || u>n || u<1) return 0;
    if (dis[v][u]>val){
        dis[v][u]=val;
        return 1;
    }
    return 0;
}
ll solve(ll x,ll y){
    dis[x][y]--;
    queue <pii> q;
    q.push({x,y});
    while(q.size()){
        ll v=q.front().F,u=q.front().S;
        q.pop();
        ll z=dis[v][u]+vis[v+1][u];
        ll b=upd(v+1,u,z);
        if (b){
            q.push({v+1,u});
        }
        z=dis[v][u]+vis[v-1][u];
        b=upd(v-1,u,z);
        if (b){
            q.push({v-1,u});
        }
        z=dis[v][u]+vis[v][u+1];
        b=upd(v,u+1,z);
        if (b){
            q.push({v,u+1});
        }
        z=dis[v][u]+vis[v][u-1];
        b=upd(v,u-1,z);
        if (b){
            q.push({v,u-1});
        }
    }
    return 0;
}
int32_t main(){
    sync;
    cin >> n ;
    ll cnt=1;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            dis[i][j]=min(i-1,min(j-1,min(n-i,n-j)))+1;
            nod[cnt++]={i,j};
            vis[i][j]=1;
        }
    }
    ll ans=0;
    for (int i=1;i<=n*n;i++){
        ll x;
        cin >> x;
        ll v=nod[x].F,u=nod[x].S;
        solve(v,u);
        ans+=dis[v][u];
        vis[v][u]=0;
    }
    cout << ans << endl;

}


Measured memory_bytes: 7660
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

int main()
{
    fast
    lli n=5,ans=-1;
    for(lli i=1;i<=5;i++)
    {
        lli xx;
        cin>>xx;
        if(xx==0)
        {
            ans=i;
        }
    }
    cout<<ans;
}
//a+b=a⊕b+2∗(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(u == s) cout << --a << " " << b << endl;
  else cout << a << " " << --b << endl;
}


Measured memory_bytes: 3608
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func sliceAtoi(arr []string) (int, int, int) {
	si := make([]int, 0, len(arr))
	for _, a := range arr {
		i, _ := strconv.Atoi(a)
		si = append(si, i)
	}
	return si[0], si[1], si[3]
}

func main() {
	a, b, k := sliceAtoi(strings.Split(nextLine(), " "))
	if a > k {
		fmt.Println(k)
	} else if a+b >= k && a <= k {
		fmt.Println(a)
	} else {
		fmt.Println(a - (k - (a + b)))
	}
}


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

int main() {
  long long A, B;
  cin >> A >> B;
  
  long long sum = 1;
  int i = 0;
  for (; ; i++) {
    if (sum >= B) break;
	sum += A - 1;
  }
  cout << i << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $N);
$map = array_fill(1,$N,[]);
for($i=0;$i<$N-1;$i++){

    [$a,$b] = fscanf(STDIN, "%d%d");
    $map[$a][$b]=1;
    $map[$b][$a]=1;
}
$list = array_fill(1,$N,-1);
$list[1] = 0;
$list[$N] = 1;
$count = $N;
$count-=2;
$point = [0,0];
$queue = new SplQueue();
setQueue(1,0);
setQueue($N, 1);
while($count){
    $deq = $queue->dequeue();
    setQueue($deq[0], $deq[1]);
}
if($point[0] > $point[1]){
    echo "Fennec";
}else{
    echo "Snuke";
}

function setQueue($target, $type){
    global $list, $map, $point, $count, $queue;
    foreach($map[$target] as $key => $value){
        if($list[$key] === -1){
            $list[$key] = $type;
            $point[$type]++;
            $count--;
            $queue->enqueue([$key, $type]);
        }
    }
}

Measured memory_bytes: 67460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b,c,n,m;
    cin>>a>>b>>c>>n>>m;
    ll ans=INF;
    REPR(i,max(n,m)){
        int p=max(0LL,n-i);
        int q=max(0LL,m-i);
        chmin(ans,p*a+q*b+i*2*c);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int N = 1e5 + 1000;
vector<vector<int>> g(N);
vector<int> par(N, -1);

void bfs() {
  par[1] = 1;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto &u : g[v]) {
      if (par[u] == -1) {
        par[u] = v;
        q.push(u);
      }
    }
  }
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bfs();
  for (int i = 2; i <= n; i++) {
    if (par[i] == -1) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  for (int i = 2; i <= n; i++) {
    cout << par[i] << "\n";
  }
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

ll a[10010], b[10010];

int main(void) {
	int n;
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	ll asum = 0LL, bsum = 0LL;

	rep(i, n) {
		asum += a[i];
		bsum += b[i];
	}

	ll anum = bsum - asum, bnum = bsum - asum;

	bool ok = true;
	rep(i, n) {
		if (a[i] % 2 != b[i] % 2) {
			if (bnum == 0) ok = false;
			b[i]++;
			bnum--;
		}
	}

	rep(i, n) {
		if (a[i] < b[i]) {
			const ll aneed = (b[i] - a[i]) / 2LL;
			anum -= aneed;
		}
		if (a[i] > b[i]) {
			const ll bneed = (a[i] - b[i]);
			bnum -= bneed;
		}
	}

	if (anum < 0 or bnum < 0) ok = false;

	if (ok)
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

import numpy as np

K = int(input())

L=(K+(-K)%4)//2
x = np.arange(L)
grid = (x[:,None] + x[None,:]) % L + 1
grid[::2][grid[::2]<=K-L] += L

if K == 1:
    grid[:] = 1
print(L)
print('\n'.join(' '.join(row) for row in grid.astype(str)))

Measured memory_bytes: 38936
N,M = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
A.sort()
s = sum(A)
for i in range(N):
    if A[i] >= s*(1/(4*M)):
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
// 1_4_D

#include <iostream>
using namespace std;

int main(){
  int n, num, maximum = -1000000, minimum = 1000000;
  long long int sum = 0;
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> num;
    maximum = max(maximum, num);
    minimum = min(minimum, num);
    sum += num;
  }

  cout << minimum << " " << maximum << " " << sum << endl;

  return 0;
}

Measured memory_bytes: 3100
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        ans_int = ((int1+int2)*int3)/2;
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll p[maxn];

void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> p[i];
    sort(p + 1, p + 1 + n);
    ll res = 0;
    for (int i = 1; i <= k; i++) res += p[i];
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 3652
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>

ll f(ll x, ll y) {
	if (x == -1)return 0;
	return x / y + 1;
}

int main()
{
	ll a, b, x;
	cin >> a >> b >> x;
	ll cnt = 0;
	cnt = f(b, x) - f(a - 1, x);
	cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
import java.math.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.*;

public class Main{


    public static long f(long n){
        if(n==1) return 1;
        return n*f(n-1);
    }

    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        int res = 1;
        for(int i=1;i<n;i++){
            if(s.charAt(i)!=s.charAt(i-1)) res++;
        }

        System.out.print(res);



    }

    
}


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

using namespace std;

int main() {
    int n, temp;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(3, 0)), dp(n, vector<int>(3, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> v[i][j];
        }
    }
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];
    for(int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + v[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + v[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + v[i][2];
    }
    int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
A, B, K = map(int, input().split())

if (B - A) // 2 < K:
    num_list = [i for i in range(A, B+1)]
    for i in num_list:
        print(i)
else:
    left = [i for i in range(A, A+K)]
    right = [i for i in range(B-K+1, B+1)]
    num_list = left + right
    for i in num_list:
        print(i)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int c[3][3];
int main( void )
{
  ios::sync_with_stdio(false);
  for( int i=0; i<3; i++ ){
    for( int j=0; j<3; j++ ){
      cin >> c[i][j];
    }
  }
  for( int a0=-1000; a0<=1000; a0++ ){
    int b0 = c[0][0] - a0;
    int b1 = c[0][1] - a0;
    int b2 = c[0][2] - a0;
    int a1 = c[1][0] - b0;
    int a2 = c[2][0] - b0;
    if( c[1][1] != a1 + b1 ) continue;
    if( c[1][2] != a1 + b2 ) continue;
    if( c[2][1] != a2 + b1 ) continue;
    if( c[2][2] != a2 + b2 ) continue;
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

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


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

	double arr[n];
	double dp[n+1][n+1]; // i coins j  heads

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

	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp[i][j]=0;
		}
	}
	dp[0][0] = 1;

	for(int i=1;i<=n;i++){
		dp[i][i] = dp[i-1][i-1]*arr[i-1];
	}

	for(int j=1;j<=n;j++){
		dp[j][0] = dp[j-1][0]*(1-arr[j-1]);
	}

	for(int i=2;i<=n;i++){
		for(int j=1;j<i;j++){
			dp[i][j] = dp[i-1][j-1]*(arr[i-1]) + dp[i-1][j]*(1-arr[i-1]);
		}
	}

	double ans = 0.0;
	for(int i= (n/2) + 1;i<=n;i++){
		ans += dp[n][i];
	}

	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=n;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 70528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		int[] S = new int[n];
		for(int i = 0; i < n; i++){
			S[i] = Integer.parseInt(str[i]);
		}
		
		int q = Integer.parseInt(br.readLine());
		str = br.readLine().split(" ");
		int count = 0;
		for(int i = 0; i < q; i++){
			
			int T = Integer.parseInt(str[i]);
			int left = 0, right = n;
			
			while(right != left){
				int half = (right + left)/2;
				if(S[half] < T){
					left = half + 1;
				} else if(S[half] > T){
					right = half;
				} else {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 51564
#include<stdio.h>
//using namespace std;
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int t;
    //cin>>t;
    //while(t--)
    //while(!cin.eof())
    {
        char c;
        scanf("%c",&c);
        if(c>='a'&&c<='z') printf("a\n");
        if(c>='A'&&c<='Z') printf("A\n");
    }
    return 0;
}
/*

*/


Measured memory_bytes: 1592
#include <stdio.h>
int main(void){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}




Measured memory_bytes: 2100
N = int(input())
A = list(map(int,input().split()))
rain = [0]*N

for i in range(N):
    if i % 2 == 0:
        rain[0] += A[i]
    else:
        rain[0] -= A[i]

for i in range(1,N):
    rain[i] = (A[i-1] - rain[i-1] // 2) * 2

print(" ".join(map(str,rain)))

Measured memory_bytes: 19092
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int X;
    int Y = 0;
    cin >> X;
    if(X == 2){
        cout <<X<< "\n";
    }else{
    for(int i = X;;i++){
        for(int l = 2;l<i;l++){
            if(i%l == 0)break;
            if(l == i-1)Y = i;
        }
        if(Y != 0)break;
    }
    cout <<Y<< "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

int perm(int c) {
    return c*(c-1);
}

int main() {
    int n, m;
    cin >> n >> m;
    int count = 0;
    if(n == 2) {
        count++;
    } else if(n > 2) {
        count += (perm(n)/2);

    }
    if(m == 2) {
        count++;
    } else if(m > 2) {
        count += (perm(m)/2);
    }
    cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
int main(){
	int n,m;
	cin >>n>>m;
	vector<pair<int,int>> A(n);
	int a , b;
	rep(i,n){
		cin >> a >> b;
		A[i] = make_pair(a,b);
	}
	vector<pair<int,int>> B(m);
	int c , d;
	rep(j,m){
		cin >> c >> d;
		B[j] = make_pair(c,d);
	}
	rep(i,n){
		tie(a,b) = A[i];
		int check =INF;
		int ans = 1;

		rep(j,m){
			tie(c,d) =B[j];
			int dis = abs(a-c)+abs(b-d);
			if(chmin(check,dis)){
				ans =j+1;
			}
		}
		cout<<ans<<endl;
	}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<bool> v(8);
    int num = 0;
    rep(i, n) {
        if (a[i]<3200) {
            v[a[i]/400] = true;
        }
        else {
            num++;
        }
    }
    int ans1 = 0;
    rep(i, 8) {
        if (v[i]) ans1++;
    }
    int ans2 = ans1 + num;
    ans1 = max(ans1, 1);
    
    
    cout << ans1 << " " << ans2 << endl;

    return 0;
}


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

using namespace std;
using ll = long long;


int method(ll n){
    int ans = 0;
    ll m = n;
    for(ll i = 2; i * i <= n; i++){
        int t = 0;
        while(m % i == 0){
            m /= i;
            t++;
        }
        for(int j = 1; j < 10000; j++){
            if(t >= j){
                ans++;
                t -= j;
            }else{
                break;
            }
        }
    }
    if(m != 1) ans++;
    return ans;
}

int main(){
    ll n;
    cin >> n; 
    cout << method(n) << endl; 
}

Measured memory_bytes: 3632
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
A.append(0)
ans = 0
for j in range(N):
  ans += A[j]//2
  if A[j]%2 != 0 and A[j+1] != 0:
    A[j+1] += 1
print(ans)

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

int main(){
  int A, B;
  int ans=1;
 cin >> A >> B;
  int K = A;
  for (int i=0; i<40; i++){
    if (A < B) {
      A += K - 1;
      ans ++;
    }
    else if (A>=B){ if (B==1) {ans=0; break;}
    else break;}
  }
  
  cout << ans << endl;
    
  
      
    
}

Measured memory_bytes: 256
import sys
from heapq import *
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8, i8[:, :], i8[:]), cache=True)
def main(N, S, G, CD):
    ind = np.searchsorted(G[:, 0], np.arange(N + 1), 'right')
    U = 2600
    C, D = CD[::2], CD[1::2]
    C = np.minimum(C, U)
    S = np.minimum(S, U)
    INF = 10**18
    dist = np.full((N + 1, U + 1), INF, np.int64)
    dist[1, S] = 0
    q = [(0, 1, S)]
    while q:
        d, v, coin = heappop(q)
        if dist[v, coin] < d:
            continue
        for i in range(ind[v - 1], ind[v]):
            w, a, b = G[i, 1:]
            if coin < a:
                continue
            if dist[w, coin - a] <= d + b:
                continue
            dist[w, coin - a] = d + b
            heappush(q, (d + b, w, coin - a))
        c = min(U, coin + C[v - 1])
        if dist[v, c] <= d + D[v - 1]:
            continue
        dist[v, c] = d + D[v - 1]
        heappush(q, (d + D[v - 1], v, c))
    return dist

N, M, S = map(int, readline().split())
nums = np.array(read().split(), np.int64)
UVAB = nums[:4 * M]
CD = nums[4 * M:]

U, V, A, B = UVAB.reshape(-1, 4).T

G = np.empty((M + M, 4), np.int64)
G[:, 0] = np.concatenate((U, V))
G[:, 1] = np.concatenate((V, U))
G[:, 2] = np.concatenate((A, A))
G[:, 3] = np.concatenate((B, B))
G = G[G[:, 0].argsort()]

ans = main(N, S, G, CD)[2:].min(axis=1)
print('\n'.join(map(str, ans.tolist())))

Measured memory_bytes: 110536
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll n;cin>>n;
    vector<ll> a(n),b(n);
    cin>>a>>b;
    
    
    ll ans = 0;
    rep(k,29){
        ll c = 0;
        
        vector<ll> bm(b);
        vector<ll> am(a);
        rep(i,n)bm[i]%=(ll)pow(2LL,k+1);
        rep(i,n)am[i]%=(ll)pow(2LL,k+1);
        
        sort(all(am));sort(all(bm));
        ll T = pow(2LL,k);
        rep(i,n){
            ll v = am[i];
            c += lower_bound(all(bm),T * 2 - v)-lower_bound(all(bm),T - v);
            c += lower_bound(all(bm),T * 4 - v)-lower_bound(all(bm),T * 3 - v);
        }
        
        ans += pow(2LL,k)*(c%2);

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






Measured memory_bytes: 6548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class Main {
	
	private static Map<String,Integer> map = new HashMap<>();
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int[][] a = new int[n][3];

		for (int i = 0; i < n; i++) {
			
			int[] temp = new int[3];
			String[] input = br.readLine().split(" ");
			for (int j = 0; j <3; j++) {
				temp[j] = Integer.parseInt(input[j]);
			}
			
			a[i] = temp;
		}
		
		int ans = solve(a);
		
		System.out.println(ans);
	}

	private static int solve(int[][] a) {
		return helper(a,0,0);
	}

	private static int helper(int[][] a, int i, int last) {
		
		if(i==a.length)
			return 0;
		
		String key = i+":"+last;
		
		if(map.containsKey(key))
			return map.get(key);
		
		int max = 0;
		
		for (int j = 1; j <=3; j++) {
			if(j==last)
				continue;
			max = Math.max(a[i][j-1]+helper(a, i+1, j), max);
		}
		
		
		map.put(key, max);
		
		return max;
	}

}

Measured memory_bytes: 121656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

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

    ll mi = min({a * 8, b * 4, c * 2, d});
    ll ans = n / 2 * mi;

    if(n%2==1)
        ans += min({a * 4, b * 2, c});
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
R,r=range,raw_input;N,K=map(int,r().split());L=K+1;P,Q=R(K),R(L);D=[L*[0]for i in Q];a=b=0
for i in R(N):x,y,c=r().split();x,y=int(x),int(y);p=(x/K+y/K+ord(c))%2;D[y%K+1][x%K+1]+=1-2*p;b+=p
for i in P:
 for j in Q:D[i+1][j]+=D[i][j]
for i in P:
 for j in Q:D[j][i+1]+=D[j][i]
for i in Q:
 for j in Q:
  S=D[i][K]+D[K][j]-D[i][j]*2;a=max(a,S,D[K][K]-S)
print a+b

Measured memory_bytes: 23668
n = int(input())
a = list(map(int,input().split()))

max = (10 ** 9) + 7

#入力配列の総和
line = 0
for i in range (n):
    line += a[i]

#a11, a22, ...対角線要素の総和
rem = 0
for i in range(n):
    rem += a[i]*a[i]

sum = ((line*line) - rem) // 2

ans = sum % max

print(ans)


Measured memory_bytes: 105320
#include <ctime>
#include <string>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
int N, K, card[500][500];
int main() {
	srand((unsigned)time(NULL));
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N / 2; j++) {
			scanf("%d", &card[i][j]);
		}
	}
	while (true) {
		string s;
		for (int i = 0; i < N; i++) {
			s += rand() % 2 + 48;
		}
		bool flag = true;
		for (int i = 0; i < K; i++) {
			int c = 0;
			for (int j = 0; j < N / 2; j++) {
				if (s[card[i][j] - 1] == '1') {
					c++;
				}
			}
			if (c < N / 8 || 3 * N / 8 < c) flag = false;
		}
		if (flag) {
			cout << s << endl; break;
		}
	}
	return 0;
}

Measured memory_bytes: 4196
from bisect import bisect_right

N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()

L = [A[0]]
for a in A[1:]:
    if a >= L[-1]:
        L.append(a)
    else:
        L[bisect_right(L, a)] = a

print(len(L))


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

typedef long long ll;

ll gcd(int a, int b)
{
    return b == 0 ? a : gcd(b, a%b);
}

int main()
{
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    ll ans = 1ll*a*b/gcd(a, b);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int w,h,c1,c2,b,d;
char a[51][51];
int dfs(int i,int j){
    if(i==h||j==w||i<0||j<0||a[i][j]=='#')return 0;
    if(a[i][j]=='W'){d++;return 0;}
    else if(a[i][j]=='B'){b++;return 0;}
    int s=1;
    a[i][j]='#';
    s+=dfs(i+1,j);
    s+=dfs(i-1,j);
    s+=dfs(i,j+1);
    s+=dfs(i,j-1);
    return s;
}
int main(){
    int i,j,ans;
    while(cin>>w>>h,w!=0&&h!=0){
        c1=c2=0;
    for(i=0;i<h;i++)cin>>a[i];
    for(i=0;i<h;i++)for(j=0;j<w;j++)if(a[i][j]=='.'){
        d=b=0;
        ans=dfs(i,j);
        if(b>0&&d>0)continue;
        else if(b>d)c1+=ans;
        else if(b<d)c2+=ans;
    }
        cout<<c1<<" "<<c2<<endl;
}}

Measured memory_bytes: 1356
n = int(input())
li = list(map(int,input().split()))
height = [0]
sum = 0
for i in range(n-1):
  if li[i] >= li[i+1]:
    sum += 1
  else:
    height.append(sum)
    sum = 0
height.append(sum)
print(max(height))
    

Measured memory_bytes: 15020
X, Y, A, B ,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = []

for i in range(X):
    ans.append(p[i])

for i in range(Y):
    ans.append(q[i])

for i in range(C):
    ans.append(r[i])

ans.sort(reverse=True)
print(sum(ans[0:X+Y]))

Measured memory_bytes: 22560
#include <cstdio>

int main(){
    unsigned long long N,M;
    unsigned long long S;

    scanf("%llu %llu",&N,&M);

    if(N==1){
        if(M>2) S=M-2;
        else S=0;
    } 
    else if(M==1){
        if(N>2) S=N-2;
        else S=0;
    }
    else S = (N-2)*(M-2);
    if(N==1&&M==1)S=1;
    printf("%llu\n",S);
    
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;
ll dp[1000002][13];
int main(){
    string s; cin >> s;
    int N = s.length();
    /*
    dp[0][0] = 1;
    for(int i=0; i<N; i++){
        int digit = s[i] - '0';
        for(int j=0; j<13; j++){
            if(s[i] == '?'){
                for(int k=0; k<10; k++){
                    int new_mod = (10 * j + k) % 13;
                    dp[i+1][new_mod] += dp[i][j];
                    dp[i+1][new_mod] %= MOD;
                }
            } else {
                    int new_mod = (10 * j + digit) % 13;
                    dp[i+1][new_mod] += dp[i][j];
                    dp[i+1][new_mod] %= MOD;
            }
        }
    }
    cout << dp[N][5] << endl;
    */
    for(int j=0; j<13; j++){
        if(s[0] == '?'){
            for(int k=0; k<10; k++){
                int new_mod = k % 13;
                dp[0][new_mod] = 1;
            }
        }
        else {
            int new_mod = (s[0] - '0') % 13;
            dp[0][new_mod] = 1;
        }
    }

    for(int i=1; i<N; i++){
        for(int j=0; j<13; j++){
            if(s[i] == '?'){
                for(int k=0; k<10; k++){
                    int new_mod = (j * 10 + k) % 13;
                    dp[i][new_mod] += dp[i-1][j];
                    dp[i][new_mod] %= MOD;
                }
            } else {
                int new_mod = j * 10 + (s[i] - '0');
                new_mod %= 13;
                dp[i][new_mod] += dp[i-1][j];
                dp[i][new_mod] %= MOD;
            }
        }
    }
    cout << dp[N-1][5] % MOD << endl;
    return 0;
}




Measured memory_bytes: 10752
// https://atcoder.jp/contests/practice2/tasks/practice2_f
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M);
    for (auto &x : A)
        cin >> x;
    for (auto &x : B)
        cin >> x;
    auto p = convolution(A, B);
    for (auto &x : p) {
        cout << x << " ";
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 27256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-16 23:50:00
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        cout << "DENIED" << endl; return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X, A, B;
	cin >> X >> A >> B;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		if (S[0] == 'n') {
			X += A;
		}
		else if (S[0] == 't') {
			X += B;
		}
		else {
			X = 0;
		}
		X = max(X, (int)0);
	}
	cout << X << endl;
}


Measured memory_bytes: 3224
// ProblemURL : https://atcoder.jp/contests/abc120/tasks/abc120_d
// ---------------------------------------------
package main

import "fmt"

type djSet struct{ p []int }

func newDj(size int) *djSet {
	dj := &djSet{}
	dj.initDjSet(size)
	return dj
}
func (dj *djSet) initDjSet(size int) {
	dj.p = make([]int, size)
	for i := 0; i < size; i++ {
		dj.p[i] = -1
	}
	return
}
func (dj *djSet) unite(x, y int) bool {
	xr, yr := dj.find(x), dj.find(y)
	if xr != yr {
		if dj.p[yr] < dj.p[xr] {
			x, y = y, x
			xr, yr = yr, xr
		}
		dj.p[xr] += dj.p[yr]
		dj.p[yr] = x
	}
	return xr != yr
}
func (dj *djSet) find(x int) int {
	if dj.p[x] < 0 {
		return x
	}
	dj.p[x] = dj.find(dj.p[x])
	return dj.p[x]
}
func (dj *djSet) isSame(x, y int) bool { return dj.find(x) == dj.find(y) }
func (dj *djSet) size(x int) int       { return -dj.p[dj.find(x)] }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&as[i], &bs[i])
		as[i]--
		bs[i]--
	}

	convenience := 0
	conveniences := make([]int, m)
	dj := newDj(n)
	for i := m - 1; i >= 0; i-- {
		if !dj.isSame(as[i], bs[i]) {
			convenience += dj.size(as[i]) * dj.size(bs[i])
			dj.unite(as[i], bs[i])
		}
		conveniences[i] = convenience
	}

	conveniences = append(conveniences, 0)
	inconvenience := 0
	for i := 1; i < len(conveniences); i++ {
		inconvenience += conveniences[i-1] - conveniences[i]
		fmt.Println(inconvenience)
	}
}


Measured memory_bytes: 7552
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

struct UnionFind{
    
    vector<int> par;
    vector<int> rank;
    vector<int> sz;
    int uf_size;

private:
    void init(int n = 1){
        par.resize(n);
        rank.resize(n);
        sz.resize(n);
        uf_size = n;
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

public:
    UnionFind(int n = 1){
        init(n);
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        uf_size--;
        par[y] = x;
        sz[x] = sz[x] + sz[y];
        return true;
    }

    int size(int x){
        return sz[find(x)];
    }

};

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

    int n, m; cin>>n>>m;
    UnionFind uf(n);

    for(int i=0; i<m; i++){
        int x, y, z; cin>>x>>y>>z;
        x--, y--;
        uf.unite(x, y);
    }

    cout << uf.uf_size << endl;

    return 0;
}

Measured memory_bytes: 1408
import numpy

N = int(input())
p = numpy.asarray(list(map(int,input().split())))

p_diff = numpy.diff(p)

# p_diff = p_diff[p_diff != 0]
p_diff = numpy.where(p_diff > 0, 1, -1)

p_diff2 = numpy.diff(p_diff)

print(len(p_diff2[p_diff2 == 0]))

Measured memory_bytes: 12508
#include<stdio.h>
int main(){
	int a[30];
	int i,n,m;
	int tmp,x,y;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		a[i]=i+1;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d, %d",&x,&y);
		tmp=a[x-1];
		a[x-1]=a[y-1];
		a[y-1]=tmp;
	}
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#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() {
  ll a, b, c;
  cin >> a >> b >> c;
  map<ll, ll> mp;

  ll i = 1;
  while (mp[(a * i) % b] == 0) {
    mp[(a * i) % b]++;
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
    i++;
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256