akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;

namespace io {
#define gc() (iS == iT ? (iT = (iS = ibuff) + fread(ibuff, 1, SIZ, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
	const int SIZ = 1 << 21 | 1;
	char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS = obuff, *oT = oS + SIZ - 1, fu[110], c;
	int fr;
	inline void out() {
		fwrite(obuff, 1, oS - obuff, stdout);
		oS = obuff;
	}
	template<class Type>
	inline void read(Type &x) {
		x = 0;
		Type y = 1;
		for (c = gc(); (c > '9' || c < '0') && c != '-'; c = gc());
		c == '-' ? y = -1 : x = (c & 15);
		for (c = gc(); c >= '0' && c <= '9'; c = gc())
			x = x * 10 + (c & 15);
		x *= y;
	}
	template<class Type>
	inline void print(Type x, char text = '\n') {
		if (x < 0)
			*oS++ = '-', x *= -1;
		if (x == 0)
			*oS++ = '0';
		while (x)
			fu[++fr] = x % 10 + '0', x /= 10;
		while (fr)
			*oS++ = fu[fr--];
		*oS++ = text;
		out();
	}
}
using namespace io;
#define ll long long
using namespace std;
const int maxn = 1e5 + 5;

vector<int> g[maxn];
int mx[maxn], n, col[maxn], q, d[maxn], ch[maxn], m, p[maxn];

void dfs(int x) {
	if (!col[x])
		col[x] = ch[q];
	for (int i : g[x])
		if (mx[x] - 1>mx[i])
			mx[i] = mx[x] - 1, dfs(i);
}

int main() {
	memset(mx, -1, sizeof(mx));
	read(n), read(m);
	for (int i = 1, uu, vv; i <= m; i++)
		read(uu), read(vv), g[uu].push_back(vv), g[vv].push_back(uu);
	read(q);
	for (int i = 1; i <= q; i++)
		read(p[i]), read(d[i]), read(ch[i]);
	for (; q; q--)
		if (d[q]>mx[p[q]]) mx[p[q]] = d[q], dfs(p[q]);
	for (int i = 1; i <= n; i++)
		print(col[i]);
	return 0;
}

Measured memory_bytes: 12536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

template<typename T>
struct BinaryIndexedTree {
  int N;
  vector<T> data;
 
  BinaryIndexedTree(int sz) : N(sz), data(sz+1,0) {}
 
  T sum(int k) { // [0,k) (0-indexed) a[0] + … + a[k-1]
    T ret = 0;
    for(; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
 
  T sum(int l, int r) { // [l,r) (0-indexed) a[l] + …　+ a[r-1]
    T vl = sum(l);
    T vr = sum(r);
    return vr - vl;
  }
 
  void add(int k, T x) { // (0-indexed) a[k] += x;
    for(++k; k <= N; k += k & -k) data[k] += x;
  }
 
  int lowerbound(T x) { // (0-indexed)
    int k = 1;
    int ret = 0;
    while ((k<<1) <= N) k <<= 1;
    while (k > 0) {
      if (ret + k <= N && data[ret+k] < x) {
        x -= data[ret+k];
        ret += k;
      }
      k >>= 1;
    }
    return ret;
  }
 
  int upperbound(T x) { // (0-indexed)
    ++x;
    int k = 1;
    int ret = 0;
    while ((k<<1) <= N) k <<= 1;
    while (k > 0) {
      if (ret + k <= N && data[ret+k] < x) {
        x -= data[ret+k];
        ret += k;
      }
      k >>= 1;
    }
    return ret;
  }
};

template<typename T>
vector<T> compress(vector<T> A){
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    return A;
}
/*
  vector<int> as, comp(n);
  as = compress(a);
  int sz=as.size();
  rep(i,n){ comp[i] = lower_bound(as.begin(), as.end(), a[i]) - as.begin(); }
*/  

int main(){
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n,0);
  rep(i,n) cin >> a[i];
  vector<ll> r(n+1,0);
  rep(i,n){
    r[i+1] = r[i] + a[i] - k;
  }
  vector<ll> z = compress(r);
  vector<int> comp(n+1);
  rep(i,n+1){ comp[i] = lower_bound(z.begin(), z.end(), r[i]) - z.begin(); }

  BinaryIndexedTree<int> bt(n+2);
  ll ans = 0;
  rep(i,n+1){
    ans += bt.sum(0,comp[i]+1);
    bt.add(comp[i],1);
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 22;

int N, M, C;
int A[MAX], B[MAX];

int main() {
    cin >> N >> M >> C;
    REP (i, M) cin >> B[i];
    int ans = 0;
    REP (n, N) {
        int val = C;
        REP (i, M) cin >> A[i];
        REP (i, M) val += A[i] * B[i];
        if (val > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		char op = in.next().charAt(0);
		int m = in.nextInt();
		if (op == '+') {
			out.println(n + m);
		} else {
			out.println(n - m);
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 22996
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> a(n);
  bool zero = false;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] == 0) zero = true;
  }
  if (zero) {
    puts("0");
    return 0;
  }
  int64 bound = 1e18;
  int64 ret = 1;
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if (ret > bound / a[i]) {
      found = true;
      break;
    }
    ret *= a[i];
  }
  if (found) {
    puts("-1");
  } else {
    printf("%lld\n", ret);
  }
  return 0;
}


Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();
        int n = sc.nextInt();
        var p = new int[n];
        for (int i = 0; i < n; i++)
            p[i] = sc.nextInt();

        int t = 0;
        for (int i = 0; i < n; i++)
        {
            if (t == 2 && p[i] != i + 1)
            {
                t = 3;
                break;
            }
            else if (p[i] != i + 1)
            {
                t++;
            }
        }
        if (t == 1 || t == 3) Console.WriteLine("NO");
        else Console.WriteLine("YES");
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;


signed main(void){
    int n;
    scanf("%lld", &n);
    vector <int> a;
    int mae=0;
    int cnt = 0;
    rep(i,n){
        int c; scanf("%lld", &c);
        if(mae==c) continue;
        else {a.push_back(c); mae = c; cnt++;}
    }
    n = cnt;
    vector <int> dp(200005), dp2(200005,0); dp[0] = 1;
    vector <vector<int>> rock(200005,vector <int>());
    
    for(int i=0;i<n;i++){
        dp[i+1] = dp[i];
        int x = rock[a[i]].size();
        dp[i+1] += dp2[a[i]];
        dp2[a[i]] += dp[i];
        dp[i+1]%=MOD;
        rock[a[i]].push_back(i);
    }
    printf("%lld", dp[n]%MOD);
}


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

int main(){
	int H, W, K, i, j, k, l;
	scanf("%d%d%d", &H, &W, &K);
	vector<string> s(H);
	for(i = 0; i < H; i++){
		cin >> s[i];
	}
	vector<vector<int>> a(H, vector<int>(W, -1));
	int count = 0;
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(s[i][j] == '#'){
//				printf("(i, j) = (%d, %d)\n", i, j);
				count++;
//				printf("count = %d\n", count);
				for(k = i; k >= 0 && a[k][j] == -1; k--){
					for(l = j; l >= 0 && a[k][l] == -1; l--){
						a[k][l] = count;
					}
				}
				int f = 1;
				for(k = j + 1; k < W; k++){
					if(s[i][k] == '#'){
						f = 0;
					}
				}
//				printf("f = %d\n", f);
				if(f == 1 && j < W - 1){
					for(k = i; k >= 0 && a[k][j + 1] == -1; k--){
						for(l = j + 1; l < W; l++){
							a[k][l] = count;
						}
					}
				}
			}
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(a[i][j] == -1){
				a[i][j] = a[i - 1][j];
			}
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			printf("%d ", a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll a,b,c,k;
ll pos;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>k;
	c=gcd(a,b);
	for(int i=c;i>0;i--){
		if(c%i==0)pos++;
		if(pos==k){
			cout<<i;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
S = input()

N = len(S)-1
sumsum = 0


for i in range(2**N):
    binary = bin(i)
    binary = binary[2:].zfill(N)
    
    tmps = S[0]
    for j in range(N):
        if binary[j] == '0':
            tmps = tmps + S[j+1] 
        else :
            sumsum += int(tmps)
            tmps = S[j+1]

    sumsum += int(tmps)

if N == 0:
    sumsum = int(S)

print(sumsum)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long int;

int main (void) {
  int N, M;
  cin >> N >> M;

  vector<int> s(N - 1);

  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a == 0 || b == 0) {
      if (a == 0) {
        s[b - 1]++;
      } else {
        s[a - 1]++;
      }
    } else {
      s[a - 1]++;
      s[b - 1]++;
    }
  }

  REP(i, N - 1) {
    if (s[i] % 2 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  Int x,y;
  {
    Int a=-1,b=-1;
    function<void(Int,Int,Int)> dfs=[&](Int v,Int p,Int d){
      //cout<<v<<" "<<p<<" "<<d<<endl;
      if(b<d) a=v,b=d;
      for(Int u:G[v])
	if(u!=p) dfs(u,v,d+1);
    };
    dfs(0,-1,0);
    x=a;a=-1;b=-1;
    dfs(x,-1,0);
    y=a;
  }
  //cout<<x<<" "<<y<<endl;

  vector<Int> ans(n,n);
  vector<Int> dp(n,-1);
  
  Int ok;
  function<void(Int,Int)> dfs=[&](Int v,Int p){
    if(p<0) ok=1;
    dp[v]=0;
    Int cnt=0;
    for(Int u:G[v]){
      if(u==p) continue;
      dfs(u,v);
      chmax(dp[v],dp[u]);
      if(dp[u]>1) cnt++;
    }
    ok&=cnt<=1;
    dp[v]++;
  };

  vector<Int> tmp;
  Int idx;
  function<void(Int,Int)> dfs2=[&](Int v,Int p){
    if(p<0) tmp.clear(),idx=0;
    Int nv=-1;
    Int cur=idx++,cnt=0;
    for(Int u:G[v]){
      if(u==p) continue;
      cnt++;
      if(nv<0||dp[u]!=1) nv=u; 
    }
    if(~nv) cnt--;
    for(Int i=0;i<cnt;i++) tmp.emplace_back(idx++);
    tmp.emplace_back(cur);
    if(~nv) dfs2(nv,v);
  };

  dfs(x,-1);
  if(ok) dfs2(x,-1);
  chmin(ans,tmp);
  
  dfs(y,-1);
  if(ok) dfs2(y,-1);
  chmin(ans,tmp);
  
  if(ans[0]==n) cout<<-1<<endl;
  else{
    for(Int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<ans[i]+1;
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 18788
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,mx,i,sum=0,x;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    x=a[0];
    sum++;
    for(i=1;i<n;i++){
        if(a[i]>=x){
            sum++;
            x=a[i];
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <functional>

int N, H;
int b[100000];

int main(){
        scanf("%d %d",&N,&H);
        int a;
        int maxa = 0;
        for(int i = 0; i < N; i++){
                scanf("%d %d",&a,b+i);
                if(maxa < a){ maxa = a;}
        }

        std::sort(b,b+N,std::greater<int>());
        int cnt=0;
        int bind = 0;
        while(H > 0 && b[bind] >= maxa && bind != N){ 
                cnt++; H -= b[bind++];
        }
        if(H > 0){
                cnt += H/maxa;
                cnt += (H%maxa==0)?0:1;
        }

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

}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(void)
{
	int H,W;
	int i,j;

	while (1) {
		cin >> H;
		cin >> W;

		if ((H==0) && (W==0)) {
			break;
		}

		for (i = 0; i < H; i++) {
			for ( j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;


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


bool inRange(int a, int x, int b){
	return (a <= x && x <= b);
}

int Check(vector<vector<vector<int> > > &cube, int &n, int &m){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				int p = cube[i][j][k];
				if(p == 0) continue;
//				cout<< i<< " "<< j<< " "<< k<< " "<< p<< endl;
				for(int a=0;a<13;a++){
					int i2 = i + (m-1) * dx[a];
					int j2 = j + (m-1) * dy[a];
					int k2 = k + (m-1) * dz[a];
					if(inRange(0, i2, n-1) && inRange(0, j2, n-1) && inRange(0, k2, n-1)){
						bool flag = true;
						for(int b=0;b<m;b++){
							int q = cube[i + b*dx[a]][j + b*dy[a]][k + b*dz[a]];
							if(q != p){
								flag = false;
								break;
							}
						}
						if(flag) return p;
					}
				}
			}
		}
	}
	return 0;
}



bool solve(){
	int n, m, p;
	cin>> n>> m>> p;
	if(n==0 && m==0 && p==0) return false;
//	cout<< endl; cout<< n<< " "<< m<< " "<< p<< endl;
	
	vector<vector<vector<int> > > cube(n, vector<vector<int> >(n, vector<int>(n, 0) ) );
	int turn = -1;
	int ans1 = 0, ans2 = -1;
	for(int i=0;i<p;i++){
		int x, y;
		cin>> x>> y;
		x = x-1; y = y-1;
		for(int j=0;j<n;j++){
			if(cube[j][y][x] == 0){
				cube[j][y][x] = turn;
				break;
			}
		}
		
		if(ans1 == 0){
			ans1 = Check(cube, n, m);
			if(ans1 != 0) ans2 = i+1;
		}
		turn *= -1;
	}
	
/*	for(int i=n-1;i>=0;i--){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				cout<< " "<< cube[i][j][k];
			}
			cout<< endl;
		}
		cout<< endl;
	}
*/	
	if(ans1){
		cout<< ((ans1 == 1) ? "White" : "Black")<< " "<< ans2<< endl;
	}else{
		cout<< "Draw"<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());
	return 0;
}

 

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N, K; cin >> N >> K;
  vector<int> cnt(10, 0);
  rep(i, K) {
    int d; cin >> d;
    cnt[d]++;
  }

  for (int i = N;; ++i) {
    bool can_find = false;
    int tmp = i;
    while (tmp) {
      int digit = tmp%10;
      if (cnt[digit] == 1) {
        can_find = true;
        break;
      }
      tmp/=10;
    }
    if (can_find) continue;

    cout << i << endl;
    return 0;
  }

}

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

int main(){
    int A[3];
    REP(i, 3) cin >> A[i];

    sort(A, A + 3);
    if(A[0] == 5 and A[1] == 5 and A[2] == 7){
        cout << "YES" << endl;
    }else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 10;
int arr[M];
int gcd(int a, int b) {
	return a % b == 0 ? b : gcd(b, a%b);
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++)
		cin >> arr[i];
	sort(arr, arr + n+1);
	int ans;
	ans = arr[1] - arr[0];
	for (int i = 2; i <= n; i++) {
		ans = min(ans,gcd(arr[i] - arr[i - 1], ans));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 
int n,m,r;
const int INF=1e7;
int d[2][200][200],z[1000];
typedef pair<int,int> P;
 
int main(){
 
 
    while(scanf("%d %d",&n,&m),n){
	    
	   for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;
		  d[0][i][i]=d[1][i][i]=0;
	   }
	    
	   for(int i=0;i<m;i++){
		  int x,y,t;
		  char c;
		  scanf("%d %d %d %c",&x,&y,&t,&c);
		  x--; y--;
		  
		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);
		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);
	   }
	    
	   for(int k=0;k<n;k++){
		  for(int i=0;i<n;i++){
			 for(int j=0;j<n;j++){
				d[0][i][j]=min(d[0][i][j],d[0][i][k]+d[0][k][j]);
				d[1][i][j]=min(d[1][i][j],d[1][i][k]+d[1][k][j]);
			 }
		  }
	   }
	    
	   scanf("%d",&r);
	   for(int i=0;i<r;i++){
		  scanf("%d",&z[i]);
		  z[i]--;
	   }
	    
	   vector<vector<int> > dp(1000,vector<int>(200,INF));
	   dp[0][z[0]]=0;
 
	   int res=INF;
	   for(int i=1;i<r;i++){
		  for(int j=0;j<n;j++){
						    
			 for(int k=0;k<n;k++){
				dp[i][k]=min(dp[i][k],dp[i-1][j]+d[1][z[i-1]][j]+d[0][j][k]+d[1][k][z[i]]);
				if(i==r-1 && res>dp[i][k]) res=dp[i][k];
			 }
			 dp[i][j]=min(dp[i][j],dp[i-1][j]+d[1][z[i-1]][z[i]]);
			 if(i==r-1 && res>dp[i][j]) res=dp[i][j];
		  }
	   }
 
	   printf("%d\n",res);
	    
    }
}

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

using namespace std;

long long n, k, q, a[100005], b[100005];

int main () {
	cin >> n >> k >> q;
	for(int i = 1; i <= n; i++) {
		b[i] = k - q;
	}
	for(int i = 1; i <= q; i++) {
		cin >> a[i];
		b[a[i]] += 1;
	}
	for(int i = 1; i <= n; i++) {
		if(b[i] > 0) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

ll dp[110][5][5][5];

int main(){
  int n;
  cin >> n;
  dp[0][0][0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 5; j ++){
      for(int k = 0; k < 5; k++){
        for(int l = 0; l < 5; l++){
          for(int m = 1; m < 5; m++){
            if(k == 1 && l == 3 && m == 2) continue;
            if(j == 1 && l == 3 && m == 2) continue;
            if(k == 3 && l == 1 && m == 2) continue;
            if(k == 1 && l == 2 && m == 3) continue;
            if(j == 1 && k == 3 && m == 2) continue;
            dp[i+1][k][l][m] = dp[i+1][k][l][m] + dp[i][j][k][l];
            dp[i+1][k][l][m] %= MOD;
          }
        }
      }
    }
  }

  ll ans = 0;
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 5; k++){
        ans  += (dp[n][i][j][k])%MOD;
      }
    }
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
try:
    N = int(input())
    
    if N>=1 and N<=10000:
        if N % 1000 == 0:
            print(0)
        else:
            integer = N//1000
            integer +=1 
            print((integer*1000) - N)
   
            
        
        
except Exception as e:
    print(e)

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
    	fastio;
    	int n;
    	cin>>n;
    	map<string,int>m;
    	m["AC"]=0;
    	m["WA"]=0;
    	m["TLE"]=0;
    	m["RE"]=0;
    	for(int i=0;i<n;i++)
    	{
    		string s;
    		cin>>s;
    		m[s]++;
    	}
    	cout<<"AC"<<' '<<'x'<<' '<<m["AC"]<<endl;
    	cout<<"WA"<<' '<<'x'<<' '<<m["WA"]<<endl;
    	cout<<"TLE"<<' '<<'x'<<' '<<m["TLE"]<<endl;
    	cout<<"RE"<<' '<<'x'<<' '<<m["RE"]<<endl;
    }

Measured memory_bytes: 3680
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int a[] = new int[N];

        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }

        int b[] = new int[N];
        int c[] = new int[N];
        int count = 0;

        for(int i = N - 1; i >= 0; i--){
            int sum = 0;
            for(int j = i; j < N; j += (i + 1)){
                sum += c[j];
            }
            if(sum % 2 != a[i]){
                b[count] = i + 1;
                c[i] = 1;
                count++;
            }
        }

        System.out.println(count);
        for(int i = 0; i < count; i++){
            System.out.print(b[i] + " ");
        }

        sc.close();
    }
}


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

int main(){
	int N;
  	cin>>N;
  	int A[N],ans[N]={};
  	for(int i=2;i<=N;i++){
    	cin>>A[i];
      	ans[A[i]]++;
    }
  	for(int j=1;j<N;j++){
    	cout<<ans[j]<<endl;
    }
  	cout<<"0";
  	return 0;
}

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

using namespace std;

typedef long long ll;

ll count(ll H) {
  if (H == 1) {
    return 1;
  }
  return 1 + 2 * count(H / 2);
}

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

  cout << count(H) << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
lst = []
for _ in range(N):
  d1, d2 = map(int, input().split(' '))
  lst.append((d1, d2))
  
idx = 0
flag = False
while idx < N-2:
  cnt = 0
  for i in range(3):
    d1, d2 = lst[i+idx]
    if d1 == d2:
      cnt += 1
  if cnt == 3:
    flag = True
    break
  else:
    idx += 1
 
print('Yes' if flag else 'No')

Measured memory_bytes: 9080
use std::io::Read;

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

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let mut p: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    p.sort();

    let mut ans: usize = 0;
    for i in 0..k {
        ans += p[i];
    }

    return ans.to_string();
}


Measured memory_bytes: 2200
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 1e6+123;
char c;

void _case_()
{
    cin >> c;
    cout << char(c+1) el;
   // cout << c << " is followed by " << char(c+1)  << '.' << endl;
}



int main()
{
    optimize();
    //_test_
      _case_();
}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3640
N=int(input())
A=[0]*N
B=[0]*N
C=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  C[i]=[A[i],B[i]]

if N%2==1:
  M=N//2
  C.sort(key=lambda x:x[0])
  p=C[M][0]
  C.sort(key=lambda x:x[1],reverse=True)
  q=C[M][1]
  print(q-p+1)
else:
  M=N//2
  C.sort(key=lambda x:x[0])
  p=C[M-1][0]
  C.sort(key=lambda x:x[1])
  q=C[M-1][1]
  C.sort(key=lambda x:x[0],reverse=True)
  r=C[M-1][0]
  C.sort(key=lambda x:x[1],reverse=True)
  s=C[M-1][1]
  #print(p,q,r,s)
  x=q-p+1
  y=s-r+1
  print(x+y-1)

Measured memory_bytes: 45264
x1,y1,x2,y2=[int(i) for i in input().split()]
a=[x2-x1,y2-y1]
b=[y1-y2,x2-x1]
x3=x1+a[0]+b[0]
y3=y1+a[1]+b[1]
x4=x3-a[0]
y4=y3-a[1]
print(x3,y3,x4,y4)

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

int n,k;
int a[5010];
int f[5010][5010];

bool check(int x) {
	memset(f,0,sizeof(f));
	f[0][0]=1;
	if (0>=k-a[x]&&0<k) return true;
	for (int i=1;i<=n;i++) {
		int tmp=a[i];
		if (i==x) tmp=0;
		f[i][0]=1;
		for (int j=1;j<k;j++) {
			if (j>=tmp) f[i][j]=f[i-1][j]|f[i-1][j-tmp];
			else f[i][j]=f[i-1][j];
			if (j>=k-a[x]&&j<k&&f[i][j]) {
				return true;
			}
		}
	}
	return false;
}

int main() {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=0,r=n;
	while (l<r) {
		int mid=(l+r)/2+1;
		if (check(mid)) r=mid-1;
		else l=mid;
	} 
	cout<<l<<endl;
}


Measured memory_bytes: 98432
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll A,B,C,X;cin>>A>>B>>C>>X;
  int cnt=0;
  rep(i,A+1){
    rep(j,B+1){
      rep(k,C+1){
        if(i*500+j*100+k*50==X)cnt++;
      }
    }
  }
  cout<<cnt<<endl;
 
}







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

using namespace std;

int main(){
    string s;
    cin >> s;
	if(s == "Sunny"s) cout << "Cloudy";
  	if(s == "Cloudy"s) cout << "Rainy";
  	if(s == "Rainy"s) cout << "Sunny";
 }




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

using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    if (A > B)
        cout << 0 << endl;

    else if (N == 1)
        cout << (A == B ? 1 : 0) << endl;

    else {
        ll Min = A * (N - 2);
        ll Max = B * (N - 2);
        cout << Max - Min + 1 << endl;
    }
}


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

int D, N, T[212], A[212], B[212], C[212];
int dp[212][212], ans;

int main(void) {
	scanf("%d%d", &D, &N);
	for (int i = 0; i < D; ++i) { scanf("%d", &T[i]); }
	for (int i = 0; i < N; ++i) { scanf("%d%d%d", &A[i], &B[i], &C[i]); }

	for (int i = 0; i < D; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i][j] = -1;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (A[i] <= T[0] && T[0] <= B[i]) {
			dp[0][i] = 0;
		}
	}
	for (int i = 0; i < D - 1; ++i) {
		for (int j = 0; j < N; ++j) {
			if (dp[i][j] >= 0) {
				for (int k = 0; k < N; ++k) {
					if (A[k] <= T[i + 1] && T[i + 1] <= B[k]) {
						dp[i + 1][k] = std::max(dp[i + 1][k], dp[i][j] + abs(C[j] - C[k]));
					}
				}
			}
		}
	}

	ans = -1;
	for (int i = 0; i < D; ++i) {
		ans = std::max(ans, dp[D - 1][i]);
	}
	printf("%d\n", ans);
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m; cin>>n>>m;
    vector<string> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];

    bool allin=false;

    rep(i,n)rep(j,n){
        if(i+m-1>=n || j+m-1>=n) continue;
        bool in=true;
        rep(k,m)rep(l,m){
            if(a[i+k][j+l]!=b[k][l]) in=false;
        }
        if(in) allin=true;
    }

    if(allin) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N, K - Q);
  for (int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    a--;
    A[a]++;
  }
  for (int a : A) {
    if (a > 0) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 1024
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

def get_GCD(m, n)
  tmp = [n, m].max
  n = [n, m].min
  m = tmp
  while n != 0
    tmp = m % n
    m = n
    n = tmp
  end
  m
end

n = i()
an = li()
minus_num = an.count {|item| item < 0 }

res = if minus_num %2 == 0
  an.map{|a| a.abs}.sum
else
  bn = an.map{|a| a.abs}
  bn.sum - (bn.min*2)
end

p res


Measured memory_bytes: 9500
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    int mini = Inf;
    int sum = 0;
    int tmp;
    int ans;
    rep(i, n) {
      sum += l + i;
    }
    rep(i, n) {
      if (mini > abs(l + i)) {
        mini = abs(l + i);
        tmp = l + i;
      }
    }
    if (tmp < 0) {
      mini *= -1;
    }

    ans = sum - mini;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import copy
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = copy.copy(S)
SR = copy.copy(S)
SU = copy.copy(S)
SD = copy.copy(S)
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))


Measured memory_bytes: 196256
#include <iostream>
using namespace std;
int main(void){
    int n = 0, m = 0, p = 0;
    while(cin >> n >> m >> p){
        if(n == 0){
            break;
        }
        int allG = 0;
        int plaier[100];
        for(int i = 0; i < 100; i++){
            plaier[i] = 0;
        }
        for(int i = 0; i < n; i++){
            cin >> plaier[i];
            allG += plaier[i];
        }
        int forG = allG * (100-p);
        if(plaier[m-1] == 0){
            cout << 0 << endl;
        }
        else{
            cout << forG / plaier[m-1] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3080
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=100000;

char s[MAXLEN+1]; int slen;
char t[MAXLEN+1]; int tlen;
int ssum[MAXLEN+1];
int tsum[MAXLEN+1];
int nq;

void run() {
	scanf("%s%s",s,t); slen=strlen(s); tlen=strlen(t);
	ssum[0]=0; REP(i,slen) ssum[i+1]=ssum[i]+(s[i]=='A'?2:1);
	tsum[0]=0; REP(i,tlen) tsum[i+1]=tsum[i]+(t[i]=='A'?2:1);
	scanf("%d",&nq);
	REP(i,nq) {
		int s1,s2,t1,t2; scanf("%d%d%d%d",&s1,&s2,&t1,&t2); --s1,--t1;
		int sval=ssum[s2]-ssum[s1],tval=tsum[t2]-tsum[t1];
		printf("%s\n",(sval%3)==(tval%3)?"YES":"NO");
	}
}

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


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

using namespace std;

#define int long long

const int MAX = 5e5;

bool ok[MAX + 7];

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int x;
	cin >> x;
		
	if(x <= 2)
	{
		cout << 2;
		return 0;
	}

	for(int i = 3; i <= MAX; i += 2)
		if(ok[i] == false)
		{
			for(int j = i * i; j <= MAX; j += 2 * i)
				ok[j] = true;
		}
	
	for(int j = x; j <= MAX; j++)
		if(ok[j] == false && j % 2 == 1)
		{
			cout << j;
			return 0;
		}
}

Measured memory_bytes: 768
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        var n = sc.Int();

        var s = sc.Str(n);

        var cnt = new long[5];

        foreach (var x in s)
        {
            switch (x[0])
            {
                case 'M':
                    cnt[0]++;
                    break;
                case 'A':
                    cnt[1]++;
                    break;
                case 'R':
                    cnt[2]++;
                    break;
                case 'C':
                    cnt[3]++;
                    break;
                case 'H':
                    cnt[4]++;
                    break;
            }
        }

        long ans = 0;

        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                for (int k = j + 1; k < 5; k++) {
                    ans += cnt[i] * cnt[j] * cnt[k];
                }
            }
        }

        pr.WriteLine(ans);
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        const int d = 2;
        var ret = new int[d, d];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < d; j++)
            {
                for (int k = 0; k < d; k++)
                {
                    ret[i, j] += a[i, k] * a[k, j];
                }
            }
        }

        return ret;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

#define chmax(p,q)(p=max(p,q))
ll dp[3010][3010][4];
ll v[3010][3010];
int main(){
	int r,c,k;
	scanf("%d%d%d",&r,&c,&k);
	rep(i,0,k){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		v[x-1][y-1]=z;
	}
	
	dp[0][0][1]=v[0][0];
	rep(i,0,r)rep(j,0,c){
		if(i){
			//上からくる
			chmax(dp[i][j][0],max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))));
			chmax(dp[i][j][1],dp[i][j][0]+v[i][j]);
		}
		if(j){
			//左からくる
			//拾わない
			rep(k,0,4)chmax(dp[i][j][k],dp[i][j-1][k]);
			//拾う
			rep(k,0,3)chmax(dp[i][j][k+1],dp[i][j-1][k]+v[i][j]);
		}
	}
	printf("%lld",max(dp[r-1][c-1][0],max(dp[r-1][c-1][1],max(dp[r-1][c-1][2],dp[r-1][c-1][3]))));
}

Measured memory_bytes: 354416
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, a[109], b[109], c[109], ret, g[109][109]; long long pw[109]; bool vis[109]; set<long long> s;
void solve(vector<int> v, long long h) {
	int res = 0;
	for (int i = 0; i < v.size(); i++) {
		int r = 1 << 30;
		for (int j = 0; j < v.size(); j++) {
			if (i != j) r = min(r, g[v[i]][v[j]]);
		}
		if(v.size() >= 2) res += r;
	}
	ret = max(ret, res);
	for (int i = 0; i < m; i++) {
		if (vis[a[i]] || vis[b[i]]) {
			int u1 = a[i], u2 = b[i];
			if (!vis[u1]) swap(u1, u2);
			bool flag = true;
			for (int j : v) {
				if (!g[u2][j]) {
					flag = false;
					break;
				}
			}
			if (!flag) continue;
			long long nh = h + pw[u2];
			if (!s.count(nh)) {
				s.insert(nh);
				vis[u2] = true;
				v.push_back(u2);
				solve(v, nh);
				v.pop_back();
				vis[u2] = false;
			}
		}
	}
}
int main() {
	pw[0] = 1;
	for (int i = 1; i <= 100; i++) pw[i] = pw[i - 1] * 314159265358979;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--;
		g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
	}
	for (int i = 0; i < n; i++) vis[i] = true, solve(vector<int>({ i }), pw[i]), vis[i] = false;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3924
import sys
input = sys.stdin.readline
from itertools import accumulate

def merge(x, y):
  a, b = dp[x]
  c, d = dp[y]
  if a >= c:
    return (a, max(c, b))
  return (c, max(a, d))
  
n = int(input())
A = tuple(map(int, input().split()))
dp = [(a, 0) for a in A]
for j in range(n):
  for i in range(1<<n):
    if i & (1<<j):
      dp[i] = merge(i, i & ~(1<<j))
L = tuple(accumulate((sum(d) for d in dp), max))
print(*L[1:], sep="\n")

Measured memory_bytes: 50936
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    int k,s;
    cin >> k >> s;

    int ans = 0;
    rep(i,k+1) {
        rep(j,k+1) {
            int z = s - i - j;
            if(z >= 0 && z <= k)    ans++; 
        }
    }

    cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256