akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 1e6 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int LN = 22;
const int SN = 320;

long long n, m, u, v, k, t, q, x, d, p, a, b, c, s;

string sa, sb;
int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> sa >> sb;
   int cnt = 0;
   for (int i = 0; i < 3; ++i) if (sa[i] == sb[i]) cnt++;
   cout << cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using lli = long long;
using pii = pair<int,int>;

const int MOD=1000000007;

int n,dp[200001][2];
vector<int> da[200001],adj[200001];
int ea[19][200001],de[200001];
void make(int cur,int p,int d) {
    int a=1;
    de[cur]=d;ea[0][cur]=p;
    da[d].push_back(cur);
    while(p!=-1 && ea[a-1][p]!=-1) {
        p=ea[a][cur]=ea[a-1][p];
        a++;
    }
    for(auto &it:adj[cur]) make(it,cur,d+1);
}
int lca(int u,int v) {
    if(de[u] > de[v]) swap(u,v);
    int dif=de[v]-de[u];
    for(int i=0;1<<i<=dif;i++) if(dif>>i&1) {
        v=ea[i][v];
    }
    if(v==u) return v;
    for(int i=17;i>=0;i--) if(ea[i][u]!=ea[i][v]) {
        u=ea[i][u];v=ea[i][v];
    }
    return ea[0][v];
}

int power(int a,int p) {
    int ret=1;
    while(p) {
        if(p&1)ret=1ll*ret*a%MOD;
        a=1ll*a*a%MOD;
        p>>=1;
    }
    return ret;
}
int inv(int a) {return power(a,MOD-2);}

int pa[200001];
void init() {
    for(int i=0;i<=n;i++) dp[i][0]=dp[i][1]=1;
    memset(ea,-1,sizeof(ea));
    for(int i=0;i<=n;i++) pa[i]=i;
}
int find(int cur) {return cur==pa[cur] ?cur : pa[cur]=find(pa[cur]);}
int solve(int d) {
    int s=(int)da[d].size();
    if(!s) return 0;

    vector<pii> ta;
    for(int i=0;i<s-1;i++) ta.push_back({de[lca(da[d][i],da[d][i+1])],i});
    sort(ta.begin(),ta.end(),greater<pii>());
    for(int i=0,j;i<sz(ta);i=j) {
        vector<int> va;
        va.push_back(find(da[d][ta[i].se+1]));
        for(j=i;j<sz(ta) && de[lca(da[d][ta[i].se+1], da[d][ta[j].se])]==ta[i].fi;j++){
            va.push_back(find(da[d][ta[j].se]));
        }
        
        int d[2]={1,1};
        for(auto &v:va) {
            d[0] = 1ll*d[0]*((dp[v][0]+dp[v][1])%MOD)%MOD;
            d[1] = 1ll*d[1]*dp[v][0]%MOD;
        }
        
        int td=d[1];
        d[1]=0;
        for(auto &v:va) {
            d[1] = (d[1] + 1ll*td*inv(dp[v][0])%MOD*dp[v][1]%MOD)%MOD;
        }
        d[0] = (d[0]-d[1]+MOD)%MOD;
        for(int i=1;i<sz(va);i++) {
            pa[find(va[i])] = find(va[0]);
        }
        dp[find(va[0])][0] = d[0];
        dp[find(va[1])][1] = d[1];
    }
    int v=find(da[d][0]);
    return 1ll*dp[v][1]*power(2,n+1-s)%MOD;
}

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        int p;
        scanf("%d",&p);
        adj[p].push_back(i);
    }

    init();
    make(0,-1,0);
    
    int md=*max_element(de,de+n+1),ans=0;
    for(int i=0;i<=md;i++) {
        ans = (ans+solve(i))%MOD;
    }
    printf("%d\n",ans);
    
    return 0;
}


Measured memory_bytes: 49408
#include <stdio.h>

int main(void)
{
    
    int totalValue;
    long sum = 0;
    int temp;

    scanf("%d", &totalValue);
    int arr[totalValue];
    for(int i = 0; i < totalValue; i++){
    	scanf("%d", &arr[i]);
        sum+=arr[i];
    }
    for (int i = 0; i < totalValue; i++)
            {
                for (int j = i + 1; j < totalValue; j++)
                {
                    if (arr[i] > arr[j])
                    {
                        temp =  arr[i];
                        arr[i] = arr[j];
                        arr[j] = temp;
                    }
                }
            }
    printf("%d %d %ld\n", arr[0], arr[totalValue-1], sum);
    return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int curr = 0;
  for (int i = 1; i < n; ++i){
    if (s[i - 1] == s[i])++curr;
  }
  cout << min(n - 1, curr + 2 * k) << endl;
}
    

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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define maxn   3005

ll a[maxn][maxn];

ll f[maxn][maxn][5];

int main() {
//        freopen(".inp","r",stdin);

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int m, n, k;
        cin >> m >> n >> k;

        for(int i = 1; i <= k; ++ i) {
            int x, y, v;
            cin >> x >> y >> v;
            a[x][y] = v;
        }

        for(int i = 1; i <= m; ++ i) {
            for(int j = 1; j <= n; ++ j) {
                for(int z = 1; z <= 3; ++ z) {
                    f[i][j][z] = max(f[i][j][z], f[i][j-1][z]);
                    f[i][j][1] = max(f[i][j][1], f[i-1][j][z] + a[i][j]);
                    f[i][j][z] = max(f[i][j][z], f[i][j-1][z-1] + a[i][j]);
                }
            }
        }
        cout << max({f[m][n][1], f[m][n][2], f[m][n][3]});
}




Measured memory_bytes: 426080
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    std::vector<lint> a(n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%lld", &a[i]);
    }

    std::vector<lint> ans(n, 0);
    lint ans_num = 0;

    for (lint i = n; i >= 1; i--)
    {
        lint sum = 0;
        for (lint j = i * 2; j <= n; j += i)
        {
            sum += ans[j - 1];
        }

        if (sum % 2 == 0)
        {
            if (a[i - 1] == 0)
            {
                ans[i - 1] = 0;
            }
            else
            {
                ans[i - 1] = 1;
                ans_num++;
            }
        }
        else
        {
            if (a[i - 1] == 0)
            {
                ans[i - 1] = 1;
                ans_num++;
            }
            else
            {
                ans[i - 1] = 0;
            }
        }
    }

    printf("%lld\n", ans_num);

    for (int i = 0; i < n; ++i)
    {
        if (ans[i] == 1)
        {
            printf("%lld ", i + 1);
        }
    }

    return 0;
}


Measured memory_bytes: 3968
#!/usr/bin/env python
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = 0
ans = 0
for i in range(N):
    if A[i] - c <= 0:
        ans += A[i]
        c = B[i]
    elif A[i] - c <= B[i]:
        ans += A[i]
        c = B[i] - (A[i] - c)
    else:
        ans = ans + c + B[i]
        c = 0
ans += min(A[N], c)
print(ans)


Measured memory_bytes: 18624
N = int(input())
A = list(map(int,input().split()))

kabu = 0
money = 1000

for i in range(1,N):
    if A[i] > A[i-1]:
        kabu,money = divmod(money,A[i-1])
        money += A[i] * kabu
        kabu = 0
    elif A[i] < A[i-1] and kabu > 0:
        money += A[i-1] * kabu
        kabu = 0
print(money) 

Measured memory_bytes: 9200
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

class D_data {
public:
	int h = 0;
	int w = 0;
	D_data(int hh, int ww) {
		h = hh;
		w = ww;
	}
};
static int D_path(char mazeOrg[21][21], int sw, int sh, int W, int H) {

	char maze[21][21];
	for (int i = 0; i < 21; i++) {
		for (int j = 0; j < 21; j++) {
			maze[i][j] = mazeOrg[i][j];
		}
	}

	int path[21][21] = { 0 };

	std::queue<D_data> root;
	root.push(D_data(sh, sw));
	
	int maxDist = 0;
	while (root.size()) {
		D_data nowPos = root.front(); root.pop();
		int nowh = nowPos.h;
		int noww = nowPos.w;
		if (maze[nowh][noww] == '#') {
			continue;
		}
		int nowd = path[nowh][noww];

		maze[nowh][noww] = '#';

		int dh[] = { -1, 0, 1, 0 };
		int dw[] = { 0, 1, 0, -1 };

		for (int i = 0; i < 4; i++) {
			int nexth = nowh + dh[i];
			int nextw = noww + dw[i];

			if ((nextw >= 0) && (nextw < W) && (nexth >= 0) && (nexth < H) && (maze[nexth][nextw] == '.')) {
				path[nexth][nextw] = nowd + 1;
				root.push(D_data(nexth, nextw));
				if (maxDist < (nowd + 1)) {
					maxDist = nowd + 1;
				}
			}
		}
	}

/*
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			printf("%02d ", path[i][j]);
		}
		putchar('\n');
	}
	putchar('\n');
*/
	return maxDist;
}

static void D_task()
{
	int H, W;
	char maze[21][21] = { 0 };
	
	get2int(H, W);
	for (int i = 0; i < H; i++) {
		getstring(maze[i]);
	}

/*
	putchar('\n');
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			printf("%c", maze[i][j]);
		}
		putchar('\n');
	}
	putchar('\n');
*/

	int maxDist = 0;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			maxDist = tp_max(maxDist, D_path(maze, w, h, W, H));
		}
	}
	printf("%d\n", maxDist);
}


Measured memory_bytes: 256
#a

x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

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

temp=[]
for i in range(K):
    if A+i<B+1: temp.append(A+i)

for i in range(K-1,-1,-1):
    if B-i>A-1: temp.append(B-i)

ans=set(temp)
ans=sorted(ans)

for i in ans:
    print(i)

Measured memory_bytes: 3064
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair< ll, ll > P;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll n;
  ll m;
  cin >> n >> m;

  vector< P > p(m);
  map< ll, vector< P > > memo;
  map< ll, bool > visited;
  REP(i, m)
  {
    ll a, b;
    cin >> a >> b;
    memo[a - 1].push_back(P(b - 1, i + 1));
    memo[b - 1].push_back(P(a - 1, i + 1));
  }

  queue< ll > que;
  vector< ll > ans(n, -1);
  que.push(0);
  while (!que.empty())
  {
    ll heya = que.front();
    que.pop();
    auto kouhos = memo[heya];
    for (auto k : kouhos)
    {
      ll k_heya = k.first;
      ll k_i = k.second;
      if (ans[k_heya] == -1)
      {
        ans[k_heya] = heya;
        que.push(k_heya);
      }
    }
  }

  bool enabled = true;
  FOR(i, 1, n - 1)
  {
    if (ans[i] == -1)
    {
      enabled = false;
      break;
    }
  }

  if (!enabled)
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  FOR(i, 1, n - 1)
  {
    cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 27236
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S = sc.next

    def rec(s: String): String = {
      if (s.isEmpty) {
        println("YES")
        sys.exit()
      }
      if (s.startsWith("dream")) {
        if (s.startsWith("dreameraser")) {
          rec(s.replaceFirst("dreameraser", ""))
        } else if (s.startsWith("dreamerase")) {
          rec(s.replaceFirst("dreamerase", ""))
        } else if (s.startsWith("dreamer")) {
          rec(s.replaceFirst("dreamer", ""))
        } else {
          rec(s.replaceFirst("dream", ""))
        }
      } else if (s.startsWith("erase")) {
        if (s.startsWith("eraser")) {
          rec(s.replaceFirst("eraser", ""))
        } else {
          rec(s.replaceFirst("erase", ""))
        }
      } else {
        println("NO")
        sys.exit()
      }
    }

    rec(S)
  }
}


Measured memory_bytes: 115784
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
d = [sum(j*k for j, k in zip(i, b)) for i in a]
print(sum(1 for i in d if i + c > 0))

Measured memory_bytes: 3060
w = input()

words = {}

for c in w:
    if c in words:
        words[c] += 1
    else:
        words[c] = 1

is_beautiful = True

for c in words:
    if words[c] % 2:
        is_beautiful = False
        break

if is_beautiful:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if (b - a <= 0)
        printf("delicious\n");
    else if (b - a <= x)
        printf("safe\n");
    else
        printf("dangerous\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
   int n,i;
   cin>>n;
   ll a[n+1],b[n+1],sum=0,count=0;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       if(a[i]<0)
           count++;
       b[i]=abs(a[i]);
       sum=sum+b[i];
   }
   //cout<<sum<<endl;
   sort(b,b+n);
   if(count%2==0)
       cout<<sum<<endl;
   else
       cout<<sum-(b[0]+b[0])<<endl;
   return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ipair = pair<int, int>;

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

  vector<vector<int>> s(n + 1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    s[a].push_back(b);
    s[b].push_back(a);
  }

  vector<int> cost(n + 1, -1);
  priority_queue<ipair, vector<ipair>, greater<ipair>> que;
  que.push({0, 1});
  cost[1] = 0;
  while (!que.empty()) {
    auto c = que.top().first;
    auto num = que.top().second;
    que.pop();

    for (size_t i = 0; i < s[num].size(); i++) {
      auto next = s[num][i];
      if (cost[next] == -1) {
        que.push({c + 1, next});
        cost[next] = c + 1;
      }
    }
  }
  if (cost[n] == 2) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 16812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 200010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int arr[maxn], tmp[maxn];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i], tmp[i] = arr[i];
  sort(tmp + 1, tmp + 1 + n);
  int l = tmp[n/2];
  int r = tmp[(n/2) + 1];
  for (int i = 1; i <= n; ++i) {
    if (arr[i] >= r) cout << l << endl;
    else cout << r << endl;
  }
}





Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

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

    int maxv = -2000000000; // 十分小さい値を初期値に設定
    int minv = R[0];

    for ( int i = 1; i < n; i++ ) {     // ここで毎回R[i]を読み込めば、配列は不要
        maxv = max(maxv, R[i] - minv);  // 最大値を更新
        minv = min(minv, R[i]);         // ここまでの最小値を保存しておく
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3884
#ABC106 B
#まずnを素因数分解できないとならない
#1.エラトステネスのふるいで200以下の素数を全部列挙する
import math

def allprimes(N):
	primes = []
	for i in range(N):
		primes.append(i+1)
	i = 2
	while i <= math.sqrt(N):
		index = 0
		while True:
			index += 1
			if index == 1:
				continue
			else:
				if index * i <= N:
					#合成数をぜんぶ0に置換
					primes[index*i-1] = 0
				else:
					break
		i += 1
	return sorted(list(set(primes)))[2:]

#2.ある整数kが与えられたときにそれを素因数分解できるようになる

primes = allprimes(200)

def factor(k):
	#素数配列primeが存在することが前提
	nprimes = {}
	for prime in primes:
		nprimes[prime] = 0
	for prime in primes:
		if k < prime:
			break
		else:
			while True:
				if k % prime != 0:
					break
				else:
					k = int(k / prime)
					nprimes[prime] += 1
	return nprimes

#3.1以上N以下の整数を順次素因数分解して約数の個数をチェック
result = 0
for n in range(int(input())):
	if n+1 == 1 or (n+1) % 2 == 0:
		#nが1か偶数だったらスキップ
		continue
	#素数のべき乗の多い順番に列挙
	else:
		nps = sorted(factor(n+1).values())
		if nps[:-3:-1] == [7,0] or nps[:-4:-1] == [3,1,0] or nps[:-5:-1] == [1,1,1,0]:
			result += 1

print(result)

Measured memory_bytes: 3188
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;

typedef pair<long long, string> pls;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e,H, W,Q;
long long A[200000]= {};
long long B[200][205] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S[200];
set <long long>sll;
pl buf;
pls bufls;
vector <long long>vl[100005];
vector <pl>vpl[100005];
vector <pls>vpls;
vector <string> vs;

struct ST
{
	long long hajime;
	long long owari;
	long long zahyou;
	int bangou;

	bool operator<(const ST& another) const
	{
		return hajime < another.hajime;//年齢を比較
	};

};



vector <ST> vst;
ST st[200005];



int main() {

	cin >> H>>W>>K;

	B[0][K] = 1;

	A[0] = 1;
	A[9] = 1;
	A[10] = 1;
	C[0][0] = 1;
	C[0][1] = 0;
	for (int i = 1; i <= 8; i++) {
		C[0][i] = C[0][i - 1] + C[1][i - 1];
		C[1][i] = C[0][i - 1];
		A[i] = C[0][i] + C[1][i];
	}

	for (int i = 0; i < H; i++) {
		for (int j = 1; j <= W; j++) {
			if (j == 1) {
				B[i+1][j] += B[i][j]*max((ll)0,A[W-2]);
				
				B[i + 1][j+1] += B[i][j] * max((ll)0,A[W-3]);
				B[i + 1][j] %= modd;
				B[i + 1][j+1] %= modd;
			}
			else if (j == W) {
				B[i + 1][j] += B[i][j] * max((ll)0, A[W-2]);
				B[i + 1][j - 1] += B[i][j] * max((ll)0, A[W-3]);
				B[i + 1][j] %= modd;
				B[i + 1][j-1] %= modd;
			}
			else {
				B[i + 1][j - 1] += B[i][j] * max((ll)0, A[max(j - 3, 0)] * A[max(W - j-1, (ll)0)]);
				B[i + 1][j] += B[i][j] * max((ll)0, A[max(j-2,0)]*A[max(W-j-1,(ll)0)]);
				B[i + 1][j + 1] += B[i][j] * max((ll)0, A[max(j - 2, 0)] * A[max(W - j - 2, (ll)0)]);
				B[i + 1][j-1] %= modd;
				B[i + 1][j] %= modd;
				B[i + 1][j+1] %= modd;
			}
			
			

		}
	}

	if (W == 1) {
		cout << 1 << endl;
	}
	else {
		cout << B[H][1] % modd << endl;
	}

	return 0;

}


Measured memory_bytes: 6400
#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 n, m, q;
vector<int> a, b, c, d;
int ans;
 
void dfs(vector<int> A) {
  if (A.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
 
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}
 
int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

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

// Common file
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}

/*****************************************************/

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

    int len = s.length() , l = 0 , r = 0;

    for(int i = 0; i < len; ++i)
        if(s[i] != t[i])
            ++l;
    for(int i = len - 1; i >= 0; --i)
        if(s[i] != t[i])
            ++r;

    cout << min(l , r) << "\n";

    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <string>

#define MAX_SIZE (200 * 1000)
char query[MAX_SIZE][2];

bool die(int pos, int N, int Q, std::string text, bool isLeft) {
    for( int i = 0; i < Q; ++i ) {
        if( text[pos] == query[i][0] ) {
            if( query[i][1] == 'L' ) { --pos; }
            else { ++pos; }
            if( pos < 0 ) {
                return isLeft;
            }
            if( pos >= N ) {
                return !isLeft;
            }
        }
    }
    return false;
}

int main() {

    int N, Q;
    std::string text;
    std::cin >> N >> Q >> text;
    for( int i = 0; i < Q; ++i ) {
        std::cin >> query[i][0] >> query[i][1];
    }

    bool visited[MAX_SIZE];
    for( int i = 0; i < N; ++i ) {
        visited[i] = false;
    }

    int Lmin = -1;
    int Lmax = N;
    int Rmin = -1;
    int Rmax = N;

    for( int i = 0; i < 20; ++i ) {
        int Lpos = (Lmin + Lmax) / 2;
        if( die(Lpos, N, Q, text, true) ) { Lmin = Lpos; }
        else { Lmax = Lpos; }
        int Rpos = (Rmin + Rmax) / 2;
        if( die(Rpos, N, Q, text, false) ) { Rmax = Rpos; }
        else { Rmin = Rpos; }
    }

    if( Lmin > Rmax ) { std::cout << 0 << std::endl; }
    else {
        std::cout << (Rmax - Lmin - 1) << std::endl;
    }

    return 0;

}


Measured memory_bytes: 1156
#include<cstdio>
#include<limits.h>
#include<queue>
#include<vector>
struct S{int i,d,c;S(int i,int d,int c):i(i),d(d),c(c){}bool operator<(const S&r)const{return d-r.d?d>r.d:c>r.c;}};
int main()
{
	int n,m,u,v,d,c,i,r,x[10001];
	std::vector<S>e[10001];
	std::priority_queue<S>q;
	while(scanf("%d%d",&n,&m),n)
	{
		for(r=i=0;i<=n;++i)e[i].clear(),x[i]=INT_MAX;
		while(m--)
		{
			scanf("%d%d%d%d",&u,&v,&d,&c);
			e[u].push_back(S(v,d,c));
			e[v].push_back(S(u,d,c));
		}
		q.push(S(1,0,0));
		while(!q.empty())
		{
			S s(q.top());q.pop();
			if(x[s.i]<=s.d)continue;
			x[s.i]=s.d;
			r+=s.c;
			for(i=0;i<e[s.i].size();++i)
				q.push(S(e[s.i][i].i,s.d+e[s.i][i].d,e[s.i][i].c));
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>                                                                                                                
using namespace std;
int main(){
    int n,d,flg=0;
    cin >> n >> d;
    if(n%((d*2)+1) > 0) flg = 1;
    cout << n/((d*2)+1)+flg << '\n'; 
    return 0;
}


Measured memory_bytes: 256
import std.stdio,std.conv,std.string;

void main()
{
  auto num = readln.strip.to!long;
  if (num < 1200) {
    writeln("ABC");
  }
  else if (num < 2800) {
    writeln("ARC");
  }
  else {
    writeln("AGC");
  }
}


Measured memory_bytes: 256
S = input()
alphabet = list("abcdefghijklmnopqrstuvwxyz")

if S == "zyxwvutsrqponmlkjihgfedcba":
     print(-1)
        
elif len(S) < 26:
    print(S + min(set(alphabet) - set(S)))
    
else:
    for i in range(1, 27):
        if list(S)[-i] > list(S)[-(i + 1)]:
            break
    T = sorted(list(S)[-i:])
    #print(T)
    for t in T:
        if t > list(S)[-(i + 1)]:
            break
    print("".join(list(S)[:-(i + 1)]) + t)

Measured memory_bytes: 3064
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

const int maxN = 200005;

bool prime[maxN];
vector<int> all;

void fill(){
    for(int i = 1; i < maxN; i++){
        prime[i] = true;
    }
    for(int p = 2; p * p <= maxN; p++){
        if(prime[p] == true){
            for(int i = p * p; i <= maxN; i += p){
                prime[i] = false;
            }
        }
    }
    for(int i = 2; i < maxN; i++){
        if(prime[i]) all.pb(i);
    }
    return;
}

void solve(){
    ll n;
    cin >> n;
    fill();
    auto it = lower_bound(all.begin(), all.end(), n) - all.begin();
    cout << all[it] << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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 rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1
typedef pair<ll, ll> P;

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

int main() {
    ll H, A, ans = 0;

    cin >> H >> A;
    ans = H / A;
    if(H - (ans * A) > 0) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp;
    auto DP = new long[][](N.length, 2);
    foreach (ref dp; DP) dp[] = -1;
    long solve(int i, bool k) {
        if (i == N.length) return k == 0 ? 0 : long.max/3;
        if (DP[i][k] == -1) {
            long n = N[i]-'0';
            if (k) {
                DP[i][k] = min(solve(i+1, 0) + 10 - n, solve(i+1, 1) + 10 - n - 1);
            } else {
                DP[i][k] = min(solve(i+1, 0) + n, solve(i+1, 1) + n + 1);
            }
        }
        return DP[i][k];
    }
    writeln(min(solve(0, 0), solve(0, 1) + 1));
}

Measured memory_bytes: 179496
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W, N = MAP()
sr, sc = MAP()
S = input()
T = input()

l, r, u, d = 1, W, 1, H

for s, t in zip(S[::-1], T[::-1]):
	if t == "L":
		r = min(r+1, W)
	elif t == "R":
		l = max(l-1, 1)
	elif t == "U":
		d = min(d+1, H)
	elif t == "D":
		u = max(u-1, 1)

	if s == "L":
		l += 1
	elif s == "R":
		r -= 1
	elif s == "U":
		u += 1
	elif s == "D":
		d -= 1

	if l > r or u > d:
		print("NO")
		exit()

if l <= sc <= r and u <= sr <= d:
	print("YES")
else:
	print("NO")


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

using namespace std;

typedef long long ll;
ll n, m;

int main() {
    scanf("%lld%lld",&n,&m);
    if (n>m) swap(n,m);
    if (m==1) printf("1\n");
    else if (n==1) printf("%lld",m-2);
    else printf("%lld\n",(n-2)*(m-2));
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void input(int*,int*,int*);
int ans(int,int,int);
int main(void){
    int a,b,k;
    int anse;
    input(&a,&b,&k);
    anse=ans(a,b,k);
    printf("%d\n",anse);
    return 0;
}
void input(int* a,int* b,int* k){
    scanf("%d %d %d",a,b,k);
}
int ans(int p,int q,int r){
    int a=0;
    int i=p;
    int counter=0;
    while(counter<r){
        if(p%i==0 && q%i==0){
            a=i;
            counter++;
        }
        i--;
    }

    return a;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> A(N);
	ll sit=0;//0:未決定 1:上昇 2:下降

	rep(i,N) cin>>A[i];
	ll mem=A[0],ans=0;
	rep1(i,N-1){
		if(sit==0){
			if(A[i]<mem){
				mem=A[i];
				sit=2;
			}
			else if(A[i]>mem){
				mem=A[i];
				sit=1;
			}
		}
		else if(sit==1){
			if(A[i]>=mem) mem=A[i];
			else{
				ans++;
				mem=A[i];
				sit=0;
			}
		}
		else{
			if(A[i]<=mem) mem=A[i];
			else{
				ans++;
				mem=A[i];
				sit=0;
			}
		}
	}
	cout<<ans+1;
}
	

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    Int res = 0;
    for (Int i = 1; i <= n; i++) {
        for (Int j = 1; j <= n; j++) {
            if (i * j > n) break;
            if (i > 0 and j > 0 and n - i * j > 0) {
                res++;
            }
        }
    }
    print(res);
}

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


Measured memory_bytes: 3612
#include<stdio.h>



int main()
{
    char a[10000],c;
    int cont=0,j=0;
    while(scanf("%c",&a[j])!=EOF){
        j++;
    }
    a[j]=0;
    for(int i=0;i<26;i++){
        j=0;
        cont =0;
        while(a[j]!=0){
            if('a'+i==a[j]||'A'+i==a[j]){
                cont++;
            }
            j++;
        }
    printf("%c : %d\n",'a'+i,cont);
    }
}


Measured memory_bytes: 2088
/*input
10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820
*/

#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;

vector<long long> factorial(MAXN, 1);

inline long long add(long long x, long long y) {
	return ((x % MOD) + (y % MOD))% MOD;
}

inline long long subtract(long long x, long long y) {
	x = x % MOD;
	y = y % MOD;

	if(x >= y) return x - y;
	else return x - y + MOD;
}

inline long long multiply(long long x, long long y) {
	return ((x % MOD) * (y % MOD)) % MOD;
}

inline long long power(long long x, long long y) {
	long long res = 1;
	x = x % MOD;

	while(y > 0) {
		if(y & 1) {
			res = multiply(res, x);
		}
		y = y / 2;
		x = multiply(x, x);
	}

	return res;
}

inline long long divide(long long x, long long y) {
	return multiply(x, power(y, MOD-2));
}

inline long long C(long long n, long long r) {
	if(n < r or r < 0 or n < 0) return 0;
	return divide(factorial[n], multiply(factorial[r], factorial[n-r]));
}

void precompute() {
	for(int i = 1; i < MAXN; i++) {
		factorial[i] = multiply(factorial[i-1], i);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<long long> a(n);
	vector<long long> cnt(61);

	for(int i = 0; i < n; i++) {
		cin >> a[i];
		for(long long j = 0; j <= 60; j++) {
			if(a[i] & (1ll << j)) cnt[j]++;
		}
	}

	long long ans = 0;

	for(long long i = 0; i <= 60; i++) {
		long long temp = multiply(cnt[i], n - cnt[i]);
		temp = multiply(power(2, i), temp);
		ans = add(ans, temp);
		//ans += (1ll << i) * (cnt[i] * (n - cnt[i]));
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 10368
n, q = map(int, input().split())
s = input()
start = [0]
count = 0
for i in range(len(s)-1):
    if s[i]+s[i+1] == "AC":
        count += 1

    start.append(count)


for _ in range(q):
    l,r = map(int, input().split())
    print(start[r-1]-start[l-1])


Measured memory_bytes: 6100
h,w = map(int,input().split())
m = [list(map((lambda x: 0 if x == '#' else 1),list(input()))) for i in range(h)]
ret = sum(list(map(sum,m)))

q = [[0,0,0]]
m[0][0] = 0
while len(q)!=0:
    qtop = q.pop(0)
    x = qtop[0]
    y = qtop[1]
    d = qtop[2]
    if x == h-1 and y == w-1:
        print(ret-d-1)
        break
    if 0 < x and m[x-1][y] == 1:
        m[x-1][y] = 0
        q.append([x-1,y,d+1])
    if h-1 > x and m[x+1][y] == 1:
        m[x+1][y] = 0
        q.append([x+1,y,d+1])
    if 0 < y and m[x][y-1] == 1:
        m[x][y-1] = 0
        q.append([x,y-1,d+1])
    if w-1 > y and m[x][y+1] == 1:
        m[x][y+1] = 0
        q.append([x,y+1,d+1])
else:
    print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<pair<ll, ll>> lrs{}, pqs{};
    for (auto &&i: irange(0LL, M)) {
        ll l, r;
        cin >> l >> r;
        l--; r--;
        lrs.emplace_back(make_pair(l, r));
    }
    for (auto &&i: irange(0LL, Q)) {
        ll p, q;;
        cin >> p >> q;
        p--; q--;
        pqs.emplace_back(make_pair(p, q));
    }
    vector<vector<ll>> from_to(N, vector<ll>(N, 0));
    for (auto && i: irange(0LL, M)){
        ll from, to;
        tie(from, to) = lrs.at(i);
        from_to.at(from).at(to)++;
    }
//    from_toに対して範囲クエリが飛んでくる
//    from_toのこの範囲の合計は？みたいなクエリ
//    1次元であれば，累積和をとって，先っちょマイナスお尻でいける
//    2次元であれば，累積和の特殊系を作って，解く
//    ポイントは累積和の上下のおしりを0で埋めること
//    つまり，acc[i+1] = acc[i] + raw[i]というふうには書けないということを自覚すること
//    （acc[i+1, j]+=acc[i, j]; acc[i, j+1]+=acc[i, j]と書く）

//    初期化
    vector<vector<ll>> acc(N+1, vector<ll>(N+1, 0));
    for (auto && i: irange(1LL, N+1)){
        for (auto && j: irange(1LL, N+1)){
            acc.at(i).at(j) = from_to.at(i-1).at(j-1);
        }
    }
//    行方向の和
    for (auto && i: irange(1LL, N+1)){
        for (auto && j: irange(0LL, N+1)){
            acc.at(i).at(j) += acc.at(i-1).at(j);
        }
    }
//    列方向の和
    for (auto && i: irange(0LL, N+1)){
        for (auto && j: irange(1LL, N+1)){
            acc.at(i).at(j) += acc.at(i).at(j-1);
        }
    }
//    範囲クエリに答える
//    添字が1ずつずれている(つまり，pqの世界でのiはaccの世界でのi+1)
    for (auto && i: irange(0LL, Q)){
        ll p, q;
        tie(p, q) = pqs.at(i);
        cout << acc.at(q+1).at(q+1) - acc.at(q+1).at(p) - acc.at(p).at(q+1) + acc.at(p).at(p) << endl;
    }

    return 0;
}


Measured memory_bytes: 10476
#include <stdio.h>

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);

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

    sort(a.begin(), a.end(), greater<int>());

    int sum_a = 0;
    int sum_b = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            sum_a += a[i];
        } else {
            sum_b += a[i];
        }
    }
    cout << sum_a - sum_b << endl;

    return 0;
}


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

int main(void){
    int n, x;
    cin >> n >> x;

    int l[n];
    rep(i, n){
        cin >> l[i];
    }

    int count = 0;
    int ans = 0;
    rep(i, n + 1){
        if(ans > x)
            break;
        ans += l[i];
        count++;
    }

    cout << count << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int main()
{
    ll pi = 314159;
    ll R;
    cin >> R;
    ll ans = R*pi*2;
    double a = (double)(ans) / 100000.0;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3744
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	int x;

	cin >> x;

	if (x == 7 || x  == 5 || x  == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d = new int[N];
        for(int n=0; n<N; n++) d[n]=sc.nextInt();

        long hp = 0;
        for(int m=0; m<N; m++) for(int n=m+1; n<N; n++) hp += d[m]*d[n];
        System.out.println(hp);
    }
}


Measured memory_bytes: 22996
S = input()
T = input()

lt, ls = len(T), len(S)

def diff(s1, s2):
    d = len(s1)

    d -= len([i for i,j in zip(s1, s2) if i == j])
    return d

dlen = min([diff(T, S[i:i+lt]) for i in range(ls) if i + lt <= ls])

print(dlen)


Measured memory_bytes: 9000
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll N,T;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
	ll sum = 0;
	cin>>N;
	ll a[N];
    ll b[N];
	for(ll i = 0 ; i<N ; i++){
		cin>>a[i];
		sum = sum^a[i];
	}

	for(ll i = 0 ; i<N ; i++)
		b[i] = sum^a[i];


	for(ll i = 0 ; i<N ; i++)
		cout<<b[i]<<' ';


cout<<'\n';
}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
  solve();

	return 0;
}

Measured memory_bytes: 6636
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int ans[n];
    for(int i=0; i<n; i++){
        ans[i]=0;
    }
    for(int i=0; i<n-1; i++){
        scanf("%d",&a[i]);
        ans[a[i]-1]++;
    }
    for(int i=0; i<n; i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

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

const int INF=1e8L;

vector<int> dp,pre;

void rec(int i, const vector<int>& not_taken, int score_so_far, int mask, int group) {
    if(i == (int) not_taken.size()) {
        dp[mask] = max(dp[mask], score_so_far + pre[group]);
        return;
    }
    rec(i + 1, not_taken, score_so_far, mask, group);
    rec(i + 1, not_taken, score_so_far, mask ^ (1 << not_taken[i]),
        group ^ (1 << not_taken[i]));
}

signed main(){
		
	int n;
	cin>>n;
	vector<vector<int>> in(n,vector<int>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>in[i][j];
		}
	}
	
	dp.resize(1<<n,-INF);
	pre.resize(1<<n);
	// dp[mask] - best total score if we grouped rabbits from 'mask' already
	for(int mask=0;mask<(1<<n);mask++){
		for(int j=0;j<n;j++){
			for(int k=j+1;k<n;k++){
				if((mask&(1<<k)) and (mask&(1<<j)))
					pre[mask]+=in[j][k];
			}
		}
	}
	// O(2^n * n + 3^n)
	dp[0]=0;
	for(int mask = 0; mask < (1 << n); ++mask) {
        vector<int> not_taken;
        for(int i = 0; i < n; ++i) {
            if(!(mask & (1 << i))) {
                not_taken.push_back(i);
            }
        }
        rec(0, not_taken, dp[mask], mask, 0);
    }
    
    printf("%lld\n",dp[(1<<n)-1]);
    
    return 0;
}	


Measured memory_bytes: 1280
#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>;
const int INF = 1001001001;

int main() {
    ll N; cin >> N;
    ll A[200005];
    rep(i, N) cin >> A[i];

    map<ll, ll> mp;
    rep(i, N) mp[A[i]]++;

    ll ans = 0;
    map<ll, ll> ans1, ans2;
    // ans N個のボールでやったときの答え
    // ans1 ｋ番目がiではなかったとき、iのボールからから2個選ぶ方法の数
    // ans2 ｋ番目がiだった　　　とき、iのボールからから2個選ぶ方法の数

    for (auto k : mp) {
        if (k.second < 2) {
            ans1[k.first] = 0;
            ans2[k.first] = 0;
        } else if (k.second == 2) {
            ans += 1;
            ans1[k.first] = 1;
            ans2[k.first] = 0;
        } else {
            ans += k.second * (k.second-1) / 2;
            ans1[k.first] = k.second * (k.second-1) / 2;
            ans2[k.first] = (k.second-1) * (k.second-2) / 2;
        }
    }

    rep(k, N) {
        cout << ans - ans1[A[k]] + ans2[A[k]] << endl;
    }

    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli n;
	cin>>n;

	lli now = -INF;

	REP(i,0,n){
		lli num;
		cin>>num;
		if(now-1 > num){
			cout<<"No"<<endl;
			return 0;
		}
		now = max(now,num);
	}

	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n;
cin >> n;
vl a(n);
rep(i,n) cin >> a[i];

ll ans = 0;
rep(i,n) {
    if(a[i] % 2 == 0) {
        ans += a[i]/2;
    } else {
        ans += a[i]/2;
        if(i+1 < n && a[i+1] >= 1) {
            ans++;
            a[i+1]--;
        }
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1024