akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

int main(){
	int p[14][14];
	int x, y, s, max = 0, sum = 100;
	for(int i = 0; i < 14; i++){
		for(int j = 0; j < 14; j++){
			p[i][j] = 0;
		}
	}

	while(scanf("%d,%d,%d", &x, &y, &s) + 1){
		if(s == 0){
			break;
		}
		p[x+2][y+2]++;
		p[x+1][y+2]++;
		p[x+2][y+1]++;
		p[x+3][y+2]++;
		p[x+2][y+3]++;
		s--;
		if(s){
			p[x+1][y+1]++;
			p[x+1][y+3]++;
			p[x+3][y+1]++;
			p[x+3][y+3]++;
			s--;
			if(s){
				p[x][y+2]++;
				p[x+2][y]++;
				p[x+2][y+4]++;
				p[x+4][y+2]++;
			}
		}
	}

	for(int i = 2; i < 12; i++){
		for(int j = 2; j < 12; j++){
			if(p[i][j]){
				sum--;
				if(max < p[i][j]){
					max = p[i][j];
				}
			}
		}
	}

	printf("%d\n%d\n", sum, max);
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    int count_a = 0, count_b = 0, j;
    rep(i, s.size()) {
        if(s[i] == '*') {
            j = i+1;
            break;
        }
        if(s[i] == '(') count_a++;
        if(s[i] == ')') count_a--;
    }
    for(int k = j; k<s.size(); k++) {
        if(s[k] == ')') count_b++;
    }
    cout << min(count_a, count_b) << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool check(int ans, int n){
    return ans+ans*8/100 == n;
}

int main(){

    int n;
    cin>>n;
    int ans = (int)(n/1.08);
    if(check(ans,n)) printf("%d\n",ans);
    else if(check(ans+1,n)) printf("%d\n",ans+1);
    else printf(":(\n");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int i,j=0,n,m,flag = 1;
    string kirai[10][2],ans;

    cin >> n >> m;

    for(i = 0;i < m;i++){
        cin >> kirai[i][0];
    }
    
    while(1){
        ostringstream stream;
        stream << n;
        
        ans = stream.str();

        flag= 1;
        for(i = 0;i < m;i++){
            if(ans.find(kirai[i][0]) < 10){
                flag = 0;
                break;
            }
        }
        if(flag == 1){
            break;
        }
        n++;
        
    }

    cout << n << endl;
    
    return 0;
}


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

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(N, scores):
    last_score = scores[0]
    for i in range(1, N):
        next_score = [
            max(last_score[1], last_score[2]) + scores[i][0],
            max(last_score[2], last_score[0]) + scores[i][1],
            max(last_score[0], last_score[1]) + scores[i][2],
        ]
        last_score = next_score
    return max(last_score)


T1 = """
3
10 40 70
20 50 80
30 60 90
"""


def main():
    N = int(input())
    scores = []
    for i in range(N):
        scores.append(list(map(int, input().split())))
    print(solve(N, scores))


def _test():
    """
    >>> as_input(T1)
    >>> main()
    210
    """
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 87028
N = int(input())
H = list(map(int, input().split()))

cnt = 0
r = 0
l = 0
while r < N - 1:
    if H[r] >= H[r + 1]:
        r += 1
    else:
        cnt = max(cnt, r - l)
        l = r + 1
        r = l
else:
    cnt = max(cnt, r - l)
print(cnt)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string s[9999];
int h,w,dp[1002][10002][3],a,b,c,d,n;
main(){
  cin>>h>>w>>n;
  r(i,w+1)s[0]+='@';
  r(i,h)cin>>s[i+1],s[i+1]='@'+s[i+1];
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++){
      r(k,3)dp[i][j][k]+=dp[i][j-1][k];
      if(s[i][j]=='J')dp[i][j][0]++;
      if(s[i][j]=='O')dp[i][j][1]++;
      if(s[i][j]=='I')dp[i][j][2]++;
    }
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      r(k,3)dp[i][j][k]+=dp[i-1][j][k];
  while(n--){
    cin>>a>>b>>c>>d;a--;b--;
    cout<<dp[c][d][0]-dp[a][d][0]-dp[c][b][0]+dp[a][b][0]<<' ';
    cout<<dp[c][d][1]-dp[a][d][1]-dp[c][b][1]+dp[a][b][1]<<' ';
    cout<<dp[c][d][2]-dp[a][d][2]-dp[c][b][2]+dp[a][b][2]<<endl;
  }
}

Measured memory_bytes: 19608
#include<iostream>
using namespace std;
int main()
{
  long long int i,n,m,s;
  cin>>n>>m;
  long long int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  s=0;
  int f=0;
  for(i=0;i<n;i++)
  {
    s=s+a[i];
    if(s>m)
    {
      cout<<i+1;
      f=1;
      break;
    }
  }
  if(f==0)
    cout<<n+1;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int h, w, n;
int sr, sc;
string s, t;
int sct[MN][4];
int tct[MN][4];

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

    cin >> h >> w >> n;
    cin >> sr >> sc;
    cin >> s >> t;
    int xl = 0, xr = h+1, yl = 0, yr = w+1;
    RFOR(i, n-1, 0){
        if(t[i] == 'U'){
            xr = min(xr+1, h+1);
        } else if(t[i] == 'D'){
            xl = max(xl-1, 0);
        } else if(t[i] == 'L'){
            yr = min(yr+1, w+1);
        } else if(t[i] == 'R'){
            yl = max(yl-1, 0);
        }
        //cout << xl << " " << xr << " " << yl << " " << yr << "\n";

        if(s[i] == 'U'){
            xl++;
        } else if(s[i] == 'D'){
            xr--;
        } else if(s[i] == 'L'){
            yl++;
        } else if(s[i] == 'R'){
            yr--;
        }

        //cout << xl << " " << xr << " " << yl << " " << yr << "\n";

        if(xl+1>=xr || yl+1>=yr) break;
    }

    if(sr <= xl || sr >= xr || sc <= yl || sc >= yr){
        cout << "NO\n";
    } else{
        cout << "YES\n";
    }

    /*FOR(i, 1, n){
        F0R(j, 4){
            sct[i][j] = sct[i-1][j];
            tct[i][j] = tct[i-1][j];
        }
        if(s[i] == 'L'){
            sct[i][0]++;
        } else if(s[i] == 'U'){
            sct[i][1]++;
        } else if(s[i] == 'R'){
            sct[i][2]++;
        } else if(s[i] == 'D'){
            sct[i][3]++;
        }

        if(t[i] == 'L'){
            tct[i][0]++;
        } else if(t[i] == 'U'){
            tct[i][1]++;
        } else if(t[i] == 'R'){
            tct[i][2]++;
        } else if(t[i] == 'D'){
            tct[i][3]++;
        }
    }*/

    return 0;
}


Measured memory_bytes: 920
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    vector<vector<long long>> bin(100, vector<long long>(100, 0));
    for (int i = 0; i < 100; ++i) {
        bin[i][0] = 1;
    }
    for (int i = 1; i < 100; ++i) {
        for (int j = 1; j < 100; ++j) {
            bin[i][j] = bin[i - 1][j - 1] + bin[i - 1][j];
        }
    }
    int n, a, b;
    cin >> n >> a >> b;
    vector<long long> v(n);
    map<long long, int> count;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        ++count[v[i]];
    }
    sort(v.begin(), v.end());
    long long sum = 0;
    map<long long, int> res;
    for (int i = 0; i < a; ++i) {
        sum += v[n - 1 - i];
        ++res[v[n - 1 - i]];
    }
    cout << fixed << setprecision(12) << double(sum) / a << '\n';
    long long bla = 1;
    if (res.size() == 1) {
        bla = 0;
        auto x = res.begin()->first;
        auto y = res.begin()->second;
        for (int i = y; i <= min(count[x], b); ++i) {
            bla += bin[count[x]][i];
        }
    }
    else {
        for (auto& p : res) {
            bla *= bin[count[p.first]][p.second];
        }
    }
    cout << bla << '\n';

    return 0;
}


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



int main(void){


	char W[11];
	char T[1001];
	char t[] = "END_OF_TEXT";
	int j,i;
	int count = 0;



	scanf("%s",W);

	for(i = 0;W[i] != '\0' ;i++){
	
			if(W[i] >= 'A' && W[i] <= 'Z'){
				W[i] += 32;
			
 
			}
	
	}

	while(1){

		
		scanf("%s",T);
		
		if(strcmp(T,t) == 0){
	
				break;
		}

	
	
		for(i = 0;T[i] != '\0' ;i++){
			
			if(T[i] >= 'A' && T[i] <= 'Z'){
				T[i] += 32;
			
 
			}

		}	
			




	

		j = strcmp(T,W);
	
		if(j == 0){
			count++;
		}


		

	}

	

		printf("%d\n",count);

return 0;



}

Measured memory_bytes: 548
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let k = read!(i64);
    let (a,b) = read!(i64,i64);
    for i in a..(b+1) {
        if i%k==0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}

fn run() {
    solve();
}


Measured memory_bytes: 2268
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n,m;
    cin>>n>>m;
    vvi ab(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    vi ans(n);
    vi used(n);
    
    queue<int>q;
    q.push(0);
    while(q.size()){
        int now=q.front();
        q.pop();
        used[now]=1;
        for(int x:ab[now]){
            if(used[x]==1)continue;
            used[x]=1;
            ans[x]=now+1;
            q.push(x);
        }
        //cout<<"aaa";
    }
    cout<<"Yes"<<endl;
    arep(i,1,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 10624
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 50;


void solve(string S){
    ll ans = INF;
    rep(i, S.length()-2){
        auto X = stoi(S.substr(i, 3));
        ans = min(ans, (ll)abs(X-753));
    }
    cout << ans << endl;
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

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

    ll sum = 0;
    REP(i, N) {
        int a = i + 1;
        if (a%5 != 0 && a%3 != 0) {
            sum += a;
        }
    }
    cout << sum << endl;
}


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

typedef long long ll;
ll N;
vector<ll> A, B, C;
ll R;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    A[i] = a - 1;
  }
  B.resize(N);
  for (ll i = 0; i < N; ++i) cin >> B[i];
  C.resize(N - 1);
  for (ll i = 0; i < N - 1; ++i) cin >> C[i];
  for (ll i = 0; i < N; ++i) R += B[A[i]];
  for (ll i = 0; i < N - 1; ++i) {
    if (A[i + 1] == A[i] + 1) R += C[A[i]];
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  bool judge=1;
  int N;
  cin>>N;
  for (int i=0; i<1000000; i++){
    if(N>=100*i&&N<=105*i){
      cout<<1<<endl;
      judge=0;
      break;
    }
  }
  if (judge){
    cout<<0<<endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
char s[maxx];

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	int ans = 1;
	for(int i = 2; i <= n; i++) {
		if(s[i] != s[i - 1]) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 764
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            return i, n//i
    return n, 1

from collections import Counter
mod = 10**9+7
n = int(input())
f = 1
d = Counter()
div = {}
for i in range(2,n+1):
    a,b = make_divisors(i)
    c,e = Counter(), Counter()
    if a > 1:
        c.update({a:1} if a not in div else div[a])
    if b > 1:
        e.update({b:1} if b not in div else div[b])
    div[i] = c + e
    d.update(div[i])

# print(d)
ans = 1
for v in d.values():
    ans = ans * (v+1) % mod
print(ans)

Measured memory_bytes: 3828
n = int(input())
*a, = map(int, input().split())
*b, = map(int, input().split())

knock = 0
ex = 0
for i in range(n):
    if a[i] < b[i]:
        ex = b[i] - a[i]
        knock += a[i]
    elif a[i] >= b[i]:
        ex = 0
        knock += b[i]

    if ex != 0:
        if a[i+1] < ex:
            knock += a[i+1]
            a[i+1] = 0
        else:
            a[i+1] -= ex
            knock += ex

print(knock)


Measured memory_bytes: 18380
r, g, b = map(int,input().split())
soma = 0

if 1 <= r <= 9 and 1 <= g <= 9 and 1 <= b <= 9:
    soma = r*100 + g*10 + b
    if soma%4 == 0:
        print('YES')
    else:
        print('NO')



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


int main() {

    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << ab*bc/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  	int i, n, even[100001]={0}, odd[100001]={0};
  	scanf("%d",&n);
  	for(i=0; i<n; i++){
      	if(i&1){ scanf("%d", &odd[i/2]); }
      	else   { scanf("%d", &even[i/2]); }
    }
  	if(n&1){
      for(i=(n-1)/2; i>=0; i--){ printf("%d ",even[i]); }
      for(i=0; i<n/2; i++){ printf("%d ", odd[i]); }
    }else{
      for(i=(n-1)/2; i>=0; i--){ printf("%d ", odd[i]); }
      for(i=0; i<n/2; i++){ printf("%d ",even[i]); }
    }
  	printf("\n");
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e5+5;
int n,q,a[maxn];
ll c[maxn];
void read(int& ret)
{
	ret=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();
}
ll ask(int u)
{
	ll ret=0;
	for(int i=u;i;i-=(i&(-i))) ret+=c[i];
	return ret;
}
void add(int u,int d)
{
	for(int i=u;i<=n;i+=(i&(-i))) c[i]+=d;
}
int main()
{
	read(n),read(q);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++) add(i,a[i]);
	while(q--){
		int type,u,v;
		read(type),read(u),read(v);
		if(!type) add(u+1,v);
		else printf("%lld\n",ask(v)-ask(u));
	}
	return 0;
}

Measured memory_bytes: 10192
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int l[10];
int v1,v2;
void solve() {

    int sum=0;
    rep(i,10) sum+=l[i];
    int v=v1+v2;
    double a = 1.0*sum/v;
    double b = a*v1;
    // cout<<b<<endl;
    rep(i,10) {
        if(b<=l[i]) {
            cout<<i+1<<endl;
            return;
        }
        b-=l[i];
    }
}
int main() {
    while(~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],
                &l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)) {

        solve();


    }
    return 0;
}

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

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

const int MMAX = 1<<21;
const int NMAX = 21;

const ll MOD = 1e9+7;

ll dp[NMAX+1][MMAX];
int N;
int a[NMAX][NMAX];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> N;
	for(int i=0;i<N;++i) {
		for(int j=0;j<N;++j) {
			cin >> a[i][j];
		}
	}
	dp[0][0] = 1;
	for(int i=0;i<N;++i) {
		for(int j=0;j<(1<<N);++j) {
			if(dp[i][j] == 0) continue;
			for(int k=0;k<N;++k) {
				if(!(j&(1<<k)) && a[i][k]) {
					dp[i+1][j|(1<<k)] = (dp[i+1][j|(1<<k)] + dp[i][j])%MOD;
				}
			}
		}
	}
	cout << dp[N][(1<<N)-1] << endl;
	return 0;
}


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

	using namespace std;
int main(void){

string odd, even,a;
  cin >> odd >> even;
  int e,o;
  e = even.size();
  o = odd.size();
  for(int i = 0; i < e + o; i++)
  {
  if(i % 2 == 0){
      a+= odd[i / 2];
    }
    else{
      a += even[(i - 1) / 2];
  }}
	cout<<a<<endl;
 return 0; 
 }
  


Measured memory_bytes: 256
w = sorted(list(input()))
w_l = []
for i in range(0,len(w)):
    w_l.append(w[i])
    try:
        if w[i] != w[i+1]:
            w_l.append(" ")
    except:
        pass
w_l = "".join(w_l).split()
for j in w_l:
    if len(j)%2 == 0:
        continue
    else:
        print("No")
        exit()
print("Yes")

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 2e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    int sum = 0;
    int m = INF;
    REP(i, N)
    {
        int s; cin >> s;
        sum += s;
        if(s % 10 != 0) m = min(m, s);
    }
    if(m == INF) cout << 0 << endl;
    else if(sum % 10 != 0) cout << sum << endl;
    else cout << sum - m << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication34
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int w = int.Parse(Console.ReadLine());
                if (w == 0) break;
                List<int> s = new List<int>(); int r, l = int.MinValue;
                for(int x=0;x<w;x++)
                {
                    int a = int.Parse(Console.ReadLine());
                    s.Add(a);
                }
                for (int b = 0; b < s.Count; b++)
                {
                    r = 0;
                    for (int c = b; c < s.Count; c++)
                    {
                        r += s[c];
                        if (r > l) { l = r; }
                    }
                }
                Console.WriteLine(l);
            }
        }
    }
}

Measured memory_bytes: 9332
#include<iostream>
#include<string>
#include<queue>
using namespace std;

typedef struct process {
	string name;
	int time;
} Prc;
int main() {
	int n, q;
	Prc p;
	queue<Prc> Q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> p.name >> p.time;
		Q.push(p);
	}
	long long T = 0;
	while (!Q.empty()) {
		if (Q.front().time > q) {
			T += q;
			p.name = Q.front().name;
			p.time = Q.front().time - q;
			Q.pop();
			Q.push(p);
		}
		else {
			T += Q.front().time;
			cout << Q.front().name << " " << T << endl;
			Q.pop();
		}
	}
}


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

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;
	for (int i = 0;i < dx;i++) {
		cout << 'R';
	}
	for (int i = 0;i < dy;i++) {
		cout << 'U';
	}
	for (int i = 0;i < dx;i++) {
		cout << 'L';
	}
	for (int i = 0;i < dy;i++) {
		cout << 'D';
	}

	cout << 'D';
	for (int i = 0;i < dx + 1;i++) {
		cout << 'R';
	}
	for (int i = 0;i < dy + 1;i++) {
		cout << 'U';
	}
	cout << "LU";
	for (int i = 0;i < dx + 1;i++) {
		cout << 'L';
	}
	for (int i = 0;i < dy + 1;i++) {
		cout << 'D';
	}
	cout << 'R';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n); r(m);
    while(m--){
        int a; r(a);
        n-=a;
    }
    if(n<=0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))
S = input()
 
a = 0
b = 0
for s in S:
    if s == 'a':
        if a + b < A + B:
            print('Yes')
            a += 1
        else:
            print('No')
    elif s == 'b':
        if (a + b < A + B) and b < B:
            print('Yes')
            b += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 9212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
    {
    static void Main(string[] args)
        {
        int N_length=int.Parse(System.Console.ReadLine());
        long[] A = new long[N_length];
        long[] B = new long[N_length];
        long[] C = new long[N_length];
        for (int j = 0; j < N_length; j++)
        {
            string[] input = System.Console.ReadLine().Split(' ');
            A[j] = long.Parse(input[0]);
            B[j] = long.Parse(input[1]);
            C[j] = A[j] + B[j];
        }
        Array.Sort(C);
        Array.Reverse(C);
        long ans = C.Where((value, index) => index % 2 == 0).Sum() - B.Sum();
        System.Console.WriteLine(ans);
    }
    }


Measured memory_bytes: 17604
#include<iostream>
#include <algorithm>
#include<cmath>
using namespace std;
int main()
{
	double n;
	int w[100];
	double sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		sum += w[i];
	}
	double nowsum = 0;
	double ans = 100000;
	nowsum = w[0];
	for (int i = 1; i < n-1; i++)
	{
		nowsum += w[i];
		if (fabs((sum/2) - nowsum) < fabs(ans))
		{
			ans = fabs((sum/2) - nowsum);
			//cout << i << "," << sum<<","<<nowsum<<","<<abs((sum/2) - nowsum) << endl;
		}
	}
	cout << ans*2 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int a,b,c;
  cin >> a >> b>> c;
  cout << c<<" " << a << " " << b << endl;
  
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,x;
  cin>>n>>m>>x;
  int asc=0,desc=0;
  vector<int> ms(m);
  for(int i=0;i<m;i++){cin>>ms.at(i);}
  for(int i=0;i<x;i++){
    for(int j=0;j<m;j++){if(ms.at(j)==i){desc++;}}
  }
  for(int i=x+1;i<n;i++){
    for(int j=0;j<m;j++){if(ms.at(j)==i){asc++;}}
  }
  cout<<min(desc,asc)<<endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template <typename T,typename E>
struct SegmentTree{
    using F = function<T(T,T)>;
    using G = function<T(T,E)>;
    using H = function<E(E,E)>;
    int n,height;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    vector<T> dat;
    vector<E> laz;
    SegmentTree(F f,G g,H h,T ti,E ei):
    f(f),g(g),h(h),ti(ti),ei(ei){}
    
    void init(int n_){
        n=1;height=0;
        while(n<n_) n<<=1,height++;
        dat.assign(2*n,ti);
        laz.assign(2*n,ei);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    inline T reflect(int k){
        return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
    }
    inline void eval(int k){
        if(laz[k]==ei) return;
        laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
        laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=ei;
    }
    inline void thrust(int k){
        for(int i=height;i;i--) eval(k>>i);
    }
    inline void recalc(int k){
        while(k>>=1)
            dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
    }
    void update(int a,int b,E x){
        thrust(a+=n);
        thrust(b+=n-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1) laz[l]=h(laz[l],x),l++;
            if(r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a);
        recalc(b);
    }
    void set_val(int a,T x){
        thrust(a+=n);
        dat[a]=x;laz[a]=ei;
        recalc(a);
    }
    T query(int a,int b){
        thrust(a+=n);
        thrust(b+=n-1);
        T vl=ti,vr=ti;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,reflect(l++));
            if(r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
};

int main(){
    ll n;
    cin>>n;
    const ll MX=110000;
    using P = pair<ll, ll>;
    auto f=[](P a,P b){return max(a,b);};
    auto g=[](P a,P b){return max(a,b);};
    auto h=[](pll a,pll b){return max(a,b);};
    SegmentTree<P,pll> T(f,g,h,P(0,0),pll(0,0));
    T.build(vector<P>(MX,P(0,0)));
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    for(auto &I:a){
        pll w=T.query(0,I);
        w.F++;
        w.S+=I;
        T.update(I,I+1,w);
    }
    cout<<T.query(0,MX).S<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 12860
function Main (N) {
  N = parseInt(N, 10);
  var ans = 0;
  for (var i = 1; i <= N; i++) {
    if (i%3 != 0 && i%5 != 0) {
      ans += i
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll K;
  cin >> K;

  deque<pair<ll, ll>> Q;
  vector<ll> dist(K, -1);
  Q.push_front(make_pair(1, 1));
  while (!Q.empty())
  {
    ll v = Q.front().first, w = Q.front().second;
    Q.pop_front();

    if (dist.at(v) != -1)
      continue;
    dist.at(v) = w;

    ll nv0 = (v * 10) % K;
    ll nv1 = (v + 1) % K;

    Q.push_front(make_pair(nv0, dist.at(v)));
    Q.push_back(make_pair(nv1, dist.at(v) + 1));

    //cerr << v << " " << nv0 << " " << nv1 << endl;
  }

  ll ans = dist.at(0);
  cout << ans << endl;

  /*
  for (ll i = 0; i < K; i++)
  {
    cerr << i << " " << dist.at(i) << endl;
  }
  */
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

using ull = unsigned long long;
constexpr int MAX = 4000;
constexpr ull B = 100000007ULL;

vector<vector<int>> make(const string& str)
{
    int N = str.size();
    vector<vector<int>> cnt(N + 1, vector<int>(26));
    for (int i = 0; i < N; i++) {
        cnt[i + 1][str[i] - 'a']++;
        for (int j = 0; j < 26; j++) {
            cnt[i + 1][j] += cnt[i][j];
        }  
    }
    return cnt;
}

ull get_hash(int len, int s,
             const vector<vector<int>>& cnt)
{
    auto l = cnt[s];
    auto r = cnt[s + len];
    
    ull res = 1;
    for (int i = 0; i < 26; i++) {
        res = res * B + (r[i] - l[i]);
    }
    return res;
}

int main()
{
    string S, T;
    cin >> S >> T;
    
    if (S.size() < T.size()) swap(S, T);

    int s = S.size(), t = T.size();
    
    auto sc = make(S);
    auto tc = make(T);
    
    vector<ull> vec[MAX + 1];
    for (int i = s; i >= 1; i--) {
        for (int j = 0; j <= s - i; j++) {
            vec[i].emplace_back(get_hash(i, j, sc));
        }
        sort(vec[i].begin(), vec[i].end());
        vec[i].erase(unique(vec[i].begin(), vec[i].end()), vec[i].end());
    }    
    
    int res = 0;
    for (int i = t; i >= 1; i--) {
        for (int j = 0; j <= t - i; j++) {
            if (binary_search(vec[i].begin(), vec[i].end(), get_hash(i, j, tc))) {
                res = max(res, i);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78044
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(n, h, w);
	int cnt = 0;
	FOR (i, 1, n)
	    FOR (j, 1, n)
	        if (i + h - 1 <= n && j + w - 1 <= n) cnt++;
	        
	        print(cnt);
}



















Measured memory_bytes: 256
import math


def f2(n):
    d = 0
    c = 0
    for i in range(1, n):
        e = 0
        if i * i == n:
            e -= 1
        elif n % i == 0:
            e -= 1
        e += n // i
        d += e

    return d

def main():
    print(f2(int(input())))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
import math
N = int(input())
A = [0 for _ in range(N)]
for x in range(1,math.floor(N**0.5)+1):
    for y in range(1,math.floor((N-x**2)**0.5)+1):
        for z in range(1,math.floor((N-x**2-y**2)**0.5)+1):
            c = x**2+y**2+z**2+x*y+y*z+z*x
            if c <= N:
                A[c-1] += 1
for i in range(N):
    print(A[i])

Measured memory_bytes: 9452
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
#include <thread>
#include <fstream>

using namespace std;

//const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 200500; //       e5
//const int SZ = 122;

long long a[MX];
vector<int> e[MX];
int n;

vector<int> go(int u){
    vector<int> d(n, n);
    list<int> sp;
    sp.push_back(u);
    while(sp.begin() != sp.end()){
        u = sp.front();
        sp.pop_front();
        for(int i = 0; i < e[u].size(); i++){
            int v = e[u][i];
            if(d[v] == n){
                d[v] = d[u] + 1;
                sp.push_back(v);
            }
        }
    }
    return d;
}

int main()
{
    //epic(); return 0;
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    cin >> n;
    for(int i =0 ; i < n - 1; i++){
        int u, v;
        cin >> u >> v; u--; v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    auto d1 = go(0);
    auto d2 = go(n - 1);

    int s = 0;
    for(int i = 0; i < n; i++){
        if(d1[i] <= d2[i]) s++; else s--;
    }
    if(s > 0) cout << "Fennec"; else cout << "Snuke";
    cout << endl;

    return 0;
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(){

	int n,a[1000];

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int j=n-1;j>0;j--){
		cout<<a[j]<<" ";
	}
	cout<<a[0]<<endl;

return 0;
}



Measured memory_bytes: 3132
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
    now = int(s[0])
    cou = 0
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            cou += now
            now = int(s[j+1])
        elif (i >> j) & 1 == 0:
            now = now*10 + int(s[j+1])
    ans += cou + now
print(ans)

Measured memory_bytes: 3064
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 10/06/2017 12:09:54
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ull unsigned long long
using namespace std;

int main(){
	map<string, int> mapp;
	int n;
	cin>>n;
	int x;
	for(int i = 0; i < n; i++){
		cin>>x;
		if( x <= 399) mapp["gray"]++;
		else if(x <= 799) mapp["brown"]++;
		else if(x <= 1199) mapp["green"]++;
		else if(x <= 1599) mapp["cyan"]++;
		else if(x <= 1999) mapp["blue"]++;
		else if(x <= 2399) mapp["yellow"]++;
		else if(x <= 2799) mapp["orange"]++;
		else if(x <= 3199) mapp["red"]++;
		else mapp["any"]++;
	}
	int sum = 0;
	
		if(mapp["gray"]) sum++;
		if(mapp["brown"]) sum++;
		if(mapp["green"]) sum++;
		if(mapp["cyan"]) sum++;
		if(mapp["blue"]) sum++;
		if(mapp["yellow"]) sum++;
		if(mapp["orange"]) sum++;
		if(mapp["red"]) sum++;
	if(sum == 0){
		cout<<1<<" ";
	}
	else cout<<sum<<" ";
	cout<<sum+mapp["any"]<<endl;
	return 0;
	
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

int H, W;
std::string S[30];
int d[30][30];

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

  std::cin >> H >> W;

  for(int i=0;i<H;++i){
      std::cin >> S[i];
  }

  int mx = 0;

  for(int i=0;i<H;++i){
      for(int j=0;j<W;++j){
          if(S[i][j] == '#'){
              continue;
          }

          memset(d, -1, sizeof(d));
          d[i][j] = 0;

          std::queue<P> que;
          que.emplace(i, j);

          until(que.empty()){
              int y, x;
              std::tie(y, x) = que.front();
              que.pop();

              for(int k=0;k<4;++k){
                  int ny = y + dy[k], nx = x + dx[k];
                  if(ny < 0 || ny >= H || nx < 0 || nx >= W){
                      continue;
                  }

                  if(S[ny][nx] == '#' || d[ny][nx] >= 0){
                      continue;
                  }

                  d[ny][nx] = d[y][x] + 1;
                  mx = std::max(mx, d[ny][nx]);
                  que.emplace(ny, nx);
              }
          }
      }
  }

  std::cout << mx << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int partition(int A[], int p, int r);
void swap(int &a, int &b);
int main(void)
{
	int n, i;
	cin >> n;
	int A[n];
	for (i = 0; i < n; i++)
		cin >> A[i];
	int flag = partition(A, 0, n-1);
	for (i = 0; i < n; i++)
	{
		if (i == flag)
			cout << "[" << A[i] << "] ";
		else if (i != n - 1)
			cout << A[i] << " ";
		else
			cout << A[i];
	}
	cout << endl;
	return 0;
}

int partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p - 1;
	int j;
	for (j = p; j < r; j++)
	{
		if (A[j] <= x)
		{
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}
void swap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
}


Measured memory_bytes: 3476
k,t = map(int, input().split())
lis = list(map(int, input().split()))

m = max(lis)
lis = sorted(lis)

if lis[-1:]:
    pass

if sum(lis[:-1]) >= m:
    print(0)
else:
    print(m-1-sum(lis[:-1]))


Measured memory_bytes: 9072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

struct edge{
  int to,id;
};
vector<vector<edge> > g;
vector<int> ans;

void dfs(int v,int p=-1,int c=-1){
  int k=1;
  rep(i,g[v].size()){
    int nv=g[v][i].to;
    int ei=g[v][i].id;
    if(nv==p) continue;
    if(k==c) k++;
    ans[ei]=k;
    dfs(nv,v,k);
    k++;
  }
}

int main(){
  int N; cin >> N;
  g.resize(N);
  ans.resize(N-1);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(edge{b,i});
    g[b].push_back(edge{a,i});
  }
  dfs(0);
  int mx=0;
  rep(i,N){
    chmax(mx,int(g[i].size()));
  }
  cout << mx << endl;
  rep(i,N-1){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,a,b,k;
long long ans;
long long mul[300005],inv[300005];


long long ksm(long long a,long long x){
	long long ans=1;
	while(x){
		if(x%2==1) ans=ans*a%mod;
		a=a*a%mod;
		x/=2;
	}
	return ans;
}

long long C(long long m,long long n){
	if(m<n) return 0;
	return mul[m]*inv[n]%mod*inv[m-n]%mod;
}

int main(){
	cin>>n>>a>>b>>k;
	
	mul[0]=inv[0]=1;
	for(long long i=1;i<=n;i++) mul[i]=mul[i-1]*i%mod;
	inv[n]=ksm(mul[n],mod-2);
	for(long long i=n-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
	
	for(long long i=0;i<=n && i*a<=k;i++){
		if((k-i*a)%b==0){
			long long j=(k-i*a)/b;
			ans=(ans+C(n,i)*C(n,j))%mod;
		}
	}
	cout<<ans;
	cout<<endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

    private static int n;
    private static int[] a;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();

        int q = sc.nextInt();
        int[] m = new int[q];
        for (int i = 0; i < q; i++) m[i] = sc.nextInt();

        for (int i = 0; i < q; i++) {
            if (solve(0, m[i]))
                System.out.println("yes");
            else
                System.out.println("no");
        }

    }

    private static boolean solve(int i, int m) {
        if (m == 0) return true;
        if (i >= n) return false;
        return solve(i + 1, m) || solve(i + 1, m - a[i]);
    }
}



Measured memory_bytes: 26872
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  s=input()
  if 'AC'==s:
    ac+=1
  if 'WA'==s:
    wa+=1
  if 'TLE'==s:
    tle+=1
  if 'RE'==s:
    re+=1

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

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

int main(){
    int N,sum = 0;
    cin >> N;
    vector<int>vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if (i < j){
                sum += vec.at(i)*vec.at(j);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main()
{
    while(~scanf("%s", str))
    {
        int len = strlen(str), cnt0 = 0, cnt1 = 0;
        for(int i = 0 ; i < len; i++)
            if(str[i] == '0') cnt0++;
            else cnt1++;
        printf("%d\n", min(cnt0, cnt1)*2);
    }
    return 0;
}

Measured memory_bytes: 384
dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]
dY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]
def solve(x,y,XY):
	xy = XY[:]
	if len(xy) == 0: return True
	sx,sy = xy.pop(0),xy.pop(0)
	for dx,dy in zip(dX,dY):
		if doa(x+dx,y+dy,sx,sy): 
			r = solve(x+dx,y+dy,xy)
			if r: return r

def doa(x,y,sx,sy):
	if not (0 <= x <= 9 and 0 <= y <= 9): return False
	return True if abs(x-sx) < 2 and abs(y-sy) < 2 else False

while 1:
	x,y = map(int,raw_input().split())
	if x == y == 0: break
	n = input()
	xy = map(int,raw_input().split())
	print "OK" if solve(x,y,xy) else "NA"

Measured memory_bytes: 4268
from sys import stdin
from sys import setrecursionlimit
from itertools import accumulate
import bisect

n,m,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))

aa = [0]+list(accumulate(a))
bb = [0]+list(accumulate(b))
ma = 0

for i,j in  enumerate(aa):
    if j > k:
        break
    nowa = i
    nowb = bisect.bisect(bb,k-j)-1
    ma = max(ma,nowa+nowb)

print(ma)

Measured memory_bytes: 132740