akhauriyash/Code-Regression huggingface dataset:
n = int(input())
H = list(map(int, input().split()))

ans = [0] * n

ans[1] = abs(H[0]-H[1])
for i in range(2, n):
    ans[i] = min(ans[i-2]+abs(H[i-2]-H[i]), ans[i-1]+abs(H[i-1]-H[i]))
print(ans[-1])

Measured memory_bytes: 13980
import sys, re
#from collections import deque, defaultdict, Counter
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
#from itertools import permutations, combinations, product
#from operator import itemgetter, mul
from copy import deepcopy,copy
#from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, x = MAP()

lis = MAP()

d = 0
ct = 1

for y in lis:
    d += y
    if d > x:
        print(ct)
        break
    else:
        ct += 1
else:
    print(n+1)



Measured memory_bytes: 3680
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    string s;
    cin>>s;
    int ans = 0,count = 0;

    for(int i=0;i<s.size();++i) {
        if(s[i] == 'A' or s[i] == 'G' or s[i] == 'T' or s[i] == 'C') {
            ++count;
            ans = max(ans,count);
        }
        else {
            ans = max(ans,count);
            count = 0;
        }
    }
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s, t;
	cin >> s >> t;
	
	int ans = 0;
	for(int i = 0; i < s.size(); ++i) {
		if( s[i] == t[i] ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()


int main (void) {

  std::string S; std::cin >> S;

  int acnt = 0;
  long long ans = 0;
  for(int i=0; i<S.size(); i++) {
    if ( S[i] == 'A' ) acnt++;
    else if ( S[i] == 'B' ) {
      if ( i<(S.size()-1) && S[i+1] == 'C' ) {
        ans += acnt;
        i++;
      }
      else acnt = 0;
    }
    else acnt = 0;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int s;
  cin>>s;
  
  vector<int> c(1000000);
  c[0]=s;
  for(int i=0;i<1000000;i++){
    if(c[i]%2==0){
      c[i+1]=c[i]/2;
    }
    else if(c[i]%2==1){
      c[i+1]=3*c[i]+1;
    }
  }
  
  for(int i=0;i<=1000000;i++){
    for(int j=i+1;j<=1000000;j++){
      if(c[i]==c[j]){
        cout<<j+1<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 7212
#include<stdio.h>
int main(void){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2148
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    a = li()
    a.insert(0, 0)
    a.append(0)
    rin = []

    for i in range(n + 1):
        rin.append(abs(a[i] - a[i + 1]))
    drin = []
    for i in range(n):
        drin.append(abs(a[i] - a[i + 2]))
    tmpall = sum(rin)

    for i in range(n):
        print(tmpall - rin[i] - rin[i + 1] + drin[i])


main()


Measured memory_bytes: 21736
#!/usr/bin/env python3
import sys
rl = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

N = int(rl())
SL = read().split()

A, W, T, R = ord('A'), ord('W'), ord('T'), ord('R')
na, nw, nt, nr = 0, 0, 0, 0
for s in SL:
  if s[0] == A:
    na += 1
  elif s[0] == W:
    nw += 1
  elif s[0] == T:
    nt += 1
  elif s[0] == R:
    nr += 1

print('AC x ' + str(na))
print('WA x ' + str(nw))
print('TLE x ' + str(nt))
print('RE x ' + str(nr))

Measured memory_bytes: 15244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int money = 0;
		if (x == 1) {
			money += 300000;
		} else if (x == 2) {
			money += 200000;
		} else if (x == 3) {
			money += 100000;
		}
		if (y == 1) {
			money += 300000;
		} else if (y == 2) {
			money += 200000;
		} else if (y == 3) {
			money += 100000;
		}
		if (x == 1 && y == 1) {
			money += 400000;
		}
		System.out.println(money);
	}
}


Measured memory_bytes: 21844
/**
 *    author        : Saurav Paul 
 *    created       : August 21, 2020 5:48 PM
 *    Problem Name  : D - Sum of Divisors
 *    Problem Limit : 3000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc172/tasks/abc172_d
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

void solve(){

    ll N ;
    cin >> N ;
    vector<int> nod(N+1) ;

    for(int i = 1 ; i <= N ; i++){
        for(int j = i ; j <= N ; j+= i){
            nod[j] ++ ;
        }
    }

    ll answer = 0 ;

    for(int i = 1 ; i <= N ; i++){
        answer += (ll) nod[i] * i ;
    }

    cout << answer << endl ;

}

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


Measured memory_bytes: 42288
#include <bits/stdc++.h>
#define Tayeb ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;
int main()
{
    Tayeb;
    int N,val1,count=0;
    cin >> N;
    int arr[N],arr2[N];
    for(int i=0; i<N; i++)
    {
        cin >> arr[i];
        arr2[i]=arr[i];

    }
    sort(arr,arr+N);

    for(int i=0; i<N; i++)
    {
        if(arr[i]!=arr2[i])
        count++;
    }
    if(count==0||count==2)
    cout << "YES\n";
    else
    cout << "NO\n";

    return 0;

}


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

using namespace std;

int main() {

    long long h;
    cin >> h;

    long long ans = 0, x = 1;

    while (h != 1) {
        h /= 2;
        ans += x;
        x *= 2;
    }

    ans += x;

    cout << ans;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

vector<ll> temp;
void change(vector<ll>& dp, ll num)
{
  temp = dp;
  for (ll i = 0; i < 13; ++i)
  {
    ll inum = i + num;
    inum %= 13;
    if (inum < 0)
    {
      inum += 13;
    }
    dp.at(inum) = temp.at(i);
  }
}

int main()
{
  ll mod = 1000000007;
  string S;
  cin >> S;
  ll N = S.size();
  vector<ll> dp(13, 0);
  dp.at(0) = 1;
  for (ll i = 0; i < N; ++i)
  {
    if (S[N - i - 1] != '?')
    {
      ll num = (S[N - i - 1] - '0') * pow(10, i % 3);
      // cout << num << endl;
      if ((i / 3) % 2 == 0)
      {
        change(dp, num);
      }
      else
      {
        change(dp, -num);
      }
    }
    else
    {
      temp = dp;
      ll power = pow(10, i % 3);
      if ((i / 3) % 2 == 0)
      {
        for (ll j = 1; j < 10; ++j)
        {
          for (ll k = 0; k < 13; ++k)
          {
            dp.at((k + j * power) % 13) += temp.at(k);
            dp.at((k + j * power) % 13) %= mod;
          }
        }
      }
      else
      {
        for (ll j = 1; j < 10; ++j)
        {
          for (ll k = 0; k < 13; ++k)
          {
            ll kj = (k - j * power) % 13;
            if (kj < 0)
            {
              kj += 13;
            }
            dp.at(kj) += temp.at(k);
            dp.at(kj) %= mod;
          }
        }
      }
    }
  }
  cout << dp.at(5) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;
const ll INF = ll(1e18)+1;

int main(){
   int n, k;
   cin >> n >> k;
   int keta = 0;
   while(n != 0){
      n /= k;
      keta++;
   }
   cout << keta << endl;
   return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    cout<<fixed<<setprecision(20);
    cout<<2*in()*M_PI<<endl;
}


Measured memory_bytes: 3772
#include <cmath>
#include <queue>
#include <tuple>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, c, a, b;
int main() {
	ios::sync_with_stdio(false);
	while (cin >> n >> m, n | m) {
		vector<vector<pair<int, int> > > v(n);
		for (int i = 0; i < n; i++) {
			cin >> c;
			for (int j = 0; j < c; j++) {
				cin >> a >> b;
				v[i].push_back(make_pair(a, b));
			}
		}
		vector<vector<vector<int> > > d(n);
		for (int i = 0; i < n; i++) d[i] = vector<vector<int> >(v[i].size(), vector<int>(m + 1, 999999999));
		priority_queue<tuple<int, int, int, int> > que; // (dist, y, x, z)
		for (int i = 0; i <= 1 && i <= m; i++) {
			for (int j = 0; j < v[i].size(); j++) {
				d[i][j][i] = 0;
				que.push(make_tuple(0, i, j, i));
			}
		}
		while (!que.empty()) {
			tuple<int, int, int, int> t1 = que.top(); que.pop();
			int a1 = -get<0>(t1), b1 = get<1>(t1), c1 = get<2>(t1), d1 = get<3>(t1);
			for (int i = 1; i <= 2 && b1 + i < n; i++) {
				if (i == 2 && d1 == m) continue;
				for (int j = 0; j < v[b1 + i].size(); j++) {
					int s = abs(v[b1][c1].first - v[b1 + i][j].first) * (v[b1][c1].second + v[b1 + i][j].second);
					if (d[b1 + i][j][d1 + i - 1] > a1 + s) {
						d[b1 + i][j][d1 + i - 1] = a1 + s;
						que.push(make_tuple(-d[b1 + i][j][d1 + i - 1], b1 + i, j, d1 + i - 1));
					}
				}
			}
		}
		int ret = 999999999;
		for (int i = 0; i <= 1 && i <= m; i++) {
			for (int j = 0; j < v[n - i - 1].size(); j++) {
				for (int k = 0; k <= m - i; k++) {
					ret = min(ret, d[n - i - 1][j][k]);
				}
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 5448
<?PHP
$s=fgets(STDIN);
$m=0;
$p=0;
for($i=0;$i<strlen($s);$i++){
  $p++;
  if(strcmp($s[$i],A)&&strcmp($s[$i],T)&&strcmp($s[$i],G)&&strcmp($s[$i],C))$p=0;
  $m=$m<$p?$p:$m;
}
echo $m;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n, k;
    cin >> n >> k;
    map<int, bool> mp;
    rep(i, k)
    {
        int d;
        cin >> d;
        rep(j, d)
        {
            int t;
            cin >> t;
            mp[t] = true;
        }
    }
    int ans = n;
    rep(i, 1, n + 1)
    {
        if (mp[i])
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string a,b; cin>>a>>b;
    int n,m; cin>>n>>m;
    string s; cin>>s;
    if(s==a) n--;
    else m--;
    cout<<n<<" "<<m<<endl;
}

Measured memory_bytes: 256
n = int(input())
def f(s):
  if int(s) > n:
    return 0 #再帰終了
  if s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
  	cnt = 1
  else:
  	cnt = 0
  cnt += f(s + "3")
  cnt += f(s + "5")
  cnt += f(s + "7")
  return cnt
  
result = f("0")
print(result)

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

string s[3030];

ll orb[3030][3030],ingot[3030][3030];

int main(void){
	int h,w,i,j;
	ll ans=0ll;
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> s[i];
	}
	for(i=(h-1); i>=0; --i){
		for(j=(w-1); j>=0; --j){
			orb[i][j] = orb[i][j+1];
			if(s[i][j]=='O'){
				++orb[i][j];
			}
			ingot[i][j] = ingot[i+1][j];
			if(s[i][j]=='I'){
				++ingot[i][j];
			}
		}
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			if(s[i][j]=='J'){
				ans += orb[i][j]*ingot[i][j];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 166036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int h,w;
  cin >> h >> w;
  int ch,cw,dh,dw;
  cin >> ch >> cw >> dh >> dw;
  vector<vector<char>> maze(h+2,vector<char>(w+2,'#'));
  rep1(i,h) rep1(j,w) cin >> maze[i][j];
  vector<vector<bool>> seen(h+2,vector<bool>(w+2,0));
  vector<vector<int>> warp(h+2,vector<int>(w+2,-1));
  deque<pair<int,int>> q;
  q.push_front({ch,cw});
  warp[ch][cw] = 0;
  while(!q.empty()){
    int a = q.front().first;
    int b = q.front().second;
    q.pop_front();
    if(seen[a][b]) continue;
    seen[a][b] = 1;
    for (int i=-2;i<=2;i++){
      for (int j=-2;j<=2;j++){
        int nA = a+i;
        int nB = b+j;
        if(nA<0 || h<nA) continue;
        if(nB<0 || w<nB) continue;
        if(seen[nA][nB]) continue;
        if(maze[nA][nB]=='#') continue;
        bool sub1 = i==-1 && j==0;
        bool sub2 = i==1 && j==0;
        bool sub3 = i==0 && j==-1;
        bool sub4 = i==0 && j==1;
        if(sub1 || sub2 || sub3 || sub4){
          if(warp[nA][nB]==-1){
            warp[nA][nB] = warp[a][b];
          }else{
            warp[nA][nB] = min(warp[nA][nB],warp[a][b]);
          }
          pair<int,int> nextQ = {nA,nB};
          q.push_front(nextQ);
        }else{
          if(warp[nA][nB]==-1){
            warp[nA][nB] = warp[a][b]+1;
          }else{
            warp[nA][nB] = min(warp[nA][nB],warp[a][b]+1);
          }
          pair<int,int> nextQ = {nA,nB};
          q.push_back(nextQ);
        }
      }
    }
  }
  cout << warp[dh][dw] << endl;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


signed main(void)
{
	IOS;
	int k; cin>>k;
	int sum=0;
	for(int i = 1; i <= k; i++) {
		for(int j = 1; j <= k; j++) {
			for(int l=1; l<=k; l++) {
				sum += __gcd(i,__gcd(j,l));
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>

using namespace std;

int a[101];

int main(void){
  int n,m,x;
  int c0, cn;
  
  scanf("%d%d%d", &n, &m, &x);
  for (int i=0; i<m; i++){
    int t;
    scanf("%d", &t);
    a[t]=1;
  }
  
  c0=cn=0;
  for (int i=x-1; i>=0; i--){
    c0 += a[i];
  }
  for (int i=x+1; i<=n; i++){
    cn += a[i];
  }
  
  printf("%d\n", c0<cn?c0:cn);
  return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int l[m], r[m];
    int left = 0;
    int right = 100000;
    for(int i=0;i<m;i++){
        cin >> l[i] >> r[i];
    }
    for(int j=0;j<m;j++){
        if(l[j] > left){
            left = l[j];
        }
        if(r[j] < right){
            right = r[j];
        }
    }
    if(right >= left){
        cout << right - left + 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
// 基本テンプレート (縮小版)

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int dp[62][3];

signed main() {
    cin >> N;
    dp[0][0] = 1;
    rep(i,0,61) rep(c,0,3) rep(x,0,2) rep(y,x,2) {
        int val = (N >> i & 1) - c - x - y;
        (dp[i+1][(1-val)/2] += dp[i][c]) %= MOD;
    }
    cout << dp[61][0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    string S;
    cin >> S;
    sort(S.begin(), S.end());
    if (S[0] == S[2]) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        while(m%2==0&&m) ans++,m/=2;
    }
    printf("%d\n",ans);

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ans = [""] * m
arr = []
cnt = 1
for i in range(m):
    p, y = map(int, input().split())
    arr.append((p, y, i))
arr.sort()

ans[arr[0][2]] = "{:06}{:06}".format(arr[0][0], cnt)
for i in range(1, m):
    if arr[i - 1][0] == arr[i][0]:
        cnt += 1
    else:
        cnt = 1
    ans[arr[i][2]] = "{:06}{:06}".format(arr[i][0], cnt)

for i in ans:
    print(i)

Measured memory_bytes: 29028
from heapq import*
i=input
for*x,_ in'_'*int(i()):
 n,s,*y=int(i()),0
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:
  x.sort();n,*h=len(x),
  while n:
   while[[n]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[1]
   n-=1
  for*_,r in x+h:s+=r
 print(s)

Measured memory_bytes: 47768
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define ull unsigned long long
#define ALL(v) ((v).begin()), ((v).end())
#define INCREASING(v) sort(ALL(v))
#define DECREASING(v) INCREASING(v), reverse(ALL(v))
#define SZ(v)   ((int)((v).size()))
#define LP(c,x,n)  for(int c=x;c<n;c++)
#define LO(c,n,x)  for(int c=n;c>=x;c--)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define PI ( 2 * acos(0.0))
#define EPS 1e-8
#define INF 1.0/0.0
#define Yala_Besor3a ios_base::sync_with_stdio(0),ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ReadFile freopen("delivery.in","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
using namespace std;
const int OO = 0x3f3f3f3f,NegOO= -1*OO,N =1e3+5,mod =1e9+7 ;
int n,m;
int dp[N][N];
char arr[N][N];
bool vis[N][N];
int cnt=0;
int solve(int i,int j)
{
   // cout<<cnt++<<endl;
    if(i<0||j<0||j>m-1||i>n-1||arr[i][j]=='#')return 0;
    if(i==n-1&&j==m-1)return 1;
    int &rf=dp[i][j];
    if(~rf)return rf%mod;
    rf=0;
    rf=solve(i+1,j)%mod;
    rf+=solve(i,j+1)%mod;
    return rf%mod;
}
int main()
{
    //Yala_Besor3a;
    cin>>n>>m;
    LP(c,0,n)LP(i,0,m)cin>>arr[c][i];
    memset(dp,-1, sizeof(dp));
    cout<<solve(0,0)%mod<<endl;
    return 0;
}

Measured memory_bytes: 5248
from collections import Counter

c = Counter()

n = int(input())

for i in range(n):
    text = input()
    if text == "AC":
        c["AC"] += 1
    elif text == "WA":
        c["WA"] += 1
    elif text == "TLE":
        c["TLE"] += 1
    elif text == "RE":
        c["RE"] += 1

print("AC x {}".format(c["AC"]))
print("WA x {}".format(c["WA"]))
print("TLE x {}".format(c["TLE"]))
print("RE x {}".format(c["RE"]))

        

Measured memory_bytes: 9368
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w, a, b = map(int, read().split())
for i in range(b):
    print('1' * (w - a) + '0' * a)
for i in range(h - b):
    print('0' * (w - a) + '1' * a)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

  int X;
  cin >> X;
  cout << (X >= 30 ? "Yes" : "No") << endl;
      
  return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  double r;
  cin >> r;
  cout << setprecision(20) << fixed << r * 2 * 3.14159 << endl;
  return 0;
}

Measured memory_bytes: 3804
sum=0
list=[]
sum_list=[]
while True:
    n=int(input())
    if n!=0:
        list.append(n)
    else:
        break
for i in list:
    i=str(i)
    for j in range(len(i)):
        sum+=int(i[j])
    sum_list.append(sum)
    sum=0

for i in sum_list:
    print(i)




Measured memory_bytes: 5620
#include<stdio.h>
int main(void)
{
	int i,j,n,m,a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]<a[j]){
				m=a[i];
				a[i]=a[j];
				a[j]=m;
			}
		}
	}
	printf("%d\n",a[0]-a[n-1]);
	return 0;
}

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


using namespace std;
vector<vector<char>> vec;
int n,m;
int meme[1007][1007];
const int M=1000000007;


int solve(int x , int y){
    if(x>=n || x<0 || y>=m || y<0 || vec[x][y]=='#'){
        return 0;
    }
    if(x==n-1 && y==m-1){
        return (1%M);
    }
    int &ret = meme[x][y];
    if(~ret){
        return ret%M;
    }
    ret = ((solve(x+1,y)%M) + (solve(x,y+1)%M))%M;
    
    return ret%M;
}

int main(){
        cin>>n>>m;
        memset(meme,-1,sizeof(meme));
        vec = vector<vector<char>>(n+2,vector<char>(m+2));
        string line;
        for(int i = 0 ; i<n ; i++){
            cin>>line;
            for(int j = 0 ; j<line.size() ; j++){
                vec[i][j] = line[j];
            }
        }
        cout<<solve(0,0)<<endl;

    return 0;
}

Measured memory_bytes: 8580
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N, K;

    cin >> N >> K;

    double result = 0;

    for (int i = 1; i <= N; i++) {
        int s = i;
        int count = 0;
        while (s < K) {
            s*=2;
            count++;
        }

        result += double(1) / double(N * pow(2, count));
    }

    printf("%.12f\n", result);
}

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

#define ll long long
const int N = 2e5+5;

ll A[N];

int pen[N];
void update(int ind,int add) {
   while(ind<N) {
      pen[ind] += add;
      ind += ind&(-ind);
   }
}
int query(int ind) {
   int ret = 0;
   while(ind>0) {
      ret += pen[ind];
      ind = ind&(ind-1);
   }
   return ret;
}

int f(vector<ll> &g,ll x) {
   int l = 0,r = g.size()-1,mid;
   while(l<r) {
      mid = (l+r+1)/2;
      if(g[mid]<=x) {
         l = mid;
      } else {
         r = mid-1;
      }
   }
   return l+1;
}

void solve() {
   int n,k;
   scanf("%d %d",&n,&k);
   map<ll,int> Hash;
   Hash[0] = 0;
   vector<ll> gg;
   gg.push_back(0);
   ll inf = -1e18;
   gg.push_back(inf);
   for(int i=1;i<=n;++i) {
      scanf("%lld", &A[i]);
      A[i] = A[i]- k;
      A[i] = A[i] + A[i-1];
      Hash[A[i]];
      gg.push_back(A[i]);
   }
   int pos = 1;
   sort(gg.begin(),gg.end());
   ll ret = 0;
   int zero_ind = f(gg,0)+1;

   update(zero_ind,1);
   for(int i=1;i<=n;++i) {
      ll x= A[i];
      ll ind = f(gg,x)+1;
      ret += query(ind);
      update(ind,1);
   }
   printf("%lld\n", ret);
}

int main()
{
   //freopen("input.txt","r",stdin);
   solve();
}

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

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 3e5+35;
const int maxn = 4e3+23;
LL A,B,n;
int main(){
    cin >> A >> B >> n;
    LL x = min(n,B-1);
    cout << (A*(x%B)-(A*x%B))/B;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include <map>
#include<algorithm>
using namespace std;
int search(string, pair<string, int>*, pair<string, vector<string> >*);
int n;
int m,si;
int main()
{
	
	while (true){
		pair<string, int>p[101];
		pair<string, vector<string> >chan[101];
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> p[i].first >> p[i].second;
		}

		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> chan[i].first >> si;
			for (int i2 = 0; i2 < si; i2++){
				string s;
				cin >> s;
				chan[i].second.push_back(s);
			}
		}
		string s;
		cin >> s;
		int ans = search(s,p,chan);
		cout << ans << endl;
	}
}
int search(string s, pair<string, int>*p, pair<string, vector<string> >*chan){
	int num = 0;
	bool flag = true;
	for (int i = 0; i < m; i++){
		if (chan[i].first == s){
			flag = false;
			for (int i2 = 0; i2 < chan[i].second.size(); i2++){
				num += search(chan[i].second[i2],p,chan);
			}
		}
	}
	if (!flag){
		int k;
		for (int i = 0; i < n; i++){
			if (p[i].first == s){
				num=min(p[i].second,num);
				break;
			}
		}
	}
	if (flag){
		for (int i = 0; i < n; i++){
			if (p[i].first == s){
				num += p[i].second;
			}
		}
	}
	return num;
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for(auto& e : h) cin >> e;
    sort(h.begin(), h.end());
    long long res;
    if(n <= k){
        res = 0;
    }else{
        res = accumulate(begin(h), end(h) - k, 0LL); 
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
N = list(str(input()))

tmp = len(N)
fx = 0
x = 0
for i in range(tmp):
    x += int(N[i]) * 10 ** (tmp - i - 1)
    fx += int(N[i])

if x % fx == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
from collections import defaultdict
n = int(input())
d = list(map(int, input().split()))

mod = 998244353
di = defaultdict(int)
btr = 0
if d[0] != 0:
    print(0)
    exit()
for i in range(n):
    di[d[i]] += 1

keylist = sorted(list(di.keys()))
if di[0] != 1:
    print(0)
    exit()
result = 1
for i in range(1, len(keylist)):
    if i != keylist[i]:
        print(0)
        exit()
    result = result * (di[i-1] ** di[i]) % mod

print(result)



Measured memory_bytes: 64692
#include <stdio.h>
#include <vector>
#include <queue>
#define INF 100000000
using namespace std;

//firstにh、secondにwを入れる
typedef pair<int, int> PII;

//S、1...Nまでの座標を格納する
PII cheese[10];

const int MAX_H = 1010, MAX_W = 1010;
int H, W, N;
char field[MAX_H][MAX_W];
int d[MAX_H][MAX_W];

int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

bool infield(int h, int w){
    return (0<=h && h<H && 0<=w && w<W);
}

//sからgまでの最短手数を返す
int bfs(PII s, PII g){
    queue<PII> que;
    //init
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++)
            d[i][j] = INF;
    }
    que.push(s);
    d[s.first][s.second] = 0;
    
    while(!que.empty()){
        PII p = que.front(); que.pop();
        if(p == g)
            break;
        for(int i=0; i<4; i++){
            int nh = p.first+dh[i];
            int nw = p.second+dw[i];
            
            if(infield(nh, nw) && field[nh][nw]!='X' && d[nh][nw]==INF){
                que.push(PII(nh, nw));
                d[nh][nw] = d[p.first][p.second] + 1;
            }
        }
    }
    
    return d[g.first][g.second];
}

void solve(){
    int ans = 0;
    
    //cheeseリストを作る
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(field[i][j] == 'S')
                cheese[0] = PII(i, j);
            
            for(char c='1'; c<='9'; c++){
                if(field[i][j] == c)
                    cheese[c-'0'] = PII(i, j);
            }
        }
    }
    for(int i=0; i<N; i++)
        ans += bfs(cheese[i], cheese[i+1]);
    printf("%d\n", ans);
}

int main(){
    scanf("%d%d%d", &H, &W, &N);
    for(int i=0; i<H; i++)
        scanf("%s", field[i]);
    solve();
    return 0;
}

Measured memory_bytes: 6028
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin >> K;
    cout << num[K-1] << endl;
    
    return 0;
    
}



Measured memory_bytes: 256
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vi a(n);
	loop(i,n)
	cin>>a[i];
	int ans=0;
	int count=0;
	l00p(i,1,n)
	{
		if(a[i]>a[i-1])
		{
			ckmax(ans,count);
			count=0;
		}
		else 
		count++;
	}
	ckmax(ans,count);
	cout<<ans;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3708
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>

using namespace std;

map<char, string> make(){
  map<char, string> data;
  data.insert(make_pair('0', "0000"));
  data.insert(make_pair('1', "0001"));
  data.insert(make_pair('2', "0010"));
  data.insert(make_pair('3', "0011"));
  data.insert(make_pair('4', "0100"));
  data.insert(make_pair('5', "0101"));
  data.insert(make_pair('6', "0110"));
  data.insert(make_pair('7', "0111"));
  data.insert(make_pair('8', "1000"));
  data.insert(make_pair('9', "1001"));
  data.insert(make_pair('a', "1010"));
  data.insert(make_pair('b', "1011"));
  data.insert(make_pair('c', "1100"));
  data.insert(make_pair('d', "1101"));
  data.insert(make_pair('e', "1110"));
  data.insert(make_pair('f', "1111"));
  return data;
}

string change(map<char, string>& data, const string& str_){
  string str;
  for(int i=0; i<str_.size(); ++i){
    str.append(data[str_[i]]);
  }
  return str;
}

void solve(const string& str){
  int i, j, counter;
  double ans1, ans2;
  // seisuu
  for(i=24, j=0, ans1=0; i>0; --i, ++j){
    if(str[i] == '1') ans1 += pow(2.0, j);
  }
  // syousuu
  for(i=25, j=-1, ans2=0, counter=1; i<32; ++i, --j){
    if(str[i] == '1'){
      ans2 += pow(2.0, j);
      counter = -j;
    }
  }
  if(str[0] == '1') cout << "-";
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(counter);
  cout << ans1+ans2 << endl;
}

int main(){
  int n;
  string str,str_;
  map<char, string> data = make();
  cin >> n;
  for(int i=0; i<n; ++i){
    cin >> str_;
    str = change(data, str_);
    //   cout << str << endl;
    solve(str);
  }
  return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <sstream>

using namespace std;


int main(int argc, const char * argv[]) {
    int A, B, T;
    cin >> A >> B >> T;
    
    cout << ((int)(T / A)) * B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 10000
struct each{
	int w,x;
}a[MAX];
int n,now,b[MAX],v[MAX],nex[MAX],vis[MAX],head[MAX];
inline void add(int x,int y)
{
	nex[++now]=head[x];
	head[x]=now;
	v[now]=y;
}
inline bool com(each x,each y) {
	return x.w<y.w; }
int main()
{
	scanf("%d",&n);
	memset(vis,-1,sizeof(vis));
	for(register int i=1;i<=n;i++)	a[i].x=i,scanf("%d",&a[i].w);
	for(register int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	sort(a+1,a+n+1,com);
	for(int i=1;i<=n;i++) b[a[i].x]=i;
	for(register int i=1;i<=n;i++)
	{
		vis[a[i].x]=0;
		for(register int j=head[a[i].x];j;j=nex[j])
			if(a[b[v[j]]].w<a[i].w&&!vis[v[j]])	vis[a[i].x]=1;
	}
	for(register int i=1;i<=n;i++)	if(vis[i])	printf("%d ",i);
	putchar('\n');
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<string> s(N);
    REP(i, N)
    {
        cin >> s[i];
        sort(ALL(s[i]));
    }
    sort(ALL(s));

    ll ans = 0;
    ll start = 0, end = 1;;
    while(end != N)
    {
        if (s[start] != s[end])
        {
            ans += (end - start) * (end - start - 1) / 2;
            start = end;
        }
        end++;
    }
    ans += (end - start) * (end - start - 1) / 2;

    cout << ans << endl;
}


Measured memory_bytes: 7296
import * as fs from 'fs';

namespace AtCoder.abc092 {

    export class Program {

        constructor(private args: string) {
            this.args = args;
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {
            const [a, b, c, d]: number[] = this.args.split('\n').map(Number);

            console.log(Math.min(a, b) + Math.min(c, d));
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim();
const prg = new AtCoder.abc092.Program(args);
prg.main();


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,steps=0;
  cin>>n;
  while(n>0)
  {
    if(n>=11)
    {
      steps=steps+2*(n/11);
      n=n%11;
    }
    else if(n>6 and n<11){steps=steps+2;n=0;}
    else if(n>0 and n<7){steps++;n=0;}
  }
  cout<<steps;
  
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
A = []
B = []
if n % 2 == 0:
    while len(a) > 0:
        A.append(max(a))
        a.remove(max(a))
        B.append(max(a))
        a.remove(max(a))
else:
    while len(a) > 1:
        A.append(max(a))
        a.remove(max(a))
        B.append(max(a))
        a.remove(max(a))
    A.append(max(a))
print(sum(A) - sum(B))

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

int main(){
	string s; cin >> s;
	while (s.size() >= 5) {
		string fi, si, sv;
		if (s.size() >= 5) fi = s.substr(0, 5);
		if (s.size() >= 6) si = s.substr(0, 6);
		if (s.size() >= 7) sv = s.substr(0, 7);
		if (sv == "dreamer" && s[7] != 'a') s.erase(0, 7); else
		if (si == "eraser"  && s[6] != 'a') s.erase(0, 6); else
		if (fi == "erase" || fi == "dream") s.erase(0, 5);
		else break;
	}
	cout << (s.size() ? "NO" : "YES") << '\n';
}


Measured memory_bytes: 3736
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define sqr(x) (x) * (x)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sc scanf
#define pr printf
#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)
#define INF 1000000000
#define mod 1000000007

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

	map<int, int> sa;
	for (int i = 1; i <= k; i++) {
		int di;
		cin >> di;
		for (int j = 1; j <= di; j++) {
			int ai;
			cin >> ai;
			sa[ai]++;
		}
	}

	int jv = 0;
	for (int i = 1; i <= n; i++)
		jv += (bool)(sa[i] == 0);

	cout << jv << endl;

	return 0;
}


Measured memory_bytes: 3636
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
    double a,b,x;
    cin >> a >> b >> x;

    int taiseki = a * a * b;

    double ans;

    if(taiseki/2 <= x){
        double k = x / a;
        double l = k / a;
        double p = b - l;
        double q = 2*p/a;
        double ans2 = atan(q);
        ans = 180 * ans2 / 3.141592653589793;
    }

    else{
        double m = b*b;
        double n = m/x;
        double q = n/2;
        double ans2 = atan(a*q);
        ans = 180 * ans2 / 3.141592653589793;
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807



string shuffle_str(string & str, int num)
{
  string S1 (num,0);
  string S2 (str.size() - num,0);
  string out;
  for(int i = 0; i < str.size(); i ++)
  {
    if(i < num) 
    {
      S1[i] = str[i];
  }
  else
  {
    S2[i - num] = str[i];
  }
  }
  out = S2 + S1;
  
  return out;
}

void solve(void)
{

  int N;
  cin>> N;

  vector<int> point (2,0);

  for (int i = 0; i < N; i++)
  {
    string A , B;
    cin>>A>>B;
    if(A > B)
    {
      point[0] += 3;
    }
    else if(A < B)
    {
      point[1] += 3;
    }
    else
    {
      point[0]++;
      point[1]++;
    }
  }

  cout<<point[0]<<" "<<point[1]<<endl;
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::vector<int> V(N);
    for(auto &v : V){
        std::cin >> v;
    }
    std::sort(V.begin(),V.end());

    double max = static_cast<double>(V[0]);
    for(int i=1; i<N; ++i){
        max += static_cast<double>(V[i]);
        max /= 2.0;
    }

    std::cout << std::fixed << std::setprecision(10) << max << std::endl;
    return 0;
}


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

int main(void)
{
	int a, maxim=-1, num[100] = { 0 };

	while (cin >> a)
	{
		num[a - 1]++;
	}
	for (int i = 0; i < 100; i++)
	{
		maxim = max(maxim, num[i]);
	}
	for (int i = 0; i < 100; i++)
	{
		if (num[i] == maxim) cout << i + 1 << endl;
	}
	return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

ll dp[1000005][2];

int main(){
  string S;
  cin >> S;
  int N = S.size();
  REP(i, N+1){
    REP(j, 2){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  dp[0][1] = 1;
  REP(i, N){
    int d = S[i] - '0';
    dp[i+1][0] = min(dp[i][0]+d, dp[i+1][0]);
    dp[i+1][0] = min(dp[i][1]+10-d, dp[i+1][0]);
    dp[i+1][1] = min(dp[i][0]+d+1, dp[i+1][1]);
    dp[i+1][1] = min(dp[i][1]+10-d-1, dp[i+1][1]);
  }
  cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 20040
#71c
import collections

N = int(input())
A_list = [int(e) for e in input().split()]

#4 本の異なる棒を選び，それらの棒を辺として長方形（正方形を含む）を作りたいです．
#作ることができる最大の長方形の面積を求めてください
stick_one = 0
stick_two = 0

c = collections.Counter(A_list)

for stick in sorted(c.items(), reverse=True):
    if stick[1] >= 4 and stick_one == 0:
        stick_one = stick[0]
        stick_two = stick[0]
        print(stick_one * stick_two)
        break
    elif 4 > stick[1] >= 2 and stick_one == 0:
        stick_one = stick[0]
    elif stick[1] >= 2 and stick_one != 0:
        stick_two = stick[0]
        print(stick_one * stick_two)
        break
else:
    print(0)

Measured memory_bytes: 21412
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;

int main()
{
	int x,i, a[10] = { 0 };
	char b[4] = { 0 };
		cin >>x;
	a[0] = x / 1000;
	a[3] = x % 10;
	a[2] = (x % 100 - a[3])/10;
	a[1] = (x % 1000 - 10 * a[2] - a[3])/100;
	if (a[0] + a[1] + a[2] + a[3] == 7)cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=" << 7 << endl;
	else if (a[0] + a[1] + a[2] - a[3] == 7)cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=" << 7 << endl;
	else if (a[0] + a[1] - a[2] + a[3] == 7)cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=" << 7 << endl;
	else if (a[0] + a[1] - a[2] - a[3] == 7)cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=" << 7 << endl;
	else if (a[0] - a[1] + a[2] + a[3] == 7)cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=" << 7 << endl;
	else if (a[0] - a[1] + a[2] - a[3] == 7)cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=" << 7 << endl;
	else if (a[0] - a[1] - a[2] + a[3] == 7)cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=" << 7 << endl;
	else if (a[0] - a[1] - a[2] - a[3] == 7)cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=" << 7 << endl;
	return 0;
}

Measured memory_bytes: 256