akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a1: u64,
        a2: u64,
        a3: u64,
    }

    let result = if a1 + a2 + a3 >= 22 {
        "bust"
    } else {
        "win"
    };
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<stdio.h>
#define false 0
#define true 1
int A[20],n,q,m[200];
int solve(int i ,int m){
  int res;
  if(m == 0) return true;
  else if(i >= n) return false;
  res = solve (i + 1, m) || solve(i + 1,m - A[i]);
    return res;
}


int main(){
  int i;
  scanf("%d",&n);
  for(i = 0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    if(solve(0,m[i]) == true){
      printf("yes\n");
    }else printf("no\n");

  }
  return 0;
}

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

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

const int N = 100005;
const ll INF = 1000000000000;

ll n, W, w[105], p[105], dp[N];

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

  cin >> n >> W;
  for(int i = 0; i < n; i++) cin >> w[i] >> p[i];

  for(int i = 1; i < N; i++) dp[i] = INF;
  dp[0] = 0;

  for(int i = 0; i < n; i++){
    for(int g = N - 1; g >= p[i]; g--){
      if(min(dp[g], w[i] + dp[ g - p[i] ]) <= W) dp[g] = min(dp[g], w[i] + dp[ g - p[i] ]);
    }
  }

  for(int i = N - 1; i >= 0; i--){
    //cout << i << " " << dp[i] << endl;
    if(dp[i] != INF) cout << i << endl, exit(0);
  }
}


Measured memory_bytes: 1024
n = int(input())
arr = list(map(int,input().split()))

nums = list(set(arr))
nums.sort()
last = nums[-1]
from collections import Counter
arr = Counter(arr)
ans = 0

for i in nums:
    if arr[i] == 1:
        ans += 1
    for j in range(last//i+1):
        del arr[i*j]

print(ans)

Measured memory_bytes: 40956
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc,char** argv){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i = 0; i < k ; i++){
    if(i%2 == 0){
      if(a%2 == 1){
        a--;
      }
      a /= 2;
      b += a;
    }else{
      if(b%2 == 1){
        b--;
      }
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
t1=[int(_) for _ in input().split()]
m=int(input())
t2=[]
for i in range(m):
    s=input().split()
    t2.append(sum(t1)-t1[int(s[0])-1]+int(s[1]))
for i in range(m):
    print(t2[i])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{    
    fastinput;
    LL n,i,j;
    LL cnt=0;
    map<LL,LL> freq;
    cin>>n;
    for(i=1;i<=n;i++)
    {        
        cin>>j;
        cnt+=freq[i-j];
        freq[i+j]++;
    }
    cout<<cnt<<endl;    
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll cal(ll n)
{
    return (n * (n + 1) / 2);
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
<>>><<><<<<<>>><
    */
    string s;
    cin >> s;
    ll i = 0;
    ll res = 0;
    bool f = 0;
   // ll preopen = 0, preclose = 0;
    while(i < s.size())
    {
        ll j;
        ll open = 0;
        ll close = 0;
        j = i;
        while(s[j] == '<' && j < s.size())
        {
            j++;
            open++;
        }
        while(s[j] == '>' && j < s.size())
        {
            j++;
            close++;
        }
        res += cal(max(open, close)) + cal(min(open, close) - 1);
        i = j;
       // preopen = open;
       // preclose = close;
        //cout << res << " " << i << endl;sp;
    }
    cout << res;
    return 0;
}


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

int main() {
  string S;
  cin>>S;
  long long w=0LL,sum=0LL;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='W'){
      w++;
      sum+=i;
    }
  }
  if(w==S.size()||w==0LL)
    cout<<"0"<<endl;
  else
    cout<<sum-w*(w-1LL)/2LL<<endl;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <cstdio>
const int MAXN = 1e5+5;
int cnt[MAXN];
int H[MAXN];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &H[i]);
  }
  int ret = 0;
  cnt[N-1] = 0;
  for (int i = N-2; i >= 0; --i) {
    if (H[i] >= H[i+1]) {
      cnt[i] = cnt[i+1] + 1;
      ret = std::max(cnt[i], ret);
    } else {
      cnt[i] = 0;
    }
  }
  printf("%d\n", ret);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  int H=0;
  int M;
  for(int i=0;i<N;i++){
    cin >> M;
    if(M>=H){
      H=M;
      sum++;
    }
    else{
    }
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  t=s
  s=list(s)
  s.reverse()
  s=''.join(s)
  s=s.replace('b','1')
  s=s.replace('d','2')
  s=s.replace('p','3')
  s=s.replace('q','4')
  s=s.replace('1','d')
  s=s.replace('2','b')
  s=s.replace('3','q')
  s=s.replace('4','p')
  if s==t:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 6736
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int a,b,c;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int h,n;
  cin>>h>>n;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  int temp = h;
  REP(i,n){
    temp -= a[i];
    if(temp <= 0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    ll ans = 0;
    // init
    ll ac = ((N - M) * 100) * (pow(2, M));
    ll tle = (pow(2, M) * 1900) * M;
    ans = ac + tle;
    cout << ans << endl;
    return (0);
}

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

ll lcmOf2(int a,int b=360)
{
	int Max=max(a,b);
	ll lcm=Max;
	while(lcm%a!=0 || lcm%b!=0)
	{
		lcm+=Max;
	}
	return lcm;
}

int main()
{
	int x;
	cin>>x;
	
	ll lcm=lcmOf2(x);
	
	cout<<lcm/x<<endl; 
	
	return 0;   
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
P dequeue(){
  P x = Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  if(a>b)return b;
  else return a;
}
int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s %d",Q[i].name,&Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d, h;
  h = 0;
  in3(a, b, c);
  in(d);
  if(abs(a - c) <= d)
    h++;
  else if(abs(a - b) <= d && abs(b - c) <= d)
    h++;
  if(h)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)
func main(){
	var n int
	fmt.Scan(&n)
	l := make([] int,n)
	
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}
	count := 0
	Max := 0
	for i := 0; i < n; i++ {
		count = count + l[i]
		Max = int(math.Max(float64(Max),float64(l[i])))
	}
	ans := 0
	ans = count - Max
	//fmt.Println(ans)
	if Max < ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 512
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

double get_angle(double h, double m)  {    
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    double ha = 0.5 * (h * 60 + m);  
    double ma = 6 * m;  
  
    double ang = abs(ha - ma);  
    ang = min(360 - ang, ang);  
    return ang;
}  

int main() {
	double a, b, h, m;
	double pi = 3.141592653589793238;
	cin>>a>>b>>h>>m;
	
	double angle = get_angle(h, m) * pi / 180 ;
	double csq = a*a + b*b - 2*a*b*cos(angle);
	printf("%.9lf\n", sqrt(csq));
    return 0;
}



Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
const int mod = 1e9+7;
ll arr[N],pref[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	for (int i = 1 ; i <=n ; i++)
		pref[i] = (pref[i-1]%mod+arr[i]%mod)%mod;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		ans = (ans%mod + (arr[i]%mod*(pref[n]-pref[i]+mod)%mod)%mod)%mod;
	cout << ans;
	return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF 100000000

struct P {
    int x, y, t, ignore;
    bool operator >(const P& p) const {
        return ignore > p.ignore;
    }
};

const int dx[] = {0,1,1,0,-1,-1,0},
          dy[][7] = {{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};

int G[201][201][6];
bool obstacle[201][201];

int main() {
    int ix, iy, ox, oy;
    cin >> ix >> iy >> ox >> oy;
    ix += 100;
    iy += 100;
    ox += 100;
    oy += 100;
    int n;
    cin >> n;
    REP(i, n) {
        int x, y;
        cin >> x >> y;
        x += 100;
        y += 100;
        obstacle[y][x] = true;
    }
    int W, H;
    cin >> W >> H;

    fill_n((int *)G, 201*201*6, INF);

    priority_queue<P, vector<P>, greater<P>> que;
    que.push({ix, iy, 0, 0});
    G[iy][ix][0] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();

        if (p.x == ox && p.y == oy) {
            cout << p.ignore << endl;
            return 0;
        }

        int order = abs((p.x-100) * (p.y-100) * p.t) % 6;
        REP(i, 7) {
            int sx = p.x + dx[i];
            int sy = p.y + dy[abs(p.x-100)%2][i];
            if (-W <= sx-100 && sx-100 <= W && -H <= sy-100 && sy-100 <= H) {
                if (!obstacle[sy][sx]) {
                    int t = (p.t+1) % 6;
                    int ignore = p.ignore + (i == order ? 0 : 1);
                    if (G[sy][sx][t] > ignore) {
                        G[sy][sx][t] = ignore;
                        que.push({sx, sy, p.t+1, ignore});
                    }
                }
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long a,b,c;
  vector<set<pair<long,long> > >tree(n+1);
  for(int i=0;i<n-1;i++){
    cin >> a >> b >> c;
    tree[a].insert(make_pair(b,c));
    tree[b].insert(make_pair(a,c));
  }
  vector<long>distance(n+1,-1);
  int q,k;
  cin >> q >> k;
  distance[k] = 0;
  queue<int>que;
  que.push(k);
  while(!que.empty()){
    int tmp = que.front();
    que.pop();
    for(auto p: tree[tmp]){
      int dest = p.first;
      int dist = p.second;

      if(distance[dest] == -1){
        distance[dest] = distance[tmp] + dist;
        que.push(dest);
      }
    }
  }
  int x[q];
  int y[q];
  for(int qq = 0;qq<q;qq++){
    cin >> x[qq] >> y[qq];
  }
  for(int i=0;i<q;i++){
    cout << distance[x[i]] + distance[y[i]] << endl;
  }
  
}


Measured memory_bytes: 20608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0; char ch=gc(); bool positive=1;
	for (;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for (;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(int a){
    if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	if(a<0){
		a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=3,mod=1000000007;
struct matrix{
	int a[N][N];
	inline int* operator [] (int x){
        return a[x];
    }
	void clear(){
    	memset(a,0,sizeof(a));
	}
}zs,ans,md;
matrix operator *(matrix a,matrix b){
	matrix tmp; tmp.clear();
	
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){tmp[i][j]=(tmp[i][j]+(ll)a[i][k]*b[k][j])%mod;
			}
		}
	}
	return tmp;
}
matrix ksm(matrix zs,int k){
	matrix ans; ans.clear(); for(int i=0;i<3;i++)ans[i][i]=1;
	for(;k;k>>=1){
		if(k&1)ans=ans*zs;
		zs=zs*zs;
	}
	return ans;
}
int n,m,a[100005];
int main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++)a[i]=read()+1;
	zs[0][0]=1; zs[0][1]=2;
	zs[0][2]=1; zs[1][1]=1; zs[1][2]=1;
	zs[2][0]=1; zs[2][1]=2; zs[2][2]=2;
	md=zs; md[2][0]=md[2][1]=0; md[2][2]=1;
	for(int i=0;i<3;i++)ans[i][i]=1;
	for(int i=1;i<=m;i++){
		ans=ans*ksm(zs,a[i]-a[i-1]-1);
		ans=ans*md;
	}
	//cout<<ans[0][0]<<" "<<ans[0][1]<<" "<<ans[0][2]<<endl;
	ans=ans*ksm(zs,n-a[m]);
	cout<<ans[0][2]<<endl;
}


Measured memory_bytes: 640
s = list(input())
t = list(input())
n = len(s)
sp = []
tp = []
for i in range(n):
    if not s[i] in sp:
        sp.append(s[i])
    x = sp.index(s[i])
    if not t[i] in tp:
        tp.append(t[i])
    y = tp.index(t[i])
    
    if x != y:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 6704
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  vector<int> v(n);
  REP(i,n){
    cin >> v[i];
  }

  int ans = 0;
  REP(i,n){
    if(v[i] >= k)
      ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MAX 100100
#define MAXN 110

int pd[MAX][3];
int a[MAXN];
int n, k;

int solve(int rest, int jog){
	int otro = (jog+1)%2;
	
	if(rest <= 0) return otro;
	
	
	if(pd[rest][jog] != -1) return pd[rest][jog];
	
	for(int i = 1; i <= n; i++){
		if(rest-a[i] >= 0 && solve(rest-a[i], otro) == jog) return pd[rest][jog] = jog;
	}
	return pd[rest][jog] = otro;
}

int main (){
	int i;
	cin >> n >> k;
	
	for(i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(i = 0; i <= k; i++){
		pd[i][0] = -1;
		pd[i][1] = -1;
	}
	
	if(solve(k,0)==0) cout << "First" << endl;
	else              cout << "Second" << endl;
	
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back

#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const double pi=acos(-1);
const int N=2e5+10;
int n,a[N];
void solve()
{
    cin>>n;
    rep(i,2,n)
    {
        int x;
        scanf("%d",&x);
        a[x]++;
    }
    rep(i,1,n) printf("%d ",a[i]);
}
int main()
{
	//int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;
int main() {
	ll a[1000];
	for (ll i = 0; i <= 2; ++i) {
		cin >> a[i];
	}
	ll sum = 0;
	sort(a, a + 3);
	if (a[0] % 2 == 0 && a[1] % 2 == 0 && a[2] % 2 == 0) {
		sum += (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 0 && a[1] % 2 == 1 && a[2] % 2 == 0) {
		a[0] = a[0] + 1;
		a[2] = a[2] + 1;
		sum += 1 + (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 0 && a[1] % 2 == 0 && a[2] % 2 == 1) {
		a[0] = a[0] + 1;
		a[1] = a[1] + 1;
		a[2] = sum += 1 + (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 0 && a[1] % 2 == 1 && a[2] % 2 == 1) {
		a[2] = a[2] + 1;
		a[1] = a[1] + 1;
		a[2] = sum += 1 + (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 1 && a[1] % 2 == 0 && a[2] % 2 == 0) {
		a[2] = a[2] + 1;
		a[1] = a[1] + 1;
		a[2] = sum += 1 + (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 1 && a[1] % 2 == 1 && a[2] % 2 == 0) {
		a[0] = a[0] + 1;
		a[1] = a[1] + 1;
		a[2] = sum += 1 + (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 1 && a[1] % 2 == 0 && a[2] % 2 == 1) {
		a[0] = a[0] + 1;
		a[2] = a[2] + 1;
		a[2] = sum += 1 + (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}
	else if (a[0] % 2 == 1 && a[1] % 2 == 1 && a[2] % 2 == 1) {
		sum += (a[2] - a[1]) / 2 + (a[2] - a[0]) / 2;
		cout << sum << endl;
	}




}

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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int main(void){
    int q;
    scanf("%d", &q);
    int l[q], r[q];
    for(int i = 0;i < q;i++){
        scanf("%d %d", &l[i], &r[i]);
    }
    int c[100001];
    int prime[66] ={2,3,5,7,11,13,17,19,23,29,
    31,37,41,43,47,53,59,61,67,71,
    73,79,83,89,97,101,103,107,109,113,
    127,131,137,139,149,151,157,163,167,173,
    179,181,191,193,197,199,211,223,227,229,
    233,239,241,251,257,263,269,271,277,281,
    283,293,307,311,313, 317};
    c[0] = 0;
    c[1] = 0;
    for(int i = 2;i < 100001;i++){
        int j = 0;
        while(1){
            if(i < prime[j]*prime[j]){
                c[i] = 1;
                break;
            }
            if(i%prime[j]==0){
                c[i] = 0;
                break;
            }
            j++;
        }
    }
    int cc[100001];
    int count = 0;
    for(int i = 0;i < 100001;i++){
        if(c[i] == 1 && c[(i+1)/2] == 1){
            count++;
        }
        cc[i] = count;
    }
    for(int i = 0;i < q;i++){
        printf("%d\n", cc[r[i]]-cc[l[i]-1]);
    }
    return 0;
}

Measured memory_bytes: 2176
N = int(input())
A = list(map(int,input().split(' ')))
B = list(map(int,input().split(' ')))
C = list(map(int,input().split(' ')))

before = -1
sum_happy = 0

for a in A:
    sum_happy += B[a - 1]
    if a == before+1:
        sum_happy += C[a - 2]
    before = a

        
print(sum_happy)
        

Measured memory_bytes: 3060
import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N = int(input())
A = list(map(int, input().split()))

if gcd_list(A) != 1:
    print('not coprime')
    exit()

primes = set()
for a in A:
    len_primes = len(primes)
    divs = set(prime_factorize(a))
    primes |= divs

    if len(primes) != len_primes + len(divs):
        print('setwise coprime')
        exit()

print('pairwise coprime')


Measured memory_bytes: 183916
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define int long long

const int maxn = (2e5 + 12);
int n, a[maxn], cnt[maxn], ans;

int32_t main() {
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		ans += (cnt[i] * (cnt[i] - 1)) / 2;
	}
	for (int i = 0; i < n; i++) {
		cout << ans - ((cnt[a[i]] - 1)) << '\n';
	}
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector> 
#include<map> 
using namespace std;
#define mid 1000000007  
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=b)
	cout<<"unsafe";
	else
	cout<<"safe";
	return 0; 
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n; 
	scanf("%d",&n);
	int a=0,b=0,c=0,x;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		if(x%4==0)
			a++;
		else if(x%2==0)
			b++;
		else
			c++;
	}
	a-=c;
  	if(a>=0||(a==-1&&b==0)) 
	  	printf("Yes");
  	else	
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#define FASTIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//#define BZ
//#define PBDS
//#define POINT

#ifndef BZ
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("no-stack-protector")
#pragma GCC target ("tune=native")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("conserve-stack")
//#pragma GCC optimize ("no-stack-limit")
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
//using xll = __int128_t;
using str = string;
using pll = pair<ll, ll>;

#ifdef POINT
using point = complex<ll>;
#define x real
#define y imag
#endif

#ifdef PBDS
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//using namespace __gnu_pbds::detail;
template <class T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif

#define INF 0x7fffffffffffffffLL
#define BASE 1000000007LL // 3 * 10**9 + 19 // 998244353 - rev == pow(n + m, BASE - 2)
#define MAX(type) std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()

#define LOG(v) cout << #v << " " << v << "\n";

#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define forEach(c) for (auto &it : c)
#define loop while (true)
#define mp make_pair
#define mt make_tuple

template <class T>
void chMax(T &a, T b) {
	if (a < b) a = b;
}

template <class T>
void chMin(T &a, T b) {
	if (b < a) a = b;
}

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

void solve() {
	string s;
	cin >> s;
	string t = s;
	reverse(t.begin(), t.end());
	ll cnt = 0;
	for (ll i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt / 2 << "\n";
}

//#define LOCAL

int main() {
	FASTIO
#ifdef LOCAL
	auto start = std::chrono::system_clock::now();
#endif
	solve();
#ifdef LOCAL
	auto end = std::chrono::system_clock::now();
	std::chrono::duration<ld> elapsed_seconds = end - start;
	cerr << "\ntime: " << elapsed_seconds.count() << " s\n";
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1001001001;
string S,T;
int dp[1001][1001];

int main(){
    cin>>S>>T;
    for(int i=0;i<=S.size();i++)for(int j=0;j<=T.size();j++)dp[i][j]=INF;

    for(int i=0;i<=T.size();i++)dp[0][i]=i;
    for(int i=0;i<=S.size();i++)dp[i][0]=i;

    for(int i=0;i<S.size();i++){
        for(int j=0;j<T.size();j++){
            dp[i+1][j+1]=min(dp[i][j],min(dp[i+1][j],dp[i][j+1]))+1;

            if(S[i]==T[j])dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]);

        }
    }


    cout<<dp[S.size()][T.size()]<<endl;
    return 0;
}

Measured memory_bytes: 5100
import math
A, B, H, M = map(int, input().split())
ha = H * 30 + M * 0.5
ma = M * 6
angle = abs(ha - ma)
if angle > 180:
    angle = 360 - angle
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(angle))))

Measured memory_bytes: 9512
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll a,b;cin>>a>>b;
  a--;
  if(a<0)a++;
  vl sa,sb;
  ll i=0;
  while(a>=pow(2,i)){
    ll p=pow(2,i);
    //cout<<p<<endl;
    if(i==0){
      if(a%4==1||a%4==2)sa.push_back(1);
      else sa.push_back(0);
      i++;
      continue;
    }
    if((a/p)%2==0)sa.push_back(0);
    else if(a%2==1)sa.push_back(0);
    else sa.push_back(1);
    i++;
  }
  
  i=0;
  while(b>=pow(2,i)){
    ll p=pow(2,i);
    //cout<<p<<endl;
    if(i==0){
      if(b%4==1||b%4==2)sb.push_back(1);
      else sb.push_back(0);
      i++;
      continue;
    }
    if((b/p)%2==0)sb.push_back(0);
    else if(b%2==1)sb.push_back(0);
    else sb.push_back(1);
    i++;
  }
  
  ll la=sa.size(),lb=sb.size();
  vl ans;
  //rep(j,la)cout<<sa[j]<<" ";
  //cout<<endl;
  rep(j,lb){
    if(j<la&&sa[j]!=sb[j]){
      ans.push_back(1);
    }
    else if(j<la){
      ans.push_back(0);
    }
    else if(sb[j]==1){
      ans.push_back(1);
    }
    else ans.push_back(0);
  }
  reverse(ans.begin(),ans.end());
  ll fa=0;
  rep(j,lb){
    fa*=2;
    fa+=ans[j];
  }
  cout<<fa<<endl;
  cout<<endl;
}

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();
    long m = 0;
    long a = 0;
    long r = 0;
    long c = 0;
    long h = 0;
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      if (s.charAt(0) == 'M') m++;
      if (s.charAt(0) == 'A') a++;
      if (s.charAt(0) == 'R') r++;
      if (s.charAt(0) == 'C') c++;
      if (s.charAt(0) == 'H') h++; 
    }
    long ans = 0;
    if (m > 0) {
      ans += (m * a * r) + (m * a * c) + (m * a * h) + (m * r * c) + (m * r * h) + (m * c * h);
    }
    if (a > 0) {
      ans += (a * r * c) + (a * r * h) + (a * c * h);
    }
    if (r > 0) {
      ans += (r * c * h);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 45412
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int n; cin >> n;
    cout << 180 * (n-2) << endl;
}


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

int main(){
    string str;
    cin >> str;
    int ans = 0;
    for(int i = 0; i < str.length(); i++){
        if(i % 2 == 0){//g
            if(str[i] == 'p'){
                ans--;
            }
        }else{//p
            if(str[i] == 'g'){
                ans++;
            }
        }
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
#define ERASE(a)  (a).erase(unique((a).begin(), (a).end()), (a).end()); // sortしてから
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int x; cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		
		int sum = a.length() + b.length() + c.length();
		
		int flag = 0;
		
		int f_a = 0;
		int f_b = 0;
		int f_c = 0;
		
		for(int i = 0 ; i < sum ; i++){
			
			if(flag == 0){
				
				if(f_a == a.length()){
					
					System.out.println("A");
					break;
				}
				
				if(a.charAt(f_a) == 'a'){
					flag = 0;
				} else if(a.charAt(f_a) == 'b'){
					flag = 1;
				} else if(a.charAt(f_a) == 'c'){
					flag = 2;
				}
				
				f_a++;
				
			
			} else if(flag == 1){
				
				if(f_b == b.length()){
					
					System.out.println("B");
					break;
				}
				
				if(b.charAt(f_b) == 'a'){
					flag = 0;
				} else if(b.charAt(f_b) == 'b'){
					flag = 1;
				} else if(b.charAt(f_b) == 'c'){
					flag = 2;
				}
				
				f_b++;
				
			
			} else if(flag == 2){
				
				if(f_c == c.length()){
					
					System.out.println("C");
					break;
				}
				
				if(c.charAt(f_c) == 'a'){
					flag = 0;
				} else if(c.charAt(f_c) == 'b'){
					flag = 1;
				} else if(c.charAt(f_c) == 'c'){
					flag = 2;
				}
				
				f_c++;
				
			}
			
		}
	}
}


Measured memory_bytes: 10068
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define ok puts("OK");

using namespace std;

const int N = 3e3 + 5;

int a, b, c, d, e, f, u[N][N], res, cur;

double ans;

void dfs (int v, int x)
{
    u[v][x] = 1;

    if ( v + a * 100 + x <= f && !u[v + a * 100][x])
        dfs(v + a * 100, x);

    if ( v + b * 100 + x <= f && !u[v + b * 100][x])
        dfs(v + b * 100, x);

    if ( v + x + c <= f && e * (v / 100) >= x + c && !u[v][x + c])
        dfs(v, x + c);

    if ( v + x + d <= f && e * (v / 100) >= x + d && !u[v][x + d])
        dfs(v, x + d);
}

main ()
{
    cin >> a >> b >> c >> d >> e >> f;
    dfs(0, 0);
    for (int i = 0; i <= f; i++)
    {
        for (int j = 0; j <= f; j++)
        {
            double x = i, y = j;

            if (u[i][j] && ans < (x + y) / x)
            {
                ans = (x + y) / x;
                cur = i;
                res = j;
            }
        }
    }
    cout << cur + res << " " << res << endl;
}


Measured memory_bytes: 28928
n, m = map(int, input().split())
B=[]
D={}
switch = 0
ans = 0
#写像の集合をかぶらないように作る
#かぶったらその時点で-1
if n==1:
	switch+=1
	for i in range(m):
		a, b = map(int, input().split())
		B.append(b)
	if len(set(B))>=2:
		print(-1)
	elif len(B)==0:
		print(0)
	else:
		print(B[0])

if n>=2:
	for i in range(m):
		a, b = map(int, input().split())
		if a==1 and b==0:
			print(-1)
			switch+=1
			break
		if a in D:
			for s in D:
				if a == s and b != D[s]:
					print('-1')
					switch+=1
					break
		else:
			D[a]=b
for a in D:
	ans+=D[a]*10**(n-a)

if switch==0:
	if 10**(n-1)>ans:
		print(ans+10**(n-1))
	else:
		print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
public class Main{
   
   static long knapsack(long [] ww,long [] vv,int n,int w,long [][] dp){
     if(n==0){
       return 0;
     }
     if(dp[n][w]>0){
       return dp[n][w];
     }

     long in=-1;
     if(w-ww[n-1]>=0)
         in=vv[n-1]+knapsack(ww, vv, n-1,w-(int)ww[n-1],dp);

    long ex=knapsack(ww, vv, n-1,w,dp);

    return dp[n][w]=Math.max(in,ex);

   }
   public static void main(String [] args){

     Scanner sc=new Scanner(System.in);
     int n=sc.nextInt();
     int w=sc.nextInt();

     long [] ww=new long[n];
     long [] vv=new long[n];

     for(int i=0;i<n;i++){
       ww[i]=sc.nextLong();
       vv[i]=sc.nextLong();
     }

     long cost=knapsack(ww, vv, n,w,new long [n+1][w+1]);

     System.out.println(cost);

    }
   }
 

Measured memory_bytes: 127700
#include<bits/stdc++.h>
using namespace std;
#define maxn 10005
#define mo 1000000007
int a[maxn],inv[1000005],num[1000005];
void Inverse(int p,int a[],int n){ 
    a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=1ll*(p-p/i)*a[p%i]%p;
    }
}
int main(){
	int n,x,w,sum=1,ans=0;scanf("%d",&n);
	Inverse(mo,inv,1000000);
	for(int i=0;i<n;i++){
		scanf("%d",a+i),x=a[i];
		for(int j=2;j*j<=x;j++){
			w=0;while(x%j==0)x/=j,w++;
			num[j]=max(w,num[j]);
		}
		if(x)num[x]=max(1,num[x]);
	}
	for(int j=2;j<=1000000;j++){
		for(int k=0;k<num[j];k++)sum=1ll*sum*j%mo;
	}
	for(int i=0;i<n;i++){
		(ans+=1ll*sum*inv[a[i]]%mo)%=mo;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 7808
#include <stdio.h>
int nge(int* o,int* p)
{
  int k;

  k=*o;
  *o=*p;
  *p=k;
}

int main(void)
{
  int a,c,d,e,x,y;
  int f[3000][2];

  for(a=0;a<=2999;a++){
    e=a;
    scanf("%d",&c); scanf("%d",&d);
    
    if(d+c==0) goto OUT;

    if(d<c)
      nge(&c,&d);
    
    f[a][0]=c;
    f[a][1]=d;
  }
  OUT:
  
  for(a=0;a<=e-1;a++)
    printf("%d %d\n",f[a][0],f[a][1]);

  return(0);
}

Measured memory_bytes: 2712
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	int N;
	cin >> N;
	
	map<char, int> smap;
	int counter = 0;
	char pre = ' ';
	for (int i = 0; i < N; ++i)
	{
		char tmp;
		cin >> tmp;
		if (pre != tmp)
		{
			counter += 1;
		}

		pre = tmp;
	}

	cout << counter;

}

Measured memory_bytes: 384
# include <iostream>

using namespace std;

# define N_MAX 100
# define M_MAX 100

int main(){
  int T[N_MAX], P[M_MAX], X[M_MAX];
  int t, N, M, T_sum;

  cin >> N;

  T_sum = 0;
  for(int n=0; n < N; n++){
    cin >> t;
    T_sum += t;
    T[n] = t;
  }

  cin >> M;

  for(int m=0; m < M; m++) {
    cin >> P[m] >> X[m];
  }

  for(int m = 0; m < M; m++) {
    cout << (T_sum - T[P[m]-1] + X[m]) << endl;
  }

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> card(N);

    for (size_t i = 0; i < N; i++)
    {
        cin >> card[i];
    }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());

    int Alice = 0, Bob = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (i & 1 == 1)
        {
            Bob += card[i];
        }
        else
        {
            Alice += card[i];
        }
    }

    int res = Alice - Bob;
    cout << res << endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define gg exit(0);

main(){
    #define task "TASK"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    fasty;
    int n; cin>>n;
    long long ret=0;
    vector<vector<int>> f(50,vector<int>(20));
    while(n--){
        string s; cin>>s;
        int mul=9;
        if(s.find(".")!=string::npos) mul=10-s.size()+s.find(".");
        long long num=0;
        forv(ch,s) if(ch!='.') num=num*10+ch-'0';
        while(mul--) num*=10;
        int two=0,five=0;
        while(num%2==0) two++, num/=2;
        while(num%5==0) five++, num/=5;
        forinc(i,0,49) forinc(j,0,19) if(min(i+two,j+five)>=18) ret+=f[i][j];
        f[two][five]++;
    }
    cout<<ret;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int z,b,f;
int main(){
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        if(x%4==0){
            f++;
        }
        else if(x%2==0){
            b++;
        }
        else{
            z++;
        }
    }
    if(b==0&&f>=z-1){
        cout << "Yes" << endl;
    }
    else if(f>=z){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        x:i32,
    }
    let ans = if x >= 30 { "Yes" } else { "No" };
    println!("{}", ans);
}

Measured memory_bytes: 2128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func f(n int) int {
	if n%2 == 1 {
		return 3*n + 1
	}
	return n / 2
}

func main() {
	s := nextInt()
	already := map[int]bool{}
	already[s] = true

	i := 1
	for {
		i++
		s = f(s)
		if already[s] {
			fmt.Println(i)
			return
		}
		already[s] = true
	}
}


Measured memory_bytes: 640
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    d = sorted(map(int, input().split()))

    print(d[n // 2] - d[n // 2 - 1])


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 44988