akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n , M[MAX][MAX];

int prim(){
	int u , minv;
	int d[MAX] , p[MAX] , color[MAX];
	
	for( int i = 0; i < n; i++ ){
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while(1){
		minv = INFTY;
		u = -1;
		for( int i = 0; i < n; i++ ){
			if( minv > d[i] && color[i] != BLACK ){
				u = i;
				minv = d[i];
			}
		}
		if( u == -1 ){
			break;
		}
		color[u] = BLACK;
		
		for( int v = 0; v < n; v++ ){
			if( color[v] != BLACK && M[u][v] != INFTY ){
				if( d[v] > M[u][v] ){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	
	int sum = 0;
	
	for( int i = 0; i < n; i++ ){
		if( p[i] != -1 ){
			sum += M[i][p[i]];
		}
	}
	
	return sum;
}

int main( void ){
	
	scanf( "%d" , &n );
	
	for( int i = 0; i < n; i++ ){
		for( int j = 0; j < n; j++ ){
			int e;
			scanf( "%d" , &e );
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	
	printf( "%d\n"  ,prim() );
	
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N = in(), A[MAX], x = 0, y = 0;
  rep(i, N) A[i] = in();
  sort(A, A+N, greater<>());

  rep(i, N){
    if(i % 2 == 0) x += A[i];
    else y += A[i];
  }

  cout << x - y << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3180
use std::io;

fn sum_of_string(s: &String) -> u32 {
    s.chars().fold(0, |acc, c| c.to_digit(10).unwrap_or(0) + acc)
  }

fn main(){


    let mut input: String = String::new();

    io::stdin().read_line(&mut input).expect("Enter Something");
    
    let digit_sum:u32 = sum_of_string(&input);

    println!("{}", {
        if digit_sum%9 == 0{"Yes"}
        else {"No"}
    });

}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007

using namespace std;

typedef unsigned long long ull;

int main(void)
{
    constexpr int N_MAX = 1000;
    constexpr int K_MAX = 1000;

    // Stirling numbers of the second kind
    ull s[N_MAX + 1][K_MAX + 1];
    REP(i, N_MAX + 1) s[i][i] = 1;
    FOR(n, 1, N_MAX + 1) s[n][0] = 0;
    FOR(n, 1, N_MAX + 1) FOR(k, 1, n) s[n][k] = ((k * s[n - 1][k]) % MOD + s[n - 1][k - 1]) % MOD;

    int n, k;
    cin >> n >> k;
    ull result = 0;
    REP(i, k + 1) {
        result = (result + s[n][i]) % MOD;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 9988
package main

import "fmt"

func main() {
	var x, n, count int
	fmt.Scan(&x)
	n, count = 100, 0
	for {
		count++
		n = int(float64(n) * 1.01)
		if x <= n {
			fmt.Print(count)
			break
		}
	}
}


Measured memory_bytes: 1752
import numpy as np
import math
import collections
import bisect
import itertools


def num2alpha(num):
    if num <= 26:
        return chr(96 + num)
    elif num % 26 == 0:
        return num2alpha(num // 26 - 1) + chr(122)
    else:
        return num2alpha(num // 26) + chr(96 + num % 26)


def main():
    N = int(input())
    print(num2alpha(N))


if __name__ == "__main__":
    main()


Measured memory_bytes: 27096
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
int main()
{
    fast
    ll t = 1;
    //cin>>t;
    while(t--){
    ll n;
    cin>>n;
    if(n%2){
        cout<<((ld)(n/2+1)/n)<<"\n";
    }
    else
    {
        cout<<(ld)(n/2)/n<<"\n";
    }
    
    }
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a, b, c = map(int, readline().split())
    if b-a==c-b:
        print('YES')
    else:
        print('NO')



if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
N = int(input())
A = list(map(int,input().split()))
sa = sum(A)

unit = N*(N+1)//2
if sa%unit:
    print('NO')
    exit()

k = sa//unit
A.append(A[0])

for a,b in zip(A,A[1:]):
    if b-a-k > 0 or (b-a-k)%N != 0:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;

    map<map<char,ll>, ll> mp;

    rep(i,N){
        string s;
        cin >> s;
        map<char, ll> tmp;
        for(auto c : s) ++tmp[c];
        ++mp[tmp];
    }

    ll ans = 0;
    for(auto m : mp) ans += m.second * (m.second - 1) / 2;

    print(ans);
    
    return 0;
}

Measured memory_bytes: 62336
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll M = 1000000007;

ll N;
ll DP[1000010];
ll SUM[1000010];

ll dp(int n);

ll sum(int n) {
  if (n < 0) return n;
  if (SUM[n] != -1) return SUM[n];
  return SUM[n] = (sum(n-1) + dp(n-1))%M;
}

ll dp(int n) {
  if (n < 0) return 1;
  if (DP[n] != -1) return DP[n];
  // k_1, k_2
  ll ans = (N-1) * (N-1);
  ans %= M;
  // 1
  ans += dp(n-1);
  ans %= M;
  // k_1, 1
  ans += sum(n-2-1+1) + M - sum(n-N-1);
  ans %= M;
  // cerr << "dp(" << n << ") = " << ans << endl;
  return DP[n] = ans;
}

int main () {
  cin >> N;
  fill(DP, DP+1000010, -1);
  fill(SUM, SUM+1000010, -1);
  DP[0] = 1;
  DP[1] = N;
  SUM[0] = 0;
  for (auto i = 0; i < N; ++i) {
    sum(i);
  }
  cout << dp(N) << endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int i=0;
int main(){
	cin>>s;
	while(i<s.size()){
		if(s[i]=='C'){
			for(int j=i+1;j<s.size();j++){
				if(s[j]=='F'){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
			break;
		}
		i++;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n - 1];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n - 1; i++)
        cin >> c[i];

    int ans = 0;
    int pre = -1;
    for(int i = 0; i < n; i++) {
        ans += b[a[i] - 1];
        if(pre + 1 == a[i])
            ans += c[a[i - 1] - 1];
        pre = a[i];
    }
    cout << ans << endl;
}

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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  for (int i=0; i < N; i++){
    cin >> a.at(i);
  }
  
  int ans =0;
  for (int i=0; i < N; i++){
    if((i+1)%2==1 && a.at(i)%2==1){ ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;

typedef long long ll;

void hora(int tc) {
	int n;
	cin>>n;
	cout<<n * n * n<<endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.setf(ios::showpoint), cout.precision(10);
	int ntc = 1;
//	cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) {
		hora(tc);
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
#define maxn 110
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
struct edge{
	int to,nxt,flow;
}e[2*maxn*maxn];
int fir[2*maxn],lv[2*maxn],cur[2*maxn];
int a[maxn][maxn],mark[maxn][maxn],b[maxn][maxn];
int n,m,S,T,tot;
inline void add_edge(int x,int y,int z)
{
	e[tot].to=y; e[tot].flow=z; e[tot].nxt=fir[x]; fir[x]=tot++;
	e[tot].to=x; e[tot].flow=0; e[tot].nxt=fir[y]; fir[y]=tot++;
}
int find(int now,int limit)
{
//	printf("%d %d\n",now,limit);
	if(now==T)return limit;
	int ans=0;
	for(int i=cur[now];~i;i=e[i].nxt){
		cur[now]=i;
		if(e[i].flow&&lv[e[i].to]==lv[now]+1){
			int tmp=find(e[i].to,std::min(limit,e[i].flow));
			e[i].flow-=tmp; e[i^1].flow+=tmp;
			ans+=tmp; limit-=tmp;
			if(!limit)break;
		}
	}
	return ans;
}
int dinic()
{
//	puts("QAQ");
	static int q[2*maxn];
	int ans=0;
	while(1){
		for(int i=0;i<=T;i++)
			lv[i]=0,cur[i]=fir[i];
		int h=1,t=1;
		q[1]=S; lv[S]=1;
		while(h<=t){
			int now=q[h++];
			for(int i=fir[now];~i;i=e[i].nxt)
				if(e[i].flow&&!lv[e[i].to]){
					q[++t]=e[i].to; lv[e[i].to]=lv[now]+1;
				}
		}
//		for(int i=0;i<=T;i++)writesp(lv[i]); putchar('\n');
		if(!lv[T])break;
		int k=find(S,inf);
		while(k){
			ans+=k;
			k=find(S,inf);
		}
	}
	return ans;
}
void solve(int C)
{
	memset(fir,255,sizeof(fir)); tot=0;
	S=0; T=2*n+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(!mark[i][j])add_edge((a[i][j]-1)/m+1,n+i,1);
	for(int i=1;i<=n;i++)
		add_edge(S,i,1),add_edge(i+n,T,1);
	dinic();
//	puts("TAT");
	for(int i=1;i<=n;i++){
		int t=0;
		for(int j=fir[i+n];~j;j=e[j].nxt)
			if(e[j].flow&&e[j].to!=T)t=e[j].to;
		int k=1;
		while(k<=m&&(mark[i][k]||(a[i][k]-1)/m+1!=t))++k;
		mark[i][k]=1; b[i][C]=a[i][k];
//		printf("%d %d\n",i,k);
	}
}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=read();
	for(int i=1;i<=m;i++)
		solve(i);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			writesp(b[i][j]);
		putchar('\n');
	}
	for(int j=1;j<=m;j++)
		for(int i=1;i<=n;i++)
			for(int k=i+1;k<=n;k++)
				if(b[i][j]>b[k][j]){
					int tmp=b[i][j]; b[i][j]=b[k][j]; b[k][j]=tmp;
				}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			writesp(b[i][j]);
		putchar('\n');
	}
	return 0;
}

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

typedef long long ll;

int main() {
	string s;
	cin >> s;
	ll sum = 0;
	for(auto& e:s) {
		sum += (e-'0');
	}
	if (sum%9 ==0) cout << "Yes";
	else cout << "No";	
	return 0;
}


Measured memory_bytes: 3700
import java.io.PrintWriter;
import java.util.*;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();

        HashMap<Character, Integer> count = new HashMap<>();

        for (char ch : s.toCharArray()) {
            if (count.containsKey(ch))
                count.put(ch, count.get(ch) + 1);
            else
                count.put(ch, 1);
        }

        boolean flag = false;
        if (count.size() == 2) {
            for (Map.Entry<Character, Integer> e : count.entrySet()) {
                if (e.getValue() != 2)
                    break;
            }
            flag = true;
        }

        out.println(flag ? "Yes" : "No");
    }

}


Measured memory_bytes: 23124
S = input()
ch = list(S)
num = len(S)
n1 = int((num-1)/2)
result = str("Yes")
i = int(0)
j = int(0)
k = int(0)
while i < n1:
    if ch[i] == ch[n1-1-i]:
        i = i+1
    else:
        result = str("No")
        break
if result == "Yes":
    while j < n1:
        if ch[num - n1+j] == ch[num - j-1]:
            j = j+1
        else:
            result = str("No")
            break
if result == "Yes":
    while k < num:
        if ch[k] == ch[num-1-k]:
            k = k + 1
        else:
            result = str("No")
            break
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=405;
int n,a[N],ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]!=i+1) ans++;
    }
    if(ans>2)
        cout<<"NO\n";
    else
        cout<<"YES\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll ans;
int n,e[305][305];
bool f[305][305];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			scanf("%d",&e[i][j]),f[i][j]=1;
	for(int k=1;k<=n;++k)
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				if(k==i || k==j || !f[i][j]) continue;
				else if(e[i][j]>e[i][k]+e[k][j]) {puts("-1");return 0;}
				else if(e[i][j]==e[i][k]+e[k][j]) f[i][j]=f[j][i]=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(f[i][j]) ans+=e[i][j];
	printf("%lld\n",ans>>1);
}

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

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.length();
	int sum=0;
	for(int i=0;i<n;i++){
		if(s1[i]==s2[i])
		    sum++;
	}
	cout<<sum<<endl;
}

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

	public static int digits(long n) {
		int digit = 0;
		while(n > 0) {
			digit++;
			n /= 10;
		}
		return digit;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = 10;
		for(int i = 1; i <= Math.sqrt(N); i++) {
			if(N % i == 0)
				ans = Math.min(ans, Math.max(digits(N/i), digits(i)));
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22740
s=list(input())
n=len(s)
r=reversed(s)
f=s[0:(n-1)//2]
l=s[(n+3)//2-1:n]
rf=reversed(f)
rl=reversed(l)
a="".join(s)
b="".join(r)
c="".join(f)
d="".join(rf)
e="".join(l)
f1="".join(rl)
if a==b and c==d and e==f1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
import math
a, b, x = map(float, input().split())

if x>=a**2*b/2:
    c = 2*b - 2*x/a**2
    print('{:.11g}'.format(math.degrees(math.atan(c/a))))
else:
    c=2*x/(a*b)
    print('{:.11g}'.format(90.0-math.degrees(math.atan(c/b))))

Measured memory_bytes: 3060
# read www.u.dendai.ac.jp/~ochi/introalg02.pdf if you need
def e_gcd(a, b):
    u0,u1 = 1,0
    if b == 0:
    	return u0,u1
   
    d0,d1 = a,b
    while True:
        q,r = d0//d1,d0%d1
        if r == 0:
        	return u1,(d1-a*u1)/b

        d0,d1 = d1,r # r=d0%d1. here is nomal gcd ope.
        u0,u1 = u1,u0-q*u1 # u1 = u0-d0//d1*u1. 

a,b = map(int, raw_input().split())
print " ".join(map(str, e_gcd(a,b)))

Measured memory_bytes: 4224
$n = gets.to_i
$edges = Hash.new { |h, k| h[k] = [] }
($n-1).times do
  a, b = gets.split.map {|x| x.to_i - 1}
  $edges[a] << b
  $edges[b] << a
end

def calc_distances(start)
  dists = Array.new($n) { -1 }
  q = [[start, 0]]
  until q.empty?
    p, d = q.shift
    dists[p] = d
    $edges[p].each do |np|
      q.push([np, d + 1]) if dists[np] == -1
    end
  end

  dists
end

dists_fenec = calc_distances(0)
dists_snuke = calc_distances($n-1)

fenec, snuke = 0, 0
0.upto($n-1).each do |p|
  dists_fenec[p] <= dists_snuke[p] ? fenec += 1 : snuke += 1
end

puts fenec > snuke ? 'Fennec' : 'Snuke'

Measured memory_bytes: 21896
#include <stdio.h>
#include <string.h>

int main(){
	int x,ac,wa,tle,re;
	char c[16];
	ac=wa=tle=re=0;
	scanf("%d",&x);
	for(int i=0; i<x; i++){
		scanf("%s",&c);
		if (strcmp(c,"AC") == 0) ac++;
		else if (strcmp(c,"WA") == 0) wa++;
		else if (strcmp(c,"TLE") == 0) tle++;
		else if (strcmp(c,"RE") == 0) re++;
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
 
	return 0;
}

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            long N = IO.ReadLineToLong();
            long[] str = new long[5];
            for(int i = 0; i < 5; i++)
            {
                str[i] = IO.ReadLineToLong();
            }

            long min = str.Min();
            long ans;
            if (min >= N)
            {
                ans = 5;
            }
            else if (N%min==0)
            {
                ans = N / min + 4;
            }
            else
            {
                ans = N / min + 5;
            }

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 13268
import itertools
import math

n = int(input())
xys = [list(map(int, input().split())) for i in range(n)]
# print(xys)

patterns = list(itertools.permutations([i for i in range(n)], n))
# print(patterns)

def calc_length(i, j):
    xi, yi = i
    xj, yj = j

    return math.sqrt((xi - xj) ** 2 + (yi - yj)**2)

def calc_length_many(pattern):
    num = 0
    # print(pattern)
    for k in range(len(pattern) -1):
        i = xys[pattern[k]]
        j = xys[pattern[k+1]]
        num += calc_length(i, j)
    return num
ans = 0
# print(patterns[0])
for i in range(len(patterns)):
    # print(patterns[i])
    ans += calc_length_many(patterns[i])

print(ans / len(patterns))

Measured memory_bytes: 47084
#include<stdio.h>
#define MAX 100000

int main(){
  int n,i,A[MAX],temp,j,k;
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &A[i]);

  j = -1;
  k = 0;
  for(i = 0; i < n; i++){
    if(A[i] <= A[n-1]){
      j++;
      temp = A[j];
      A[j] = A[k];
      A[k] = temp;
    }
    k++;
  }

  for(i = 0; i < n; i++){
    if(i != 0) printf(" ");
    if( i == j) printf("[");
    printf("%d",A[i]);
    if(i == j) printf("]");
  }
  printf("\n");

  return 0;
}


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

int main() {
  string w;
  cin >> w;
    
  vector<int> count(30, 0);
  
  for (int i = 0; i < w.size(); i++) {
    count[w[i] - 'a']++;
  }
  
  bool cond = true;
  for (int i = 0; i < 26; i++) {
    if (count[w[i]-'a'] % 2 == 1) {
      cond = false;
      break;
    }
  }
  
  if (cond) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  
  
}




Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int f(ll a)
{
  int ret = 0;
  while( a > 0 ){
    ret++;
    a /= 10;
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  int ret = 1000;
  for( ll i=1; i*i<=N; i++ ){
    if( N % i == 0 ){
      ret = min( ret, max( f(i), f(N/i) ) );
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
		if (((xb1 <= xa1 && xa1 <= xb2) || (xa1 <= xb1 && xb1 <= xa2)) && ((yb1 <= ya1 && ya1 <= yb2) || (ya1 <= yb1 && yb1 <= ya2))) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

template <class T>
class SegTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> data;
    const F f;
    const T e;

public:
    SegTree(const vector<T>& as, const F f, const T& e) : f(f), e(e) {
        n = 1;
        while (n < as.size()) n <<= 1;
        data.assign(2 * n, e);
        for (int i = 0; i < as.size(); i++) {
            data[n + i] = as[i];
        }
        for (int i = n - 1; i > 0; i--) {
            data[i] = f(data[2 * i], data[2 * i + 1]);
        }
    }

    void update(int k, const T& x) {
        k += n;
        data[k] = x;
        while (k >>= 1) {
            data[k] = f(data[2 * k], data[2 * k + 1]);
        }
    }

    T query(int a, int b) {
        T L = e, R = e;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) {
                L = f(L, data[a++]);
            }
            if (b & 1) {
                R = f(data[--b], R);
            }
        }
        return f(L, R);
    }
};

int main() {
    int n;
    cin >> n;
    vi hs(n), as(n), pos(202020, -1);
    for (int i = 0; i < n; i++) {
        cin >> hs[i];
        pos[hs[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    SegTree<i64> dp(vi(n), [](i64 a, i64 b) {return max(a, b);}, -1e18);
    for (int i = 0; i < n; i++) {
        dp.update(i, 0);
    }
    for (int i = 1; i < 202020; i++) {
        if (pos[i] == -1) continue;
        int p = pos[i];
        if (p == 0) {
            dp.update(p, as[p]);
        } else {
            dp.update(p, dp.query(0, p) + as[p]);
        }
    }
    i64 nax = 0;
    for (int i = 0; i < n; i++) {
        nax = max(nax, dp.query(i, i + 1));
    }
    cout << nax << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	3*MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	ll Visit[MAXN]={};
	for(ll i=0;i<n-1;i++) {
		cin>>x;
		Visit[x]++;
	}

	for(ll i=1;i<=n;i++) {
		cout<<Visit[i];newl;
	}

}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 13000
fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let s = iter.next().unwrap().chars();
    let t = iter.next().unwrap().chars();
    let mut cnt_s = s.fold(vec![0; 26], |mut cnt_v, x| {
        cnt_v[x as usize - 'a' as usize] += 1;
        cnt_v
    });
    let mut cnt_t = t.fold(vec![0; 26], |mut cnt_v, x| {
        cnt_v[x as usize - 'a' as usize] += 1;
        cnt_v
    });
    cnt_s.sort();
    cnt_s.reverse();
    cnt_t.sort();
    cnt_t.reverse();
    if cnt_s == cnt_t {
        println!("Yes");
    } else {
        println!("No");
    }
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
H, W, K = map(int, input().split())
total_black = 0
row_black = list()
column_black = list()
matrix = [[] for _ in range(H)]
for i in range(H):
  t = input()
  total_black += t.count("#")
  row_black.append(t.count("#"))
  for j in range(W):
    matrix[i].append(t[j])

for i in range(W):
  count = 0
  for j in range(H):
    if matrix[j][i] == "#":
      count += 1
  column_black.append(count)

ans = 0
for i in range(2**H):
  count_row = 0
  select_row = list()
  
  for l in range(H):
    if (i >> l) & 1:
      # l行を選択
      count_row += row_black[l]
      select_row.append(l)
  
  for j in range(2**W):
    count_column = 0
    select_column = list()
    for k in range(W):
      if (j >> k) & 1:
        #k列を選択
        count_column += column_black[k]
        select_column.append(k)
    
    count_duplication = 0
    for r in select_row:
      for c in select_column:
        if matrix[r][c] == "#":
          count_duplication += 1

    #行列が選択されている
    if total_black - count_row - count_column + count_duplication == K:
      ans += 1
      
print(ans)

Measured memory_bytes: 68516
import numpy as np

n = int(input())
s = [i for i in input()]

if(n % 2 != 0):
    print("No")
else:
    a = int(n/2)
    s_a = s[:a]
    s_b = s[a:]
    if(s_a == s_b):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 18492
n,k = map(int,input().split())
point = list(map(int,input().split()))
t = input().translate(str.maketrans('rsp','201'))
c = 0
for i in range(k):
  dp = [0]*3
  for j in range(i,n,k):
    pdp,dp = dp,[0]*3
    for l in range(3):
      if l == int(t[j]):
        dp[l] = max(pdp[(l+1)%3],pdp[(l+2)%3]) + point[l]
      else:
        dp[l] = max(pdp[(l+1)%3],pdp[(l+2)%3])
  c += max(dp)
print(c)

Measured memory_bytes: 3700
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

struct pos{
    int x, y, d;
};

int y_vec[] = {  0,  0, -1, +1 };
int x_vec[] = { -1, +1,  0,  0 };

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                continue;
            }
            vector<string> vec = s;
            queue<pos> q;
            vec[i][j] = '#';
            q.emplace(pos{ j, i, 0 });
            int local_max = 0;
            while (!q.empty()) {
                pos p = q.front(); q.pop();
                for (int k = 0; k < 4; k++) {
                    int nx = p.x + x_vec[k];
                    int ny = p.y + y_vec[k];
                    int nd = p.d + 1;
                    if (nx < 0 || nx >= w) { continue; }
                    if (ny < 0 || ny >= h) { continue; }
                    if (vec[ny][nx] == '#') {
                        continue;
                    }
                    vec[ny][nx] = '#';
                    q.emplace(pos { nx, ny, nd });
                    if (nd > local_max) {
                        local_max = nd;
                    }
                }
            }
            if (local_max > ans) {
                ans = local_max;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

  bool f[101010] = {false};

  int sum = 0;
  for (int i = 1; sum < n; ++i) {
    sum += i;
    f[i] = true;
  }

  int d = sum - n;
  f[d] = false;

  for (int i = 0; i < 101010; ++i) {
    if (f[i]) cout << i << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll n;
  cin >> n;
  ll sum=0;
  ll j=1;
  for(int i=0;i<n;i++) {
    if(j%3!=0 && j%5!=0) {
      sum+=j;
      j+=1;}
    else {
      sum+=0;
      j+=1;}
    }
  cout << sum << endl;
  return 0;
  }
      


Measured memory_bytes: 3636
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 1e5 + 5;
const int MOD = 998244353;
int cnt[N], n, d[N], mx;
inline LL q_pow(LL n, LL k) {
    LL res = 1;
    while(k) {
        if(k&1) res = res*n%MOD;
        n = n*n%MOD;
        k >>= 1;
    }
    return res;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &d[i]), mx = max(mx, d[i]), cnt[d[i]]++;
    if(d[1] || cnt[0] > 1) return 0*puts("0");
    LL ans = 1;
    for (int i = 1; i <= mx; ++i) {
        ans = (ans * q_pow(cnt[i-1], cnt[i])) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MX 1000000007
int main()
{
    int n;
    unsigned long long int ans=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        ans=(ans%MX)*(i);
        ans=ans%MX;
    }
    cout<<ans<<endl;

}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0; i < m; ++i) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int num = c;
        for(int j = 0; j < m; ++j) {
            num += a[i][j]*b[j];
        }
        if(num > 0) ++ans;
    }

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


Measured memory_bytes: 256
from collections import Counter
def main():
    n = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    e = 0
    o = 0
    for v in c.values():
        if v % 2 == 0:
            e += 1
        else:
            o += 1
    if e % 2 != 0:
        e -= 1
    print(o + e)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62124
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,c;
	int m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a[3];
		for(int j=0;j<3;j++)scanf("%d",&a[j]);
		std::sort(a,a+3);
		
		m=max(m,a[2]);
		
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2])puts("YES");
		else{
			if(m<12)puts("NO");
			else puts("YES");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;
int main(){

	int n;
	int field[21][21];
	while(cin>>n&&n!=0){
		memset(field,0,sizeof(field));
		for(int i = 0; i < n; i++){
			int x,y;
			cin>>x>>y;
			field[y][x]=1;
		}
		int m;
		cin>>m;
		int rx=10;
		int ry=10;
		int cnt=n;
		for(int i = 0; i < m; i++){
			char ch;
			int d;
			cin>>ch>>d;
			int ny=ry;
			int nx=rx;
			while(d){
				d--;
				if(ch=='W'){
					nx--;
					if(ny>=0&&nx>=0&&ny<=20&&nx<=20){
						if(field[ny][nx]){
							cnt--;
							field[ny][nx]=0;
						}
						ry=ny;
						rx=nx;
					}
				}
				else if(ch=='E'){
					nx++;
					if(ny>=0&&nx>=0&&ny<=20&&nx<=20){
						if(field[ny][nx]){
							cnt--;
							field[ny][nx]=0;
						}
						ry=ny;
						rx=nx;
						
					}
				}
				else if(ch=='N'){
					ny++;
					if(ny>=0&&nx>=0&&ny<=20&&nx<=20){
						if(field[ny][nx]){
							cnt--;
							field[ny][nx]=0;
						}
						ry=ny;
						rx=nx;
						
					}
				}
				else if(ch=='S'){
					ny--;
					if(ny>=0&&nx>=0&&ny<=20&&nx<=20){
						if(field[ny][nx]){
							cnt--;
							field[ny][nx]=0;
						}
						ry=ny;
						rx=nx;
						
					}
				}
			}
		}
		if(cnt==0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll h, id = 1, cnt = 0;
  cin >> h;

  while (id <= h) id *= 2, cnt++;
  cnt--;
  ll ans = 1;
  rep(i, cnt) ans = ans * 2 + 1;

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


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

int main()
{
    int h,w,i,j;
    
    cin >> h >> w;

    while( h != 0 and w != 0)
    {
        for(i=0; i < h; i++)
        {
            if(i == 0 or i == h -1)
            {
                for(j=0; j < w; j++)
                {
                    cout << "#";
                }
                cout << endl;
            }
            else
            {
                cout << "#";
                for(j=1; j < w - 1; j++)
                {
                    cout << ".";
                }
                cout << "#";
                cout << endl;
            }
        }
        cout << endl;

        cin >> h >> w;
    }
    return 0;
}

Measured memory_bytes: 1152
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
   int max=a[0];
  long long  int count=0;
   for(int i=0;i<n;i++){
       if(a[i]>=max)
       max=a[i];
       else{
           count+=max-a[i];
       }
   }
   cout<<count;
    return 0;
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

using vl    = vector<long long>;
using vvl   = vector<vl >;
using vvvl  = vector<vvl >;

template<typename T>
class SegmentTree{
	using F=function<T(T,T)>;
	int n,offset;	//n:=(葉の数（2の階乗数),offset:=(n-1).
	const T e;		//e:=(単位元).
	vector<T> node;
	const F f;		//f:=(二項演算処理).
	
	int bufsize(int n_){//木の必要なノード数を返す.
		n=1;
		while(n<n_) n<<=1;
		offset=n-1;
		return 2*n-1;
	}
	void build(int l=0,int r=-1){//木を構築する. O(N).
		if(r<0) r=n;
		l+=offset, r+=offset;
		do{
			l=(l-1)/2, r=(r-1)/2;
			for(int i=l;i<r;++i) node[i]=f(node[2*i+1],node[2*i+2]);
		}while(l>0);
	}
	
public:
	/*constructor.*/
	SegmentTree(int n_,T e_,F f_):node(bufsize(n_),e_),e(e_),f(f_){}
	SegmentTree(vector<T> &v_,T e_,F f_):node(bufsize(v_.size()),e_),e(e_),f(f_){
		copy(ALL(v_),node.begin()+offset);//<algorithm>.
		build();
	}
		
	void init(){fill(ALL(node),e);}//初期化する.
	void update(int k,T a){//k番目の要素をaに更新する. O(log N).
		k+=offset;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;//parent.
			node[k]=f(node[2*k+1],node[2*k+2]);
		}
	}
	/*[a,b)間のクエリ結果を返す. O(log N).
	（後ろの3つの引数は計算の簡単のための引数. kはノード番号,lとrはそのノードが[l,r)に対応づいているかを表す. 外からはquery(a,b,0,0,n)と呼ぶ.）*/
	T query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(b<=l or r<=a) return e;			//[a,b)と[l,r)が交差しなければe.
		if(a<=l and r<=b) return node[k];	//[a,b)が[l,r)を完全に含んでいれば,この節点の値.
		T vl=query(a,b,2*k+1,l,(l+r)/2);
		T vr=query(a,b,2*k+2,(l+r)/2,r);
		return f(vl,vr);					//交差する場合,2つの子をクエリ処理して比較.
	}
	
	typename vector<T>::reference operator[](int i){return node[i+offset];}
};

int main(){
	int n,q;
	cin>>n>>q;
	
	vl a(n);
	REP(i,n) cin>>a[i];
	
	using Type = llong;
	auto f=[](Type a,Type b)->Type{return a+b;};
	SegmentTree<Type> tree(a,0LL,f);
	REP(i,q){
		int t,x,y;
		cin>>t>>x>>y;
		
		if(t==0) tree.update(x,tree[x]+y);
		else cout<<tree.query(x,y)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 16432
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>
 
using namespace std;
 
const int oo = 1e8, maxN = 2e5 + 10, modP = 1e9 + 7;
 
int c[maxN][2], n, k, m, q[maxN], flag;
vector < int > adj[maxN];
map < pair < int, int >, int > mmap;
 
void bfs(int u, int t) {
    int l = 1, r = 1;
    q[1] = u; 
    c[u][t] = ++flag;
    while (l <= r) {
        int u = q[l++];
        c[u][t] = flag;
        for (int i = 0; i < adj[u].size(); ++i) {
            int v = adj[u][i];
            if (c[v][t]) continue;
            c[v][t] = flag;
            q[++r] = v;
        }
    }
}
 
int main() {
    cin >> n >> k >> m;
    for (int i = 1; i <= k; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
 
    for (int i = 1; i <= n; ++i)
        if (!c[i][0]) bfs(i, 0);
 
    flag = 0;
    for (int i = 1; i <= n; ++i) adj[i].clear();
    for (int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
 
    for (int i = 1; i <= n; ++i)
        if (!c[i][1]) bfs(i, 1);
 
    for (int i = 1; i <= n; ++i) mmap[make_pair(c[i][0], c[i][1])]++;
    for (int i = 1; i <= n; ++i) printf("%d ", mmap[make_pair(c[i][0], c[i][1])]);
}


Measured memory_bytes: 23040
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
 
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/


  int n;
  cin>>n;
  int arr[n+1][3];
  for(int i=0;i<n;i++)
  {
  	for(int j=0;j<3;j++)
  		{
  			cin>>arr[i][j];
  		
  		}
  }
 
  int dp[n+1][3];
  memset(dp,INT_MIN,sizeof(dp));
  for(int i=0;i<3;i++)
  {
  	dp[0][i]=arr[0][i];
  }
  for(int i=1;i<n;i++)
  {
  	for(int j=0;j<3;j++)
  	{
  		for(int k=0;k<3;k++)
  		{
  			if(j==k)
  				{
  					continue;
  				}
  				else
  				{
  					dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);
  				}
  		}
  	}
  }
 
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 200005, L = 262144, inf = 1e9;

int n, m, s[N];
pii a[N];

struct minseg {
	int v[2*L];
	void init () {
		for(int i=2*L;i--;) v[i] = inf;
	}
	void upd (int P, int V) {
		P += L;
		while(P) {
			v[P] = min(v[P], V);
			P /= 2;
		}
	}
	int get (int S, int E) {
		S += L; E += L;
		int R = inf;
		while(S <= E) {
			if(S%2 == 1) R = min(R, v[S++]);
			if(E%2 == 0) R = min(R, v[E--]);
			S /= 2; E /= 2;
		}
		return R;
	}
} b, w;

int hmd (int I, int V) {
	if(!V) return s[I];
	return I - s[I];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&s[i]);
		s[i] += s[i-1];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&a[i].X,&a[i].Y);
	}
	sort(a+1, a+1+m);
	b.init(); w.init();
	w.upd(0, 0);
	for(int i=1;i<=m;i++) {
		int B = b.get(a[i].X-1, a[i].Y-1);
		int W = w.get(0, a[i].X-1);
		b.upd(a[i].Y, B);
		w.upd(a[i].Y, B + hmd(a[i].Y, 1) - hmd(a[i].Y, 0));
		b.upd(a[i].Y, W + hmd(a[i].X-1, 0) - hmd(a[i].X-1, 1));
		w.upd(a[i].Y, W + hmd(a[i].X-1, 0) - hmd(a[i].X-1, 1) + hmd(a[i].Y, 1) - hmd(a[i].Y, 0));
	}
	printf("%d\n", w.get(0,n) + s[n]);
}


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

int main(){
    int n, m, l;
    long long a[100][100], b[100][100], c[100][100];
    cin >> n >> m >> l;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            c[i][j] = 0;
            for(int k = 0; k < m; k++){
                c[i][j] = c[i][j] + a[i][k] * b[k][j];
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            cout << c[i][j];
            if(j != l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define NMAX 1001
using namespace std;
char b[NMAX][NMAX];
int n,m,nr[NMAX][NMAX];
int floodfill()
{
    queue<pair<int,int>> q;
    q.push({0,0});
    nr[0][0]=(b[0][0]=='#');
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;
        if(x<n-1){
            if(nr[x+1][y]>nr[x][y]+(b[x][y]=='.' && b[x+1][y]=='#')){
                nr[x+1][y]=nr[x][y]+(b[x][y]=='.' && b[x+1][y]=='#');
                q.push({x+1,y});
            }
        }
        if(y<m-1){
            if(nr[x][y+1]>nr[x][y]+(b[x][y]=='.' && b[x][y+1]=='#')){
                nr[x][y+1]=nr[x][y]+(b[x][y]=='.' && b[x][y+1]=='#');
                q.push({x,y+1});
            }
        }
        q.pop();
    }
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>b[i][j];
            nr[i][j]=INT_MAX;
        }
    }
    floodfill();
    cout<<nr[n-1][m-1];
    return 0;
}


Measured memory_bytes: 2688
let a=Int(readLine()!)!
var s : [String] = []
//var anag : [Character:Int] = [:]
//var chars : [[Character]] = []
var hashchar : [String:Int] = [:]
//var anaglist : [[Character:Int]] = []
//var kotae : [[Character:Int]:Int] = [] 
var tmps : String 

var o = 0

for var i  in 0..<a {
  //s.append(readLine()!)
  //var arr2 = Array(readLine()!.characters )
  //arr2 = arr2.sort()
  tmps = String( readLine()!.characters.sort() )
  //print( String(arr2) )

  //print(chars)
  /*
  for var j in 0..<arr2.count {
    if(  anag[arr2[j]] == nil ) {
      anag[arr2[j]] = 1
    } else {
      anag[arr2[j]] = (anag[arr2[j]])! + 1
    }
  }*/
  
  //print( hashchar[String(arr2)] )
  if( hashchar[tmps] == nil ) {
    hashchar[tmps] = 0
  } else {
    var tmp = ( hashchar[tmps] )! + 1
    hashchar[tmps] = tmp
    o += tmp
  }
  
  //var z = 0

  //chars.append(arr2)
  //anaglist.append( anag )
  
  //print( anag )
  //anag = [:]
}
/*
for var k in 0..<anaglist.count {
  for var x in k+1..<(anaglist.count) {
    if( anaglist[x] == anaglist[k] ){
      o += 1
    }
  }
}
*/
  
print( o )


Measured memory_bytes: 22540
#include<stdio.h>

int main(void) {
int i,n;

scanf("%d",&n);
int ans[n];

for (i = 0; i < n; i++) {
scanf("%d", &ans[i]);
}
for (i--; i >= 0; i--) {
printf("%d", ans[i]);
if(i != 0) {
printf(" ");
}
}
printf("\n");

return (0);
}

Measured memory_bytes: 600