akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define ll long long

int main(void){
    ll n, k;
    cin >> n >> k;
    ll p[n];
    double sum[n];
    double ans[n];
    for(ll i = 0; i < n; i++){
        cin >> p[i];
        ans[i] = (double(p[i])+1)*0.5;
        if(i > 0)
            sum[i] = sum[i-1] + ans[i];
        else
            sum[i] = ans[i];
    }
    double MAX = sum[k-1];
    for(ll i = k; i < n; i++)
        MAX = max(MAX, sum[i]-sum[i-k]);
    cout << fixed << setprecision(10) << MAX << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    int l = 0, r = 0;
    string ans;
    for(int i=0; i<n; i++){
        if(s.at(i)=='(') r++;
        else{
            if(r==0){
               l++; 
            }
            else r--;
        }
    } 

    for(int i=0; i<l; i++){
        ans += '(';
    }

    ans += s;

    for(int i=0; i<r; i++){
        ans += ')';
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int ans[6][20] = {
	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
	{1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
	{0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 36, 108, 220, 334, 384, 0, 0, 0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 0, 976, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001}};

int g[110];
inline void init(){
	For(i,2,100)
		FOR(j,1,i) if ((1ll<<j)-i>=g[j]){
			g[i]=j;break;
		}
}
inline int G(ll n){
	if (n<=100) return g[n];
	for (int i=1;;i++) if ((1ll<<i)-n>=G(i)) return i;
}
inline int solve(ll n,ll k){
	if (n<k) swap(n,k);
	if (k<63&&(1ll<<k)-n<n) return solve((1ll<<k)-n,k);
	if (k>5) return 1001;
	return ans[k][n];
}

int main(){
	ll n=read();
	init();
	int ans=solve(n,G(n))+(n==4)+(n==7)*2;
	printf("%d\n",ans>1000?-1:ans);
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  int n,m;
  string s,t;
  cin>>s;
  if(s[0]>='A' and s[0]<='Z')cout<<"A"<<endl;
  else cout<<"a"<<endl;


  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    int N;
    std::cin >> N;

    priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> students;
    int tmp = 0, index = 1;

    for (int i = 0; i < N; ++i)
    {
        std::cin >> tmp;
        students.push({tmp, index++});
    }

    while (!students.empty())
    {
        std::cout << students.top().second << " ";
        students.pop();
    }

    std::cout << std::endl;

    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll N, A, B;
vector<ll> H;

// 余剰である場合、真
bool check(int v){
    ll sa = A - B;
    ll ret = 0;
    for(int i = 0; i < N; i++) {
      ll zanHP = H[i] - v * B;
      if(zanHP > 0) ret += (zanHP + sa - 1) / sa;
    }
    return (ret <= v);
}

int main(){
    cin >> N >> A >> B;

    H.resize(N);
    REP(i,N) cin >> H[i];
 
    int l = 0, h = 1 << 30;
    while(h - l > 0) {
        int m = (l + h) / 2;
        if(check(m)) h = m;
        else l = m + 1;
    }
    cout << l << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MX = 1e6+10;
int main(){
	vector<int> div(MX, 0);
	int n; cin>>n;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		div[x]++;
	}
	for(int i=1;i<MX;i++){
		if(div[i]){
			for(int j=i+i; j<MX; j+=i){
				div[j]=0;
			}
		}
	}
	int ret=0;
	for(int i=1;i<MX;i++){
		if(div[i]==1) ret++;
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (100005);
#if !testing
	#define cerr if(0)cout
#endif
int dp[20005];
int32_t main() {
	IAMSPEED
	memset(dp,0,sizeof dp);
	int a,b,c; cin >> a >> b >> c;
	int v; cin >> v;
	set <tuple<int,int,int> > s;
	FOR(i,0,a) {
		FOR(j,0,b) {
			FOR(k,0,c) {
				if (i*500 + j*100 + k*50 == v) {
					s.insert(make_tuple(i,j,k));
				}
			}
		}
	}
	cout << s.size();
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int kans(int a){
    if(a%2==0){
        return a/2;
    }else{
        return 3*a+1;
    }
}
using namespace std;
int main(){
    string S;
    cin >> S;

    map<char, int> mp;

    REP(i,S.size()){
        if(S[i] == 0) mp[S[i]] ++;
        else          mp[S[i]] ++;
    }

    int ans = 2;

    ans = ans * min(mp['0'],mp['1']);

    cout << ans << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(void){
int N,M;
cin >> N >> M;
const int NMMAX=50;
int A[NMMAX],B[NMMAX],C[NMMAX],D[NMMAX];

for(int i=0;i<N;++i){
cin >> A[i] >> B[i];
 }

 for(int j=0;j<M;++j){
 cin >> C[j] >> D[j];
 }

 for(int i=0;i<N;++i){
 int min_dist=abs(A[i]-C[0])+abs(B[i]-D[0]),checkpoint=1;

 for(int j=1;j<M;++j){
 const int cur_dist=abs(A[i]-C[j])+abs(B[i]-D[j]);
 if(min_dist>cur_dist){
 min_dist=cur_dist;
 checkpoint=j+1;
 }
 }

 cout << checkpoint << endl;
 }

 return 0;
 }

Measured memory_bytes: 256
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> VecDeque<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    if n == 1 {
        println!("{:?}", a[0]);
        return;
    }

    let mut dp: Vec<Vec<i64>> = vec![vec![0; n]; n];

    for i in 0..n - 1 {
        dp[i][i + 1] = std::cmp::max(a[i], a[i + 1]) - std::cmp::min(a[i], a[i + 1]);
    }

    for w in 2..n {
        for i in 0..n - w {
            let j = i + w;
            dp[i][j] = std::cmp::max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
        }
    }
    println!("{:?}", dp[0][n - 1]);
}


Measured memory_bytes: 90364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

   vector<int> num(N,0);
   int num_max=1;

   for(int i=0;i<N;++i){
      if(H[i]<H[i+1]){
         num[num_max] = i+1;
         num_max++;
      }
   }
   num[num_max] = N;
   int max=0;
   for(int i=0;i<num_max+1;++i){
      if(num[i+1]-num[i]-1>max) max = num[i+1]-num[i]-1;
   }

   cout << max << endl;


}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main(){
   int n,m;
   cin >> n >> m;
   vector<int> miti(n,0);
   rep(i,m){
       int a,b;
       cin >> a >> b;
       miti[a-1]++;
       miti[b-1]++;
   }
   rep(i,n){
       cout << miti[i] << endl;

   }
   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        long h = sc.nextLong();

        long cnt = 0;

        long binary = 1;

        while (h>0){
            cnt += binary;
            binary *= 2;
            h /= 2;
        }

        System.out.println(cnt);

    }
}






Measured memory_bytes: 21844
#include <iostream>

using namespace std;

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

    if(n < 1200)
        cout << "ABC" << endl;
    else if(n < 2800)
        cout << "ARC" << endl;
    else 
        cout << "AGC" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string A, B, C;

  std::cin >> A >> B >> C;

  std::cout << (A.back() == B.front() && B.back() == C.front() ? "YES" : "NO") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> MY(3);
  for (int i=0;i<3;i++){
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  cout << MY.at(2)-MY.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


string SA, SB, SC;
int PA = 0;
int PB = 0;
int PC = 0;
char n = 'a';

bool isFinished() {
    if (n == 'a') {
        return PA >= SA.size();
    } else if (n == 'b') {
        return PB >= SB.size();
    } else if (n == 'c') {
        return PC >= SC.size();
    }
}

int main() {
    cin >> SA >> SB >> SC;
//    DEBUG(SA);
//    DEBUG(SB);
//    DEBUG(SC);

    while (!isFinished()){
//        DEBUG(n);
//        DEBUG(PA);
//        DEBUG(PB);
//        DEBUG(PC);

        if (n == 'a') {
            n = SA[PA];
            PA++;
        } else if (n == 'b') {
            n = SB[PB];
            PB++;
        } else if (n == 'c') {
            n = SC[PC];
            PC++;
        }
    }

    if (n == 'a') {
        cout << 'A' << endl;
    } else if (n == 'b') {
        cout << 'B' << endl;
    } else if (n == 'c') {
        cout << 'C' << endl;
    }
}

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

using namespace std;

long long MOD = 1e9 + 7;

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

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

    std::string s;
    cin >> s;

    for (size_t i = 0; i < s.size(); i++)
    {
        if ((i + 1) % 2 == 0) {
            if (s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }

        if ((i + 1) % 2 == 1) {
            if (s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(void) {
  char s[100];
  scanf("%s", s);
  bool ac = false;
  for (int i = 1; s[i]; ++i) {
    if (s[i - 1] == 'A' && s[i] == 'C') {
      ac = true;
      break;
    }
  }
  puts(ac ? "Yes" : "No");
  return 0;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

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

	if(s == "ARC"){
		cout << "ABC" << endl;
	}else{
		cout << "ARC" << endl;
	}

	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()

int const inf = 1<<29;

bool isDAG(vector<vector<int>>& G) {
  int N = G.size();
  vector<bool> vis(N);

  std::function<bool(int, unordered_set<int>&)> dfs = [&](int curr, unordered_set<int>& st) {
    for(auto&& e: G[curr]) {
      if(st.count(e)) return false;
      if(vis[e]) continue;
      st.insert(e);
      vis[e] = 1;
      if(!dfs(e, st)) return false;
      st.erase(e);
    }
    return true;
  };

  rep(e, N) {
    vis[e] = 1;
    unordered_set<int> st = {e};
    if(!dfs(e, st)) return false;
  }
  return true;
}

int main() {

  int M, N; cin >> M >> N;
  vector<vector<pair<int, int>>> cmd_sect(N, vector<pair<int, int>>(M, {0, inf}));

  rep(cmd_idx, M) {
    int K; cin >> K;
    rep(_, K) {
      int skill; cin >> skill; skill--;
      string op; cin >> op;
      int threshold; cin >> threshold;
      if(op == ">=") {
        cmd_sect[skill][cmd_idx].first = max(cmd_sect[skill][cmd_idx].first, threshold);
      } else {
        cmd_sect[skill][cmd_idx].second = min(cmd_sect[skill][cmd_idx].second, threshold);
      }
      if(cmd_sect[skill][cmd_idx].first > cmd_sect[skill][cmd_idx].second) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  vector<vector<int>> G(M);
  
  rep(i, N) {
    rep(a, M) rep(b, M) {
      if(a == b) continue;
      if(cmd_sect[i][a].second < cmd_sect[i][b].first)
        G[a].push_back(b);
    }
  }

  rep(i, M) {
    sort(all(G[i]));
    G[i].erase(unique(all(G[i])), G[i].end());
  }

  cout << (isDAG(G) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3992
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 1000000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll p2[1000001];
int main()
{
	invinit();
	ll n, m, k;
	scanf("%lld%lld%lld", &n, &m, &k);
	p2[0] = 1;
	for (int i = 1; i <= 1000000; i++)p2[i] = p2[i - 1] * 2 % mod;
	ll nm = 0, nk = 0;
	for (int i = n; i <= n + m; i++)nm = (nm + com(n + m, i)) % mod;
	for (int i = n; i <= n + k; i++)nk = (nk + com(n + k, i)) % mod;
	ll ans = 0;
	for (int s = 0; s <= k; s++)
	{
		ans += p2[k - s] * nm%mod*com(n + m + k, s) % mod;
		ans %= mod;
	}
	for (int s = 0; s <= m; s++)
	{
		ans += p2[m - s] * nk%mod*com(n + m + k, s) % mod;
		ans %= mod;
	}
	ll now = 0;
	for (int t = 0; t <= k; t++)
	{
		now += com(n + m + k - m, t);
		now %= mod;
	}
	for (int s = m; s >= 0; s--)
	{
		ans += mod - (now*com(n + m + k, s) % mod);
		ans %= mod;
		now = (now * 2 + mod - com(n + m + k - s, k));
		now %= mod;
	}
	printf("%lld\n", ans);
}

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

using ll=long long;



void solve(){
    int x;
    cin>>x;

    if(x==7||x==5||x==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    if(N%1000==0){
        cout<<0<<endl;
    }else{
        cout<<1000-N%1000<<endl;
    }
    
}

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

bool check(int S[], int T[], int s, int i)
{
  int middle = s / 2;
  int left = 0;
  int right = s;
  while (left < right)
  {
    if (T[i] == S[middle])
    {
      return true;
    }

    else if (T[i] < S[middle])
    {
      right = middle;
      middle = (right + left) / 2;
    }
    else
    {
      left = middle + 1;
      middle = (left + right) / 2;
    }
  }
  return false;
}

int main(void)
{
  int count = 0;
  int s;
  cin >> s;
  int S[s];
  for (int i = 0; i < s; i++)
  {
    cin >> S[i];
  }

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

  for (int i = 0; i < t; i++)
  {
    count += check(S, T, s, i);
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3676
S=gets.chomp
T=gets.chomp
s = S.chars.map {|c| c == '?' ? '.{1}' : c}

(S.length - T.length).downto(0) do |i|
    if T.match(Regexp.compile(s[i...i+T.length].join))
        s = S
        s[i...i+T.length] = T
        puts s.tr('?','a')
        exit
    end
end

puts 'UNRESTORABLE'

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();	
		int b=sc.nextInt();	
		int c=sc.nextInt();	
		
		int total=a+b+c;
		int min=Math.min(Math.min(a,b),Math.min(b,c));
		int max=Math.max(Math.max(a,b),Math.max(b,c));
		int ans=total-min-max;
		
		int count=0;
		count=max-ans;
		min+=count;
		count+=(max-min)/2;
		if((max-min)%2==1){
			count+=2;
		}
		System.out.println(count);
		sc.close();
	}
}

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

int main(){
	int N;
	cin >> N;
	ll dp[N][3];
	int a[N], b[N], c[N];
	for(int i=0; i<N; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(int i=1; i<N; i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]) << endl;
	return 0;
}

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

#define ll long long

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    ll buf = N / (A+B);
    ans += A*buf;
    buf = N % (A+B);
    if(buf >= A) ans += A;
    else ans += buf;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include <string.h>
#include <math.h>
#include<map>
#include<string.h>
#define ll long long
using namespace std;
ll a,b,c;
int main()
{

    cin>>a>>b>>c;
    cout<<b/c-a/c+(bool)(a%c==0)<<endl;
    return 0;
}


Measured memory_bytes: 888
program atcoder
  implicit none
  integer m
  read *, m    ! 変数mに、標準入力から数字を読み込み代入する

               ! このあたりに、解答を導く計算を書く

  print '(i0)',48-m    !  ","のあとに解答となる変数を書く
end program atcoder

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

const int N = 5e5 + 5;
struct que{
    int l,r,i;
};
int x;
bool comp(que a, que b){
    if(a.l/x!=b.l/x) return a.l/x<b.l/x;
    else return a.r<b.r;
}
int m[500005]={};
int32_t main()
{
    IOS;
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n,q; cin>>n>>q;
        int a[n];
        x=sqrt(n);
        for (int i = 0; i < n; ++i)
        {
            cin>>a[i];
        }
        int ans[q]={};
        vector<que> v;
        for (int i = 0; i < q; ++i)
        {
            int l,r; cin>>l>>r;
            l--; r--;
            v.push_back({l,r,i});
        }
        sort(v.begin(), v.end(),comp);
        int curl=0,curr=-1;
        int cnt=0;
        for (int i = 0; i < q; ++i)
        {
            int l=v[i].l,r=v[i].r;
            // cout<<l<<" "<<r<<"\n";
            while(curl>l){
                curl--;
                m[a[curl]]++;
                if(m[a[curl]]==1) cnt++;
            }
            while(curr<r){
                curr++;
                m[a[curr]]++;
                if(m[a[curr]]==1) cnt++;
            }
            while(curl<l){
                m[a[curl]]--;
                if(m[a[curl]]==0) cnt--;
                curl++;
            }
            while(curr>r){
                m[a[curr]]--;
                if(m[a[curr]]==0) cnt--;
                curr--;
            }
            // cout<<curl<<" "<<curr<<"\n";
            ans[v[i].i]=cnt;
        }
        for (int i = 0; i < q; ++i)
        {
            cout<<ans[i]<<"\n";
        }
    }
    return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  rep(i, n - 1) repi(j, i + 1, n) {
    int c = 0;
    while (!((i ^ j) & bit32(c))) c++;
    cout << c + 1 << (j == n - 1 ? '\n' : ' ');
  }
}


Measured memory_bytes: 512
import java.util.*;

class Main {
  public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
    //int 整数
    int x = sc.nextInt();
    //長さ
    int n = sc.nextInt();
    int minDiff = x;
    int pNot[] = new int[102];
    int ans = 0;
    
    for(int i = 0; i <= 101;i++)
      pNot[i] = 1;
    
    
    for(int i = 0; i < n; i++)
      pNot[sc.nextInt()] = 0;
    
    
    for(int i = 0;i <= 101; i++)
      if(pNot[i] == 1)
        if(minDiff > Math.abs(x - i)){
          minDiff = Math.abs(x - i);
          ans = i;
        }
      
    
    System.out.println(ans);
  }
}


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< pii,vector<pii> ,greater< pii >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}*/
//const int md = 998244353;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/
const int inf = (int) 1e18;
const int md = (int) 1e9+21;


signed main()
{
    showoff;
    int a,b;
    cin >> a >> b;
    cout << max(max(2*a-1,2*b-1),a+b);
    

    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

// ACL
#include <atcoder/all>
using namespace atcoder;
// ACL END

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;

using P = std::pair<int, int>;
using ll = long long;
using ld = double;

// using bint = boost::multiprecision::cpp_int;

template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

const int MOD = 998244353;

struct S{
    modint998244353 v;
    modint998244353 s;
};
using F = long long;


S op(S a, S b){ return {a.v+b.v, a.s+b.s}; }
S e(){ return {0, 0}; }
S ma(F f, S x){
    if(f != 10) x.v = f*x.s;
    return x;
}
F co(F f, F g){ return (f == 10 ? g : f); }
F id(){ return 10; }



// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n,q;
    cin>>n>>q;
    vector<S> a(n);
    rep(i,n)a[i]=S{modint998244353(10).pow(n-i-1),modint998244353(10).pow(n-i-1)};
    lazy_segtree<S,op,e,F,ma,co,id> ls(a);
    rep(i,q){
        int l,r,d;
        cin>>l>>r>>d;
        ls.apply(l-1,r,d);
        cout<<ls.all_prod().v.val()<<endl;
    }
}


Measured memory_bytes: 10892
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(int)(n);(i)++)
#define ll long long
using namespace std;

int i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    int n;
    cin>>n;
    int h[n][3];
    REP0(i,n)cin>>h[i][0]>>h[i][1]>>h[i][2];
    int dp[n+1][3];
    int ans;

    REP0(i,3)dp[0][i]=0;
    
    REP1(i,n){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+h[i-1][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+h[i-1][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+h[i-1][2];
    }

    ans=max(max(dp[n][0],dp[n][1]),dp[n][2]);

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

Measured memory_bytes: 2560
n = int(input())
s = input()
res = 0
for i in range(1,n):
    b,c =(s[:i], s[i:])
    cnt = 0
    for j in range(26):
        p = chr(ord('a') + j)
        cnt += (p in b) and (p in c)
    res = max(res, cnt)
print(res)


Measured memory_bytes: 3060
N,M = list(map(int,input().split()))
SC = [0]*(N+1)
if M == 0:
  if N==1:
    print(0)
    exit()
  else:
    print(1*10**(N-1))
    exit()

for m in range(M):
  sc = list(map(int,input().split()))
  if (sc[0] == 1) and (sc[1] == 0):
    if N==1:
      continue
    else:
      print(-1)
      exit()
  elif sc[0] > N:
    print(-1)
    exit()
  elif SC[sc[0]] == 0:
    SC[sc[0]] = sc[1]
  else:
    if SC[sc[0]] != sc[1]:
      print(-1)
      exit()

if (SC[1]==0) and (N > 1):
  SC[1] = 1
ans = 0
for i in range(N):
  ans += 10**(N-i-1)*SC[i+1]

print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var t = cin.nextInt();
            var a = cin.nextInt();
            var h = cin.ArrayLong(n);

            var ta = h.Select(i => Math.Abs(a - (t - (0.006 * i))));
            Console.WriteLine(ta.ToList().IndexOf(ta.Min())+1);            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<functional>


using namespace std;
using ll = long long;

string hanten(string s){
    string result;
    for(int i=0;i<s.length();i++){
        result += s[s.length()-1-i];
    }
    return result;
}

int main(){
    string s;
    int q;
    cin>>s>>q;
    int t[q],f[q] = {};
    char c[q] = {};

    string sentou,matubi;
    int hantennum = 0;

    for(int i=0;i<q;i++){
        cin>>t[i];
        if(t[i] == 1){
            hantennum++;
            //string tmp = sentou;
            //sentou = matubi;
            //matubi = tmp;
            //hanten(sentou);
            //hanten(matubi);
        }
        if(t[i] == 2){
            cin>>f[i]>>c[i];
            if(hantennum % 2 == 0){
                if(f[i] == 1) sentou = c[i] + sentou;
                else matubi = matubi + c[i];
            }
            else{
                if(f[i] == 2) sentou = c[i] + sentou;
                else matubi = matubi + c[i];
            }
        }
    }
    s = sentou + s + matubi;

    if(hantennum % 2 == 0) cout<<s<<endl;
    else {
        s = hanten(s);
        cout<<s<<endl;
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
#define MAX 200000

bool judge(long *b,long n){
    long t=0;
    bool ok = false;
    rep(i,n){
        t+=b[i];
    }
    rep(i,n){
        
        if(b[i]%2 != (t-b[i])%2){ok = true;break;}
    }
    return ok;
}

int main(){
    long n;
    long a[MAX],b[MAX];
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,50){
        rep(j,n){
            b[j] = (a[j]>> i)%2;
        }
        bool ok = judge(b,n);
        rep(j,n){
            if(ok){
                a[j] ^= (ok << i);
            }
        }
    }

    rep(i,n){
        cout << a[i] << " ";
    }
}

Measured memory_bytes: 6632
#include <stdio.h>
int main(){
  int a[10],i,x,y;
  float f;
  for(;;){
    if((scanf("%d,",&a[0])) == EOF) break;
    for(i=1;i<10;i++){
      scanf("%d,",&a[i]);
      a[i] += a[i-1];
    }
    scanf("%d,%d",&x,&y);
    f = (float)x/(x+y)*a[9];
    i=0;
    while(a[i]<f) i++;
    printf("%d\n",i+1);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int n,MOD,ans;
int a[N],sum[N];
signed main(){
	scanf("%lld%lld",&n,&MOD);
	for (register int i=1; i<=n; ++i) scanf("%1lld",&a[i]);
	if (MOD==2 || MOD==5)
	{
		for (register int i=1; i<=n; ++i) if (a[i]%MOD==0) ans+=i;
		printf("%lld\n",ans);
	}
	else
	{
		sum[0]=1;
		int now=0,base=1;
		for (register int i=n; i>=1; --i)
		{
			now=(now+a[i]*base)%MOD;
			ans+=sum[now];
			sum[now]++; 
			base=base*10%MOD;	
		}
		printf("%lld\n",ans);
	}
return 0;	
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> m = new HashMap<>();
		Set<Integer> d = new HashSet<>();

		long answer = n;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (!m.containsKey(x)) {
				m.putIfAbsent(x, 1);
				continue;
			}

			int c = m.get(x);
			if (c == 1) {
				m.put(x, c + 1);
				d.add(x);
			} else {
				answer -= 2;
				m.put(x, c - 1);
				d.remove(x);
			}
		}

		answer -= d.size();
		if (d.size() % 2 == 1) answer -= 1;
		System.out.println(answer);
	}
}


Measured memory_bytes: 62900
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	
	int cmp (String p1, String p2) {
		if( p1.length() != p2.length() ) return p2.length() - p1.length();
		return p2.compareTo(p1);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h) == 0 ) break;
			
			String[][] dp = new String[h+1][w+1];
			String pass = "";
			char[][] map = new char[h+1][w+1];
			
			for(String[] a: dp) fill(a, "");
			
			for(int i=1;i<=h;i++) {
				String str = sc.next();
				for(int j=1;j<=w;j++) {
					map[i][j] = str.charAt(j-1);
				}
			}
			
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
				if( '0' <= map[i][j] && map[i][j] <= '9' ) {
					if( map[i][j] == '0' && dp[i-1][j].equals("") && dp[i][j-1].equals("") ) continue;
					dp[i][j] = ( cmp(dp[i-1][j], dp[i][j-1])<0? dp[i-1][j]: dp[i][j-1] ) + (char)map[i][j];
				}
				pass = cmp(pass, dp[i][j])<0? pass: dp[i][j];
			}
			
			System.out.println(pass);
			
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
#include <iostream>

using namespace std;
int main() {
    int unsigned long a, b, x;
    cin >> a >> b >> x;
    //unsigned long a[m], d[n][m];
    
    int unsigned long a_mod = a % x;
    
    if (a_mod != 0) {
        a += (x - a_mod);
    }
    b -= b % x;
        
    if (a > b) {
        cout << 0 << endl;
    } else {
        cout << (b-a) / x + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
rank = []
for i in range(N):
  name, point = input().split(" ")
  rank.append({
    "name": name,
    "point": 100 - int(point),
    "id": i + 1
  })

rank.sort(key = lambda x: (x["name"], x["point"]))
print("\n".join(list(map(lambda r: str(r["id"]), rank))))

Measured memory_bytes: 9168
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

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

	ll ans = 0;
	for (int i = 0; i < N; i++){
		ans += A[i] -1;
	}

	cout<<ans;



}	


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <time.h>
using namespace std;

#define LL long long 
#define clr(x) memset(x,0,sizeof(x))
#define eps 1e-6
#define PI 3.1415926535897932384626433832795028          
#define MAXN 105

struct number{
   
	LL p,t,v;
    double c[MAXN];
	double ps[MAXN];

}mem[MAXN];

LL c[55][55];

void C()
{
	 for(LL i = 0;i < 55; i++ )
	       c[0][i]=1;
	 for(LL i = 1;i < 55; i++ )
	 {
		 for(LL j = i;j < 55; j++ )

			 c[i][j]=c[i-1][j-1]+c[i][j-1];
		 
	 }
	 
}

int main()
{

	LL n,m,l,p,t,v;
	C();
	while(scanf("%lld%lld%lld", &n, &m, &l)!=EOF)
	{
		 for(LL i = 0 ;i < n; i++ )
		 {
			 scanf("%lld%lld%lld", &mem[i].p, &mem[i].t, &mem[i].v); 
			 
			 mem[i].c[0]=l*1.0/mem[i].v;
			 for(int j = 1 ;j <= m; j++)
			 {
				mem[i].c[j]+=mem[i].t+mem[i].c[j-1];
			 }
            mem[i].ps[0]=c[0][m]*pow(mem[i].p/100.0,0.0)*pow(1.0-mem[i].p/100.0,m*1.0);
			for(int j = 1; j <= m; j++ )
				mem[i].ps[j]=c[j][m]*(double)pow(mem[i].p/100.0,j*1.0)*pow(1.0-mem[i].p/100.0,(m-j)*1.0);
			//for(int j = 0; j <= m; j++ )
				//printf("%lf ",mem[i].ps[j]);
		 }

		  for(LL i = 0; i< n ; i++ )
		  {
			  double tp,pp=0.0;
			  for(LL j = 0; j <= m; j++ )
			  {
				  tp=mem[i].ps[j];

				  for(LL k = 0; k < n; k++ )
				  {
					  double t=0.0;
					  if(k==i)
						  continue;
					  for(LL q = 0; q <= m; q++ )
						  if(mem[k].c[q]>mem[i].c[j]+eps)
							  t+=mem[k].ps[q];
					  tp*=t;
				  }

				   pp+=tp;
			  }
			  
			  printf("%lf\n",pp);
		  }
	 
	}
	return 0;
}

Measured memory_bytes: 1128
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let v:Vec<i32> = procon_read();
	let k = v[0];
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let v:Vec<i32> = procon_read();
	let y = v[0];
	if n <= k {
		println!("{}", n*x);
	}else{
		println!("{}", k*x + (n - k)*y);
	}
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
//????????????????????????????????????
void Check(const string& str){
  string strparent=str;
  int gap=1;
  while(strparent.find("the")==(string::npos)&&
        strparent.find("this")==(string::npos)&&
        strparent.find("that")==(string::npos)){
    for(int i=0;i<str.length();i++){
      if(!isalpha(str[i]))continue;//" "
      //strparent[i]=(gap+str[i]-'a')%26+'a';
      strparent[i]=(gap+str[i])%26+'a';
    }
    gap++;
  }
  cout<<strparent<<endl;
}

int main(){
  string str;
  while(getline(cin,str)){
    Check(str);
  }
}

Measured memory_bytes: 3180
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int K;
    io.read(K);
    if(K % 2 == 0){
        cout << (K / 2) * (K / 2);
    }
    else {
        cout << (K / 2 + 1) * (K / 2);
    }
    return 0;
}

Measured memory_bytes: 256