akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
struct edge{
	int s,t,nxt;
}e[4005];
int e_cnt,last[2005],fa[2005][2005];
void ins(int a,int b){
	e[e_cnt]=(edge){a,b,last[a]};
	last[a]=e_cnt++;
}
void dfs0(int x,int r){
	for(int i=last[x];i!=-1;i=e[i].nxt)if(e[i].t!=fa[r][x]){
		fa[r][e[i].t]=x;
		dfs0(e[i].t,r);
	}
}
int tag[2005][2005];
bool E[2005][2005];
/*
void dfs1(int x,int r,int nr);
void push(int s,int t){
	while(s!=t){
		// if(s==32||t==32||s==200||t==200)printf("!%d %d %d %d\n",s,t,tag[48][200],tag[48][32]);
		E[s][t]=E[t][s]=1;
		if(!tag[s][t])dfs1(t,s,t);
		if(!tag[t][s])dfs1(s,t,s);
		if(tag[s][t]!=t)s=tag[s][t];
		else if(tag[t][s]!=s)t=tag[t][s];
		else break;
	}
}
*/
void dfs1(int x,int r,int nr){
	if(r==nr)return;
	if(tag[r][x]){
		if(tag[r][x]==nr)return;
		if(E[r][x]){
			E[r][x]=E[x][r]=0;
			if(!E[tag[r][x]][nr]){
				E[tag[r][x]][nr]=E[nr][tag[r][x]]=1;
				dfs1(tag[r][x],nr,tag[r][x]);
				dfs1(nr,tag[r][x],nr);
			}
		}
		return;
	}
	tag[r][x]=nr;
	for(int i=last[x];i!=-1;i=e[i].nxt)if(e[i].t!=fa[r][x])dfs1(e[i].t,r,nr);
}
int ans=0;
vector<int> v[2005];
bool ok[2005],in[2005];
void dfs2(int x,int r){
	in[x]=1;
	for(int i=0;i<v[x].size();i++)if(in[v[x][i]]&&ok[v[x][i]])ok[x]=1;
	if(ok[x])ans++;
	for(int i=last[x];i!=-1;i=e[i].nxt)if(e[i].t!=fa[r][x])dfs2(e[i].t,r);
	in[x]=0;
}
int main(){
	// freopen("45.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	memset(last,-1,sizeof(last));
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		ins(v,u);
		ins(u,v);
	}
	for(int i=1;i<=n;i++)fa[i][i]=0,dfs0(i,i);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		E[u][v]=E[v][u]=1;
		dfs1(u,v,u); dfs1(v,u,v);
		/*
		for(int i=1;i<n;i++)
			for(int j=i+1;j<=n;j++)if(E[i][j])printf("!%d %d\n",i,j);
		puts("------");
		*/// puts("ok");
	}
	// for(int i=1;i<=n;i++)if(E[200][i]&&fa[200][i]==32)printf("%d\n",i);
	// printf("%d\n",E[32][48]);
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)if(E[i][j])v[i].push_back(j),v[j].push_back(i);
	for(int i=1;i<=n;i++){
		memset(ok,0,sizeof(ok));
		ok[i]=1;
		dfs2(i,i);
	}
	printf("%d\n",(ans-n)/2);
	return 0;
}

Measured memory_bytes: 35968
n = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

accum_A1 = [0]
accum_A2 = [0]

for i in range(n):
    accum_A1 += [accum_A1[-1]+A1[i]]
for i in reversed(range(n)):
    accum_A2 += [accum_A2[-1]+A2[i]]

ans = 0
for i in range(n):
    ans = max(accum_A1[i+1]+accum_A2[-1-i],ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long A, long long B, long long C, long long K){
    if(K%2==0){
    cout << A - B << endl;

    }else{
        cout << B - A << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#define MAX 6000
#define INF 1<<29
using namespace std;
int V,d[MAX],cost[MAX][MAX];
bool used[MAX];
void di(int);

int main(){

  int m,a,b,c,e,f,g;


  while(cin >> V >> m)
    {
      for(int i=0;i<=V+2;i++)for(int j=0;j<=V+2;j++)cost[i][j]=INF;
      for(int i=0;i<m;i++)
	{
	  cin >> a;
	  if(a == 1)
	{
	  cin >> b >> c >> e;
	  if(cost[b][c] != INF)
	    {
	      cost[b][c]=min(cost[b][c],e);
	      cost[c][b]=min(e,cost[c][b]);
	    }
	  else 
	    {
	      cost[b][c]=e;
	      cost[c][b]=e;
	    }
	}
	  else if(a == 0)
	    {
	      cin >> f >> g;
	      di(f);
	      if(d[g] == INF)
		{
		  cout << "-1" << endl;
		}
	      else 
		{
		  cout << d[g] << endl;
		}
	    }
	}
  }
  return 0;
}

void di(int s)
{

  for(int i=0;i<=V;i++)d[i]=INF;
  for(int i=0;i<=V;i++)used[i]=false;
  d[s]=0;
  while(true)
    {
      int v=-1;
      for(int u=1; u<=V ;u++)
	{
	  if(!used[u] && (v == -1 || d[u]<d[v]))v=u;
	}
      
      if(v == -1)break;
      used[v]=true;
      for(int u=1;u<=V;u++)
	{
	  d[u]=min(d[u],d[v]+cost[v][u]);
	}
    }
}

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

int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = n/b;
  ll y = n % b;
  ll p = (x-1)*b + b-1;
  ll q = n;
  cout << max(a*p/b-a*(p/b),a*q/b-a*(q/b)) << endl;
  return 0;
}


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

int main(){
	string s;
	cin>>s;
	int flag=false,flag2=false,flag3=false,flag4=false;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S')flag=true;
		if(s[i]=='N')flag2=true;
		if(s[i]=='W')flag3=true;
		if(s[i]=='E')flag4=true;
	}
	if(flag&&flag2&&!flag3&&!flag4){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(!flag&&!flag2&&flag3&&flag4){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(flag&&flag2&&flag3&&flag4){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ans=float('inf')
for i in range(1,n//2+1):
    tmp=0
    a=i
    b=n-i
    while a>0:
        tmp+=a%10
        a//=10
    while b>0:
        tmp+=b%10
        b//=10
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int  a,b,c,d;
  double q,e=0;
  cin>>a;
  e=a;
  if(a%2==1) e=a+1;
  q=(e/2)/a;
  cout<<fixed<<q<<"\n";
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define pi 3.14159265

using namespace std;

int main()
{
    double a,b,x;
    cin >> a >> b >> x;
    double l=2.0*x/(a*b);
    double y=(2.0*(a*a*b-x))/(a*a);
    double p;
    if(a>=l) p=pi/2.0-atan(l/b);
    else p=pi/2.0-atan(a/y);
    cout << fixed << setprecision(9) << p*180/pi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main() {
	int n,a,b;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		a = i;
		b = a;
		if (i % 3 == 0) {
			printf(" %d", a);
			continue;
		}
		for (;;) {
			if (a%10==3) {
				printf(" %d", b);
				break;
			}
			else if(a<10){
				break;
			}
			a /= 10;
		}
	}
	printf("\n");

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   string s;
    cin >> s;
    
    int res  = 0;
    
    for(auto x : s) res+=x-'0';
    
    if(res % 9 == 0) cout << "Yes";
    else cout <<"No";
       
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3788
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn dfs(s: &str, N: u32) -> i32 {
    if s.parse::<u64>().unwrap() > N as u64 {
        0
    } else {
        let digits = ['3', '5', '7'];
        let mut ret = if digits.iter().map(|&x|
            s.chars().collect::<Vec<char>>().iter()
                .filter(|&&c| c == x)
                .count()
        ).collect::<Vec<usize>>().iter().all(|&x| x > 0) {
            1
        } else {
            0
        };
        for &c in digits.iter() {
            ret += dfs(&(s.to_string() + &c.to_string()), N);
        }
        ret
    }
}

fn main() {
    let N: u32 = read_line().parse().unwrap();
    println!("{}", dfs(&"0".to_string(), N));

}


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

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

}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/03/20 20:34:41
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

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

  return 0;
}


Measured memory_bytes: 3612
using System;
class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int n = N % 10;
			switch (n)
			{
				case 2:
				case 4:
				case 5:
				case 7:
				case 9:
					Console.WriteLine("hon");
					break;
				case 0:
				case 1:
				case 6:
				case 8:
					Console.WriteLine("pon");
					break;
				case 3:
					Console.WriteLine("bon");
					break;
			}

		}
	}

Measured memory_bytes: 27480
#include <stdio.h>

int main() {
  int a, b, c, temp;

  scanf ("%d %d %d", &a, &b, &c);

  if (c < b) {
    temp = b;
    b = c;
    c = temp;
  }

  if (b < a) {
    temp = a;
    a = b;
    b = temp;
  }

  if (c < b) {
    temp = b;
    b = c;
    c = temp;
  }

  printf ("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin>>a>>b>>c;
    
    if(a > b) swap (a, b);
    if(b > c) swap (b, c);
    if(a > b) swap (a, b);
    cout<<a<<" "<<b<<" "<<c<<endl;

}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long     ll;
const ll big=2e6+5;
#define endl "\n";
ll a[6];
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
for(int i=1;i<=5;++i)
    cin>>a[i];
for(int i=1;i<=5;++i){
if(a[i]==0){cout<<i;return 0;}
}

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
  int n,m,i,j,k,l;
  char a[51][51],b[51][51];
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++) scanf("%s",a[i]);
  for(i=0;i<m;i++) scanf("%s",b[i]);
  for(i=0;i<n-m+1;i++){
    for(j=0;j<n-m+1;j++){
      int match=1;
      for(k=0;k<m;k++){
        for(l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l]){match=0;break;}
        }
      }
      if(match==1) {printf("Yes");return 0;}
    }
  }
  printf("No");
  return 0;
}

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

const ll MOD = 1e9+7;

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
    return is >> x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
  friend constexpr Fp<MOD> modinv(const Fp<MOD> &a) noexcept {
    return modpow(a, MOD - 2);
  }
};

using mint = Fp<MOD>;

int N, K;

mint dp[51][51][2501];

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

  dp[0][0][0] = 1;
  rep(i,N) {
    rep(j,i+1) rep(k,K+1) {
      dp[i+1][j][k+2*j] += dp[i][j][k] * (2*j + 1);
      if(j > 0) dp[i+1][j-1][k+2*(j-1)] += dp[i][j][k]*j*j;
      dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k];
    }
  }

  cout << dp[N][0][K] << endl;
  return 0;
}


Measured memory_bytes: 49152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[3][3],b[3][3]={};
  for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        cin >> a[i][j];
        b[i][j] = -1;
      }
  }
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
      int num;
      cin >> num;
      for(int j=0;j<3;j++){
          for(int k=0;k<3;k++){
              if(a[j][k]==num) b[j][k]=1;
          }
      }
  }
  bool flag = 0,flag1 = 0,flag2=0;
  for(int i=0;i<3;i++){
          if((b[i][0]==b[i][1])&&(b[i][1]==b[i][2])&&b[i][0]!=-1) flag = 1;
          if((b[0][i]==b[1][i])&&(b[1][i]==b[2][i])&&b[0][i]!=-1) flag1 = 1;
  }
  if(b[0][0]==b[1][1]&&b[1][1]==b[2][2]&&b[0][0]!=-1) flag2 = 1;
  if(b[0][2]==b[1][1]&&b[1][1]==b[2][0]&&b[0][2]!=-1) flag2 = 1;
  if(flag||flag1||flag2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, X, T;
	cin >> N >> X >> T;

	cout << ((N + X - 1) / X) * T << "\n";

	return 0;
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int n,k;
    string s;
    cin >> n >> k >> s;
    k--;
    s[k] = tolower(s[k]);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
pas = input()
ans1,ans2,ans3 = 0,0,0

if len(pas)<6:
    print("INVALID")
else:
    for i in range(len(pas)):
        if pas[i].isupper(): ans1 += 1
        if pas[i].islower(): ans2 += 1
        if pas[i].isdecimal(): ans3 += 1

    if ans1>0 and ans2>0 and ans3>0: print("VALID")
    else: print("INVALID")




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

string WA = "WA";
string AC = "AC";

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n, 0);
  int seikai = 0;
  int penalty = 0;
  rep(i, m) {
    int q;
    cin >> q;
    string hantei;
    cin >> hantei;
    if (hantei == AC && p[q-1] != -1) {
      seikai++;
      penalty += p[q-1];
      p[q-1] = -1;
      continue;
    }
    if (hantei == WA && p[q-1] != -1) {
      p[q-1]++;
      continue;
    }
  }
  
  cout << seikai << ' ' << penalty << endl;
  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B; cin >> A >> B;
    int ans = 0;
    ans += max(A, B);
    if(A > B) A--;
    else B--;
    ans += max(A, B);
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int a,b,c,d,e;
    vector<int> V(5);
    vector<int> A;
    int diff = 0;
    int total = 0;
    rep(i,5) {
        cin >> V[i];
        if(V[i]%10 != 0) {
            A.pb(10-V[i]%10);
        }
    }
    sort(all(A));
    rep(i,5) {
        total += V[i];
    }
    if (A.size() > 0) {
        rep(j,A.size()-1) {
            diff += A[j];
        }
    }
    cout << total+diff << "\n";
}


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

using namespace std;
typedef long long int lli;
lli N;
lli v[ 1005 ];
lli w[ 10005 ];
lli DP[ 1005 ][ 10005 ];
bool visited[ 1005 ][ 10005 ];

lli max_sum( lli i, lli weight ){

    if( weight < 0 )
        return INT64_MIN;
    
    if( i >= N )
        return 0;
    
    if( visited[ i ][ weight ] )
        return DP[ i ][ weight ];

    visited[ i ][ weight ] = true;

    lli take = max_sum( i + 1, weight - w[ i ] ) + v[ i ];
    lli not_take = max_sum( i + 1, weight );
    lli take_the_same = max_sum( i, weight - w[ i ] ) + v[ i ];

    return DP[ i ][ weight ] = max( { take, not_take, take_the_same } );
}

int main(){
    lli W;
    cin >> N >> W;
    for( int i = 0; i < N; i++)
        cin >> v[ i ] >> w[ i ];
    
    cout << max_sum( 0, W ) << endl;

    return 0;
}


Measured memory_bytes: 12300
import sys

N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N == 1:
    if A[0] == 0:
        print(1)
        sys.exit()
    else:
        print(0)
        sys.exit()
        
if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        k = 0
        for i in range(0, N//2 + 1, 2):
            if a[k] == a[k+1] == 2*j:
                j += 1
                k += 2
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    k = 0
    for i in range(0, N//2 + 1, 2):
        if A[k] == A[k+1] == 2*j -1:
            j += 1
            k += 2
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

Measured memory_bytes: 13880
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)998244353) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	string str;
	cin >> str;
	if(n>=3200)
		cout << str << endl;
	else
		cout << "red" << endl;

	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int count;
  int ans = 10000000;
  for (int i = a[0]; i <= a[n - 1]; i++)
  {
    count = 0;
    for (int j = 0; j < n; j++)
    {
      count += (a[j] - i) * (a[j] - i);
      //cout << i << endl;
    }
    if (count < ans)
      ans = count;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = int(1e5);
ll N, K, a[MAX_N], b[MAX_N];
map<ll, ll> mp;


void solve() {
    ll times = 0;
    EACH(m, mp) {
        times += m.second;
        if (times >= K) {
            cout << m.first << endl;
            return;
        }
    }
}

int main() {
    cin >> N >> K;
    REP(i, N) {
        cin >> a[i] >> b[i];
        mp[a[i]] += b[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> D;
  Vec(C,lli,26,0);
  rep(i,0,26)cin >> C[i];
  DV(A,lli,D,26,0);
  rep(i,0,D)rep(j,0,26)cin >> A[i][j];
  Vec(last,lli,26,-1);
  rep(i,0,D){
    num=0;
    int flag2=-1;
    rep(j,0,26){
      flag=A[i][j];
      int temp=last[j];
      last[j]=i;
      rep(k,0,26)flag-=C[i]*(i-last[j]);
      last[j]=temp;
      if(flag>num){
        num=flag;
        flag2=j;
      }
    }
    if(flag2=-1){
      num=0;
      rep(j,0,26)chmax(num,C[i]*(i-last[j]));
      rep(j,0,26){
        if(num==C[i]*(i-last[j])){
          flag2=j;
          break;
        }
      }
    }
    last[flag2]=i;
    Out(flag2+1);
  }
}

Measured memory_bytes: 3748
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
fn main() {
    input! { n: usize, mut v: [i32;n] }
    v.sort(); 
    let max = v.pop().unwrap();
    let mut sum = 0;
    for i in v {
        sum += i;
    }
    if sum > max {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
import java.util.*;

class Node {
	public int id;
	public Node parent;
	public Node[] children;
	public int depth;

	Node(int id) {
		this.id = id;
	}
	void setChilidren(Node[] children) {
		this.children = children;
		for (int i = 0; i < children.length; i++) {
			this.children[i].setParent(this);
		}
	}
	void setParent(Node parent) {
		this.parent = parent;
	}
	void setDepth(int depth) {
		this.depth = depth;
		if (this.children != null) {
			for (int i = 0; i < children.length; i++) {
				this.children[i].setDepth(depth + 1);
			}
		}
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node[] tree = new Node[n];
		for (int i = 0; i < n; i++) {
		    tree[i] = new Node(i);
		}
		for (int i = 0; i < n; i++) {
			Node node = tree[scanner.nextInt()];
			int k = scanner.nextInt();
			if (k > 0) {
				Node[] c = new Node[k];
				for (int j = 0; j < k; j++) {
					c[j] = tree[scanner.nextInt()];
				}
				node.setChilidren(c);
			}
		}
		Node root = null;
		for (int i = 0; i < n; i++) {
			if (tree[i].parent == null) {	
				root = tree[i];
				break;
			}
		}
		root.setDepth(0);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append("node ");
			sb.append(i);
			sb.append(": parent = ");
			sb.append(tree[i].parent == null ? -1 : tree[i].parent.id);
			sb.append(", depth = ");
			sb.append(tree[i].depth);
			sb.append(", ");
			if (tree[i].parent == null) {
				sb.append("root");
			} else {
				sb.append(tree[i].children == null ? "leaf" : "internal node");
			}
			sb.append(", [");
			if (tree[i].children != null) {
				for (int j = 0; j < tree[i].children.length; j++) {
					sb.append(tree[i].children[j].id);
					sb.append(j == tree[i].children.length - 1 ? "]" : ", ");
				}
			} else {
				sb.append("]");
			}

			sb.append("\n");
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 114572
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=0;
static int t=6e5;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int before=ans[p];
    int after=rand()%ntype+1;
    int before_score=Score(before)+Score(after);
    ans[p]=after;
    int delta=Score(before)+Score(after)-before_score;
    if(delta>0){ 
        max_score+=delta;
    }
    else ans[p]=before;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


Measured memory_bytes: 3700
#!/usr/bin/ruby

n, m = gets.split.map { |s| s.to_i }
ab = []
(0...n).each { |i|
  ab[i] = gets.split.map { |s| s.to_i }
}
days = (1..m).to_a
payments = 0
ab.sort { |ab1, ab2|
  a1, b1 = ab1
  a2, b2 = ab2
  if b1 != b2
    b2 <=> b1
  else
    a1 <=> a2
  end
}.each { |a, b|
  i = days.bsearch_index { |d| d >= a }
  next if i == nil
  days.delete_at(i)
  payments += b
  break if days.length == 0
}
puts payments


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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h,a;
    cin>>h>>a;
    int ans=0;
    while(h>0){
        h-=a;
        ans++;
    }
    cout<<ans;
    return 0;
}


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

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&b==c&&c==a)||(a!=b&&b!=c&&c!=a)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define Free (-1)
#define NonFree (-2)
#define NoQ (-3)
using namespace std;
const int N = 8;
int row[N];
int col[N];
int dpos[15];
int dneg[15];

int inits[N];

void printBoard() {
    for (int r = 0; r < N; ++r) {
        for (int c = 0; c < N; ++c) {
            if (row[r] != c) {
                cout << ".";
            } else {
                cout << "Q";
            }
        }
        cout << endl;
    }
};

void putQueen(int i) { 
    int j;
    if (i == N) {
        printBoard();
        return;
    }
    if (inits[i] == Free) {
        for (j = 0; j < N; ++j) {
            if (col[j] == NonFree ||
                dpos[i + j] == NonFree ||
                dneg[i - j + N - 1] == NonFree) {
                continue;
            }
            row[i] = j;
            col[j] = dpos[i + j] = dneg[i - j + N - 1] = NonFree;
            putQueen(i + 1);
            row[i] = NoQ;
            col[j] = dpos[i + j] = dneg[i - j + N - 1] = Free;
        }
    }else{
        putQueen(i + 1);
    }
};
void DeskSetup(int r, int c) {  // Basic
    row[r] = c;
    col[c] = dpos[r + c] = dneg[r - c + N - 1] = NonFree;
}

void InitDesk() { // Basic
    for (int j = 0; j < N; ++j) {
        row[j] = NoQ;
        col[j] = inits[j] = Free;
    }
    for (int j = 0; j < 15; ++j) {
        dpos[j] = dneg[j] = Free;
    }

};

int main() {
    int r, c, i;
    InitDesk();
    cin >> i;
    for (int k = 0; k < i; ++k) {
        cin >> r >> c;
        DeskSetup(r, c);
        inits[r] = NonFree;
    }
    putQueen(0);
    return 0;
}


Measured memory_bytes: 3096
def west_count(s):
    a = []
    n = 0
    for c in s:
        a.append(n)
        if c == "W":
            n += 1
    return a


def east_count(s):
    a = []
    n = 0
    for c in reversed(s):
        a.append(n)
        if c == "E":
            n += 1
    return list(reversed(a))


n = int(input())
s = input()
w = west_count(s)
e = east_count(s)

ans = n
for i in range(n):
    ans = min(ans, w[i] + e[i])

print(ans)


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

int main()
{
    int n, m, x; cin>>n>>m>>x;
    vector<int> a(n+1);
    for(; cin>>m; a[m]=1);

    int toL=0; for(int i=x; i>=0; --i) toL+=a[i];
    int toR=0; for(int i=x; i<=n; ++i) toR+=a[i];
    cout<<min(toL, toR)<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<lint> G[60]; // MAX_V,隣接リスト
lint root;

lint parent[7][60]; // logMAX_V,MAX_V
lint depth[60];

void LCAdfs(lint v,lint p,lint d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,G[v].size()) if(G[v][i]!=p) LCAdfs(G[v][i],v,d+1);
}

void LCAinit(lint V){
    LCAdfs(root,-1,0);
    for(int k=0;k+1<7;k++){
        for(int v=0;v<V;v++){
            if(parent[k][v]<0) parent[k+1][v]=-1;
            else parent[k+1][v]=parent[k][parent[k][v]];
        }
    }
}

lint LCA(lint u,lint v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<7;k++){
        if((depth[v]-depth[u])>>k&1) v=parent[k][v];
    }
    if(u==v) return u;
    for(int k=7-1;k>=0;k--){
        if(parent[k][u]!=parent[k][v]){
            u=parent[k][u];
            v=parent[k][v];
        }
    }
    return parent[0][u];
}

vector<int> path(int s,int t){
    int lca=LCA(s,t);
    vector<int> ps,pt;
    int now=s;
    while(true){
        if(now==lca) break;
        ps.push_back(now);
        now=parent[0][now];
    }
    now=t;
    while(true){
        pt.push_back(now);
        if(now==lca) break;
        now=parent[0][now];
    }
    reverse(pt.begin(),pt.end());
    ps.insert(ps.end(),pt.begin(),pt.end());
    return ps;
}

map<pint,int> edge;

int main(void){
    int N;
    cin >> N;
    rep(i,N-1){
        int u,v;
        cin >> u >> v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
        edge[pint(u,v)]=i;
        edge[pint(v,u)]=i;
    }
    LCAinit(N);
    lint ans=(1LL<<(N-1));
    lint minus=0;
    int M;
    cin >> M;
    int u[M],v[M];
    rep(i,M) cin >> u[i] >> v[i];
    rep(i,M) u[i]--,v[i]--;
    int edgecnt[N-1]={};
    rep(i,(1<<M)){
        if(i==0) continue;
        int pick=Flagcount(i);
        rep(j,M) if(i&(1<<j)){
            vector<int> way=path(u[j],v[j]);
            rep(k,way.size()-1) edgecnt[edge[pint(way[k],way[k+1])]]++;
        }
        int vtx=0;
        rep(i,N-1) if(edgecnt[i]) vtx++;
        lint cnt=(1LL<<(N-1-vtx));
        if(pick%2) minus+=cnt;
        else minus-=cnt;
        rep(j,N-1) edgecnt[j]=0;
    }
    cout << ans-minus << endl;
}

Measured memory_bytes: 3612
N = int(input())
dic = {}

for i in range(N):
    s = input()
    if s in dic:
        dic[s]= dic[s]+1
    else:
        dic[s]=1

# valueがmaxであるkeyを探してくる
max_val = max(dic.values())
keys_of_max_val = [key for key in dic if dic[key] == max_val]

keys_of_max_val.sort()

for k in keys_of_max_val:
    print(k)


Measured memory_bytes: 32092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t;
  cin >> t;
  int ts = t.size();
  char x;
  for (int i = 0; i < ts; i++) {
    x = t.at(i);
    if (x == '?') {
      t.at(i) = 'D';
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3724
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 250;

/* typedef */

/* global variables */

int as[MAX_H];

/* subroutines */

/* main */

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

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

  for (int i = 0; i < h; i++) {
    printf("node %d: key = %d, ", i + 1, as[i]);
    if (i > 0) printf("parent key = %d, ", as[(i - 1) / 2]);
    int i0 = i * 2 + 1, i1 = i0 + 1;
    if (i0 < h) printf("left key = %d, ", as[i0]);
    if (i1 < h) printf("right key = %d, ", as[i1]);
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
#include<map>
#include<cmath>
#define INF 999999999
typedef long long ll;

int main() {
	std::string a, b, c;
	std::cin >> a >> b;
	c = a + b;
	int iii = std::stoi(c);
	double i;
	int ii;
	ii = sqrt(iii);
	i = sqrt(iii);
	if (ii == i) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = [ni() for _ in range(n)]

    a.sort()

    ans1 = []
    ans2 = []
    if not n % 2:
        small = a[:n // 2]
        large = a[n // 2:]
        for i in range(n // 2):
            ans2.append(large[i])
            ans2.append(small[i])

        tmp_ans = 0
        for i in range(1, n):
            tmp_ans += abs(ans2[i - 1] - ans2[i])

        print(tmp_ans)

    else:
        small1 = a[:n // 2 + 1]
        large1 = a[n // 2 + 1:]
        small1.insert(0, small1[-1])
        del small1[-1]
        for i in range(n // 2):
            ans1.append(small1[i])
            ans1.append(large1[i])
        ans1.append(small1[n // 2])

        small2 = a[:n // 2]
        large2 = a[n // 2:]
        large2.append(large2[0])
        del large2[0]
        for i in range(n // 2):
            ans2.append(large2[i])
            ans2.append(small2[i])
        ans2.append(large2[n // 2])

        tmp_ans1 = 0
        tmp_ans2 = 0
        for i in range(1, n):
            tmp_ans1 += abs(ans1[i - 1] - ans1[i])
            tmp_ans2 += abs(ans2[i - 1] - ans2[i])

        print(max(tmp_ans1, tmp_ans2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 13152
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;


int N;
int a[20], ans = 0;

void solve(int idx, bool even = false) {
    if(idx == N) {
        if(even) ans++;
    }
    else {
        for(int i=-1; i<=1; i++) {
            int val = a[idx] + i;
            // printf("idx = %lld, val = %lld, even = %d\n", idx, val, even);
            solve(idx+1, even | (val % 2 == 0));
        }
    }
}

signed main() {
    cin >> N;
    rep(i,0,N) cin >> a[i];
    solve(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
 
namespace Application
{
	class Solution
	{
		static void Main(string[] args)
		{ 
			var currentTime = 0;
			var currentX = 0;
			var currentY = 0;
 
			var stepCount = int.Parse(Console.ReadLine());
 
			var result = "Yes";
 
			for (var i = 0; i < stepCount; i++)
			{
				var inputWords = Console.ReadLine().Split(' ');
				var nextTime = int.Parse(inputWords[0]);
				var nextX = int.Parse(inputWords[1]);
				var nextY = int.Parse(inputWords[2]);
 
				var diffTime = nextTime - currentTime;
				var diffX = Math.Abs(nextX - currentX);
				var diffY = Math.Abs(nextY - currentY);
 
				var move = diffTime - (diffX + diffY);
 
				// 到達可能
				if (move >= 0
					&& move % 2 == 0)
				{
					currentTime = nextTime;
					currentX = nextX;
					currentY = nextY;
				}
				else
				{
					result = "No";
					break;
				}
			}
 
			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 15292
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){
	
	ll N, H;
	cin >> N >> H;
	vvl v(N, vl(2));
	rep(i, N) cin >> v[i][0] >> v[i][1];
	
	ll ma = 0;
	rep(i, N) chmax(ma, v[i][0]);
	vl p(0);
	rep(i, N) if(v[i][1] > ma) p.push_back(v[i][1]);
	
	ll ans = 0;
	ll cnt = 0;
	SORT(p);
	REV(p);
	rep(i, p.size()){
		if(cnt >= H) break;
		ans += 1;
		cnt += p[i];
	}
	if(cnt < H) ans += (H - cnt + ma - 1) / ma;
	print(ans);
		
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
    
	return 0;
	
}





Measured memory_bytes: 9708
# coding: utf-8
# Your code here!

def floor_sum(n,m,a,b):
    res = 0
    while True:
        res += ((n-1)*n*(a//m)>>1) + (b//m)*n
        a %= m
        b %= m
        if a*n+b <= m:
            return res
        Y = (a*n+b)//m
        n,m,a,b = Y,a,m, a*n + b - m*Y

import sys
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
    n,m,a,b = map(int,input().split())
    print(floor_sum(n,m,a,b))


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 500 + 5;
int mat[MAX][MAX], D[MAX][MAX], group[3][35];
int n, c;

int main() {
	scanf("%d %d", &n, &c);
	fori(i, 1, c + 1) {
		fori(j, 1, c + 1) {
			scanf("%d", &D[i][j]);
		}
	}
	fori(i, 1, n + 1) {
		fori(j, 1, n + 1) {
			scanf("%d", &mat[i][j]);
			int g = (i + j) % 3;
			fori(k, 1, c + 1) {
				group[g][k] += D[mat[i][j]][k];
			}
		}
	}

	int ans = 1 << 30;
	fori(i, 1, c + 1) {
		fori(j, 1, c + 1) {
			fori(k, 1, c + 1) {
				if(i == j || i == k || j == k) {
					continue;
				}
				ans = min(ans, group[0][i] + group[1][j] + group[2][k]);
			}
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

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

	int maximum = 0,ans = 1;

	for(int i = 2; i <= N; i++){

		int count = 0;
		int tmp = i;

		while(tmp%2 == 0){
			tmp /= 2;
			count++;
		}
		if(maximum < count){
			maximum = count;
			ans = i;
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3748