akhauriyash/Code-Regression huggingface dataset:
A, B, K = [int(i) for i in input().split()]

for i in range(K):
    if A%2 == 1 and i%2 == 0:
        A += -1
        B += int(A/2)
        A = int(A/2)
    elif A%2 == 0 and i%2 == 0:
        B += int(A/2)
        A = int(A/2)
    elif B%2 == 1 and i%2 == 1:
        B += -1
        A += int(B/2)
        B = int(B/2)
    elif B%2 == 0 and i%2 == 1:
        A += int(B/2)
        B = int(B/2)

print(A, end=' ')
print(B)


Measured memory_bytes: 3064
import org.w3c.dom.ls.LSOutput;
import java.util.*;
public class Main {
    static boolean visited[] = new boolean[1002];
    static boolean counted[] = new boolean[1002];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        if (n >= 400 && n < 600) {
            count = 8;
        }
        if (n >= 600 && n < 800) {
            count = 7;
        }
        if (n >= 800 && n < 1000) {
            count = 6;
        }
        if (n >= 1000 && n < 1200) {
            count = 5;
        }
        if (n >= 1200 && n < 1400) {
            count = 4;
        }
        if (n >= 1400 && n < 1600) {
            count = 3;
        }
        if (n >= 1600 && n < 1800) {
            count = 2;
        }
        if (n >= 1800 && n < 2000) {
            count = 1;
        }
        System.out.println(count);
    }
}






Measured memory_bytes: 35760
from math import factorial as f
from collections import Counter as co
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
d=co(a)
keys=[k for k,v in d.items() if v==2]
dbl=keys[0]
ll=[i for i,x in enumerate(a) if x==dbl]
b=ll[1]-ll[0]
m=n-b

def pf(x,y,p):
  if y==0: return 1
  if y%2==0:
    d=pf(x,y//2,p)
    return d*d%p
  if y%2==1:
    return (x*pf(x,y-1,p))%p

facl=[1]
for i in range(1,n+2):
  facl.append(facl[i-1]*i%mod)
invl=[1]*(n+2)
for i in range(1,n+2):
  invl[i]=pf(facl[i],mod-2,mod)

def comb(x,k,p):
  if x<0 or k<0 or x<k: return 0
  if x==0 or k==0: return 1
  return (facl[x]*invl[k]*invl[x-k])%mod

for k in range(1,n+2):
  print((comb(n+1,k,mod)-comb(m,k-1,mod))%mod)

Measured memory_bytes: 23020
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include<string>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
const LL maxn=4e5+10;
const double eps=1e-9;
LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int read1()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main()
{
    LL a,b,c;
    cin>>a>>b>>c;
    if(c-a-b<0){
        printf("No\n");
    }
    else{
    if(4*a*b<(c-a-b)*(c-a-b)){
          //  printf("%lld\n",4*a*b);
        printf("Yes\n");
    }
    else{
         // printf("%lld\n",4*a*b);
        printf("No\n");
    }
    }
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vvi dp(n+1, vi(m+1));

  rep(i,0,n+1) rep(j,0,m+1) {
    if (i<n and j<m and s[i] == t[j]) ckmax(dp[i+1][j+1], dp[i][j]+1);
    if (i < n) ckmax(dp[i+1][j], dp[i][j]);
    if (j < m) ckmax(dp[i][j+1], dp[i][j]);
  }

  int i = n, j = m;
  string ans;
  while (i and j) {
    if (s[i-1] == t[j-1]) {
      ans.pb(s[i-1]);
      --i; --j;
    } else if (dp[i][j] == dp[i-1][j]) --i;
    else --j;
  }

  reverse(all(ans));
  cout << ans << '\n';
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  ll n;
  cin >> n;
  ll a[200010];
  ll cnt[200010] = {};
  rep(i, n)
  {
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
  }
  ll sum = 0;
  rep(i, n)
  {
    sum += cnt[i] * (cnt[i] - 1) / 2;
  }
  rep(i, n)
  {
    cout << sum - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){
    int c[3][3];
    cin >> c[0][0] >> c[0][1] >> c[0][2];
    cin >> c[1][0] >> c[1][1] >> c[1][2];
    cin >> c[2][0] >> c[2][1] >> c[2][2];
    int d[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            d[i][j] = c[i][j] - c[i][(j+1)%3];
        }
    }
    for(int i=0;i<3;i++){
        bool b = d[0][i] == d[1][i] && d[1][i] == d[2][i];
        if(!b){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            d[i][j] = c[i][j] - c[(i+1)%3][j];
        }
    }
    for(int i=0;i<3;i++){
        bool b = d[i][0] == d[i][1] && d[i][1] == d[i][2];
        if(!b){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    int fst_pl = -1;
    rep(i, n) {
        cin >> x[i];
        if (fst_pl == -1 && x[i] > 0) fst_pl = i;
    }

    ll ans = 1001001001;
    for (int i=0; i<n-k+1; i++) {
        ll tmp = abs(x[i] - x[i+k-1]);
        if (i < fst_pl && i+k-1 >= fst_pl) {
            ll s = min(abs(x[i]), x[i+k-1]);
            tmp += s;
        } else if (fst_pl >= i){
            tmp += abs(x[i]);
        } else {
            tmp += abs(x[i+k-1]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,m,x;
int c[15];
int a[15][15];

void solve(){
    cin >> n >> m >> x;
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int U=(1 << n);
    int ans=mod;
    rep(S,U){
        vector<int> v(m,0);
        int num=0;
        rep(i,n){
            if(S&(1 << i)){
                num+=c[i];
                rep(j,m){
                    v[j]+=a[i][j];
                }
            }
        }
        bool flag=true;
        rep(i,m){
            if(v[i]<x) flag=false;
        }
        if(flag) ans=min(ans,num);
    }
    if(ans<mod) cout << ans << endl;
    else cout << -1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int get_lcs_length(std::string X, std::string Y) {
    int m = X.length();
    int n = Y.length();
    vector<vector<int>> c(m + 1, vector<int>(n + 1, 0));
    X = " " + X;
    Y = " " + Y;

    int max_length = 0;
    for (int i = 1; i <= m; i ++) {
        for (int j = 1; j <= n; j ++) {
            if (X[i] == Y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = std::max(c[i - 1][j], c[i][j - 1]);
            }
            max_length = std::max(max_length, c[i][j]);
        }
    }
    return max_length;
}

int main() {
    int q;
    std::cin >> q;
    for (int i = 0; i < q; i ++) {
        std::string X, Y;
        std::cin >> X;
        std::cin >> Y;
        std::cout << get_lcs_length(X, Y) << std::endl;
    }

}



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


void solve(long long N, std::vector<long long> A){
  const long long M = 1'000'000;
  vector<long long> cnt(M, 0);
  for (long long a : A) {
    if (cnt[a] != 0) {
      cnt[a] = 2;
      continue;
    }
    for (long long i=a; i<=M; i+=a) cnt[i]++;
  }

  long long ans = 0;
  for (auto a : A) {
    if (cnt[a] == 1) ans++;
  }
  cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 12760
import bisect as bi
 
n = int(input())
lia = list(map(int,input().split()))
lib = list(map(int,input().split()))
lic = list(map(int,input().split()))
lia = sorted(lia)
lib = sorted(lib)
lic = sorted(lic)
 
ans = 0
for i in range(n):
  tmpa = bi.bisect_left(lia,lib[i])
  tmpc = n - bi.bisect_right(lic,lib[i])
  ans += tmpa*tmpc
print(ans)

Measured memory_bytes: 23360
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n = 5;
    rep(i,n) {
        int a; cin>>a;
        if (a==0) {
            cout << i+1 << '\n';
            return 0;
        }
    }
    return 0;
}

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

#define ll long long int
#define mem(n) memset(n,0,sizeof(n))
#define LCM(a,b) (a / __gcd(a,b) ) * b
#define gcd(a,b) __gcd(a,b)
#define for0(l,n) for(int l=0;l<n;l++)
#define for1(l,n) for(int l=1;l<=n;l++)
#define bug(n) cout<<">> "<<n<<" <<";
#define pb push_back
#define P1(a) cout<<a<<endl;
#define P2(a,b) cout<<a<<" "<<b<<endl;
#define P3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define S1(a) cin>>a
#define S2(a,b)cin>>a>>b
#define S3(a,b,c) S2(a,b),S2(c)
#define squerit(n) (ll)n*n
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)

bool vowel(char a)
{
    a= toupper(a);
    if((a=='A')||(a=='E')||(a=='I')||(a=='O')||(a=='U'))return 1;
    return 0;
}

ll n,arr[5000];

int main()
{
    ll m;
    cin>>n>>m;
    ll a;
    ll sum = 0;
    for0(i,n)
    {
        cin>>a;

       ll mn = min( a- 0, abs(a-m) );
        sum+= mn*2;
    }
    cout<<sum<<endl;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] v = new double[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextDouble();
		}
		sc.close();

		Arrays.sort(v);

		double vAve = (v[0] + v[1]) / 2;
		double tmp = 0;

		for (int i = 2; i < n; i++) {
			tmp = vAve;
			vAve = (tmp + v[i]) / 2;
		}

		System.out.println(vAve);

	}

}


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

int main() {
  int H;  //縦の個数
  int W; //横の個数
  
  cin >> H >> W;  //入力
  
  vector<string> test(H);  //H行のラインの文字列データ
  vector<string> result(H);  //結果の文字列データ
  
  //テストのデータを受け取る
  for (int i = 0; i < H; i++){
    cin >> test.at(i);
  }
  
  //一行目の出力
  for (int i = 0; i < W + 2; i++){
    cout << '#';
  }
  
  //改行
  cout << "" << endl;
  
  //各行において、#をつけ足していく→出力も
  for (int i = 0; i < H; i++){
    result.at(i) = '#' + test.at(i) + '#';
    cout << result.at(i) << endl;
  }
  
  //最後の行の出力
  for (int i = 0; i < W + 2; i++){
    cout << '#';
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		//組み合わせ判定
		if (S.equals("AAA") || S.equals("BBB")) {
			//一致したとき
			System.out.println("No");

		}
		//一致しないとき
		else {

			System.out.println("Yes");
		}
		sc.close();

	}

}


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

int main() {
  int A,B,C,D; 
  cin>>A>>B>>C>>D;
  int ans;
  if(B<=C||D<=A)ans=0;
  else if(A<=C&&B>=D)ans=D-C;
  else if(C<=A&&D>=B)ans=B-A;
  else if(A<=C&&B<=D)ans=B-C;
  else if(C<=A&&D<=B)ans=D-A;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
array = [list(map(int, input().split())) for i in range(N)]

cost = 0
time = 0

for i in range(N):
    if array[i][1] <= T and (cost > array[i][0] or cost == 0):
        cost = array[i][0]

if cost == 0:
    print('TLE')
    exit()

print(cost)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 100005
#define ll long long
#define slld(t) scanf("%I64d",&t)
#define sd(t) scanf("%d",&t)
#define ss(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%I64d\n",t)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define vi vector<int>
#define vpii vector<pii >
#define vll vector<ll>
#define clr(x) memset(x,0,sizeof(x))
#define fil(x) memset(x,MAX,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I <= (B); ++I)
using namespace std;
const ll INF = 2147483647;
ll digitsum (ll num)
{
    ll sum = 0 ;
    while (num != 0)
    {
        sum+=(num%10);
        num/=10;
    }
    return sum;
}
bool isPrime[MAX+1];
void sieve(int n) 
{
    for(int i = 0; i <= n;++i) 
    {
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= n; ++i) 
    {
         if(isPrime[i] == true) 
         {
             for(int j = i * i; j <= n ;j += i)
                 isPrime[j] = false;
        }
    }
}
#define matrix vector< vector<ll> >
matrix matmul(matrix &a, matrix &b){
    int i, j, k, n = a.size();
    matrix ans (n, vector<ll>(n));
    for(i=0;i<n;i++)
        for(j=0;j<n;j++){
            ll temp = 0;
            for(k=0;k<n;k++)    temp = (temp + a[i][k] * b[k][j]) % MOD;
            ans[i][j] = temp;
        }
    return ans;
}
matrix matpwr(matrix &a, ll p)
{
    int n = a.size();
    matrix ans(n, vector<ll> (n));
    for(int i=0;i<n;i++)    ans[i][i] = 1;
    while(p)
    {
        if(p&1) ans = matmul(ans, a);
        a = matmul(a, a);
        p >>= 1;
    }
    return ans;
}
ll pwr(ll base, ll p, ll mod = MOD)
{
   ll ans = 1;
    while(p)
    {
        if(p & 1)   ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return (a*b) / gcd(a, b);
}
const int N = 2e5+5 ;
int n ;
int dist[N];
set<int> s[N];
set<int> :: iterator it ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    //freopen("a.in", "r", stdin); 
    //freopen("a.out", "w", stdout);

    int r ;
    cin >> r ;
    int a[r] ;
    REP(i,r) cin >> a[i] ;
    sort(a,a+r) ;
    int ans = a[r-1] - a[0] ;
    cout<<ans ;

    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 10496
s = list(input())

num1 = 0
num2 = 0

for i in range(len(s)):
  if i%2 == 1:
    if int(s[i]) == 0:
      num1 += 1
    else:
      num2 += 1
  else:
    if int(s[i]) == 1:
      num1 += 1
    else:
      num2 += 1

print(min(len(s)-num1, len(s)-num2))

Measured memory_bytes: 3956
#include<iostream>
using namespace std;
bool slove(int N){
  int g=N;
  int sum=0;
  int dig;
  while(N){
    dig=N%10;
    sum=sum+dig;
    N=N/10;
  }
  if(g%sum==0){
    return true;
  }else{
    return false;
  }
}
int main(){
  int N;
  cin>>N;
  if(slove(N)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> sv(1046527);


int cton(char c) {
    if(c == 'A') return 1;
    else if(c == 'T') return 2;
    else if(c == 'G') return 3;
    else  return 4;
}
long long getkey(string str) {
    long long key = 0,fivpow = 1;//５進数的な
    for(int i = 0; i < str.size(); i++) {
        key += fivpow*cton(str.at(i));
        fivpow *= 5;
    }
    return key;
}

int h1(int key) {
    return (key % 1046527);
}

int h2(int key) {
    return (1 + (key % (1046526)));
}

bool find(string str) {
    long long key = getkey(str);
    long long h;
    for(int i = 0; ;i++) {
        h = (h1(key) + i*h2(key)) % 1046527;
        if(sv.at(h) == key) {
            return true;
        }
        else if(sv.at(h) == 0) {
            return false;
        }
    }
    return false;
}

int insert(string str, vector<int>& sv) {
    long long key = getkey(str);
    long long h;
    for(int i = 0; ;i++) {
        h = (h1(key) + i*h2(key)) % 1046527;
        if(sv.at(h) == key) {
            break;
        }
        else if(sv.at(h) == 0) {
            sv.at(h) = key;
            break;
        }
    }
    return 0;
}

int main (){
    int n;
    scanf ("%d",&n);
    string todo, str;
    for (int i = 0; i < n; i++) {
        cin >> todo >> str;
        if(todo.at(0) == 'i') {
            insert(str,sv);
        }
        else {
            if(find(str)) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}





Measured memory_bytes: 7172
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[1001],dp[101];
int main()
{
    int n;
    cin>>n;
    for(int i = 2; i<=n; i++)
    {
        int cur = i;
        for(int j = 2 ;j<=i; j++)
        {
            while(cur % j == 0)
            {
                cur /=j;
                cnt[j]++;
            }
        }
    }
    dp[1]=1;
    for(int i=1; i<=100; i++)
        if(cnt[i])
        {
            for(int j=75; j>=1; j--)
            {
                for(int x=1; x<=cnt[i]; x++)
                {
                    if(j*(x+1)<=75)
                        dp[j*(x+1)]+=dp[j];
                }
            }
        }
    cout<<dp[75]<<endl;
    return 0;
}


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

using namespace std;

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

    int n;

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

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

        int ans = a[n - 1] - a[0];
        for (int i = 0; i < n - 1; ++i)
            ans = min(ans, a[i + 1] - a[i]);

        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N, A = 0, B = -10000000000, a = 10000000000, b = 10000000000, Ans = 0;

int main(){
cin >> N;

rep(i, 0, N){

  ll x, y;cin >> x >> y;

  A = max(x + y, A);B = max(x - y, B);

  a = min(x + y, a);b = min(x - y, b);

}

Ans = max(A - a, B - b);

cout << Ans;

}

Measured memory_bytes: 3616
#include <stdio.h>
#define MAX 2000000

int size,a[MAX+1];

void maxHeapify(int i){
  int left,right,largest,b;
 
  left = 2 * i ;
  right = 2 * i + 1;

  if( left<=size && a[left] >a[i] )largest=left;

  else largest = i;

  if( right <=size && a[right] > a[largest] ) largest = right;

  if( largest != i ){
    b = a[i];
    a[i] = a[largest];
    a[largest] = b;
    maxHeapify(largest);
  }
}
int main(){

  int i;

  scanf("%d",&size);

  for( i=1 ; i<=size ; i++ ) scanf("%d",&a[i]);

  for( i=size/2 ; i>=1 ; i-- ) maxHeapify(i);

  for( i=1 ; i<=size ; i++ ){
    printf(" %d",a[i]);
  }
  
  printf("\n");

  return 0;

}


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

using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

inline bool compare(const int &a, const int &b){
    return a > b;
}

const int N = 100007;

vector <int> a, b, c;

inline int max_id(int &x, int &y, int &z){
    if(a[x] >= b[y] && a[x] >= c[z]) return x;
    if(b[y] >= c[z]) return y;
    return z;
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    a.resize(A); b.resize(B); c.resize(C);
    for(auto &x: a) cin >> x;
    for(auto &x: b) cin >> x;
    for(auto &x: c) cin >> x;
    sort(a.begin(), a.end(), compare);
    sort(b.begin(), b.end(), compare);
    sort(c.begin(), c.end(), compare);
    LL ans = 0;
    int x = 0, y = 0, z = 0;
    for(int i = 0; i < X+Y; i++){
        if(x < X && y < Y){
            if(z < C){
                if(a[x] >= b[y] && a[x] >= c[z]) ans += a[x++];
                else if(b[y] >= c[z]) ans += b[y++];
                else ans += c[z++];
            }
            else{
                if(a[x] >= b[y]) ans += a[x++];
                else ans += b[y++];
            }
        }
        else if(x < X){
            if(z < C){
                if(a[x] >= c[z]) ans += a[x++];
                else ans += c[z++];
            }
            else{
                ans += a[x++];
            }
        }
        else if(y < Y){
            if(z < C){
                if(b[y] >= c[z]) ans += b[y++];
                else ans += c[z++];
            }
            else{
                ans += b[y++];
            }
        }
        else{
            ans += c[z++];
        }
    }
    cout << ans << '\n';
    

	return 0;
}


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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int b_acc[n+1], w_acc[n+1];
  b_acc[0] = 0;
  w_acc[0] = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == '.') {
      b_acc[i+1] = b_acc[i];
      w_acc[i+1] = w_acc[i] + 1;
    } else {
      b_acc[i+1] = b_acc[i] + 1;
      w_acc[i+1] = w_acc[i];
    }
  }
  int ans = n;
  for (int i=0; i<=n; i++) {
    int tmp = b_acc[i] + (w_acc[n] - w_acc[i]);
    ans = min(tmp, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2180
from heapq import heappop, heappush
v_num, e_num = map(int, input().split())
pair_lst = [i for i in range(v_num)]
que = []
for _ in range(e_num):
  s, t, w = map(int, input().split())
  heappush(que, (w, s, t))
def find(x):
  if x == pair_lst[x]:
    return x
  else:
    tmp = find(pair_lst[x])
    pair_lst[x] = tmp
    return tmp

length_sum = 0
while que:
  w, s, t = heappop(que)
  root_s = find(s)
  root_t = find(t)
  if root_s != root_t:
    pair_lst[root_s] = root_t
    length_sum += w

print(length_sum)


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    vi h(n);
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vi dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int j=i+1;
        if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        j=i+2;
        if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	u64 N, X, M;
	cin >> N >> X >> M;

	if(N < M) {
		u64 ans = 0;

		for(u64 i=0; i<N; i++) {
			ans = ans + X;
			X = (X * X) % M;
		}
		
		cout << ans << endl;
		return 0;
	}

	vector<bool> l(M);
	u64 lsum = 0;
	u64 nX = X;

	// find loop
	for(u64 i=0; i<M; i++) {
		if(nX == 0) {
			cout << lsum << endl;
			return 0;
		}
		
		if(l[nX]) break;
		
		l[nX] = true;
		lsum = lsum + nX;
		nX = (nX * nX) % M;
	}

	// before loop
	u64 lcnt = 0;
	u64 ans = 0; 
	for(u64 i=X; i!=nX; i=i*i%M) {
		ans += i;
		lcnt++;
	}
	N-= lcnt;

	// in loop
	lsum = nX;
	lcnt = 1;

	for(u64 i=nX*nX%M; i!=nX; i=i*i%M) {
		lcnt++;
		lsum += i;
	}

	ans += (N / lcnt) * lsum;

	// extra
	u64 a = nX;
	for(u64 i=0; i<N%lcnt; i++) {
		ans += a;
		a = (a * a) % M;
	}

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

Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var hn = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var h = hn[0];
        var n = hn[1];
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var sum = seqA.Sum();
        Console.WriteLine(sum >= h ? "Yes" : "No");
    }
}


Measured memory_bytes: 18784
//https://atcoder.jp/contests/arc096/tasks/arc096_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    LL a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    cout<<min({
        a*x+b*y,
        2*x*c+max(y-x,0ll)*b,
        2*y*c+max(x-y,0ll)*a
        })<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
import bisect
l=[[] for _ in range(n)]
l2=[]

for i in range(m):
  p,y=map(int,input().split())
  l[p-1].append(y)
  l2.append([p,y])

for m in l:
  m.sort()
for m in l2:
  print("{:06d}".format(m[0]) +"{:06d}".format(bisect.bisect_left(l[m[0]-1],m[1])+1))


Measured memory_bytes: 34200
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    string c;
    std::cin >> c;
    if(c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o' ){
        std::cout << "vowel" << std::endl;
    }else{
        std::cout << "consonant" << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

ll dp[10010][2][110];

int main(void){
    string K;
    int D;
    cin >> K >> D;
    int N = K.size();
    dp[0][0][0] = 1;
    for(int n=0;n<N;++n){
        for(int d=0;d<D;++d){
            for(int free=0;free<2;++free){
                int x = K[n] - '0';
                for(int i=0;i<=9;++i){
                    if(i<x) dp[n+1][1][(d+i)%D] += dp[n][free][d] %= MOD;
                    else if(i==x) dp[n+1][free][(d+i)%D] += dp[n][free][d] %= MOD;
                    else if(free) dp[n+1][free][(d+i)%D] += dp[n][free][d] %= MOD;
                }
            }
        }
    }
    ll ans = (dp[N][0][0] + dp[N][1][0] - 1)%MOD;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a: A) cin >> a;

    vector<int> left(n + 1), right(n + 1);

    for (int i = 0; i < n; i++){
        left[i + 1] = max(A[i], left[i]);
        right[n - i - 1] = max(A[n - i - 1], right[n - i]);
    }

    for (int i = 0; i < n; i++)
        cout << max(left[i], right[i + 1]) << endl;
}

Measured memory_bytes: 3968
#include <iostream>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    int a[h][w], row[h] = {}, col[w] = {};
    string s;
    for (int i=0; i<h; i++) {
        cin >> s;
        for (int j=0; j<w; j++) {
            if (s[j] == '#') {
                a[i][j] = 1;
                row[i]++;
                col[j]++;
            } else {
                a[i][j] = 0;
            }
        }
    }
    for (int i=0; i<h; i++) {
        if (row[i] != 0) {
            for (int j=0; j<w; j++) {
                if (col[j] != 0) {
                    cout << ((a[i][j] == 0) ? '.' : '#');
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3628
#include <iostream>

#define N 100

using namespace std;

void dump(int n, int a[]) {
    for (int i=0; i<n; i++) {
        if (i>0) { cout<<" "; }
        cout<<a[i];
    }
    cout<<endl;
}

void selection_sort(int n, int a[], int& swapCount) {
    for (int i=0; i<n; i++) {
        int mini = i;
        for (int j=i; j<n; ++j) {
            if (a[j] < a[mini]) {
                mini = j;
            }
        }
        int tmp = a[mini];
        a[mini] = a[i];
        a[i] = tmp;
        if (i != mini) {
            swapCount++;
        }
    }
}

int main() {
    int n;
    int a[N];
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    int count = 0;
    selection_sort(n, a, count);
    dump(n, a);
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;

#define pb push_back
#define mod 1000000007
#define rep(n) for(int i = 0; i < n; i++)
#define drep(n) for(int i = n; i >= 0; i--)
#define For(n, m) for(int i = n; i < m; i++)
#define dfor(n, m) for(int i = n; i >= m; i--)
#define out(n) cout << n << endl;
#define vout(a) for(int i = 0; i < a.size(); i++) COUT(a[i])
#define aout(a) for(int i = 0; i < a.length(); i++) COUT(a[i])
#define sort(a) for(int i = 0; i < a.size() - 1; i++) for(int j = 0; j < a.size() - i - 1; j++) if(a[j] > a[j + 1]) swap(a[j], a[j + 1]);
#define dsort(a) for(int i = 0; i < a.size() - 1; i++) for(int j = 0; j < a.size() - i - 1; j++) if(a[j] < a[j + 1]) swap(a[j], a[j + 1]);

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

  b = a / 11;
  c = a % 11;

  out(b * 2 + (c <= 6 ? c == 0 ? 0 : 1 : 2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    ll K;
    cin >> N >> K;
    vector<ll> cnt(45);
    for (int i = 0; i < N; ++i) {
        ll A;
        cin >> A;
        for (int j = 0; j < 45; ++j)
            if ((A >> j) & 1)
                cnt[j]++;
    }

    vector<vector<ll>> dp(45, vector<ll>(2, -1));
    dp[44][1] = 0;
    for (int i = 43; i >= 0; --i) {
        if (~dp[i + 1][0]) {
            dp[i][0] = max(dp[i + 1][0] + (cnt[i] << i), dp[i][0]);
            dp[i][0] = max(dp[i + 1][0] + ((N - cnt[i]) << i), dp[i][0]);
        }
        if (~dp[i + 1][1]) {
            if ((K >> i) & 1) {
                dp[i][0] = max(dp[i + 1][1] + (cnt[i] << i), dp[i][0]);
                dp[i][1] = max(dp[i + 1][1] + ((N - cnt[i]) << i), dp[i][1]);
            } else
                dp[i][1] = max(dp[i + 1][1] + (cnt[i] << i), dp[i][1]);
        }
    }

    cout << max(dp[0][0], dp[0][1]) << endl;

    return 0;
}


Measured memory_bytes: 3664
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

q = deque([0])
d = [-1]*n
d[0] = 0
ans = [0]*n
print("Yes")

while q:
    p = q.popleft() # 先に入れた要素を取り出す
    for node in g[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            q.append(node) # リストへの追加
        else:
            if d[node] + 1 == d[p]:
                ans[p] = node + 1

for i in range(1,n):
    print(ans[i])


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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(abs(a-e)<=k){
    cout << "Yay!";
  }else{
    cout << ":(";
  }
}

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

using namespace std;

const int NS = (int)2e5+4, MOD = (int)1e9+7;
int N, arr[NS];
int last[NS];
int d[NS];

int main(){
    scanf("%d", &N); for(int i=1;i<=N;++i) scanf("%d", arr+i);
    d[0] = 1;
    for(int i=1;i<=N;++i){
        d[i] = d[i-1];
        if(last[arr[i]]&&last[arr[i]]<i-1) d[i] = (d[i]+d[last[arr[i]]])%MOD;
        last[arr[i]] = i;
    }
    printf("%d\n", d[N]);
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);   //入力を受け付ける
    if(a==b&&b==c){             //全ての色が同じなら
        puts("1");
    }else if(a==b||b==c||a==c){ //3つのうち2つが同じなら 
        puts("2");
    }else{                      //上のどの条件にも当てはまらないなら
        puts("3");
    }
    return 0;
}


Measured memory_bytes: 128
a = list(map(int, input().split()))
H = int(a[0])
W = int(a[1])
K = int(a[2])
c_h_list = []
for i in range(H):
    c_h_list.append(input())

c_h = []
for i in range(H):
    for j in range(W):
        if c_h_list[i][j] == '.':
            c_h.append(0)
        elif c_h_list[i][j] == '#':
            c_h.append(1)
ret = 0
for h_count in range(2**H):
    for w_count in range(2**W):
        c_h_copy = c_h.copy()
        if h_count % 2 == 1:
            for i in range(W):
                c_h_copy[i] = 0
        if h_count//2 % 2 == 1:
            for i in range(W):
                c_h_copy[i + W * 1] = 0
        if h_count//4 % 2 == 1:
            for i in range(W):
                c_h_copy[i + W * 2] = 0
        if h_count//8 % 2 == 1:
            for i in range(W):
                c_h_copy[i + W * 3] = 0
        if h_count//16 % 2 == 1:
            for i in range(W):
                c_h_copy[i + W * 4] = 0
        if h_count//32 % 2 == 1:
            for i in range(W):
                c_h_copy[i + W * 5] = 0
        if w_count % 2 == 1:
            for i in range(H):
                c_h_copy[i * W] = 0
        if w_count//2 % 2 == 1:
            for i in range(H):
                c_h_copy[i*W + 1] = 0
        if w_count//4 % 2 == 1:
            for i in range(H):
                c_h_copy[i*W + 2] = 0
        if w_count//8 % 2 == 1:
            for i in range(H):
                c_h_copy[i*W + 3] = 0
        if w_count//16 % 2 == 1:
            for i in range(H):
                c_h_copy[i*W + 4] = 0
        if w_count//32 % 2 == 1:
            for i in range(H):
                c_h_copy[i*W + 5] = 0
        if sum(c_h_copy) == K:
            ret += 1
print(ret)


Measured memory_bytes: 9340
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

class UnionFind {
    vector<int> p;//p[i]はiの属する組織
public:
    UnionFind(int n) {
        p = vector<int>(n);
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
        return;
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        p[find(x)] = p[find(y)];
    }

/* xとyが属する集合が同じかを判定する */
    bool same(int x, int y) {
        return find(x) == find(y);
    }

};

class Solve {
public:
    Int N, M;
    vector<vector<pair<Int, Int>>> G;

    vector<Int> dist;

    bool dfs(int n, Int d = 0ll) {
        if (dist[n] != -INFl) {
            return dist[n] == d;
        }

        dist[n] = d;

        for (auto e : G[n]) {
            bool tmp = dfs(e.first, d + e.second);
            if (!tmp) {
                return false;
            }
        }

        return true;
    }


    void solve() {
        cin >> N >> M;
        G.resize(N);
        dist.resize(N, -INFl);

        for (int i = 0; i < M; ++i) {
            Int a, b, d;
            cin >> a >> b >> d;
            a--, b--;
            G[a].push_back(make_pair(b, d));
            G[b].push_back(make_pair(a, -d));
        }

        for (int i = 0; i < N; ++i) {
            if (dist[i] == -INFl && !dfs(i)) {
                cout << "No" << endl;
                return;
            }
        }
        cout << "Yes" << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    char a[102][102];
    int b[26] {0};
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++){
        cin >> a[i][j];
        b[a[i][j] - 'a']++;
    }
    if(h % 2 == 0 && w % 2 == 0){
        for(int i = 0; i < 26; i++){
            if(b[i] % 4){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    if(h % 2 == 0 && w % 2 != 0){
        int r = 0;
        for(int i = 0; i < 26; i++){
            if(b[i] % 2){
                cout << "No" << endl;
                return 0;
            }
            if(b[i] % 4) r++;
        }
        if(r <= h / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if(h % 2 != 0 && w % 2 == 0){
        int r = 0;
        for(int i = 0; i < 26; i++){
            if(b[i] % 2){
                cout << "No" << endl;
                return 0;
            }
            if(b[i] % 4) r++;
        }
        if(r <= w / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if(h % 2 != 0 && w % 2 != 0){
        int r = 0, s = 0;
        for(int i = 0; i < 26; i++){
            if(b[i] % 2) s++;
            else if(b[i] % 4) r++;
        }
        if(s <= 1 && r <= h / 2 + w / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    string s,t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;

    if(s == u)a--;
    else b--;

    cout << a << " " << b << endl;

}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toInt)
  val s = readLine.map(_ == '0')
  val memo = new Array[Int](n + 1)

  def step(i: Int): Boolean = {
    if (i > n) true
    else if (!s(i)) step(i + 1)
    else {
      (m to 1 by -1).find{p => s(i - p)} match {
        case None => false
        case Some(p) =>
          memo(i) = p
          step(i + 1)
      }
    }
  }

  def collect(pos: Int, l: List[Int]): List[Int] = {
    if (pos == 0) l
    else {
      val i = memo(pos)
      collect(pos - i, i :: l)
    }
  }

  println(
    if (m >= n) n
    else {
      (1 to m).foreach {i =>
        if (s(i)) memo(i) = i
      }
      if (step(m + 1)) {
        collect(n, Nil).mkString(" ")
      } else -1
    }
  )
}

Measured memory_bytes: 40864
s = input()

from itertools import combinations
from collections import Counter

def split(s, pivot):
    split_ary = []
    st = 0
    for p in pivot:
        split_ary.append(s[st:p])
        st = p
    split_ary.append(s[st:])
    return split_ary

sub_ary = []
N = len(s)
for i in range(N):
    for sep_idx in combinations(range(1,N), i):
        sub_ary.extend(split(s, sep_idx))

c = Counter(sub_ary)
ans = 0
for k,cnt in c.items():
    ans += int(k) * cnt

print(ans)

Measured memory_bytes: 9500
N = int(input())
L = list(map(int, input().split()))
M = sorted(L)
medi1 = M[N//2-1]
medi2 = M[N//2]
#print(medi1,medi2)
for x in L:
    if x <= medi1:
        ans = medi2
    else:
        ans = medi1
    print(ans)


Measured memory_bytes: 93780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define mod 1000000007
int n,m,a[105];
int main(){
	cin >> n >> m;
	int x = 0;
	vector<int>vi,vi2;
	for(int i=1;i<=m;i++){
		cin >> a[i];
		x += (a[i]%2);
		if(a[i]%2==1) vi.pb(a[i]);
		else vi2.pb(a[i]);
	}
	int nxt = 1;
	for(int i=0;i<min(1,(int)vi.size());i++) a[nxt++] = vi[i];
	for(int i=0;i<vi2.size();i++) a[nxt++] = vi2[i];
	for(int i=1;i<vi.size();i++) a[nxt++] = vi[i];
	if(m==1){
	    if(n==1) puts("1\n1\n1");
		else cout << a[1] << endl << 2 << endl << a[1]-1 << endl << 1 << endl; return 0;
	}
	if(x >= 3){
		puts("Impossible"); return 0;
	}
	for(int i=1;i<=m;i++) cout << a[i] << (i==m?'\n':' ');
	if(x == 0){
		cout << m << endl;
		for(int i=1;i<=m;i++){
			int b;
			if(i==1) b = -1;
			else if(i==m) b = 1;
			else b = 0;
			cout << a[i]+b << endl;
		}
	}
	else if(x == 1){
		cout << m << endl;
		for(int i=1;i<=m;i++){
			int b;
			if(i==1) b = 1;
			else if(i==m) b = -1;
			else b = 0;
			cout << a[i]+b << endl;
		}
	}
	else{
		cout << (a[m]==1?m-1:m) << endl;
		for(int i=1;i<=m;i++){
			int b;
			if(i==1) b = 1;
			else if(i==m) b = -1;
			else b = 0;
			if(a[i]+b==0) break;
			cout << a[i]+b << endl;
		}
	}
}

Measured memory_bytes: 256
//
// Created by misclicked on 2020/3/14.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

#define ONLINE_JUDGE
#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#else
    ios_base::sync_with_stdio(false);
    cin.tie();
#endif
    vector<int> vec(
            {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51});
    int n;
    cin >> n;
    cout << vec[n - 1] << endl;
}

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

void dfs(vector<int> g[],int vis[],int dp[],int u)
{
	vis[u]=1;
	int maxx=0;

	for(int i=0;i<g[u].size();i++)
	{
		if(!vis[g[u][i]])
		{
			dfs(g,vis,dp,g[u][i]);
			maxx=max(maxx,1+dp[g[u][i]]);
		}
		else
		{
			maxx=max(maxx,1+dp[g[u][i]]);
		}
	}

	dp[u]=maxx;
}

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

	vector<int> g[n+1];
	int vis[n+1];
	int dp[n+1];

	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
	}

	// for(int i=1;i<=n;i++)
	// {
	// 	cout<<i<<" : ";
	// 	for(int j=0;j<g[i].size();j++)
	// 	{
	// 		cout<<g[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	for(int i=1;i<=n;i++)
	{
		vis[i]=0;
		dp[i]=-1;
	}

	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			dfs(g,vis,dp,i);
	}

	int maxx=0;
	for(int i=1;i<=n;i++)
	{
		//cout<<dp[i]<<" ";
		if(dp[i]>maxx)
		{
			maxx=dp[i];
		}
	}
	//cout<<endl;
	cout<<maxx<<endl;
	return 0;
}

Measured memory_bytes: 9856