akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}
 
//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
 
int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}
 
ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}
 
template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}
 
template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}
 
template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}
 
const int MAXN = 200010;
const int INF = 1000000000;
const int MOD = 1000000007;

int n;
int a[MAXN], b[MAXN];

int main()
{
	
	n = inp();
	for (int i = 1; i <= n+1; ++ i)
		a[i] = inp();
	for (int i = 1; i <= n; ++ i)
		b[i] = inp();
	i64 ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		int d = min(a[i], b[i]);
		ans += d;
		a[i] -= d;
		b[i] -= d;
		d = min(a[i+1], b[i]);
		ans += d;
		a[i+1] -= d;
		b[i] -= d;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string x;
    int s=0;
    cin>>x;
    int l=x.length();
    for(int i=0;i<x.length();i++){
        if(x[i]=='S'){
            s++;
        }else{
            if(s>0){
                s--;
                l-=2;
            }
        }
    }
    cout<<l<<endl;
    
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

void solve(){
    int N; cin >> N;
    vector<pair<int,int>> left,right;
    ll ans=0;
    for (int i=0;i<N;++i){
        int K,L,R; cin >> K >> L >> R;
        if (L>=R){
            ans+=R;
            left.emplace_back(--K,L-R);
        } else {
            ans+=L;
            right.emplace_back(--K,R-L);
        }
    }
    sort(ALL(left));
    reverse(ALL(left));
    priority_queue<int> pq;
    int n=left.size(),m=N-n,now=0;
    for (int i=n-1;i>=0;--i){
        while(now<n&&left[now].first>=i){
            pq.emplace(left[now++].second);
        }
        if (!pq.empty()){
            ans+=pq.top(); pq.pop();
        }
    }
    sort(ALL(right));
    while(!pq.empty()) pq.pop();
    now=0;
    for (int i=n;i<N;++i){
        while(now<m&&right[now].first<i){
            pq.emplace(right[now++].second);
        }
        if (!pq.empty()){
            ans+=pq.top(); pq.pop();
        }
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    for (;T--;){
        solve();
    }
}

Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string t = "AKIHABARA";
    if(len(s) > len(t)){
        cout << "NO\n";
        return 0;
    }
    int i = 0;
    int j = 0;
    int n = len(s);
    while(j < len(t)){
        if(i < n && s[i] == t[j]){
            i++,j++;
        }else if(t[j] == 'A'){
            j++;
        }else{
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338

int main(){
    int a,b,h,m;

    scanf("%d %d %d %d", &a, &b, &h, &m);

    long double arg;
    long double c;

    arg = PI * ((long double)(h * 60 + m) / 2 - (long double)m * 6) / 180;
    c = sqrtl((long double)(a * a + b * b) - (long double)2 * a * b * cosl(arg));

    printf("%20.20Lf", c);
    }

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<int> A, B;

signed main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);

    vector<pair<int, int>> index(N);

    rep(i, N)
    {
        cin >> A[i] >> B[i];
        index[i] = (mp(B[i], A[i]));
    }

    sort(index.begin(), index.end());

    int t = 0;

    rep(i, N)
    {
        t += index[i].sec;
        //cout << t << endl;
        if (t > index[i].fst)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

namespace abc139_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string yohou = Console.ReadLine();
            string jissai = Console.ReadLine();
            int count = 0;

            for(int i=0; i < 3; i++)
            {
                if (yohou.Substring(i,1) == jissai.Substring(i, 1))
                {
                    count = count + 1; 
                }
            }
            Console.WriteLine(count);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

ll d, n, m;
ll in[100000];

int main() {
	while (cin >> d, d) {
		cin >> n >> m;
		for (int i = 0; i < n - 1; i++) {
			cin >> in[i];
		}
		sort(in, in + n - 1);
		in[n - 1] = d;

		ll ans = 0;

		for (int i = 0; i < m; i++) {
			ll a;
			cin >> a;

			int tmp = lower_bound(in, in + n, a) - in;
			ans += min(in[tmp] - a, a - in[tmp - 1]);

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

Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	string s,t;
	cin >> s >> t;

	vector< vec_i> dp(3001, vec_i(3001, 0));
	rep(i, s.size()){
		rep(j, t.size()){
			if(s[i] == t[j]){
				dp[i+1][j+1] = dp[i][j] + 1;
			}else{
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
			}
		}
	}

	string ans = "";
	int i = s.size(), j = t.size();
	while(dp[i][j] > 0){
		if(dp[i][j-1] == dp[i][j]){
			j--;
		}else if(dp[i-1][j] == dp[i][j]){
			i--;
		}else if(dp[i-1][j-1] == dp[i][j] - 1){
			ans = t[j-1] + ans;
			i--; j--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 35584
class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            x, y = y, x
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        self.size[x] += self.size[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]


def p_e():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        x, y, z = map(int, input().split())
        uf.unite(x - 1, y - 1)
    ans = set()
    for i in range(n):
        ans.add(uf.find(i))
    print(len(ans))
    

if __name__ == '__main__':
    p_e()

Measured memory_bytes: 80728
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
using namespace std;

int main()
{
    int x, y;
    for (int i = 1; i <= 3000; i++)
    {
        cin >> x >> y;
        if (x == 0 && y == 0)
        {
            return 0;
        }
        else if (x > y)
        {
            printf("%d %d\n", y, x);
        }
        else if (x < y)
        {
            printf("%d %d\n", x, y);
        }
        else if (x == y)
        {
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
//int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
/**************/
int h[int(1e5)] = { 10,30,40,20 };
ll dp[int(1e5)];
int main()
{
	int n=4;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> h[i];
	for (int i = 0; i < n; i++)dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			
			int jump = i+j + 1;
			if (jump >= n)continue;
			dp[jump] = min(dp[jump],dp[i] + abs(h[jump] - h[i]));
		}
	}
	cout << dp[n-1] << endl;

}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  string str,str2;

  for(int u=0;u<n;u++) {


  cin >> str;

  set <string> S;
  S.clear();

  int count = 0;
  string stra ,strb ,strt;

  for(int i=1;i<str.size();i++){
    stra = str.substr(0,i);
    strb =  str.substr(i);    
    //  cout << stra << "+" << strb << endl;

    for(int j=0;j<2;j++) {
      for(int k=0;k<2;k++) {

	reverse(stra.begin() , stra.end());

	//	cout << stra << "+" << strb << endl;  

	S.insert(stra + strb);

	reverse(strb.begin() , strb.end());

	//	cout << stra << "+" << strb << endl;
	S.insert(stra+strb);

      }
      strt = stra;
      stra = strb;
      strb = strt;
    }

  }
  cout << S.size() << endl;

  }

  return 0;
}

Measured memory_bytes: 1292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  double N; cin >> N;
  LL cnt = 0;
  for (LL A = 1; A < N; ++A) {
    LL bs = ceil(N/A) - 1;
    cnt += bs;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m >> k;

    bool isAns = false;
    for (int in = 0; in <= n; in++)
    {
        for (int jm = 0; jm <= m; jm++)
        {
            if (in * m + jm * n - 2 * (in * jm) == k)
                isAns = true;
        }
    }

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

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int p,q,r;
  int min;
  scanf("%d%d%d",&p,&q,&r);
  min=p+q;
  if(q+r<min)
  min=q+r;
  if(min>r+p)
  min=r+p;
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 128
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 510
int n;
bool a[N][N];
int f[N][N];
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
struct DOT{
	int x,y;
} q[N*N];
void expand(int X,int Y){
	int head=1,tail=1;
	q[1]={X,Y};
	while (head<=tail){
		int x=q[head].x,y=q[head].y;
		++head;
		for (int i=0;i<4;++i){
			int tx=x+dx[i],ty=y+dy[i];
			if (tx<1 || tx>n || ty<1 || ty>n || f[x][y]+a[x][y]>=f[tx][ty])
				continue;
			f[tx][ty]=f[x][y]+a[x][y];
			q[++tail]={tx,ty};
		}
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			a[i][j]=1,f[i][j]=min(min(i-1,n-i),min(j-1,n-j));
	int ans=0;
	for (int i=1;i<=n*n;++i){
		int p,x,y;
		scanf("%d",&p);
		x=(p-1)/n+1;
		y=p%n;
		y=((y==0)?n:y);
		ans+=f[x][y];
		a[x][y]=0;
		expand(x,y);
	}
	printf("%d\n",ans);	
	return 0;
}

Measured memory_bytes: 6260
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
map<ii, int> cnt;
li binpow(int a, int b)
{
	if(b==0) return 1LL;
	int temp=binpow(a, b/2);
	if(b%2) return (temp*temp%MOD)*a%MOD;
	return temp*temp%MOD;
}
ii modif(ii x)
{
	if(x.se<0) 
	{
		x.fi=-x.fi;
		x.se=-x.se;
	}
	return x;
}
ii get_inv(ii x)
{
	return modif({-x.se, x.fi});
}
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int n, cnt1=0, cnt2=0, cnt3=0;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		int a, b;
		cin>>a>>b;
		if(!a and !b) cnt1++;
		else if(!a and b) cnt2++;
		else if(a and !b) cnt3++;
		else 
		{
			int d=__gcd(a, b);a/=d;b/=d;
			cnt[modif({a, b})]++;
		}
	}
	int ans=(1+(binpow(2, cnt2)-1+binpow(2, cnt3)-1))%MOD;
	set<ii> us;
	for(auto temp: cnt)
	{
		ii a=temp.fi, b=modif(get_inv(temp.fi));
		if(us.count(a) or us.count(b)) continue;
		ans=ans*((binpow(2, cnt[a])+binpow(2, cnt[b])-1)%MOD)%MOD;
		us.insert(a);
		us.insert(b);
	}
	ans=ans+cnt1-1;
	while(ans<0) ans+=MOD;
	cout<<ans;
}




Measured memory_bytes: 53392
#include <stdio.h> 
 
 
 int main(){ 
     int x; 
     int i=0; 
     while(1){ 
         scanf("%d", &x); 
         if(x==0)break; 
         printf("Case %d: %d\n", ++i, x); 
     } 
     return 0; 
 } 


Measured memory_bytes: 2032
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = NextS();
		
		long n, x;
		n = long.Parse(s[0]);
		x = long.Parse(s[1]);
		
		long ans = n;
		long a = x;
		long b = n - x;
		long tmp = 0;
		
		while(true){
		    if(b%a==0){
		        ans += b * 2 - a;
		        break;
		    } else {
		        ans += (b - b%a)*2;
		        b = b%a;
		        tmp = a; a = b; b = tmp;
		    }
		}
		
		Console.WriteLine(ans);
	}

	public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
	public static string[] NextS(){ return Console.ReadLine().Trim().Split(' '); }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(void){
    int n, ans = 0;
  	cin >> n;
    if (n == 10 || n == 100 || n == 1000 || n == 10000 || n == 100000) ans = 10;
    else for (int i = 0; i <= 5; i++) {
        ans += n % 10;
        n /= 10;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
def run():
  N = list(map(int, list(input())))
  K = int(input())
  Nlen = len(N)
  dp = [[[0]*(K+2) for _ in range(2)] for n in range(Nlen+1)]
  dp[0][0][0] = 1
  for nlen in range(Nlen):
    dN = N[nlen]
    for d in range(10):
      for j in range(2):
        for k in range(K+2):
          flagj = j or d < dN
          if (flagj == 0) and (d > dN): continue
          flagk = min(K+1, k+(d != 0))
          dp[nlen+1][flagj][flagk] += dp[nlen][j][k]
  print(dp[-1][0][K]+dp[-1][1][K])
  
if __name__ == '__main__':
    run()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[100100];
int Aeven[100100];
int Aodd[100100];
int Asum[100100];

int solve(int x) {
    //青木くんがxより大きい数をm枚とるとすると左から取る枚数の最小値を決められる
    //その和が右に残っている枚数以上ならok
    int ok = 0;
    int ng = N;
    int midi = l_b(A, A + N, x) - A;//A[midi],A[midi+1],...,A[midi+m-1]を取る
    while (ng - ok > 1) {
        int m = (ok + ng) / 2;
        if (midi + m - 1 >= N) {
            ng = m;
            continue;
        }
        int dist = A[midi + m - 1] - x;
        int leftIdx = l_b(A, A + N, x - dist) - A;
        int n = midi + m - leftIdx;
        //A[midi+m],A[midi+m+1],...,A[midi+m+n-1]
        if (midi + m + n - 1 < N)ok = m;
        else ng = m;
    }
    //高橋くんはA[midi+ok],A[midi+ok+1],...,A[N-1]と
    //A[N-2n-1],A[N-2n-3],...,A[0or1]を取る
    //ただしn=N-(midi+ok)
    int res = Asum[N - 1] - Asum[midi + ok - 1];

    int n = N - (midi + ok);
    if ((N - 2 * n - 1) % 2 == 0) {
        res += Aeven[N - 2 * n - 1];
    } else {
        res += Aodd[N - 2 * n - 1];
    }
    return res;
}

void pre() {
    Aeven[0] = A[0];
    Aodd[1] = A[1];
    Asum[0] = A[0];
    Asum[1] = Asum[0] + A[1];
    for (int i = 2; i < N; ++i) {
        if (i % 2 == 0)Aeven[i] = Aeven[i - 2] + A[i];
        else Aodd[i] = Aodd[i - 2] + A[i];
        Asum[i] = Asum[i - 1] + A[i];
    }
    rep(i, N) {
        A[i] = 4 * A[i] + 1;
    }
}

signed main() {
    int Q;
    cin >> N >> Q;
    rep(i, N) {
        cin >> A[i];
    }
    pre();
    rep(i, Q) {
        int X;
        cin >> X;
        cout << solve(4 * X) << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i=0;i<(int)n;i++)
int INF=1e9;

int main() {
  int64_t N, s=0;
  cin >> N;
  if(N%2==0) {
    N/=2;
    while(N>0) {
      s+=N/5;
      N/=5;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(d)  (d).begin(),(d).end()
#define RALL(d) (d).rbegin(), (d).rend()
#define PB push_back
#define MP make_pair
#define SZ(d) int((d).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,d,b) for(int i=(d);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(d) memset((d), 0 ,sizeof(d))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int max_v = 200;
const int max_e = max_v * (max_v - 1) / 2;
const int inf = (1 << 29);
int E, V;
VVI d(max_v);



int main()
{
	int V, E, R;
	cin >> V >> E >> R;
	VI r(R);
	REP(i, R) { cin >> r[i]; r[i]--; }
	SORT(r);
	REP(i, V) {
		d[i] = VI(V);
		REP(j, V) d[i][j] = inf;
	}

	REP(i, E) {
		int u, v, c;
		cin >> u >> v >> c;
		u--; v--;
		d[u][v] = d[v][u] = c;
	}

	REP(k, V) REP(i, V) REP(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	LL min_d = 100000LL * max_e;
	do {
		LL tmp = 0LL;
		REP(i, R - 1) tmp += d[r[i]][r[i + 1]];
		min_d = min(min_d, tmp);
	} while (next_permutation(r.begin(), r.end()));
	cout << min_d << endl;
	return 0;
}

Measured memory_bytes: 384
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
Min=A[0]

Bc=[list(map(int,input().split())) for _ in range(M)]
Bc.sort(key=lambda x: x[1],reverse=True)

j=0
ans=0
for i in range(N):
    if (j>=M) or (A[i]>=Bc[j][1]):
        break
    if (A[i]<Bc[j][1]) and (Bc[j][0]>0):
        A[i]=Bc[j][1]
        Bc[j][0]-=1
        if Bc[j][0]==0:
            j+=1

print(sum(A))



Measured memory_bytes: 33004
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  string s;
  cin >> s;

  //process
  
  
  //output
  cout << s.substr(0,3) << endl;
}

Measured memory_bytes: 3556
import sys

num = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
    print(0)
    sys.exit()
for i in a:
  if b * i > 10 ** 18:
    print(-1)
    sys.exit()
  else:
    b *= i
print(b)

Measured memory_bytes: 21476
str = input()
if str == 'SUN':
 print(7)
elif str == 'MON':
 print(6)
elif str == 'TUE':
 print(5)
elif str == 'WED':
 print(4)
elif str == 'THU':
 print(3)
elif str == 'FRI':
 print(2)
elif str == 'SAT':
 print(1)

 

Measured memory_bytes: 2940
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
struct ver
{
    int col;
    list<int> adj;
};
list<int>ans;
void solve(int i,int p,vector<ver> & rec,bool k)
{
    if(k)
    ans.push_back(i+1);
    else if(rec[i].col==0)
        ans.push_front(i+1);
    rec[i].col=1;
    for(auto it =rec[i].adj.begin();it!=rec[i].adj.end();++it)
    {
        if(rec[*it].col==0&&*it!=p)
        {
            solve(*it,i,rec,k);
            return ;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;cin>>n>>m;
    ver ob;ob.col=0;
    vector<ver>rec(n,ob);
    for(int i=0;i<m;++i)
    {
        int a,b;cin>>a>>b;
        rec[a-1].adj.push_back(b-1)
            ;rec[b-1].adj.push_back(a-1);
    }
    int posn=0;int min1=1e7;
    for(int i=0;i<n;++i)
    {
        if(rec[i].adj.size()<min1)
        {
            posn=i;
            min1=rec[i].adj.size();
        }
    }
    solve(posn,-1,rec,true);
    solve(posn,-1,rec,false);
    cout<<ans.size()<<'\n';
    for(auto i=ans.begin();i!=ans.end();++i)
    {
        cout<<*i<<' ';
    }
    cout<<'\n';
}










Measured memory_bytes: 12544
n, m, l = gets.split( " " ).map { | val | val.to_i }

matrixA = []
matrixB = []

n.times {
	matrixA.push( gets.split( " " ).map { | val | val.to_i } )
}
m.times {
	matrixB.push( gets.split( " " ).map { | val | val.to_i } )
}

output = []
c = 0
for i in ( 0 ... n )
	for j in ( 0 ... l )
		c = 0
		for k in ( 0 ... m )
			c += ( matrixA[i][k] * matrixB[k][j] )
		end
		output.push( c )
		output.push( " " )
	end
	output.pop
	output.push( "\n" )	
end

print( output.join  )

Measured memory_bytes: 7108
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N,M,K;cin>>N>>M>>K;
    vector<ll> A(N+1),B(M+1);
    A[0] = 0;B[0] = 0;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        A[i+1] = A[i] + a;
    }
    for(int i=0;i<M;i++){
        int b;cin>>b;
        B[i+1] = B[i] + b;
    }
    int ans = 0;
    int j = M;
    for(int i=0;i<=N;i++){
        if(A[i]>K) break;
        while(B[j]>K-A[i]) j--;
        ans = max(ans,i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6384
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

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

    usize n;
    std::cin >> n;
    vec<i64> a(2*n);
    for (i64& x: a) std::cin >> x;
    std::sort(ALL(a));

    i64 ans = 0;
    for (usize i=0; i<2*n; i+=2) {
        ans += a.at(i);
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 256
program sample
	implicit none
    integer(8) :: X,Y
    real(8) :: a,b
    
    read(*,*) X,Y
    
    a=real(X,8)
    b=real(Y,8)
    
    if (Y/2 == b/2) then
    	if (X*2 <= Y .and. Y <= X*4) then
        	write(*,*) 'Yes'
        else
        	write(*,*) 'No'
        end if
    else
    	write(*,*) 'No'
	end if
    stop
end program sample

Measured memory_bytes: 2856
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n,ans int
	var s []byte
	Fscan(in, &n, &s)
	i, j := 0, n-1
	for i < j {
		for ; i < j && s[i] == 'R'; i++ {
		}
		for ; i < j && s[j] == 'W'; j-- {
		}
		if i>=j {
			break
		}
		ans++
		i++
		j--
	}
	Fprintln(out, ans)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 3420
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int k, s;
    int count = 0;
    cin >> k >> s;
    int maxx = min(k, s);
    int minx = max(0, s - 2 * k);
    for (int i = minx; i <= maxx; i++) {
        int yzsum = s - i;
        int maxy = min(yzsum, k);
        int miny = max(0, yzsum - k);
        count += maxy - miny + 1;
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 256
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	int L,R,d;
	cin >> L>>R>>d;
	/////////////////////
	
	int out = 0;
	for( int i = L; i <= R; ++i ) {
		if( i % d == 0 ) {
			out++;
		}
	}
	
	//////// 出力 ////////
	cout << out;
	/////////////////////
	
	return 0;
}
#if 0


#endif


Measured memory_bytes: 3628
n, l = map(int,input().split())

pies = [l+i-1 for i in range(1,n+1)]
pie_plan = sum(pies)
pie_real = 0
diff_plan_real = float("inf")
for i in range(1,n+1):
    pie_provisonal = sum([l+j-1 for j in range(1,n+1) if j != i])
    if abs(pie_plan - pie_provisonal) < diff_plan_real:
        diff_plan_real = abs(pie_plan - pie_provisonal)
        pie_real = pie_provisonal
    
print(pie_real)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


long long  gcd(long long  a, long long  b) { return b ? gcd(b, a%b) : a; }
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL N; cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	LL ans = a[0];
	FOR(i, 0, N) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;

	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  string n;
  cin >> n;
  rep(i, n.size()) {
    if (n[i] == '1')
      cout << '9';
    else
      cout << '1';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  if((0<=a)&&(a<=100)&&(0<=b)&&(b<=100)&&(0<=c)&&(c<=100))
    {
      d = b/a;
      if(d>=c) printf("%d",c);

      else printf("%d\n",d);
    }

return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        List<Integer> nums = new ArrayList<>();
        for(int i = 0;i < n;i++) {
            nums.add(sc.nextInt());
        }
        Collections.sort(nums);
        int n1 = nums.get(n / 2 - 1);
        int n2 = nums.get(n / 2);
        System.out.println(n2 - n1);
    }
}

Measured memory_bytes: 59096
#
# abc091 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
apple
orange
apple
1
grape"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
apple
orange
apple
5
apple
apple
apple
apple
apple"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    l = {}
    for _ in range(N):
        w = input()
        if w in l:
            l[w] += 1
        else:
            l[w] = 1
    M = int(input())
    for _ in range(M):
        w = input()
        if w in l:
            l[w] -= 1
        else:
            l[w] = -1
    print(max(max(l.values()), 0))


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16232
S = input()
N = len(S)

odd = {'R', 'U', 'D'}
even = {'L', 'U', 'D'}

for i in range(0, N, 2):
    if S[i] in odd:
        continue
    else:
        print('No')
        exit()

for i in range(1, N, 2):
    if S[i] in even:
        continue
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int a[110];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;
    cin>>n;
    for(int i=0;i<2*n;++i)
        cin>>a[i];
    sort(a,a+2*n);
    int sum=0;
    for(int i=0;i<2*n;i+=2)
        sum+=a[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
int dp[50][3001];
int main() {
	int N,M,S;
	while(scanf("%d %d %d",&N,&M,&S),N|M|S) {
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int m=1;m<=M;m++) {
			for(int n=N*N;n>=1;n--) {
				for(int s=m;s<=S;s++) {
					dp[n][s]+=dp[n-1][s-m];
					if(dp[n][s]>=100000) dp[n][s]-=100000;
				}
			}
		}
		printf("%d\n",dp[N*N][S]);
	}
}

Measured memory_bytes: 1620
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

string t, b;
LL spell[1002] = {};//1-origin

int main() {
	cin >> t >> b;
	for (int i = 0; i < t.size(); i++) {
		for (int j = b.size() - 1; j >= 0; j--) {
			if (t[i] == b[j]) {
				if (!j) spell[0]++;
				else  spell[j] += spell[j - 1];
				spell[j] %= MOD;
			}
		}
	}
	cout << spell[b.size() - 1] % MOD << endl;
	return 0;
}



Measured memory_bytes: 3204
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    aa = list(map(int, input().split()))
    cnt_aa = Counter(aa)
    nc3 = cnt_aa[3]
    nc2 = cnt_aa[2]
    nc1 = cnt_aa[1]
    dp = [[[0] * (n + 1) for _ in range(nc3 + nc2 + 1)] for _ in range(nc3 + 1)]
    for c3 in range(nc3 + 1):
        for c2 in range(nc2 + nc3 - c3 + 1):
            if c3 + c2 > n: break
            for c1 in range(n + 1):
                s = c1 + c2 + c3
                if s > n: break
                if c1 > 0: dp[c3][c2][c1] += (dp[c3][c2][c1 - 1] + n / s) * c1 / s
                if c2 > 0: dp[c3][c2][c1] += (dp[c3][c2 - 1][c1 + 1] + n / s) * c2 / s
                if c3 > 0: dp[c3][c2][c1] += (dp[c3 - 1][c2 + 1][c1] + n / s) * c3 / s
    print(dp[nc3][nc2][nc1])

main()


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


def solve(a: int, s: str):
    ret = s
    if a < 3200:
        ret = 'red'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(a, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
#define pi 3.14159265359
int main()
{
    unsigned long int n,m,a;
    unsigned long long int sum=0;
    cin>>n>>m;
    while(m>0){
        cin>>a;
        sum+=a;
        m--;
    }
    if(sum<=n) cout<<n-sum<<endl;
    else cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main()
{
	
	string s;
	cin >> s;

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int num, mi = 1e9, ma = 0 , i = 0, a, ans = 0;
	cin >> num >> a;
	vector<int> d(num);
	for (; i < num; i++) {
		scanf("%d", &a);
		mi = min(mi, a);
		d[i] = a - mi;
		ma = max(ma, d[i]);
	}
	for (i = 0; i < num; i++) {
		if (d[i] == ma)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define ull unsigned long long
const int H = 1000;
const int W = 1000;
const ull mod = 1e9 + 7ULL;

int main()
{
	ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int h, w;
    string grid[H];
    cin >> h >> w;
    for (int i = 0; i < h; i++)
        cin >> grid[i];
    ull dp[H][W];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
            dp[i][j] = 0;
    }
    for (int i = 1; i < w; i++)
    {
        if (grid[0][i] == '#')
            break;
        dp[0][i] = 1ULL;
    }
    for (int i = 1; i < h; i++)
    {
        if (grid[i][0] == '#')
            break;
        dp[i][0] = 1ULL;
    }
    for (int i = 1; i < h; i++)
    {
        for (int j = 1; j < w; j++)
        {
            if (grid[i][j] == '.')
            {
                if (grid[i - 1][j] == '.')
                    dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                if (grid[i][j - 1] == '.')
                    dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            }
        }
    }
    cout << dp[h - 1][w - 1];
    return 0;
}

Measured memory_bytes: 9088