akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int d,t,s;
	cin>>d>>t>>s;
	
	if(d <= t*s)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

int tab[11];
int calc(int y, int m, int d){
  int ret = 0;
  ret = (y-1) / 3 * (tab[10]*2+20*10);
  ret += (y+2) % 3 * tab[10];
  if(y % 3 == 0)
	ret += (m-1)*20 + d-1;
  else
	ret += tab[m-1] + d-1;
  return ret;
}

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

  for(int i=1;i<=10;++i) tab[i] = tab[i-1] + ((i&1)? 20: 19);
  int N; cin >> N;
  REP(i,N){
	int y, m, d; cin >> y >> m >> d;
	cout << calc(999,10,20) - calc(y,m,d) + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
def main():
    import numpy as np
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
    a.sort()
    b.sort()
    c.sort()
    a=np.array(a)
    b=np.array(b)
    c=np.array(c)

    cnt_a=np.searchsorted(a,b)
    cnt_c=n-np.searchsorted(c,b,side='right')
    print(np.sum(cnt_a*cnt_c))
if __name__=='__main__':
    main()

Measured memory_bytes: 31476
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=n;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
      chmin(ans,max(i+1,n-i-1));
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
using Graph = vector<vecint>;

bool dfs(const Graph &g, vecint &clr, vector<bool> &vis, int i = 0, int c = 1) {
  vis[i] = true;
  clr[i] = c;
  for (int j : g[i]) {
    if (!vis[j]) {
      if (!dfs(g, clr, vis, j, 3-c))
        return false;
    } else if (clr[j] != 3-c) {
      return false;
    }
  }
  return true;
}

int main()
{
  ll n,m;
  cin>>n>>m;
  Graph g(n);
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vecint clr(n, 0);
  vector<bool> vis(n, false);
  bool bip = dfs(g, clr, vis);
  if (bip) {
    ll p = 0, q = 0;
    REP(i,n) {
      if (clr[i] == 1) ++p;
      else ++q;
    }
    cout << (p*q - m) << endl;
  } else {
    ll emax = n * (n-1) / 2;
    cout << (emax - m) << endl;
  }
  return 0;
}


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

int main(){
  int n;
  string k;
  int arr[4] = {0,0,0,0};
  cin>>n;
  for (int i = 0;i <n; i++){
    cin>>k;
    if (k=="AC"){
      arr[0]+=1;
    }
    else if (k=="WA"){
      arr[1]+=1;
    }
    else if (k=="TLE"){
      arr[2]++;
    }
    else{
      arr[3]++;
    }
  }

  cout<<"AC x "<<arr[0]<<endl;
  cout<<"WA x "<<arr[1]<<endl;
  cout<<"TLE x "<<arr[2]<<endl;
  cout<<"RE x "<<arr[3]<<endl;
  return 0;
}


Measured memory_bytes: 3604
use std::collections::{BTreeSet, VecDeque};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let s: Vec<_> = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - 'A' as usize)
        .collect();
    let mut graph = vec![BTreeSet::new(); n];
    let mut count = vec![[0; 2]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        if !graph[a].contains(&b) {
            graph[a].insert(b);
            count[a][s[b]] += 1;
        }
        if !graph[b].contains(&a) {
            graph[b].insert(a);
            count[b][s[a]] += 1;
        }
    }

    let mut q = VecDeque::new();
    let mut removed = vec![false; n];
    for i in 0..n {
        if count[i][0] == 0 || count[i][1] == 0 {
            removed[i] = true;
            q.push_back(i);
        }
    }

    while let Some(v) = q.pop_front() {
        let next: Vec<_> = graph[v].iter().cloned().collect();
        for next in next.into_iter() {
            assert!(graph[next].remove(&v));
            assert!(count[next][s[v]] > 0);
            count[next][s[v]] -= 1;
            if count[next][s[v]] == 0 && !removed[next] {
                removed[next] = true;
                q.push_back(next);
            }

            if next != v {
                assert!(graph[v].remove(&next));
                assert!(count[v][s[next]] > 0);
                count[v][s[next]] -= 1;
            }
        }

        graph[v].clear();
        assert_eq!(count[v][0], 0);
        assert_eq!(count[v][1], 0);
    }

    if removed.into_iter().all(|r| r) {
        println!("No");
    } else {
        println!("Yes");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 35068
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  double m,n;
  ll d;
  double ans;
  cin >> n>> m >> d;
  if(d==0){
    ans = (m-1)/n;
  }else{
    ans = (m-1)*2*(n-d)/(n*n);
  }
  printf("%.8lf\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif
		int y;
		cin>>y;
		int n= y%10;
		if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ){
			cout<<"hon"<<"\n";
		}
		else if (n == 0 ||n == 1 ||n == 6 ||n == 8){
			cout<<"pon"<<"\n";
		}
		else if(n ==3)
		{
			cout<<"bon"<<"\n";
		}

		return 0;	
	}	

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
int cal(int n,int m,int a[]){
  int i,j;
  int max=0;
  for(i=1; i<=n; i++){
    for(j=i+1; j<=n; j++){
      if(a[i]+a[j]<=m && max<a[i]+a[j]){
	max=a[i]+a[j];
      }
    }
  }
  if(max!=0){
    return max;
  }else if(n!=0 &&m!=0){
    max=-1;
    return max;
  }else{
    max=0;
    return max;
  }
}
int main(void){
  int i,j=1,k;
  int b[1000];
  while(1){
    int n;//品物の個数
    scanf("%d",&n);
    int m;//金額
    scanf("%d",&m);
    int a[n];
    if(n!=0 && m!=0){
      for(i=1; i<=n; i++){
	scanf("%d",&a[i]);
      }
      b[j]=cal(n,m,a);
      j++;
    }else{
      break;
    }
  }
  for(k=1; k<=j; k++){
    if(b[k]==-1){
      printf("NONE\n");
    }else if(b[k]!=0){
      printf("%d\n",b[k]);
    }else{
      break;
    }
  }
  return 0;
}



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

#define int long long
const int MOD=998244353;
int dp[2][505][513];//dp[i][j][k]:i-1番目の数字がjでxorがk

signed main(){
  int n,x;cin>>n>>x;
  dp[0][0][0]=1;
  for(int j=0;j<504;j++)dp[0][j+1][0]+=dp[0][j][0];
  for(int i=1;i<=n;i++){
    for(int j=0;j<=x;j++)for(int k=0;k<513;k++)dp[i&1][j][k]=0;
    for(int j=0;j<=x;j++){
      for(int k=0;k<513;k++){
        dp[i&1][j][k^j]+=dp[(i^1)&1][j][k];
        dp[i&1][j][k^j]%=MOD;
      }
    }
    for(int k=0;k<513;k++){
      for(int j=0;j<x;j++){
        dp[i&1][j+1][k]+=dp[i&1][j][k];
        dp[i&1][j+1][k]%=MOD;
      }
    }
  }
  cout<<dp[n&1][x][x]<<endl;
}



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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

int main() {

    long long x;
    cin >> x;

    long long cur = 100;
    for (int i = 0; ; i++) {
        cur = cur + (cur / 100);
        if (cur >= x) {
            printf("%d\n", i + 1);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3764
use v5.18;
use warnings;
use utf8;
use List::Util qw( sum );
sub line { chomp(my $str = <>); $str; }
sub split_line { (split / /, line) }

my ($limit, $min, $max) = split_line;

my $sum = 0;
for my $num (1 .. $limit) {
  my @digits = split //, $num;
  my $dsum = sum @digits;
  if ( $dsum >= $min && $dsum <= $max ) {
    $sum += $num;
  }
}
say $sum;


Measured memory_bytes: 896
n, m = map(int, input().split())
lst = list(map(int, input().split()))

if n >= m:
    print(0)
else:
    lst.sort()
    diff_lst = []
    for i in range(len(lst)-1):
        diff = lst[i+1] - lst[i]
        diff_lst.append(diff)
    diff_lst.sort(key = lambda x: -x)
    print(sum(diff_lst[n-1:]))

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

int main()
{
	
	int n;
	cin>>n;
	vector<int> h;
	int count=0;
	for(int i=0;i<n;i++)
	{
		int temp;
		cin>>temp;
		h.push_back(temp);
		while (h[i] % 2 == 0) { h[i] /= 2; count++; }
		
	}
	cout<<count<<"\n";
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

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

	int n; cin >> n;
	vector<int> h, dp(n);

	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		h.pb(x);
	}

	dp[0] = 0; dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vi p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(ALL(p), std::greater<>());
  sort(ALL(q), std::greater<>());
  vi d;
  rep(i, x) d.push_back(p[i]);
  rep(i, y) d.push_back(q[i]);
  rep(i, c) d.push_back(r[i]);
  sort(ALL(d), std::greater<>());
  ll ans = 0;
  rep(i, x+y) ans += d[i];
  cout << ans << endl;
}

Measured memory_bytes: 6540
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int mod = 1e9 + 7;
const int MAXN = 200010;

inline int fsp(int x, int k = mod - 2) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % mod;
		x = 1LL * x * x % mod, k >>= 1;
	} return s;
}

int fac[MAXN];
int ifac[MAXN];

inline void init(int n) {
	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = 1LL * fac[i - 1] * i % mod;
	ifac[n] = fsp(fac[n]);
	for(int i = n; i >= 1; i--) ifac[i - 1] = 1LL * ifac[i] * i % mod;
}

vector<int>W[MAXN];

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri, X = ri, Y = ri;

	init(n);

	for(int i = 1; i <= n; i++) {
		int c = ri, w = ri;
		W[c].push_back(w);
	}

	int mi = 1e9, mii = 1e9;
	for(int i = 1; i <= n; i++) {
		if(W[i].size()) {
			sort(W[i].begin(), W[i].end());
			if(W[i][0] < mii) mii = W[i][0];
			if(mii < mi) swap(mii, mi);
		}
	}

	int sz = 0, res = 1;
	for(int i = 1; i <= n; i++) {
		if(W[i].size()) {
			int t = W[i][0] == mi ? mii : mi;
			if(t + W[i][0] > Y) continue;
			int Sz = W[i].size() - 1;
			while(Sz && W[i][Sz] + W[i][0] > X && W[i][Sz] + t > Y) --Sz;
			sz += Sz + 1, res = 1LL * res * ifac[Sz + 1] % mod;
		}
	} cout << 1LL * res * fac[sz] % mod << endl;
	return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main(void){
    int i,j,a[15],b;
    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<9;i++){
        for(j=i+1;j<10;j++){
            if(a[i]<a[j]){
                b=a[i];
                a[i]=a[j];
                a[j]=b;
            }
        }
    }
    for(i=0;i<3;i++){
        printf("%d\n",a[i]);
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int>l(N);
	rep(i, N)cin >> l[i];
	sort(l.begin(), l.end(), greater<int>());
	int ans = 0;
	rep(i, K) ans += l[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int number1=0;
		int number2=0;
		int number3=0;
		if(a<=b && b<=c) {
			number1=a; number2=b; number3=c;

		}else if (a<=c && b>=c) {
			number1=a; number2=c; number3=b;

		}else if(b<=a &&a<=c) {
			number1=b; number2=a; number3=c;

		}else if(b<=c && c<=a) {
			number1=b; number2=c; number3=a;
		}else if(c<=a && a<=b) {
			number1=c; number2=a; number3=b;

		}else if(c<=b && b<=a) {
			number1=c; number2=b ;number3=a;

		}
		System.out.println(number1+" "+number2+" "+number3);

	}

}



Measured memory_bytes: 26280
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159


inline int mul(int a,int b){return (a*1ll*b)%MOD;}
inline int add(int a,int b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,MOD-2);}


bitset<N>every;
int n,t;
int arr[N];
int freq[5];
signed main() 
{
     forn(i,1,3)
     {
          int a,b;
          cin>>a>>b;
          freq[a]++;
          freq[b]++;
     }
     sort(freq+1,freq+1+4);
     
     
          if(freq[1]==1 and freq[2]==1 and freq[3]==2 and freq[4]==2)
              cout<<"YES";
          else cout<<"NO";    
}

//       g++ -g c.cpp ; ./a.exe

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

using namespace std ;

#define ll long long

ll a , b [ 3001 ] , c , d , e , cnt ;

int main ()
{
    cin >> a ;
    if ( a < 1200 ){
        cout << "ABC" ;
        return 0 ;
    }
    if ( a >= 1200 && a < 2800 ){
        cout << "ARC" ;
        return 0 ;
    }
    cout << "AGC" ;
    return 0 ;
}
    

Measured memory_bytes: 256
x, y, turn = 0, 0, 0

loop do
  r, rad = gets.split(",").map(&:to_i)
    break if r == 0 and rad == 0
  x += r * Math::sin(turn * Math::PI / 180)
  y += r * Math::cos(turn * Math::PI / 180)
  turn += rad
end

puts x.to_i
puts y.to_i

Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 1145148931919810;
int main(){
    string s;
    ll w;
    cin >> s >> w;
    for(ll i = 0; i < s.size(); i += w) cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define Max 100010
using namespace std;
struct node
{
    int n,d;
}push;
vector<node>  e[Max];
bool vis[Max];
int flag=0;
int dis[Max];
void dfs(int x)
{
    vis[x]=true;
    if(flag)
    return;
    for(int i=0;i<e[x].size();i++)
    {
        node tmp;
        tmp=e[x][i];
        if(vis[tmp.n])
        {
            if(dis[tmp.n]!=dis[x]+tmp.d)
            {
                flag=1;
                break;
            }
        }
        else
        {
            dis[tmp.n]=dis[x]+tmp.d;
            dfs(tmp.n);
        }
    }
}
int main()
{
    int N,M;
    int l,r,d;
    scanf("%d%d",&N,&M);
    int i;
    for(i=0;i<M;i++)
    {
        scanf("%d%d%d",&l,&r,&d);
        push.n=r;
        push.d=d;
        e[l].push_back(push);
        push.n=l;
        push.d=-1*d;
        e[r].push_back(push);
    }
    for(i=0;i<N;i++)
    {
        if(vis[i]==false)
        {
            dfs(i);
        }
        if(flag)
            break;
    }
    if(flag)
        printf("No\n");
    else printf("Yes\n");
    return 0;
}


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

int main(){
  int x, a, b;
  cin >> x;
  a = ( x - ( x % 500 ) ) / 500;
  b = ( ( x % 500 ) - ( x % 500 ) % 5 ) / 5;
  cout << 1000 * a + 5 * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	ll x,i,p=100;
	cin>>x;
	for(i=1;i<4000;i++)
	{
		p=(ll)(p*1.01);
//		cout<<p<<" ";
		if(p>=x) break;
//		if(100*pow(1.01,i)>=x) break;
	}
	cout<<i;
	return 0;
}

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

typedef long long ll;

int main() {
	// string s;
	// cin >> s;
	// if (s[(int)s.size()-1] != 's') {
		// cout << s << 's';
	// } else {
		// cout << s <<  "es";
	// }
	int N;
	cin >> N;
	vector< bool > v(N);
	for(int i=0; i<N; i++) {
		int x,y;
		cin >> x >> y;
		v[i] = (x == y);
		
	}
	bool y = 0;
	for (int i=2; i<N; i++) {
		bool yy = 1;
		for (int j=i-2; j<=i; j++) {
			yy &= v[j];
		}
		y |= yy;
	}
	cout << (y ? "Yes" : "No");
	return 0;
	
}


Measured memory_bytes: 3592
from collections import defaultdict
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
a = inl()
h =defaultdict(int)
b = [0]*(n+1)
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i]+a[i]
    b[i+1] = (s[i+1]-i-1)%k
ddprint(s)
ddprint(b)
acc = 0
for i in range(n+1):
    if i>=k:
        h[b[i-k]] -= 1
    acc += h[b[i]]
    h[b[i]] += 1
    #ddprint("i {} acc {} h {}".format(i,acc,h))
print(acc)


Measured memory_bytes: 112972
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] ans=new boolean[n];
		Unionfind uf=new Unionfind(n);
		for(int i = 0; i<m; i++){
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			int z = sc.nextInt();
			uf.unite(x,y);
		}
		long count=0;
		for(int i=0; i<n; i++){
			if(!ans[uf.root(i)]){
				ans[uf.root(i)]=true;
				count++;
			}
		}
		System.out.println(count);
	}
	static class Unionfind{
		int[] parent;
		public Unionfind(int n){
			this.parent=new int[n];
			for(int i = 0; i<n; i++){
				parent[i]=i;
			}
		}
		public int root(int t){
			if(parent[t]==t){
				return t;
			}else{
				return parent[t]=root(parent[t]);
			}
		}
		public void unite(int x,int y){
			if(same(x,y)){
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[yroot]=xroot;
		}
		public boolean same(int x,int y){
			return root(x)==root(y);
		}
	}
}


Measured memory_bytes: 91792
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
int dfs(int x,vector<string> s,int n,int k,int m){
int res=0;
if(n==1)res=1;
//cout<<n+1<<endl;
for(int i=x;i<m&&k<s[i].size();i++){
if(s[i][k]=='.')continue;

int a=s[i][k]-'0';

if(s[i][k]=='+')a=dfs(i+1,s,0,k+1,m);
else if(s[i][k]=='*')a=dfs(i+1,s,1,k+1,m);
if(n==1){
	res*=a;
}else{
	res+=a;
}

}
//cout<<res<<endl;
return res;
}
int main(void){
	int n;
	while(1){
cin>>n;
if(n==0)break;

vector<string> s(n);
for(int i=0;i<n;i++){
	cin>>s[i];
//a.push(s);
}
cout<<dfs(0,s,0,0,n)<<endl;;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
using namespace std;

typedef long long int ll;
constexpr int kMod = 998244353, kN = int(2E5 + 10);

struct BIT {
	ll val[kN];
	void init() {memset(val, 0, sizeof(val));}
	void add(int pos, ll x) {
		while (pos < kN) {
			val[pos] = (val[pos] + x) % kMod;
			pos += pos & -pos;
		}
		return ;
	}
	ll ask(int pos) {
		ll ans = 0;
		while (pos){
			ans += val[pos];
			pos ^= pos & -pos;
		}
		return ans % kMod;
	}
};

ll Pow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % kMod;
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

ll Rev(ll n) {return Pow(n, kMod - 2);}

int a[kN], f[kN];
ll p[kN];
BIT bit, bcnt;

int main() {
	int n, k;
	ll ans = 0, tot = 0, sum = 0;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	p[0] = 1;
	p[1] = (k - 1) * Rev(k) % kMod;
	for (int i = 2; i <= n; i++) p[i] = p[i - 1] * p[1] % kMod;
	for (int i = 1; i <= k; i++) f[i] = 0;
	for (int i = k + 1; i <= n; i++) f[i] = i - k;
	bit.init();
	bcnt.init();
	for (int i = 1; i <= n; i++) {
		ans += p[f[i]] * tot % kMod;
		ans -= p[f[i]] * (tot + tot - bit.ask(a[i])) % kMod;
		ans += (i - 1 - bcnt.ask(a[i]));
		bit.add(a[i], Rev(p[f[i]]));
		bcnt.add(a[i], 1);
		tot = (tot + Rev(p[f[i]]) * Rev(2)) % kMod;
	}
	ans %= kMod;
	if (ans < 0) ans += kMod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 7920
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();

		int cnt =0;
		Map<Integer,Integer> map = new HashMap<>();

		int n = s;
		map.put(0, s);
		for (int i = 1; i < 1000000; i++) {

			if (n%2 == 0) {
				n = n/2;
				if (map.containsValue(n)){
					cnt = map.size()+1;
					break;
				}
				map.put(i, n);
			} else {
				n = 3*n +1;
				if (map.containsValue(n)){
					cnt = map.size()+1;
					break;
				}
				map.put(i, n);
			}
		}

		System.out.println(cnt);

	}

}


Measured memory_bytes: 23764
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;



class CPP{
private:
    ll v;
    vector<pair<pll,ll>> edge; //to,cost
    ll sum;
    vector<ll> count;
    const ll INF=1e18;
    
public:
    CPP(ll v):v(v),sum(0),count(vector<ll>(v,0)){}
    
    void add_edge(ll from,ll to,ll cost){
        edge.push_back({{from,to},cost});
        sum+=cost;
        count[from]++;
        count[to]++;
    }
    
    ll solve(){
        ll ret=sum;
        vector<ll> n;
        for(int i=0;i<v;i++){
            if(count[i]%2==1){n.push_back(i);}
        }
        if(n.size()==0){return ret;}
        vector<vector<ll>> A(v,vector<ll>(v,INF));
        for(int i=0;i<v;i++){A[i][i]=0;}
        for(int i=0;i<edge.size();i++){
            A[edge[i].F.F][edge[i].F.S]=min(A[edge[i].F.F][edge[i].F.S],edge[i].S);
            A[edge[i].F.S][edge[i].F.F]=A[edge[i].F.F][edge[i].F.S];
        }
        for(int i=0;i<v;i++){
            for(int t=0;t<v;t++){
                for(int h=0;h<v;h++){
                    A[t][h]=min(A[t][i]+A[i][h],A[t][h]);
                }
            }
        }
        vector<ll> dp(1LL<<n.size(),INF);
        priority_queue<pll,vector<pll>,greater<pll>> q; //cost,where
        q.push({0,0});
        dp[0]=0;
        while(!q.empty()){
            pll w=q.top(); q.pop();
            if(dp[w.S]!=w.F){continue;}
            for(int i=0;i<n.size();i++){
                if(w.S>>i&1){continue;}
                for(int t=i+1;t<n.size();t++){
                    if(w.S>>t&1){continue;}
                    pll New={w.F,w.S};
                    New.S|=1LL<<i;
                    New.S|=1LL<<t;
                    New.F+=A[n[i]][n[t]];
                    if(dp[New.S]>New.F){
                        dp[New.S]=New.F;
                        q.push(New);
                    }
                }
            }
        }
        return ret+dp[(1LL<<n.size())-1];
    }
};



int main(){
    ll v,e;
    cin>>v>>e;
    CPP cpp(v);
    for(int i=0;i<e;i++){
        ll s,t,d;
        cin>>s>>t>>d;
        cpp.add_edge(s,t,d);
    }
    cout<<cpp.solve()<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , D;
  cin >> N >> D;
  
  int i = 0;
  
  while (((D * 2) + 1) * i < N) {
    i++;
  }
  cout << i << endl;
  
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

s = [list(input()) for _ in range(h)]

for i in range(1, h-1):
  for j in range(1, w-1):
    if s[i][j] == '#':
      
      if s[i+1][j]=='#' or s[i-1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
        continue
      else:
        print('No')
        exit()
      
print('Yes')

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

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

const int MAXN = 200010;

int n;

int v[MAXN];

lli freq[MAXN];

lli choose(lli k)
{
	lli ans = k;
	ans *= ( k - 1 );

	return ans/2;
}

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]), freq[ v[i] ]++;

	lli ans = 0;

	for(int i = 1 ; i <= n ; i++)
		ans += choose( freq[i] );

	for(int i = 1 ; i <= n ; i++)
	{
		lli curAns = ans;
		curAns -= choose( freq[ v[i] ] );
		curAns += choose( freq[ v[i] ] - 1 );

		printf("%lld\n",curAns);
	}
}

Measured memory_bytes: 3968
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            // 出力
            boolean ok = false;

            for (int i = 1; i <= 2000; i++) {
                if (i * 100 <= x && x <= i * 105) ok = true;
            }
            out.println(ok ? 1 : 0);

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////



int main() {
    
    ll N;
    string S;
    cin >> N >> S;

    ll ans = 0;

    rep(p, (1 << N)) {
        vector<char> r;
        vector<char> b;

        rep(i, N) {
            if ((p >> i) % 2 == 0) { r.push_back(S[i]); }
            else { b.push_back(S[i]); }
        }

        ll K = b.size();
        ll M = r.size();

        vector<vector<ll>> dp(K + 1, vector<ll>(M + 1, 0));

        dp[0][0] = 1;

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

            if (j > 0 && S[2*N - i - j] == r[j - 1]) {
                dp[i][j] += dp[i][j - 1];
            }

            //cout << i << j << dp[i][j] << endl;
        }

        ans += dp[K][M];

        //cout << p << dp[K][M] << endl;
    }

    cout << ans;

	system("PAUSE");
}

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

int main() {
  int n,t,a;
  cin>>n>>t>>a;
  vector<int>h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  vector<double>kion(n);
  for(int i=0;i<n;i++){
    kion[i]=(double)t-h[i]*0.006;
    //cout<<kion[i]<<endl;
  }
  double sa=LLONG_MAX;
  int kotae=0;
  for(int i=0;i<n;i++){
    double tmp=fabs(kion[i]-(double)a);
    //cout<<i<<" "<<tmp<<endl;
    if(sa>tmp){
      kotae=i+1;
      sa=tmp;
    }
  }
  cout<<kotae<<endl;
  return 0;
}



Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

import sys
import os
import math


for s in sys.stdin:
    lis = s.split()

    a = int(lis[0])
    op = lis[1]
    b = int(lis[2])

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(math.floor(a / b))
    else:
        break

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

using namespace std;

int main(){

  int p_min = 3000;
  int j_min = 3000;
  for(int i = 0;i < 5;++i){
    if(i < 3){
      int p;
      cin>>p;

      p_min = min(p,p_min);
    }
    else{
      int j;
      cin>>j;

      j_min = min(j,j_min);
    }
  }

  int ans = p_min + j_min - 50;
  cout<<ans<<endl;

  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

using ll = long long;
using P = pair<int,int>;

const int N = 1000001;

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

  vector<int> v(N, false);
  vector<int> tab(N, false);
  rep(i, n) {
    int t;
    cin >> t;
    if (v[t]) {
      tab[t] = true;
    }
    v[t] = true;
  }

  rep(i, N) {
    if (!v[i]) continue;

    for(int j = i * 2; j < N; j += i) {
      v[j] = false;
    }
  }

  rep(i, N) {
    if (tab[i]) {
      v[i] = false;
    }
  }

  cout << count(v.begin(), v.end(), true) << endl;

  return 0;
}


Measured memory_bytes: 11172
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int MODU = 1e9+7;
const int N = 1e5+10;


void solve() {
	
}

int main() {
	int n;
	cin >> n;
	vector<int> subord(n+1);
	int temp;
	for(int i=2; i<=n; i++) {
		cin >> temp;
		subord[temp]++;
	}
	for(int i=1; i<=n; i++) {
		cout << subord[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4052
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    if (a < b) {
        console.log('a < b');
    } else if (a > b) {
        console.log('a > b');
    } else {
        console.log('a == b');
    }

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

typedef long long ll;

int main()
{
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0)
    {
        cout << 1 << endl;
    }
    else if (b == 0)
    {
        cout << 2 << endl;
    }
    else if (c == 0)
    {
        cout << 3 << endl;
    }
    else if (d == 0)
    {
        cout << 4 << endl;
    }
    else if (e == 0)
    {
        cout << 5 << endl;
    }
    return 0;
}


Measured memory_bytes: 3520
A, B = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


print(len(set(prime_decomposition(gcd(A, B)))) + 1)

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

using namespace std;
using ll = long long int;

int addwin(char a, int r, int s, int p) {
    if (a == 'r') return p;
    if (a == 's') return r;
    if (a == 'p') return s;
}

char win(char a) {
    if (a == 'r') return 'p';
    if (a == 's') return 'r';
    if (a == 'p') return 's';
}

bool iswin(char a, char b) {
    if (a == 'r' && b == 's') return true;
    else if (a == 's' && b == 'p') return true;
    else if (a == 'p' && b == 'r') return true;
    else return false;
}

int main(void) {
    int n, k, r, s, p; 
    cin >> n >> k;
    cin >> r >> s >> p;
    string t; cin >> t;
    vector<vector<char>> a(k);
    for (int i = 0; i < t.size(); i++) {
        a.at(i % k).push_back(t[i]);
    }
    ll score = 0;
    char prev;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < a.at(i).size(); j++) {
            if (j == 0) {
                score += addwin(a.at(i).at(j), r, s, p);
                prev = win(a.at(i).at(j));
                //cout << a.at(i).at(j) << " " << prev << endl;
                continue;
            }
            if (win(a.at(i).at(j)) == prev && j != a.at(i).size() - 1) {
                if (iswin(prev, win(a.at(i).at(j + 1)))) prev = win(prev);
                else if (iswin(win(a.at(i).at(j + 1)), prev)) prev = win(win(a.at(i).at(j + 1)));
                else prev = a.at(i).at(j);
            }
            else {
                if (win(a.at(i).at(j)) == prev) {
                    //cout << a.at(i).at(j) << " " << prev << endl;
                    continue;
                }
                score += addwin(a.at(i).at(j), r, s, p);
                prev = win(a.at(i).at(j));
            }
            //cout << a.at(i).at(j) << " " << prev << endl;
        }
        //cout << endl;
    }
    cout << score << endl;
}

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

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

  int n = 1;
  for(int i=0; i<N; i++){
    if(a[n-1]==2){
      cout << i+1 << endl;
      break;
      }
    else{
      n = a[n-1];
    }
  }

  if(a[n-1]!=2){
    cout << -1 << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2,vector<int>(n));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int max_sum=0;
	for (int i = 0; i < n; i++) {
		int sum = 0;
		int num1 = 0;
		for (int j = 0; j < n; j++) {
			if (j == i) {
				sum += a[num1][j];
				num1++;
			}
			sum += a[num1][j];
		}
		if (sum > max_sum) {
			max_sum = sum;
		}
	}
	cout << max_sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1;
	s2=s1;
	int l=s1.length(),i;
	for(i=0;i<l/2;i++)
		swap(s2[i],s2[l-i-1]);
	//reverse(s2.begin(),s2.end());
	for(i=0;i<l;i++)
	{
		if(s2[i]=='b')s2[i]='d';
		else
		if(s2[i]=='d')s2[i]='b';
		else
		if(s2[i]=='p')s2[i]='q';
		else
		if(s2[i]=='q')s2[i]='p';
	}
	if(s2==s1)cout<<"Yes";
	else	cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
from itertools import product
import numpy as np

n, _, x = map(int, input().split())
arr1 = np.array([list(map(int, input().split())) for _ in range(n)])
ans = 1200000
if np.all(arr1.sum(0)[1:] >= x):
    for i in product((0, 1), repeat=n):
        arr2 = (i * arr1.T).sum(1)
        if np.all(arr2[1:] >= x):
            ans = min(ans, arr2[0])
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)

const int N = 5e5 + 7;
const ll mod = 1e9 + 7;

vector<vector<int>> keys;
vector<int> costs;
ll dp[1007][1 << 13];
int n, m;

ll solve(int idx, int mask) {
	if (mask == (1 << n)-1)
		return 0;

	if (idx == m) {
		return 1e18;
	}

	ll& ans = dp[idx][mask];
	if (~ans)
		return ans;

	int newmask = mask;
	for (int i = 0; i < (int)keys[idx].size(); i++) {
		newmask |= (1 << keys[idx][i]);
	}

	ans = min(solve(idx+1, mask), costs[idx] + solve(idx+1, newmask));
	return ans;
}


int main() {
	fastIO;
	cin >> n >> m;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		costs.push_back(a);
		vector<int> tmp(b);
		for (int j = 0; j < b; j++) {
			cin >> tmp[j];
			tmp[j]--;
		}
		keys.push_back(tmp);
	}
	ll ans = solve(0, 0);
	if (ans >= 1e18)
		cout << -1;
	else
		cout << ans;

}


Measured memory_bytes: 68280
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (abs(a - b) > 1000000000000000000)cout << "Unfair" << endl;
	else {
		if (k % 2 == 0)cout << a - b << endl;
		else cout << b - a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100010];

int main()
{
    int n;scanf("%d",&n);

    for(int i=0;i<n;i++)scanf("%lld",&a[i]);

    int zero=0;
    for(int i=0;i<n;i++)if(a[i]==0)zero++;

    if(zero>0)
    {
       printf("0\n");
       return 0;
    }


    ll prod=1;
    for(int i=0;i<n;i++)
    {
        if(a[i ] <=1000000000000000000/ prod)
        {
            prod *=a[i];
        }
        else
        {
           printf("-1\n");
           return 0;
        }
    }

    printf("%lld\n",prod );

}


Measured memory_bytes: 4512
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=int(C*D/gcd(C,D))
b=int(B//C)+int(B//D)-int(B//c)
a=int((A-1)//C)+int((A-1)//D)-int((A-1)//c)
print(int((B-b)-(A-1-a)))

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

int main(){
    string s;
    cin >> s;
    if(s.size()<4){
        cout << "No" <<endl;
        return 0;
    }
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
long long dist[100010];
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N, M;
	cin >> N >> M;

	priority_queue<long long>que;
	for (int i = 0; i < N; ++i) {
		long long a;
		cin >> a;
		que.push(a);
	}

	for (int i = 0; i < M;++i) {
		long long target = que.top(); que.pop();
		long long n = target / 2;
		que.push(n);
	}

	long long ans = 0;
	while (!que.empty()) {
		ans += que.top(); que.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 5624
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n <= 999)
        cout << "ABC" << endl;
    else
        cout << "ABD"  << endl;
    return 0;
}

Measured memory_bytes: 256