akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

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

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int x = h1 * 60 + m1;
  int y = h2 * 60 + m2;
  int ret = max(0, y - x - k);
  cout << ret << endl;
  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << " " << max(0LL,(A+B) - N) << endl;
}

Measured memory_bytes: 3596
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
#define mod 1e9+7
typedef long long ll;

void Main()
{
	string O, E;	
  	cin >> O >> E;
  	int osz = O.size();
	int esz = E.size();
  	string ans;
  	rep(i,osz){
    	ans[2*i] = O[i];
    }
	rep(i,esz){
      	ans[2*i+1] = E[i];
    }
  
  	rep(i,osz+esz){
  		cout << ans[i];
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

using namespace std;

int main(){
    int n;
    long long int k;
    cin >> n >> k;
    map<int, long long int> num;

    for(int i = 0; i < n; i++){
        int a;
        long long int b;cin >> a >> b;
        if(num.find(a) == num.end()){
            num[a] = b;
        }
        else{
            num[a] += b;
        }
    }
    map<int, long long int>::iterator itr = num.begin();
    while(itr != num.end()){
        k -= itr->second;
        if( k <= 0){
            break;
        }
        itr++;
    }
    cout << itr->first << endl;

	return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<int>> G;
vector<int> col;
void f(int u, int x) {
	col[u] = x;
	for (int v : G[u]) if (col[v] < 0) f(v, x^1);
}
int main() {
	cin >> N;
	G.resize(N);
	for (int i = 0; i < N-1; ++ i) {
		int u, v;
		cin >> u >> v;
		-- u; -- v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	col.resize(N, -1);
	f(0, 0);
	vector<vector<int>> a(3);
	vector<vector<int>> b(2);
	for (int i = 1; i <= N; ++ i) a[i%3].push_back(i);
	for (int i = 0; i < N; ++ i) b[col[i]].push_back(i);
	vector<int> r(N);
	if (b[0].size() >= a[1].size() && b[1].size() >= a[2].size()) {
		for (int v : b[0]) {
			if (a[1].empty()) {
				r[v] = a[0].back(); a[0].pop_back();
			} else {
				r[v] = a[1].back(); a[1].pop_back();
			}
		}
		for (int v : b[1]) {
			if (a[2].empty()) {
				r[v] = a[0].back(); a[0].pop_back();
			} else {
				r[v] = a[2].back(); a[2].pop_back();
			}
		}
	} else {
		int k;
		if (b[0].size() <= a[0].size()) k = 0;
		else if (b[1].size() <= a[0].size()) k = 1;
		else throw 1;
		for (int v : b[k]) {
			r[v] = a[0].back(); a[0].pop_back();
		}
		for (int v : b[k^1]) {
			for (int i = 0; i < 3; ++ i) if (!a[i].empty()) {
				r[v] = a[i].back(); a[i].pop_back();
				break;
			}
		}
	}
	for (auto x : r) cout << x << " ";
	cout << endl;
}


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

class Main {
    public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        
        List<Integer> res_list = new ArrayList<Integer>();
        res_list.add(A+B);
        res_list.add(A-B);
        res_list.add(A*B);
        Collections.sort(res_list, Collections.reverseOrder());
        System.out.println(res_list.get(0));
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

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

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,k;
	cin >> n >> k;

	int h[n];
	rep(i,n) cin >> h[i];

	sort(h,h+n);

	int ans=INF;
	rep(i,n-k+1){
		ans=min(ans,h[i+k-1]-h[i]);
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  vector<int> A;
  A = {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};
  cout << A[K-1] << endl;
}


Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
G = [input() for i in range(h)]
directions = [(1,0),(0,1),(-1,0),(0,-1)]
ans = 0

for sx in range(w):
  for sy in range(h):
    if G[sy][sx] == "#":
      continue
      
    dist = [[-1] * w for i in range(h)]
    dist[sy][sx] = 0
    que = deque([[sy, sx]])
    
    while len(que):
      y,x = que.popleft()
      for dx,dy in directions:
        nx = x + dx
        ny = y+ dy
        if not (0<=nx<w and 0<=ny<h) or G[ny][nx]=="#":
          continue
        if dist[ny][nx] != -1:
          continue
      
        dist[ny][nx] = dist[y][x] +1
        que.append([ny,nx])
      
    ans = max(ans, max([max(d) for d in dist]))
    
print(ans)

Measured memory_bytes: 3316
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

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

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
	using namespace std;

	int n, q;
	cin >> n >> q;

	string s;
	cin >> s;

	vec<int> v(s.size());

	for (int i = 1; i < s.size(); ++i)
	{
		v[i] += v[i - 1];
		if (s[i - 1] == 'A' && s[i] == 'C')
		{
			v[i]++;
		}
	}

	for (int i = 0; i < q; ++i)
	{
		int l, r;
		cin >> l >> r;
	
		cout << v[r - 1] - v[l - 1] << endl;
	}




	return 0;
}

Measured memory_bytes: 1408
N = int(input())
T, A = map(int, input().split())
H_list = [int(e) for e in input().split()]
     
diff=1000000
ans = 0
     
for i in range(len(H_list)):
  if abs(T-H_list[i]*0.006-A)<diff:
    diff = abs(T-H_list[i]*0.006-A)
    ans = i
    
print(ans+1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0
#define all(x) x.begin(), x.end()

int main(){
  int n,k,m;
  while(scanf("%d%d%d",&n,&k,&m),n|k|m){
    vector<int> v;
    rep(i,n)v.push_back(i+1);
    int cur = v.erase(v.begin()+m-1)-v.begin();
#if DEB
    printf("cur:%d\n",cur);
#endif
    rep(i,n-2){
      cur = (cur+k-1)%v.size();
      cur = v.erase(v.begin()+cur)-v.begin();
#if DEB
      printf("cur:%d\n",cur);
#endif
    }
    printf("%d\n",v[0]);
  }
  return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if (a > b) swap(a, b);

    if ((b-a) % 2 == 0) {
        cout << (b-a)/2 << endl;
    } else {
        ll d = min(a-1, n-b);
        ll ans = (d*2+(b-a)+1)/2;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

// 普通のKnapsack問題ではなかった
int main() {
	ll N, W;
	cin >> N >> W;

	vector<vector<ll>> wv(4);
	vector<vector<ll>> v_sum(4);

	ll w1, v1;
	cin >> w1 >> v1;
	wv[0].push_back(v1);
	rep(i, N-1) {
		ll w, v;
		cin >> w >> v;
		wv[w-w1].push_back(v);
	}

	rep(i, 4) {
		sort(wv[i].begin(), wv[i].end());
		reverse(wv[i].begin(), wv[i].end());
		rep(j, wv[i].size()+1) {
			if(j==0) v_sum[i].push_back(0);
			else v_sum[i].push_back(v_sum[i][j-1] + wv[i][j-1]);
		}
	}
	
	// rep(i, 4) {
	// 	cout << "v_sum: ";
	// 	rep(j, v_sum[i].size()) {
	// 		cout << v_sum[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }

	ll ans = 0;
	for(int d=min((int)(W/(w1+3)), (int)wv[3].size()); d>=0; d--) {
		ll restd = W - d*(w1+3);
		int c = min((int)(restd/(w1+2)), (int)wv[2].size());

		for(; c>=0; c--) {
			ll restc = restd - c*(w1+2);
			ll b = min((int)(restc/(w1+1)), (int)wv[1].size());

			for(; b>=0; b--) {
				ll restb = restc - b*(w1+1);
				int a = min((int)(restb/w1), (int)wv[0].size());

				ll val = v_sum[0][a] + v_sum[1][b] + v_sum[2][c] + v_sum[3][d];
				// cout << "v " << val  << '|' << a << ' ' << b << ' ' << c << ' ' << d << endl; 
				ans = max(val, ans);
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
   ll i,w;
     ll dp[n+1][W+1];
     for(i=0;i<=n;i++)
     {
     	for(w=0;w<=W;w++)
     	{
     		if(i==0||w==0)
     			dp[i][w]=0;
     		else if(w>=wt[i-1])
     			dp[i][w]=max(dp[i-1][w],val[i-1]+dp[i-1][w-wt[i-1]]);
     		else
     			dp[i][w]=dp[i-1][w];
     	}
     }
     return dp[n][W];
} 
void solve()
{
       ll n,W;
       cin>>n>>W;
       ll wt[n],val[n],i,j;
       for(i=0;i<n;i++)
       {
       	  cin>>wt[i]>>val[i];
       }
       ll z=knapSack(W,wt,val,n);
      cout<<z;
}
int main()
{
    fast();
    {
      solve();
    }
    return 0;
}


Measured memory_bytes: 82400
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    
//-----------------------------------------------------------------------------------------------------------//

    map<pll,ll> ans;
    READV(N);
    FORI(i,1,N+1)
    {
        ll ld=i%10;
        ll prev=-1;
        ll x=i;
        while (x>0)
        {
            prev=x%10;
            x=x/10;
        }
        ans[{prev,ld}]++;
    }
    ll ans1=0;
    for(auto p: ans)
    {
        ans1+=(p.se)*(ans[{p.fi.se,p.fi.fi}]);
    }
    cout<<ans1<<endl;


//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
using namespace std;
const int64_t INF = numeric_limits<int64_t>::max() / 8;
int64_t solve(const vector<int64_t> &ss, const vector<int64_t> &ts,int64_t x)
{
    auto si = lower_bound(ss.begin(), ss.end(), x);
    auto ti = lower_bound(ts.begin(), ts.end(), x);
    auto si_v = si == ss.end() ? INF : *si;
    auto ti_v = ti == ts.end() ? INF : *ti;
    auto si_1_v = si == ss.begin() ? -INF : *(si - 1);
    auto ti_1_v = ti == ts.begin() ? -INF : *(ti - 1);

    int64_t ans = INF; 
    {
        auto v = max(si_v - x, ti_v - x);
        ans = min(v, ans);
    }
    {
        auto v = max(x - si_1_v, x - ti_1_v);
        ans = min(v, ans);
    }
    {
        auto v = min(
            // tera -> jinja
            2 * (si_v - x) + (x - ti_1_v),
            // jinja -> tera
            2 * (ti_v - x) + (x - si_1_v)
        );
        ans = min(v, ans);
    }
    {
        auto v = min(
            (si_v - x) + 2 * (x - ti_1_v),
            (ti_v - x) + 2 * (x - si_1_v)
        );
        ans = min(v, ans);
    }
    return ans;
}
int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vector<int64_t> ss, ts;
    for(int i = 0; i < a; ++i)
    {
        int64_t s;
        cin >> s;
        ss.push_back(s);
    }
    for(int i = 0; i < b; ++i)
    {
        int64_t t;
        cin >> t;
        ts.push_back(t);
    }
    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());
    for(int i = 0; i < q; ++i)
    {
        int64_t x;
        cin >> x;
        cout << solve(ss,ts, x) << endl;
    }
}

Measured memory_bytes: 3060
n=int(input())
l=list(map(int,input().split()))
l.sort()
max=l[n-1]
dp=[0]*(max+1)
for i in l:
  if dp[i]!=0:
    dp[i]+=1
    continue
  for j in range(i,max+1,i):
    dp[j]+=1
sum=0
for i in l:
  if dp[i]==1:
    sum+=1
print(sum)

Measured memory_bytes: 32148
import java.util.Scanner;

//AtCoder Beginner Contest 141
//A	Weather Prediction
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		if ("Sunny".equals(S)) {
			System.out.println("Cloudy");
		} else if ("Cloudy".equals(S)) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
	}
}


Measured memory_bytes: 22100
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n+1,0),b(n+1,0) ;
	for(int i=0;i<n;i++){
		int x ; cin >> x ;
		a.at(i+1) = a.at(i)+x ;
	}
	for(int i=0;i<n;i++){
		int x ; cin >> x ;
		b.at(i+1) = b.at(i)+x ;
	}
	ll ans = 0 ;
	for(int i=1;i<=n;i++){
		ll cnt = a.at(i)-a.at(0)+b.at(n)-b.at(i-1) ;
		if(ans<cnt) ans = cnt ;
	}
	cout << ans << endl ;
}


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

char itoc(int num){
	if(num == 0){
		return '0';
	}else if(num == 1){
		return '1';
	}else if(num == 2){
		return '2';
	}else if(num == 3){
		return '3';
	}else if(num == 4){
		return '4';
	}else if(num == 5){
		return '5';
	}else if(num == 6){
		return '6';
	}else if(num == 7){
		return '7';
	}else if(num == 8){
		return '8';
	}else{
		return '9';
	}
}

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

	string ab,ba;
	for(int i=0;i<b;i++){
		ab.push_back(itoc(a));
	}
	for(int i=0;i<a;i++){
		ba.push_back(itoc(b));
	}
	if(ab <= ba){
		cout << ab << endl;
	}else{
		cout << ba << endl;
	}
}


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

int fac(int N) {
  if(N <= 0) return 0;
  if(N == 1) return 1;
  int n = 1;
  while(N>0) {
    n *= N;
    N--;
  }
  return n;
}

int main() {
  int N; cin >> N;
  vector<int> P(N), Q(N);
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  
  int a = 0, b = 0;
  vector<int> k(0);
  rep(i, N) k.push_back(i+1);
  rep(i, fac(N)) {
    int p = 1;
    rep(j,N) if(P[j] != k[j]) p = 0;
    if(p == 1) {
      a = i;
      break;
    }
    next_permutation(k.begin(), k.end());
  }
  k = {};
  rep(i, N) k.push_back(i+1);
  rep(i, fac(N)) {
    int q = 1;
    rep(j,N) if(Q[j] != k[j]) q = 0;
    if(q == 1) {
      b = i;
      break;
    }
    next_permutation(k.begin(), k.end());
  }

  cout << abs(a-b) << endl;

}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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;
}

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    string s;
    ll N;
    cin >> N;
    vector<vector<ll> > a(3, vector<ll>(N));
    rep(i, 0, 3) {
        rep(j, 0, N) {
            cin >> a[i][j];
        }
    }
    rep(i, 0, 3) {
        sort(a[i].begin(), a[i].end());
    }
    ll res = 0;
    rep(i, 0, N) {
        auto Iter1 = lower_bound(a[0].begin(), a[0].end(), a[1][i]);
        auto start1 = Iter1 - a[0].begin();
        auto Iter2 = upper_bound(a[2].begin(), a[2].end(), a[1][i]);
        auto end2 = a[2].end() - Iter2;
        ll a = start1 * end2;
        res += a;
    }
    cout << res << endl;
    return 0;
}

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

const int max=104729;
char so[104730];

int main(){
	int i,j,n,s;
	
	memset(so,0,sizeof(so));
	
	so[0]=so[1]=1;
	
	for(i=2;i*i<=max;i++){
		for(j=2*i;j<=max;j+=i){
			so[j]=1;
		}
	}
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		s=0;
		for(i=1;n;i++){
			if(so[i]==0){
				s+=i;
				--n;
			}
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int a[5];
	for (int i = 1; i <= 3; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 4);
	int p_1 = a[3] - a[2], ans = 0;
	a[1] += p_1; a[2] += p_1;
	if ((a[2] - a[1]) & 1) ans = p_1 + (a[2] - a[1] + 1) / 2 + 1;
	else ans = p_1 + (a[2] - a[1]) / 2;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int x = Integer.parseInt(strArr[0]);
		int a = Integer.parseInt(strArr[1]);
		int b = Integer.parseInt(strArr[2]);
		if (a >= b) {
			System.out.println("delicious");
		} else if (a + x >= b) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 23124
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

#define ll long long
#define ld long double

constexpr double EPS = 1e-16;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

string s;

void input() {
  cin >> s;
}

void solve1() {
  int ans = 0;

  string good = "ACGT";

  int cur = 0;

  for (auto&& i : s) {
    if (good.find(i) != string::npos) {
      ++cur;
    } else {
      ans = max(ans, cur);

      cur = 0;
    }
  }

  cout << max(ans, cur);
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef  long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll pow1(ll n,ll p)
{
	if(p==0)	return 1;
	ll x=pow1(n, p/2);
	x=(x*x);
	if(p%2==0)
		return x;
	else
		return (x*n);
}
int main()
{
    fast;
   ll t;
   t=1;
   while(t--)
   {
       map<ll,ll>mp;
       ll n,x=0;
       std::cin >> n;
       ll a[n];
       fr(i,0,n)
       {
           std::cin >> a[i];
           mp[a[i]]++;
           if(mp[a[i]]>1)
           x=1;
       }
       if(x==1)
       cout<<"NO\n";
       else
       cout<<"YES\n";
       
   }
}

Measured memory_bytes: 17676
N=int(input())
A=str(input())


def ans176(N:int, A:str):
    A=list(map(int,A.split()))
    step_count=0
    max=A[0]
    for i in range(1,N):
        if A[i]<max:
            step_count=step_count+max-A[i]
        else:
            max=A[i]
    return(step_count)

print(ans176(N,A))

Measured memory_bytes: 33516
n = int(input())
if n <= 111:
    print(111)
elif 111 < n <= 222:
    print(222)
elif 222 < n <= 333:
    print(333)
elif 333 < n <= 444:
    print(444)
elif 444 < n <= 555:
    print(555)
elif 555 < n <= 666:
    print(666)
elif 666 < n <= 777:
    print(777)
elif 777 < n <= 888:
    print(888)
else:
    print(999)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll = int_fast64_t;

std::vector<ll> divisor(ll n){
        std::vector<ll> ret;
        for(ll i=1; i*i<=n; i++){
                if(n%i == 0){
                        ret.push_back(i);
                        if(i*i != n) ret.push_back(n/i);
                }
        }
        std::sort(ret.begin(), ret.end());
        return ret;
}

int main(){
	ll n;
	scanf("%ld", &n);

	ll ans = 0;
	for(ll i: divisor(n)){
		if(i==1) continue;
		ll m = n;
		while(m%i==0) m /= i;
		if(m%i==1) ans++;
	}	
	for(ll i: divisor(n-1)){
		if(n%i==1) ans++;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 gcd(int a, int b) { return a ? gcd(b%a, a) : b; }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    int ans = 0;
    rep(i, 0, N) ans = gcd(ans, A[i]);
    cout << ans << endl;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			C();
		}


		public static void C()
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int m = cin.Int();
			List<int>[] f = new List<int>[m];
			for (int i = 0; i < m; i++) {
				int t = cin.Int();
				f[i] = new List<int>();
				for (int j = 0; j < t; j++) {
					f[i].Add(1 << (cin.Int() - 1));
				}
			}

			int[] p = new int[m];
			for (int i = 0; i < m; i++) {
				p[i] = cin.Int();
			}

			int ans = 0;
			int l = (int)Math.Pow(2, n);
			for (int k = 0; k < l; k++) {
				bool ok = true;
				for (int i = 0; i < m; i++) {
					int cnt = 0;
					for (int j = 0; j < f[i].Count; j++) {
						if ((f[i][j] & k) != 0) {
							++cnt;
						}
					}

					if (cnt % 2 != p[i]) {
						ok = false;
						break;
					}
				}

				if (ok) {
					++ans;
				}

			}

			Console.WriteLine(ans);
		}

	}

	public class Scanner
	{
		string[] s;
		int i;

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

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

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

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

		public long Long()
		{
			return long.Parse(Next());
		}

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

		public double Double()
		{
			return double.Parse(Next());
		}


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


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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;

ll N,M;  vector<vector<pair<ll,ll>>> to ;

vector<ll> dist;

int main(){
cin >> N >> M; 
  dist = vector<ll> (N,INF);
  
  to.resize( N + 10);
  
  for(ll i = 0; i < M; i++){
    ll a,b,c; cin >> a >> b >> c; a--; b--; c *= -1;
    to[a].push_back(make_pair(b,c));}
  
  bool closed = false;
  
  dist[0] = 0;
  
  for(ll i = 0; i < 2 * N; i++){
    for(ll v = 0; v < N; v++){
      if( dist[v] == INF){ continue;}//
      else{
        if( to[v].empty()){ continue;}
        for( ll k = 0; k < to[v].size(); k++){
          ll p =  to[v][k].first; //vから繋がる先
          ll q =  to[v][k].second; // v- p間のコスト
          if( dist[p] > dist[v] + q){
            dist[p] = dist[v] + q;
            if( i >= N && p == N - 1){ closed = true;}}
        }}
    }}
  
  if( closed){ cout << "inf" << endl;}
  else{
    cout << -dist[N-1] << endl; } return 0;}
            
          


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  string K;
  int N, D;
  ll dp[10010][2][110];

  void init() {
    cin >> K >> D;
    N = K.size();
  }

  ll rec(int i, int smaller, int r) {
    ll *cur = &dp[i][smaller][r];
    if(*cur >= 0) return *cur;
    if(i >= N) return *cur = (r == 0);
    int d = K[i] - '0';
    int ub = smaller ? 9 : d;
    ll acc = 0;
    repc(j, ub) {
      ll ret = rec(i+1, (smaller || (j<ub)), (r+j)%D) % MOD_1_000_000_007;
      acc = (acc + ret) % MOD_1_000_000_007;
    }
    return *cur = acc;
  }

  void solve() {
    memset(dp, -1, sizeof dp);
    ll ans = (rec(0, 0, 0) + MOD_1_000_000_007 - 1) % MOD_1_000_000_007;
    cout << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}


Measured memory_bytes: 18304
import java.util.*;

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int cnt =0;
      int N = sc.nextInt();
      int[] a = new int[N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextInt();
      }
      
      Arrays.sort(a);
      
      System.out.println(a[N/2]-a[N/2 -1]);
  }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    ll a;cin>>a;
    n-=a;
  }
  cout<<max(-1ll, n)<<endl;
  
  return 0;
}


Measured memory_bytes: 3636
import numpy as np

A, B, C, X, Y = map(int,input().split())

value = [A, B]
n_pizza = [X, Y]

# 買う手法は次の3通りしかない
# 全てAとB単品で揃える場合
price_1 = A * X + B * Y
# 全てCで揃える場合
price_2 = 2 * C * max(X, Y)
# 少ない方までCで買って、残りは単品という場合
idx_more_to_buy = n_pizza.index(max(n_pizza))
price_3 = 2 * C * min(X, Y) + value[idx_more_to_buy] * (n_pizza[idx_more_to_buy] - min(X, Y))

ans = min(price_1, price_2, price_3)
print(ans)

Measured memory_bytes: 12504
import sys


def read_input_line():
    return sys.stdin.readline().strip()


def task(X, K, D):
    if_steps = abs(X) / D
    if K <= if_steps:
        return abs(X) - K * D
    over_steps_delta = (K - if_steps) % 2
    over_steps = round(if_steps + over_steps_delta)
    below_steps = over_steps - 2
    dist_a = abs(abs(X) - over_steps * D)
    dist = dist_a
    if below_steps >= 0:
        dist_b = abs(abs(X) - below_steps * D)
        if dist_b < dist:
            dist = dist_b
    return dist


def main():
    [X, K, D] = [int(s) for s in read_input_line().split(' ')]
    result = task(X, K, D)
    print(result)


main()


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

#define int double

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999

using namespace std;

int32_t main(){
    int n, m, d;
    cin >> n >> m >> d;

    if(d == 0){
        printf("%.10lf\n", 1/n * (m - 1));
    }
    else{
        printf("%.10lf\n", 2*(n - d) / (n*n) * (m - 1));
    }
}

Measured memory_bytes: 256
S = list(input())
alpha = ['a','b','c','d','e','f','g','h','i','j','k','l',\
        'm','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(alpha)):
    if S.count(alpha[i])==0:
        print(alpha[i])
        exit()
print('None')

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

using namespace std;

#define MAX 10000
#define INFTY (1 << 29)

class DisjointSet {
  public:
    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size){
      rank.resize(size, 0);
      p.resize(size, 0);
      for(int i = 0; i < size; ++i) makeSet(i);
    }

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

    bool same(int x, int y){
      return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){
      if(rank[x] > rank[y]){
        p[y] = x;
      }
      else {
        p[x] = y;
        if(rank[x] == rank[y]){
          rank[y]++;
        }
      }
    }

    int findSet(int x){
      if(x != p[x]){
        p[x] = findSet(p[x]);
      }
      return p[x];
    }
};

class Edge {
  public:
    int source, target, cost;
    Edge(int source=0, int target=0, int cost=0):
    source(source), target(target), cost(cost) {}
    bool operator < (const Edge &e) const {
      return cost < e.cost;
    }
};

int kruskal(int N, vector<Edge> edges){
  int totalCost = 0;
  sort(edges.begin(), edges.end());
  DisjointSet dset = DisjointSet(N + 1);

  for(int i = 0; i < N; ++i) dset.makeSet(i);

  int source, target;
  for(int i = 0; i < edges.size(); ++i){
    Edge e = edges[i];
    if(!dset.same(e.source, e.target)){
      totalCost += e.cost;
      dset.unite(e.source, e.target);
    }
  }
  return totalCost;
}

int main(){
  int N, M, cost;
  int source, target;

  cin >> N >> M;

  vector<Edge> edges;
  for(int i = 0; i < M; ++i){
    cin >> source >> target >> cost;
    edges.push_back(Edge(source, target, cost));
  }

  cout << kruskal(N, edges) << endl;

  return 0;
}



Measured memory_bytes: 5380
/*************************************************************************

       Author:            palayutm
       Created Time :     Mon 10 Oct 2016 12:09:48 PM CST

       File Name:         b.cc
       Description:       new style, new life

 ************************************************************************/
#include <bits/stdc++.h>

using namespace std;

int main(int argc, const char *argv[])
{
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  for (auto c : s) {
    if (c == 'a' && a+b > 0) {
      puts("Yes");
      a > 0 ? --a : --b;
    } else if (c == 'b' && b > 0) {
      puts("Yes");
      b --;
    } else {
      puts("No");
    }
  }
  return 0;
}



Measured memory_bytes: 896
a1,a2,a3= map(int,input().split())
a4,a5,a6= map(int,input().split())
a7,a8,a9= map(int,input().split())
n=int(input())
b=[int(input()) for _ in range(n)]
bing = [(a1,a2,a3),(a4,a5,a6),(a7,a8,a9),
        (a1,a4,a7),(a2,a5,a8),(a3,a6,a9),
        (a1,a5,a9),(a3,a5,a7)]
for cs in bing:
    for c in cs:
        if not c in b:break
    else:
        print('Yes')
        break
else:print('No')

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) scanf("%d", &a[i]);

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    if(ggg != 1){
        printf("not coprime");
        return 0;
    }

    //エラトステネスの篩
    int P_MAX = 1000005;
    vi pmn(P_MAX);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = 3*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    vi cnt(P_MAX,0);
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                printf("setwise coprime");
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    printf("pairwise coprime");
}


Measured memory_bytes: 14856
#include <stdio.h>

int abs(int num){
        if(num<0)return num*-1;
        else return num;
}

int min(int a,int b){
        if(a<b)return a;
        else return b;
}

int main(){
        int N,ans;
        scanf("%d\n",&N);
        ans=N;
        char c[N];
        int Ws[N+1],Rs[N+1];
        for(int i=0;i<N;i++)scanf("%c",&c[i]);

        Ws[0]=0;
        Rs[0]=0;
        for(int i=1;i<=N;i++){
                Ws[i]=Ws[i-1];
                Rs[i]=Rs[i-1];
                if(c[i-1]=='W')Ws[i]++;
                else (Rs[i]++);
        }
        for(int i=0;i<=N;i++){
                int W=Ws[i],R=N-Ws[N]-Rs[i];
                int swapNum=min(W,R);
                int changeNum=abs(W-R);
                ans=min(ans,swapNum+changeNum);
        }

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

Measured memory_bytes: 3460
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
EPS = 10 ** -10

class ModTools:
    """ 階乗・逆元用のテーブルを構築する """

    def __init__(self, MAX, MOD):
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, -1, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせ """

        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def nHr(self, n, r):
        """ 重複組み合わせ """

        return self.nCr(r+n-1, r)

    def nPr(self, n, r):
        """ 順列 """

        if n < r: return 0
        return self.fact[n] * self.inv[n-r] % self.MOD

    def div(self, x, y):
        """ MOD除算 """

        return x * pow(y, self.MOD-2, self.MOD) % self.MOD

N, K = MAP()

mt = ModTools(N+K+1, MOD)
ans = mt.nCr(K, N)
print(ans)



Measured memory_bytes: 5812
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
}


Measured memory_bytes: 3596
fun main(args: Array<String>) = ABC165D.main()

object ABC165D {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    val A: Int
    val B: Long
    val N: Long

    init {
        val (a, b, n) = readLongs()
        A = a.toInt()
        B = b
        N = n
    }

    fun main() {
        //val ans = (1..N).map { x ->
        //    A * x / B - A * floorDiv(x,B)
        //}.max()

        if (B == 1L) {
            val ans = 0
            println(ans)
            return
        }

        val scores = (0..N / B - 1).asSequence().map { floor ->
            val x = (floor + 1) * B - 1
            A * x / B - A * floor
        } + sequenceOf(A * N / B - A * (N / B))

        val ans = scores.max()

        println(ans)
    }

    /*####################################################################################*/

    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
}

Measured memory_bytes: 40796
W,H,N=map(int,input().split())
x=[0]*N
y=[0]*N
a=[0]*N
minX=0
maxX=W
minY=0
maxY=H
for i in range(N):
  x[i],y[i],a[i]=map(int,input().split())
  if a[i]==1:
    minX=max(minX,x[i])
  if a[i]==2:
    maxX=min(maxX,x[i]) 
  if a[i]==3:
    minY=max(minY,y[i])
  if a[i]==4:
    maxY=min(maxY,y[i]) 

ans=(maxX-minX)*(maxY-minY)
if maxX<minX or maxY<minY:
  ans=0
print(ans)

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

int main()
{
        int n;
        cin >> n;
        int N = 1e5;
        vector< pair<int, int> >a(N + 1), b(N + 1);
        for(int i = 0; i <= N; i++) {
                a[i] = {0, i};
                b[i] = {0, i};
        }
        for(int i = 0; i < n; i++) {
                int x;
                cin >> x;
                if(i % 2)
                        b[x].first++;      
                else
                        a[x].first++;
        }
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        int ans;
        if(a.back().second == b.back().second) {
                if(a[N].first > b[N].first)
                        ans = n - (a[N].first + b[N - 1].first);
                else if(a[N].first < b[N].first)
                        ans = n - (a[N - 1].first + b[N].first);
                else {
                        if(a[N - 1].first > b[N - 1].first)
                                ans = n - (a[N - 1].first + b[N].first);
                        else
                                ans = n - (a[N].first + b[N - 1].first);
                }
        } else 
                ans = n - (a[N].first + b[N].first);
        cout << ans;
        return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  map<ll,ll> mp;
  ll ans=0,powten=10,n=s.length(),val=s[n-1]-'0';
  mp[val]++;mp[0]++;
  for(ll pos=n-2;pos>-1;--pos) {
    powten%=2019;
    val=(s[pos]-'0')*powten+val;
    mp[val%2019]++;
    powten*=10;
  }
  for(auto p:mp) ans+=p.second*(p.second-1)/2;
  print(ans);
  return 0;
}

Measured memory_bytes: 3792