akhauriyash/Code-Regression huggingface dataset:
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
   ｜  ―――  ｜      ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

#include <bits/stdc++.h>
using namespace std;
 
//#define int ll

typedef int64_t ll;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")

signed main(){
    string s;
    cin >> s;

    int ans = 114514;

    REP(i,LEN(s)-1){
        if(s[i]!=s[i+1]) ans = min(ans,max(i+1,LEN(s)-i-1));
    }

    printf("%d\n",min(ans,SZ(s)));

    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for(int i = 0; i < n - 2; i++) {
    if(s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C') ans += 1;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void)
{
  int A, B;

  cin >> A >> B;

  if(A > 8){
    cout << ":(" << endl;
  }
  else if(B > 8){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
//ll dp[200020];
map<ll,ll>need;
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;

    for(ll i=0;i<n-1;i++){
        if(a[i]+a[n-1]==n-1-i){
            //cout<<i<<endl;
            ans++;
        }
        need[(n-1-i)-a[i]]++;
        
    }
    //cout<<ans<<Endl;
    ll cnt=1;
    for(ll i=n-2;i>=1;i--){
        //cout<<(n-1-i)-a[i]<<" "<<a[i]<<endl;
        need[(n-1-i)-a[i]]--;
        //cout<<(n-1-i)-a[i]<<endl;
        //if(i==3)cout<<need[a[i]-cnt]<<endl;
        ans+=need[a[i]+cnt];
        cnt++;
    }

    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 27468
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string get(int x) {
  string res = "";
  while (x > 0) {
    res += (char)('0' + x % 10);
    x /= 10;
  }
  while ((int)res.size() < 6) {
    res += "0";
  }
  reverse(res.begin(), res.end());
  return res;
}

const int N = 100'009;

int p[N];
int y[N];
vector<int> g[N];
string ans[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d %d", p + i, y + i);
    --p[i];
    g[p[i]].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    sort(g[i].begin(), g[i].end(), [](int l, int r) {
      return y[l] < y[r];
    });
    for (int j = 0; j < (int)g[i].size(); ++j) {
      ans[g[i][j]] = get(i + 1) + get(j + 1);
    }
  }
  for (int i = 0; i < m; ++i) {
    puts(ans[i].c_str());
  }
}


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

int main(){
  int a,b;
  cin>>a>>b;
char w[a][b];
vector<int>h(a),t(b);
  for(int i=0;i<a;i++){
  h[i]=0;
  }
    for(int i=0;i<b;i++){
  t[i]=0;
    }
for(int i=0;i<a;i++){
  for(int j=0;j<b;j++){
  cin>>w[i][j];
    if(w[i][j]=='#'){
      h[i]=1;
        t[j]=1;
    }
  }
}

for(int i=0;i<a;i++){
  for(int j=0;j<b;j++){
  if(h[i]==1&&t[j]==1){
      cout<<w[i][j];
    }
  }
      if(h[i]!=0){
        cout<<endl;
      }
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
int mod=1e9+7;





int32_t main() {
    int T;
    T=1;
    //cin>>T;
    while(T--){
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<int>dp(n,(int)1e9);
        dp[0]=0;
        dp[1]=abs(a[0]-a[1]);
        for(int i=2;i<n;i++){
            for(int j=i-1;j>=max(i-k,(int)0);j--){
                dp[i]=min(dp[i], abs(a[i]-a[j])+dp[j]);
            }
        }
        
        cout<<dp[n-1];
        cout<<'\n';
    }
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 5005
const ll INF = 1e9 + 7;


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

const ll MOD = 1e9 + 7;

int main() {

	ll r, g, b, n;
	cin >> r >> g >> b >> n;
	ll ans = 0;

	//cout << n / r << " " << n / g << endl;
	for (int i = 0; i <= n/r; i++)
	{
		for (int j = 0; j <= n / g; j++)
		{
			if (r*i > g*j > n)
			{
				continue;
			}
			if ((n - (r*i + g * j)) % b == 0 && (n - (r*i + g * j)) / b >= 0)
			{
				//cout << i << " " << j << " " << (n - (r*i + g * j)) / b << endl;
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner sc= new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int area=a*b;
int length=(a+b)*2;
System.out.println(area +" "+ length);
sc.close();
}
}


Measured memory_bytes: 26196
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <ctime>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int x[10000];
int n, k;
int ans[10];

int query(){
  printf("?");
  REP(i,n) printf("%d", x[i]);
  printf("\n");
  fflush(stdout);
  return getInt();
}

int main(){
  srand(time(NULL));

  n = getInt();
  k = getInt();

  REP(i, k){
    do{
      // Random
      REP(j, n) x[j] = rand() % 2;
      REP(j, i) x[ans[j] - 1] = 0;
    }while(query() == 0);

    vector<int> ones;
    REP(j, n) if(x[j] == 1) ones.push_back(j);

    while(ones.size() != 1){
      int m = ones.size() / 2;

      REP(j, n) x[j] = 0;
      REP(j, m) x[ones[j]] = 1;

      if(query() == 1){
	ones = vector<int>(ones.begin(), ones.begin() + m);
      }else{
	ones = vector<int>(ones.begin() + m, ones.end());
      }
    }

    ans[i] = ones[0] + 1;
  }

  printf("!");
  REP(i,k) printf("%d%c", ans[i], i == k - 1 ? '\n' : ' ');
  fflush(stdout);

  return 0;
}

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

int main(void) {
	char s[200000];
	int ans[200000] = { 0 };
	scanf("%s", s);
	int length = 0;
	while (s[length] != 0)
		length++;
	int count = 0;
	for (int i = 0; i < length; i++) {
		if (s[i] == 'R')
			count++;
		else if (count % 2 == 1) {
			ans[i - 1] += count / 2 + 1;
			ans[i] += count / 2;
			count = 0;
		}
		else {
			ans[i - 1] += count / 2;
			ans[i] += count / 2;
			count = 0;
		}
	}

	for (int i = length - 1; i >= 0; i--) {
		if (s[i] == 'L')
			count++;
		else if (count % 2 == 1) {
			ans[i + 1] += count / 2 + 1;
			ans[i] += count / 2;
			count = 0;
		}
		else {
			ans[i + 1] += count / 2;
			ans[i] += count / 2;
			count = 0;
		}
	}

	for (int i = 0; i < length; i++)
		printf("%d ", ans[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> vec(n, 0);
  vector<bool> used(n, 0);
  for (int i = 0; i < n; i++) {
    int j;
  	cin >> j;
    vec.at(i) = j-1;
  }
  int ans;
  int c;
  while(1) {
  	ans++;
    if (vec[c] == 1) {
    	cout << ans << endl;
    	break;
    }
    if (used[vec[c]] == 1) {
    	cout << -1 << endl;
    	break;
    }
    used[vec[c]] = 1;
    c = vec[c];
  }
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int a, b, c;
    cin >> a >> b >> c;

    a = a ^ b;
    b = a ^ b;
    a = a ^ b;

    a = a ^ c;
    c = a ^ c;
    a = a ^ c;

    cout << a << " " << b << " " << c << endl;

    return 0;
}

Measured memory_bytes: 3168
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var one = myconv(next(),4);
  myout(Math.ceil(one[0] / one[1]));
}

Measured memory_bytes: 22076
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--) 
 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}   
 
signed main(){
    fast;   
    int a, b, c, k;
    cin >> a>> b>> c>> k;
    if(k<=a){
        cout << k;
    }
    else if(k<=a+b){
        cout <<a;
    }
    else{
        cout << a-(k-(a+b));
    }
}

Measured memory_bytes: 3648
# '#'の数がH+W-1

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    h,w = map(int, input().split())
    s = 0
    for _ in range(h):
        a = input().rstrip()
        s += a.count('#')

    if s == h+w-1:
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define dl double
#define PB push_back
#define MP make_pair
#define PPB pop_back
#define FI first
#define SE second
#define IN insert
#define ER erase
#define clean cout.flush()
#define PF push_front
#define PP pop
#define PH push
#define TP top
#define all(x) x.begin(),x.end()
#define REV reverse
#define IOS ios_base::sync_with_stdio(false);
#define inout freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
//Here I have defined all the things.....have you any problem?

const ll mod=1e9+7;
const ll lim=1e6+10;
ll ara[lim];
ll b[lim];
ll f[lim];
ll m[100010];

//fasting input and output
void faster()
{
    IOS; cin.tie(NULL); cout.tie(NULL);
}

void solve()
{
    string x,y;
    cin>>x>>y;
    int n=x.size();
    int m=y.size();
    int ans=100000;
    for(int i=0;i<=n-m;i++)
    {
        string s=x.substr(i,m);
        int cnt=0;
        for(int j=0;j<s.size();j++)
        {
            if(y[j]!=s[j]) cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;

}

int main()
{
    faster();
    //if you hack my code you are a bullshit
    /*ll t; cin>>t; while(t--)*/solve();
    return 0;
}
//Remember, "FAILURE IS THE PILLAR OF SUCCESS"


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

using namespace std;

int main(){
  //enum case = {AC, WA, TLE, RE};
  int n, array[4] = {0};
  string s, results[4] = {"AC", "WA", "TLE", "RE"};
  
  cin >> n;
  for(int i = 0; i < n; i++){
	cin >> s;
    for(int j = 0; j < 4; j++){
      if(s == results[j])
        array[j]++;
    }
  }
  
  for(int i = 0; i < 4; i++)
    cout << results[i] << " x " << array[i] << endl;
                  
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

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

	int id[2] = { 0,0 };
	bool ng = 0;

	for (int i = 1; i < s.size(); ++i)
	{
		if (s[0] == s[i])
		{
			id[0] = 0;
			if (id[1] == 0)
				id[1] = i;
			else
				ng = 1;
		}
	}

	if (id[1] == 0)
		ng = 1;

	if (id[1] == 1)
	{
		if (s[2] != s[3])
			ng = 1;
	}
	if (id[1] == 2)
	{
		if (s[1] != s[3])
			ng = 1;
	}
	if (id[1] == 3)
	{
		if (s[2] != s[1])
			ng = 1;
	}

	if (ng)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
s = list(map(int, list(input())[: -1]))
if s[0] == 0 or s[-1] == 1:
  print(-1)
  exit(0)
n = len(s)
for i in range(n - 1):
  if s[i] != s[-2 - i]:
    print(-1)
    exit(0)
res = []
temp = []
s[-1] = 1
for i in range(n):
  if s[i] == 0 or i == 0:
    temp.append(i + 1)
  else:
    if len(res):
      p = res[-1][0]
      res.append((i + 1, p))
    if len(temp):
      while len(temp):
        res.append((i + 1, temp.pop()))
for _ in range(len(res)):
  print(*res.pop())

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

int a[200000];

int main() {

    int n, i; ll ans = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", a + i);
    for(i = 1; i < n && a[i] - a[i - 1] <= 1; i++);
    if (a[0] || i < n) {
        puts("-1");
        return 0;
    }
    for(i = n - 1; i >= 0; i--) {
        if (!a[i]) continue;
        if (i < n - 1 && a[i + 1] == a[i] + 1) continue;
        ans += a[i];
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    long long ans = 0L;
    
    vector<int> vec(n + 1);
    for (int i = 1; i <= n; i++) {
        long long buf = n / i;
        long long bufsum = (1 + buf) * buf / 2;
        ans += i * bufsum;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42296
import sys
n,k = map(int, input().split())

a = list(map(int, input().split()))

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+k+1):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]))

print(dp[n-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;
ld pi = 3.14159265359;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    cin >> n;
    ld d;
    cout << fixed << setprecision(9) << 2 * pi * n;

    return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>
int main(void){
    int k,s,x,y,cnt=0;
    scanf("%d%d",&k,&s);
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            if(x+y<=s && s-x-y<=k) cnt++;
        }
    }
    printf("%d",cnt);
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
	double r,a,b;
	
	scanf("%lf",&r);
	
	a=r*r*M_PI;
	b=2*r*M_PI;
	
	printf("%.6f %.6f\n",a,b);
	
	return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    ll lala, la = 2, now;
    rep(i,N){
        if(i == 0) now = 1;
        else now = la + lala;
        lala = la;
        la = now;
    }
    cout<<now<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    int NORTH = 0;
    int EAST = 1;
    int SOUTH = 2;
    int WEST = 3;
    int[] dx = { 0, 1, 0, -1};
    int[] dy = { 1, 0, -1, 0};

    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int w = sc.nextInt();
            int h = sc.nextInt();
            if(w == 0 && h == 0){
                break;
            }
            int[][] field = new int[h][w];
            int direction = NORTH;
            int x = 0;
            int y = 0;
            while(true){
                String command = sc.next();
                if(command.equals("STOP")){
                        break;
                    }
                if(command.equals("FORWARD")){
                    int n = sc.nextInt();
                    for(int i = 0;i < n;i++){
                        int nx = x + dx[direction];
                        int ny = y + dy[direction];
                        if(nx < 0 || nx >= w || ny < 0 || ny >= h){
                            break;
                        }
                        x = nx;
                        y = ny;
                    }
                }
                if(command.equals("BACKWARD")){
                    int n = sc.nextInt();
                    for(int i = 0;i < n;i++){
                        int nx = x - dx[direction];
                        int ny = y - dy[direction];
                        if(nx < 0 || nx >= w || ny < 0 || ny >= h){
                            break;
                        }
                        x = nx;
                        y = ny;
                    }
                }
                if(command.equals("RIGHT")){
                    direction = (direction + 1) % 4;
                    }
                if(command.equals("LEFT")){
                    direction = (direction + 3) % 4;
                }

            }
            x += 1;
            y += 1;
            System.out.println(x + " " + y);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

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

int deljenje=1000000007;

int f(vector<vector<char> > &m,int h,int w,vector<vector<int> > &dp)
{
    dp[0][0]=0;
    for (int i=1;i<h;i++)
        if(m[i][0]=='.')
            dp[i][0]=1;
        else
            break;
    for (int i=1;i<w;i++)
        if(m[0][i]=='.')
            dp[0][i]=1;
        else
            break;
    for (int i=1;i<h;i++)
        for (int j=1;j<w;j++)
        {
            if(m[i-1][j]=='.')
                dp[i][j]=(dp[i][j]+dp[i-1][j])%deljenje;
            if(m[i][j-1]=='.')
                dp[i][j]=(dp[i][j]+dp[i][j-1])%deljenje;
        }
    return dp[h-1][w-1];
}

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char> > m(h,vector<char> (w,0));
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            cin >> m[i][j];
    vector<vector<int> > dp(h,vector<int> (w,0));
    cout << f(m,h,w,dp);
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];
bool X[N][N];

void initialize() {
	for (int i = 0; i < N; i++) {
		row[i] = FREE;
		col[i] = FREE;
	}
	for (int i = 0; i < 2 * N - 1; i++) {
		dpos[i] = FREE;
		dneg[i] = FREE;
	}
}
void printBoard() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (X[i][j]) {
				if (row[i] != j) return;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cout << ((row[i] == j) ? "Q" : ".");
		}
		cout << endl;
	}
}
void recursive(int i) {
	if (i == N) {
		printBoard();
		return;
	}
	for (int j = 0; j < N; j++) {
		if (NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1]) continue;
		row[i] = j;
		col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
		recursive(i + 1);
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
	}
}
int main() {
	initialize();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) X[i][j] = false;
	}
	int k;
	cin >> k;
	for (int i = 0; i < k; i++) {
		int r, c;
		cin >> r >> c;
		X[r][c] = true;
	}
	recursive(0);
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int k, x;
  cin >> k >> x;
  if(500*k >= x){
    cout << "Yes"<< endl;
  } else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

edges = [[] for _ in range(n)]
for i in range(1, n):
    _from, to, dist = i, i-1, 0
    edges[_from].append([to, dist])

for _ in range(m):
    _from, to, dist = map(int, input().split())
    edges[_from-1].append([to-1, dist])


D = [float('INF')]*n
D[0] = 0
todo = []
for to, dist in edges[0]:
    heapq.heappush(todo, [dist, to])
    D[to] = dist

while todo:
    total_dist, node = heapq.heappop(todo)

    for to, dist in edges[node]:
        if total_dist + dist < D[to]:
            heapq.heappush(todo, [total_dist+dist, to])
            D[to] = total_dist + dist
        else:
            continue

ans = D[n-1]
if ans == float('INF'):
    ans = -1

print(ans)


Measured memory_bytes: 51200
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, X = sc.nextInt()
    val x = Array.fill(N)(sc.nextInt() - X)
    // Dの到達可能性？
    // +D, -Dにしか移動できないということは
    // x' = X + nD で表せる箇所にしか到達できないということ
    // 初期化時に x_? について, -X をしておく
    // すると各xについて x % D == 0 を調べればよくなる
    // O(N)ではまだ通らないので D を log Nぐらいで見つけたい...
    // 全ての x について -X しておくと nD で表せて
    // かつ最大のDを見つけたいということはDは最大公約数になる
    // 累積GCDしたらそれがD
    def gcd(a: Int, b: Int): Int =
      if (a % b == 0) b
      else gcd(b, a % b)

    val D = x.reduce((a, b) => gcd(a, b)).abs
    println(D)
  }

}


Measured memory_bytes: 49300
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	vector<int> x = {a, b, c};
	int ans = 0;
	for(int i = 0; i < k; ++i) {
		sort(x.begin(), x.end());
		x[2] *= 2;
	}
	
	cout << accumulate(x.begin(), x.end(), 0) << endl;
	
	return 0;
}


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

   bool flag=true;
   for(int i=0;i<3;i++){
      if(S.at(i)==S.at(i+1))
         flag=false;
   }
   if(flag==true)
      cout<<"Good"<<endl;
   else
      cout<<"Bad"<<endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  string s;
  cin >> s;

  bool all9 = true;
  rep(i, 1, s.length()){
    if(s[i] != '9'){
      all9 = false;
    }
  }

  if(all9){
    cout << 9*(s.length()-1) + int(s[0]-'0') << endl;
  }else if(s.length()==1){
    cout << s << endl;
  }else{
    int ans = 9*(s.length()-1) + int(s[0]-'1');
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
char a[100],b[100],c[100];
char temp,x;
int aa=0,bb=0,cc=0;
int end =1;
scanf("%s%s%s",a,b,c);
temp = a[aa];
while(end){
switch (temp){
case('a'):
  aa++;
  temp = a[aa];
  x = 'A';
  break;
case('b'):
  temp = b[bb];
  bb++;
  x = 'B';
  break;
case('c'):
  temp = c[cc];
  cc++;
  x='C';
  break;
default:
  printf("%c",x);
  end =0;
}
}
return 0;
}

Measured memory_bytes: 128
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

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

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

const ll N=1e5+5;




int main()
{ 

IOS;


ll n;cin>>n;

vl a(n+2),b(n+1);

for(int i=1;i<=n+1;i++)cin>>a[i];

FOR(i,n)cin>>b[i+1];

ll tot=0;

for(int i=1;i<=n;i++){

if(b[i]>=a[i]){
  tot+=min(b[i],a[i]+a[i+1]);
  a[i+1]-=(b[i]-a[i]);
  if(a[i+1]<0)a[i+1]=0;
}
else {
tot+=b[i];

}

}

cout<<tot<<endl;

return 0;
 
}


Measured memory_bytes: 4744
a['~~'],b[99999],c,n,i;u(int*x,int*y){i=*y-*x;}main(m){for(;scanf("%d%d",&n,&m)*n;memset(a,i=!printf("%d\n",c),9e4)){for(a[1]=c=1;i<3*m;)scanf("%d",b+i++);for(qsort(b,m,12,u);m--;)c+=a[b[m*3+1]]&&!a[b[m*3+2]]++;}}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define pi acos(-1)
#define flag bool fl=true;
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0);
 
int main()
{
      int n=5,i=1,a[6];
  for(i=1;i<6;i++){
        cin>>a[i];
    if(a[i]==0)break;}
  
  cout<<i;
  
  
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
 	 ll a,b,s,as;
  cin>>a>>b;
  s=a+b;
  if(s%2==0)
  {
    as=s/2;
    cout<<as<<endl;
  }
  else{
    cout<<"IMPOSSIBLE\n";
  }
  
  
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int x,y;
    int n;
    cin >> n >> x >> y;
    vector<int> dis(n+1,0);
    rep1eq(i,1,n){
        rep1eq(j,i+1,n){
            int dist = min(j-i,abs(i-x)+abs(j-y)+1);
            dis[dist]++; 
        }
    }
    rep1(i,1,n){
        cout << dis[i]<<endl;
    }


}

Measured memory_bytes: 256
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)
      

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int gcd(int a,int b){//ユークリッドの互除法
  if(a==0||b==0){
    return max(a,b);
  }
  while(b){
    a %= b;
    swap(a,b);
  }
  return a;
}
struct segment_tree{
  vl data;
  function<ll(ll,ll)> func;
  ll n,identity;
  segment_tree(ll size,ll id,function<ll(ll,ll)> f):func(f),identity(id){
    n = 1;
    while(n<size) n*=2;
    data.assign(2*n+1,id);
  }
  void update(ll i,ll x){
    data[i+=n-1]=x;
    while(i>0){
      i = (i-1)/2;
      data[i]=func(data[2*i+1],data[2*i+2]);
    }
  }
  ll find(ll a,ll b,ll k=0,ll l=0,ll r=-1){
    if(r<0) r = n;
    if(r<=a||b<=l) return identity;
    if(a<=l&&r<=b) return data[k];
    ll vl = find(a,b,2*k+1,l,(l+r)/2);
    ll vr = find(a,b,2*k+2,(l+r)/2,r);
    return func(vl,vr);
  }
};
struct gcd_tree{
  segment_tree gd;
  gcd_tree(ll size):gd(size,0,[](ll a,ll b)->ll{return gcd(a,b);}){}
  void update(ll i,ll x){
    gd.update(i,x);
  }
  ll find(ll a,ll b){
    return gd.find(a,b);
  }
};
signed main(){
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  gcd_tree gd(n);
  REP(i,n){
    gd.update(i,a[i]);
  }
  int ans = a[0];
  ans = gcd(ans,gd.find(1,n));
  ans = max(ans,gcd(ans,gd.find(0,n-1)));
  REP(i,n){
    ans = max(ans,gcd(gd.find(0,i),gd.find(i+1,n)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,ans;
main()
{
	cin>>n;
	vector<pair<int,int> >a;
	int now=0;
	for(int i=0;i<n;i++)
	{
		int x,y;cin>>x>>y;
		a.push_back(make_pair(y,x));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++)
	{
		if(now<a[i].second)
		{
			ans++;
			now=a[i].first;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3888
import math

S = input()
K = int(input())
#print(S)
cnt = 1
ans = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt //2 
        cnt = 1
ans += cnt //2 
#print("ans", ans)    
ans *= K
#print("ans*K",ans)

if S[0] == S[-1]:
    cntf = 1
    cnte = 1
    for i in range(1,len(S)):
        #print(S[i], S[i-1] )
        if S[i] == S[i-1]:
            cntf += 1
        else:
            break
    #print("---------------")
    for i in range(1,len(S)):
        #print(S[-i], S[-i+1] )
        if S[-i-1] == S[-i]:
            cnte += 1
        else:
            break
    #print(cnte, cntf)
    if cnte % 2 ==1 and cntf % 2 ==1:
        #print("bbbb")
        ans += (K-1)  

    if cnte == len(S):
        #print("aaa")
        ans = len(S) * K // 2
print(ans)




Measured memory_bytes: 3064
NN = 19
X = [0] * ((1<<NN+1)-1)
 
def popcount(x):
    x -= (x >> 1) & 0x55555555
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x += x >> 8
    x += x >> 16
    return x & 0x3f

def update(a, x):
    i = (1<<NN) - 1 + a
    X[i] = x
    while i:
        i = (i-1) // 2
        X[i] = X[2*i+1] | X[2*i+2]

def rangeor(a, b):
    l = a + (1<<NN)
    r = b + (1<<NN)
    x = 0
    while l < r:
        if l%2:
            x |= X[l-1]
            l += 1
        if r%2:
            r -= 1
            x |= X[r-1]
        l >>= 1
        r >>= 1
    return x

N = int(input())
A = [ord(a) - 97 for a in input()]
for i, a in enumerate(A):
    X[(1<<NN) + i] = 1 << a
for i in range((1<<NN)-1)[::-1]:
    X[i] = X[i*2+1] | X[i*2+2]

Q = int(input())
for _ in range(Q):
    a, b, c = input().rstrip().split()
    if a == "1":
        b = int(b)
        c = ord(c) - 97
        update(b, 1<<c)
    else:
        b, c = int(b), int(c)
        print(popcount(rangeor(b, c+1)))

Measured memory_bytes: 77976
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string s[h];
    for(int i=0;i<h;i++){
    	cin >> s[i];
    }
    int dx[8]={ -1, -1, -1, 0, 0, 1, 1, 1 },dy[8]={ -1, 0, 1, -1, 1, -1, 0, 1};
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		if(s[i][j]=='.'){
    			int sum = 0;
    			for(int k=0;k<8;k++){
    				int x = j + dx[k], y = i + dy[k];
    				if(x < 0 || x >= w || y < 0 || y >= h)continue;
    				if(s[y][x]=='#') sum++;
    			}
    			s[i][j] = '0' + sum;
    		}
    	}
    }
    for(int i=0;i<h;i++){
    	cout << s[i] << endl;
    }
    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;



int h,w; 
int sx=0,sy=0,gx,gy;

char maze[50][50];
int  dist[50][50];

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

int bfs(){
  queue<P> que;
  rep(i,h){
    rep(j,w){
      dist[i][j]=INF;
    }
  }
  que.push(P(sy,sx));
  dist[sy][sx]=0;
  
  while(que.size()){
    P p=que.front(); que.pop();
    if(p.first==gy && p.second==gx){
      return dist[gy][gx];
      break;
    }
    rep(i,4){
      int ny=p.first+dy[i], nx=p.second+dx[i];
      if(0<=nx && nx<w && 0<=ny && ny<h && maze[ny][nx]=='.' && dist[ny][nx]==INF){
        que.push(P(ny,nx));
        dist[ny][nx]=dist[p.first][p.second]+1;
      }
    }    
  }
  return 0;
}
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int cnt=0;
  cin>>h>>w;
  gx=w-1;
  gy=h-1;
  rep(i,h){
    rep(j,w){
      cin>>maze[i][j];
      if(maze[i][j]=='#') cnt++;
    }
  }
  int ans=bfs();
  if(bfs()) cout<<h*w-cnt-ans-1<<endl;
  else cout<<-1<<endl;
}
  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define LL long long 
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

int n,a,b,c,d,k;
inline bool check(int l){
	LL cntl = l / (k+1),r = l % (k+1);
	LL cnta = a - (cntl * k + r),cntb = b - (cntl);
	return cntb <= cnta * k;
}
inline void solve(){
	read(a),read(b),read(c),read(d),k = max(ceil(1.0*a/(b+1)),ceil(1.0*b/(a+1)));
	n = a + b;
	int L = 0,R = n,Mid,Ans = 0;
	while (L < R){
		Mid = L+R>>1;
		if (check(Mid)) Ans = Mid+1,L = Mid+1; else R = Mid;
	}
	int l = Ans;
	LL cntl = l / (k+1),r = l % (k+1);
	int cnta = a - (cntl * k + r),cntb = b - (cntl);
	int w = l + 1 + (cntb - (cnta) * k);
	for (int i = c; i <= d; ++i){
		if (i <= l){
			putchar(i % (k+1) == 0 ? 'B' : 'A');
		}
		else{
			int j = i - w;
			putchar(j %(k+1) == 0 ? 'A' : 'B');
		}
	}
	putchar('\n');
}

signed main(){
	int T; read(T); while (T--) solve();
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N; y++) {
            int z = N - x - y;
            if (z < 0) continue;
            if (10000 * x + 5000 * y + 1000 * z == Y) {
                return cout << x << " " << y << " " << z << endl, 0;
            }
        }
    }
    cout << "-1 -1 -1\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 998244353;

int main(){
  vector<int> t(3,0);
  rep(i,3) cin >> t[i];
  sort(all(t));
  cout << t[0]+t[1] << endl;
}

Measured memory_bytes: 256
import collections, queue, sys
n, k =  map(int, input().split())
m = 10**9+7
edges = collections.defaultdict(list)
q = queue.Queue()
preq = queue.Queue()
ans = 1

for i in range(n-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

j = 1
for i in edges[1]:
    q.put(i)
    preq.put(1)
    if k - j <= 0:
        print(0)
        sys.exit()
    ans = ans%m * (k - j)%m
    j+=1

while not q.empty():
    j = 2
    node = q.get()
    prenode = preq.get()
    for i in edges[node]:
        if not i == prenode:
            q.put(i)
            preq.put(node)
            if k - j <= 0:
                print(0)
                sys.exit()
            ans = ans%m * (k - j)%m
            j+=1
print((ans*k)%m)


Measured memory_bytes: 31832
var
	N,i:Longint;
	H:Array[0..100000]of Longint;
begin
	read(N);
	for i:=1 to N do begin
		read(H[i]);
		if H[i-1]>H[i] then begin
			writeln('No');
			exit;
		end else if H[i-1]<H[i] then dec(H[i]);
	end;
	writeln('Yes');
end.


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import collections
import itertools


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    graph = collections.defaultdict(list)
    for aa,bb in zip(a,b):
        graph[aa].append(bb)
        graph[bb].append(aa)

    res = 0
    for seq in itertools.permutations(range(1,N+1)):
        if seq[0] != 1:
            continue
        bOK = True
        for i in range(len(seq)-1):
            if seq[i+1] not in graph[seq[i]]:
                bOK = False
                break
        if bOK:
            res += 1

    print(res)





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
string arr;
long long mod=1e9+7;
int dp[100001][30];
long long getsum(int ind,int sum){
	if(ind==arr.size()) return (sum%13==5?1:0);
	if(dp[ind][sum]!=-1) return dp[ind][sum];
	int limit=9;
	
	long long res=0;
	
	
		if(arr[ind]=='?'){
			for(int i=0;i<=limit;i++){
			res+=getsum(ind+1,(sum*10+i)%13);
			res%=mod;
			
		        }
		}
		else res+=getsum(ind+1,(sum*10+(arr[ind]-'0'))%13), res%=mod;
	return dp[ind][sum]=res;;
}
int main() {

    cin>>arr;
    memset(dp,-1,sizeof(dp));
    cout<<getsum(0,0)<<endl;

	return 0;
}

Measured memory_bytes: 23288
s = input()


length = len(s)//2
if len(s) % 2 != 0:
    print("No")
    exit(0)

tmp = 0
for i in range(0, len(s), 2):
    if s[i] == 'h' and s[i+1] == 'i':
        tmp += 1

if length == tmp:
    print("Yes")
else:
    print("No")


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

int n;

void solve(vector<int> &a) {
    int count = 0;
    int num = 1;
    for (int i = 0; i < n; i++) {
        if (a.at(i) != num) {
            count++;
        } else {
            num++;
        }
    }

    if (count == n) {
        cout << -1 << endl;
    } else {
        cout << count << endl;
    }
}

int main() {
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a.at(i));
    }

    solve(a);

    return 0;
}

Measured memory_bytes: 1024
import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	t = map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1)))
	dp[x] = mn(t)	#reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()

Measured memory_bytes: 376408