akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  int sum = 0;
  rep(i, n - 1) sum += v[i];
  if(sum > v[n-1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i=0; i<n; i++)
#include<math.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  
  int cnt = 0;
  while(1) {
    bool flag = 0;
    for (int i=0; i<N; i++) {
      if (A[i]%2==1) {
        flag = 1;
      }
    }
    if (flag) break;
    cnt++;
    for (int i=0; i<N; i++) {
      A[i] /= 2;
    }
  }
  cout << cnt << endl;
}

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

int main() {
    int N, A, D;
    D = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> A;
        int B = A % 2;
        int E = i+1;
        int C = E % 2;
        if (B == 1 && C == 1) {
            D++;
            }
        else {
        }
    }
    cout << D << endl;
}

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

const int  INF = 1e9+5;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++)
    cin >> h[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++)
    {
        for(int j: {i+1,i+2})
        {
            if(j<n)
            {
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>

using vi = std::vector<int>;

const vi pow6n = {1, 6, 36, 216, 1296, 7776, 46656, 279936};  // [0,7], [0,8)
const vi pow9n = {1, 9, 81, 729, 6561, 59049, 531441};        // [0,6], [0,7)
vi pows        = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};

int main(void) {
    std::sort(pows.rbegin(), pows.rend());

    int N;
    std::cin >> N;

    int ans = 1'000'000'000;  // '

    // 9^p で i円， 6^p で (N-i)円を withdrow
    for (int i = 0; i <= N; ++i) {
        int withdrow_num = 0;

        // 9^p で i円 引き出す
        int i9 = i;
        for (int j = 6; j >= 0; --j) {
            withdrow_num += i9 / pow9n.at(j);
            i9 %= pow9n.at(j);
        }

        // 6^p で (N-i)円 引き出す
        int i6 = N - i;
        for (int j = 7; j >= 0; --j) {
            withdrow_num += i6 / pow6n.at(j);
            i6 %= pow6n.at(j);
        }

        ans = std::min(ans, withdrow_num);
    }

    std::cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		
		String v=s.next();
		long n=s.nextLong();
		for(int i=0,e=(int)Math.min(v.length(),n);i<e;++i) {
			if(v.charAt(i)!='1') {
				System.out.println(v.charAt(i));
				return;
			}
		}
		System.out.println('1');
	}
}


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

#define MAXN 200007

int n ;
pair < int , int > a[ MAXN ] ;

vector < pair < int , int > > srt ;

int cnt[ MAXN ] ;
int sm = 0 ;


long long f ( ) {
    for ( int i = 1 ; i <= n ; ++ i ) {
        cnt[ i ] = 0 ;
    }
    int sz = srt.size ( ) ;
    int en = -1 ;
    int sm = 0 ;
    long long mnint = -1 ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( en < i ) {
            ++ cnt[ srt[ i ].second ] ;
            ++ sm ;
            en = i ;
        }
        while ( en < sz - 1 && sm < n ) {
            ++ en ;
            ++ cnt[ srt[ en ].second ] ;
            if ( cnt[ srt[ en ].second ] == 1 ) { ++ sm ; }
        }
        if ( sm == n ) {
            long long sr = srt[ en ].first - srt[ i ].first ;
            if ( mnint < 0 || mnint > sr ) { mnint = sr ; }
        }
        -- cnt[ srt[ i ].second ] ;
        if ( cnt[ srt[ i ].second ] == 0 ) { -- sm ; }
    }
    return mnint * ( srt[ sz - 1 ].first - srt[ 0 ].first ) ;
}

long long obtain ( ) {
    for ( int i = 1 ; i <= n ; ++ i ) {
        cnt[ i ] = 0 ;
    }
    int sz = srt.size ( ) ;
    long long fst = -1 ;
    long long lst = -1 ;
    int sm = 0 ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( cnt[ srt[ i ].second ] > 0 ) {
            if ( fst == -1 ) { fst = srt[ i ].first ; }
        }
        else {
            cnt[ srt[ i ].second ] = 1 ;
            ++ sm ;
            if ( sm == n ) { lst = srt[ i ].first ; }
        }
        if ( sm == n && fst > -1 ) { break ; }
    }
    return ( lst - srt[ 0 ].first ) * ( srt[ sz - 1 ].first - fst ) ;
}

void input ( ) {
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d%d" , &a[ i ].first , &a[ i ].second ) ;
        srt.push_back ( { a[ i ].first , i } ) ;
        srt.push_back ( { a[ i ].second , i } ) ;
    }
    sort ( srt.begin ( ) , srt.end ( ) ) ;
}

void solve ( ) {
    if ( n == 1 ) {
        printf ( "0\n" ) ;
        return ;
    }
    int sz = srt.size ( ) ;
    long long ans = obtain ( ) ;
    if ( srt[ sz - 1 ].second != srt[ 0 ].second ) {
        ans = min ( ans , f ( ) ) ;
    }
    printf ( "%lld\n" , ans ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  int n,i; cin>>n>>i;
  int ans = n-i+1;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <typeinfo>

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;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#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 shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

template <class T>
void print(const vector<T> v) {
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j) {
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  ll x = 0;
  for (int i = 0; i < 40; ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      if ((a[j] >> 1ll * (39 - i)) & 1) {
        cnt++;
      }
    }
    if (n - cnt <= cnt) {
      ans += (1ll << (39 - i)) * cnt;
    } else {
      if (x + (1ll << (39 - i)) <= k) {
        ans += (1ll << (39 - i)) * (n - cnt);
        x += (1ll << (39 - i));
      } else {
        ans += (1ll << (39 - i)) * cnt;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

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

  int N;
  cin >> N;
  map<string, int> mp;

  string s;
  rep(i, N){
    cin >> s;
    mp[s]++;
  }

  int max_cnt = -1;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    chmax(max_cnt, itr->second);
  }

  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second == max_cnt){
      cout << itr->first << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>

const double PI = atan(1) * 4;

using namespace std;

int main()
{
    int a, b;
    char op;
    while (true)
    {
        cin >> a >> op >> b;

        if (op == '?')
            break;

        if (op == '+')
            cout << a+b;
        else if (op == '-')
            cout << a-b;
        else if (op == '*')
            cout << a*b;
        else if (op == '/')
            cout << a/b;

        cout << endl;
    }

}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    map<string,int32> m;
    REP(i,n){
        string s;
        cin >> s;
        m[s]++;
    }
    int32 mx = -1;
    for(auto p : m){
        mx = max(mx, p.second);
    }
    vector<string> ans;
    for(auto p : m){
        if(p.second == mx){
            ans.push_back(p.first);
        }
    }
    sort(ALL(ans));
    for(auto a : ans){
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 25584
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, M;
	cin >> N >> M;
	int L = 0, R = N;
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		L = max(L, l);
		R = min(R, r);
	}
	cout << max(0, R - L + 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define LL long long
#define pb push_back
vector<LL>V;
int main(){
	V.pb(0);
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int t;cin>>t;;
		V.pb(t);
	}
	for(int i=1;i<=n;i++){
		V.pb(V[i]);
	}
	for(int i=1;i<V.size();i++){
		V[i]+=V[i-1];
	}
	LL MX=V[n]/3,MN=1;
	vector<LL>::iterator IT=V.begin();
	IT++;
	for(int i=1;i<=n;i++,IT++){
		LL mn=MN,mx=MX;
		LL p=(mn+mx)/2;
		while(mx-mn>1){
			p=(mn+mx)/2;
			vector<LL>::iterator it1=lower_bound(IT,IT+n-1,(*(IT-1))+p);
			vector<LL>::iterator it2=lower_bound(it1+1,IT+n-1,(*it1)+p);
			vector<LL>::iterator it3=lower_bound(it2+1,IT+n-1,(*it2)+p);
			if(*it3<=*(IT+n-1) && p<=(*it3)-(*it2))mn=p;
			else mx=p;
		}
		MN=max(MN,mn);
	}
	cout<<MN<<endl;
	return 0;
}


Measured memory_bytes: 3116
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] h = new long[n];
    for(int i = 0;i < n;i++)h[i]=sc.nextLong();
    long[] sum = new long[n];
    Arrays.fill(sum,(long)Math.pow(10,15));
    sum[0]=0;
    if(k>=n){
      long min = (long)Math.pow(10,15);
      for(int i = 1;i < n;i++)min = Math.min(min,Math.abs(h[0]-h[i]));
      System.out.println(min);
      return;
    }
    for(int i = 1;i < k;i++){
      for(int j = 1;j <= i;j++){
        sum[i]=Math.min(sum[i],sum[i-j]+Math.abs(h[i]-h[i-j]));
      }
    }
    for(int i = k;i < n;i++){
      for(int j = 1;j <= k;j++){
        sum[i]=Math.min(sum[i],sum[i-j]+Math.abs(h[i]-h[i-j]));
      }
    }
    System.out.println(sum[n-1]);
  }
}

Measured memory_bytes: 62176
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;
const long long maxn =10000470;
bool vis[maxn];
long long f[10000010];
long long tmp[10000010];
int p_n=0;
long long init(int n){
    p_n=0;
    long long i,j;
    long long sum = 0;
    memset(vis, 0, sizeof(vis));
    for(i=1; i<=n; i++){
        f[i] = 1;
        tmp[i] = i;
    }
    for(i=2;i<=n;i++){
        if(!vis[i]){
            f[i] = 2;
            for(j=i*i;j<=n;j+=i){
                vis[j]=1;
                long long cnt=0;
                while(tmp[j]%i == 0){
                    tmp[j]/=i;
                    ++cnt;
                }
                f[j] *= cnt+1;
            }
        }
    }
    for(i=1; i<=n; i++){
        if(tmp[i]!=1&&vis[i]) f[i]*=2;
        sum += i*f[i];
    }
    return sum;
}
int main(){
    int n;
    scanf("%d", &n);
    printf("%lld\n", init(n));
    return 0;
}


Measured memory_bytes: 169820
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const ll INF = 1000000000000000001;

int a, b, x;
int main(void){
    cin >> x >> a >> b;
    x -= a;
    cout << x%b << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)
 
#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
//------show vector---------
template <typename T>
void showV(vector < T > a){
  EACH(i,a){
    cerr << *i << ',';
  }  
  cerr << endl;
}
 
//------show matrix---------
template <typename T>
void showVV(vector < vector < T > > a){
  EACH(i,a){
    showV(*i);
  }  
}
//grobal var
//------------------------------------------
LL dp[2000][2000];
vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int A,B;
  while(cin >> A >> B){
    int ans;
    ans = max(A+B,A-B);
    ans = max(ans,A*B);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/locale_facets.h>
#include<stdio.h>
inline void output(long long o);
inline long long input();
int main()
{
	int a=input(),b=input(),c=input();
	output((a+b)*c/2);
	return 0;
}
inline void output(long long o)
{
	if(o<0)putchar('-'),o=-o;
	if(o>=10)output(o/10);
	putchar(o%10^'0');
}
inline long long input()
{
	bool positive=true;
	char now=getchar();
	long long i=0;
	for(;!isdigit(now);now=getchar())
	if(now=='-')positive=!positive;
	for(;isdigit(now);now=getchar())i=(i<<3)+(i<<1)+(now^'0');
	return positive?i:-i;
}

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

int  main()
{
	long W,H,x,y; cin >> W >> H >> x >> y;

	long double area = (double)H*W;
	long double a,b;
	a = (long double)min((long double)area - ((H-y) * W), (long double)(H-y) * W);
	b = (long double)min((long double)area - (H * (W-x)), (long double)H * (W-x));
	long double c = (long double)H * W / 2;

	printf("%Lf ", (long double)max({a, b, c}));

	if ((long double)max({a, b, c}) == a || (long double)max({a, b, c}) == b)
	{
		if (a == b)
			cout << 1;
		else
			cout << 0;
	}
	else
		cout << "0\n";
	return (0);
}


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

int main (){
    int H,W;
    int y,x;
    while(1){
        cin >> H >> W;
        if(H==0||W==0)break;
        
        for(y=1;y<=H;y++){
            if(y%2==1){
                for(x=1;x<=W;x++){
                    if(x%2==1){
                        cout << '#';
                    }
                    else if(x%2==0){
                        cout << '.';
                    }
                }
            }
            else if(y%2==0){
                for(x=1;x<=W;x++){
                    if(x%2==1){
                        cout << '.';
                    }
                    else if(x%2==0){
                        cout << '#';
                    }
                }
            }
            
            cout << endl;
        }
        
        cout << endl;
    }
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }
    int cnt= 0;
    rep(i, n-2){
        int a = p[i],b=p[i+1],c=p[i+2];
        if((a>b && b>c) || (a<b && b<c)){
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
lint p=1e9+7;

int main(){
  lint N,K;
  cin>>N>>K;
  vector<lint> ma(N+2,0),mi(N+2,0);
  FOR(i,1,N+2){
    mi[i]=mi[i-1]+i-1;
    ma[i]=ma[i-1]+N-i+1;
  }
  lint ans=0;
  FOR(i,K,N+2){
    ans+=ma[i]-mi[i]+1;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6428
###
### atcorder test program
###

import sys

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

math = math()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

m = 100000

for i in range(int(input())):
    m *= 1.05
    if m%1000 != 0:
        m = (m//1000+1) * 1000
    else:
        m = (m//1000) * 1000

print(int(m))



Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m;
  pair<int,int> a[60];
  vector<int> ans;
  cin>>n;
  rep(i,n){
    cin>>m;
    a[i]=make_pair(m,i+1);
  }
  sort(a,a+n);
  repn(i,n-1){
    if(a[i].first>1) ans.push_back(a[i].second);
    else break;
  }
  rep(i,n){
    if(a[i].first<0 && a[i].first!= -1){
      if(a[i+1].first<0){
	ans.push_back(a[i].second);
	ans.push_back(a[i+1].second);
	i++;
      }else break;
    }else break;
  }
  sort(ans.begin(),ans.end() );
  cout<<ans.size()<<endl;
  rep(i,ans.size() ){
    cout<<ans[i]<<endl;
  }
      
  

  return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
ll dp[110][110][310];
int main(){
    ll N,W;cin>>N>>W;
    vector<ll>w(N),v(N);
    rep(i,N)cin>>w[i]>>v[i];
    REP(i,1,N)w[i]-=w[0];
    ll s=w[0];
    w[0]=0;
    dp[0][0][0]=0;
    rep(i,N){
        rep(j,N){
            rep(k,301){
                if((j+1)*s+k+w[i]<=W){
                    dp[i+1][j+1][k+w[i]]=max(dp[i+1][j+1][k+w[i]],dp[i][j][k]+v[i]);
                }
                dp[i+1][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
            }
        }
    }
    ll ans=0;
    rep(i,N+1){
        rep(j,N+1){
            rep(k,301){
                ans=max(dp[i][j][k],ans);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 28544
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}
 
int main(){
	int n;
	cin>>n;
	vector<int> a;
	a.resize(n);
	int b[100001];
	rep(i,100001){
		b[i]=0;
	}
	rep(i,n){
		cin>>a[i];
		b[a[i]]++;
	}
	int ans=0;
	FOR(i,0,99999){
		ans=max(ans,b[i]+b[i+1]+b[i+2]);
	}
	cout<<ans<<endl;
}

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

int main() {
 int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if((A + B) > (C + D)){
  cout << "Left" << endl; 
  }
  else if((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
  }

Measured memory_bytes: 256
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        StringBuffer sb = new StringBuffer();
        
        while(true){
            String[] strAry = (br.readLine()).split(" ");
            int h = Integer.parseInt(strAry[0]);
            int w = Integer.parseInt(strAry[1]);
            
            if(0 == h & 0 == w){
                break;
            }
            for(int i = 0; i < h; i++){
                sb.append("#");
                for(int j = 0; j < (w - 2); j++){
                    if(0 == i || (h - 1) == i){
                        sb.append("#");
                    }else{
                        sb.append(".");
                    }
                }
                sb.append("#").append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> idx(n);
    rep(i, n) a[i]--;
    rep(i, n) idx[a[i]] = i;
    multiset<int> st;
    rep(i, 2) {
        st.insert(-1);
        st.insert(n);
    }
    ll ans = 0;
    rrep(x, n) {
        int i = idx[x];
        vector<int> l(2), r(2);
        st.insert(i);
        {
            auto it = st.find(i);
            rep(j, 2) {
                it--;
                l[j] = *it;
            }
        }
        {
            auto it = st.find(i);
            rep(j, 2) {
                it++;
                r[j] = *it;
            }
        }
        vector<int> ls(2), rs(2);
        ls[0] = i - l[0]; ls[1] = l[0] - l[1];
        rs[0] = r[0] - i; rs[1] = r[1] - r[0];
        ll c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0];
        ans += c * (x + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8648
N = int(input())
ans = 0
b = 0
for i in range(N):
    a = int(input())
    ans += (a + b) // 2
    if (a + b) % 2 == 1:
        if a > 0:
            b = 1
        else:
            b = 0
    else:
        b = 0
        
print(ans)

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

int main() {
  int n,a,b; cin >> n >> a >> b;
  a = abs(n-a); b = abs(n-b);
  if(a>b){
    cout << "B";
  }
  else{
    cout << "A";
  }
}

Measured memory_bytes: 3564
#include<stdio.h>

int main()
{
	int	N;
	int *a;
	int i;
	scanf("%d", &N);
	a = (int *)malloc( sizeof( int ) * N );	
	for(i = 0; i < N; ++i){
		scanf("%d", &a[i]);
	}
	
	printf("%d", a[N - 1]);
	for(i = N - 2; i >= 0; --i){
		printf(" %d", a[i]);
	}
	
	printf("\n");
	free(a);

	return 0;
}

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

int main(){
    int n;
    int64_t k;
    static int a[200000], f[200000];
    cin >> n >> k;
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> f[i];
    
    sort(a, a+n);
    sort(f, f+n, greater<decltype(f[0])>());

    int64_t ok = 1'000'000'000'000, ng = -1;
    while(ok-ng > 1){
        int64_t mid = (ok+ng) / 2;
        int64_t cost = 0;
        for(int i=0;i<n;++i) cost += max(a[i] - mid/f[i], INT64_C(0));
        if(cost <= k) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(auto &x:a){
        cin >> x;
    }

    int sum=0,count=0;
    do{
        sum+=k;
        if(sum<n)sum--;
        count++;
    }while(sum<n);

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>

typedef long long ll;

using namespace std;
ll mod = 1000000007;
int n, m;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll r,d,x;
    cin >> r >> d >> x;

    for (int i = 1; i <= 10; i++) {
        x = r*x-d;

        cout << x << "\n";
    }
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if (a > b) {
    int tmp = b;
    b = a;
    a = tmp;
  }
  
  int base = 1;
  int ans = 0;
  rep(i, b) {
    ans += a * base;
    base *= 10;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()

if 2*n>=m:
    print(m//2)
    exit()
print(n+math.ceil((m-2*n)//4))

Measured memory_bytes: 38384
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

inline int read(){
	char ch = getchar();
	int x = 0, f = 1;
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int n;
int val[3][maxn];
int dp[maxn][3];

int main()
{
	n = read();
	rep(i, 1, n) rep(j, 0, 2) val[j][i] = read();
	rep(i, 1, n){
		rep(j, 0, 2){
			rep(k, 0, 2){
				if(k == j) continue;
				dp[i][j] = qmax(dp[i][j], dp[i-1][k] + val[j][i]);
			}
		}
	}
	printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
template<typename A, typename B> bool cmin(A &a, const B &b) { if (a > b) { a = b; return true; } else return false; }
 
main {
  int e;
  while(cin>>e,e){
    int m=1000000000;
    rep(z,101) rep(y, 1001) {
      int x=e-z*z*z-y*y;
       if (x>=0) cmin(m,x+y+z);
     }
    cout<<m<<endl;
  }
  bye;
}

Measured memory_bytes: 3080
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next(); //("00000" + nexts()).substr(-5).split("").map(x => +x);
    let a = new Set(nexts(n))
    let ans = a.size

    return ans;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;
int n,c;
int cou;
bool ch(ll s){
    cou++;
    string t=to_string(s);
    vector<bool>cv(3,0);
    rep(i,0,t.size()){
        if(t.at(i)=='3')cv.at(0)=true;
        if(t.at(i)=='5')cv.at(1)=true;
        if(t.at(i)=='7')cv.at(2)=true;
    }
    bool cc=true;
    rep(i,0,3){
        if(cv.at(i)==0) cc= false;
    }
    if(cc) return true;
    else return false;
}
void dfs(ll s){
    if(357<=s and s<=n){
        if(ch(s)) c++;
    }
    if(s>=n) return;
    dfs(s*10+7);
    dfs(s*10+5);
    dfs(s*10+3);
}
int main(){
    cin>>n;
    c=0;
    cou=0;
    dfs(0);
    cout<<c<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define num_digit first
#define num_set second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef pair<ll, vi> pivi;
typedef vector<pivi> vivi;
typedef priority_queue<ll> pq;

const int MAX_N = 1;
//                    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
const int COST[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int MAX_COST = 8;

int N, M;
vi mnum(MAX_COST, 0);

vi max_vi(vi &a, vi &b) {
  vii A, B;
  for (int i = 0; i < MAX_COST; i++) {
    if (a[i] != 0) {
      A.pb(mp(mnum[i], a[i]));
    }
    if (b[i] != 0) {
      B.pb(mp(mnum[i], b[i]));
    }
  }
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());

  if (A.size() == 0) return b;
  if (B.size() == 0) return a;

  for (int i = 0; i < min(A.size(), B.size()); i++) {
    if (A[i] > B[i]) return a;
    if (A[i] < B[i]) return b;
  }
  return a;
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    ll a; cin >> a;
    mnum[COST[a]] = max(mnum[COST[a]], a);
  }

  vivi dp(N+1, mp(-1, vi(MAX_COST, 0)));
  dp[0].num_digit = 0;
  for (int i = 0; i < N; i++) {
    if (dp[i].num_digit == -1) continue;
    for (int j = 0; j < MAX_COST; j++) {
      if (i+j > N || mnum[j] == 0) continue;
      if (dp[i+j].num_digit <= dp[i].num_digit + 1) {
        vi tmp = dp[i].num_set;
        tmp[j]++;
        if (dp[i+j].num_digit == dp[i].num_digit + 1) {
          tmp = max_vi(dp[i+j].num_set, tmp);
        }
        dp[i+j] = mp(dp[i].num_digit + 1, tmp);
      }
    }
  }

  vii ans;
  vi ans_set = dp[N].num_set;
  for (int i = 0; i < MAX_COST; i++) {
    ans.pb(mp(mnum[i], ans_set[i]));
  }

  sort(ans.rbegin(), ans.rend());
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 0; j < ans[i].second; j++) {
      cout << ans[i].first;
    }
  } cout << endl;

  return 0;
}


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

int main(void){
	int n, i;
	int h=0;
	scanf("%d", &n);
	int now=0, ans=0;
	for(i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		if(a<=h){
			now++;
		}else{
			if(now>ans) ans=now;
			now=0;
		}
		h=a;
	}
	if(now>ans) ans=now;
	printf("%d\n", ans);
}


Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int[500][500] MS, CS;

void main()
{
    auto nmq = readln.split.to!(int[]);
    auto N = nmq[0];
    auto M = nmq[1];
    auto Q = nmq[2];

    foreach (_; 0..M) {
        auto lr = readln.split.to!(int[]);
        ++MS[lr[0]-1][lr[1]-1];
    }

    foreach_reverse (s; 0..N) {
        foreach (e; s..N) {
            CS[s][e] = MS[s][e] +
                (e ? CS[s][e-1] : 0) +
                (s+1 < N ? CS[s+1][e] : 0) -
                (e && s+1 < N && s+1 <= e-1 ? CS[s+1][e-1] : 0);
        }
    }

    foreach (_; 0..Q) {
        auto pq = readln.split.to!(int[]);
        writeln(CS[pq[0]-1][pq[1]-1]);
    }
}

Measured memory_bytes: 3964
import java.util.Scanner;

public class Main {
    static String a[];
    static String n;

  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  n = sc.next();
	  a = new String[n.length()];
	  for(int i = 0; i < n.length(); i++) {
		  a[i] = n.substring(i, i+1);
	  }
      System.out.println(dfs(0,a[0]));
      sc.close();
  }
  static public long dfs(int i,String sum) {
	//基本ケース　枝の最後の基本ケース
    if (i == n.length()-1) {
    		long tmp = 0;
    		String[] siki = sum.split(",");
    		for(int j = 0; j < siki.length; j++) {
    			tmp += Long.parseLong(siki[j]);
    		}
    	return tmp;
    }

    //再帰ケース
    long X = dfs(i + 1,sum + a[i+1]);
    long Y = dfs(i + 1,sum + "," + a[i+1]);

    return X+Y;
  }
}

Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n,x[30],y[30],r[30],c[30],cover[30];
char dp[1<<24];
vector<int> same_col[5];

int rec(int bit){
  if(dp[bit])return dp[bit];

  int res = 0;
  for(int i=0;i<4;i++){
    if(same_col[i].size()<2)continue;
    for(int a : same_col[i])for(int b : same_col[i]){
	if(a<=b)continue;
	if( (~bit)&(1<<a) && (~bit)&(1<<b) ){
	  if( (~bit)&cover[a] || (~bit)&cover[b])continue;
	  res = max(res, rec(bit | (1<<a) | (1<<b))+2);
	}
      }
  }
  return dp[bit]=res;
}
  
int main(){
  while(cin >> n, n){
    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];
    for(int i=0;i<4;i++)same_col[i].clear();

    for(int i=0;i<n;i++){
      same_col[c[i]-1].push_back(i);
      cover[i] = 0;
      for(int j=0;j<i;j++){
	if( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) < (r[i]+r[j])*(r[i]+r[j]) ){
	  cover[i] |= 1<<j;
	}
      }
    }

    memset(dp,0,sizeof(dp));
    cout << rec(0) << endl;
  }	  
}

Measured memory_bytes: 17600
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

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



int main(){
  int n;cin>>n;
  if(n%2){
    cout << "No" << endl;
    return 0;
  }
  string s;cin>>s;
  for(int i = 0; s.size()/2 > i; i++){
    if(s[i] != s[i+s.size()/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<int> x(5);
    rep(i,5) cin>>x[i];
    rep(i,5){
        if (x[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <vector>
using namespace std;
struct node{
    int parent;
    int l;
    int r;
    int val;
    int real;
};
struct tree{
    vector<node>map;
    bool first;
    int root;
    void insert(int n,int now){
        if(map[n].val>map[now].val){
            map[n].parent=now;
            map[now].r=n;
        }
        else{
            if(now==root){
                root=n;
                map[n].l=now;
                map[now].parent=n;
            }
            else{
                insert(n,map[now].parent);
                if(map[map[now].parent].r!=now){
                    map[now].parent=n;
                    map[n].l=now;
                }
            }
        }
        return ;
    }
    void postorder(int n){
        if(n==-1)return ;
        postorder(map[n].l);
        postorder(map[n].r);
        if(first)printf(" ");
        else first=true;
        printf("%d",map[n].real);
        return ;
    }
};
node int_to_node(int n,int a){
    node temp;
    temp.val=a;
    temp.real=n;
    temp.l=temp.r=temp.parent=-1;
    return temp;
}
int main(){
    int n,a[100],temp;
    tree t;
    t.first=false;
    t.root=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&temp);
        a[temp]=i;
    }
    scanf("%d",&temp);
    t.map.push_back(int_to_node(temp,a[temp]));
    for(int i=1;i<n;i++){
        scanf("%d",&temp);
        t.map.push_back(int_to_node(temp,a[temp]));
        t.insert(i,i-1);
    }
    t.postorder(t.root);
    printf("\n");
}

Measured memory_bytes: 2780
N, M = map(int, input().split())
xs = []
for i in range(M):
    a, b = map(int, input().split())
    xs += [(a, 1, i), (b, 0, i)]
xs.sort()
d = set()
r = 0
for x, s, i, in xs:
    if s == 1:
        d.add(i)
    else:
        if i not in d:
            continue
        r += 1
        d = set()
print(r)


Measured memory_bytes: 80216
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846

void solve(){
	int r; cin >> r;
	long double ans;
	ans = (2.000000000000 * PI * (long double)r);
	cout << ans << endl;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>
    using namespace std;
    int main(void){
        long a,b,x,ans;
        cin>>a>>b>>x;
        long n;
        n=a%x;
        a=a-n;
        if(n==0){
            ans=(b-a)/x+1;
        }else{
            ans=(b-a)/x;
        }
        cout<<ans<<endl;
        
    }

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 P = pair<int,int>;
//Write From this Line

//AtCoder解説動画(https://www.youtube.com/watch?v=TdR816rqc3s&feature=youtu.be)からもらった
struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {} //このコロンってなんですか
	int find(int x){
		if (d[x] < 0) return x; //x:根
		return d[x] = find(d[x]);//x:子 -> xの親の根を返す
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);//根同士をくっつける。
		if ( x ==  y) return false ; 
		/*連結成分が一致してるんだったらfalse返す。
			minimum spanning tree (クラスカル法と言うのをやるときに、くっつけたかどうかを取れると嬉しい.
			chmin/chmaxみたいなノリかな
		 */
		if ( d[x] > d[y]) swap(x,y);//xの方が大きいようにする（ただしサイズは負デモっているので不等号が逆）
		d[x] += d[y] ; //xにyをくっつける.
		d[y] = x;
		return true; 
	}
	bool same(int x, int y) { return find(x) == find(y) ; }
	int size(int x) { return -d[find(x)];}
};
int main()
{
	int n, m;
	cin >> n >> m;

	UnionFind uf(n);
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	rep(i,m){
		int x, y;
		cin >> x >> y;
		--x, --y;
		uf.unite(x,y);
	}
	int ans = 0;
	rep(i,n){
		int a = p[i]; 
		--a; // i と a が繋がってたら ans ++
		if(uf.same(i,a)) ans ++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	
	int g = 0, p = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'g'){
			g++;
		}else{
			p++;
		}
	}
	
	cout << s.length() / 2 - p << endl;
	
	return 0;
}

Measured memory_bytes: 512