akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

const int cmax = 200010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

ll com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    mint ret=fac[n]*finv[k]*finv[n-k];
    return ret.x;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	mint ans(1);
	mint base(2);
	ll tn = n;
	while(tn > 0) {
		if(tn % 2 == 1) {
			ans *= base;
		}
		base = base * base;
		tn /= 2;
	}
	ans -= 1;
	com_init();
	mint ma = 1;
	ma *= finv[a];
	rep(i, a) ma *= n - i;
	ans -= ma;
	mint mb = 1;
	mb *= finv[b];
	rep(i, b) mb *= n - i;
	ans -= mb;
	cout << ans.x << endl;
}


Measured memory_bytes: 4992
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const LL mod = 1000000007ll;
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL n,k;

mint ans = 0;

//N個の部屋が横に並んでる状況をイメージ
//まず0人になる部屋をi個選び、
//残りのN-i個の部屋にN人を配列する(仕切りを使う)
void solve(){
	k = min(k,n-1);
	combination c(n);
	for(int i=0;i<=k;i++){
		ans += c(n,i)*c(n-1,n-i-1);
	}
}
 
int main(){
	cin >> n >> k;
 
	solve();

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

Measured memory_bytes: 3328
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	map<string, int> dic;
	int n;

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		char command[10];
		char c[15];
		scanf("%s", command);
		scanf("%s", c);

		if (command[0] == 'i')
		{
			dic.insert(make_pair(string(c), 0));
		}
		else if (command[0] == 'f')
		{
			if (dic.find(string(c)) != dic.end())
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
		else
		{
			printf("illegal input\n");
		}
	}

	return 0;
}

Measured memory_bytes: 33368
import re
import functools

N = int(input())
MOD = 10 ** 9 + 7


@functools.lru_cache(maxsize=None)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C', last3 + c):
            ret += dfs(cur + 1, last3[1:] + c)
    return ret % MOD


print(dfs(0, 'TTT'))

Measured memory_bytes: 5796
a, b, c, d, e, k = [int(raw_input()) for i in range(6)]
#print(k)

list = [a, b, c, d, e]
#print(list)

flag = True

for i in range(5):
    y = list[0]
    list.pop(0)
    #print(list)
    alist = map(lambda x: x - y, list)
    #print(alist)
    if (all([z <= k for z in alist])) == False:
        flag = False
        break
    else:
        continue
        break

if flag == True:
    print("Yay!")
else:
    print(":(")


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

int main(){

  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  int rest[5];
  int time[5];
  int ans = 0;
  int minpos = 0;

  for(int i = 0 ; i < 5 ; i++){
    rest[i] = a[i]%10;
    // cout << "TIME : " << a[i] << endl;
    // cout << "rest : " << rest[i] << endl;

    if(rest[i] == 0) time[i] = a[i];
    else time[i] = a[i] +  10 - (a[i]%10);

    // cout << "time" << i << " :  " << time[i] << endl;

    if(rest[i] < rest[minpos] && rest[i] != 0) minpos = i;
  }

  // cout << "minpos " << minpos << endl;

  int total = 0;

  for(int i = 0 ; i < 5 ; i++){
    if(i == minpos) total += a[i];
    else total += time[i];
  }
  

  // for(int i = 0 ; i < 4 ; i++){
  //   if(rest[i+1] - rest[i] < 0) {
  //     total += a[i];
  //     continue;
  //   }
  //   else total += time[i];
  // }

  ans = total;

  cout << ans << endl;


}

Measured memory_bytes: 256
from collections import deque

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

edges = [list(map(int, input().split())) for _ in range(M)]
od = [-1]*(N+1)
low = [-1]*(N+1)
pa = [0]*(N+1)
od[1] = 0
low[1] = 0
pa[1] = 1
ni = {i:[] for i in range(1,N+1)}

for i in range(M):
  ni[edges[i][0]].append(edges[i][1])
  ni[edges[i][1]].append(edges[i][0])

rlt = 0
h = deque([])
for i in ni[1]:
  h.append([1,i])

i = 0
while h:
  a = h.pop()
  if od[a[1]] > -1:
    if od[a[1]] < od[a[0]]:
      low[a[0]] = od[a[1]]
      c = a[0]
      while low[pa[c]] > od[a[1]]:
        low[pa[c]] = od[a[1]]
        c = pa[c]
  else:
    i += 1
    od[a[1]] = i
    low[a[1]] = i
    pa[a[1]] = a[0]
    for b in ni[a[1]]:
      if b == a[0]:
        continue
      h.append([a[1],b])
          
for i in range(2,N+1):
  if od[pa[i]] < low[i]:
    rlt += 1

print(rlt)


Measured memory_bytes: 67108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1LL<<60;

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

  vector<string> g(h);

  for(int i = 0; i < h; i++) cin >> g[i];

  vector<int> r(h,0), c(w,0);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g[i][j] == '#'){
        r[i] = 1;
        c[j] = 1;
      }
    }
  }
  for(int i = 0; i < h; i++){
    if(!r[i]) continue;
    for(int j = 0; j < w; j++){
      if(!c[j]) continue;
      cout << g[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long cnt = 0;
		for(long r=0;r * R <= N;r++){
			for(long g = 0; g * G <= N; g++){
				var ball = r * R + g * G;
				if(ball <= N && (N - ball) % B == 0) cnt++;
			}
		}
		
		Console.WriteLine(cnt);
		
		
	}
	long R,G,B,N;
	public Sol(){
		var d = ria();
		R = d[0]; G = d[1]; B = d[2]; N = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include <stdio.h>

#include <iostream>

using namespace std;

int main() {
    int H, N;
    int A;
    int counter = 0;
    cin >> H >> N;
    for (int i = 0; i < N; i++) {
        cin >> A;
        counter += A;
    }
    if (counter >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define        ll     long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    int sum=0;
    bool flag=false;
    while(n--){
        int a,b;
        cin>>a>>b;
        if(a==b)sum++;
        else sum=0;
        if(sum==3)flag=true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#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;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  deque<int> q;
  rep(i,n){
    if(i%2==1) q.push_front(a[i]);
    else q.push_back(a[i]);
  }
  if(n%2==0){
    rep(i,n){
      cout << q.front() << " ";
      q.pop_front();
    }cout << endl;
  }
  else{
    rep(i,n){
      cout << q.back() << " ";
      q.pop_back();
    }cout << endl;
  }
}

Measured memory_bytes: 3840
#include <stdio.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(){
	int i,n;
	scanf("%d",&n);
	int r[n],min[n],max[n],Max=-1000000000;
	for(i=0;i<n;i++){
		scanf("%d",&r[i]);
    }

	min[0]=r[0];
	max[0]=r[n-1];
	for(i=1;i<n-1;i++){
		min[i] = MIN (r[i],min[i-1]);
		max[i] = MAX (r[n-1-i],max[i-1]);
	}
	for(i=0;i<n-1;i++){
		Max = MAX (max[n-2-i]-min[i],Max);
	}
	printf("%d\n", Max);

	return 0;
}

Measured memory_bytes: 4144
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    double a, b;
    cin >> a >> b;

    int ans = ceil((a + b) / 2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int i,k,m,n=0,f=0;
	cin >> s;
	if(s[0]!='A' || s[1]=='C' || s[s.size()-1]=='C')
        f=1;
	for(i=1;i<s.size();i++)
    {
        if(f)
            break;
        if(s[i]=='C')
            n++;
        else if(s[i]>='A' && s[i]<='Z' || n>1 || s[i]=='A')
            f=1;
    }
    if(n==0)
        f=1;
    if(f==0)
        cout << "AC\n";
    else
        cout << "WA\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,count=0,sum;
  cin >> N;
  vector<int> a(N),box(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    box.at(i)=0;
  }
  for(int i=N;i>0;i--){
    if(i>N/2){
      box.at(i-1)=a.at(i-1);
      if(box.at(i-1)==1) count++;
    }
    else{
      sum=0;
      for(int j=2;i*j<=N;j++){
        sum+=box.at(i*j-1);
      }
      if(sum%2!=a.at(i-1)){
        box.at(i-1)++;
        count++;
      }
    }
  }
  cout << count << endl;
  if(count!=0){
    for(int i=0;i<N;i++) if(box.at(i)==1) cout << i+1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2432
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ans = 0

N.times do |i|
  if B[i] > A[i]
    ans += A[i]
    B[i] -= A[i]

    if B[i] > A[i+1]
      ans += A[i+1]
      A[i+1] = 0
    else
      ans += B[i]
      A[i+1] -= B[i]
    end
  else
    ans += B[i]
    B[i] = 0
  end
end

puts ans

Measured memory_bytes: 15388
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    ans = 0
    for i in range(1, n):
        a = i
        b = n // a - (n % a == 0)
        ans += max((b), 0)
    print(ans)

Measured memory_bytes: 64712
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vector<int>> dp(n + 1, vector<int>(n + 1));
  rrep (i, n) {
    rrep (j, n) {
      if (i <= j) continue;
      if (s[i] == s[j]) dp[i][j] = min(i - j, dp[i + 1][j + 1] + 1);
    }
  }
  int maxi = 0;
  rep (i, n) maxi = max(maxi, *max_element(all(dp[i])));
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 98304
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main()
{
	int n, d, x, a[101];
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int j = 0;
		while ((1 + j * a[i]) <= d) {
			ans++;
			j++;
		}
	}
	cout << ans + x << endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
s = list(input() for _ in range(n))
cou = 0
for i in s:
    cou += i.count('AB')
a = 0
b = 0
both = 0
for i in s:
    if i[0]=="B":
        b += 1
    if i[-1]=="A":
        a += 1
    if i[0]=="B" and i[-1]=="A":
        both += 1
if min(a,b)==both and a==b:
    print(cou+max(min(a,b)-1,0))
else:
    print(cou+min(a,b))


Measured memory_bytes: 3700
n,m=map(int,input().split())
lst=[]
for i in range(m):
    a=[int(x) for x in input().split()]
    a=[x-1 for x in a]
    lst.append(a[1:])
p=[int(x) for x in input().split()]
ans=0

for i in range(2**n):
    on=[]
    light_on=0
    for j in range(n):
        if ((i>>j)&1):
            on.append(j)
    for j in range(m):
        num_on=0
        for k in range(len(lst[j])):
            if lst[j][k] in on:
                num_on+=1
        if (num_on%2)==p[j]:
            light_on+=1
    if light_on==m:
        ans+=1

print(ans)

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    REP(i, 0, D) {
        cin >> p[i] >> c[i];
    }
    int ans = 1 << 30;
    REP(i, 0, 1 << D) {
        int score = 0;
        int cnt = 0;
        REP(j, 0, D) {
            if ((i >> j) & 1) {
                score += p[j] * (j + 1) * 100 + c[j];
                cnt += p[j];
            }
        }
        for (int j = D - 1; j >= 0; j--) {
            int res = G - score;
            if (res <= 0) break;
            if ((i >> j) & 1) continue;
            if (res >= p[j] * (j + 1) * 100) {
                score += p[j] * (j + 1) * 100;
                cnt += p[j];
            } else {
                score = G;
                cnt += (res + (j + 1) * 100 - 1) / ((j + 1) * 100);
            }
        }
        if (score >= G) {
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
d=[0j,100+0j]
for _ in[0]*int(input()):
 p=[d[0]]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a+r,a+r+r*(1+3**.5*1j)/2,b-r,b]
 d=p
for e in d:print(e.real,e.imag)


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(ll (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int h, w, r;
string s[50];
int d[50][50];

void bfs() {
	int wh = 0;
	rep(i,h) rep(j,w) wh += s[i][j]=='.';
	queue<pair<int,pii>> q;
	q.push({0,{0,0}});
	rep(i,h) rep(j,w) d[i][j] = inf;
	d[0][0] = 0;
	while (!q.empty()) {
		int x = q.front().se.se, y = q.front().se.fi, dis = q.front().fi; q.pop();
		if (d[y][x]<dis) continue;
		rep(i,4) {
			int xx = x + dx[i], yy = y + dy[i];
			if (xx<0 || xx>=w || yy<0 || yy>=h || d[yy][xx]<=dis+1 || s[yy][xx]=='#') continue;
			d[yy][xx] = dis+1;
			q.push({dis+1,{yy,xx}});
		}
	}
	if (s[0][0]=='#' || d[h-1][w-1]==inf) r = -1;
	else r = wh - d[h-1][w-1] - 1;
}

signed main() {
	cin >> h >> w;
	rep(i,h) cin >> s[i];
	bfs();
	cout << r << ln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main() {
	int n, m, x, y;
	bool flag = true;
	int sw[100000];
	memset(sw, 0, sizeof(sw));
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		sw[x] += 1;
		sw[y] += 1;
	}
	for (int i = 0; i < 100000; i++) {
		if (sw[i] % 2 == 1) {
			flag = false;
			break;
		}
	}
	if (flag == true) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void){
  int N, k, a, b, c, d;

  k = 1;
  scanf("%d", &N);
  a = N / 1000;
  b = (N - a * 1000) / 100;
  c = (N - a * 1000 - b * 100) / 10;
  d = N - a * 1000 - b * 100 - c * 10;
  int list[] = {a,b,c,d};
  qsort(list, 4, sizeof(int), compare_int);
  if (a == b && b == c && c == d) printf("Yes\n");
  else if ((a == b && b == c) || (d == b && b == c)) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        String s = sc.next();

        // 主処理
        String result = 3200 <= a ? s : "red";

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 23764
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String ans = "";
        for (int i = 0; i < line.length(); i++)
            ans = ans.concat("x");
        System.out.println(ans);
    }
}

Measured memory_bytes: 22484
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

bool g[8][8];

int dfs(int v, int N, bool visited[N]){
    bool all = true;

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

    if(all){
        return 1;
    }

    int r = 0;

    for(int i = 0; i < N; i++){
        if(g[v][i] == false){
            continue;
        }
        if(visited[i]){
            continue;
        }

        visited[i] = true;
        r += dfs(i, N, visited);
        visited[i] = false;
    }

    return r;
}

int main(void){

    int N, M;

    scanf("%d%d", &N, &M);

    int a[M], b[M];

    for(int i = 0; i < M; i++){
        scanf("%d%d", &a[i], &b[i]);
        g[a[i]-1][b[i]-1] = true;
        g[b[i]-1][a[i]-1] = true;
    }

    bool visited[N];

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

    printf("%d\n", dfs(0, N,visited));

    return 0;
}

Measured memory_bytes: 1728
use std::io::{stdin, BufRead, BufReader};

fn main() {
    let mut w: u32 = 0;
    for i in 0..2 {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        match i {
            0 => w = buf.trim().parse().unwrap(),
            _ => break,
        }
    }
    let reader = BufReader::new(stdin());
    let mut hlines = vec![];
    for line in reader.lines() {
        let l: Vec<u32> = line.unwrap()
            .trim()
            .split(',')
            .filter_map(|x| x.parse::<u32>().ok())
            .collect();
        hlines.push((l[0], l[1]));
    }

    let mut answer = Vec::with_capacity((w + 1) as usize);
    for i in 1..w + 2 {
        answer.push(i);
    }
    for i in 1..w + 1 {
        let mut current = i;
        for hline in &hlines {
            if hline.0 == current {
                current = hline.1;
            } else if hline.1 == current {
                current = hline.0;
            }
        }
        answer[(current - 1) as usize] = i;
    }
    for i in 0..w {
        println!("{}", answer[i as usize]);
    }
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
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; }

int main(){
    int n;cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);

    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    rep(i,n-1){
        cin>>c[i];
    }
    int ans=0;
    int stock=0;
    rep(i,n){
        if(a[i]==stock+1){
            ans+=c[a[i]-2];
        }
        ans+=b[a[i]-1];

        stock=a[i];

    }

    cout<<ans<<endl;

}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

ll n,x,y,dp[100005][2],vis[100005];
vll adj[100005];

void dfs(int cur) {
	dp[cur][0] = dp[cur][1] = 1;
	vis[cur]=1;
	for(auto x : adj[cur]) {
		if(!vis[x]) {
			dfs(x);
			dp[cur][0] = (dp[cur][0]*(dp[x][0]+dp[x][1])%mod)%mod;
			dp[cur][1] = dp[cur][1]*dp[x][0]%mod;
		}
	}
}

int main() {
	IOS
	cin >> n;
	fori(i,1,n-1,1) {
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1);
	cout << (dp[1][0]+dp[1][1])%mod << endl;
}


Measured memory_bytes: 12288
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

public class Test
{
    public static void Main()
    {
        var x = long.Parse(Console.ReadLine());

        Console.WriteLine((x * 2 + 9) / 11);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  string S,T;
  cin >> S >> T;
  ll s=S.size(),t=T.size(),ans=INF;
  rep(i,s-t+1){
    ll k=0;
    rep(j,t){
      if(S.at(i+j)!=T.at(j)){
        k++;
      }
    }
    ans=min(ans,k);
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 3628
N = int(input())
ans = []
for i in range(N):
    S,P = map(str,input().split(" "))
    P = int(P)
    ans.append([S,P,i+1])
sort_list = sorted(ans,key = lambda x:(x[0],-x[1]))
for i in range(N-1):
    if sort_list[i][0] == sort_list[i+1][0]:
        if sort_list[i][1] < sort_list[i+1][1]:
            temp = sort_list[i][1]
            sort_list[i][1] = sort_list[i+1][1]
            sort_list[i+1][1] = temp
#print(sort_list)
for i in range(N):
    print(sort_list[i][2])

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

using namespace std;

class Solution {
public:
    vector<int> solve(string& s, int m) {
        int n = s.length();
        if (s[n - 1] == '1') {
            return {};
        }

        const int INF = 1 << 24;
        vector<int> dp(n + 1, INF);
        vector<int> next(n + 1, n);
        dp[n - 1] = 0;
        deque<int> que;
        que.emplace_back(n - 1);
        for (int i = n - 2; i >= 0; --i) {
            if (s[i] == '1') {
                continue;
            }

            while (!que.empty()) {
                int u = que.front();
                if (u > i + m) {
                    que.pop_front();
                } else {
                    break;
                }
            }
            if (que.empty()) {
                break;
            }
            dp[i] = dp[que.front()] + 1;
            next[i] = que.front();
            while (!que.empty()) {
                if (dp[que.back()] == dp[i]) {
                    que.pop_back();
                } else {
                    break;
                }
            }
            que.push_back(i);
        }   

        if (dp[0] >= INF) {
            return {};
        }
        int x = 0;
        vector<int> res;
        while (x < n - 1) {
            int nx = next[x];
            res.push_back(nx - x);
            x = nx;
        }
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    Solution sol;
    auto res = sol.solve(s, m);
    if (res.empty()) {
        cout << "-1\n";
    } else {
        int m = res.size();
        for (int i = 0; i < m; ++i) {
            cout << res[i] << (i == m - 1 ? '\n' : ' ');
        }
    }

    return 0;
}

Measured memory_bytes: 1744
def divide(x, y):
    s = 1
    if(x < 0):s *= -1
    if(y < 0):s *= -1
    return abs(x) / abs(y) * s     

operator = {"+":(lambda x,y: x+y),
            "-":(lambda x,y: x-y),
            "*":(lambda x,y: x*y),
            "/":divide
            }

def ind(src, x):
    if x not in src:return 1<<30
    return src.index(x)
 
def _split(_src):
    c = 0
    l = len(_src)
    if l == 0:
        return []
    while c < l and ord('0') <= ord(_src[c]) <= ord('9'):
        c += 1

    if c == 0:
        return [_src[0]] + _split(_src[1:])
    else:
        return [int(_src[:c])] + _split(_src[c:])
         
 
def evaluate(src):
    if len(src) == 1:
        return src[0]
         
    if "(" in src:
        l = src.index("(")
        r = l
        st = 1
        while st:
            r += 1
            if src[r] == "(": st += 1
            if src[r] == ")": st -= 1
        
        mid = evaluate(src[l + 1:r])
        return evaluate( src[:l] + [mid] + src[r + 1:])
    
    pos = min(ind(src, "*"), ind(src,"/"))
    if(pos == 1<<30):
        pos = min(ind(src, "+"), ind(src, "-"))
    op = src[pos]
    l, r = src[pos - 1], src[pos + 1]
    mid = operator[op](l, r)
    return evaluate(src[:pos - 1] + [mid] + src[pos + 2:])

     
for t in xrange(input()):
    _src = raw_input().strip("=")
    src = _split(_src)
    print evaluate(src)

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int count=0;
  for (int i=0;i<=A;i++) {
    for (int j=0;j<=B;j++) {
      for (int k=0;k<=C;k++) {
        if (X==500*i+100*j+50*k) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

int vec_find(vector<int> k,int x){
  int count=0;
  for(int i=0;i<k.size();i++){
    if(x==k.at(i))count++;
  }
  return count;
}

int main(){
  int s,i=1;
  cin >> s;
  vector<int> ans;
  while(1){
    i++;
    ans.push_back(s);
    if(s%2==0)s/=2;
    else if(s%2==1)s=3*s+1;
    if(vec_find(ans,s)!=0){
      cout << i << endl;
      return 0;
    }
  }
}


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

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, x;
    cin >> n >> x;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < n - 1; i++) {
        int diff = a[i] + a[i + 1] - x;
        if(diff > 0) {
            ans += diff;
            a[i + 1] -= min(diff, a[i + 1]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2e2+5;
const int MAXM=4e5+5;
int edge,head[MAXN],tail[MAXM],nex[MAXM];
int n,ans,d[MAXN];
int c[MAXN];
bool fl=0;
int q[MAXM],l,r;
void add(int u,int v){
	edge++,nex[edge]=head[u],head[u]=edge,tail[edge]=v;
}
void dfs(int u,int col){
	if (c[u]>0&&c[u]!=col) fl=1;
	if (c[u]) return;
	c[u]=col;
	for (int e=head[u];e;e=nex[e]){
		int v=tail[e];
		dfs(v,col^1);
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			char c=getchar(); while (c!='0'&&c!='1') c=getchar();
			if (c=='1') add(i,j);
		}
	}
	dfs(1,2);
	for (int i=1;i<=n;i++){
		for (int i=1;i<=n;i++) d[i]=0;
		l=r=0;
		q[++r]=i;
		d[i]=1; int res=1;
		while (l<r){
			int u=q[++l];
			res=max(res,d[u]);
			for (int e=head[u];e;e=nex[e]){
				int v=tail[e];
				if (d[v]) continue;
				d[v]=d[u]+1;
				q[++r]=v;
			}
		}
		ans=max(ans,res);
	}
//	for (int i=1;i<=n;i++) printf("%d %d\n",i,d[i]);
	if (!fl) printf("%d\n",ans);
	else printf("-1\n");
	return 0;
}


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

#define fi first
#define se second

const int N = 100100;

using namespace std;

int n;
int x[N];
int y[N];
int r[N];
bool used[N];
long double d[N];

long double dist(int i, int j)
{
        long double e = 1ll * (x[i] - x[j]) * (x[i] - x[j]) + 1ll * (y[i] - y[j]) * (y[i] - y[j]);
        return max((long double)0, sqrt(e) - r[i] - r[j]);
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> x[1] >> y[1] >> x[2] >> y[2];
        cin >> n;
        n += 2;
        for(int i = 3; i <= n; i++){
                cin >> x[i] >> y[i] >> r[i];
        }
        long double inf = (long double)(1e18);
        for(int i = 2; i <= n; i++){
                d[i] = inf;
        }
        for(int i = 1; i <= n; i++){
                int h = -1;
                for(int j = 1; j <= n; j++){
                        if(used[j]){
                                continue;
                        } else if(h == -1 || d[j] < d[h]){
                                h = j;
                        }
                }
                used[h] = 1;
                for(int j = 1; j <= n; j++){
                        d[j] = min(d[j], d[h] + dist(h, j));
                }
        }
        cout << fixed << setprecision(9) << d[2] << "\n";
}


Measured memory_bytes: 256
import math
a, b, x = [int(x) for x in input().split()]
y = 2 * (b - (x / (a * a)))
if x == a * a * b: print(0)
elif y <= b:
    value = a / y
    print(90 - math.degrees(math.atan(value)))
else:
    y = (2 * x) / (a * b)
    v = b / y
    print(math.degrees(math.atan(v)))

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

int main() {
	long long a,b,v,c,y;
	cin>>a>>b;
	if(a>b){
		y=a;
	}
	else{
		y=b;
	}
	for(int i=1;i<=y;i++){
		v=a-i;
		c=b-i;
		if(v<0){
			v=v*-1;
		}
			if(c<0){
			c=c*-1;
		}
		if(v==c){
			cout<<i;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=0;i<max(a,b);i++)  cout<<min(a,b);
	re 0;
}

Measured memory_bytes: 256
w,h,n = map(int,input().split())

#座標用配列
s = [[1 for i in range(w)] for j in range(h)]

    
#標準入力
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(h):
            s[j][0:x] = [0 for k in range(x)]         
    elif a ==2:
        for j in range(h):
            s[j][x:w] = [0 for k in range(x,w)]       
    elif a ==3:
        for j in range(y):
            s[j] = [0 for k in range(w)]   
    elif a==4:
        for j in range(y,h):
            s[j] =[0 for k in range(w)]
            

cnt = 0
for i in s:
    cnt += sum(i)
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define WHITE 0
#define BRACK 1

int **matrix;
int *d;
int *parent;
int *color;

void di(int);

int main(){
  int n,i,j,k,u,v;
  scanf("%d",&n);
 
  color =  malloc(n * sizeof(int ));
  d =  malloc(n * sizeof(int ));
  parent = malloc(n * sizeof(int));
 
  matrix = malloc(n * sizeof(int *));
  for(i=0;i<n;i++)
    matrix[i] = malloc(n * sizeof(int));
 
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      matrix[i][j] = -1;
   
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&matrix[u][v]);
    }
  }
 
  di(n);
 
  for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
 
  free(d);
  free(color);
  free(parent);
  for(i=0;i<n;i++) free(matrix[i]);
  free(matrix);
 
  return 0;
   
}
 
 
void di(int n){
  int mincost;
  int i,j,u;
 
  for(i=0;i<n;i++){
    d[i] = INT_MAX;
    parent[i] = -1;
    color[i] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INT_MAX;
 
    for(i=0;i<n;i++){
      if(color[i] != BRACK && d[i] < mincost){
    mincost = d[i];
    u = i;
      }
    }
 
    if(mincost == INT_MAX) break;
 
    color[u] = BRACK;
 
    for(i=0;i<n;i++){
      if(color[i] != BRACK && matrix[u][i] != -1 && matrix[u][i] + d[u] < d[i]){
    d[i] = matrix[u][i] + d[u];
    parent[i] = u;
      }
    }
  }
}

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#define N 100009
using namespace std;
const int INF = 0x3f3f3f3f;
int a[N];

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


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

const int Maxn = 100005;
int n, m, cnt, top, s, maxi, now, fa[Maxn], node[Maxn], sta[Maxn], a[Maxn], b[Maxn], w[Maxn], head[Maxn];
long long sum[Maxn], mini[Maxn];
vector <int> Ve[Maxn];
bool vis[Maxn];
struct edg
{
	int nxt, to;
}edge[2 * Maxn];
void add(int x, int y)
{
	edge[++cnt] = (edg){head[x], y};
	head[x] = cnt;
}
void dfs(int u)
{
	mini[u] = 0x3f3f3f3f3f3f3f3f;
	sum[u] = b[u];
	for (vector <int> :: iterator it = Ve[u].begin(); it != Ve[u].end(); it++)
	{
		int to = *it;
		dfs(to);
		sum[u] += sum[to];
		mini[u] = min(mini[u], max((long long) w[u], mini[to]) - sum[to]);
	}
	if (!Ve[u].size()) mini[u] = w[u] + b[u];
	else mini[u] += sum[u];
}
int get_fa(int x)
{
	return x == fa[x] ? x : fa[x] = get_fa(fa[x]);
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[i], &b[i]), w[i] = max(0, a[i] - b[i]), node[i] = fa[i] = i;
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		add(x, y);
		add(y, x);
	}
	sort(node + 1, node + 1 + n, [](int x, int y){return w[x] < w[y];});
	for (int j = 1; j <= n; j++)
	{
		int u = node[j];
		vis[u] = true;
		for (int i = head[u]; i; i = edge[i].nxt)
		{
			int to = edge[i].to;
			if (vis[to] && get_fa(to) != u)
				Ve[u].push_back(get_fa(to)), fa[get_fa(to)] = u;
		}
	}
	dfs(node[n]);
	printf("%lld", mini[node[n]]);
	return 0;
}

Measured memory_bytes: 14208
import sys


def jump(n, h, res):
  res[0] = 0
  res[1] = abs(h[0] - h[1])
  for i in range(2, len(res)):
      res[i] = min(res[i-1] + abs(h[i] - h[i-1]), res[i-2] + abs(h[i] - h[i-2]))

  return res[n]


def main(N, H):
  res = [0] * N

  print jump(N-1, H, res)


if __name__ == '__main__':
  H, N = None, None
  for i, line_ in enumerate(sys.stdin):
    line = line_.strip()
    if line:
        if not i:
            N = int(line.strip())
        H_ = line.strip().split()
        H = [int(num) for num in H_]
  if N is not None and H is not None:
    main(N, H)


Measured memory_bytes: 18468
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

typedef pair<int,int> P;

int main() {
    int n;
    bool ans = false;
    cin >> n;
    vector<P> p(n);
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        p[i].second = a[i];
    }

    for (int i=0; i<n; i++) cin>>p[i].first;
    sort(p.begin(), p.end());
    sort(a.begin(), a.end());

    for (int i=0; i<n; i++) {
        if (a[i] > p[i].first) {
            puts("No");
            return 0;
        }
    }


    for (int i=0; i<n-1; i++)
        if (a[i+1] <= p[i].first) ans = true;

    map<int,int> trans;
    for (int i=0; i<n; i++) trans[p[i].second] = i;

    int i=0;
    vector<bool> used(n,false);
    int cnt = 0;
    while (!used[i]) {
        used[i] = true;
        i = trans[a[i]];
        cnt++;
    }
    if (cnt != n) ans = true;

    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n;
	cin>>n;
	string s;
	vector<string> vec(n);
	for(int i= 0; i<n;i++)
	{
		cin>>vec.at(i);
	}
	sort(vec.begin(),vec.end());
	int c = 1;
	for(int i = 1; i < n; i++)
	{
		if(vec.at(i) != vec.at(i-1))
		{
			c++;
		}
	}
	cout<<c<<"\n";
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 9548
T=X=Y=f=0
for i in[0]*input():t,x,y=map(int,raw_input().split());f+=t-T<abs(x-X)+abs(y-Y)or(x+y+t+X+Y+T)%2;T,X,Y=t,x,y
print["Yes","No"][f>0]

Measured memory_bytes: 3332
from collections import Counter
n = int(input())
s = []
for i in range(n):
    s.append(input())

c = Counter(s)
d = c.most_common()

t = []
t.append(d[0])
cnt = 1

if len(d)>1:
    for i in range(len(d)-1):
        if d[i+1][1]==t[0][1]:
            t.append(d[i+1])
            cnt+=1
        else:
            break

    t= sorted(t)

    for i in range(cnt):
        print(t[i][0])

else:
    print(d[0][0])

Measured memory_bytes: 51792
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    long q,h,s,d,ans=0,n,o;
    scanf("%ld %ld %ld %ld",&q,&h,&s,&d);
    scanf("%ld",&n);
    o=min(2*q,h);
    o=min(2*o,s);
    ans+=n/2*min(2*o,d);
    ans+=n%2*o;
    printf("%ld\n",ans);
}

Measured memory_bytes: 128
while True:
    try:
        N = int(input())
        result = dict()
        for i in range(N):
            S = input()
            ss = ''.join(sorted(S))
            if ss not in result:
                result[ss] = 0
            result[ss] += 1
        print(sum(map(int, map(lambda x: x*(x-1)/2, result.values()))))
    except EOFError:
        break

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

int main()
{
    string s;
    cin>>s;
    int res=0, cnt=0;
    for(char c: s) {
        if ("ATCG"s.find(c)!=string::npos)
            res=max(res, ++cnt);
        else
            cnt=0;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int tt(int,int,int);
int main(void)
{
	int i,n,a[1000],b[1000],c[1000],kai[1000];
	
	scanf("%d", &n);
	for (i=0;i<n;i++){
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		kai[i] = tt(a[i], b[i], c[i]);
	}
	
	for (i=0;i<n;i++){
		if (kai[i] == 1){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return 0;
}

int tt(int A, int B, int C)
{
	int orz=0;
	if (A*A == B*B + C*C){
		orz = 1;
	}
	else if (B*B == A*A + C*C){
		orz = 1;
	}
	else if (C*C == A*A + B*B){
		orz = 1;
	}
	else {
		orz = 0;
	}
	
	return orz;
}

Measured memory_bytes: 596