akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

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

ll b[300005][61]={};
ll c[300005][61]={};

int main(){
    fast_io
    
    int n;
    cin>>n;
    ll a[n];
    rep(i,n) cin>>a[i];

    int l=61;
    rep(i, n){
        rep(j, l){
            ll t=(1ll<<j);
            if((t&a[i])!=0){
                b[i][j]=1;
            }
        }
    }
    rep(i,n){
        rep(j,l){
            c[i+1][j]=c[i][j]+b[i][j];
        }
    }
    ll ans=0;
    rep(i,n-1){
        rep(j,l){
            ll t=1ll<<j;
            ll k;
            if((t&a[i])!=0){
                k=n-(i+1)-(c[n][j]-c[i+1][j]);
            }else{
                k=(c[n][j]-c[i+1][j]);
            }
            t%=mod;
            ans+=k*t;
            ans%=mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 288640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,v,p,a[N],b[N];
bool judge(int mid)
{
    if(n-mid+1<=p) return true;
    for(int i=1;i<=n;i++) b[i]=a[i];
    for(int i=n;i>=n-p+2;i--) b[i]+=m;
    b[mid]+=m;
    for(int i=mid+1;i<n-p+2;i++)
        if(b[i]>b[mid]) return false;
    int sum=v-p,now=0;
    if(sum<=0) return true;
    for(int i=1;i<n-p+2;i++)
    {
        if(i==m) continue;
        if(b[mid]-b[i]>=m) sum--;
        else
        {
            int x=b[mid]-b[i];
            if(now>=x) now-=x;
            else
            {
                x-=now;now=0;
                if(sum)
                {
                    sum--;now=m-x;
                }
            }
        }
        if(sum==0&&now==0) return true;
    }
    return false;
}
int main()
{
    scanf("%d%d%d%d",&n,&m,&v,&p);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int l=1,r=n,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(judge(m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%d\n",n-ans+1);
}


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

int main() {
string s;
cin>>s;
for(int i=0;i<s.size();i++){
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
        break;
    }
    else{
    cout<<"No"<<endl;
    break;
    }
}

return 0;
}

Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Falls K=0: n^2.
;; Sei K >= 1 und sei b fixiert. Es reicht, den Fall b > K zu untersuchen.
;; Das kleinste a, so dass a % b >= K, ist a=K. Die Liste von a ist wie folgt:
;; K, K+1, ..., b-1 (total: b-K)
;; b+K,b+K+1, ..., 2b-1  (total: b-K)
;; ...
;; pb+K, pb+K+1, ..., pb+K+q = N (total: q+1)
;; wobei p die kleinste Zahl mit (p+1)b-1>=N. Also p = ceil(N+1/b)-1 und q =
;; N-pb-K. Zusammenfassend ist die Anzahl von a für ein fixiertes b: p(b-K)+max(q+1, 0).
;; Die Antwort ist die Summe davon für alle b in (K, N]

(defun main ()
  (let* ((n (read))
         (k (read)))
    (println
     (if (zerop k)
         (* n n)
         (loop for b from (1+ k) to n
               for p = (- (ceiling (1+ n) b) 1)
               for q = (- n (* p b) k)
               sum (+ (* p (- b k)) (max 0 (+ q 1))))))))

#-swank(main)


Measured memory_bytes: 16360
#include <stdio.h>
int main()
{
    int k, a, b; scanf("%d%d%d", &k, &a, &b);
    long res1=k+1, res2=1;
    for(; k>0 && res2<a; --k) ++res2;
    for(; k>1; k-=2) res2+=b-a;
    res2+=k;
    printf("%lld\n", res1<res2 ? res2 : res1);
}


Measured memory_bytes: 128
use std::vec::Vec;
use std::cmp;

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>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let s: String = read();
    let t: String = read();
    let ss: Vec<char> = s.chars().collect();
    let tt: Vec<char> = t.chars().collect();
    let ns: usize = s.len();
    let nt: usize = t.len();
    let mut lcs: Vec<Vec<i64>> = vec![vec![0; nt+1]; ns+1];


    for i in 1..ns+1 {
        for j in 1..nt+1 {
            if ss[i-1] == tt[j-1] {
                lcs[i][j] = lcs[i-1][j-1] + 1;
            } else {
                lcs[i][j] = cmp::max(lcs[i-1][j], lcs[i][j-1]);
            }
        }
    }

    let mut ans: String = String::new();
    let mut i: usize = ns;
    let mut j: usize = nt;

     while i > 0 && j > 0  {

         if lcs[i][j] == lcs[i-1][j] {
             i -= 1;
         }
         else if lcs[i][j] == lcs[i][j-1] {
             j -= 1;
         }
         else if lcs[i][j] == lcs[i-1][j-1] + 1 {
              ans.push(ss[i-1]);
              i -= 1;
              j -= 1;
          }
     }

    println!("{}", ans.chars().rev().collect::<String>());
}


Measured memory_bytes: 90364
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
struct point{
	int l,r,v;
	bool operator <(const point &rhs) const{
		return r<rhs.r || (r==rhs.r && l>rhs.l);
	}
}a[maxn];
struct Segment_tree{
	ll Max[maxn<<2],tag[maxn<<2];
	inline void push_down(int x){
		if(tag[x]){
			Max[x<<1]+=tag[x];
			Max[x<<1|1]+=tag[x];
			tag[x<<1]+=tag[x];
			tag[x<<1|1]+=tag[x];
			tag[x]=0;
		}
	}
	inline void push_up(int x){
		Max[x]=max(Max[x<<1],Max[x<<1|1]);
	}
	void update(int x,int L,int R,int ql,int qr,ll v){
		if(ql<=L && R<=qr){
			tag[x]+=v,Max[x]+=v;
			return;
		}
		int Mid=(L+R)>>1;
		push_down(x);
		if(ql<=Mid) update(x<<1,L,Mid,ql,qr,v);
		if(qr>Mid) update(x<<1|1,Mid+1,R,ql,qr,v);
		push_up(x);
	}
	ll query(int x,int L,int R,int ql,int qr){
		if(ql>qr) return 0;
		if(ql<=L && R<=qr) return Max[x];
		int Mid=(L+R)>>1;
		ll res=0;
		push_down(x);
		if(ql<=Mid) chkmax(res,query(x<<1,L,Mid,ql,qr));
		if(qr>Mid) chkmax(res,query(x<<1|1,Mid+1,R,	ql,qr));
		push_up(x);
		return res;
	}
}Seg;
int num[maxn],tmp;
ll sum[maxn],dp[maxn];
int main(){
	int n=read(),m=read();
	REP(i,1,m) a[i].l=read(),a[i].r=read(),a[i].v=read();
	sort(a+1,a+m+1);
	for(int i=1,k=1;i<=n;++i){
		tmp=0;
		num[0]=i;
		while(k<=m && a[k].r==i){
			num[++tmp]=a[k].l,sum[tmp]=a[k].v;
			++k;
		}
		sum[tmp+1]=0;
		DREP(j,tmp,1) sum[j]+=sum[j+1];
		dp[i]=max(Seg.query(1,1,n,1,i-1),0ll)+sum[1];
		REP(j,1,tmp) if(num[j]<num[j-1]) Seg.update(1,1,n,num[j],num[j-1]-1,sum[j]);
		Seg.update(1,1,n,i,i,dp[i]);
	}
	printf("%lld\n",max(Seg.query(1,1,n,1,n),0ll));
	return 0;
}


Measured memory_bytes: 16896
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    string s, t; cin >> s >> t;
    rep(i,n) cout << s[i] << t[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

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

  ll n,w,i,j;
    cin>>n>>w;
  ll ww[n+1]={};
  ll v[n+1]={};
  ll dp[n+2][100002]={};

  for(i=1;i<=n;i++){
    cin>>ww[i];
      cin>>v[i];
  }

  for(i=0;i<=n;i++){
    for(j=0;j<=1e5;j++){
      if(j!=0)dp[i][j]=1e10;
    }
  }
 

  for(i=1;i<=n;i++)
  {
    for(j=1;j<=100000;j++){
        dp[i][j]=1e10;
      if(i)dp[i][j]=dp[i-1][j];
      if(v[i] <=j ){
        dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]] + ww[i]);
      }
    }
  }

  for(i=1e5;i>=0;i--){
    if(dp[n][i]<=w){
      cout<<i<<"\n";
      return 0;
    }
  }



  return 0;
}


Measured memory_bytes: 80000
s = input()

if s[0] == '1':
  s = '9' + s[1:]
elif s[0] == '9':
  s = '1' + s[1:]
  
if s[1] == '1':
  s = s[0] + '9' + s[2]
elif s[1] == '9':
  s = s[0] + '1' + s[2]

if s[2] == '1':
  s = s[:2] + '9'
elif s[2] == '9':
  s = s[:2] + '1'
print(s)

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

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> m;
    bool flag=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            flag=1;
        } else if (s[i]=='C'&&flag){
            m.push_back(i);
            flag=0;
        } else {
            flag=0;
        }
    }
    
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        auto ans1=lower_bound((m).begin(),(m).end(), l);
        auto ans2=lower_bound((m).begin(),(m).end(), r);
        cout << ans2-ans1 << endl;
    }
    
}

Measured memory_bytes: 1228
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,l=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]
q=int(input())
st=[list(map(int,input().split())) for i in range(q)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n,w = n,m #n:頂点数　w:辺の数

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = abc[i]
    x,y=x-1,y-1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
tmp=warshall_floyd(d)

newd = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        if d[i][j]<=l:
            newd[i][j]=1
            newd[j][i]=1
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

tmp=warshall_floyd(newd)

for i in range(q):
    s,t=st[i]
    s,t=s-1,t-1

    print(newd[s][t]-1 if newd[s][t]!=float('inf') else -1)

Measured memory_bytes: 135132
import bisect
n=int(input())
a = list(map(int, input("").split()))
b = list(map(int, input("").split()))
c = list(map(int, input("").split()))
out=0
a.sort()
b.sort()
c.sort()
for i in b:
    na = bisect.bisect_left(a,i)
    nc = bisect.bisect(c,i)
    out += na * (len(c)-nc)
print(out)

Measured memory_bytes: 29352
#include <iostream>

using namespace std;
const int maxn=1e3;
int d[maxn][maxn];
const int INF=2147483647;
struct node{
    int from;
    int to;
    int cost;
}edge[9905];
//结构体存信息
int point, E;
bool find(){
    int tmp[maxn];
    fill(tmp,tmp+maxn,0);
    for(int i=0;i<point;i++){
        for(int j=0;j<E;j++){
            node e=edge[j];
            if(tmp[e.to]>tmp[e.from]+e.cost){
                tmp[e.to]=tmp[e.from]+e.cost;
                if(i==point-1)
                    return true;
            }
        }
    }
    return false;
}
int main(){
    cin>>point>>E;
    int temp=E;
    for(int i=0;i<point;i++){
        for(int j=0;j<point;j++){
            if(i==j)
                d[i][j]=0;
            else
                d[i][j]=INF;
        }
    }
    for(int i=0;i<E;i++){
        cin>>edge[i].from>>edge[i].to>>edge[i].cost;
        d[edge[i].from][edge[i].to]=edge[i].cost;
    }

     for(int k=0;k<point;k++){
         for(int i=0;i<point;i++){
             for(int j=0;j<point;j++){
                if(d[i][k]!=INF&&d[k][j]!=INF)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
             }
         }
    }
    if(find()){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    for(int i=0;i<point;i++){
        for(int j=0;j<point;j++){
            if(j!=0)
            cout<<" ";
            if(d[i][j]>=INF){
                cout<<"INF";
            }
            else
                cout<<d[i][j];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3604
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
    ull x, y;
    cin >> x >> y;
    ull z = y / x;
    for (int c = 63; c >= 0; --c) {
        if (((z >> c) & 1) == 1) {
            cout << c + 1 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}



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

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

    int A, B, K;
    cin >> A >> B >> K;

    if(B - A + 1 > K * 2) {
        for(int i = 0; i < K; i++) {
            cout << A + i << endl;
        }
        for(int i = K - 1; i >= 0; i--) {
            cout << B - i << endl;
        }
    } else {
        for(int i = A; i <= B; i++) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int fact(int x,int y){
    if(y==1)return x;
    else if(y%2==0)return fact(x*x%inf,y/2);
    else return fact(x*x%inf,y/2)*x%inf;
}
int mul[114514];
int di[114514];
int C(int n,int t){
    return mul[n]*di[t]%inf*di[n-t]%inf;
}
signed main(){
    int n;cin>>n;
    int a[114514];
    int c[114514]={};
    int key=0;
    rep(i,0,n+1){
        cin>>a[n];
        if(!c[a[n]])c[a[n]]=i+1;
        else key=c[a[n]]+n-i-1;
    }
    mul[0]=1;
    rep(i,1,114514)mul[i]=mul[i-1]*i%inf;
    di[114513]=fact(mul[114513],inf-2);
    for(int i=114512;i>=0;i--)di[i]=di[i+1]*(i+1)%inf;
    rep(i,0,n+1){
        if(!i)cout<<n<<endl;
        else if(i==n)cout<<1<<endl;
        else cout<<((n+1>=i+1?C(n+1,i+1):0)-(key>=i?C(key,i):0)+inf)%inf<<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cstdint>
					/*多倍長整数/cpp_intで宣言
					#include <boost/multiprecision/cpp_int.hpp>

					using namespace boost::multiprecision;
					*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	ll a, b, c, x, y;
	ll ans = 0;
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
	if (a + b > c * 2) {
		int tmp = min(x, y);
		x -= tmp;
		y -= tmp;
		ans += tmp * c * 2;
	}
	if (a > c * 2) {
		ans += c * x * 2;
		x = 0;
	}
	if (b > c * 2) {
		ans += c * y * 2;
		y = 0;
	}
	ans += x * a + y * b;
	printf("%lld\n", ans);

	Please AC;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=1,p; cin>>n;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    p=a[0];
    for(ll i=2;i<n;i++){
        if((a[i-1]-p)*(a[i]-a[i-1])<0){
            ans++;
            p=a[i];
            i++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	// freopen("input.in", "r", stdin);

	string s; cin >> s;
	for(char c : s)
		cout << "x";
	cout << "\n";
}

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

int main() {
   //int a, b, c;
   string s;
   cin >> s;
   if(s == "ABC") {
      cout << "ARC";
   } else{
      cout << "ABC";
   }
   return 0;
}

Measured memory_bytes: 3620
rec = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    rec[a - 1] += 1
    rec[b - 1] += 1
k = [0] * 4
for i in range(4):
    k[rec[i]] += 1
if k[2] == 2 and k[1] == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var (
		n int
		m int
		p int
		s string
	)
	
	fmt.Scan(&n,&m)
	result := make([]int, n+1)
	
	waCnt := 0
	acCnt := 0
	
	for subCnt := 0; subCnt < m; subCnt++ {
		fmt.Scan(&p,&s)
		p--

		//まだACになっていない問題でWAにしたら、ペナルティ
		if result[p] != -1 && s == "WA" {
			result[p]++
		}
		
		//まだACになっていない問題でACにしたら、正答
		if result[p] != -1 && s == "AC" {
			acCnt++
			waCnt += result[p]
			result[p] = -1
		}
	}
	fmt.Println(acCnt,waCnt)
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  bool f=true;

  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0) f=false;
    }
  }
  if(f)cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,r;
    cin>>n>>r;
    
    if(n >= 10) cout << r << endl;
    else cout << 100*(10 - n) + r << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
c = []
bit = 0
for i in range(n):
    c.append(list(map(int,input().split())))
ans = 1000000000000
for i in range(2**n):
    l = [0 for _ in range(m)]
    current = 0
    for j in range(n):
        if (i>>j)&1:
            current += c[j][0]
            for k in range(m):
                l[k] += c[j][k+1]
    flag = 1
    for h in l:
        if h < x:
            flag = 0
    if flag:
        ans = min(ans,current)
if ans == 1000000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9232
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        long a = sc.nextLong();
        double b = 100 * sc.nextDouble() + 0.01;
        a = a * (int) b / 100;
        sc.close();
        System.out.println(a);
    }
}

Measured memory_bytes: 36896
#define ll long long
#define pb push_back
#define make_pair mp
#define first f
#define second s
#define upper_bound ub
#define lower_bound lb
#define MOD 1000000007
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


#define ordered_set tree<pair<ll,ll> , null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update>ll fn



void solve(){
    ll n;cin>>n;
    ll a[n+1],ps[n+1];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    ps[n]=0;
    for(ll i=n-1;i>=1;i--){
        ps[i]=ps[i+1]+a[i+1];
        ps[i]%=MOD;
    }
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans += (ps[i]*a[i])%MOD;
        ans%=MOD;
    }
    cout<<ans;
}

int main ()
{
  ios_base::sync_with_stdio (false);
  cin.tie (NULL);
  ll t;
  //cin>>t;
  t = 1;
  while (t)
    {
      solve();t--;
      //cout<<"end of test case"<<endl;
    }
  return 0;
}


Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	int N, K;
	cin >> N >> K;
	int d = 0;
	while (N) {
		N /= K;
		d++;
	}
	cout << d << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s; cin >> s;
    int ans;
    
    if(s=="SUN") ans = 7;
    else if(s=="MON") ans = 6;
    else if(s=="TUE") ans = 5;
    else if(s=="WED") ans = 4;
    else if(s=="THU") ans = 3;
    else if(s=="FRI") ans = 2;
    else ans = 1;

    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <iomanip>

//--boost--
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using Rat = boost::rational<Bint>;
//!--boost--

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
using ll = unsigned long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll INF = 1LL << 60;
const int INF_INT = 1 << 30;

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

struct Fast {
	Fast() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast; //cin,cout高速化のおまじない＋桁数指定


//void solve()
//{
//	ll N;
//	cin >> N;
//	vector<ll> A(N);
//	rep(i, N) {
//		cin >> A[i];
//		if (A[i] == 0) {
//			cout << 0 << endl;
//			return;
//		}
//	}
//
//	unsigned long long result = 1;
//	rep(i, N) {
//		unsigned long long temp = (A[i] + (unsigned long long)1000000000000000000 - 1);
//		temp /= A[i];
//		if (result > temp) {
//			cout << -1 << endl;
//			return;
//		}
//		else {
//			result *= A[i];
//			if (result > (unsigned long long)1000000000000000000) {
//				cout << -1 << endl;
//				return;
//			}
//		}
//	}
//
//	cout << result << endl;
//}

void solve() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return;
		}
	}

	Bint result = 1;

	rep(i, N) {
		result *= A[i];
		if (result > (Bint)1e18) {
			cout << -1 << endl;
			return;
		}
	}

	cout << result << endl;
}

int main() {
#if TEST && LOCAL
	ll t; cin >> t;
	rep(i, t) { solve(); }
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

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 INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M;
    cin >> M;
    ll sum = 0;
    ll C = 0;
    ll ans = 0;

    REP(i,M){
        ll d, c;
        cin >> d >> c;
        sum += d * c;
        C += c;
    }
    ans += C - 1;
    ans += (sum - 1) / 9;
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *    author: Behradm
 *    Created: 14.06.2020 16:25:12
 *    In the Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[5];
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < 5; i++) {
    if (a[i] == 0) {
      cout << i + 1 << '\n';
      return 0;
    }

  }
  return 0;
}




Measured memory_bytes: 3652
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    l.sort(key=lambda x:x[0])
    ans=0
    cnt=0
    for i in range(n):
        if m>=l[i][1]:
            cnt+=l[i][1]
            m-=l[i][1]
            ans+=l[i][0]*l[i][1]
        else:
            cnt+=m
            ans+=l[i][0]*m
            break
    print(ans)
resolve()

Measured memory_bytes: 29020
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
//using Bint = mp::cpp_int;

int main()
{
	int N,mp,res=0;
	vector<int>H;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int h;
		cin>>h;
		H.push_back(h);
		if(i==0)
		{
			mp=h;
			res+=h;
		}
		else
		{
			if(mp<=h)
			{
				res+=h-mp;
				mp=h;
			}
			else
			{
				mp=h;
			}
		}
	}
	cout<<res<<endl;
	
}

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

int main()
{
	int n, h, w;
	int a, b;
	int k = 0;
	std::cin >> n >> h >> w;
	while (n != 0) {
		std::cin >> a >> b;
		if (a >= h && b >= w)
			k++;
		n--;
	}
	std::cout << k;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,k,s;//k使う個数,s合計
int ans = 0;
void dfs(int sum,int i,int cnt){
	if(sum==s&&cnt==0){
		ans++;
		return ;
	}
	if(i>n||cnt==0)return;
	dfs(sum+i,i+1,cnt-1);
	dfs(sum,i+1,cnt);
}

int main(){
	while(cin>>n>>k>>s,n||k||s){
		ans = 0;
		dfs(0,1,k);
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define S second
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e10, MOD=1000000007;
     
ll n, k, q=1, a[N], b[4][N], c[N], f[N], m, o=3, h, w, mx, mn, ans[N], Ans;
string s, S;
vector <ll> v[N];
pair<ll, ll> p[N];

ll POW(ll x, ll y){
	
	ll X=x;x=1;
	while(y){
		if(y%2)x*=X,x%=MOD,y--;
		y/=2, X*=X, X%=MOD;
	}
	return x;
}

main(){ios_base::sync_with_stdio(false), cin.tie(0);
                    
    cin>>n>>k;
	
	for (int i=k; i>=1; i--){
		ans[i]=POW((k/i),n);
		for (int j=2*i; j<=k; j+=i){
			ans[i]-=ans[j];
			if(ans[i]<0)ans[i]+=MOD;
		}
		(Ans+=(ans[i]*i))%=MOD;
	}
	
	cout<<Ans;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, M, R;
int land[202][202], sea[202][202];
int z[1001];

int dp[1001][202];

int solve(int idx, int ship) {
  if(idx == R-1) return 0;
  int& res = dp[idx][ship];
  if(~res) return res;
  res = inf;
  chmin(res, solve(idx+1, ship)+land[z[idx]][z[idx+1]]);
  rep(i, N) {
    chmin(res, solve(idx+1, i)+land[z[idx]][ship]+sea[ship][i]+land[i][z[idx+1]]);
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N >> M, N) {
    rep(i, 202) rep(j, 202) land[i][j] = (i == j ? 0 : inf);
    rep(i, 202) rep(j, 202) sea[i][j] = (i == j ? 0 : inf);
    rep(i, M) {
      int x, y, t;
      char c;
      cin >> x >> y >> t >> c;
      x--, y--;
      if(c == 'S') sea[x][y] = sea[y][x] = min(sea[x][y], t);
      if(c == 'L') land[x][y] = land[y][x] = min(land[x][y], t);
    }
    cin >> R;
    rep(i, R) cin >> z[i], z[i]--;
    rep(i, N) rep(j, N) rep(k, N) {
      chmin(sea[j][k], sea[j][i]+sea[i][k]);
      chmin(land[j][k], land[j][i]+land[i][k]);
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, z[0]) << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
   int n;
   cin >> n;
   unordered_map<string, int> m1;
   map<int, vector<string>> m2;
   for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      ++m1[s];
   }
   for (pair<string, int> elem: m1) {
      m2[elem.second].push_back(elem.first);
   }
   vector<string> arr = m2.rbegin()->second;
   sort(arr.begin(), arr.end());
   for (string s: arr) {
      cout << s << endl;
   }
}


Measured memory_bytes: 28228
def is_even(S):
  L = len(S)
  left = S[:L//2]
  right = S[L//2:]
  return (left == right)

S = list(input())
# 消すのは末尾から

answer = 0
while S:
  S.pop()
  if is_even(S):
    answer = len(S)
    break

print(answer)

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll ans = 0;
  while (1) {
    bool ok = true;
    rep(i, n) {
      if (a[i] % 2) {
        ok = false;
        break;
      }
      a[i] /= 2;
    }
    if (!ok)
      break;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
N = int(input())
values_list = []
for i in range(N):
    values = list(map(int, input().split()))
    values_list.append(values)

# DPテーブルは選択分拡張する
dp = [[0,0,0] for i in range(N+1)]

for i in range(N):
    for j in range(0, 3):
        for k in range(0, 3):
            if j == k:
                continue
            dp[i][k] = max(dp[i][k], dp[i-1][j] + values_list[i][k])

print(max(dp[N-1]))


Measured memory_bytes: 47372
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>


int main() {
	long long int height, width;
	std::cin >> height >> width;
	if (height == 1 || width == 1) std::cout << 1 << std::endl;
	else std::cout << ((height + 1) / 2) * ((width + 1) / 2) + (height / 2) * (width / 2) << std::endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

int main(){
	int N,X;
	cin >> N >> X;
	vector<int> D(N);
	for(int i = 0; i < N; i++){
		cin >> D[i];
	}
	int sum = 0;
	for(int i = 0; i < N; i++){
		sum += D[i];
	}
	X -= sum;
	sort(D.begin(),D.end());
	int min = D[0];
	int cnt = 0;
	if(X > min){
		while(X >= min){
			X -= min;
			cnt++;
		}
	}
	
	cout << N +cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll x,y,i,ans=0;
    cin>>x>>y;
    i = x;
    while (i <= y)
    {
        ans++;
        i *= 2;

    }
    cout << ans << endl;
}


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

int main() {
	string s , l="";
	cin >> s;
	int a = s.length();
	for(int i = 0 ; i < a ; i++)
	{
		if(s[i]=='A')
			l+="T";
		else if(s[i]=='T')
			l+="A";
		else if(s[i]=='G')
			l+="C";
		else
			l+="G";
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

typedef vector<double> vd;
typedef vector<vd> vvd;
int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
char roomChar[3][3]={{'A','B','C'},{'D','E','F'},{'G','H','I'}};
char getRoomChar(int x,int y){
	return roomChar[y][x];
}
pii getRoomLoc(char c){
	REP(x,3){
		REP(y,3){
			if(roomChar[y][x]==c){
				return make_pair(x,y);
			}
		}
	}
}
int main(){
	int n;
	while(cin>>n,n){
		char s,t,b;
		cin>>s>>t>>b;
		vector<vvd> p(n+1,vvd(3,vd(3)));
		pii sl=getRoomLoc(s);
		p[0][sl.first][sl.second]=1;
		REP(i,n){
			REP(x,3){
				REP(y,3){
					REP(d,4){
						int xx=x+dx[d];
						int yy=y+dy[d];
						if(xx>=0&&yy>=0&&xx<3&&yy<3&&getRoomChar(xx,yy)!=b){
								p[i+1][xx][yy]+=p[i][x][y]/4;
						}else{
							p[i+1][x][y]+=p[i][x][y]/4;
						}
					}
				}
			}
		}
		pii tl=getRoomLoc(t);
		printf("%.10f\n",p[n][tl.first][tl.second]);
	}
}

Measured memory_bytes: 1240
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int a;
  int a_1=0;
  int a_2=0;
  int a_3=0;
  
  cin>>a;
  
  a_1=a/100;
  a=a%100;
  a_2=a/10;
  a_3=a%10;
  
  if(a_1==7||a_2==7||a_3==7)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N, M;
	cin >> N >> M;
	vector<ll>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	map<ll, ll>nums;
	ll sum = 0;
	nums[sum]++;
	for (int i = 0; i < N; ++i) {
		sum += A[i];
		nums[sum%M]++;
	}
	ll res = 0;
	for (map<ll, ll>::iterator it = nums.begin(); it != nums.end(); ++it) {
		res += it->second*(it->second - 1) / 2;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
#define M 1000000007
 
#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))
 
typedef long long ll;
typedef long double ld;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, c; cin>>n>>c;
    ll x[n+1], v[n+1];
    for(int i=0; i<n; i++)
    {
    	cin>>x[i]>>v[i];
    }
    v[n]=0; x[n]=0;
    ll mx=0, curr=0, pen=0, mxm=0, curr1=0;
    stack<pair<ll, ll> > ind, ind1;
    ind.push(mp(n, 0));
    ind1.push(mp(-1, 0));
    for(int i=n-1; i>=0; i--)
    {
    	curr1+=v[i];
    	if((curr1-2*(c-x[i]))>mxm)
    	{
    		mxm=(curr1-2*(c-x[i]));
    		ind.push(mp(i, mxm));
    	}
    }
    curr1=0; mxm=0;
    for(int i=0; i<n; i++)
    {
    	curr1+=v[i];
    	if((curr1-2*x[i])>mxm)
    	{
    		mxm=(curr1-2*x[i]);
    		ind1.push(mp(i, mxm));
    	}
    }
    curr=0;
    for(int i=0; i<n; i++)
    {
    	curr+=v[i];
    	while(ind.top().first<=i)
    	{
    		ind.pop();
    	}
    	mx=max(mx, curr-x[i]+ind.top().second);
    }
    curr=0;
    for(int i=n-1; i>=0; i--)
    {
    	curr+=v[i];
    	while(ind1.top().first>=i)
    	{
    		ind1.pop();
    	}
    	mx=max(mx, curr-c+x[i]+ind1.top().second);
    }
    cout<<mx<<endl;
    return 0;
}

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

 int main(){
  int N, M, C;
  int B[100], A[100][100];

  cin >> N >> M >> C ;

  for ( int i = 0; i < M; ++i ) cin >> B[i];

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



  int ans = 0; 
  for ( int i = 0; i < N; ++i ){
   int sum=0;
   for ( int j = 0; j < M; ++j ){
    sum += A[i][j] * B[j];
   }
   if (sum + C > 0) {
    ++ans;
   }
  }
  cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ct = 0
a.sort()
for i in range(n-1,-1,-1):
    l = 0
    r = i -1
    while(l < r):
        if a[l] + a[r] > a[i]:
            ct += r-l
            r -= 1
        else:
            l += 1
print(ct)


Measured memory_bytes: 41452
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define int ll
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 1e5+5;
int n,m,val[N],cnt[N];
it gcd(int x,int y){return y==0?x:gcd(y,x%y);}
it lcm(int x,int y){return 1ll*x*y/gcd(x,y);}
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);
	for(ri i=1;i<=n;++i){
		read(val[i]);
		while(val[i]%2==0) val[i]>>=1,++cnt[i];
	}
	int flag=1;
	for(ri i=2;i<=n;++i)
		flag&=cnt[i]==cnt[1];
	if(!flag) return puts("0"),0;
	int res=val[1];
	for(ri i=2;i<=n;++i)
		res=lcm(val[i],res);
	res<<=cnt[1]-1;
	print((m/res+1)>>1);
	return 0;
}

Measured memory_bytes: 1792