akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll x;
    cin >> x;

    ll result = 0;
    result += x / 500 * 1000;
    x %= 500;
    result += x / 5 * 5;

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int count = 0;
    for(int i=0;i<n;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    long ans = 0;
    
    ans +=(long) a[n-1];
    count++;
    for(int i=n-2;i>=0;i--){
      if( count >= n -1 ){
        break;
      }
      ans +=(long) a[i];
      count++;
      if( count >= n -1 ){
        break;
      }
      ans +=(long) a[i];
      count++;
    }
    if( n == 1 ){
      ans = 0;
    }
    //ans +=(long)  1000000000 * 2 * 100000;
    System.out.println(ans);
  }
}

Measured memory_bytes: 50456
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N;
ll cnt=2;



int main(void) {
  ll i, j, k;

  string s;
  cin >> s;
  
  if(s=="ABC") pt("ARC");
  if(s=="ARC") pt("ABC");
  
}
 


Measured memory_bytes: 3596
//********************
//*@Author:  ChenShou*
//*@Language:C++11   *
//********************

#include<bits/stdc++.h>

//#pragma comment ( linker ," /STACK:102400000 , 102400000 " )
//#define DEBUG
#define RI register int 
#define endl "\n"

using namespace std ;

typedef long long ll ;
// typedef __int128 lll ;
const int N = 100000  + 10 ;
const int M = 1000000 + 10 ;
const int MOD = 1e9 + 7 ; 
const double PI = acos(-1.0) ;
const double EXP = 1E-9 ;
const int INF = 0x3f3f3f3f;

inline ll read(){
    long long 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 ;
}

ll n;

void solve(){
	n=read();
	map<ll ,ll >m;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll tmp = read();
		ans+=m[i-tmp];
		m[i+tmp]++;
	}
	cout<<ans<<endl;
	return ;
}

int main(){
#ifdef DEBUG
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
//	for(ll T=read();T;T--)
		solve();
#ifdef DEBUG
    printf("\nHellow , Mr.ChenShou\n");
    printf("\t Time cost : %lf s \n",(double)clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}


Measured memory_bytes: 26300
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  1e+6+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/************************************************************************************** *******************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, k, a[N], dp[N];


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/


/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    char c;
    cin>>c;
    if(isupper(c))cout<<"A";
    else cout<<"a";
    newl;
    
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 27060
using System;

class Program
    {
        static void Main()
        {
            while (true)
            {
                int[] num = TypeConverter.arrayStrToInt(Console.ReadLine().Split(' '));

                if (num[0] == -1 && num[1] == -1 && num[2] == -1)
                    break;
                else if (num[0] == -1 || num[1] == -1)
                    Console.WriteLine("F");
                else if (num[0] + num[1] >= 80)
                    Console.WriteLine("A");
                else if (80 > num[0] + num[1] && num[0] + num[1] >= 65)
                    Console.WriteLine("B");
                else if (65 > num[0] + num[1] && num[0] + num[1] >= 50)
                    Console.WriteLine("C");
                else if (50 > num[0] + num[1] && num[0] + num[1] >= 30)
                    if (num[2] >= 50)
                        Console.WriteLine("C");
                    else
                        Console.WriteLine("D");
                else if (30 > num[0] + num[1])
                    Console.WriteLine("F");
            }
        }
    }

class TypeConverter
    {
        static public int[] arrayStrToInt(string[] str)
        {
            return Array.ConvertAll<string, int>(str,
                delegate(string value)
                {
                    return int.Parse(value);
                }
            );
        }

        static public string[] arrayIntToStr(int[] x)
        {
            return Array.ConvertAll<int, string>(x,
                delegate(int value)
                {
                    return value.ToString();
                }
            );
        }
    }

Measured memory_bytes: 5328
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[210];

int main(){
	cin >> n; int c=0;
	REP(i,0,n) cin >> a[i],c+=a[i]%2;
	
	int i=0;
	while(!c){
		c=0;
		REP(i,0,n) a[i]/=2, c+=a[i]%2;
		i++;
	}
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;

template <class T> void multiple_transform(::std::vector<T> &a) {
    int n = a.size();
    ::std::vector<bool> sieve(n, true);
    for (int p = 2; p < n; ++p) {
        if (sieve[p]) {
            for (int k = (n - 1) / p; k != 0; --k) {
                sieve[k * p] = false;
                a[k] = (a[k] + a[k * p])%mod;
            }
        }
    }
    for (int i = 0; ++i != n;) {
        a[i] = (a[i] + a[0])%mod;
    }
}

template <class T> void inverse_multiple_transform(::std::vector<T> &a) {
    int n = a.size();
    ::std::vector<bool> sieve(n, true);
    for (int i = 0; ++i != n;) {
        a[i] = (a[i] - a[0] + mod)%mod;
    }
    for (int p = 2; p < n; ++p) {
        if (sieve[p]) {
            for (int k = 1; k * p < n; ++k) {
                sieve[k * p] = false;
                a[k] = (a[k] - a[k * p] + mod)%mod;
            }
        }
    }
}

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

int main(){
    int n;cin >> n;
    vector<LL> a(1000001,0),A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        a[A[i]] += A[i];
    }
    multiple_transform(a);
    for (int i = 1; i <= 1000000; i++) {
        a[i] = a[i] * a[i];
    }
    inverse_multiple_transform(a);
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        a[A[i]] = (a[A[i]] + mod - (A[i] * A[i] %mod)) %mod;
    }
    for (int i = 1; i <= 1000000; i++) {
        ans = (ans + a[i] * fpow(2*i,mod-2))%mod;
    }
    cout << ans << endl;
    return 0;
}



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

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

  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }

  for(int i = n - 1; i > 0; i--){
    cout << data.at(i) << ' ';
  }
  cout << data.at(0) << endl;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main(void){
  int p,q,r,s;
  scanf("%d %d %d",&p,&q,&r);
  if(p+q>q+r){
    s = q+r;
  }
  else{
    s = p+q;
  }
  if(s>p+r){
    s=p+r;
  }
  printf("%d\n",s);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int G() {
	int o=0;bool f=0;char t=getchar();
	while(t<48||t>57) f|=t=='-',t=getchar();
	while(t>47&&t<58) o=(o<<1)+(o<<3)+t-48,t=getchar();
	return f?-o:o;
}
int n,p,i,a,A[2];
long long ans,t;
int main() {
	cin>>n>>p;t=1; 
	for(i=1;i<=n;i++)
	cin>>a,A[a&1]++;i=0;
	while(A[1]>=0) {
		i++;
		if((A[1]&1)==p) ans+=t;
		t*=A[1]--;t/=i; 
	} i=0;	
	while(A[0]) ans*=2,A[0]--;
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int i,mark,a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(i=1,mark=0;i<=10000;i++)
	{
		if(a*i%b==c) mark=1;
	}
	if(mark==1) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(ALL(d));
  cout << d[n / 2 ] - d[n / 2 - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n;
  int64 ans=0;
  cin>>n;
  int64 a[n],sum[n+1];
  sum[0]=0;
  rep(i,n){
    cin>>a[i];
  }
  rep1(i,n+1){
    sum[i]=a[i-1]+sum[i-1];
  }
  map<int64,int64> mp;
  rep(i,n+1){
    mp[sum[i]]++;
  }
  for(auto p: mp){
    ans+=p.second*(p.second-1)/2;
  }
  cout<<ans;
}


Measured memory_bytes: 15872
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    w,h,N=mis()
    s,t=0,0
    for i in range(N):
        x,y,a=mis()
        if a==1 and s<x: s=x
        elif a==2 and w>x: w=x
        elif a==3 and t<y: t=y
        elif a==4 and h>y: h=y
    print(0 if h-t<=0 or w-s<=0 else (h-t)*(w-s))



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(read())
for i in range(1, 3501):
    for h in range(i, 3501):
        check = 4 * i * h - n * (i + h)
        if check > 0:
            v = n * i * h
            if v % check == 0:
                print(i, h, v // check)
                exit()


Measured memory_bytes: 3060
import collections

n = int(input())
v_list = list(map(int, input().split()))

v_list_1 = []
v_list_2 = []

for i in range(0,n//2):
    v_list_1.append(v_list[2*i])
    v_list_2.append(v_list[2*i+1])

v_1_c = collections.Counter(v_list_1)
v_2_c = collections.Counter(v_list_2)
v_1_cnt = v_1_c.most_common()[::-1]
v_2_cnt = v_2_c.most_common()[::-1]
ans = 0

ans_1_1 = n//2 -v_1_cnt[-1][1]
ans_2_1 = n//2 -v_2_cnt[-1][1]
if len(v_1_cnt) == 1 and len(v_2_cnt) == 1:
    if v_1_cnt[-1][0] != v_2_cnt[-1][0]:
        ans = 0
    else:
        ans = n//2
else:
    if v_1_cnt[-1][0] != v_2_cnt[-1][0]:
        ans = ans_1_1 + ans_2_1
    else:
        ans_1_2 = n//2 -v_1_cnt[-2][1]
        ans_2_2 = n//2 -v_2_cnt[-2][1]
        ans = ans_1_1 + min(ans_1_2, ans_2_2)
#print(v_1_cnt[-1],v_1_cnt[-2],v_2_cnt[-1],v_2_cnt[-2])
print(ans)


Measured memory_bytes: 28136
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    char x, y;
    char comma;
    char current='A';
    while(cin >> x >> comma >> y)
    {
        if(x == current) swap(y, current);
        else if(y == current) swap(x, current);
    }
    cout << current << endl;
}

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

int main(){
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> p(N, 0);
  for(int i = 0; i < Q; i++){
    int a; cin >> a; p[a-1]++;
  }
  for(int i = 0; i < N; i++){
    cout << ((p[i] > Q - K)?"Yes":"No") << endl;
  }
}

Measured memory_bytes: 1024
n, y = list(map(int,input().split()))
for i in range(n + 1):
    for j in range(n -i + 1):
        if i * 10000 + j * 5000 + (n -i -j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int result = 0;
  for (int i = 1; i <= N; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= N; ++j) {
      cnt += (i % j == 0);
    }
    result += (cnt == 8);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
M=0..18
c=M.map{[0]*19}
gets
p$<.sum{|a|a=(a.to_r*10**9).to_i
i,j=[2,5].map{|c|M.find{a%c**-~_1>0}||18}
c[~i..].sum{_1[~j..].sum}+0*c[i][j]+=1}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 1010, M = 1000010;

int n, m;
int g[N][N];
int h[M], e[M], ne[M], idx;
int q[M], d[M], f[M];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int top_sort(int st)
{
	int hh = 0, tt = -1;
	q[ ++ tt] = st;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			
			if ( -- d[j] == 0)
			{
				q[ ++ tt] = j;
				f[j] = f[t] + 1;
			}
		}
	}
	
	int res = 0;
	for (int i = 1; i <= m; i ++ )
		if (!f[i]) return -1;
		else res = max(res, f[i]);
	return res;
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ )
		for (int j = i + 1; j <= n; j ++ )
			g[i][j] = g[j][i] = ++ m;
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 0, a = m + 1; j < n - 1; j ++ )
		{
			int b;
			scanf("%d", &b);
			b = g[i][b];
			
			d[b] ++ ;
			add(a, b);
			a = b;
		}
	
	printf("%d\n", top_sort(m + 1));
	return 0;
}

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

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

   cin >> a >> b >> c ;

   if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
       cout << "YES";
   }
   else
   {
       cout << "NO";
   }
   
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a  = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        for(int i=n-1;i>=1;i--){
            System.out.print(a[i]+" ");
        }
        System.out.println(a[0]);
        sc.close();
    }
}


Measured memory_bytes: 26068
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B = mapint()

def cal(N):
    bits = [0]*50
    for i in range(1, 50):
        b = 2**i
        bits[i-1] = ((N//b*(b//2))+max(0, N%b-b//2))
    return bits

a_bits = cal(A)
b_bits = cal(B+1)
ans = 0
for i, (a, b) in enumerate(zip(a_bits, b_bits)):
    ans += 2**i*((a+b)%2)
print(ans)

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

bool isNum(const char s) {
    return s >= '0' && s <= '9';
}
int convert(const string &s) {
    int i = 0;
    int ret = 0;
    while(i < s.size()) {
        if(isNum(s[i])) {
            int n = s[i]-'0';
            if(s[i+1] == 'm') ret += n*1000; 
            if(s[i+1] == 'c') ret += n*100; 
            if(s[i+1] == 'x') ret += n*10; 
            if(s[i+1] == 'i') ret += n; 
            i += 2;
        } 
        else if(s[i] == 'm') i++, ret += 1000;
        else if(s[i] == 'c') i++, ret += 100;
        else if(s[i] == 'x') i++, ret += 10;
        else if(s[i] == 'i') i++, ret += 1;
        else i++;
    }
    return ret;
}

string reverse(int n) {
    string s;
    if(n/1000 > 0) {
        if(n/1000 > 1) {
            char c = n/1000 + '0';
            s += c;
        }
        s += 'm';
        n %= 1000;
    }
    if(n/100 > 0) {
        if(n/100 > 1) {
            char c = n/100 + '0';
            s += c;
        }
        s += 'c';
        n %= 100;
    }
    if(n/10 > 0) {
        if(n/10 > 1) {
            char c = n/10 + '0';
            s += c;
        }
        s += 'x';
        n %= 10;
    }
    if(n > 0) {
        if(n > 1) {
            char c = n + '0';
            s += c;
        }
        s += 'i';
        n %= 1000;
    }
    return s;
}

int main(void){
    int n;
    string a, b;
    int x, y;
    cin >> n;
    rep(loop, n) {
        cin >> a >> b;
        cout << reverse(convert(a) + convert(b)) << endl;
    }
}

Measured memory_bytes: 1200
s = input()
key = ""

for i in range(8):
  if i == 0:
    key = s[len(s)-7:]
    if key == "keyence":
      break
  if 0 < i < 7:
    key = s[:i] + s[len(s) - 7 + i:]
    if key == "keyence":
      break
  if i == 7:
    key = s[:7]
    if key == "keyence":
      break

if key == "keyence":
  print("YES")
else:
  print("NO")
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
int x,ac=0,wa=0,tle=0,re=0;
string y;
cin>>x;
for ( int i = 0 ; i<x;i++ )
{
    cin>>y;
    if (y=="AC")ac++;
    if (y=="WA")wa++;
    if (y=="TLE")tle++;
    if (y=="RE")re++;

}
cout<<"AC x "<<ac<<endl;
cout<< "WA x "<<wa<<endl;
cout<< "TLE x "<<tle <<endl;
cout << "RE x "<<re<<endl;

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3632
a,b,c,k = map(int, input().split())
sum = 0
if a >= k:
    sum += 1*k
    print(sum)
elif a < k :
    sum += 1*a
    k = k - a
    if b >= k:
        print(sum)
    else :
        k = k - b
        sum += (-1)*k
        print(sum)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vec vector<int>
using namespace std;

const ll INF = 1e18;
int n, m, s;
vec a, b, c, d, u, v;
vector<vec> edge;
vector<vector<ll>> dp;
vector<vector<bool>> vis;

int oth(int x, int e) {
	if (u[e] == x) return v[e];
	return u[e];
}

int main() {
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	cin >> n >> m >> s;
	a = vec(m);
	b = vec(m);
	c = vec(n);
	d = vec(n);
	u = vec(m);
	v = vec(m);
	edge = vector<vec>(n); 
	for (int i=0; i<m; i++) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		--u[i]; --v[i];
		edge[u[i]].push_back(i);
		edge[v[i]].push_back(i);
	}
	for (int i=0; i<n; i++) cin >> c[i] >> d[i];
	
	int MXS = n*50 + 2;
	int MX = MXS - 1;
	dp = vector<vector<ll>>(n, vector<ll>(MXS, INF));
	vis = vector<vector<bool>>(n, vector<bool>(MXS));
	dp[0][min(MX, s)] = 0;
	priority_queue<pair<ll,pii>, vector<pair<ll,pii>>, greater<pair<ll,pii>>> pq;
	pq.push({0, {0, min(MX, s)}});
	while (!pq.empty()) {
		int id = pq.top().second.first;
		int co = pq.top().second.second;
		pq.pop();
		if (vis[id][co]) continue;
		vis[id][co] = true;
		for (int e : edge[id]) {
			int idx = oth(id, e);
			// reach all city
			if (co == MX) {
				if (dp[idx][co] > dp[id][co]+b[e]) {
					dp[idx][co] = dp[id][co] + b[e];
					pq.push({dp[idx][co], {idx, co}});
				}
				continue;
			}
			
			if (co>=a[e] && dp[idx][co-a[e]] > dp[id][co]+b[e]) {
				dp[idx][co-a[e]] = dp[id][co] + b[e];
				pq.push({dp[idx][co-a[e]], {idx, co-a[e]}});
			}
			
			// do transaction
			ll need = max(0, a[e]-co);
			ll exch = max(1ll, need/c[id] + (need%c[id]>0));
			while (1) {
				ll time = dp[id][co] + d[id]*exch;
				ll coin = co + c[id]*exch;
				if (coin-a[e]<MX) {
					if (dp[idx][coin-a[e]] > time+b[e]) {
						dp[idx][coin-a[e]] = time+b[e];
						pq.push({time+b[e], {idx, coin-a[e]}});
					}
				}
				else {
					if (dp[idx][MX] > time+b[e]) {
						dp[idx][MX] = time+b[e];
						pq.push({time+b[e], {idx, MX}});
					}
					break;
				}
				exch++;
			}
		}
	}
	vector<ll> ans(n, INF);
	for (int i=1; i<n; i++) {
		for (int j=0; j<MXS; j++) {
			ans[i] = min(ans[i], dp[i][j]);
		}
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 37212
import math
if __name__ == '__main__':
    def sig(s, m):
        ans = (s-m)**2
        return ans

    while(True):
        n = int(input())
        if n == 0:
            break
        ds = input()
        s = ds.split()
        ave = sum([int(i) for i in s])/len(s)
        ans = 0
        for sn in s:
            ans += sig(int(sn), ave)
        else:
            ans = math.sqrt(ans/len(s))

        print(ans)



Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	int n;
	std::cin >> n;
	int counter=0;
	rep(i,n){
		if((i+1)%15==0)counter+=600;
		else counter+=800;
	}
	std::cout <<  counter << std::endl;
}


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

int main(){
  vector<int> ant(5,0);
  for(int i=0; i<5; i++) cin>>ant[i];
  sort(ant.begin(),ant.end());
  int k; cin>>k;
  if(k>=ant[4]-ant[0]) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)
typedef pair<int, int> P;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int px = sx, py = sy;
    map<P, bool> mp;
    string ans = "";
    
    cout << string(tx-sx, 'R') << string(ty-sy, 'U') \
         << string(tx-sx, 'L') << string(ty-sy, 'D') \
         << 'D' << string(tx-sx+1, 'R') << string(ty-sy+1, 'U') \
         << 'L' << 'U' << string(tx-sx+1, 'L') << string(ty-sy+1, 'D') << 'R' \
         << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<queue>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}


int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, M; cin >> N >> M;

	char n[50][50];
	rep(i, 0, N) {
		cin >> n[i];
	}

	char m[50][50];
	rep(i, 0, M) {
		cin >> m[i];
	}

	rep(i, 0, N) {
		rep(j, 0, N) {
			bool b = true;
			rep(k, 0, M) {
				rep(l, 0, M) {
					b &= (m[k][l] == n[i + k][j + l]);
				}
			}
			if (b) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;

	return 0;
}

Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

import heapq
A_que = []
for i in A:
    A_que.append((-1) * i)
heapq.heapify(A_que)
for i in range(M):
    price = (-1) * heapq.heappop(A_que)
    price = price // 2
    heapq.heappush(A_que, (-1) * price)
print(-sum(A_que))

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int n,h; cin >> n >> h;
  vector<int> a(n),b(n);
  for(int i = 0; i < n; ++i)cin >> a[i] >> b[i];
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  int ans = (h+a.front()-1)/a.front();
  for(int i = 0; i < n; ++i){    
    h -= b[i];
    if(h <= 0){
      ans = min(ans,i+1);
      break;
    }
    ans = min(ans,i+1+(h+a.front()-1)/a.front());
  }
  cout << ans << endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int k, s, ans;

int main() {
	cin >> k >> s;
	rept(x,k) {
		rept(y,k) {
			if (0<=s-x-y && s-x-y<=k) ans++;
		}
	}
	cout << ans << ln;
}

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

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

  uint64_t max = 1e18;
  uint64_t m = 1;
  uint64_t a = 1;

  bool fal = true;
  int re = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    if (0 == a)
    {
      re = 0;
      fal = false;
      break;
    }

    if (max / a < m)
    {
      re = -1;
      fal = false;
    }
    m *= a;
  }

  if (fal == false)
  {
    cout << re << endl;
  }
  else
  {
    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;;
  int count = 700;
  if(s[0] == 'o') count += 100;
  if(s[1] == 'o') count += 100;
  if(s[2] == 'o') count += 100;
  cout << count << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;
 
int main(void)
{
	int n, a, b;

	cin >> n >> a >> b;

	cout << min(n*a, b) << '\n';

	return 0;
}

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

int main()
{
  string s,t;
  cin >> s >> t;
  
  int ssize = s.size();
  int tsize = t.size();
  int count = 0,maxcount = 0;
  for(int i = 0; i <= ssize - tsize; i++){
    for(int j = 0; j < tsize; j++){
      if(t[j] == s[i+j]){
        count++;
      }
    }//for
    if(count > maxcount){
      maxcount = count;
    }//if
    count = 0;
  }//for
    
    cout << tsize - maxcount << endl;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		List<int[]> hws = new ArrayList<>();
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0) break;	// 1 <=H.W<= 300
			
			int[] hw = new int[]{H, W};
			hws.add(hw);
			
		}
		sc.close();
		
		for(int[] hw : hws) {
			
			for(int hh = 0; hh < hw[0]; hh++) {
				for(int ww = 0; ww < hw[1]; ww++) {
					if (hh == 0 || hh == hw[0]-1 || ww == 0 || ww == hw[1]-1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		
	}
}

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

int main(){
    double M;
    int N;
    cin >> N >> M;
    double limit,sum=0; 
    limit = M /4.0;
    int result=0;
    int A[N];
    for (int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    for (int i=0;i<N;i++){
        if(A[i] >= sum / (4.0 * M)) result++;
    }
    if(result >= M)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
    int N,K,P; cin >> N;
    for(int i=0; i<N; i++){
        cin >> K >> P;
        if(K%P==0) cout << P << endl;
        else cout << K%P << endl;

    }
}


Measured memory_bytes: 3084
#include <cstdio>
#include <cstring>
#include <cstdlib>
char s[112345];
int fir[112345], num[112345];
int main(){
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int r = 1, l = n;
	for(int i(2); i <= n; ++i){
		if(s[i] == 'R'){
			r = i;
		}
		else{
			fir[i] = r;
		}
	}
	for(int i(n - 1); i >= 1; --i){
		if(s[i] == 'L'){
			l = i;
		}
		else{
			fir[i] = l;
		}
	}
	for(int i(1); i <= n; ++i){
		int d = abs(fir[i] - i);
		if(d % 2 == 1){
			++num[fir[i] + (s[fir[i]] == 'L' ? -1 : 1)];
		}
		else{
			++num[fir[i]];
		}
	}
	for(int i(1); i < n; ++i) printf("%d ", num[i]);
	printf("%d\n", num[n]);
	return 0;
} 


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

using namespace std;

int main(){
    int x,y,s;
    while(cin>>x>>y>>s,x){
        int ans=0;
        for(int i=1;i<=s-1;++i){
            for(int j=i;j<=s-1;++j){
                if(i*(100+x)/100+j*(100+x)/100==s)ans=max(ans,i*(100+y)/100+j*(100+y)/100);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3092
import bisect
def prime(n):
  prime_table = [2]
  for i in range(3,n+1):
    f = 1
    for j in prime_table[:bisect.bisect_right(prime_table,int(i**0.5))]:
      if i % j == 0:
        f = 0
        break
    if f:
      prime_table.append(i)
  return prime_table

n = int(input())
prime = prime(10**3)
l = [0] * len(prime)
for i in range(1,n+1):
  for j in range(len(prime)):
    while i % prime[j] == 0:
      i = i // prime[j]
      l[j] += 1
a = 1
for i in l:
  a = (a * (i+1)) % (10**9+7)
print(a)

Measured memory_bytes: 40816
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define ms(a) memset(a,0,sizeof(a))
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll Mod = 998244353;
#define mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
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);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}


ll dp[100005][2];
ll visited[100005];

void dfs(ll u,vl adj[])
{
  visited[u]=1;
  //if(u!=0&&sz(adj[u])==1)
  {
    dp[u][0]=1;
    dp[u][1]=1;
  }
  for(auto it:adj[u])
  {
    if(visited[it]==0)
    {
      //f++;
      dfs(it,adj);
      dp[u][0]=modmulti(dp[u][0],dp[it][1]);
      dp[u][1]=modmulti(dp[u][1],modadd(dp[it][0],dp[it][1]));
    }
  }
  

}

     
int main()
{
      
  fast;
  ll n;
  cin>>n;
  vl adj[n];
  ingraph(adj,n-1); 

  dfs(0,adj); 
  //cout<<endl;
  //fr(i,0,n)
    //cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;  

  ll ans=0;
  ans=(dp[0][0]+dp[0][1])%mod;
  cout<<ans<<endl;
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 18392
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a,b,c;
void input(){
    fast_io();
    cin >> a >> b >> c;
}

int solve(){
    bool t = (b-a)==(c-b);
    cout << (t?"YES":"NO") << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using  namespace std;
int main() {
    char a,b;
    while(cin>>a>>b) {
        if(a=='H'&&b=='H')
            cout<<"H"<<endl;
        else if(a=='H'&&b=='D')
            cout<<"D"<<endl;
        else if(a=='D'&&b=='H')
            cout<<"D"<<endl;
        else if(a=='D'&&b=='D')
            cout<<"H"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N = int(input())
    A = list(map(int, input().split()))
    cost = 0

    for i in range(1, N):
        a_left, a_right = A[i-1], A[i]
        if a_left > a_right:
            cost += a_left - a_right
            A[i] = a_left
    print(cost)


if __name__ == "__main__":
    main()


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, cnt[5];
double DP[305][305][305];

double Solve(int i, int j, int k){
  if (DP[i][j][k] != -1) return DP[i][j][k];
  if (i > N || j > N || k > N) return 0;

  double ans = 0;
  if (i > 0){
    ans += Solve(i-1, j, k) * (double)i / (double)(i+j+k);
  }
  if (j > 0){
    ans += Solve(i+1, j-1, k) * (double)j / (double)(i+j+k);
  }
  if (k > 0){
    ans += Solve(i, j+1, k-1) * (double)k / (double)(i+j+k); 
  }
  ans += (double)N / (double)(i+j+k);

  return DP[i][j][k] = ans;
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    int A; cin >> A; cnt[A]++;
  }
  fill((double*)DP, (double*)(DP+N+1), -1);
  DP[0][0][0] = 0;

  printf("%.10lf\n", Solve(cnt[1], cnt[2], cnt[3]));

  return 0;
}


Measured memory_bytes: 222564
#include<iostream>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int cnt = 0;
	REP(i, 0, 101) {
		if (i >= A && i < B && i >= C && i < D) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
# N = 5
# A = list([24, 11, 8, 3, 16])

M = max(A) + 1
cnt =[0 for _ in range(M)]

for i in A:
    for j in range(i, M, i):
        cnt[j] += 1

ans = 0
for k in A:
    if cnt[k] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 32220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll x,y;
	cin>>x>>y;
	ll ans=0;
	if(x==1){
		ans+=300000;
	}
	else if(x==2){
		ans+=200000;
	}
	else if(x==3){
		ans+=100000;
	}
	if(y==1){
		ans+=300000;
	}
	else if(y==2){
		ans+=200000;
	}
	else if(y==3){
		ans+=100000;
	}
	if(x==1&&y==1){
		ans+=400000;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    ll a, b;
    cin >> a >> b;
    set<ll> ad, bd;
    ad.insert(1); bd.insert(1);
    for (ll i=2; i*i<=a; ++i) {
        if (a%i!=0) continue;
        while (a%i==0) a /= i;
        ad.insert(i);
    }
    if (a > 1) ad.insert(a);
    for (ll i=2; i*i<=b; ++i) {
        if (b%i!=0) continue;
        while (b%i==0) b /= i;
        bd.insert(i);
    }
    if (b > 1) bd.insert(b);
    set<ll> res;
    set_intersection(all(ad), all(bd), inserter(res, res.end()));
    cout << sz(res) << endl;
    return 0;
}


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

void solve(){
  int l ;
  cin>>l;int a[l];
  
  for (int i = 1; i <= l; ++i)
  {
    cin>>a[i];
  }
  int cnt =0;
  for (int i = 1; i <= l; ++i)
  {
    if(a[i]%2 != 0 and i%2  != 0) cnt++;
  }
  cout<< cnt;
}

int main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t=1; 
     // cin >> t;
     while (t--) solve();
 
     return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int first, second, flag;
  
  first = stoi(S.substr(0, 2));
  second = stoi(S.substr(2));
  
  if (first >= 1 && first <= 12) {
    if (second >= 1 && second <= 12) {
      flag = 2;
    }
    else {
      flag = 1;
    }
  }
  
  else if (second >= 1 && second <= 12) {
    flag = 0;
  }
  
  else {
    flag = 3;
  }
  
  if (flag == 0){
    cout << "YYMM" << endl;
  }
  
  else if (flag == 1) {
    cout << "MMYY" << endl;
  }
  
  else if (flag == 2) { 
    cout << "AMBIGUOUS" << endl;
  }
  
  else {
    cout << "NA" << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector< tuple<string, int, int> > restaurant;
    for(int i=1; i<=N; i++) {
        string S;
        int P;
        cin >> S >> P;
        P = -P;
        restaurant.emplace_back(S, P, i);
    }
    sort(restaurant.begin(), restaurant.end());
    for(int i=0; i<N; i++) {
        cout << get<2>(restaurant.at(i)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256