akhauriyash/Code-Regression huggingface dataset:
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e5 + 5;

int N;
vector<int> G[MAXN];

void input()
{
    read(N);
    for (int i = 2; i <= N; ++i) {
        int f;
        read(f);
        G[f].push_back(i);
    }
}

int dfs(int u, int f)
{
    vector<int> list;
    for (int i = 0; i < SZ(G[u]); ++i) {
        int v = G[u][i];
        if (v == f)
            continue;
        list.push_back(dfs(v, u));
    }
    std::sort(ALL(list));
    int ret = 0;
    for (int i = 0; i < SZ(list); ++i) {
        chkmax(ret, list[i] + SZ(list) - i);
    }
    return ret;
}

void solve()
{
    int ans = dfs(1, 0);
    printf("%d\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("B.in", "r", stdin);
    freopen("B.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 为谁醉倒为谁醒，到今犹恨轻离别。
//     -- 吕本中《踏莎行·雪似梅花》


Measured memory_bytes: 16640
# abc149_c

X = int(input())

def is_prime(n):
  dmax = int(n**0.5)+2
  for i in range(2, dmax):
    if n%i==0:
      return False
  return True

if X==2:
  print(X)
else:
  p = False
  while not p:
    p = is_prime(X)
    if p:
      print(X)
    X = X+1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
using namespace std;

inline constexpr auto divceil (int64_t a, int64_t b)
{
  return (a + b - 1) / b;
}

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

  int64_t n; cin >> n;
  int64_t a, b, c, d, e; cin >> a >> b >> c >> d >> e;

  int64_t time_a = divceil (n, a);
  int64_t time_b = max (time_a + 1, divceil (n, b) + 1);
  int64_t time_c = max (time_b + 1, divceil (n, c) + 2);
  int64_t time_d = max (time_c + 1, divceil (n, d) + 3);
  int64_t time_e = max (time_d + 1, divceil (n, e) + 4);

  cout << time_e << endl;
}


Measured memory_bytes: 256
import numpy as np

N, T = map(int, input().split())
T -= 1

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

dp = [[0] * (T + 1) for _ in range(N + 1)]

dp = np.zeros(T + 1, dtype = np.int32)

ans = AB[N - 1][1]
for i in range(N - 1, 0, -1):
    # for j in range(T + 1):
    #     if j < AB[i][0]:
    #         dp[i][j] = dp[i + 1][j]
    #     else:
    #         dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - AB[i][0]] + AB[i][1])
    if AB[i][0] <= T + 1:
        dp[AB[i][0]:] = np.maximum(dp[AB[i][0]:], dp[:T + 1 - AB[i][0]] + AB[i][1])
    tmp = dp[T] + AB[i - 1][1]
    ans = max(ans, tmp)
    
print (ans)
# print (AB)

# for i in dp:
#     print (dp)

Measured memory_bytes: 83276
#include<algorithm>
#include<cmath>
#include <functional>
#include <math.h>
#include<stdio.h>
#include<utility>
#include<vector>
int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}
void Input(std::vector<std::pair<int ,int> > &vnnInput);
bool bCrossProduct (std::pair<int,int > &point, std::vector<std::pair<int,int> >& StackPoints,int i);
int main(void){
    int nInput;
    scanf("%d",&nInput );
    std::vector<std::pair<int ,int> > vnnInput(nInput);
    Input( vnnInput);
    //vnniValuePoint((angle,lenght_2),n)
    std::vector<std::pair<std::pair<double ,double>,size_t> > vnniValuePoint(nInput);
    vnniValuePoint[0]=std::pair<std::pair<double ,double>,size_t>(std::pair<double ,double>(0.,0.),0);
    for(int i=1;i<nInput;++i ){
        int dX=     vnnInput[i].first-vnnInput[0].first;
        int dY=     vnnInput[i].second-vnnInput[0].second;        
        int nLength_2=dX*dX+dY*dY;
        vnniValuePoint[i].first.second=1.*nLength_2;        
        int GCD=gcd(std::abs(dX),std::abs(dY));
        dX/=GCD;
        nLength_2/=(GCD*GCD);
        vnniValuePoint[i].first.first=std::acos(dX/std::sqrt(1.*nLength_2));
        vnniValuePoint[i].second=i;
    }
    //SortWithArg_Length
    std::stable_sort(vnniValuePoint.begin(),vnniValuePoint.end());
    //Parallel Reverse@end
    int n=0;
    for(int i=vnniValuePoint.size()-2;i>=0;--i){
        if(std::abs(vnniValuePoint[vnniValuePoint.size()-1].first.first-vnniValuePoint[i].first.first)>1.e-8){
            break;
        }
        ++n;
    }     
    std::vector<std::pair<int ,int> > vnnSortedput(nInput);
    for(int i=0;i<nInput;++i){
        vnnSortedput[i]= vnnInput[vnniValuePoint[i].second];
    }
    std::reverse(vnnSortedput.end()-n-1,vnnSortedput.end());
    //prepareConvexHull    
    int iIndex=0;
    for (int i = 1; i <nInput-1 ; ++i){
        vnnInput[++iIndex] = vnnSortedput[i];
        while (!bCrossProduct (vnnSortedput[i+1],vnnInput,iIndex)){
            --iIndex  ;
        }
    }
    vnnInput[++iIndex] = vnnSortedput[nInput-1];
    printf("%d\n",++iIndex);//++??¢???????????????=????´???°
    for (int i = 0 ;i < iIndex; ++i){
        printf("%d %d\n",vnnInput[i].first,vnnInput[i].second);
    }
    //system("pause");
    return 0;
}
void Input(std::vector<std::pair<int ,int> > &vnnInput){
    for(int i=0;i<vnnInput.size();++i){
        scanf("%d%d",&vnnInput[i].second,&vnnInput[i].first);
    }
    std::sort(vnnInput.begin(),vnnInput.end());
    for(int i=0;i<vnnInput.size();++i){
        std::swap(vnnInput[i].first,vnnInput[i].second);
    }
}
bool bCrossProduct (std::pair<int,int > &point, std::vector<std::pair<int,int> >& StackPoints,int i){


    double dValueCrossPro;

    dValueCrossPro = 
        (StackPoints[i].first - StackPoints[i-1].first) 
        * (point.second - StackPoints[i].second)
        -(StackPoints[i].second - StackPoints[i-1].second) 
        * (point.first - StackPoints[i].first) ;
    return dValueCrossPro >= 0;

}

Measured memory_bytes: 8184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N; cin >> N;
    vel A(N+1); rep(i,N+1) cin >> A[i];
    vel B(N); rep(i,N) cin >> B[i]; 

    ll ans = 0;
    rep(i,N){
        if(A[i] > B[i]) ans += B[i];
        else if(A[i] <= B[i] and B[i] <= A[i] + A[i+1]) ans += B[i], A[i+1] += A[i] - B[i];
        else if(B[i] > A[i] + A[i+1]) ans += A[i] + A[i+1], A[i+1] = 0;
    }
    cout << ans << endl;
    return 0;
}

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

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    ll R, L;
    cin >> L >> R;

    ll ans = 2018;

    ll r,l;
    
    rep(i,2030) {
        l = L+i;
        if (l>=R) {
            continue;
        }
        rep(j,2030) {
            r = l+1+j;
            if (r>R) {
                continue;
            }
            ll tmp = (l*r)%2019;
            //cout << tmp << endl;
            ans = min(ans,tmp);
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
//using namespace atcoder;

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	map<int, int> ANum, BNum;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ANum[A[i]]++;
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		BNum[B[i]]++;
	}
	for (int i = 0; i <= N; i++) {
		if (ANum.find(i) == ANum.end() || BNum.find(i) == BNum.end()) continue;
		if (ANum[i] + BNum[i] > N) {
			cout << "No" << endl;
			return 0;
		}
	}
	reverse(B.begin(), B.end());
	int j = N - 1;
	for (int i = 0; i < N; i++) {
		if (A[i] == B[i]) {
			while (A[i] == B[j] || B[i] == A[j]) {
				j--;
				if (j < 0) j = N - 1;
			}
			swap(B[i], B[j]);
		}
	}
	cout << "Yes" << endl;
	for (int b : B) cout << b << " ";
	cout << endl;
}


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

int main(){
  int N,a;
  cin>>N;
  
  a=N-N/1000*1000;
  
  if(a%111==0||N%1110<10){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

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

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll n, k;

mint sigma(ll j) {
    return n * j - j * (j - 1) + 1;
}

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

    for (ll i = k; i <= n+1; i++) {
        ans += sigma(i);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, x[114], y[114], h[114];
	cin>>n;
	REP(i, n){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]){
			a=i;
		}
	}
	REP(c1, 101){
		REP(c2, 101){
			FOR(H, h[a], h[a]+201){
				bool ok=true;
				REP(i, n){
					if(h[i]){
						if(H!=h[i]+abs(x[i]-c1)+abs(y[i]-c2)){
							ok=false;
							i=n;
						}
					}
					else if(H>abs(x[i]-c1)+abs(y[i]-c2)){
						ok=false;
						i=n;
					}
				}
				if(ok){
					cout<<c1<<' '<<c2<<' '<<H<<'\n';
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * (b/gcd(a, b));
}



int main()
{
  ll n,t[110];
  cin>>n;
  rep(i,n)cin>>t[i];
  // rep(i,n)cout<<t[i]<<endl;
  ll ans=t[0];
  reps(i,n){
    ans=lcm(ans,t[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)

#define ln << endl

const int MOD = 1e9 + 7;

int main() {
    int N; cin >> N;

    long long p = 1;
    upto(1, N, i) p = p * i % MOD;

    cout << p ln;

    return 0;
}


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

namespace ABC140A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;  
              n=int.Parse(Console.ReadLine());
            Console.WriteLine(n * n * n);
        }
    }
}


Measured memory_bytes: 13140
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		int a, b, total;
		string[] s = Console.ReadLine().Split(' ');
		a = int.Parse(s[0]);
		b = int.Parse(s[1]);
		total = Math.Max(a + b, a - b);
		Console.WriteLine(Math.Max(total, a * b));
		
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
using P=pair<int,int>;


int main(){
  int n,s;
  cin>>n>>s;
  int v[n],w[n];
  rep(i,n) cin>>w[i]>>v[i];
  ll dp[n+1][100100];
  //実現しうる重さのmin
  rep(i,100100) dp[0][i]=1001001001001;
  rep(i,n+1)dp[i][0]=0;
  rep(i,n){
    rep(j,100100){
       dp[i+1][j]=dp[i][j];
      if(j-v[i]>=0) dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    }
  }
  for(int i=100010;i>=0;i--){
    if(dp[n][i]<=s){
    cout<<i;
      return 0;
    }
  }
}

Measured memory_bytes: 79232
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
const int N=1005;
const int M=2005;
#define mod 1000000007
using namespace std;
int diff[M];
struct node{
    int u,v,len;
    node(){}
    node(int u1,int v1,int len1):u(u1),v(v1),len(len1){}
    bool operator<(const node &x)const{return len<x.len;}
}line[M];
bool used[M];
long long x,sum;
int fa[N],fal[N],deep[N];
vector<int>a[N],w[N];
inline void swap(int &a,int &b){a^=b;b^=a;a^=b;}
inline int find(int x){return fa[x]?fa[x]=find(fa[x]):x;}
void build(int x,int fa1){
    fa[x]=fa1;
    deep[x]=deep[fa1]+1;
    for(int i=0;i<a[x].size();i++)
        if(a[x][i]==fa1)fal[x]=w[x][i];
        else build(a[x][i],x);
}
int findmax(int u,int v){
    int res=0;
    if(deep[u]<deep[v])swap(u,v);
    while(deep[u]>deep[v])res=max(res,fal[u]),u=fa[u];
    while(u!=v)res=max(res,max(fal[u],fal[v])),u=fa[u],v=fa[v];
    return res;
}
int n,m,u,v,val;
long long bits[M];
int main(){
    scanf("%d%d%lld",&n,&m,&x);bits[0]=1;
    for(int i=1;i<=m;i++)bits[i]=(bits[i-1]*2ll)%mod;
    for(int i=0;i<m;i++)scanf("%d%d%d",&u,&v,&val),line[i]=node(u,v,val);
    sort(line,line+m);
    for(int i=0;i<m;i++){
        int u=find(line[i].u),v=find(line[i].v);
        if(u!=v){
            fa[u]=v;
            sum+=line[i].len;
            a[line[i].u].push_back(line[i].v);
            a[line[i].v].push_back(line[i].u);
            w[line[i].u].push_back(line[i].len);
            w[line[i].v].push_back(line[i].len);
            used[i]=1;
        }
    }
    x-=sum;
    if(x<0)return 0*puts("0");
    memset(fa,0,sizeof fa);
    build(1,0);int cnt=0;
    for(int i=0;i<m;i++)
        if(used[i]==0){
            int maxd=findmax(line[i].u,line[i].v);
            diff[++cnt]=line[i].len-maxd;
        }
    sort(diff+1,diff+1+cnt);
    long long ans=0;
    if(x==0)ans=(bits[m]-2ll*bits[m-n+1]+2ll*mod)%mod;
    for(int i=1;i<=cnt;i++)if(x==diff[i])ans=(ans+2ll*bits[cnt-i])%mod;
    printf("%lld\n",ans);
    return 0;
}

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

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))

map<string,int> m;

int main(){
    string s, maxs;
    int max = 0;
    while(cin >> s){
        m[s]++;
        if(maxs.length() < s.length()) maxs = s;
    }
    FOREACH(it,m) max = MAX(max, it->second);
    FOREACH(it,m){
        if(it->second == max){
            cout << it->first << " " << maxs << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<ll>  h(n);
    rep(i, n) cin >> x[i] >> y[i] >> h[i];


    rep(i, 101) {
        rep(j, 101) {
            bool flag = true;
            ll tmp_h = 0;
            rep(k, n) {
                if(h[k] == 0) continue;
                if(tmp_h == 0) tmp_h = abs(i-x[k])+abs(j-y[k]) + h[k];
                else {
                    if(abs(i-x[k])+abs(j-y[k]) + h[k] != tmp_h) {
                        flag = false;
                        break;
                    }
                }
            }
            if(flag) {
                bool doubleCheck = true;
                rep(k, n) {
                    if(max(tmp_h - abs(i-x[k]) - abs(j-y[k]), (ll)0) != h[k]) {
                        doubleCheck = false;
                        break;
                    }
                }
                if(doubleCheck) {
                    cout << i << endl;
                    cout << j << endl;
                    cout << tmp_h << endl;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL 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;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto 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,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

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

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL w(n);
    REP(i,n)cin>>w[i];
    VL sum(n+1);
    sum[0] = 0;
    REP(i,n)sum[i+1] = sum[i]+w[i];
    LL ans = 1000000000;
    REP(i,n-1){
        ans = min(ans, abs((sum[n] - sum[i+1]) - sum[i+1]));
    }
    PUTS(ans);
}

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

vector<int> blue;
vector<int> red;
vector<int> redpair;
vector<int> v;
vector<vector<int> > c;
int m = 0;
int n = 0;

int gcd(int x,int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y,x%y);
}

bool match(int x){
    if(x == -1){
        return 1;
    }
    for(int i = 0;i < n;i++){
        if(c[x][i] == 1 && v[i] == 0){
            v[i] = 1;
            if(match(redpair[i])){
                redpair[i] = x;
                return 1;
            }
        }
    }
    return 0;
}

int main(){
    while(cin >> m >> n){
        if(m == 0 && n == 0){
            break;
        }
        blue.clear();
        red.clear();
        redpair.clear();
        v.clear();
        c.clear();
        for(int i = 0;i < m;i++){
            int tmp;
            cin >> tmp;
            blue.push_back(tmp);
        }
        for(int i = 0;i < n;i++){
            int tmp;
            cin >> tmp;
            red.push_back(tmp);
            redpair.push_back(-1);
            v.push_back(0);
        }
        for(int i = 0;i < m;i++){
            c.push_back(vector<int>());
            for(int j = 0;j < n;j++){
                c[i].push_back(gcd(blue[i],red[j]) != 1);
            }
        }
        int ans = 0;
        for(int i = 0;i < m;i++){
            for(int j = 0;j < n;j++){
                v[j] = 0;
            }
            if(match(i)){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2160
n,m = map(int,input().split())
b = [False]*n
dp = [0]*(n+2)

for i in range(m):
    a = int(input())
    b[a] = True

dp[n] = 1
mod = 10**9+7

for i in range(n-1,-1,-1):
    if b[i]:
        dp[i] = 0
        continue
    dp[i] = (dp[i+1] + dp[i+2]) % mod

print(dp[0])


Measured memory_bytes: 7668
import java.util.Scanner;

public class Main{
	static Scanner s = new Scanner(System.in);			//文字の入力

	static int H = s.nextInt();
	static int W = s.nextInt();
	static String data[] = new String [H];
	static char field[][] = new char[H][W];
	
	public static void main(String[] args){
	
	

		settei();
		
		solve();





	}
	static void settei(){

		for(int i = 0; i < H;i++){
			data[i] = s.next();			//文字の入力
		}
		for(int i = 0;i <H ;i++){			//たて
			for(int j= 0;j < W;j++){			//横
				field[i][j] = data[i].charAt(j);		//fieldの作成
				
			
			}
		}
		
	}

	static void solve(){
		for(int i = 0;i<H;i++){
			for(int j = 0;j <W;j++){
				dps(i,j);
			}
		}
		
		for(int i = 0;i <H ;i++){			
			for(int j= 0;j < W;j++){			
				System.out.print(field[i][j]);		//答えの表示
				if(j == W-1){
					System.out.println();
				}
			}
		}
	}

	static void dps(int y,int x){
		int count = 0;
		
		if(field[y][x] == '.'){

			for(int dx = -1;dx <= 1;dx++){
				for(int dy = -1;dy<=1;dy++){
					int nx = x + dx;
					int ny = y + dy;
					if(0 <= nx && nx < W && 0 <= ny && ny < H)
						if(field[ny][nx] == '#'){
						count++;		//爆弾の個数を数える
						
					}
				}

			}
			field[y][x] = (char)(count+'0');		//周りの爆弾の数を表示
			
			
		}else{
			return;				//現在地が'.'じゃなければ何もしない
		}
	}

}


Measured memory_bytes: 23252
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<P> suzu(N);
  vector<vector<int>> X(100005);
  vector<vector<int>> Y(100005);
  for(int i=0; i<N; i++){
    cin >> suzu[i].first >> suzu[i].second;
    X[suzu[i].first].emplace_back(i);
    Y[suzu[i].second].emplace_back(i);
  }
  vector<vector<int>> G(N);
  for(int i=0; i<100005; i++){
    for(int j=1; j<X[i].size(); j++){
      G[X[i][j]].emplace_back(X[i][j-1]);
      G[X[i][j-1]].emplace_back(X[i][j]);
    }
    for(int j=1; j<Y[i].size(); j++){
      G[Y[i][j]].emplace_back(Y[i][j-1]);
      G[Y[i][j-1]].emplace_back(Y[i][j]);
    }
  }
  vector<bool> used(N,false);
  ll ans = 0;
  for(int i=0; i<N; i++){
    if(used[i]) continue;
    queue<int> que;
    que.emplace(i);
    used[i] = true;
    set<int> se_x,se_y;
    int cnt = 0;
    while(que.size()){
      int v = que.front();
      que.pop();
      int x = suzu[v].first;
      int y = suzu[v].second;
      se_x.emplace(x);
      se_y.emplace(y);
      cnt++;
      for(int nv: G[v]){
        if(used[nv]) continue;
        used[nv] = true;
        que.emplace(nv);
      }
    }
    ans += (ll)se_x.size()*se_y.size() - cnt;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 21880
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
main()
{
    ll n,w;
    cin >> n >> w;
    vector <ll> dp(w+1);
    ll weight,value;
    for(ll i=0;i<n;i++)
    {
        cin >> weight >> value;
        for(ll j=w-weight;j>=0;j--)
        {
            dp[j+weight]=max(dp[j+weight],dp[j]+value);
        }
    }

    cout << dp[w];
    }

Measured memory_bytes: 1024
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll n;
  cin >> n;
  ll ans = 1000 * ((n + 999) / 1000) - n;
  cout << ans;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,W;
  cin>>n>>W;
  ll wt[n+1],v[n+1],K[n+1][W+1]={};
  loop(i,n) 
    cin>>wt[i]>>v[i];

    for(ll i=0;i<=n;i++)
    {
        for(ll w=0;w<=W;w++)
       {
          if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(v[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w];
       }
    }
    cout<<K[n][W]<<"\n";
}


Measured memory_bytes: 79232
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let a = i.read_vec::<usize>(n);

    writeln!(o, "{}", solve(&a)).unwrap();
}
fn solve(a: &[usize]) -> usize {
    let mut l = vec![0];
    let mut r = vec![0];

    let mut x = a[0];
    for a in a {
        x = gcd(x, *a);
        l.push(x);
    }
    let mut x = *a.last().unwrap();
    for a in a.iter().rev() {
        x = gcd(x, *a);
        r.push(x);
    }
    (0..a.len())
        .map(|i| gcd(l[i], r[a.len() - 1 - i]))
        .max()
        .unwrap()
}
fn gcd(x: usize, y: usize) -> usize {
    fn f(x: usize, y: usize) -> usize {
        if x == 0 {
            y
        } else {
            gcd(y % x, x)
        }
    }
    f(min(x, y), max(x, y))
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   int a,b;
   cin>>a>>b;
   int ans=max({2*a-1,2*b-1,a+b});
    cout <<ans <<endl;
}


Measured memory_bytes: 3628
//46
#include<iostream>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;

int main(){
  map<int,int> nt,d;
  int m=0;
  for(string s;getline(cin,s);){
    if(s==""){
      m=1;
    }else{
      int cn;
      cn=atoi(s.c_str());
      nt[cn]++;
      d[cn]=d[cn]|1<<m;
    }
  }
  for(map<int,int>::iterator it=d.begin();it!=d.end();it++){
    if(it->second==3){
      cout<<it->first<<' '<<nt[it->first]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (2e5 + 5)
#define mod (int) 1000000007

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int main()
{
    // ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s,t;

    cin >> s;
    cin >> t;

    int ans = s.length();

    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == t[i])
        {
            ans--;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3848
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int N;

int main() {
    cin >> N;
    veci P(N);
    int ans = 0;
    REP(i,N) cin >> P.at(i);
    for(int i = 0; i < N; i++) {
        if(P.at(i) != i + 1) {
            ans++;
        }
    }
    cout << (ans <= 2 ? "YES" : "NO") << endl;
}


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

int map[91][91];
int max;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};


void move(int x, int y, int cnt)
{
	int flag;
	int i;
	
	if (max < cnt){
		max = cnt;
	}

	for (i = 0; i < 4; i++){
		if (map[y + dy[i]][x + dx[i]] == 1){
			map[y + dy[i]][x + dx[i]] = 0;
			move(x + dx[i], y + dy[i], cnt + 1);
			map[y + dy[i]][x + dx[i]] = 1;
		}
	}
}


int main(void)
{
	int n, m;
	int i, j;
	
	while (1){
		scanf("%d%d", &m, &n);
		if (m == 0 && n == 0){
			break;
		}

		memset(map, 0, sizeof(map));
		for (i = 1; i <= m; i++){
			for (j = 1; j <= n; j++){
				scanf("%d", &map[i][j]);
			}
		}
		
		max = 0;

		for (i = 1; i <= m; i++){
			for (j = 1; j <= n; j++){
				if (map[i][j] == 1){
					map[i][j] = 0;
					move(j, i, 1);
					map[i][j] = 1;
				}
			}
		}
		
		printf ("%d\n", max);
	}
	return (0);
}

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

using namespace std;

int n, a[100001];

void init()
{
	scanf("%d", &n);
	int p, c = 0, cnt = 0;
	for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &a[i]);
		}
	//sort(a, a + n);
	for (int i = 1; i <= n; ++i)
	{
		//for (int j = i + 1; j < n; ++j)
		//{
			if(i < a[i] && a[a[i]] == i) cnt++;
		//}
	}
	printf("%d\n", cnt);

}

int main()
{

	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif

	init();

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

vector<vector<pair<int, long long>>> v(100000);
vector<long long> dist(100000);

void dfs(int i, int p, long long d);

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

	int a, b, c;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b >> c;
		a--;
		b--;

		v[a].emplace_back(make_pair(b, c));
		v[b].emplace_back(make_pair(a, c));
	}

	int q, k;
	cin >> q >> k;
	k--;
	dfs(k, k, 0);

	int x, y;
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		cout << dist[x - 1] + dist[y - 1] << endl;
	}
	
	return 0;
}

void dfs(int i, int p, long long d)
{
	dist[i] = d;

	for (auto & j : v[i]) {
		if (j.first == p) {
			continue;
		}

		dfs(j.first, i, d + j.second);
	}
}

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

using namespace std;

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

typedef long long ll;

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

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;  cin >> a >> b >> c;
    if (c >= a && c <= b) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


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

double S(int a,int b,int c);
double L(int a,int b,int c);
double H(int a,int b,int c);

int main(void) {
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%lf\n",S(a,b,c));
	printf("%lf\n",L(a,b,c));
	printf("%lf\n",H(a,b,c));
	return 0;
}

double S(int a,int b,int c){
	double r=c*PI/180.0;
	return a*b*sin(r)/2.0;
}

double L(int a,int b,int c){
	double r=c*PI/180.0;
	return sqrt(a*a+b*b-2.0*a*b*cos(r))+a+b;
}

double H(int a,int b,int c){
	double r=c*PI/180.0;
	return (2.0*S(a,b,c))/a;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    vector<vint>a={{1,3,5,7,8,10,12},{4,6,9,11},{2}};

    int x,y;
    cin>>x>>y;
    for(auto &v:a){
        if(find(all(v),x)!=v.end()&&find(all(v),y)!=v.end()){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int P[101][101],f[101],d[101];
int Color[101],time=0,n;
void visit(int);

int main() {
	
	int i,a,b,c,j;
	
	scanf("%d",&n);
		
		for(i=0;i<101;i++) Color[i]=0;
		
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) {
				P[i][j]=0;
			}
			}
			
				for(i=0;i<n;i++) {
scanf("%d%d",&a,&b);
						
		for(j=0;j<b;j++) {
			scanf("%d",&c);
			
				P[a-1][c-1]=1;
				
					}
	}
	for(i=0;i<n;i++) 
	if(Color[i]==0) visit(i);
	
	for(i=0;i<n;i++) printf("%d %d %d\n",i+1,d[i],f[i]);
	
				return 0;
				}
				
				void visit( int r) {
			int v;
			d[r]= ++time;
			Color[r]=1;
			for(v=0;v<n;v++) {
				if(P[r][v]==1 && Color[v]==0) 
				visit(v);
			}
			f[r]=++time;
			}
			
					


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

int main() {
  int64_t A,B,K;
  cin >> A >> B >> K;
  if(A>=K){
    A-=K;
  }else{
    B-=K-A;
    A=0;
  }
  if(B<0){
    B=0;
  }
  cout << A << ' ' << B << endl;
}


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

using namespace std;

const int kMod = 1e9 + 7;

int main() {
    
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    vector<vector<long long>> dp(n, vector<long long>(n, 0));
    for (int i = n - 1; i >= 0; --i) {
        for (int j = i + 1; j < n; ++j) {
            dp[i][j] = 2e18;
            for (int k = i; k < j; ++k) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);
            }
            for (int k = i; k <= j; ++k)
                dp[i][j] += a[k];
        }
    }

    cout << dp[0][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
int n,k,a,b,c,ds,fa[200010],L[200010],R[200010],tag,d;
int ask(int x){return x==fa[x]?x:fa[x]=ask(fa[x]);}
long long m;
int main(){
	scanf("%d%lld%d",&n,&m,&k);ds=n;
	for(int i=0;i<n;i++)fa[i]=i;
	while(k--){
		scanf("%d%d%d",&a,&b,&c);
		int p=ask(a),q=ask(b);tag|=c;
		if(c==0&&p!=q)ds--,fa[q]=p;
		if(c==1){
			L[++d]=a;
			R[d]=b;
			if(m==n-1||p==q)return puts("No"),0;
		}
	}
	for(int i=1;i<=d;i++)if(ask(L[i])==ask(R[i]))return puts("No"),0;
	puts((m+ds-n>1ll*ds*(ds-1)/2)||(tag&&ds==2)?"No":"Yes");
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  
  int count = 0, maxcount = 0;
  for(int i = 0; i < N; i++){
    if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
      count++;
      maxcount = max(maxcount,count);
    }else{
      maxcount = max(maxcount,count);
      count = 0;
    }
  }
  cout << maxcount << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
slist=[]
for i in range(n):
    s10=input()
    si=[]
    for ii in range(10):
        si.append(s10[ii])
    si.sort()
    stmp=""
    for ii in range(10):
        stmp=stmp+si[ii]
    slist.append(stmp)
slist.sort()
    
icnt=0   
i=0 
while i<=n-2:
    j=i+1
    jcnt=0
    while slist[i]==slist[j]:
        jcnt=jcnt+1
        icnt=icnt+jcnt
        j=j+1
        if j>=n:
            break
    i=j
    if i>=n-1:
        break
            
print(icnt)  

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

#define r(i, n) for (int i = 0; i < n; i++)

using namespace std;

// input
vector<int> S, T;

int main()
{
    // input, S is ascending
    int n, q;
    cin >> n;
    while (n--)
    {
        int a;
        cin >> a;
        S.push_back(a);
    }
    cin >> q;
    while (q--)
    {
        int a;
        cin >> a;
        T.push_back(a);
    }

    // binary search
    int C = 0;
    r(i, T.size())
    {
        if (binary_search(S.begin(), S.end(), T[i]))
            C++;
    }

    cout << C << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i = 1; i <= n; i += 2){
    ll cnt = 0;
    for(ll j = 1; j * j <= i; j++){
      if(i % j ==0) cnt += 2;
      if(i % j ==0 && i / j == j) cnt--; 
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

signed main() {
    int N,M; cin >> N >> M;
    if(N<M*2) cout << 0 << endl;
    else cout << N-M*2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  char s1[n],s2[n];
  cin>>s1;
  cin>>s2;
  for(int i=0;i<n;i++)
    cout<<s1[i]<<s2[i];
  return 0;
}

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

#define INF_P 1100000000
#define INF_M -1100000000
#define MAX(a,b) a<b?b:a
#define MIN(a,b) a>b?b:a

int n, m;
int coin[20], dp[50001];

int main(void) 
{
    int i, j;
    scanf("%d %d",&m, &n);
    for (i = 0; i < n; i++) {
        scanf("%d",&coin[i]);
    }
    
    for (i = 1; i <= m; i++) {
        dp[i] = INF_P;
    }

    for (i = 0; i < n; i++) {
        for (j = coin[i]; j <= m; j++) {
            dp[j] = MIN(dp[j],dp[j-coin[i]]+1);
        }
    }

    printf("%d\n",dp[m]);

    return 0;
}

Measured memory_bytes: 792
n=int(input())
S=[list(map(str,input().split())) for _ in range(n)]
C=[list(map(int,input().split())) for _ in range(n)]
A=[]
for i in range(1,2**10):
    ans=0
    X=format(i,'b').zfill(10)
    for j in range(n):
        cnt=0
        for k in range(10):
            if S[j][k]=='1' and X[k]=='1':
                cnt+=1
        ans+=C[j][cnt]
    A.append(ans)
print(max(A))   

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;

    return 0;
}

Measured memory_bytes: 256