akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline bool Checkmax( R &A , R B ) { return A < B ? A = B , 1 : 0 ; }
template < class R > inline bool Checkmin( R &A , R B ) { return A > B ? A = B , 1 : 0 ; }
char X[200006] , Stack[200006] ;
int N , Top ;
int main() {
	scanf( "%s" , X + 1 ) ;
	N = strlen( X + 1 ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		if( X[i] == 'S' ) Stack[++Top] = 'S' ;
		else {
			if( Top and Stack[Top] == 'S' ) --Top ;
			else Stack[++Top] = 'T' ;
		}
	}
	return not printf( "%d\n" , Top ) ;
}

Measured memory_bytes: 640
n = int(input())
an = map(int, input().split())
num = 1
max = 10**18
for i in an:
    if num < max:
         num *= i
    if (i == 0):
        num = 0
        break
    
if num > 10**18:
    print(-1)
else:
    print(num)

Measured memory_bytes: 19496
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>V(N);
    for(int i=0;i<N;i++)cin>>V[i];
    vector<int>C(N);
    for(int i=0;i<N;i++)cin>>C[i];
    int ans=0;
     for(int i=0;i<N;i++){
        if(V[i]>C[i]){
        ans+=V[i]-C[i];
        }
     }
     cout<<ans<<endl;
}

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

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

    int i;
    i = 1;
    while (true) {
        if (X * i >= N) {
            cout << (i * T) << endl;
            break;
        } else {
            i++;
        }
    }    
}

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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

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 N, M;
    COMinit();
    cin >> N >> M;
    auto vec = prime_factorize(M);
    long long res = 1;
    for (auto pa : vec) {
        int num = pa.second;
        long long tmp = COM(num+N-1, N-1);
        res = (res * tmp) % MOD;
    }
    cout << res << endl;
}          


Measured memory_bytes: 5120
#pragma comment(linker, "/STACK:640000000")
#include <bits/stdc++.h>

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);

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

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

	ll res = 0;

	for (int b = k + 1; b <= n; b++) {
		res += n / b * 1LL * (b - k);
		res += max(n % b - k + 1, 0);
	}

	if (k == 0) res -= n - k;

	cout << res << endl;

	return 0;
}

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

typedef struct UnionFind{
  int *parent;
  int n;
} UnionFind;

UnionFind* newUnionFind(int n){
  UnionFind *u=(UnionFind *)calloc(1,sizeof(UnionFind));
  u->parent=(int *)calloc(n,sizeof(int));
  u->n=n;
  for(int i=0;i<n;i++) u->parent[i]=-1;
  return u;
}

int root(UnionFind *u,int x){
  if(u->parent[x]<0) return x;
  return u->parent[x]=root(u,u->parent[x]);
}

int same(UnionFind *u,int x,int y){
  return root(u,x)==root(u,y);
}

int getSize(UnionFind *u,int x){
  return -u->parent[root(u,x)];
}

void unite(UnionFind *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  if(u->parent[x]>u->parent[y]){
    int swap=x;
    x=y;
    y=swap;
  }
  u->parent[x]+=u->parent[y];
  u->parent[y]=x;
}

typedef long long int int64;

typedef struct edge{
  int a,b,c;
} edge;

int cmp(const void *a,const void *b){
  return ((edge *)a)->c-((edge *)b)->c;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  edge *e=(edge *)calloc(m,sizeof(edge));
  int i;
  for(i=0;i<m;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a--;b--;
    e[i]=(edge){a,b,c};
  }
  qsort(e,m,sizeof(edge),cmp);
  UnionFind *u=newUnionFind(n);
  int *sub=(int *)calloc(n*n,sizeof(int));
  int *a=(int *)calloc(n,sizeof(int));
  int *b=(int *)calloc(n,sizeof(int));
  int64 sum=0;
  for(i=0;i<m;i++){
    if(same(u,e[i].a,e[i].b)) continue;
    int alen=0;
    int blen=0;
    for(int j=0;j<n;j++){
      if(same(u,e[i].a,j)) a[alen++]=j;
      if(same(u,e[i].b,j)) b[blen++]=j;
    }
    for(int j=0;j<alen;j++){
      for(int k=0;k<blen;k++){
	int v=a[j];
	int u=b[k];
	sub[v*n+u]=e[i].c;
	sub[u*n+v]=e[i].c;
      }
    }
    sum+=e[i].c;
    unite(u,e[i].a,e[i].b);
  }
  int q;
  scanf("%d",&q);
  while(q--){
    int s,t;
    scanf("%d%d",&s,&t);
    s--;t--;
    printf("%lld\n",sum-sub[s*n+t]);
  }
}

int main(void){
  run();
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int f(int n){
  if(n==0)return 0;

  int t = __builtin_popcount(n);
  return f(n%t)+1;
}

int main(){
  int n;cin>>n;
  string s;cin>>s;
  vector<int> a(n);

  rep(i, n)a[i]=s[i]-'0';
  int pc=0;
  for(auto i: a)if(i)pc++;

  int sum1=0;
  int c1=1;
  if(pc-1!=0){
    rrep(i, n){
      if(a[i]) sum1 = (sum1+c1)%(pc-1);
      c1 = c1*2%(pc-1);
    }
  }

  int sum0=0;
  int c0=1;
  rrep(i, n){
    if(a[i]) sum0 = (sum0+c0)%(pc+1);
    c0 = c0*2%(pc+1);
  }

  vector<int>pow1(n);
  pow1[n-1] = 1;
  if(pc-1!=0){
    rrep(i, n-1)pow1[i] = 2*pow1[i+1]%(pc-1);
  }

  vector<int>pow0(n);
  pow0[n-1]=1;
  rrep(i, n-1)pow0[i] = 2*pow0[i+1]%(pc+1);

  rep(i, n){
    if(a[i]){
      if(pc==1)cout<<0<<endl;
      else cout<<f( (sum1-pow1[i]+pc-1)%(pc-1) )+1<<endl;
    }else{
      cout<<f( (sum0+pow0[i]+pc+1)%(pc+1) )+1<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 6000
h,w,m=map(int, input().split())
hw=[list(map(int, input().split())) for _ in range(m)]

y_list=[0]*h
x_list=[0]*w

for h_i, w_i in hw:
    y_list[h_i-1]+=1
    x_list[w_i-1]+=1

my_cnt=max(y_list)
mx_cnt=max(x_list)

y_cnt=0
x_cnt=0

my_set=set()
mx_set=set()

for h_i, w_i in hw:
    if y_list[h_i-1]==my_cnt:
        my_set.add(h_i-1)
    if x_list[w_i-1]==mx_cnt:
        mx_set.add(w_i-1)

cnt=0
for h_i, w_i in hw:
    if y_list[h_i-1]==my_cnt and x_list[w_i-1]==mx_cnt:
        cnt+=1

print(my_cnt+mx_cnt-1 if cnt==len(my_set)*len(mx_set) else my_cnt+mx_cnt)


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


int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    int cntr = 0;
    int k = 1;
    for(int i=0; i<n; i++){
        if(arr[i] == k){
            cntr++;
            k++;
        }
    }
    if(cntr == 0)
        cout << "-1";
    else   
        cout << n-cntr;
}

Measured memory_bytes: 1024
import java.util.Scanner

val sc = Scanner(System.`in`)
val a = sc.nextInt()
val b = sc.nextInt()
val c = sc.nextInt()
val d = sc.nextInt()
val e = sc.nextInt()
val k = sc.nextInt()

fun main(args: Array<String>) {
    val ary = arrayListOf(a,b,c,d,e)
    val min = ary.min()
    val max = ary.max()

    print(if (k >= max!! - min!!) "Yay!" else ":(")
}

Measured memory_bytes: 31384
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int n;
    cin >> n;
    int a,b,c;
    c = n%10;
    if(c == 1)c = 9;
    else if(c == 9)c = 1;  
    n /= 10;
    
    b = n%10;
    if(b == 1)b = 9;
    else if(b == 9)b = 1;
    n /= 10;

    a = n%10;
    if(a == 1)a = 9;
    else if(a == 9)a = 1;

    int ans = a*100 + b* 10 + c;
    cout << ans << endl;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  int t[n];
  rep(i,n) cin >> t[i];
  int m;cin >> m;

  rep(i,m){
    int p,x;cin >> p >> x;
    int ans = 0;
    rep(i,n){
      ans+=(i==p-1?x:t[i]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;

const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
	int r;cin >>r;
	double ans = 2 * 3.14 * r;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3788
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int a[M+3];
int pre[M+3];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        pre[i]=ad(bigmod(i,mod-2),pre[i-1]);
    }
    int ex=0;
    f(i,1,n)
    {
        int dan=n-i+1;
        int prb=sub(ad(pre[i],pre[dan]),1);
        ex=ad(ex,gun(a[i],prb));
    }
    f(i,1,n)
    {
        ex=gun(ex,i);
    }
    cout<<ex<<endl;
    return 0;

}













Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=3000+5,mod=1e9+7;
typedef long long ll;
ll n,arr[N],dp[N][N][3];

ll solve(int i=1,int j=n,bool f=0)
{
    if(i>j)
        return 0;
    ll &ret=dp[i][j][f];
    if(~ret)
        return ret;
    if(f==0){
        ret=arr[i]+solve(i+1,j,1);
        ret=max(ret,arr[j]+solve(i,j-1,1));
    }
    else{
        ret=-arr[i]+solve(i+1,j,0);
        ret=min(ret,-arr[j]+solve(i,j-1,0));
    }
    return ret;
}
int main()
{
    Elhabashy
    input();
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    cout<<solve()<<endl;

}



Measured memory_bytes: 215548
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            var t = a[i] - 1;
            ans += b[t];
            if (i > 0)
            {
                var p = a[i - 1] - 1;
                if (t - p == 1)
                {
                    ans += c[p];
                }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

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

    int n,m,k;
    cin>>n>>m>>k;
    
    UnionFind uf(n);
    map<int,int> mp;

    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
        mp[a]++;
        mp[b]++;
    }

    rep(i,k){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(uf.find(a)==uf.find(b)){
            mp[a]++;
            mp[b]++;
        }
    }

    rep(i,n){
        if(i) cout<<' ';
        cout<<uf.size(i)-mp[i]-1;
    }
    cout<<endl;


}

Measured memory_bytes: 7936
S = list(input())
N = len(S)

cnt = 0
Ans = 0
for i in range(N):
    if S[i] == "A" or S[i] == "T" or S[i] == "G" or S[i] == "C":
        cnt += 1
        Ans = max(Ans, cnt)
    else:
        Ans = max(Ans, cnt)
        cnt = 0
print(Ans)

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
 int n,m;
  cin>>n>>m;
  int sum=0;
  for(int i=n-1;i>=1;i--)sum+=i;
  for(int i=m-1;i>=0;i--)sum+=i;
  cout<<sum;
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

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

    if (s.substr(0, 2) <= "12" && s.substr(0, 2) >= "01" && s.substr(2, 2) <= "12" && s.substr(2, 2) >= "01") cout << "AMBIGUOUS" << endl;
    else if (s.substr(2, 2) <= "12" && s.substr(2, 2) >= "01") cout << "YYMM" << endl;
    else if (s.substr(0, 2) <= "12" && s.substr(0, 2) >= "01") cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int i, x, a, b, c;
   cin>>x;
   a = x/500;
   b = (x%500)/5;
   c = (a*1000)+(b*5);
   cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535


int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    ll ans = 1;
    ll temp = g;
    for(ll i = 2; i * i <= temp; i++){
        if(g % i == 0){
            ans++;
            while(g % i == 0){
                g /= i;
            }
        }
    }
    if(g != 1) ans++;
    cout << ans << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}
int n;
vector<vector<int>> a;
vector<int> dp1;
vector<int> dp2;
int go2(int,int);
int go1(int p,int x){
	if(dp1[x]!=-1)return dp1[x];
	int ans=1;
	for(int v:a[x]){
		if(v==p)continue;
		ans=mul(ans,go2(x,v));
	}
	return dp1[x]=ans;
}
int go2(int p,int x){
	if(dp2[x]!=-1)return dp2[x];
	int ans=1;

	for(int v:a[x]){
		if(v==p)continue;
		int tmp=add(go1(x,v),go2(x,v));
		ans=mul(ans,tmp);
	}

	return dp2[x]=ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	a.assign(n,vector<int>());
	dp1.assign(n,-1);
	dp2.assign(n,-1);
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	int ans=0;
	cout<<add(go1(-1,0),go2(-1,0))<<endl;
}


Measured memory_bytes: 13440
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int B[N-1];
    for(int i = 0; i <N-1;i++)cin >> B[i];
    B[N-1]=0;
    int sum=0;
    for(int i = -1; i <N;i++){
        if(i==-1){
            sum+=B[0];
        }else if(i==N-1){ 
            //cout <<N-2<<" "<<B[N-2]<<endl;
            sum +=B[N-2];
        }else{
            //cout << B[i]<<" "<<B[i+1]<<endl;
            sum += min(B[i],B[i+1]);
        }
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ps(x) printf("%s", x)
#define sd(n) scanf("%d",&n) == 0

int main() {
	int x, a, b;
	sd(x), sd(a), sd(b);
	int xa = abs(x - a);
	int xb = abs(x - b);
	if (xa > xb) ps("B\n");
	else ps("A\n");

}

Measured memory_bytes: 256
n = gets.to_i
v = gets.split.map(&:to_i)

ev = []
ov = []

n.times do |i|
	if i.even?
		ev << v[i]
	else
		ov << v[i]
	end
end

e = {}
o = {}

ev.size.times do |i|
  e[ev[i]] = (e[ev[i]] || 0) + 1
  o[ov[i]] = (o[ov[i]] || 0) + 1
end

e = e.sort_by {|k, v| -v}
o = o.sort_by {|k, v| -v}

e1 = e.shift
e2 = (e.shift || 0)
o1 = o.shift
o2 = (o.shift || 0)


if e1[0] == o1[0]
	puts n - [(e1[1] + o2[1]), (e2[1] + o1[1])].max
else
	puts n - (e1[1] + o1[1])
end


Measured memory_bytes: 21128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int K =sc.nextInt();
    if(N<=K){System.out.println(0);}
    else{
    long M[] =new long[N];
    for(int i=0;i<N;i++){
      M[i]=sc.nextLong();}
    Arrays.sort(M);
    long x=0;
    for(int j=0;j<N-K;j++){
      x=x+M[j];}
    System.out.println(x);}
  }
}

Measured memory_bytes: 64816
#include <stdio.h>
#include <stdlib.h>
#define inf 10e18
typedef long long ll;
 
int main(void) {
  ll i, j, k, n, m;
  scanf("%lld%lld%lld", &n, &m, &k);
  ll a[n], **sum, dp[n];
  sum = (ll**)malloc(sizeof(ll*) * (n + 10));
  for(i = 0; i < n; ++i) sum[i] = (ll*)malloc(sizeof(ll) * (m + 10));
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) dp[i] = inf;
  dp[0] = k;
  for(i = 0; i < n; ++i) {
    ll min = inf, max = 0;
    for(j = 0; j < m; ++j) {
      if(i - j >= 0) {
        if(min > a[i - j]) min = a[i - j];
        if(max < a[i - j]) max = a[i - j];
        sum[i][j] = k + (j + 1) * (max - min);
      }
    }
  }
  for(i = 1; i < n; ++i) {
    for(j = 0; j < m; ++j) {
      if(i - j > 0) {
        if(dp[i] > sum[i][j] + dp[i - j - 1]) dp[i] = sum[i][j] + dp[i - j - 1];
      } else if(!(i - j)) {
        if(dp[i] > sum[i][j]) dp[i] = sum[i][j];
      }
    }
  }
  printf("%lld\n", dp[n - 1]);
  for(i = 0; i < n; ++i) free(sum[i]);
  free(sum);
  return 0;
}


Measured memory_bytes: 159892
import fractions
a, b, c, d = map(int, input().split())
lcm = c*d//fractions.gcd(c,d)

def cnt_val(n):
    cdiv = n // c
    ddiv = n // d
    ldiv = n // lcm
    return n - cdiv - ddiv + ldiv

print(cnt_val(b) - cnt_val(a-1))

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

int main(){
    long long int x, y;
    cin >> x >> y;
    
    int cnt = 0;
    long long int start = x;
    long long int tmp = x;
    while(true){
        if(start > y){
            break;
        }
        start += tmp;
        if(start % x == 0){
            cnt++;
            tmp = start;
            //cout << "start:" << start << endl; 
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
const int maxn=3000+10;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int mod=1e9+7;
int dp[maxn][maxn][2];
int main(){
	int n=read(),m=read();
	dp[0][0][1]=1;
	REP(i,1,n) dp[0][i][0]=1;
	REP(i,1,m)
		REP(j,0,n)
			REP(k,0,1){
				if(j){
					dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-1][k])%mod;
					dp[i][j][k|(j==1)]=(dp[i][j][k|(j==1)]+dp[i-1][j][k])%mod;
				}
				if(j<n){
					dp[i][j][k|(j==0)]=(dp[i][j][k|(j==0)]+dp[i-1][j+1][k])%mod;
					dp[i][j][k]=(dp[i][j][k]+dp[i-1][j][k])%mod;
				}
			}
	int ans=0;
	REP(i,0,n) ans=(ans+dp[m][i][1])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=std::vector<ll>;
using VC=std::vector<char>;
using VB=std::vector<bool>;
using VD=std::vector<ld>;
using VVI=std::vector<VI>;
using VVC=std::vector<VC>;
using VS=std::vector<string>;
using PLL =std::pair<ll,ll>;
using PLD=std::pair<ld,ld>;
using VPLL=std::vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).std::rbegin(),(x).std::rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *std::max_element((x).begin(),(x).std::end())
#define MIN(x) *std::min_element((x).begin(),(x).std::end())
#define SORTR(x) std::sort((x).std::rbegin(),(x).std::rend())
#define SORT(x) std::sort((x).begin(),(x).std::end())
#define SUM(x) std::accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) std::fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).std::begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


ll dfs(VB visited,VVI ab,ll s=0){
	visited[s]=true;
	if(!EXIST(visited,false)) return 1;
	ll ret=0;
	for(auto &v:ab[s]){
		if(visited[v]) continue;
		else{
			ret+=dfs(visited,ab,v);
		}
	}
	return ret;
}

void Main()
{
	ll n, m, l;
	ll res = 0;
	string s, t, u;
	string sres = "No or NO";

	cin >> n>>m;
	VVI ab(n);
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		ab[a].emplace_back(b);
		ab[b].emplace_back(a);
	}
	VB visited(n,false);
	res=dfs(visited,ab);
	print(res);
	return;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
        List<Integer> list = Arrays.asList(sc.nextInt(), sc.nextInt(), sc.nextInt());
        Collections.sort(list);
        
		// 出力
		System.out.println(list.get(2) * 10 + list.get(1) + list.get(0));
	}
}


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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

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

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int maxn = 1e5 + 10;

int dp[maxn];
vector<int> a;
int n, k;

int gen(int x) {
    if (dp[x] != -1) return (dp[x] ^ 1);
    dp[x] = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > x) break;
        dp[x] |= gen(x - a[i]);
    }
    return (dp[x] ^ 1);
}

void solve() {
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0] = 0;
    gen(k);
    if (dp[k]) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
}

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

    solve();

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	int h, w; cin >> h >> w;
	bool a[8][8] = {};
	rep(i, h)rep(j, w) {
		char ch; cin >> ch;
		if (ch == '#') a[j][i] = true;
	}
	int x = 0, y = 0;
	a[0][0] = false;
	while (x < w - 1 || y < h - 1) {
		if (x < w - 1) {
			if (a[x + 1][y]) {
				x++; a[x][y] = false; continue;
			}
		}
		if (y < h - 1) {
			if (a[x][y + 1]) {
				y++; a[x][y] = false; continue;
			}
		}
		cout << "Impossible" << endl; return;
	}
	rep(i, h)rep(j, w) {
		if (a[j][i]) { cout << "Impossible" << endl; return; }
	}
	cout << "Possible" << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<pair<int, int> > df;
	for(int i = 0 ; i < n; i++){
		int x, l;
		cin >> x >> l;
		df.pb(mp(x + l, x - l));
	}
	sort(df.begin(), df.end());
	int curr = -2 * 1e9;
	int ans = 0;
	for(int i = 0; i < df.size(); i++){
		if(df[i].second >= curr){
			curr = df[i].first;
			ans++;
		}
	}
	cout << ans << '\n';


}

Measured memory_bytes: 1400
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *p = new int[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];

	int min = p[0];
	int max = -1000000000;
	for (int j = 1; j < n; j++)
	{
		if (p[j] - min > max)max = p[j] - min;
		if (p[j] < min)min = p[j];
	}

	cout << max<<endl;
    return 0;
}


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

int main()
{
	const int a[] = {1, 5, 10, 50, 100, 500};
	int b = 0;
	for (int i = 0; i < 6; i++){
		int c;
		scanf("%d", &c);
		c += b / a[i];
		b = c * a[i];
	}
	printf("%d\n", !!(b / 1000));
	
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q

#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();
    ll int n,m,a,b,res=0;
    cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)

// *start on @date: 2020-02-22 20:23

ll dx[] = {0, 0, 1, -1};
ll dy[] = {1, -1, 0, 0};

int main()
{
    IOS;
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int t;
    while(n)
    {
        n/=k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	bound := 1
	distanse := 0
	for i := 0; i < n; i++ {
		var l int
		fmt.Scan(&l)
		distanse += l
		if distanse <= x {
			bound++
			continue
		} else {
			break
		}
	}
	fmt.Println(bound)
}


Measured memory_bytes: 512
n = input().split()
N = int(n[0])
M = int(n[1])

x = input().split()
X = [int(l) for l in x]
X.sort()

X_diff = []
for i in range(M-1):
    tmp = X[i+1] - X[i]
    X_diff.append(tmp)

X_diff.sort(reverse=True)

result = 0
for i in range((N-1), M-1, 1):
    result += int(X_diff[i])

print(result)

Measured memory_bytes: 14608
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]

lines=[set(x) for x in a]+[set(x) for x in zip(*a)]+[set([a[0][0],a[1][1],a[2][2]])]+[set([a[0][2],a[1][1],a[2][0]])]
# zip()是压缩，zip(*)解压缩
bs=set(b)
if any(line.issubset(bs) for line in lines):#any（）函数：有一个满足即为真 s.issubset(a)判断a是否在s中 issubset() 方法用于判断集合的所有元素是否都包含在指定集合中，如果是则返回 True，否则返回 False。
    print("Yes")
else:
    print("No")





Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int k,x;
    cin >> k >> x;
    FOR(i, x- k + 1, k + x){
        cout << i << " ";
    }
    cout << endl;

}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int apoint = 0;
	int bpoint = 0;
	for(int i = 0; i < 4; i++)
	{
		apoint += in();
	}
	for(int i = 0; i < 4; i++)
	{
		bpoint += in();
	}
	printf("%d\n", max(apoint, bpoint));
	return (0);
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
stack<char>st,st1;
int main()
{
    char ch[20];
    scanf("%s",ch);
    for(int i=0;ch[i];i++){
        if(ch[i]=='B'){
            if(!st.empty()) st.pop();
        }
        else    st.push(ch[i]);
    }
    while(!st.empty()){
        st1.push(st.top()),st.pop();
    }
    while(!st1.empty())  cout<<st1.top(),st1.pop();
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

bool cnv(ll num){
  string ans = "";
  while(num > 0){
    ans += (num % 10) + '0';
    num /= 10;
  }
  bool f = true;
  rep(i,0,ans.sz/2)if(ans[i] != ans[ans.sz-i-1])f = false;
  return f;
}

int main(){
  cin >> n >> m;
  l = 0;
  lep(i,n,m){
    if(cnv(i))l++;
  }
  print(l);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
    int s1,s2,s3;
    cin>>a>>b>>c;
	s1=a+b;
	s2=a+c;
	s3=b+c;
	if(s1==c||s2==b||s3==a)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main(void) {
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for(int i=0; i<N; i++) {
        for(int k=0; k<D; k++) {
            cin >> X[i][k];
        }
    }
    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            double d = 0.0;
            for(int k=0; k<D; k++) {
                d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            d = sqrt(d);
            if(d - (int)d <= 0.000001) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your code here Tanmay:)
	string s;
	cin>>s;
	bool flag=true;
	for(int i=0;i<s.size();i++)
	{
		flag=true;
		if(i%2==0)
		{
			if(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D')
				flag=false;
		}
		else
		{
			if(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D')
				flag=false;
		}
		if(flag==true)
			break;

	}
	if(flag==false)
		cout<<"Yes";
	else
		cout<<"No";
	
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
  
    // extract current character from buffer 
    c = getchar(); 
    if (c=='-') 
    { 
        // number is negative 
        negative = true; 
  
        // extract the next character from the buffer 
        c = getchar(); 
    } 
  
    // Keep on extracting characters if they are integers 
    // i.e ASCII Value lies from '0'(48) to '9' (57) 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
  
    // if scanned input has a negative sign, negate the 
    // value of the input number 
    if (negative) 
        number *= -1; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
bool chmin(T &a,T b){
    if(a<=b)return 0;
    a=b;
    return 1;
}

class dijekstra{
public:
    struct edge{int v, dist;};
    struct state{
        int v,cost;
        bool operator>(const state s) const { return cost>s.cost;}
    };
    const int INF = 1e9+7;
    int N;
    vector<vector<edge>> E;

    dijekstra(int n): N(n),E(n){}

    void add_edge(int u,int v,int d){
        E[u].push_back((edge){v,d});
        // E[v].push_back((edge){u,d});
    }

    vector<int> sp(int s){
        vector<int> dp(E.size(),INF);
        priority_queue<state,vector<state>,greater<state>> q;
        q.push((state){s,0});
        while(q.size()){
            int v=q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i<E[v].size();i++){
                int nv = E[v][i].v, ncost = cost+E[v][i].dist;
                if(dp[nv] > ncost)q.push((state){nv,ncost});
            }
        }
        return dp;
    }
};

vector<vector<array<int,4>>> v;

signed main(){
    //ofstream cout("out.txt");

    int n,m,h,k;
    while(cin>>n>>m>>h>>k){
        if(n==0)break;
        h++;
        v = vector<vector<array<int,4>>>(n);
        for(int i=0;i<m;i++){
            int a,b,c,d,r;
            cin>>a>>b>>c>>d>>r;
            a--,b--,r--;
            v[a].push_back({b,c,d,r});
            v[b].push_back({a,c,d,r});
        }
        int ss,tt,p;
        cin>>ss>>tt>>p;
        ss--,tt--;
        vector<int> ps(p);
        int d[p];
        for(int i=0;i<p;i++){
            int l;
            cin>>l>>d[i];
            for(int j=0;j<l;j++){
                int a;
                cin>>a;
                a--;
                ps[i] += (1<<a);
            }
        }
        int ans = 1e9+7;
        int dp[(1<<k)];
        for(int i=0;i<(1<<k);i++)dp[i] = 1e9+7;
        dp[0] = 0;
        for(int bit=0;bit<(1<<k);bit++){
            for(int i=0;i<p;i++){
                chmin(dp[bit|ps[i]], dp[bit]+d[i]);
            }
        }
        for(int bit=0;bit<(1<<k);bit++){
            if(dp[bit] > 1e9)continue;
            dijekstra dij(h*n);
            for(int i=0;i<n;i++){
                for(auto e:v[i]){
                    int to=e[0],cost=e[1],t=e[2],r=e[3];
                    if(bit&(1<<r)){
                        for(int y=0;y<h;y++){
                            if(y+t<h) dij.add_edge(i+y*n,to+(y+t)*n,0);
                            else break;
                        }
                    }
                    else{
                        for(int y=0;y<h;y++){
                            if(y+t<h) dij.add_edge(i+y*n,to+(y+t)*n,cost);
                            else break;
                        }
                    }
                }
            }

            vector<int> dist = dij.sp(ss);
            for(int i=0;i<h;i++){
                chmin(ans,dist[tt+i*n]+dp[bit]);
            }
        }
        if(ans>1e9)ans=-1;
        cout << ans << "\n";
    }
}



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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
//typedef pair<int, int> P;

vector<int> keta(int n) {
    vector<int> k(10, 0);
    while (n != 0) {
        k[n % 10]++;
        n /= 10;
    }
    return k;
}

int main() {
    vector<ll> ans(100, 0);
    ans[0] = 2;
    ans[1] = 1;

    for (int i = 2; i < 100; i++) {
        ans[i] = ans[i - 2] + ans[i - 1];
    }

    int n;
    cin >> n;
    cout << ans[n] << endl;

}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

class union_find {
private:
  vl *par;
  vl *rnk;
public:
  union_find (ll n){
    par = new vl(n);
    iota(par->begin(),par->end(),0);
    rnk = new vl(n,0);
  }
  ll find(ll x){
    if(par->at(x) == x) return x;
    else return par->at(x) = find(par->at(x));
  }
  void unite(ll x,ll y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(rnk->at(x) < rnk->at(y)) par->at(x) = y;
    else {
      par->at(y) = x;
      if(rnk->at(x) == rnk->at(y)) rnk->at(x)++;
    }
  }
  bool same(ll x,ll y){
    return find(x) == find(y);
  }
};

union_find uf(e5);

ll n,m;
unordered_set<ll> s;

int main(){
  cin >> n >> m;
  for(ll i = 0;i < m;i++){
    ll x,y,z;
    cin >> x >> y >> z;
    uf.unite(x,y);
  }
  for(ll i = 1;i <= n;i++){
    s.insert(uf.find(i));
  }
  cout << s.size() << endl;

}


Measured memory_bytes: 20772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

int n;
string t_str1, t_str2;

const int ONEDAY = 24 * 60 * 60;

int ctoi(char c) {
    return c - '0';
}

int read_time(string t_str) {
    int hh = ctoi(t_str[0]) * 10 + ctoi(t_str[1]);
    int mm = ctoi(t_str[3]) * 10 + ctoi(t_str[4]);
    int ss = ctoi(t_str[6]) * 10 + ctoi(t_str[7]);
    int t = 60 * 60 * hh + 60 * mm + ss;
    return t;
}

int main() {
    while (true) {
        cin >> n;
        if (n == 0) break;

        vector<int> time_table(ONEDAY, 0);

        REP(i, n) {
            cin >> t_str1 >> t_str2;
            int t1 = read_time(t_str1);
            int t2 = read_time(t_str2);
            time_table[t1]++;
            time_table[t2]--;
        }

        int ans = 0;
        int num_train = 0;
        REP(i, ONEDAY) {
            num_train += time_table[i];
            ans = max(ans, num_train);
        }
        PRINT(ans);
    }
    return 0;
}


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

int main(){
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	rep(i, n){
		map<char, int> m;
		int ma = 0;
		m[a.at(i)]++;
		if(m[a.at(i)] > ma) ma = m[a.at(i)];
		m[b.at(i)]++;
		if(m[b.at(i)] > ma) ma = m[b.at(i)];
		m[c.at(i)]++;
		if(m[c.at(i)] > ma) ma = m[c.at(i)];
		ans += 3 - ma;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline 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<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n,k,d,x,ans,vis[105];
int main(){
	n=read(),k=read();
	while(k--){
		d=read();
		while(d--){
			x=read();
			vis[x]=1;
		}
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]) ++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3716