akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;


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

ll modinv(ll x){
  return power(x,hell-2);
}


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}

void solve(){  
    int n;
    cin>>n;
    ll a[n+1];
    forn(i,1,n+1)
    cin>>a[i];
    
    map<ll,ll> st;
    forn(i,1,n+1)
    st[i-a[i]]++;
    
    ll ans=0;
    forn(i,1,n+1){
        ll cur=(a[i]+i);
        ans=(ans+st[cur]);
    }
    cout<<ans;
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

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

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


void Main() {
	int N, K; cin >> N >> K;
	vll A(N); cin >> A;
	ll ng = 0, ok = 2e9;
	while (abs(ok-ng) > 1) {
		ll t = (ok+ng)/2;
		ll cnt = 0;
		for (int i = 0; i < N; i++) {
			cnt += (A[i]-1)/t;
		}
		if (cnt <= K) {
			ok = t;
		} else {
			ng = t;
		}
	}
	cout << ok << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4692
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
using namespace boost::multiprecision;
//using namespace __gnu_pbds;

cpp_int ans;
cpp_int n, a, b, c, d;
cpp_int u[] = {2, 3, 5};
cpp_int cost[3];
map<cpp_int, cpp_int> n_to_coins;

void dfs(cpp_int now, cpp_int coins){
  if(coins >= ans) return;
  if(now == 0){
    ans = coins;
    return;
  }
  if(n_to_coins.find(now) == n_to_coins.end()){
    n_to_coins[now] = coins;
  }else if(n_to_coins[now] <= coins){
    return;
  }else{
    n_to_coins[now] = coins;
  }
  
  cpp_int temp = coins + d * now;
  dfs(0, temp);
  
  REP(k, 3){
    cpp_int l, r;
    l = (now / u[k]) * u[k];
    r = ((now + u[k] - 1) / u[k]) * u[k];
    if(l == 0){
      dfs(l, coins + (now - l) * d);
    }else{
      dfs(l / u[k], coins + (now - l) * d + cost[k]);
    }
    if(r == 0){
      dfs(r, coins + (r - now) * d);
    }else{
      dfs(r / u[k], coins + (r - now) * d + cost[k]);
    }
  }
  return;
}
int main(){
  //using namespace std;
  int t;
  cin>>t;
  REP(_, t){
    cin>>n>>a>>b>>c>>d;
    //n_to_coins.clear();
    n_to_coins = map<cpp_int, cpp_int>();
    cost[0] = a;
    cost[1] = b;
    cost[2] = c;
    ans = 1;
    REP(_, 27) ans *= 10;
    dfs(n, 0);
    cout << ans << endl;
  }  
  return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, M; cin >> N >> M;
    pair<int, int> q[M];
    int ans = 0;
    rep(i, M){
        int a, b; cin >> a >> b;
        q[i] = make_pair(a, b);
    }
    sort(q, q+M);
    int till;
    rep(i, M){
        if(i == 0) till = q[0].second;
        else{
            if(q[i].first >= till){
                ans++;
                till = q[i].second;
            }
            else if(q[i].second < till) till = q[i].second;
        }
    }
    cout << ans+1 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

struct Product {
  int v, w;
};
V<Product> products;

int main() {
  int n, m;
  unordered_map<string, int> count;

  cin >> n;
  rep(i, n) {
    string str;
    cin >> str;

    count[str] += 1;
  }

  cin >> m;
  rep(i, m) {
    string str;
    cin >> str;

    count[str] -= 1;
  }


  int max_count = 0;

  for(auto it = count.begin(); it != count.end(); it++) {
    max_count = max(max_count, it->second);
  }

  cout << max_count << endl;
}


Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {
  public static void main( String[] args ) {
	  Scanner scan = new Scanner(System.in);
	  int N = scan.nextInt();
	  boolean isJustBuy = false;
	  for( int i = 0; i <= N / 4; i++ ) {
		  for( int j = 0; j <= N / 7; j++ ) {
			  if( 4 * i + 7 * j == N ) {
				  isJustBuy = true;
				  break;
			  }
		  }
	  }
	  if( isJustBuy ) {
		  System.out.println( "Yes" );
	  }else{
		  System.out.println( "No" );
	  }
  }
}

Measured memory_bytes: 22612
a,b = map(int,input().split())
z = list(map(int,input().split()))
if a in z:
	j =1
	while True:
		if (a-j) not in z:
			print(a-j)
			break
		if a+j not in z :
			print(a+j)
			break
		j+=1
else:
	print(a)

Measured memory_bytes: 61724
#include <stdio.h>

int sqrt(unsigned int x){
  int a = 0, c = 0, y = 0, i = 0, t = x;
  while(t >>= 1){
    ++i;
  }
  for(i += i & 1; i >= 0; i -= 2){
    c = (y << 1 | 1) <= x >> i;
    a = a << 1 | c;
    y = y << 1 | c;
    x -= c * y << i;
    /* if(c){
      x -= y << i;
    } */
    y += c;
  }
  return a;
}


int isPrime(int a) {

	int j;

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

	if (a < 2 || a % 2 == 0) {
		return 0;
	}


	for (j = 3; j <= sqrt(a); j += 2) {
		if (a % j == 0) {
			return 0;
		}
	}

	return 1;
}

int main() {

	int num;
	int p_count = 0;
	int n, i;

	scanf("%d", &num);
	
	for (i = 0; i < num; i++) {

		scanf("%d", &n);

		if (isPrime(n)) {
			p_count++;
		}

	}


	printf("%d\n", p_count);

	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

void solve()
{
	string s,t;
	cin>>s;
	cin>>t;
	
	int ans=L(t);
	
	for(int i=0;i<L(s);i++)
	{
		int cnt=0;
		if(i+L(t)-1 >= L(s)) break;
		for(int j=0;j<L(t);j++)
		{
			cnt += s[i+j]!=t[j];
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<'\n';
	
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3660
// Written By Mahtab Tanim
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define End return 0
#define ll long long int
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define pi acos(-1)
#define forn(i,a,b) for (int i=a;i<=b;i++)
#define PI acos(-1)
int main()
{
double r;
cin>>r;
printf("%.5lf",r*PI*2);
End;
}


Measured memory_bytes: 3788
N = int(input())
v = input().split()

for i in range(N):
    v[i] = float(v[i])
    
v.sort()
ite = 0
while(ite < N-1):
    v[ite+1] = (v[ite]+v[ite+1])/2
    v[ite] = 0
    v.sort()
    #print(v)
    ite += 1

print(v[-1])



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define N 100009
using namespace std;

int A,B,C,D,len,t;
bool check(int x){
	int a=A-x*len,b=B-x;
	if (max((a-1)/(b+1),b/(a+1))+1>len) return 0;
	return 1;
}
bool check2(int x,int y){
	int a=A-x*len-y,b=B-x;
	if (max((a-1)/(b+1),(y?b:b-t)/(a+1))+1>len) return 0;
	return 1;
}
int main(){
	int cas; scanf("%d",&cas);
	while (cas--){
		scanf("%d%d%d%d",&A,&B,&C,&D);
		len=max((A-1)/(B+1),(B-1)/(A+1))+1;
		//cerr<<len<<endl;
		int l=0,r=min(B,A/len),mid;
		while (l<r){
			mid=l+r+1>>1;
			if (check(mid)) l=mid; else r=mid-1;	
		}
		int x=l;
		t=(x>0?0:1);
		l=0; r=min(len,A-x*len);
	//cerr<<l<<' '<<r<<endl;
		while (l<r){
			mid=l+r+1>>1;
			if (check2(x,mid)) l=mid; else r=mid-1;	
		}
	//	cerr<<len<<' '<<x<<' '<<l<<endl;
		for (; C<=D; C++)
			if (C<=x*(len+1)){
				putchar(C%(len+1)?'A':'B');
			} else if (C<=x*(len+1)+l){
				putchar('A');
			} else{
				int y=A+B-C+1;
				putchar(y%(len+1)?'B':'A');	
			}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] num = new int[3];
		for(int i=0;i<3;i++) {
			num[i] = in.nextInt();
		}
		Arrays.sort(num);
		System.out.println(num[0]+num[1]);
		
		in.close();

	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,j,k) for(int i=j;i<(int)(k);++i)
#define foreach(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const int INF = 99999999;
const double EPS = 1e-9;

const int MAX_N=1000001;
int n;
int dp[MAX_N][2];

int main()
{
        rep(i,MAX_N)rep(j,2) dp[i][j]=INF;
        dp[0][0]=dp[0][1]=0;
        rep(i,MAX_N)for(int j=1;i+(j*(j+1)*(j+2)/6)<MAX_N;++j){
                dp[i+(j*(j+1)*(j+2)/6)][0]=min(dp[i][0]+1,dp[i+(j*(j+1)*(j+2)/6)][0]);
                if((j*(j+1)*(j+2)/6)&1) dp[i+(j*(j+1)*(j+2)/6)][1]
                                                                        = min(dp[i][1]+1,dp[i+(j*(j+1)*(j+2)/6)][1]);
        }

        while(cin >> n,n) cout << dp[n][0] << " " << dp[n][1] << endl;
        return 0;
}

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

const int MaxN = 100000;
long long S[ MaxN + 10 ];

void SCNF( long long &x )
{
char C;

	while( true )
	{
		C = fgetc( stdin );
		if( C >= '0' && C <= '9' ) break;
	}

	x = C - '0';

	while( true )
	{
		C = fgetc( stdin );
		if( C < '0' || C > '9' ) break;

		x = x * 10 + ( C - '0' );
	}
}

int main()
{
long long i;
long long N;
long long M;
long long A;
long long x;
long long iCnt;
long long iSum;

	scanf( "%lld%lld", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		SCNF( A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%lld\n", iCnt );

	return 0;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int n){
	int ans=0;
	vvi v(n+1,vi(5));
	rrep(i,n)rep(j,5)cin>>v[i][j];
	bool loop=true;
	while(loop){
		loop=false;
		rep(i,n){
			rep(j,3){
				if(v[i][j]&&v[i][j]==v[i][j+1]&&v[i][j]==v[i][j+2]){
					int t=v[i][j];
					range(k,j,5){
						if(v[i][k]==t){
							v[i][k]=0;
							ans+=t;
							loop=true;
						}
						else break;
					}
				}
			}
		}
		rep(j,5){
			int cnt=0;
			rep(i,n){
				if(v[i][j]==0)cnt++;
				else {
					v[i-cnt][j]=v[i][j];
					if(cnt)v[i][j]=0;
				}
			}
		}
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n)solve(n);
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#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 leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//printfを使うときはこれでエラーになるので注意,下を削除
struct all_init {
  all_init() {
    cout.tie(nullptr);
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(11);
  };
} ALL_INIT;
//printfを使うときは上を削除
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//宣言だけしとく
ll n,m,h,w,k,a,b;
string s;
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cin >> m;
	ll sum = 0 , keta = 0 ;
	rep(i,m){
		cin >> a >> b ;
		sum += a * b;
		keta += b;
	}
	cout << (sum - 1) / 9 + (keta - 1) << endl;
}



Measured memory_bytes: 256
function Main(input){
	input=input.trim().split("\n");
	var N = parseInt(input,10);
	var array = [];
	var tmp = N;
	var k = 2;
	division_loop:
	while (true) {
		if (tmp % k == 0){
			tmp = tmp / k;
			array.push(k);
		} else {
			if (k > Math.sqrt(tmp)) {
				array.push(tmp);
				break division_loop;
			}
			k++;
		}
	}
	var ans = F(F_Comparison(array,N));
	console.log(ans);
}

function F(x){
	var i = 1;
	var j = 1;
	while(true){
		j *= 10;
		if (x >= j){
			i++;
		} else {
			return i;
			break;
		}
	}
}

function F_Comparison(array, N){
	var nYakusu = array.length;
	var zeroOneArray = [];
	var tmpValue = 1;
	var candidate = 1;
	for (var i = 0; i < Math.pow(2, nYakusu); i++){
		for (var j = 0; j < nYakusu; j++){
			if ((i / (Math.pow(2, j)) | 0) % 2 === 1) {
				tmpValue *= array[j];
			}
		}
		if (tmpValue > candidate && tmpValue <= Math.sqrt(N)){
			candidate = tmpValue;
		}
        tmpValue = 1;
	}
	return N / candidate;
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main()
{
    int K, X;
    cin >> K >> X;
    int start = X - (K - 1);
    int end = X + (K - 1);
    for (int i = start; i <= end; i++){
        cout << i << " ";
    }
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<string> c(H); REP(i, H) cin >> c[i];
  vector<string> copy(H); copy = c;
  int ans = 0;
  for(int bit1 = 0; bit1 < (1 << H); ++bit1) {
    for(int bit2 = 0; bit2 < (1 << W); ++bit2) {

      for(int i = 0; i < H; ++i) {
        if(bit1 & (1 << i)) {
          REP(k, W) {
            copy[i][k] = '@';
          }
        }
      }

      for(int i = 0; i < W; ++i) {
        if(bit2 & (1 << i)) {
          REP(k, H) {
            copy[k][i] = '@';
          }
        }
      }

      int tmp = 0;
      REP(i, H) {
        REP(k, W) {
          if(copy[i][k] == '#') tmp++;
        }
      }
      if(tmp == K) ans++;
      copy = c;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
//Snuke Line
#include <cstdio>
#include <algorithm>
inline char gc()
{
	static char now[1<<16],*S,*T;
	if(S==T) {T=(S=now)+fread(now,1,1<<16,stdin); if(S==T) return EOF;}
	return *S++;
}
inline int read()
{
	int x=0; char ch=gc();
	while(ch<'0'||'9'<ch) ch=gc();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=gc();
	return x;
}
int const N=3e5+10;
int const M=1e5+10;
int n,m;
struct range{int fr,to;} rg[N];
bool cmpRg(range x,range y) {return x.fr<y.fr;}
int sgCnt,rt[M];
struct seg{int cnt; int L,R;} sg[N*20];
void update(int s) {sg[s].cnt=sg[sg[s].L].cnt+sg[sg[s].R].cnt;}
void ins(int &s,int fr,int to,int x)
{
	sg[++sgCnt]=sg[s]; s=sgCnt;
	if(fr==to) {sg[s].cnt++; return;} 
	int mid=fr+to>>1;
	if(x<=mid) ins(sg[s].L,fr,mid,x);
	else ins(sg[s].R,mid+1,to,x);
	update(s);
}
int query(int s1,int s2,int fr,int to,int fr0,int to0)
{
	if(fr0<=fr&&to<=to0) return sg[s2].cnt-sg[s1].cnt;
	int mid=fr+to>>1; int res=0;
	if(fr0<=mid) res+=query(sg[s1].L,sg[s2].L,fr,mid,fr0,to0);
	if(mid<to0) res+=query(sg[s1].R,sg[s2].R,mid+1,to,fr0,to0);
	return res;
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++) rg[i].fr=read(),rg[i].to=read();
	std::sort(rg+1,rg+n+1,cmpRg);
	rt[0]=0; int p=1;
	for(int i=1;i<=m;i++)
	{
		rt[i]=rt[i-1];
		while(rg[p].fr==i) ins(rt[i],1,m,rg[p].to),++p;
	}
	printf("%d\n",n);
	for(int d=2;d<=m;d++)
	{
		int ans=n,i;
		for(i=d;i<=m;i+=d) ans-=query(rt[i-d],rt[i-1],1,m,i-d+1,i-1);
		if(i-d+1<=m) ans-=query(rt[i-d],rt[m],1,m,i-d+1,m);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 67840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  vector<int>a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    int b;
    cin>> b;
    a.at(i) =b;
    sum +=b;
  }
  int ans=1<<30;
  for(int i=0;i<n;i++){
    int sum2 =0;
    for(int j=0;j<=i;j++){
      sum2 +=a.at(j);
    }
    ans = min(ans,abs((sum-sum2)-sum2));
  }
  cout <<ans;
    
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long int ll;

int n, x, y, flagX, flagY, curX,  curY;
ll k, positive, negative;

int main() {
    scanf("%lld%d%d", &k , &x, &y);
    flagX = (x < 0) ? -1 : 1;
    flagY = (y < 0) ? -1 : 1;
    x *= flagX;
    y *= flagY;
    if (k % 2 ==0 && (x + y) & 1)
        printf("-1");
    else {
        if (k == x + y)
            n = 1;
        else {
            n = 2;
            while (n * k < x + y || (n * k - x - y) & 1) {
                ++n;
            }
        }
        positive = (n * k + x + y) >> 1;
        negative = (n * k - x - y) >> 1;
        printf("%d\n", n);
        while(n --) {
            if (negative) {
                if (negative >= k) {
                    if (x - curX <= y - curY)
                        curX -= k;
                    else
                        curY -= k;
                    negative -= k;
                }
                else {
                    if (x - curX <= y - curY) {
                        curX -= negative;
                        curY += (k - negative);
                    }
                    else {
                        curY -= negative;
                        curX += (k - negative);
                    }
                    negative = 0;
                }
            }
            else {
                if (curX < x) {
                    if (x - curX >= k)
                        curX += k;
                    else {
                        curY += (k - (x - curX));
                        curX = x;
                    }
                }
                else {
                        curY += k;
                }
            }
            printf("%d %d\n", curX * flagX, curY * flagY);
        }
    }
    return 0;
}

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

int main() {
    long long A, B, K;
    cin >> A >> B >> K;
    long long zero = 0;
    B = min(B, A + B - K);
    B = max(zero, B);
    A = max(zero, A - K);
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#define maxn 200005
using namespace std;

vector<int> G[maxn];
bool vis[maxn];

int bfs(int x)
{
	queue<int> q;
	q.push(x);
	int cnt = 0;
	while(!q.empty())
	{
		x = q.front(); q.pop();
		if(vis[x]) continue;
		vis[x] = true, cnt ++;
		for(int i=0; i<G[x].size(); i++)
			q.push(G[x][i]);
	}
	return cnt;
}

int main(int argc, char** argv)
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=0; i<m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = bfs(0);
	for(int i=1; i<n; i++)
		if(!vis[i])
		{
			int cnt = bfs(i);
			if(cnt > ans)
				ans = cnt;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14736
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    cnt = 0
    for i in range(1, n):
        if s[i] != s[i-1]:
            cnt += 1
    print(cnt+1)


if __name__ == '__main__':
    solve()


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

string S;

int main()
{
    cin >> S;
    int N = S.size();
    while (N > 0)
    {
        if (N >= 5 && S.substr(N-5, 5) == "dream") N -= 5;
        else if (N>=7 && S.substr(N-7, 7) == "dreamer") N -= 7;
        else if (N>=5 && S.substr(N-5, 5) == "erase") N -= 5;
        else if (N>=6 && S.substr(N-6, 6) == "eraser") N -= 6;
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
vector<long>a;
long sum[2<<17];
pair<long,long>f(int l,int r)
{
	long S=sum[r]-sum[l-1];
	int i=upper_bound(sum+l,sum+r,S/2+sum[l-1])-sum;
	long aa=0,ab=1e18,ba=0,bb=1e18;
	long A=1e18;
	if(i<r)A=abs((aa=sum[i]-sum[l-1])-(ab=sum[r]-sum[i]));
	i--;
	long B=1e18;
	if(i>=l)B=abs((ba=sum[i]-sum[l-1])-(bb=sum[r]-sum[i]));
	if(A<B)return minmax(aa,ab);
	else return minmax(ba,bb);
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		long c;cin>>c;a.push_back(c);
		sum[i+1]=c+sum[i];
	}
	long ans=1e18;
	for(int i=2;i+2<=n;i++)
	{
		pair<long,long>p=f(1,i),q=f(i+1,n);
		ans=min(ans,max(p.second,q.second)-min(p.first,q.first));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3444
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize, x: i64,
        mut a: [i64; n],
    }
    a.sort();
    let mut rem = x;
    let mut result = 0;
    for a in a {
        if a <= rem {
            rem -= a;
            result += 1;
        } else {
            rem = 0;
            break;
        }
    }
    if rem > 0 {
        result -= 1;
    }
    println!("{}", result);
}


Measured memory_bytes: 2180
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

class Enumeration {
public:
  explicit Enumeration(int n, uint64_t mod)
    : mod(mod), fact(n), inv(n), finv(n) {
    fact[0] = finv[0] = inv[1] = 1;
    for (int i = 2; i < n; ++i) inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    for (int i = 1; i < n; ++i) {
      fact[i] = fact[i - 1] * i % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  uint64_t operator()(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * finv[n - k] % mod * finv[k] % mod;
  }
  uint64_t modpow(uint64_t x, uint64_t e) {
    uint64_t res = 1;
    while (e > 0) {
      if (e & 1) res = res * x % mod;
      x = x * x % mod;
      e >>= 1;
    }
    return res;
  }

private:
  uint64_t mod;
  vector<uint64_t> fact, inv, finv;
};

constexpr ll MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;

  unordered_map<int, int> mp;
  for (int i = 2; i * i <= m; ++i) {
    while (m % i == 0) {
      m /= i;
      ++mp[i];
    }
  }
  if (m != 1) ++mp[m];

  Enumeration c(1 << 17, MOD);
  ll ans = 1;
  for (auto p : mp) ans = ans * c(n - 1 + p.second, n - 1) % MOD;

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

Measured memory_bytes: 6412
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from math import cos, sqrt, radians

a, b, h, m = na()

al = h * 30 + m * 0.5
bl = m * 6
c = abs(360 - (al - bl))

ans = sqrt(a ** 2 + b ** 2 - (2 * a * b * cos(radians(c))))
print("{:.15f}".format(ans))

Measured memory_bytes: 9664
def compute(n):
	prime = [ True for i in range(0, n+1)]
	res = []
	for i in range(2, n+1):
		if prime[i]==True:
			res.append(i)
			for j in range(i , n+1,i):
				prime[j]=False
	return res

mod = 10**9+7
n = int(input())
res = compute(n)
tot = 1
for i in res:
	now = 0
	p =n
	while p>0:
		now = now+(p//i)
		now = now%mod
		p=p//i
	tot = (tot % mod)*((now+1)%mod)
	tot = tot%mod
print(tot)

Measured memory_bytes: 63160
N=gets.to_i
ps=gets.split.map(&:to_i).unshift(nil)
ps_idx=Array.new(N+1)
ps.each_with_index do |o,i|
    next if i==0
    ps_idx[o]=i
end

checked=[0,ps_idx[N],N+1]
ans=0
(1..N-1).to_a.reverse.each do |e|
    next_idx=checked.bsearch_index{|x|ps_idx[e]<x}
    checked.insert(next_idx,ps_idx[e])
    if checked[next_idx+1]==N+1
        r=0
    else
        r=e*(checked[next_idx+2]-checked[next_idx+1])*(checked[next_idx]-checked[next_idx-1])
    end
    if checked[next_idx-1]==0
        l=0
    else
        l=e*(checked[next_idx-1]-checked[next_idx-2])*(checked[next_idx+1]-checked[next_idx])
    end
    ans+=r+l
end
p ans


Measured memory_bytes: 14228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, k, n;
            string d;
            var word = Console.ReadLine().Split(' ');
            x = int.Parse(word[0]);
            k = int.Parse(word[1]);

            n = 500 * x;



            if (k<=n)
                Console.WriteLine("Yes");

           else
                Console.WriteLine("No");



            Console.ReadKey();
             }

    }
}


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

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

    long long x, y;
    cin >> x >> y;

    int cnt = 1;
    while(true){
        x *= 2;
        if(x > y) break;
        else cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

public class Test
{
	static public void Main( )
	{
		String[] line = Console.ReadLine().Split( ' ' );
		var a = int.Parse( line[0] );
		var b = int.Parse( line[1] );
		Console.WriteLine( a*b + " " + (a+b)*2 );
		
	}
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();	
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
//ruogu_alter
int to[8][2] = {
  1, 4, 
  2, 3,
  1, 1,
  1, 4,
  5, 6,
  7, 4,
  6, 6,
  5, 5       
};
const int N = 3e5 + 5;
char s[N];
int f[N][8];
//
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) rep(j, 8) {
    if (s[i] != '0') (f[i][to[j][1]] += f[i - 1][j]) %= MOD;
    if (s[i] != '1') (f[i][to[j][0]] += f[i - 1][j]) %= MOD;
  }
  cout << (f[n][4] + f[n][6]) % MOD;
  return 0;
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n>>m>>r;
    swap(n,m);
    swap(n,r);
    cout<<n<<" "<<m<<" "<<r<<"\n";
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	if n%2 == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(n * 2)
	}
}


Measured memory_bytes: 1772
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int,int> wolf[12000];
pair<int,int> top[12000];
pair<int,int> middle[12000];
pair<int,int> bottom[12000];
int T,M,B;
int size;
int main(){
	int a;
	while(scanf("%d",&a),a){
		int b;
		scanf("%d",&b);
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);p--;
		size=1;
		wolf[0]=make_pair(0,a);
		for(int i=0;i<b;i++){
			int s,t;
			scanf("%d%d",&s,&t);
			int num=0;
			int phase=0;
			int P=0;
			for(int j=0;j<size;j++){
				if(phase==0&&num+wolf[j].second-wolf[j].first>s){
					for(int k=0;k<j;k++)bottom[k]=wolf[k];
					bottom[j]=make_pair(wolf[j].first,wolf[j].first+s-num);
					wolf[j]=make_pair(wolf[j].first+s-num,wolf[j].second);
					num=s;
					B=j+1;
					P=j;
					phase++;
					j--;
					continue;
				}
				if(phase==1&&num+wolf[j].second-wolf[j].first>t){
					for(int k=P;k<j;k++)middle[k-P]=wolf[k];
					middle[j-P]=make_pair(wolf[j].first,wolf[j].first+t-num);
					wolf[j]=make_pair(wolf[j].first+t-num,wolf[j].second);
					M=j-P+1;
					for(int k=j;k<size;k++){
						top[k-j]=wolf[k];
					}
					T=size-j;
					break;
				}
				num+=wolf[j].second-wolf[j].first;
			}
			for(int j=0;j<T;j++)wolf[j]=top[j];
			for(int j=0;j<M;j++)wolf[j+T]=middle[j];
			for(int j=0;j<B;j++)wolf[j+T+M]=bottom[j];
			size=T+M+B;
		}
		int num=0;
		int ret=0;
		//for(int i=0;i<size;i++)printf("%d %d\n",wolf[i].first,wolf[i].second);
		for(int i=0;i<size;i++){
			if(wolf[i].first==wolf[i].second)continue;
			if(num+wolf[i].second-wolf[i].first>=p){
				if(wolf[i].first+p-num<=r)ret-=p-num;
				else if(wolf[i].first<=r-1)ret-=r-wolf[i].first;
				break;
			}else{
				if(wolf[i].second<=r)ret-=wolf[i].second-wolf[i].first;
				else if(wolf[i].first<=r-1)ret-=r-wolf[i].first;
			}
			num+=wolf[i].second-wolf[i].first;
		}
		num=0;
		for(int i=0;i<size;i++){
			if(wolf[i].first==wolf[i].second)continue;
			if(num+wolf[i].second-wolf[i].first>=q){
				int x=q-num;
				if(wolf[i].first+q-num<=r)ret+=q-num;
				else if(wolf[i].first<=r-1)ret+=r-wolf[i].first;
				break;
			}else{
				if(wolf[i].second<=r)ret+=wolf[i].second-wolf[i].first;
				else if(wolf[i].first<=r-1)ret+=r-wolf[i].first;
			}
			num+=wolf[i].second-wolf[i].first;//printf("%d\n",ret);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(void){
int a[4],b[4];
while(~scanf("%d",a)){
int h=0,l=0;
for(int i=0;i<3;)scanf("%d",++i+a);
for(int i=0;i<4;)scanf("%d",b+i++);
for(int i=0;i<4;i++)for(int j=0;j<4;j++){
if(a[i]==b[j])if(i==j)h++;else l++;
}
printf("%d %d\n",h,l);
}
return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>

#define ELIF else if
#define FOR(iterator, limit, adder) for(int iterator=0; iterator<limit; iterator+=adder)
#define PI 3.1415926535897932384626433832795
#define PB push_back

typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef long long ll;

using namespace std;

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

    cin>> s;
    s[3]= '8';
    cout<< s<< "\n";
}

Measured memory_bytes: 3636
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te    
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    ll vis[maxN], a[maxN], b[maxN];
    vi adj[maxN];

    void dfs(ll x, ll h, ll t){
        // cout << t << " " << x << " " << vis[x] << endl;
        vis[x] = 10;
        if(t == 1) a[x] = h;
        if(t == 2) b[x] = h;
        for(auto i: adj[x]) if(!vis[i]) dfs(i, h+1, t);
    }

    void solve() {
        ll n, cnt = 0;
        cin >> n;
        rep(i, n-1){
        ll x, y;
        cin >> x >> y;
        adj[x].pb(y), adj[y].pb(x);
    }
        dfs(1, 0, 1);
        memset(vis, 0, sizeof(vis));
        dfs(n, 0, 2);
        repA(i, 1, n)   {
            // cout << a[i] << " " << b[i] << endl;
            if(a[i] <= b[i]) cnt++; else cnt--; 
        }
        cout << (cnt > 0 ? "Fennec":"Snuke") << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    } 


Measured memory_bytes: 10880
local _i={}
for i=1,1 do
    local a=io.read()
    _i[i]={}
    for s in string.gmatch(a,"%S+")do
        _i[i][#_i[i]+1]=s
    end
end

local a={tonumber(_i[1][1]),tonumber(_i[1][2]),tonumber(_i[1][3])}
table.sort(a)
print(a[1]*a[2]*.5)

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

using namespace std;

int main()
{
	int n, t[101], v[101];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> t[i];
	for (int i = 0; i < n; i++)
		cin >> v[i];
	t[n] = 1, v[n] = 0;
	int x = 1, s = 0, d = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < t[i] * 2; j++, x++) {
			int m = 10000;
			for (int k = 0, T = 0; k <= n; T += t[k++]) {
				int l = k == i ? v[k] * 2 : k < i ? v[k] * 2 + x - T * 2 - t[k] * 2 : v[k] * 2 - x + T * 2;
				if (l < m) m = l;
			}
			if (m == s)
				d += s * 2;
			else if (m < s)
				d += s * 2 - 1, s--;
			else
				d += s * 2 + 1, s++;
		}
	}
	printf("%f\n", d / 8.);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define INF 1e9
#define REP(i,n) for (int i = 0; i < (b); ++i)
#define LOG(x) cerr << #x << " = " << (x) << endl

using namespace std;

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

    if (s.find("YAKI") == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main(){
    unsigned int k;
    string s;
    cin >> k >> s;
    if(s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{

	/*
	 * A??§??? ??????????????????????????????????£? ??\????±????????????±?????????????????§?????°?????????
	 *
	 * ??????????????± ??¢?£? ?????? ????????? ??¶?????°
	 *
	 * ????£???????????????????????????????????????????????????\?±??????°????????????????????? ?????????????????????????????????????????????????????????????????????????????¨?±??????\?±??????°??????????????????????????????
	 * ??\?±??????°?????????????????????????????????????????????????????? ????£????????????? #################### (20?????? # )
	 */
	public static void main(String[] args) {

		// ??????????????????????????????????£?
		int[][][] hoUse = new int[4][3][10];

		// ??????????????±
		// ??¢?£? ?????? ????????? ??¶?????°
		int building, floor, room, people;

		Scanner scAner = new Scanner(System.in);
		int info = scAner.nextInt();// ex:3


		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 3; j++)
				for (int k = 0; k < 10; k++)
					hoUse[i][j][k] = 0;

		for (int i = 0; i < info; i++) {
			// ex 3
			// 1 1 3 8
			// 3 2 2 7
			// 4 3 8 1
			building = scAner.nextInt();
			floor = scAner.nextInt();
			room = scAner.nextInt();
			people = scAner.nextInt();

			hoUse[building - 1][floor - 1][room - 1] += people  ;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + hoUse[i][j][k]);
				}
				System.out.println("");
			}
			if (i < 3)
				System.out.println("####################");
		}
	}
}

Measured memory_bytes: 29416
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;

  scc_graph graph(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    graph.add_edge(a, b);
  }

  auto ans = graph.scc();
  cout << sz(ans) << endl;
  rep(i,sz(ans)){
    cout << sz(ans.at(i)) << " ";
    rep(j,sz(ans.at(i)))  cout << ans.at(i).at(j) << " ";
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 40588