akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n; cin >> n;
  vector<int> l(n);
  REP(i, n) cin >> l[i];
  DESC(l);
  int sum = 0;
  FOR(i, 1, n) sum += l[i];
  if (l[0] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
line = input()
rain_day = 0
k = 0
for wether in line:
  #当日雨
  if wether == "R":
    rain_day += 1
  #当日晴れ、前日は雨
  elif rain_day != 0:
    k = rain_day
    rain_day = 0
  #当日晴れ、前日も晴れ
  else:
    pass
if k > rain_day:
  print(k)
else:
  print(rain_day)

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

int x[51];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a;
        int b;
        cin >> a >> b;
        a--;
        b--;
        x[a]++;
        x[b]++;
    }
    rep(i, n) {
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
An = list(map(int, input().split()))
ans = 1
flag = True

if 0 in An:
    print(0)
    exit()

for i in range(N):
    ans = ans * An[i]
    if ans > 10**18:
        flag = False
        break
    else:
        continue
    
if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21780
#include <iostream>

using namespace std;

int main()
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x >= r && x <= W - r && y >= r && y <= H - r){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
  
	
}

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int maisu=sc.nextInt();
		int kin=sc.nextInt();
		int h[]=new int[3];
		for(int i=0;i<3;i++) {
			h[i]=-1;
		}
		for(int i=0;i<=maisu;i++) {
			for(int j=0;j<=maisu;j++) {
				if(10000*i+j*5000+1000*(maisu-i-j)==kin&&i+j<=maisu) {
					h[0]=i;
					h[1]=j;
					h[2]=maisu-i-j;
					i=maisu+1;
					j=maisu+1;
				}
			}
		}
		System.out.print(h[0]+" "+h[1]+" "+h[2]);


	}

}

Measured memory_bytes: 22996
#include<stdio.h>
int main(){
  int n,q,i,c=0,j;
  
  scanf("%d",&n);
  
  int S[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);
  
  return 0;

}



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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
const ll INF = 10010010010010010;

struct edge {ll from, to, cost;};

edge es[5000];
ll d[2500];
int V,E;

int main() {
    ll p; cin >> V >> E >> p;
    ll a,b,c;
    rep(i,E) {
        cin >> a >> b >> c;
        a--; b--; c -= p;
        es[i].from = a;
        es[i].to = b;
        es[i].cost = -c;
    }
    rep(i,V) d[i] = INF;
    d[0] = 0;
    rep(i,V) {
        rep(j,E) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
        //printf("%d回目\n", i+1);
        //rep(j,V) printf("%lld ", d[j]);
        //printf("\n");
    }
    ll ans = d[V-1];
    rep(i,V) {
        rep(j,E) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = -INF;
            }
        }
        //printf("%d回目\n", i+1);
        //rep(j,V) printf("%lld ", d[j]);
        //printf("\n");
        if (ans > d[V-1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0ll, -ans) << endl;

    return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

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

    if (a + b >= 24) {
        cout << a + b - 24 << endl;
    } else {
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	fmt.Println(max(0, min(b, d)-max(a, c)))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
N = int(input())

ans = 10**5
for a in range(0, N+1):
	cnt = 0
	t = 1
	for i in range(7):
		cnt += (a//t)%6
		t *= 6
	t = 1
	for i in range(6):
		cnt += ((N-a)//t)%9
		t *= 9
	ans = min(ans, cnt)
print(ans)

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

using namespace std;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void solve()
{
long long int N,W;
cin>>N>>W;
long long int w[N],val[N];
for(int i=0;i<N;i++)
{

    cin>>w[i]>>val[i];
}
vector<vector<long long int>>dp(N+1,vector<long long int>(W+1,0));
//for(int i=0;i<=N;i++)
//{
 //   dp[i][0]=1;
//}
for(int i=1;i<=N;i++)
{
    for(int j=1;j<=W;j++)
    {
        if(w[i-1]<=j)
          dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+val[i-1]);
        else
            dp[i][j]=dp[i-1][j];
    }
}

/*for(int i=0;i<=N;i++)
{
    for(int j=0;j<=W;j++)
  cout<<dp[i][j]<<" ";
    cout<<"\n";
}*/
cout<<dp[N][W];
}


int main()
{
ios_base::sync_with_stdio(0), cin.tie(0);
int test=1;
//cin>>test;

while(test--)
{
     solve();
}
    return 0;
}


Measured memory_bytes: 82992
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  int res = 0;
  for (int i = 0; i < S.size() - 1; ++i) {
    if (S[i + 1] != S[i]) {
      ++res;
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3292
A=[[0 for i in range(3)]for i in range(3)]
for i in range(3):
  A[i]=list(map(int,input().split()))
N=int(input())
b=[]
for i in range(N):
  b+=[int(input())]
tf=[[0 for i in range(3)] for i in range(3)]
for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      tf[i][j]=1
an=0
for i in range(3):
  if sum(tf[i])==3 or tf[0][i]+tf[1][i]+tf[2][i]==3:
    an=1
if tf[0][0]+tf[1][1]+tf[2][2]==3 or tf[0][2]+tf[1][1]+tf[2][0]==3:
  an=1
if an==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
ll n;
cin>>n;
map<ll,ll>mp;
ll sum = 0;
for (ll i = 0; i < n; i++) {
    ll t;
    cin>>t;
    mp[t]++;
    sum += t;
}
ll q;
cin >> q;

for (ll i = 0; i < q; i++) {
    ll b,c;
    cin >> b >> c;
    mp[c]+=mp[b];
    sum -= mp[b] * b;
    sum += (mp[b]) * c;
    mp[b] = 0;
    cout << sum << endl;
}

}

Measured memory_bytes: 9468
//16, 06, 2018, 09:05:20 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

typedef unsigned long long ull;

int pot(int b, int d){
    int p = 1LL;

    while(d--){
        p *= b;
    }

    return p;
}

int main(){
    int d, n;

    cin >> d >> n;
    
    int ini = pot(100, d);
    int tmp = 0;
 
    if(n == 100){
        cout << ini * n + ini << endl;
    }else{
        cout << ini * n << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
sub f{my$c=$c[$_];$c[$_]?$e|=$c[$_]==$c:f($g+=$-=$c[$_]=-$c)for keys%$_}($N,$M)=glob<>;/ /,${$`}{$'+0}=${$'+0}{$`}=1for<>;f$_=$g=$c[1]=1;print$e?$N*~-$N/2-$M:$g*($N-$g)-$M

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

int main(void) {
 
  int n,rslt;
  scanf("%d",&n);
  int listA[n+1],listB[n+1],listC[n];
  for(int i=1;i<=n;i++)scanf("%d",&listA[i]);
  for(int i=1;i<=n;i++)scanf("%d",&listB[i]);
  for(int i=1;i< n;i++)scanf("%d",&listC[i]);
  
  rslt = listB[listA[1]];
  for(int i=2;i<=n;i++){
    rslt += listB[listA[i]];
    if(listA[i-1]+1 == listA[i]){
      rslt += listC[listA[i-1]];
    }
  }
  printf("%d\n",rslt);

  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
typedef long long ll;
typedef double db;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
//start!
const int MAX_N=1e3+5;
int main()
{
	int n=qi(),mx=0,cnt=0;
	repi(i,1,n){
		int a=qi(),b=qi();
		if(a==b) cnt++;
		else gmx(mx,cnt),cnt=0;
	}
	if(max(mx,cnt)>=3) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yymmOrMmyy
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            char[] C = S.ToCharArray();
            char[] charF = new char[2];
            char[] charB = new char[2];
            int count = 0;
            bool flag = false;

            for(int i = 0; i < 2; i++)
            {
                charF[i] = C[i];
                charB[i] = C[i + 2];
            }

            int intF = int.Parse(new string(charF));
            int intB = int.Parse(new string(charB));

            if (intF >= 0 && intF <= 99)
            {
                count++;
            }
            if(intF >= 1 && intF <= 12)
            {
                count++;
                flag = true;
            }
            if(intB >= 0 && intB <= 99)
            {
                count--;
            }
            if(intB >= 1 && intB <= 12)
            {
                count--;
                flag = true;
            }
            if (flag)
            {
                switch (count)
                {
                    case 1:
                        Console.WriteLine("MMYY");
                        break;
                    case 0:
                        Console.WriteLine("AMBIGUOUS");
                        break;
                    case -1:
                        Console.WriteLine("YYMM");
                        break;
                    default:
                        break;
                }
            }
            else {
                Console.WriteLine("NA");
            }
        }
    }
}


Measured memory_bytes: 13140
S = input()
n = len(S)
dp = [[0] * 2 for _ in range(n+1)]

dp[0][0] = 0
dp[0][1] = 1
for i in range(n):
    dp[i+1][0] = min(int(S[i]) + dp[i][0], 10 - int(S[i]) + dp[i][1])
    dp[i+1][1] = min(int(S[i]) + 1 + dp[i][0], 10 - int(S[i]) - 1 + dp[i][1])    

print(dp[n][0])

Measured memory_bytes: 140744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int h,w;cin>>h>>w;
  vector<string> s(h);
  rep(i,h)cin>>s[i];
  rep(i,w+2)cout<<'#';
  cout<<endl;
  rep(i,h){
    cout<<'#'<<s[i]<<'#';
  cout<<endl;
          }
   rep(i,w+2)cout<<'#';
  cout<<endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

vector<ll> num_list;

ll dp[200005];

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

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  string s;
  cin >> s;

  for (auto a : s) {
    num_list.push_back(a - '0');
  }

  ll current_num = 0;
  for (ll i = num_list.size() - 1; i >= 0; i--) {
    ll n = num_list[i];
    ll dg = s.length() - i;

    ll num = fastpow(10, dg - 1, 2019) * n;

    ll total = current_num + num;

    ll am = total % 2019;

    current_num = (current_num + num) % 2019;
    // cout << n << ":" << num << ":" << am << endl;

    ll j = num_list.size() - i;
    dp[j] = am;
  }

  // cout << "--------" << endl;

  map<ll, ll> m;

  ll ans = 0;
  for (ll i = 0; i < num_list.size() + 1; i++) {
    ll am = dp[i];

    // cout << "am:" << am << endl;
    ans += m[am];

    m[am] += 1;
  }
  cout << ans << endl;
}

// 1817181712114
// 18171
//     18171
//         12114
//
//
//

//
//
//
// 2019
//
// 2019 = 673 * 3
//
// 12
//
// 2019
// 4038
// 6057
// 8076
// 10095
// 12114
// 14133
// 16152
// 18171
// 20190
// 22209
// 24228
// 26247
// 28266
// 30285
// 32304
// 34323
// 36342
// 38361
// 40380
// 42399
// 44418
// 46437
// 48456
// 50475
// 52494
// 54513
// 56532
// 58551
// 60570
// 62589
// 64608
// 66627
// 68646
// 70665
// 72684
// 74703
// 76722
// 78741
// 80760
// 82779
// 84798
// 86817
// 88836
// 90855
// 92874
// 94893
// 96912
// 98931


Measured memory_bytes: 6588
import java.util.Scanner;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int p=sc.nextInt();
		String c=sc.next();
		char a[]=c.toCharArray();
		int b=0;
		for(int i=0;i<p/2;i++) {
				if(a[i]!=a[i+p/2])
					b++;
		}
		if(p%2==0){
			if(b==0) {
			System.out.print("Yes");	
			}else {
			System.out.print("No");
			}
		}else
			System.out.print("No");
			
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
 
int main() {
  string s;
  cin >> s;
  string res="";
  for(int i=0;i<s.size();i++){
    int com = s.at(i)-'0';
    if(com == 0 || com == 1){
      res += s.at(i);
    }else if(res.size()>0){
      res.pop_back();
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

    ll ans = 0,D,N;
    cin >> N >> D;
    FOR(i,0,N){
      ll a,b;
      cin >> a >> b;
      if(a*a+b*b <= D*D){
        ans++;
      }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3572
def check(n):
    global x

    check_digit = x[x[x[x[0][n[0]]][n[1]]][n[2]]][n[3]]
    if x[check_digit][n[4]] == 0:
        return True
    else:
        return False

x = [list(map(int, input().split())) for _ in range(10)]

ans = 0

for i in range(10000):
    s = str(i).zfill(4)
    n = list(map(int, s))

    check_digit = x[x[x[x[0][n[0]]][n[1]]][n[2]]][n[3]]
    n.append(check_digit)

    is_break = False
    
    for j in range(5):
        for k in range(10):
            if n[j] == k:
                continue
            temp = n[:]
            temp[j] = k
            if check(temp):
                ans += 1
                is_break = True
                break
        if is_break:
            break

    if is_break:
        continue
        
    for j in range(4):
        if n[j] == n[j + 1]:
            continue
        temp = n[:]
        temp[j], temp[j + 1] = temp[j + 1], temp[j]
        if check(temp):
            ans += 1
            break
print(ans)



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

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

    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> A(N);
    for (int i=0; i < N; ++i) cin >> A[i];

    int ans = INT_MAX;
    for (int i=0; i<(int)A.size(); ++i) {
        int x = A[i];
        vector<int> v, cand;
        for (int j=0; j<N; ++j) {
            if (A[j] < x) {
                sort(v.begin(), v.end());
                for (int k=0; k+K-1<(int)v.size(); ++k) {
                    cand.push_back(v[k]);
                }
                v.clear();
            } else {
                v.push_back(A[j]);
            }
        }
        if ( ! v.empty()) {
            sort(v.begin(), v.end());
            for (int k=0; k+K-1<(int)v.size(); ++k) {
                cand.push_back(v[k]);
            }
        }
        
        if (cand.size() < Q) continue;
        
        sort(cand.begin(), cand.end());
        ans = min(ans, cand[Q-1] - x);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

//------------------------------------------------
int main(){
  double n,d,r,rr;
  double x[10][10];
  int ans=0;
  rr=0;
  cin>>n>>d;
rep(k,0,n){
  rep(i,0,d) cin>>x[k][i];
}
rep(k,0,n){
  rep(j,1,n-k){
   rep(i,0,d){
     r=x[k][i]-x[k+j][i];
     rr+=r*r;
   }
     rr=sqrt(rr);
     int h=rr;
     if(rr-h==0) ans+=1;
     rr=0;
   }
   }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
#include <iomanip>

using namespace std;
int MOD = 998244353;
const int mxN = 2e5 + 9;

vector<int> ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N,tmp;
	cin >> N;
	for(int i=2; i <= N; i++){
        cin >> tmp;
        ar[tmp].push_back(i);
	}
	for(int i=1; i <= N; i++){
        cout << ar[i].size() << "\n";
	}


}


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

int main()
{

    int x, a, b;

    scanf("%d %d %d", &x, &a, &b );

    if ( abs(a - x) < abs(b - x) ) {
        printf("A");
    } else {
        printf("B");
    }
    putchar('\n');

    return 0;
}


Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N = int(input())
s = [0]*N
for i in range(N):
    s[i] = int(input())
    
if sum(s)%10!=0:
    print(sum(s))
else:
    l = [x for x in s if x%10!=0]
    tmp = min(l) if len(l) else sum(s)
    print(sum(s)-tmp)

Measured memory_bytes: 66204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    ll N,M,s=0,ans=0;
    cin >> N;
    ans = N*(1+N)/2 - (N/3)*(6+ (N/3-1)*3)/2 - (N/5)*(10+ (N/5-1)*5)/2 + (N/15)*(30+ (N/15-1)*15)/2; 
    cout << ans << endl;
}

Measured memory_bytes: 3524
#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);
    ll n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    ll le[n],ri[n];
    memset(le,-1,sizeof(le));
    memset(ri,-1,sizeof(ri));
    ll index=1;
    for(int i=0;i<n;i++){
    	if(s[i]=='o'){
    		le[i]=index;
    		index++;
    		i+=c;
    	}
    }
    index=k;
    for(int i=n-1;i>=0;i--){
    	if(s[i]=='o'){
    		ri[i]=index;
    		index--;
    		i-=c;
    	}
    }
    vector<int> v;
    for(int i=0;i<n;i++){
    	if(le[i]==ri[i]&&le[i]!=-1)v.pb(i+1);
    }
    for(auto& i:v)cout << i<< endl;
    return 0;
}


Measured memory_bytes: 5900
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int a,ans=0,b,c,d;
    cin>>a>>b>>c>>d;
    for(int i=1;i<=a;i++)
    {
        if(i<=b)
        ans+=c;
        else
        ans+=d;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    if(s.size() > t.size()){
        cout << "GREATER";
    }else if(s.size() < t.size()){
        cout << "LESS";
    }else{
        if(s>t){
            cout << "GREATER";
        }else if(s<t){
            cout << "LESS";
        }else{
            cout << "EQUAL";
        }
    }
}



Measured memory_bytes: 256
//  main.cpp
//  CppTest

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

int main(int argc, const char * argv[]) {
   
    /////////////////////
    // Write code below /
    /////////////////////
    int numberOfCities, numberOfRoads;
    cin >> numberOfCities >> numberOfRoads;
    vector<int> numberOfRoadsInCityN(numberOfCities);
    for (int road_i = 0; road_i < numberOfRoads; road_i++) {
        int startCity, endCity;
        cin >> startCity >> endCity;
        numberOfRoadsInCityN.at(startCity-1)++;
        numberOfRoadsInCityN.at(endCity-1)++;
    }
    
    for (int city_i = 0; city_i < numberOfRoadsInCityN.size(); city_i++) {
        cout << numberOfRoadsInCityN.at(city_i) << endl;
    }
    
    return 0;
}


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

int judge(int num){
	int count = 0;
	int n = 5;
	while(n <= num){
		count += num / n;
		n = n * 5;
	}
	return count;
}

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		cout << judge(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n;
int prime[60000];
int sosuu[10000];

void eratisthenes(){
  REP(i,60000) prime[i] = 1;
  prime[0] = 0;
  prime[1] = 0;
  int num = 0;
  for(int i=1;i<=55555;i++){
    if(prime[i]==1){
      if(i%5==1){
        sosuu[num] = i;
        num++;
      }
      for(int j = i+i;j<=55555;j+=i){
        prime[j] = 0;
      }
    }
  }
}

int main(){
  cin >> n;
  eratisthenes();
  REP(i,n){
    cout << sosuu[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
X = int(input())
if X < 100:
    print(0)
    exit()
A = X % 100
cnt = 0
cnt += (A // 5)
A %= 5
cnt += (A // 4)
A %= 4
cnt += (A // 3)
A %= 3
cnt += (A // 2)
A %= 2
cnt += (A // 1) 


if cnt*100 <= X:
    print(1)
else:
    print(0)



Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<algorithm>
#include <cstdint>
using namespace std;
  
int main(){
    int n,l,r;
    cin>>n;
    int a=0;
    for(int i=0;i<n;i++){
        cin>>l>>r;
        a=r-l+1+a;
    }
    cout<<a<<endl;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (long long)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll fib(ll n){
    vll a(n+1);
    a[0] = 1;
    a[1]  = 1;

    REP(i,2,n+1){
        a[i] = a[i-1] + a[i-2];
        a[i] %= mod;
    }

    return a[n-1];
}

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> s;
    rep(i,n){
        ll a;
        cin >> a;
        s[a]++;
    }

    ll ans = 0;
    ll m;
    cin >> m;
    rep(i,m){
        ll b;
        cin >> b;
        if(s[b] > 0)ans++;
    }

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


Measured memory_bytes: 12380
while True:
    a, op, b = input().split()
    if op == '?':
        break
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))


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

int main() {
  int n, a;
  a = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      a += vec.at(i);
    }
    else{
      a -= vec.at(i);
    }
  }
  cout << a << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

N, M, X = map(int, input().split())

li = [f'{i:012b}' for i in range(2**N)]
C = []
A = []
for i in range(N):
    B = list(map(int, input().split()))
    C.append(B[0])
    A.append(B[1:])

d = []
for l in li:
    b = l[::-1][:N]
    rikai = [0]*M
    pri = [0]*N
    for i in range(len(b)):
        if b[i] == '1':
            for j in range(M):
                rikai[j] += A[i][j]
            pri[i] += C[i]
    d.append((sum(pri), rikai))

ans = 10**100
for s in d:
    f = True
    for r in s[1]:
        if r < X:
            f = False
            break
    if f:
        ans = min(ans, int(s[0]))
if ans == 10**100:print(-1)
else: print(ans)


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

typedef long long ll;

template<typename T, typename E> class SegmentTree {
public:
  typedef function<T (T, T)> Operator;
  typedef function<T (T, E)> Apply;

  vector<T> data;
  ll n;        // size of elements (2^x alignment)
  T e;         // identity of monoid
  Operator op; // binary operator of monoid
  Apply apply; // apply effect to monoid

  // construct with size of elements
  SegmentTree(ll _n, T _e, Operator _op, Apply _apply): e(_e), op(_op), apply(_apply) {
    for(n = 1; n < _n; n *= 2);
    data.resize(n * 2 - 1, e);
  }

  // construct with initial values
  SegmentTree(const vector<T> &vec, T _e, Operator _op, Apply _apply): e(_e), op(_op), apply(_apply) {
    for(n = 1; n < vec.size(); n *= 2);
    data.resize(n * 2 - 1, e);
    FOR(i, 0, vec.size()) data[i + n - 1] = vec[i];
    for(ll i = n - 2; i >= 0; i--) data[i] = op(data[i * 2 + 1], data[i * 2 + 2]);
  }

  // query for [a, b)
  T query(ll a, ll b) { return query(a, b, 0, 0, n); }
  T query(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  // update value at k
  void update(ll k, E x) {
    k += n - 1;
    data[k] = apply(data[k], x);
    while(k > 0) {
      k = (k - 1) / 2;
      data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }
};

int main(){
  /* input */
  int N;
  cin >> N;
  auto add_op = [](ll a, ll b) { return a + b; };
  auto xor_op = [](ll a, ll b) { return a ^ b; };
  auto apply = [](ll a, ll x) { return x; };
  SegmentTree<ll, ll> add_segtree(N, 0, add_op, apply);
  SegmentTree<ll, ll> xor_segtree(N, 0, xor_op, apply);
  FOR(i, 0, N){
    ll A;
    cin >> A;
    add_segtree.update(i, A);
    xor_segtree.update(i, A);
  }

  ll res = 0;
  FOR(left, 0, N){ // 左端を固定
    int ok = left;
    int ng = N + 1;

    while(abs(ok - ng) > 1){
      int mid = (ok + ng) / 2;
      if(add_segtree.query((ll)left, (ll)mid) == xor_segtree.query((ll)left, (ll)mid)){
	ok = mid;
      }else{
	ng = mid;
      }
    }
    //cout << "[" << left << ", " << ok << ")" << endl;
    res += ll(ok - left);
  }
  cout << res << endl;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st S;
  ci(S);
  if(S == "abc" || S == "bca" || S == "cab" || S == "acb" || S == "bac" || S == "cba"){
    co("Yes");
  }
  else{
    co("No");
  }
}


Measured memory_bytes: 256
n,T = map(int, input().split())
t= list(map(int,input().split()))  #秒数


ans=0

for e in range(1,n):
    if T<=(t[e]-t[e-1]):
        ans+=T

    else:
        ans+=(t[e]-t[e-1])

print(ans+T)


Measured memory_bytes: 25196
def gcd(x,y):
  while y:
    x,y = y,x%y
  return x

def calc(x,a,b,l):
  return x - (x//a) - (x//b) + (x//l)

A,B,C,D = map(int,input().split())
lcm = C*D // gcd(C,D)
print(calc(B,C,D,lcm) - calc(A-1,C,D,lcm))


Measured memory_bytes: 38256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
sc = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'S':
        sc += 1
    else:
        if sc:
            sc -= 1
            ans += 1
print(len(s) - ans*2)


Measured memory_bytes: 10516
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    string s;
    cin >> s;
    s[3] = '8';

    cout << s << '\n';

    return 0;
}

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

int d[100];
int f[100];
int now = 1;
void dfs(vector<vector<int> > v, int i) {
  if (d[i]) return;
  d[i] = now++;
  for (int vv : v[i])
    if (i != vv) dfs(v, vv);
  f[i] = now++;
}

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

  vector<vector<int> > v(n);
  rep(i, n) {
    int u, k;
    cin >> u >> k;
    vector<int> vv(k);
    rep(j, k) {
      cin >> vv[j];
      vv[j]--;
    }
    v[i] = vv;
  }

  rep(i, n) if (!d[i]) dfs(v, i);
  rep(i, n) { printf("%d %d %d\n", i + 1, d[i], f[i]); }
  return 0;
}


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

int main() {
    int w,h,n;
    cin>>w>>h>>n;

    int xl=0,yd=0,xr=w,yu=h;

    rep(i,0,n){
        int x,y,a;
        cin>>x>>y>>a;

        if (a==1) {
            xl=max(xl,x);
        }
        else if(a==2){
            xr=min(xr,x);
        }
        else if (a==3) {
            yd=max(yd,y);
        }
        else{
            yu=min(yu,y);
        }
    }

    int answer=(xr-xl)*(yu-yd);

    if(xl>xr||yd>yu){
        cout<<0<<endl;
    }
    else {
        cout<<answer<<endl;
    }
}


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

int main(){
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c=='u'|| c=='e'||c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3580
from math import gcd

def gcd3(a, b, c):
  return gcd(gcd(a, b), c)

K = int(input())

res = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      res += gcd3(a, b, c)
      
print(res)

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t; 
    cin >> s;
    cin >> t;
    long long count= 0;
    for(long long i = 0; i < 3; i++)
    {
    	if(s[i] == t[i])
    		count++;
    }
    cout << count << '\n';
    
    return 0;
}

Measured memory_bytes: 256
//#############################################################################
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define INF 1000000000000009
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define vec vector
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
#define sum(v) accumulate(all(v),0LL)
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Globals
const ll mxN = 1e5+1LL;
vec<vec<ll>> dp(mxN,vec<ll>(2,-1LL));
vec<vec<ll>> tree(mxN,vec<ll>());
vec<bool> visited(mxN);
//#############################################################################
//Helpers
void io_handler()
{
#ifdef LOCAL_TESTING
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
template <typename T>
void print_matrix(vector<vec<T>> mat){
    for(auto row: mat){
        for(auto e : row){
            // auto fst = e[0]==INF?"INF":to_string(e[0]);
            // auto scd = e[1]==INF?"INF":to_string(e[1]);
            // cout <<"["<<fst<<","<<scd<< "]"<<" ";
            cout<<e<<" ";
        }
        cout << endl;
    }
}
template <typename T>
void print_vector(vector<T> v){
    for(auto e : v){cout<< e <<" ";}
    cout<<endl;
}
template <typename T>
map<T,T> get_count(vector<T> v){
    map<T,T> count;
    for(auto e: v){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
void add_self(ll &a, ll b){
    a = a+b; if (a>=MOD){a -= MOD;}
}
ll sub_mod(ll a, ll b){
    a = (a-b+MOD)%MOD;
    return a;
}
void dfs(ll node){
    visited[node] = true;
    dp[node][0ll] = dp[node][1LL] = 1LL;
    for(auto child : tree[node]){
        if(visited[child]){continue;}
        dfs(child);
        //If I paint my current node white
        dp[node][0LL]  = (dp[node][0LL]*((dp[child][0LL]+dp[child][1ll])%MOD))%MOD;
        //if I paint my current node black
        dp[node][1LL] = (dp[node][1LL]*(dp[child][0LL]%MOD))%MOD;
    }
}
//#############################################################################
//Solution
void solve(){
    ll n; cin>>n;
    for(ll i = 0LL; i<n-1; i++){
        ll u,v; cin>>u>>v;
        tree[u-1].eb(v-1);
        tree[v-1].eb(u-1);
    }
    dfs(0LL);
    ll ans = (dp[0LL][1LL]+dp[0LL][0LL])%MOD;
    cout<<ans<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
#ifdef LOCAL_TESTING
    cout << "⏰ Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
//#############################################################################


Measured memory_bytes: 15360
#include <cstdio>
int ar[2010][2010], ac[2010][2010], b[2010][2010];
char s[2010][2010];
int main() {
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			b[i+1][j+1] = b[i+1][j] + b[i][j+1] - b[i][j] + (s[i][j] == '1');
			ar[i+1][j+1] = ar[i+1][j] + ar[i][j+1] - ar[i][j] + (i && s[i][j] == s[i-1][j] && s[i][j] == '1');
			ac[i+1][j+1] = ac[i+1][j] + ac[i][j+1] - ac[i][j] + (j && s[i][j] == s[i][j-1] && s[i][j] == '1');
		}
	}
	while (q--) {
		int x1, x2, y1, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		printf("%d\n", b[x2][y2] - b[x2][y1-1] - b[x1-1][y2] + b[x1-1][y1-1] - (ar[x2][y2] - ar[x2][y1-1] - ar[x1][y2] + ar[x1][y1-1] + ac[x2][y2] - ac[x2][y1] - ac[x1-1][y2] + ac[x1-1][y1]));
	}
	return 0;
}


Measured memory_bytes: 52992
//ABC124A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	vector<int> a(5);
	for(int i=0;i<5;i++){
		cin >> a.at(i);
	}
	int k;
	cin >> k;
	sort(a.begin(),a.end());
	if(a.at(4)-a.at(0) > k){
		cout << ":(" << endl;
		return 0;
	}else{
		cout << "Yay!" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let mut two = 1;
    for _ in 0..m {
        two *= 2;
    }
    println!("{}", two * (1900 * m + (n - m) * 100));
}


Measured memory_bytes: 2116
def test():
  N, M, X, Y = (int(i) for i in input().split())
  x = [int(i) for i in input().split()]
  y = [int(i) for i in input().split()]

  x.sort()
  y.sort()

  for i in range(X+1, Y+1):
    if x[N-1] < i and i <= y[0] and X < i and i <= Y:
      print("No War")
      return 0

  print("War")
  
test()

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

using namespace std;

template<typename A,typename B>inline void chmin(A &a,B b){if (a>b) a=b;}

template<typename A,typename B>inline void chmax(A &a,B b){if (a<b) a=b;}

int n,h;

int a[111111],b[111111]; 

int main()
{
	cin>>n>>h;
	
	for (int i=0;i<n;i++) cin>>a[i]>>b[i];
	
	int x=*max_element(a,a+n);
	
	sort(b,b+n);
	
	reverse(b,b+n);
	
	int ans=(h+x-1)/x;
	
	for (int i=0;i<n;i++){
		h-=b[i];
		
		int tmp;
		
		if (h<=0) tmp=0;
		
		else tmp=(h+x-1)/x;
		
		chmin(ans,i+1+tmp);
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int (i) = 0; i < (n);++i)
using namespace std;
typedef long long ll;

int main(){
    int X,Y;
    cin >> X >> Y;
    string str[70];
    bool can = false;
    rep(i,X) cin >> str[i];
    int dx[4] = {1,-1,0,0};
    int dy[4] = {0,0,1,-1};
    rep(i,X){
        rep(j,Y){
            if (j+1 < Y && (str[i][j] == '.' && str[i][j+1] == '.')){
                can = true;
                }else {
                    can = false;
                    break;
                }
            }
    }

    if (can){
        cout << "Yes" << endl;
        return 0;
    }

    rep(i,X){
        rep(j,Y){
            if (str[i][j]=='#'){
                can = false;
                //cout << i << j << "hakken" << endl;
                rep(k,4){
                int x = i + dx[k];
                int y = j + dy[k];
                if (x<X && y<Y && x>=0 && y>=0 && str[x][y] == '#'){
                    can = true;
                    break;
                        }
                if (k == 3 && !can){
                    can = false;
                    cout << "No" << endl;
                    return 0;
                        }
                    }
                }
            }
        }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,a=0;
  cin>>h>>w;
  vector<string> v(h);
  for(int i=0;i<h;i++) cin>>v[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(v[i][j]=='.'){
        if(i>=1 && j>=1){
        if(v[i-1][j-1]=='#'){
          a+=1;
        }
        }
        if(j>=1){
        if(v[i][j-1]=='#'){
          a+=1;
        }
        }
        if(j>=1 && i<=h-2){
        if(v[i+1][j-1]=='#'){
          a+=1;
        }
        }
        if(i>=1){
        if(v[i-1][j]=='#'){
          a+=1;
        }
        }
        if(i<=h-2){
        if(v[i+1][j]=='#'){
          a+=1;
        }
        }
        if(i>=1 && j<=w-2){
        if(v[i-1][j+1]=='#'){
          a+=1;
        }
        }
        if(j<=w-2){
        if(v[i][j+1]=='#'){
          a+=1;
        }
        }
        if(i<=h-2 && j<=w-2){
        if(v[i+1][j+1]=='#' && v[i+1][j+1]!='\0'){
          a+=1;
        }
        }
        cout<<a;
        a=0;
      }else{
        cout<<'#';
        a=0;
      }
    }
    cout<<endl;
  }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 modpow(int64 a, int64 r){
    if(a == 1)return 1;
    if(r == 0)return 1;
    if(r & 1){
        return modpow(a, r - 1) * a % MOD;
    }else{
        int64 x = modpow(a, r / 2);
        return x * x % MOD;
    }
}

vector<int64> factorial;
vector<int64> factorialInv;

int64 comb(int64 n, int64 r){
    if(n < r)return 0;
    r = min(r, n-r);
    if(r == 0)return 1;
    return factorial[n] * factorialInv[r] % MOD * factorialInv[n - r] % MOD;
    // return factorial[n] * modpow(factorial[r], MOD-2) % MOD * modpow(factorial[n-r],MOD-2) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    factorial.resize(n+2);
    factorial[0] = 1;
    FOR(i,1,n+2){
        factorial[i] = factorial[i-1] * i % MOD;
        // cout << factorial[i] << endl;
    }
    factorialInv.resize(n+2);
    factorialInv[n+1] = modpow(factorial[n+1], MOD-2);
    FORR(i,n,0){
        factorialInv[i] = factorialInv[i+1] * (i+1) % MOD;
        // cout << factorialInv[i] << endl;
    }
    vector<int32> nIndex(n,-1);
    int32 x = 0, y = 0;
    REP(i,n+1){
        int32 a;
        cin >> a;
        a--;
        if(nIndex[a] != -1){
            x = nIndex[a];
            y = i;
            break;
        }
        nIndex[a] = i;
    }
    // cout << x << " " << y;
    FOR(k,1,n+2){
        int64 cnt = 0;
        // for(int32 j = max<int64>(0, k - n + y - 1); j <= min<int64>(k-1,x); j++){ //xより前から選ぶ数
        //     // if(x < j)break;
        //     // if(n - y < k - j - 1)continue;
        //     cnt += comb(x, j) * comb(n - y, k - j - 1) % MOD;
        //     cnt %= MOD;
        // }
        cnt = comb(x + n - y, k - 1);
        cout << (comb(n+1, k) - cnt + MOD) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	string a;
	for (int i=0;i<(int)s.size();i++){
		if ((int)a.size()>0&&a.back()=='S'&&s[i]=='T'){
			a.pop_back();
		}
		else{
			a+=s[i];
		}
	}
	cout<<a.size()<<endl;
}

Measured memory_bytes: 1356
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

int main()
{
	long long a,b,c,ma,ans,p;
	while(~scanf("%lld %lld %lld",&a,&b,&c))
	{
		scanf("%lld",&p);
		ans = a + b + c;
		ma = max(a,b);
		ma = max(ma,c);
		ans -= ma;
		for(long long i = 1;i <= p;i++) ma *= 2;
		ans += ma;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128