akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A,B,ans;

int main(){
    cin >> A >> B;
    out(max(A-B,max(A+B,A*B)));
    return 0;
}

Measured memory_bytes: 256
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	long long sum = 0;
	for (int i = 0; i < k; ++i) {
		sum += p[i];
	}
	cout << sum << '\n';	
	
	return 0;
}


Measured memory_bytes: 3644
s = str(input())
n = len(s)

L = []
c = 0
ans = 0
for i in range(n):
    if c-1 >= 0:
        if s[i] == 'g':
            ans += 1
            c -= 1
        else:
            c -= 1
    else:
        if s[i] == 'g':
            c += 1
        else:
            ans -= 1
            c += 1
print(ans)

Measured memory_bytes: 3316
function Main(input) {
  input = input.split("\n");
  var n = input[0];
  tmp = input[1].split(" ");
  a = new Array(n).fill(0);
  var m =0;
  b = new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
    m+=a[i];
    if(i!=0){
    b[i]=b[i-1]+a[i];
    }else{
      b[i]=a[i];
    }
  }
  var ans=100000000000;
  for(i=0;i<n-1;i++){
    ans=Math.min(ans,Math.abs((m-b[i])-b[i]));
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 41784
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

total = 0
total += sum(b)
for i in range(n-1):
    if a[i] + 1 == a[i+1]:
        total += c[a[i]-1]
print(total)

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }
    else{
        if(b == c){
            cout << a << endl;
        }
        else{
            cout << b << endl;
        }
    }

    return 0;
}

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

int main(){
  int n,a1,a2,a3,a4;
  string ans;
  cin>>n;
  a1=n/1000;
  a2=(n-1000*a1)/100;
  a3=(n-1000*a1-100*a2)/10;
  a4=(n-1000*a1-100*a2-10*a3);

  if(a2!=a3) ans="No";
  else {
    if(a1==a2 || a4==a3) ans="Yes";
    else ans="No";
  }


  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <complex>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  if (count(ALL(S), 'R') > count(ALL(S), 'B')) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
from copy import deepcopy
input = sys.stdin.readline
n,m=map(int,input().split())
d=[[100000]*n for _ in range(n)]
a=[0]*m
b=[0]*m
c=[0]*m
for i in range(m):
  a0,b0,c0=map(int,input().split())
  a[i]=a0-1
  b[i]=b0-1
  c[i]=c0
  d[a0-1][b0-1]=c0
  d[b0-1][a0-1]=c0
for i in range(n):
  d[i][i]=0
d2=deepcopy(d)
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
count=0
for i in range(n):
  for j in range(i):
    if d2[i][j] != 100000 and d[i][j]!=d2[i][j]:
      count+=1
print(count)


Measured memory_bytes: 43484
def main():
    num_list = []
    for _ in range(3):
        num_list.append(list(map(int,input().split())))

    a1 = 0
    b1 = num_list[0][0] - a1
    b2 = num_list[0][1] - a1
    b3 = num_list[0][2] - a1
    a2 = num_list[1][0] - b1
    a3 = num_list[2][0] - b1

    isGood = True

    if a1 + b1 != num_list[0][0]:
        isGood = False
    if a1 + b2 != num_list[0][1]:
        isGood = False
    if a1 + b3 != num_list[0][2]:
        isGood = False
    if a2 + b1 != num_list[1][0]:
        isGood = False
    if a2 + b2 != num_list[1][1]:
        isGood = False
    if a2 + b3 != num_list[1][2]:
        isGood = False
    if a3 + b1 != num_list[2][0]:
        isGood = False
    if a3 + b2 != num_list[2][1]:
        isGood = False
    if a3 + b3 != num_list[2][2]:
        isGood = False

    print('Yes' if isGood else 'No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <stdio.h>

int main(){
    int a,b;
    int d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %f\n", d,r,f);
    
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N,K;
int A[500];
signed main(){
    int sum=0;
    cin>>N>>K;
    rep(i,N){
        cin>>A[i];sum+=A[i];
    }
    vector<int>v;
    for(int i=1;i*i<=sum;i++){
        if(sum%i)continue;
        v.push_back(i);
        if(i*i!=sum)v.push_back(sum/i);
    }
    int ans=0;
    for(int i:v){
        int nesum=0,posum=0;
        vector<P>vec;
        rep(j,N){
            int ne=A[j]%i;
            int po=(i-A[j]%i)%i;
            vec.push_back({ne,po});
        }
        sort(all(vec));
        rep(j,N)posum+=vec[j].second;
        rep(j,N){
            if(posum==nesum){
                if(nesum<=K){
                    chmax(ans,i);break;
                }
            }
            nesum+=vec[j].first;
            posum-=vec[j].second;
        }
        if(posum==nesum){
            if(nesum<=K){
                chmax(ans,i);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		Integer A[]= {1,3,5,7,8,10,12};
		Integer B[]= {4,6,9,11};
		Integer C[]= {2};
		if(Arrays.asList(A).contains(x)){
			if(Arrays.asList(A).contains(y)){
				System.out.println("Yes");
			}
		}
		if(Arrays.asList(B).contains(x)){
			if(Arrays.asList(B).contains(y)){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
		if(x == 2 || y == 2){
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define ll long long int 
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	string d="ABC";
	ll i=0,j=0,c=0;
	bool cc=0;
	while(i<s.length()-2){
	    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
	        i+=3;
	        c++;
	        continue;
	    }
	    i++;
	}
	std::cout << c << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);


int main()
{
	FIO;
	long long n, k;
	vector<long long>m;
	cin >> n >> k;

	for (long long i = 0; i < n; i++)
	{
		long long x;
		cin >> x;
		m.push_back(x);
	}

	sort(m.rbegin(), m.rend());

	long long sum = 0;

	for (long long i = k; i < n; i++)
	{
		sum += m[i];
	}

	cout << sum;
}


Measured memory_bytes: 5332
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


vector<int>TopologicalSort(int n, vector<int>in, vector<int>e[]) {
	stack<int>st;
	for (int i = 0; i < n; i++)if (!in[i])st.push(i);
	vector<int>ret;
	while (st.size()) {
		int i = st.top();
		st.pop();
		ret.pb(i);
		fore(x, e[i]) {
			in[x]--;
			if (!in[x])st.push(x);
		}
	}
	return ret;
}

struct RollingHash {
	vector<ll>hash;
	vector<ll>base_pow;
	ll base, mod;
	const ll DEFAULT_BASE = 1009, DEFAULT_MOD = 1e9 + 7;
	RollingHash(string S = "", ll base_ = -1, ll mod_ = -1) {
		base = (base_ > 0) ? base_ : DEFAULT_BASE;
		mod = (mod_ > 0) ? mod_ : DEFAULT_MOD;
		if (S.size() > 0)initialize(S);
	}
	void initialize(string& S) {
		int N = S.size();
		vector<int>s(N);
		for (int i = 0; i < N; i++)s[i] = S[i];
		initialize2(s);
	}

	void initialize2(vector<int>& S) {
		hash.resize(S.size() + 1);
		base_pow.resize(S.size() + 1);
		hash[0] = 0;
		base_pow[0] = 1;
		for (int i = 1; i <= S.size(); i++) {
			hash[i] = (hash[i - 1]*base + S[i-1]) % mod;
			base_pow[i] = base_pow[i - 1] * base % mod;
		}
	}

	//[a,b)
	ll between(int a,int b) {
		return (mod + hash[b] - hash[a] * base_pow[b - a] % mod)%mod;
	}
};

int dp[1010101];

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

  int a,b;
  cin >> a>>b;
  if((a+b)%2)puts("IMPOSSIBLE");
  else puts((a+b)/2);
	return 0;
}


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

int main(){
    long long x;
    cin>>x;
    long long n=x%11,m;
    if(n==0) m=0;
    else if(n<=6) m=1;
    else m=2;
    cout<<x/11*2+m<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    a = list(map(str, input().split()))
    odd = a[::2]
    even = a[1::2]

    if n % 2 == 0:
        result = even[::-1] + odd
    else:
        result = odd[::-1] + even

    print(' '.join(result))


Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
class UnionFind {
	vector<int> par;
public:
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x=root(x);
		y=root(y);
		if(x==y)return;
		else par[x] = y;
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,ans=0;
	cin>>n>>m;
	vector<int> a(m),b(m);
	UnionFind uf;
	uf.init(n);
	FOR(i,0,m){
		cin>>a.at(i)>>b.at(i);
		a.at(i)--;
		b.at(i)--;
	}
	FOR(i,0,m){
		uf.init(n);
		FOR(j,0,m){
			if(i!=j)uf.unite(a[j],b[j]);
		}
		int k = uf.root(0);
		FOR(j,0,n){
			if(uf.root(j)!=k){
				ans++;
				break;
			}
		}
	}
	pri(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main(){
  long long a,b,c,d;
  cin >> a >> b >> c;
  d = c-a-b;
  if(4*a*b < d*d and d>0){
    cout<< "Yes" << endl;
  }
  else{
    cout<< "No" << endl;
  }    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 500000
#define INF 2147483647
#define ll long long
using namespace std;

int main(){
    int n,m;
    while(cin>>n>>m)
    {
        int sum=n+m;
        if(sum%3==0)
            cout<<"Possible\n";
        else if(m%3==0)
            cout<<"Possible\n";
        else if(n%3==0)
            cout<<"Possible\n";
        else
            cout<<"Impossible\n";
    }
    return 0;
}


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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  ll n,k;
  cin >> n >> k;
  vector<ll> v;
  for (int i = 1; i * i <= n; i++) {
    v.pb(i);
    if (n/i != i) {
      v.pb(n/i);
    }
  }
  sort(v.begin(),v.end());
  map<ll,ll> mp,mp1;
  vector<ll> v1(sz(v));
  mp[1] = 1;
  v1[0] = 1;
  mp1[1] = 0;
  for (int i = 1; i < sz(v); i++) {
    mp[v[i]] = v[i] - v[i-1];
    v1[i] = v[i] - v[i-1];
    mp1[v[i]] = i;
  }

  REP(i,k) {
    for (int j = 1; j < sz(v1); j++) {
      v1[j] += v1[j-1];
      v1[j] %= MOD;
    }
    reverse(v1.begin(),v1.end());
    for (int j = 1; j < sz(v1); j++) {
      v1[j] *= mp[v[j]];
      v1[j] %= MOD;
    }
  }
  cout << v1[0] << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

void dfs(vvi &g, vll &sx, vll &ans, vi &visited, ll v, ll p)
{
    if (visited[v] == 1)
    {
        return;
    }
    visited[v] = 1;

    if (p == -1)
    {
        ans[v] = sx[v];
    }
    else
    {
        ans[v] = ans[p] + sx[v];
    }

    for (ll i : g[v])
    {
        if (i == p)
        {
            continue;
        }
        dfs(g, sx, ans, visited, i, v);
    }
}

int main()
{
    int n, q;
    cin >> n >> q;
    vvi g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vll sx(n, 0);
    for (int i = 0; i < q; i++)
    {
        int p;
        ll x;
        scanf("%d %lld", &p, &x);
        p--;
        sx[p] += x;
    }

    vll ans(n, 0);
    vi visited(n, 0);
    dfs(g, sx, ans, visited, 0, -1);

    for (int i = 0; i < n - 1; i++)
    {
        printf("%lld ", ans[i]);
    }
    printf("%lld\n", ans[n - 1]);

    return 0;
}


Measured memory_bytes: 32896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,min_=1000000000000000000;cin>>n;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i ==0)
    {
      ll j=n/i;
      min_=min(min_,i-1+j-1);
    }    
  }
  cout<<min_;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// コンパイル　g++ -std=c++17 a.cpp


int main() {
    ll n, y;
    cin >> n >> y;
    n++;

    rep(i,n){
        rep(j,n-i){
            ll tmp = y - i * 10000 - j * 5000;
            if(tmp % 1000 == 0){
                if(i + j + tmp/1000 == n-1){
                    cout << i << " " << j << " " << tmp / 1000 << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;


}


Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
puts "Yes"
l=[]
n.times do
  l << []
end
m.times do
  a,b=gets.split.map(&:to_i)
  l[a-1] << b-1
  l[b-1] << a-1
end
vi=[0]
s=[0]
a=[nil]*(n-1)
ac=0
while ac<n-1
  z=[]
  s.each do |ss|
    l[ss].each do |lss|
      l[lss].delete(ss)
      if a[lss-1]==nil
        a[lss-1]=ss+1
        ac+=1
        z << lss
      end
    end
  end
  s=z.dup
end
puts a

Measured memory_bytes: 33120
#include <iostream>
using namespace std;
int N,A[100002],B[100001];
int main() {
	cin>>N;
	for(int i=1;i<=N+1;i++)cin>>A[i];
	for(int i=1;i<=N;i++)cin>>B[i];
	long long c=0;
	for(int i=1;i<=N;i++){
		if(B[i]<=A[i]){c+=B[i];A[i]-=B[i];B[i]=0;}
		else{c+=A[i];B[i]-=A[i];A[i]=0;
		   if(B[i]<=A[i+1]){c+=B[i];A[i+1]-=B[i];B[i]=0;}
		   else{c+=A[i+1];B[i]-=A[i+1];A[i+1]=0;}
		}
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int n , m ,q;


class var 
{
public:
	int di,ai,bi,ci;
};
var A[N];
vector<string> vec;

void build_str(int i , int prev , string str)
{
	if(i == n)
	{
		vec.pb(str);
		return;
	}

	loop(j,prev,m+1)
	{
		string res = str;
		res += ('0'+j);
		build_str(i+1,j,res);
	}
}

void solve()
{
	cin >> n >> m >> q;

	loop(i,0,q)
	{
		cin >> A[i].ai >> A[i].bi >> A[i].ci >> A[i].di;
	}

	string res = "";

	build_str(0,1,res);

	int ans = 0;

	loop(i,0,vec.size())
	{
		int sum = 0;
		loop(j,0,q)
		{
			int x = vec[i][A[j].ai-1]-'0';
			int y = vec[i][A[j].bi-1]-'0';
			if(y-x == A[j].ci)sum += A[j].di;
		}
		ans = max(sum,ans);
	}

	cout << ans;

}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 7412
#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(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

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

ll powll(ll n,ll k){ ll ret=1; while(k){ if(k&1)ret=ret*n; n=n*n; k>>=1; } return ret; }

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  map<ll,int> mp;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a.rbegin(),a.rend());
  int ans = 0;
  rep(i,n){
    if(mp[a[i]]<=0) continue;
    ll tmp = floorl(log2(a[i]));
    ll nx = powll(2,tmp+1);
    if(mp[nx-a[i]]>0){
      if(nx==2*a[i] && mp[a[i]]==1) continue;
      ans++;
      mp[nx-a[i]]--;
      mp[a[i]]--;
    }
  }
  cout << ans << ln;
  return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

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

void solve(ll testnum)
{
    string s;
    cin >> s;
    ll ss = 0;
    for(ll i=0; i<s.size(); i++) {
    	ss += (ll)(s[i] - '0');
    }
    if(ss%9 == 0) {
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 3764
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;



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

  int h,w,a,b;
  cin>>h>>w>>a>>b; 
  int g[h][w];
  rep(i,w){if(i<a)g[0][i]=1; else g[0][i]=0;}
  if(a==0&&b==0){
    rep(i,h)rep(j,w)g[i][j]=0;
  }else if(b==0){
    rep(i,w)rep(j,h)if(i<a)g[j][i]=0; else g[j][i]=1;
  }else{rep(i,w){
    rer(j,1,h){
      if(g[0][i]){
        if(j<b)g[j][i]=1; else g[j][i]=0;
      }else{
        if(j<b)g[j][i]=0; else g[j][i]=1;
      }
    }
  }}
  rep(i,h){
    rep(j,w)cout<<g[i][j];
    cout<<endl;
  }
}

Measured memory_bytes: 5120
main = do
  n <- read <$> getLine
  ps <- sequence $ replicate n getPos
  putStrLn $ if (all id (zipWith travel ((Pos 0 0 0):ps) ps))
  then "Yes"
  else "No"

data Pos = Pos Int Int Int
getPos = do
  t:x:y:_ <- (map read.words) <$> getLine
  return $ Pos t x y
travel (Pos t x y) (Pos t' x' y') = dt >= dd && mod (dt-dd) 2 == 0
  where
    dt = t' - t
    dd = abs (x'-x) + abs (y'-y)


Measured memory_bytes: 77180
#include <iostream>
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    while (a != 0 && b != 0){
        for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
                if(i == 0 || i == a-1 || j ==0 || j == b-1){
                    cout << "#";
                }else{
                    cout << ".";
                }
               
            }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;
    }
     
}


Measured memory_bytes: 3068
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(500005)


def solve(L: int, R: int, d: int):
    counter = 0
    for i in range(L,R+1):
        if (i % d == 0):
            counter += 1
    print(counter)



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(L, R, d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int a[100], b[100], c[100], d[100];
int n, m, q;
int ans = 0;
void dfs(V& s,int prev) { // 10重ループじゃなくてdfsを疑え
	if (s.size() == n) {
		int tmp = 0;
		rep(i, q) {
			if (s[b[i]] - s[a[i]] == c[i]) tmp += d[i];
		}
		chmax(ans, tmp);
		return;
	}
	for (int i = max(1, prev); i <= m; i++) {
		s.push_back(i);
		dfs(s, i);
		s.pop_back();
	}
}
int main() {
	cin >> n >> m >> q;
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--, b[i]--;
	}
	V s;
	dfs(s, -1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
H, W = gets.split(" ").map(&:to_i)
a = Array.new

H.times do |i|
    a[i] = gets.split(" ").map(&:to_i)
end

ans = []

H.times do |i| #　横方向にずらす
    (W - 1).times do |j|
        if a[i][j].odd?
            a[i][j + 1] += 1
            ans << [i + 1, j + 1, i + 1, j + 2].join(" ")
        end
    end
end

j = W - 1 #　端のマスが奇数の場合
(H - 1).times do |i|
    if a[i][j].odd?
        a[i + 1][j] += 1
        ans << [i + 1, j + 1, i + 2, j + 1].join(" ")
    end
end

puts ans.size, ans

Measured memory_bytes: 36092
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  P((n - 1) / 2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    int N;
    int s;
    int f;
int main() {
	string ans;
	cin >> N;
	vector<int> vec(N);
	for (auto& v : vec){
	cin >> v;}
  for(int i=0;i<N;++i){
    int a = vec[i];
      if(a%2 == 0&&!(a%3==0||a%5==0)){
      f++;}}
  
    if(f==0)ans ="APPROVED";
    else ans ="DENIED";
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main() {
    int n, h_, h, ans = 0, num = 0;
    cin >> n >> h_;
    for(int i = 0; i < n-1; ++i) {
        cin >> h;
        if(h_ >= h) {
            num++;
        } else {
            num = 0;
        }
        ans = max(num, ans);
        h_ = h;
    }
  	cout << ans << '\n';
}


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


int main(){
  vector<int> vec;
  vec ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n ;
  cin >>n;
  cout<< vec.at(n-1)<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e10

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> str;
    if(str=="ABC")	cout<<"ARC";
    else	cout<<"ABC";
    
    
}













int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */



Measured memory_bytes: 3604
function Main (C) {
  C = C.split("\n").map(inp => inp.split(""));
  C.pop();
  var F = [
    [C[1][2], C[1][1], C[1][0]],
    [C[0][2], C[0][1], C[0][0]]
  ];
  var ans = "YES";
  for (var i = 0; i < 2; i++) {
    for (var j = 0; j < 3; j++) {
      if (F[i][j] != C[i][j]) {
        ans = "NO";
      }
    }
  }
  console.log(ans);
}

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

Measured memory_bytes: 7372
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll c=a+b;
	if(c&1)
		cout<<"IMPOSSIBLE";
	else
		cout<<c/2;
    return 0;
}


//252908XL

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5, MAX_K = 100;
ll N, K;
ll height[MAX_N];

ll dp[MAX_N];

int main(){
  //input
  cin >> N >> K;
  REP(i, N){
    cin >> height[i];
  }
  //init dptable
  REP(i, N){
    dp[i] = INF;
  }
  dp[0] = 0;
  FOR(i, 1, N){
    FOR(j, 1, K + 1){
      if (i - j >= 0){
        chmin(dp[i], dp[i-j] + abs(height[i] - height[i-j]));
      }
    }
  }
  cout << dp[N-1] << endl;



}


Measured memory_bytes: 1792
n, m, x, y = map(int, input().split())
l_x = list(map(int, input().split()))
l_y = list(map(int, input().split()))

max_l_x = max(l_x)
min_l_y = min(l_y)

b_x = x if max_l_x < x else max_l_x
b_y = min_l_y if min_l_y < y else y

if b_x < b_y:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int sum = Math.max(a,b);
      if(sum == a){
      	sum = sum + Math.max(a-1,b);
      }
      else{
      	sum = sum + Math.max(a,b-1);
      }
      System.out.println(sum);
    }
}

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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN2(n,m)
    vector<int> v(m);
    rep(i,m) cin >> v[i];
    sort(v.begin(),v.end());

    vector<int> d(m-1);
    long long sum = 0;
    rep(i,m-1){
        d[i] = v[i+1] - v[i];
        sum += d[i];    
    }
    
    sort(d.begin(),d.end());

    rep(i,n-1){
        if(!d.size()) break;
        auto itr = d.end() -1;
        sum -= *itr;
        d.erase(itr);
    }

    cout << sum << endl;
}



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

int main(){
    int m,d;
    scanf("%d%d",&m,&d);

    ll ans=0;
    for (int i=1;i<=m;i++)
    {
        for (int j=1;j<=d;j++)
        {
            int t=j/10;
            int g=j%10;

            if (t>=2 && g>=2 && t*g==i) ans++;
        }
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
  int h,w,i,j,sharp=0;
  char s[10][10];
  scanf("%d%d",&h,&w);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf(" %c",&s[i][j]);
    }
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(s[i][j]=='#') sharp++;
    }
  }
  if(h+w-1==sharp) printf("Possible");
  else printf("Impossible");
  return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque
sys.setrecursionlimit(10**7)


def BFS(s,target):
    inf=float("inf")
    color=["white" for _ in range(n)]
    D=[inf for _ in range(n)]
    M=[[] for _ in range(n)]
    for i in AB:
        if i==target:continue
        a,b=i[0]-1,i[1]-1
        M[a] +=[b]
        M[b] +=[a]

    color[s]="gray"
    D[s]=0
    queue=deque([s])

    while len(queue)!=0:
        u=queue.popleft()
        color[u]="gray"
        for i in M[u]:
            if color[i]=="white":
                color[i]="gray"
                D[i]=D[u]+1
                queue.append(i)
        color[u]="black"

    return True if any([i==inf for i in D]) else False


n,m=map(int,input().split())
AB=[tuple(map(int,input().split())) for _ in range(m)]

cnt=0
for i in range(m):
    cnt +=BFS(0,AB[i])
print(cnt)

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

int main(void) {

	string s;
	int ans = 700;

	cin >> s;

	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o')
			ans += 100;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    ss=[input() for _ in range(n)]
    cnt=Counter(ss)
    print(cnt["E869120"])

main()



Measured memory_bytes: 8288
N=int(input())
A=list(map(int,input().split()))
dic={}
for i in A:
  if i not in dic.keys():
    dic.update({i:1})
  else:
    dic[i]+=1
ans=sum([int(j*(j-1)/2) for j in dic.values()])
for k in A:
  num=dic[k]
  if num>=1:
    print(int(ans-num+1))
  else:
    print(ans)

Measured memory_bytes: 24748
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	string S;
	cin >> S;
	
	char now = S[0];
	rep(i,S.size()){
		if(S[i] != now){
			ans++;
			now = S[i];
		}
	} 

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
//created by Whiplash99
import java.io.*;
import java.util.*;
import java.util.function.BiPredicate;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        ArrayDeque<Long> Q=new ArrayDeque<>();
        ArrayList<Long> list=new ArrayList<>();

        for(i=1;i<=9;i++) Q.add(i+0l);

        int lim=(int)(1e5+10);
        while (lim-->0)
        {
            long num=Q.poll();
            long d=num%10;

            list.add(num);
            if(d>0) Q.add(num*10+d-1);
            Q.add(num*10+d);
            if(d<9) Q.add(num*10+d+1);
        }

        System.out.println(list.get(Integer.parseInt(br.readLine().trim())-1));
    }
}

Measured memory_bytes: 35924
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;



public class Main {
	final int N = 30*2;		//30じゃだめ。スタートからの絶対値が30までってこと。
	final int[][] ofs = {
			{1, 0}, {1, 1}, {0, 1}, {-1, 0}, {-1,-1}, {0, -1}
	};
	boolean[][] visited;
	int[][] d;
	
	int bfs(int sx, int sy, int t){
		int c = 1;
		visited[sy+N][sx+N] = true;
		
		Queue<int[]> q = new LinkedList<int[]>();
		int[] ne = {sx, sy};
		q.offer(ne);
		while(true){
			if(q.isEmpty()){ break; };
			ne = q.poll();
			if(d[ne[1]+N][ne[0]+N] >= t){ continue; };
			
			for(int i=0; i<ofs.length; ++i){
				final int[] e = {
						ne[0] + ofs[i][0], ne[1] + ofs[i][1]
				};
				//if(-N<=e[0] && e[0]<=N && -N<=e[1] && e[1]<=N){
					if(!visited[e[1]+N][e[0]+N]){
						visited[e[1]+N][e[0]+N] = true;
						c++;
						q.offer(e);
						d[e[1]+N][e[0]+N] = d[ne[1]+N][ne[0]+N] + 1;
					}
				//}
			}
		}
		
		return c;
	}
	
	
	
	void io(){
		Scanner sc = new Scanner(System.in);
		while(true){
			visited = new boolean[N*2+1][N*2+1];	//filled false
			d = new int[N*2+1][N*2+1];	//filled 0
			
			final int t = sc.nextInt();  final int n = sc.nextInt();
			if(t==0 && n==0){ return; }
			for(int i=0; i<n; ++i){
				final int x = sc.nextInt();  final int y = sc.nextInt();
				visited[y+N][x+N] = true;
			}
			final int sx = sc.nextInt();  final int sy = sc.nextInt();
			
			System.out.println(bfs(sx, sy, t));
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
}

Measured memory_bytes: 14000
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

signed main()
{
    ll A, B, C, D; cin >> A >> B >> C >> D;


    ll divByC = B / C - A / C;
    if (A % C == 0) ++divByC;
    ll divByD = B / D - A / D;
    if (A % D == 0) ++divByD;

    ll E = lcm(C, D);
    ll divByE = B / E - A / E;
    if (A % E == 0) ++divByE;

    ll total = B - A + 1;
    ll ans = total - (divByC + divByD - divByE);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static long MOD = (long) 1e9 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long dp[] = new long[n + 1];
		Arrays.fill(dp, -1);
		int m = sc.nextInt();
		final long MOD = 1_000_000_007l;
		int[] a = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			if (i >= 1 && a[i] - a[i - 1] == 1) {
				System.out.println(0);
				System.exit(0);
			}
			dp[a[i]] = 0;
		}
		sc.close();

		dp[0] = 1;
		for (int i = 1; i < n + 1; i++) {
			if (dp[i] == -1) {
				dp[i] = dp[i - 1] + (i >= 2 ? dp[i - 2] : 0);
				dp[i] %= MOD;
			}
		}
		System.out.println(dp[n]);
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static Integer[] arrayInteger(Scanner sc, int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 58860
N = int(input())
A = list(map(int,input().split()))
m = max(A)
U = [0]*(m+1)
for e in A:
    U[e] += 1
ans = 0
for k in range(1,m+1):
    if U[k] == 1:
        ans += 1
    if U[k] > 0:
        for l in range(2*k,m+1,k):
            if U[l] > 0:
                U[l] += 1
print(ans)


Measured memory_bytes: 106004
#include <iostream>
#include <map>

using namespace std;

int main(void) {
	int s;
	cin >> s;
	map<int,bool> memo;
	memo[s] = true;
	int ind = 1;
	int now = s;
	bool find = false;
	while (!find) {
		++ind;
		if (now%2 == 0) {
			now /= 2;
		}
		else {
			now = (3*now) + 1;
		}
		if (memo[now]) {
			cout << ind << endl; 
			find = true;
		}
		else {
			memo[now] = true;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = scan.nextInt();
		int min = 0;
		int max = 0;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			list.add(scan.nextInt());
			int num = list.get(i);
			if (i == 0) {
				min = num;
				max = num;
			}
			sum += num;
			min = Math.min(min, num);
			max = Math.max(max, num);
		}
		System.out.printf("%d %d %d\n", min, max, sum);
	}
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 42288