akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vl A,B;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
    ld r;cin>>r;
	cout << 2*PI*r<<endl;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define sc(name) scanf("%d",&name)
#define ssc(name1,name2) scanf("%d%d",&name1,&name2)
#define sssc(name1,name2,name3) scanf("%d%d%d",&name1,&name2,&name3)
#define scl(name) scanf("%lld",&name)
#define sscl(name1,name2) scanf("%lld%lld",&name1,&name2)
#define ssscl(name1,name2,name3) scanf("%lld%lld%lld",&name1,&name2,&name3)
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define Forr(name,start,finish) for(int name=start;name>=finish;name--)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};

const ll N=1e5+10;
const ll M=1e9+7;

ll logx(ll a,ll b){return log(a)/log(b);}
ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m

vector<ll> fq(N);

int main()
{

    fast_in_out;

    ll n,k,q;
    cin>>n>>k>>q;


    For(i,1,n+1)
    fq[i]=k;

    while(q--)
    {
       ll a;
       cin>>a;

       fq[a]++;
    }

    ll cnt=0;

    For(i,1,n+1)
    cnt+=(fq[i]-k);

    For(i,1,n+1)
    fq[i]-=cnt;

    For(i,1,n+1)
    {
        if(fq[i]>0)
            cout<<"Yes"<<endl;

        else
            cout<<"No"<<endl;
    }


    return 0;
}


//cf 439 C
//cf 489 C
//cf 465 div 2 E
// cc sep17 fill the array

/*

1
3 1000000000
1231 1200
1000 800
1 100
*/


Measured memory_bytes: 1408
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b) 
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]

print(ans)

Measured memory_bytes: 38256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  c=0
  x=0
  while True:
    c+=1
    x+=n
    x%=360

    if x==0:
      return c

# main()
print(main())


Measured memory_bytes: 10692
let pi = 4. *. atan 1.
let _ = Scanf.sscanf (read_line()) "%f %f %f %f" 
  (fun a b h m ->sqrt @@ 
  a *. a +. b *. b -. 
  2.0 *. a *. b *.
  cos (
    (pi *. m /. 30.0) -. (pi *. (h /. 6.0 +. m /. 360.0)
    )
    )
    ) |> Printf.printf "%.10f\n"


Measured memory_bytes: 4376
N=int(input())
def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1
tmp=[N]
i=1
while True:
    i+=1
    N=f(N)
    if N in tmp:
        break
    else:
        tmp.append(N)
print(i)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int32_t main() {
	string s;
	cin>>s;
	int c=0,d=0,i,j,k;
	for(i=0,j=0,k=1;i<s.length();j=!j,k=!k,i++)
	{
		int ele=s[i]-'0';
		if(j!=ele)
			c++;
		if(k!=ele)
			d++;
	}
	cout<<min(c,d);
}
						

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  cin>>n;
  vector<pll> a(n);
  rep(i,n){
    cin>>a[i].first;
    a[i].second = i+1;
  }
  sort(a.begin(),a.end());

  cout<<(a[0].second)<<endl;

}


Measured memory_bytes: 4336
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll s; cin >> s;
    ll ans = 0;
    if(s == 1 || s == 2) cout << 4 << endl;
    else{
        while(s != 1){
            if(s % 2 == 1) s = 3 * s + 1;
            else s = s / 2;
            ans++;
        }
        cout << ans + 2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n;
  cin >> n;
  vector<string> s(2);
  cin >> s[0];
  cin >> s[1];
  vector<string> t(2, "");
  t[0] += s[0][0];
  t[1] += s[1][0];
  for(int i=1; i<n; i++){
    if( s[0][i-1] != s[0][i] ) t[0] += s[0][i];
    if( s[1][i-1] != s[1][i] ) t[1] += s[1][i];
  }
  n = t[0].size();

  long long int cnt = 1;
  if( t[0][0] == t[1][0] ) cnt *= 3;
  else cnt *= 6;

  for(int i=1; i<n; i++){
    if( t[0][i-1] == t[1][i-1] ){
      if (t[0][i] == t[1][i]){
        cnt *= 2;
      } else {
        cnt *= 2;
      }
    }else {
      if (t[0][i] == t[1][i]){
        cnt *= 1;
      }else {
        cnt *= 3;
      }
    }
    cnt %= mod;
  }
  cout << cnt << endl;

  return 0;
}




//


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }


char S[1111];
int main() {
    scanf("%s", S);
    int len = strlen(S);

    if ((bool)count(S, S+len, 'N') == (bool)count(S, S+len, 'S')
	    && (bool)count(S, S+len, 'E') == (bool)count(S, S+len, 'W'))
	puts("Yes");
    else 
	puts("No");


    return 0;
}



Measured memory_bytes: 256
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

A =[]
for i in range(N):
    A.append(P[i]+1)

from itertools import accumulate
B = list(accumulate(A))
#print(A)

ans = 0
if len(A) == K:
    ans = sum(A)/2
else:
    for i in range(K,N):
        ans=max(ans,(B[i]-B[i-K])/2)
print(ans)

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    double N;
    cin >> N;
    if(floor(N/2)==ceil(N/2))
    cout << 0.5 << endl;
    else{
        double ans=(floor(N/2+1))/N;
        cout << setprecision(10) << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	int n;
	cin >> n;
	cout << "ABC" << n;
	return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl d(n);
  rep(i,n)cin>>d[i];
  sort(d.begin(),d.end());
  ll count=0;
  for(ll i=d[n/2-1];i<d[n/2];i++)count++;
  cout<<count<<endl;
}
    

Measured memory_bytes: 1024
#include<stdio.h>
int buble(int a, int b[200]){
   int j,i,tmp;
  for(i=0;i<a;i++){
 	 for(j=0;j<a;j++){
   		 if(b[i]>b[j]){
  	   	   tmp=b[i];
   		   b[i]=b[j];
   		   b[j]=tmp;    
		  }
 	 }
  }
   return b;
  }
int main(){
  int N=0,L[200]={},p=0,q=0,d=0,e=0,f=0,count=0;
  scanf("%d",&N);
  for(p=0;p<=N;p++){
  scanf("%d",&L[p]);
  }
  L[200]=buble(N,L);
  p=(N*N*N-3*N*N+2*N)/6;
  for(d=0;d<N;d++){
    for(e=d+1;e<N;e++){
      for(f=e+1;f<N;f++){
  if(L[d]>=L[e]+L[f]||L[d]==L[e]||L[e]==L[f]){
    count++;
  }
      }
    }
  }
  count=p-count;
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#define r(i,n)for(int i=0;i<n;i++)
using namespace std;
main(){int c[10][10],H,W,t,a;cin>>H>>W;r(i,10)r(j,10)cin>>c[i][j];r(k,10)r(i,10)r(j,10)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);r(h,H)r(w,W){cin>>t;if(t>=0)a+=c[t][1];}cout<<a;}

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

int main() {
   long long  x;
  cin>> x;
  int iti,ni;
  iti =ni=0;
  
  vector< long long> koho(243);
  
  for (long long int i = 0; i<242; i++) {koho.at(i)=(i-121)*(i-121)*(i-121)*(i-121)*(i-121);}
   
  for (int i = 121; i < 242; i++) {
    for(int j = 0; j <=i; j++) {
      if(koho.at(i)-x==koho.at(j))
      {iti=i;ni=j;break;}
    }
    if(koho.at(iti)-x==koho.at(ni)) {break;}
      }
  cout<<iti-121<<" "<<ni-121;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll k;
ll ans, now = 1;

ll s(ll p)
{
    ll re = 0;
    while(p != 0)
    {
        re += p % 10;
        p /= 10;
    }
    return re;
}

int main()
{
    scanf("%lld", &k);
    while(k--)
    {
        ans += now;
        if(s(ans) * (ans + now) < s(ans + now) * ans) ans -= now, now *= 10, ans += now;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


const int INF = 1001001001;

// 差が大きいもの順にsortしておく
ll func(ll gb, ll ga, ll sb, ll sa, ll bb, ll ba, ll num) {
    ll f = 0;
    if (bb-ba > 0) {
        rep(x, (num)/ga+1) {
            rep(y, (num-ga*x)/sa+1) {
                int z = (num - ga*x - sa*y) / ba;
                f = max(f, (gb-ga)*x + (sb-sa) * y + (bb-ba) * z);
            }
        }
    } else if (sb-sa > 0) {
        rep(x, (num)/ga+1) {
            int y = (num - ga*x) / sa;
            f = max(f, (gb-ga)*x + (sb-sa) * y);
        }
    } else if (gb-ga > 0) {
        int x = num / ga;
        f = max(f, (gb-ga) * x);
    } else {
        f = 0;
    }
    return f;
}

int main() {
    ll n;
    cin >> n;
    ll ga, sa, ba, gb, sb, bb;
    cin >> ga >> sa >> ba >> gb >> sb >> bb;
    ll ga2, sa2, ba2, gb2, sb2, bb2;
    vector<pair<ll, pair<ll, ll> > > box;
    box.push_back(make_pair(gb-ga, make_pair(gb, ga)));
    box.push_back(make_pair(sb-sa, make_pair(sb, sa)));
    box.push_back(make_pair(bb-ba, make_pair(bb, ba)));
    sort(box.rbegin(), box.rend());

    gb2 = box[0].second.first;
    ga2 = box[0].second.second;
    sb2 = box[1].second.first;
    sa2 = box[1].second.second;
    bb2 = box[2].second.first;
    ba2 = box[2].second.second;

    ll ans = n;
    ans += func(gb2, ga2, sb2, sa2, bb2, ba2, n);
    ans += func(ba2, bb2, sa2, sb2, ga2, gb2, ans);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{ 
  int N;
  cin>>N;
  if(N%10==2 ||N%10==4 ||N%10==5||N%10==7||N%10==9 )
  {
  	cout<<"hon"<<endl;
  }
  else if(N%10==0 ||N%10==1 || N%10==6 ||N%10==8)
  {
  	cout<<"pon"<<endl;
  }
  else if(N%10==3)
  {
  	cout<<"bon"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define inf 9223372036854775807;
#define pb push_back;
#define umap unordered_map;
#define uset unordered_set;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){
    ll a, b, k;
    cin>>k;
    cin>>a>>b;
    if(a%k==0 || b%k == 0 || a/k != b/k){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
}
int main(){
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
}   

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<iomanip>
using namespace std;

int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	vector<pair<int,int>> ab(n);
	for (int i = 0; i < n; i++) {
		cin>>ab[i].first;
		cin>>ab[i].second;
	}
	sort(ab.begin(),ab.end());
	priority_queue<int> q;
	auto itr=ab.begin();
	for (int i = 1; i<=m; i++) {
		while((*itr).first<=i&&itr!=ab.end()){
			q.push((*itr).second);
			itr++;
		}
		if(q.size()>0){
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

// nのk乗を計算する
ll modpow(ll n, ll k){
    ll ret = 1;
    ll t = n;
    while(k > 0){
        if(k & 1) ret = ret * t % MOD;
        t = t * t % MOD;
        k = k>>1;
    }
    return ret;
}


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    bool check;
    if(N % 2 == 0){
        check = true;
        for (int i = 0; i < N; i++) {
            if(a[i] != 2*(i/2) + 1){
                check = false;
            }
        }
    }
    else{
        check = true;
        for (int i = 0; i < N; i++) {
            if(a[i] != 2*((i+1)/2)){
                check = false;
            }
        }
    }

    if(check == false){
        printf("0\n");
        return 0;
    }
    ll ans = modpow(2, N/2);
    printf("%lld\n", ans);

}

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

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

int dp[1005][1005];
bool visi[1005][1005];
string f[1005];
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int d,t,s;
    cin>>d>>t>>s;
    if(d <= t*s)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}


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

int main() {
  string s;
  cin >> s;
  int n= s.size();
  vector<int>v(2);
  
  for(int i=0;i<n;i++){
     v[s.at(i)-'0']++;
  }
 
  
  
  cout <<2* min(v.at(0),v.at(1))<<endl;
  
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,o;
ll dp[3009][3009],a[3009];
int main()
{
    cin>>n;
    o=n%2;
    int x=1;
    if(n%2==0)x=-1;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)dp[i][i]=a[i]*x;
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i%2==o)
            {
                dp[j][j+i]=min(dp[j][j+i-1]-a[j+i],dp[j+1][j+i]-a[j]);
            }
            else dp[j][j+i]=max(dp[j][j+i-1]+a[j+i],dp[j+1][j+i]+a[j]);
        }
    }
    cout<<dp[0][n-1]<<"\n";
   /* for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)cout<<dp[i][j]<<" ";cout<<"\n";
    }*/
}


Measured memory_bytes: 70784
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define srep(i) for(int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
const int MOD = 1000000009;

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

int main() {
    int N, R;
    cin >> N >> R;
    if(N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>x;
        A[x] = i;
    }

    for(int i=1;i<=n;i++)
        cout<<A[i]<<" ";

    return 0;
}


Measured memory_bytes: 1280
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//namespace _0608
//{
    class Program
    {
        static void Main(string[] args)
        {
           // int[] t = new int[5];
            //for (int u = 0; u < 5; u++) { t[u] = int.Parse(Console.ReadLine()); }
            int a = int.Parse(Console.ReadLine()); ;
            int b = int.Parse(Console.ReadLine()); ;
            int c = int.Parse(Console.ReadLine()); ;
            int d = int.Parse(Console.ReadLine()); ;
            int e = int.Parse(Console.ReadLine()); ;
            int x = a * e;
            int y = 0;
            if (c >= e) { y = b; }
            else { y = b + d * (e - c); }
            if (y >= x) { Console.WriteLine(x); }
            else { Console.WriteLine(y); }
        }
    }

Measured memory_bytes: 9024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        String s = stdin.readLine();

        int max = 0;
        for (int i = 0; i < n; i++) {
            int[] a = zAlgorithm(s.substring(i));
            for (int j = 1; j < a.length; j++) {
                max = Math.max(max, Math.min(j, a[j]));
            }
        }

        stdout.println(max);
    }


    private int[] zAlgorithm(String s) {
        int n = s.length();
        int[] a = new int[n];
        int i = 1;
        int j = 0;
        a[0] = s.length();
        while (i < n) {
            while (i + j < n && s.charAt(j) == s.charAt(i + j)) {
                ++j;
            }
            a[i] = j;
            if (j == 0) {
                ++i;
                continue;
            }

            int k = 1;
            while (i + k < n && k + a[k] < j) {
                a[i + k] = a[k];
                ++k;
            }
            i += k;
            j -= k;
        }
        return a;
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 46420
//  .:::.   .:::.
// :::::::.:::::::
// :::::::::::::::
// ':::::::::::::'
//   ':::::::::'
//     ':::::'
//       ':'
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
using namespace std;
const ll k_lim = 1e4; 
ll k;
string ss;
ll dp[100001];
int main()
{
    FIO;
    ll t, q, maxx, n, i, j, k1, k2, k3, x, flag, ans, sum, cnt, prev;
    cin>>n;
    vll v(n);
    
    rep(i,0,n)
    {
        cin>>v[i];    
    }
    FILL(dp, INF, ll);
    dp[0] = 0;
    rep(i,0,n)
    {
        rep(j,1,3)
        {
            if( i - j >= 0)
                dp[i] = min(dp[i],dp[i-j] + abs(v[i] - v[i-j]) );
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;    
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int n, d; cin >> n >> d;
	vector<vector<int>> v(n);
	rep(i, n) {
		rep(j, d) {
			int x; cin >> x; v[i].push_back(x);
		}
	}
	int ans = 0;
	rep(i, n) {
		Rep(j, i + 1, n) {
			int sum = 0;
			rep(k, d) {
				int dist = abs(v[i][k] - v[j][k]);
				sum += dist * dist;
			}
			int k = sqrt(sum+0.01);
			if (k*k == sum)ans++;
		}
	}
	cout << ans << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}

Measured memory_bytes: 256
'''''''''''''''''''''
grid[h][w]

    w=0 w=1 w=2
h=0
h=1
h=2
'''''''''''''''''''''

from collections import deque
import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
move = [(1, 0), (-1, 0), (0, 1), (0, -1)]     # 動ける場所の候補


def debug(start, goal, p, t):
    player = p
    debug_grid = list(list(grid[h]) for h in range(H))
    if start != (None, None):
        debug_grid[start[0]][start[1]] = "S"
    if goal != (None, None):
        debug_grid[goal[0]][goal[1]] = "G"
    debug_grid[player[0]][player[1]] = "P"
    print("~~~~~~~~~ t = " + str(t+1) + "  ~~~~~~~~")
    for debug_h in range(H):
        print("".join(str(debug_grid[debug_h][debug_w]) for debug_w in range(W)))


def distance_list(grid, visit, start, goal=(None,None)):
    dist = [[-1] * W for _ in range(H)]
    dist[start[0]][start[1]] = 0
    visit[start[0]][start[1]] = 1
    next_set = deque([(start, 0)])
    while next_set:
        p, t = next_set.popleft()
        h, w = p
        for dh, dw in move:
            q = (h + dh, w + dw)
            if q[0] < 0 or q[0] >= H or q[1] < 0 or q[1] >= W:
                continue
            if grid[q[0]][q[1]] == wall:
                continue
            if visit[q[0]][q[1]] == 1:
                continue
            #### (debug code) ######
            # debug(start, goal, q, t)
            ########################
            if q == goal:
                return t + 1
            visit[q[0]][q[1]] = 1
            dist[q[0]][q[1]] = t+1
            next_set.append((q, t + 1))
    return dist


def most_distant_point(grid, visit, start=(0,0)):
    res = (start, 0)
    temp = 0
    dist = distance_list(grid, visit, start)
    for h in range(H):
        for w in range(W):
            if dist[h][w] > temp:
                temp = dist[h][w]
                res = ((h,w), temp)
    return res


def diameter(grid, visit, start=(0,0)):
    visit = [[0] * W for _ in range(H)]
    p = most_distant_point(grid, visit, start)
    visit = [[0]*W for _ in range(H)]
    res = most_distant_point(grid, visit, start=p[0])
    return res[1]


def diameter2(grid):
    res = 0
    for h in range(H):
        for w in range(W):
            if grid[h][w] == road and visit[h][w] == 0:
                temp = diameter(grid, visit, (h,w))
                if temp > res:
                    res =temp
    return res

############################################################################################


######################################################
# スタート地点がinputで与えられる場合 (h軸とw軸の反転に注意)
######################################################

road, wall = ".", "#"                         # (進行可能を意味する記号, 進行不可を意味する記号)

H,W = map(int,input().split())                # 左上は(h,w)=(0,0)、右下は(h,w)=(H-1,W-1)

grid = []
for h in range(H):
    grid.append(input().rstrip())                # 文字列を読み込むと改行が入るため、rstrip()で消す

visit = [[0]*W for _ in range(H)]
res = diameter2(grid)           #  visitを初期化せずに何度も呼び出すと、visit が変わって返り値も変わるので注意

print(res)


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

// ceil() for integer dividing
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))

constexpr int MAX_N = 30 + 1;
int N;
int dp[MAX_N];

int main() {
  while (true) {
    cin >> N;
    if (N == 0)
      break;
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 4;
    for (int i{4}; i <= N; ++i) {
      dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    }
    cout << DIVCEIL(dp[N], 365 * 10) << endl;
  }

  return 0;
}



Measured memory_bytes: 3032
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int x[100010], w[100010];
signed main(void)
{
  int n, l, t;
  cin >> n >> l >> t;
  REP(i, n) {
    cin >> x[i] >> w[i];
    if(w[i]==2) w[i] = -1;
  }

  VI v;
  ll st = 0;
  REP(i, n) {
    ll pos = x[i]+w[i]*t;
    v.PB((pos%l+l)%l);
    if(pos < 0) st = (st-((-(pos+1)/l)+1)) % n;
    else st = (st + (pos/l)) % n;
    // cout << "i:" << i << " pos:" << pos << " " << st << endl;
  }
  sort(ALL(v));
  REP(i, n) cout << v[(i+st+n)%n] << endl;

  return 0;
}


Measured memory_bytes: 3700
import numpy as np
K,A,B = map(int,input().split())
maximum=0
if (A>=B-1):
    maximum=K+1
elif(K<A+1):
    maximum=K+1
elif((K-A+1)%2==0):
    maximum=A+(B-A)*((K-A+1)//2)
else:
    maximum=A+(B-A)*((K-A)//2)+1
print(maximum)


Measured memory_bytes: 18744
#include <bits/stdc++.h>
using namespace std;
const int N=100000+10;
struct EDGEE
{
	int nxt, to;
}edge[N<<1];
int head[N], tot = 0;
void add(int x,int y)
{
	edge[tot]=(EDGEE){head[x], y};
	head[x]=tot++;
}
int n,m;
int ans=0;
int dfs(int x, int fa)
{
	int ret=0;
	for(int i=head[x];i;i=edge[i].nxt)
		if(edge[i].to!=fa)
		{
			int tmp=dfs(edge[i].to,x);
			if(tmp==m-1) ans += (x != 1);
			else ret=max(ret,tmp+1);
		}
	return ret;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(i==1) ans+=(x!=1);
		else add(i,x), add(x,i);
	}
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e7 + 5;

int lp[MAXN];
ll div_count[MAXN];
vector<int> prime;

void init(int n)
{
    lp[1] = 1;
    for(int i = 2; i < MAXN; i++)
    {
        if(!lp[i])
            lp[i] = i, prime.pb(i);
        for(int j = 0; j < sz(prime) && i * 1LL * prime[j] < 1LL * MAXN; j++)
        {
            lp[i * prime[j]] = prime[j];
            if(i % prime[j] == 0)
                break;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        int temp = i;
        map<int, int> freq;
        while(temp > 1)
        {
            freq[lp[temp]]++;
            temp /= lp[temp];
        }
        ll cnt = 1;
        for(auto x : freq)
        {
            cnt *= 1LL * (x.ss + 1);
        }
        div_count[i] = cnt;
    }
}


int main()
{
    FASTIO;
    int n;
    cin >> n;
    init(n);
    ll ans = 0;
    for(int i=1;i<=n;i++)
    	ans += i*1LL*div_count[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 123260
#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 n;
  cin >> n;
  ll V = 0, E = 0;
  for (int i = 1; i <= n; ++i) V += ll(i)*(n-i+1);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a,b);
    E += ll(a)*(n-b+1);
  }
  ll ans = V-E;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
def attackSurvival(n,k,q):
    points = [k]*n
    p = [q]*n

    for i in range(q):
        a = int(input())-1
        p[a]-=1
    
    res = ""
    for j in range(n):
        if points[j]<=p[j]:
            res+="No\n"
        else:
            res+="Yes\n"
    print(res)
(n,k,q) = map(int,input().split(" ")) 
attackSurvival(n,k,q)

Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
bool judge(int n){
	if(n>=2000) return 1;
	if(n<100) return 0;
	int k=n%100;
	int sum=(n-k)/100;
	if(k<=(sum*5)) return 1;
	else return 0;
}
int main(){
	ll x;
	cin>>x;
	cout<<judge(x)<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
#print(N)

# 10進数で与えられた番号を、26進数に直すという問題
# N番目は、それまでの桁ごとの26進数の累積和 + その桁の計算で求められる
# 26の10累乗までは範囲内.つまり犬の名前は最大で11桁になる
# 26の11乗で3670344486987776で超える

MAX_DIGIT = 11

powers = (1, 26, 676, 17576, 456976, 11881376, 
          308915776, 8031810176, 208827064576, 
          5429503678976, 141167095653376 )

# 桁数の一番最初を示すNは何になるかというと累積和で計算できる.予め計算しておく
# つまりN=1はa, N=27はaa, N=12356631はaaaaaa
digits = (0, 1, 27, 703, 18279, 475255, 12356631, 321272407,
          8353082583, 217180147159, 5646683826135, 146813779479511
)

abc = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n',
       'o','p','q','r','s','t','u','v','w','x','y','z')

  

# 桁数を減らしながら累積和配列の中から、その値以下で最も大きいものを選択していけばよい

# 桁数決定
total_digit = 0
less_than_11 = False
for i in range(1, MAX_DIGIT + 1):
  if(N < digits[i]):
    less_than_11 = True
    total_digit = i - 1
    break

if not(less_than_11):
  total_digit = 11
  
#print("{0}を犬の名前にすると、{1}桁ある.".format(N, total_digit))

# 0番地は使わない。最終的に除去する
name = [''] * (total_digit + 1)
#print("現在の名前は{0}".format(name))
for each_digit in range(total_digit, 0, -1):
  N -= 1
  num = N % 26
  N = N // 26
  name[each_digit] = abc[num]
  #print("{0}桁目はアルファベット{1}番目なので{2}で、商が{3}".format(each_digit,
  #                                              num, abc[num], N))
  #print(name)

print(''.join(name[1::]))



Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
using dd = double;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  ull odds = 0;
  ull evens = 0;

  if (n % 2 == 0) {
    odds = n / 2;
    evens = n / 2;
  } else {
    odds =  (n / 2) + 1;
    evens = n / 2;
  }

  cout << (dd)((dd)odds / (dd)n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

ll dp[3010][3010][4];
signed main(){
    int h,w,t;cin>>h>>w>>t;
    using P=pair<int,int>;
    map<P,vector<ll>> v;
    rep(_,t){
        int i,j;ll x;cin>>i>>j>>x;i--,j--;
        v[P(i,j)].push_back(x);
    }

    for(auto &p:v){
        sort(ALL(p.second));
    }

    rep(i,h+1)rep(j,w+1){
        vector<ll> s;
        s.push_back(0);
        if(v.count(P(i,j))){
            auto &w=v[P(i,j)];
            sort(ALL(w));
            reverse(ALL(w));
            rep(i,min(3,(int)w.size())){
                s.push_back(s.back()+w[i]);
            }
        }

        // 上に行く．
        if(i<h)
        rep(u,4)rep(v,s.size())if(u+v<=3) chmax(dp[i+1][j][0],dp[i][j][u]+s[v]);
        // 右に行く
        if(j<w)
        rep(u,4)rep(v,s.size())if(u+v<=3) chmax(dp[i][j+1][u+v],dp[i][j][u]+s[v]);
    }
    ll ans=0;
    rep(i,4)chmax(ans,dp[h][w][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 307628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;

void solve1()
{
   int x1, y1, x2, y2;
   cin >> x1 >> y1 >> x2 >> y2;

   int diffx = x1-x2;
   int diffy = y1-y2;

   cout << x2 + diffy << " " << y2 - diffx << " ";
   cout << x2 + diffy + diffx << " " << y2 - diffx + diffy << endl;
}

int main()
{
   solve1();
}

Measured memory_bytes: 3628
n, m = map(int, input().split())
l, r = map(int, input().split())
ans = -1
if m > 1:
    for i in range(m-1):
        _l, _r = map(int, input().split())
        if (l < _l <= r):
            l = _l
        if (l <= _r < r):
            r = _r
        if _r < l or r < _l:
            ans = 0
            print(ans)
            break

if ans == -1:
    print(r-l+1)


Measured memory_bytes: 43608
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[1100][1100];
int v[1100][1100];
int x[1100];
int y[1100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d%d",x+i,y+i);
	for(int i=0;i<a;i++){
		dp[i][i]=0;v[i][i]=i;
	}
	for(int i=1;i<a;i++){
		for(int j=0;i+j<a;j++){
			int now=999999999;
			for(int k=v[j][j+i-1];k<=v[j+1][j+i];k++){
			//	if(k==a-1)continue;
				if(k<j||k>=j+i)continue;
				int cost=dp[j][k]+dp[k+1][j+i]+y[k]-y[i+j]+x[k+1]-x[j];
			//	printf("%d %d %d %d\n",y[k],y[i+j],x[k+1],x[j]);
				if(now>cost){
					v[j][j+i]=k;
					now=cost;
				}
			}
			dp[j][j+i]=now;
		//	printf("%d %d: %d %d\n",j,j+i,now,v[j][j+i]);
		}
	}
	printf("%d\n",dp[0][a-1]);
}

Measured memory_bytes: 10044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,k,a,b,c,tmp,tmp1;
	scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);
    tmp=max(a,b);
    tmp1=tmp=max(tmp,c);
    for(i=0;i<k;i++)
    {
    	tmp*=2;
	}
	tmp=tmp+a+b+c-tmp1;
	printf("%d",tmp);
	return 0;
}

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

const int MOD = 1000000007;
#define p(var) std::cout<<#var" = "<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a;}
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b;}

int N;
//A=0 C=1 G=2 T=3
//arr[n][i][j][k] n+1文字の長さで、末尾3文字目がi,末尾3文字目がj,末尾3文字目がkで、条件を満たす文字列の数
ll arr[100][4][4][4];

//n文字の長さで、末尾4文字目がa4,末尾3文字目がa3,末尾2文字目がa2,末尾1文字目がa1で、条件を満たす文字列の数
ll isOK(int n,int a4,int a3,int a2,int a1){
    if(n<1)return 0;

    if(a3==0 && a2==2 && a1==1)return 0;
    if(a3==2 && a2==0 && a1==1)return 0;
    if(a3==0 && a2==1 && a1==2)return 0;

    if(n==2){
        return 1;
    }

    if(a4==0 && a2==2 && a1==1)return 0;
    if(a4==0 && a3==2 && a1==1)return 0;
    return arr[n-1][a4][a3][a2];
}



int main(){
    cin >> N;

    rep(i,4){
        rep(j,4){
            rep(k,4){
                arr[2][i][j][k]=isOK(2,-1,i,j,k);
            }
        }
    }

    rep(n,N){
        if(n<3)continue;
        rep(i,4){
            rep(j,4){
                rep(k,4){
                    //n文字の長さで条件を満たす文字列の数
                    // =n-1文字の長さの各パターンに、ACGTを付け足す
                    rep(l,4){
                        arr[n][j][k][l]+=isOK(n,i,j,k,l);
                        arr[n][j][k][l] %= MOD;
                    }
                }
            }   
        }   
    }

    ll a=0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                a+=arr[N-1][i][j][k];
                a %= MOD;
            }
        }   
    } 

    cout << a << endl;
    return 0;
    
}






Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,ac(0),wa(0),tle(0),re(0); cin>>n;
    string x[n];
    for (int i=0;i<n;i++) {
        cin>>x[i];
        if (x[i]=="AC") ac++;
        else if (x[i]=="WA") wa++;
        else if (x[i]=="TLE") tle++;
        else re++;
    }
    printf ("AC x %d \nWA x %d \nTLE x %d \nRE x %d \n", ac, wa, tle, re);
}


Measured memory_bytes: 6852
#include <iostream>

using namespace std;

int main()
{
    int n, m, x;
    int a[110];
    int l1=0,r1=0;
    cin>>n>>m>>x;
    int i;

    for(i=0;i<m;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<m;i++)
    {
        if(a[i]<x){
            ++l1;
        }
        else if(a[i]>x)++r1;
    }
    if(l1<r1){
        cout<<l1<<endl;
    }
    else cout<<r1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;int a,b;cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b){
		cout << "Alice" << endl;
	}else if(a<b){
		cout << "Bob" << endl;
	}else{
		cout << "Draw" << 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);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int L[] = new int[N];
		int sum = 0;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
			sum += L[i];
			if(sum <= X) {
				ans++;
			}
		}
		
		System.out.println(++ans);
	}
}


Measured memory_bytes: 21844
n = int(input())
card = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]

for i in range(n) :
    suit,num = input().split()
    num = int(num)
    card[pattern.index(suit)][num - 1] = True;

for i in range(4) :
    for j in range(13) :
        if card[i][j] == False : print(pattern[i],j+1)



Measured memory_bytes: 5600
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
	unsigned int x,y,n;
	cin>>n;
    x=n*800;
    if(n>=15)
    cout<<x-(n/15*200);
    else
	cout<<x;
	return 0;
}

Measured memory_bytes: 256