akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(m)]

L = []
R = []
L_append = L.append
R_append = R.append
for l, r in LR:
    L.append(l)
    R.append(r)

min_R = min(R)
max_L = max(L)
if min_R >= max_L:
  ans = min_R +1 - max_L
else:
  ans = 0
  
print(ans)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;

ll x[100001], y[100001];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,X = 0,Y = 0;
  cin >> n >> m;
  rep(i,n){
    cin >> x[i];
  }
  rep(i,m){
    cin >> y[i];
  }
  REP(i,1,n+1){
    (X += (2 * i - n - 1) % mod * x[i-1]) %= mod;
  }
  REP(i,1,m+1){
    (Y += (2 * i - m - 1) % mod * y[i-1]) %= mod;
  }
  std::cout << X * Y % mod << std::endl;

  return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		int[] data = new int[3];
		for (int i = 0; i < data.length; i++) {
		    data[i] = sc.nextInt();
		}
		Arrays.sort(data);		
		System.out.println(data[2] - data[0]);
	}
}

Measured memory_bytes: 20948
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int i,k[]=new int[5],t,mx=0,j;
		for(i=0;i<5;i++){
			k[i]=s.nextInt();
		}
		for(i=0;i<5;i++){
			mx=i;
			for(j=i;j<5;j++){
				if(k[j]>k[mx]){
					mx=j;
				}
			}

			t=k[i];
			k[i]=k[mx];
			k[mx]=t;
		}
		for(i=0;i<4;i++){
			System.out.print(k[i]+" ");
		}
		System.out.println(k[4]);
	}

}

Measured memory_bytes: 12000
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double a = in.nextInt();
		double s = (a/3)* (a/3)* (a/3);
		
		
		System.out.print(s);
      
	}
}

Measured memory_bytes: 21844
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

NUM = [[0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0],
       [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0],
       [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
paper = Counter()
for line in stdin:
    if not line.strip():
        break
    x, y, size = (int(s) for s in line.split(','))

    xidx = [x, x-1, x, x+1, x-2, x-1, x, x+1, x+2, x-1, x, x+1, x]
    yidx = [y-2, y-1, y-1, y-1, y, y, y, y, y, y+1, y+1, y+1, y+2]
    val = NUM[size-1]

    for a, b, i in zip(xidx, yidx, xrange(len(xidx))):
        if a < 0 or 9 < a or b < 0 or 9 < b:
            continue
        paper[a + b * 10] += val[i]

print(sum(1 for i in xrange(100) if not paper[i]))
print(max(paper[i] for i in xrange(100)))

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

int q(const void *a,const void *b)
{
    return *(int*)a-*(int*)b;
}

int main(void)
{
    char w[100][11];
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;++i)scanf("%s",w[i]);
    for(i=0;i<n-1;++i){
        for(j=i+1;j<n;++j){
            if(strcmp(w[i],w[j])==0){
                puts("No");
                return 0;
            }
        }
    }
    for(i=1;i<n;++i){
        if(w[i-1][strlen(w[i-1])-1]!=w[i][0]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

int n,mx,x,y,m,b,a[li],k,flag,yes,vis[li],tut[li],mx1;
int cev;
string s;
vector<int> v[li];
vector<int> vv[li];

void dfs(int node,int ata,int der){
	vv[der].pb(node);
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata) continue;
		dfs(go,node,der+1);
	}
	//~ cout<<der<<endl;
	mx1=max(mx1,der);
}

int main(void){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		vis[x]++;
		vis[y]++;
		if(mx<vis[x]) yes=x;
		mx=max(mx,vis[x]);
		if(mx<vis[y]) yes=y;
		mx=max(mx,vis[y]);
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cev+=a[i];
	}
	int at=n;
	sort(a+1,a+n+1);
	printf("%d\n",cev-a[n]);
	dfs(yes,0,0);
	//~ cout<<mx1<<endl;
	for(int i=0;i<=mx1;i++){
		//~ cout<<at<<" **&&((*&& "<<endl;
		for(int j=0;j<(int)vv[i].size();j++){
			tut[vv[i][j]]=a[at];
			//~ printf("^^");
			at--;
		}
	}
	FOR{
		printf("%d ",tut[i]);
	}
	return 0;
}


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

using namespace std;

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

    vector<vector<int>> a(n, vector<int>(3));

    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    vector<vector<int>> dp(n, vector<int>(3));

    for (int i = 0; i < 3; i++) {
        dp[0][i] = a[0][i];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
                }
            }
        }
    }

    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> l(m);
  vector<int> p(m);
  rep(i,m){
    int k;
    cin >> k;
    rep(j,k){
      int s;
      cin >> s;
      s--;
      l[i].push_back(s);
    }
  }
  rep(i,m) cin >> p[i];

  int ans = 0;
  rep(sw,(1<<n)){
    bool flag = true;
    rep(i,m){
      int cnt = 0;
      for(auto j : l[i]) {
        if(sw & (1<<j)) cnt++;
        // not j << 1;
      }
      if(cnt%2 != p[i]) flag = false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;

  
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())


int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;
	vi h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	vi dp(n, INT_MAX);

	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + k; j++) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
			}
		}
	}

	cout << dp[n - 1] << "\n";

	return 0;
}

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

    else if (a < 0)
    {
        if (b >= 0)
        {
            if (c >= 0)
            {
                printf("%ld\n",b * d);
            }
            else if (c < 0)
            {
                if (d >= 0)
                {
                    if ((a * c) >= (b * d))
                    {
                        printf("%ld\n",a * c);
                        
                    }
                    else if ((a * c) < (b * d))
                    {
                        printf("%ld\n",b * d);

                    }
                    
                    
                }
                else if (d < 0)
                {
                    printf("%ld\n",a * c);

                }
                
                
            }
            
            
        }
        else if (b < 0)
        {
            if (c >= 0)
            {
                printf("%ld\n",b * c);
            }
            else if (c < 0)
            {

             printf("%ld\n",a * c);
     
            }
            
            
        }
        
        
    }
    
    
    return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
    string istr;

    cin >> istr;
    if(stoi(istr.substr(0,2)) <= 12 && stoi(istr.substr(0,2)) >= 1 && stoi(istr.substr(2,2)) <= 12 && stoi(istr.substr(2,2)) >= 1)
        cout << "AMBIGUOUS" << endl;
    else if(stoi(istr.substr(0,2)) <= 12 && stoi(istr.substr(0,2)) >= 1 && (stoi(istr.substr(2,2)) > 12 || stoi(istr.substr(2,2)) < 1))
        cout << "MMYY" << endl;
    else if((stoi(istr.substr(0,2)) > 12 || stoi(istr.substr(0,2)) < 1) && stoi(istr.substr(2,2)) <= 12 && stoi(istr.substr(2,2)) >= 1)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;

    return 0;
}

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

int main(){
    string s; cin >> s;
    int ssize = s.size();
    for(int i = 0; i <ssize; i++){
        if(i%2){ //i:even
            if(s[i] == 'R'){
                cout << "No" << endl; 
                return 0;
            }
        }else{ //i:odd
            if(s[i] == 'L'){
                cout << "No" << endl; 
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

class dice{
private:
	int me[6];
public:
	int set();
	int roll(char c);
	int show();
};

int dice::set(){
	int i;

	for (i = 0; i < 6; i++)
		cin >> me[i];

	return 0;
}

int dice::roll(char c){
	int temp;
	if (c == 'S'){
		temp = me[0];
		me[0] = me[4];
		me[4] = me[5];
		me[5] = me[1];
		me[1] = temp;
	}
	else if (c == 'N'){
		temp = me[0];
		me[0] = me[1];
		me[1] = me[5];
		me[5] = me[4];
		me[4] = temp;
	}
	else if (c == 'W'){
		temp = me[0];
		me[0] = me[2];
		me[2] = me[5];
		me[5] = me[3];
		me[3] = temp;
	}
	else if (c == 'E'){
		temp = me[0];
		me[0] = me[3];
		me[3] = me[5];
		me[5] = me[2];
		me[2] = temp;
	}

	return 0;
}

int dice::show(){

	cout << me[0] << endl;
	return 0;
}

int main(){
	dice d;
	string c;
	int i;

	d.set();

	cin >> c;

	for (i = 0; i < c.length(); i++)
		d.roll(c[i]);

	d.show();

	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9+7
int main()
{
    long int n,k;
    cin>>n>>k;
    long int arr[n],dp[n];
    for(long int i=0;i<n;i++)
    cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(long int i=2;i<n;i++)
    {
      dp[i] = INF;
        for(int j=1;j<=k;j++)
        {
            if((i-j)>=0)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	int N, K;
	
	cin >> N >> K;

	if ( K * 2 - 1 <= N )
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
import collections

N = map(int, input().split())
S = list(map(int, input().split()))
S_unique_count = list(collections.Counter(S).items())

ans = 0
for i in range(len(S_unique_count)):
    if S_unique_count[i][0] == S_unique_count[i][1]:
        pass
    elif S_unique_count[i][0] > S_unique_count[i][1]:
        ans += S_unique_count[i][1]
    elif S_unique_count[i][0] < S_unique_count[i][1]:
        ans += S_unique_count[i][1] - S_unique_count[i][0]

print(ans)

Measured memory_bytes: 69160
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int i,j,k;
  i=a+b;
  j=a-b;
  k=a*b;
  if(i>=j && i>=k)
    printf("%d",i);
    else if(j>=i && j>=k)
      printf("%d",j);
  else
    printf("%d",k);
}


Measured memory_bytes: 1708
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h = ni()
ct = 0
while h > 0:
    h //= 2
    ct = ct * 2 + 1
print(ct)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
set<string> st;
void looks(string,string);
void fiset(string,string);
int main(){
  int n;
  string a;
  string b1,b2;
  int si;

  cin >> n;
  for(int i=0;i<n;i++){
    //

    st.clear();
    //in
    cin >> a;
    si=a.size();
    for(int j=1;j<si;j++){
      int k;
      b1.clear();
      b2.clear();
      for(k=0;k<j;k++){
	b1+=a[k];
      }
      for(;k<si;k++){
	b2+=a[k];
      }
      looks(b1,b2);
    }
    cout << st.size() << endl;
  }
  return 0;
}
void looks(string n1,string n2){
  for(int i=0;i<4;i++){
    if(i==0)fiset(n1,n2);
    if(i==1||i==3){
      reverse(n1.begin(),n1.end());
      fiset(n1,n2);
    }
    if(i==2){
      reverse(n2.begin(),n2.end());
      fiset(n1,n2);
    }
  }
}
void fiset(string a,string b){
  string x;
  for(int i=0;i<2;i++){
      x.clear();
      if(i==1)a.swap(b);
	x+=a;
	x+=b;
      st.insert(x);
  }
}

Measured memory_bytes: 1292
import fractions
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
s = set(a)
c = set()
l = 1
k = (a[0] // 2) % 2
for i in a:
    l = l * i // fractions.gcd(l,i)
    if l // 2 > m:
        ans = 0
        break
    count = 0
    while True:
        if (i>>count) % 2 == 0:
            count += 1
        else:
            c.add(count)
            break
    if len(c) > 1:
        ans = 0
        break
else:
    ans = (m + l // 2) // l

print(ans)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y,z;
    cin>>x>>y;
  bool c = false;
  z=x*4;
  if(z==y){
    c=true;
  }
  else{
    for (int i = 0; i <x ; i++) {
      z-=2;
      if(z==y){
        c=true;
        break;
      }
    }
  }
if(c){
  cout<<"Yes"<<endl;
}
    else{
      cout<<"No"<<endl;
    }
  }

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


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
set <int> st;
bool type[MAXN]; int pos[MAXN];
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++) {
		int x, y; read(x), read(y);
		type[x] = true, pos[x] = y;
	}
	for (int i = 1; i <= n; i++) {
		int x, y; read(x), read(y);
		type[x] = false, pos[x] = y;
	}
	int ans = 0;
	for (int i = 0; i < 2 * n; i++) {
		if (type[i]) st.insert(pos[i]);
		else {
			set <int> :: iterator tmp = st.lower_bound(pos[i]);
			if (tmp == st.begin()) continue;
			tmp--; ans++;
			st.erase(tmp);
		}
	}
	writeln(ans);
	return 0;
}

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

int main(){
  int n, ans;
  cin >> n;
  vector<int> a(n);
  rep(i, n, 0) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  ans = a.at(n/2) - a.at(n/2 -1);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];


void solve() 
{
    int a, b;
    cin>>a>>b;

    cout<<100<<" "<<100<<endl;

    char s[101][101];

    for(int i = 1; i <= 50; i++)
    {
        for(int j = 1; j <= 100; j++)
        {
            s[i][j] = '#';
        }
    }

    for(int i = 51; i <= 100; i++)
    {
        for(int j = 1; j <= 100; j++)
        {
            s[i][j] = '.';
        }
    }

    int i = 1, j = 1;

    a--;
    while(1)
    {
        if(a==0) break;
        
        s[i][j] = '.';
        a--;
        j+=3;
        if(j > 100)
        {
            i+=2;
            j = 1;
        }
    }

    i = 52, j = 1;

    b--;
    while(1)
    {
        if(b == 0) break;
        
            s[i][j] = '#';
            b--;
        
        j+=3;
        if(j > 100)
        {
            i+=2;
            j = 1;
        }
    }

    for(int i = 1; i <= 100; i++)
    {
        for(int j = 1; j <= 100; j++)
        {
            cout<<s[i][j];
        }
        cout<<endl;
    }


} 

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15520
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4146)
using namespace std;
template <class Type>
class BIT {
private:
	size_t size_; std::vector<Type> v;
	Type sum(size_t r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & (-r); return ret; }
public:
	BIT() {};
	BIT(size_t size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v.resize(size_ + 1, 0);
	}
	inline void add(size_t i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	inline Type sum(size_t l, size_t r) { return sum(r) - sum(l); }
	bool operator[](size_t x) { return sum(x, x + 1); }
};

int n, xa[111111], ya[111111], xb[111111], yb[111111], xc[222222], yc[222222], cx, cy;
vector<int> q1[222222], q2[222222], q3[222222], q4[222222];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> xa[i] >> ya[i] >> xb[i] >> yb[i];
		if (xa[i] > xb[i]) swap(xa[i], xb[i]);
		if (ya[i] > yb[i]) swap(ya[i], yb[i]);
		xc[cx++] = xa[i]; xc[cx++] = xb[i];
		yc[cy++] = ya[i]; yc[cy++] = yb[i];
	}
	sort(xc, xc + cx);
	cx = unique(xc, xc + cx) - xc;
	sort(yc, yc + cy);
	cy = unique(yc, yc + cy) - yc;
	for (int i = 0; i < n; i++) {
		xa[i] = lower_bound(xc, xc + cx, xa[i]) - xc;
		ya[i] = lower_bound(yc, yc + cy, ya[i]) - yc;
		xb[i] = lower_bound(xc, xc + cx, xb[i]) - xc;
		yb[i] = lower_bound(yc, yc + cy, yb[i]) - yc;
	}
	for (int i = 0; i < n; i++) {
		if (ya[i] == yb[i]) {
			q1[ya[i]].push_back(xa[i]); // yoko - left
			q2[yb[i]].push_back(xb[i]); // yoko - right
		}
		else {
			q3[ya[i]].push_back(xa[i]); // tate - in
			q4[yb[i]].push_back(xb[i]); // tate - out
		}
	}
	BIT<int> b(cx);
	long long ret = 0;
	for (int i = 0; i < cy; i++) {
		for (int j = 0; j < q3[i].size(); j++) b.add(q3[i][j], 1);
		for (int j = 0; j < q1[i].size(); j++) ret += b.sum(q1[i][j], q2[i][j] + 1);
		for (int j = 0; j < q4[i].size(); j++) b.add(q4[i][j], -1);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 30688
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  string S;
  cin >> S;
  REP(i, S.size()) {
    cout << (S[i] == ',' ? ' ' : S[i]);
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args){
		try{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String str = buf.readLine();
		double r = Double.parseDouble(str);
		double pi = Math.PI;
		double s = r*r*pi;
		double l = 2*r*pi;
		System.out.println(String.format("%.6f",s)+" "+String.format("%.6f",l));
		}catch(IOException e){

		}
	}

}

Measured memory_bytes: 24596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,stack[100];
void push(int);
int pop();

int main(){
  int a,b,n;
  char s[100];
  top=0;
  while((scanf("%s",s)) != EOF){
    if (s[0] == '+'){
      b=pop(); 
      a=pop();
      push(a+b);
    }
    else if (s[0] == '-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if (s[0] == '*'){
      b=pop();
      a=pop();
      push(a*b);
    }
    else {
      n = atoi(s);
      push(n);
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  top++;
  stack[top]=x;
  }

int pop(){
  int x;
  x = stack[top];
  top--;
  return x;
}

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

using namespace std;

int cal[101];
typedef pair<int,int> pii;
typedef pair<double,pii> dpii;
int main(){

    int N,A,B;
    cin>>N>>A>>B;
    int kiziCal;
    cin>>kiziCal;
    for(int i=0;i<N;i++)cin>>cal[i];
    vector<int> v;
    for(int i=0;i<N;i++)
        v.push_back((cal[i]));
    sort(v.begin(),v.end(),greater<int>());
    double mcpd=(double)kiziCal/A;
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=v[i];
        mcpd=max(mcpd,(1.0*kiziCal+sum)/(A+(i+1)*B));
    }
    int res=(int)(mcpd+(1e-10));
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    vector<bool> canuse(10, true);
    rep(i, K) {
        cin >> D[i];
        canuse[D[i]] = false;
    }

    int max = pow(10, 9);
    for (int i = N; i <= max; i++) {
        string s = to_string(i);
        bool judge = 1;
        rep(j, s.size()) {
            if (!canuse[s[j] - '0']) {
                judge = 0;
                break;
            }
        }
        if (judge) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/
int get_f(int x, int y, int z){
  return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main() {
  int n;
  cin >> n;
  int count,f;
  bool go_x, go_y;
  for(int i=1;i<=n;i++){
    if(i>1) cout << count << endl;
    count = 0;
    go_x = true;
    for(int x=1;go_x;x++){
      go_y = true;
      for(int y=1;go_y;y++){
        for(int z=1;1;z++){
          f = get_f(x,y,z);
          //cout<<x<<y<<z<<endl;
          if(f==i){
            count++;
          }else if(f>i){
            if(z==1){
              go_y = false;
              if(y==1){
                go_x = false;
              }
            }
            break;
          }
        }
      }
    }
  }
  cout << count;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int K;
	cin >> K;
	vector<ll> order(K);
	vector<LP> ans(K);
	rep(i,K)cin >> order[i];
	ans[K-1] = make_pair(2,2);
	if(order[K-1] != 2){cout << -1 << endl; return 0;}
	for(int i = K-2; i >= 0; --i){
		ans[i].first = (ans[i+1].first + order[i+1])/order[i] * order[i];
		ans[i].second = (ans[i+1].second/order[i] + (ll)(ans[i+1].second % order[i] != 0)) * order[i];
		ll rest_max = ans[i].first / order[i+1] * order[i+1];
		ll rest_min = ans[i].second / order[i+1] * order[i+1];
		if(!(ans[i+1].second <= rest_max && rest_max <= ans[i+1].first))ans[i].first -= order[i];
		if(!(ans[i+1].second <= rest_min && rest_min <= ans[i+1].first))ans[i].second -=order[i];

		// ok or not
		bool ok = true;
		rest_max = ans[i].first / order[i+1] * order[i+1];
		rest_min = ans[i].second / order[i+1] * order[i+1];
		if(!(ans[i+1].second <= rest_max && rest_max <= ans[i+1].first))ok = false;
		if(!(ans[i+1].second <= rest_min && rest_min <= ans[i+1].first))ok = false;
		if(!ok){
			cout << -1 << endl;
			return 0;
		}
		//printf("[%d] -> [max:min = %lld : %lld][order = %lld]\n", i, ans[i].first, ans[i].second, order[i]);
	}
	ll ans_max = ans[0].first + order[0]-1;
	ll ans_min = ans[0].second;
	cout << ans_min << ' ' << ans_max << endl;
	return 0;
}


Measured memory_bytes: 5628
import fractions

N = int(input())
a = list(map(int,input().split()))
a1 = [0] * N
a2 = [0] * N
a1[0] = 0
a2[-1] = 0
a1[1] = a[0]
a2[-2] = a[-1]
ans = 0
for i in range(2,N):
    a1[i] = fractions.gcd(a1[i-1], a[i-1])
    a2[-(i+1)] = fractions.gcd(a2[-i], a[-i])
for a,b in zip(a1, a2):
    if a == 0:
        ans = max(ans, b)
    elif b == 0:
        ans = max(ans, a)
    else:
        ans = max(ans, fractions.gcd(a, b))
print(ans)


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

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		long height=0;
		long width=0;
		
		for(int i=n-1;i>=1;i--){
			if(a[i]==a[i-1]){
				if(height==0){
					height=a[i];
					i--;
				}
				else{
					width=a[i];
					break;
				}
			}
		}
		System.out.println(height*width);
	}
}


Measured memory_bytes: 50568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;


signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> h(N);
    cin >> h;
    auto check = [&](int T) {
        int count = 0;
        for (int i = 0; i < N; i++) {
            int temp = h[i] - B * T;
            if (temp > 0) {
                count += temp / (A - B) + (temp % (A - B) != 0);
            }
        }
        return count <= T;
    };
    int left = 0, right = 1e9;
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (check(mid)) right = mid;
        else left = mid;
    }
    cout << right << endl;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){

  double n;
  cin >> n;
  double cnt = 0.;
  FOR(i,1,n+1) if(i%2)cnt++;
  printf("%0.10lf\n",cnt/n);
  return 0;
}


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

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MAXN=1e5;

bool check[MAXN];
int N,A[MAXN],cur,cnt=0;

int main() {
	ri(N);
	FOR(i,0,N) ri(A[i]);
	FOR(i,0,N) A[i]--;
	cur=0;
	check[0]=true;
	while(cur!=1) {
		cur=A[cur];
		cnt++;
		if(check[cur]) {
			printf("-1\n");
			return 0;
		}
		check[cur]=true;
	}
	printf("%d\n",cnt);
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main()
{
     int a;
     long long b=900,d=90000,e=9;
     cin>>a;
     if(a<10)
     {
     	cout<<a<<endl;
	 }
	 else if(a>=10&&a<100)
	 {
	 	cout<<e<<endl;
	 }
	 else if(a>=100&&a<1000)
	 {
	 	cout<<a-100+1+e<<endl;
	 }
	 else if(a>=1000&&a<10000)
	 {
	 	cout<<b+e<<endl;
	 }
	 else if(a>=10000&&a<100000)
	 {
	 	cout<<a-10000+1+e+b<<endl;
	 }
	 else if(a==100000) 
	 {
	 	cout<<"90909"<<endl;
	 }
	 return 0;
 }

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
#define min(a, b) ((a) < (b)? (a):(b))
#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(typeof(n) i=(a); i<(n); i++)

int N;
bool g[100][100];

int main() {
    int a, b; cin >> a >> b;
    REP(i, 50, 100) rep(j, 100) g[i][j] = true;
    int i=0, j=0;
    while(a > 1) {
        g[i][2*j] = true;
        j += 1;
        if(j == 50) {
            i+=2;
            j = 0;
        }
        a--;
    }
    i=99;j=0;
    while(b > 1) {
        g[i][2*j] = false;
        j += 1;
        if(j == 50) {
            i-=2;
            j = 0;
        }
        b--;
    }
    cout << 100 << " " << 100 << endl;
    rep(i, 100) {
        rep(j, 100) {
            cout << (g[i][j]? '.':'#');
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
      int[] x = new int[n];
      double sum = 0;
      for (int i=0;i<n;i++){
        x[i]=sc.nextInt();
        sum+=x[i];
      }
      double dn = n;
      int p = (int)Math.round(sum/dn);
      int ans = 0;
      for (int i=0;i<n;i++){
        ans+=Math.pow(Math.abs(x[i]-p),2);
      }
	System.out.println(ans);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE
//ABS, task 09, 2020/04/11
//ms, tle
/*
*/

int main(void){
  int N;
  string S;
  int64_t r=0;
  int64_t g=0;
  int64_t b=0;
  int64_t ans;

  cin >>N;
  cin >>S;

  for(int i=0;i<N;i++){
    if(S.at(i)=='R') r++;
    if(S.at(i)=='G') g++;
    if(S.at(i)=='B') b++;
  }

  ans = r*g*b;
  //cout <<"r:" <<r <<" g:"<<g <<" b:" <<b <<endl;


  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i) != S.at(j) && 2*j-i<N){
        if(S.at(i) != S.at(2*j-i)
         &&S.at(j) != S.at(2*j-i)) ans--;
      }
    }
  }

  cout <<ans <<endl;
  return 0;
}

/*
rgbrgb
8
,,,,,,
,,
*/


Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(2e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int a[N];
void solve(){
    int ans = 0;
    int n;
    cin >>n;
    int sum = 0;
    for(int i =1;i<=n;i++)
        cin >> a[i],sum = (sum+a[i])%MOD;
    for(int i  = 1;i<=n;i++){
        sum -= a[i];
        if(sum < 0) sum+=MOD;
        sum%=MOD;
        a[i] = (a[i] * sum)%MOD;
        if(a[i] < 0) a[i] += MOD;
        a[i]%=MOD;
        ans = (ans + a[i])%MOD;
        if(ans<0)ans+=MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 5168
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def BinarySearch(num, nums):
    if len(nums) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(nums)
    while left < right:
        mid  = (left+right)//2
        if num < nums[mid]:
            right = mid
        else:
            left = mid + 1
    return right


def main():
    n = ni()
    s = na()
    q = ni()
    t = na()
    ans = 0
    for ti in t:
        if ti == s[BinarySearch(ti, s)-1]:
            ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main(){
	queue<char> a,b,c;
	string sa,sb,sc;
	cin >> sa >> sb >> sc;
	for(int i=0;i<sa.size();++i)a.push(sa[i]);
	for(int i=0;i<sb.size();++i)b.push(sb[i]);
	for(int i=0;i<sc.size();++i)c.push(sc[i]);
	char s='a';
	while(1){
		if(s=='a'){
			if(a.size()==0){
				cout << 'A' << endl;
				return 0;
			}
			s=a.front();
			a.pop();
		}else if(s=='b'){
			if(b.size()==0){
				cout << 'B' << endl;
				return 0;
			}
			s=b.front();
			b.pop();
		}else{
			if(c.size()==0){
				cout << 'C' << endl;
				return 0;
			}
			s=c.front();
			c.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>
using namespace std;
struct edge{
  int from,to,cap,rev;
};
static const int INF = INT_MAX/3;
int dfs(int f,int v,int t,vector<vector<edge>> &g,vector<bool> &used){
  
  if(v == t) return f;
  used[v] = true;
  for(auto& e: g[v]){
    if(used[e.to]) continue;
    if(e.cap <= 0) continue;
    int d = dfs(min(e.cap,f), e.to, t, g, used);
    if(d > 0){
      e.cap -= d;
      g[e.to][e.rev].cap += d;
      return d;
    }
  }
  return 0;
}
int max_flow(int s,int t,vector<vector<edge>> &g){
  int f = 0;
  vector<bool> used(g.size());
  while(true){
    fill(used.begin(),used.end(),false);
    int df = dfs(INF,s,t,g,used);
    if(df == 0){
      break;
    }
    f += df;
  }
  return f;
}
int main(){
  int v,e;
  cin >> v >> e;
  vector<vector<edge>> g(v);
  for(int i = 0; i < e;i++){
    int u,v,c;
    cin >> u >> v >> c;
    g[u].push_back({u, v, c, (int)g[v].size()});
    g[v].push_back({v, u, 0, (int)g[u].size() - 1});
  }
  cout << max_flow(0,v-1,g) << endl;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)  for(ll i = 0; i < (n); ++i)
#define rep1(i,n)  for(ll i = 1;i <= (n); ++i)
#define pb push_back
#define M 1000000007
unordered_map<ll,ll>mp;

int main()
{
    fastIO
    string s;
    cin>>s;
    int res=0;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
    if(s[i]=='R')
    cnt++;
    else
    cnt=0;
    res=max(res,cnt);
    }
    cout<<res;
	return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 1;
        int lastV = sc.nextInt();
        Boolean zoka = null;
        for (int i = 1; i < n; i++) {
            int now = sc.nextInt();
            if (zoka == null) {
                if (lastV > now) {
                    zoka = false;
                } else if (lastV < now) {
                    zoka = true;
                }
            } else {
                if ((zoka && now < lastV) || !zoka && now > lastV) {
                    count++;
                    zoka = null;
                }
            }
            lastV = now;
        }

        System.out.println(count);
    }
}


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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<int,int>

const int N=1e5+10;
const ll maxN=1e18+10;
const double pi=3.14159265;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    double n;
    cin >> n;
    cout << n*2*pi;
}
    

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


int main(){
	int n;
	int ary[5010];
	int sum[5020] = { 0 };

	while (cin >> n, n != 0){
		int max_ = numeric_limits<int>::min();
		for (int i = 0; i < n; i++){
			cin >> ary[i];
		}
		for (int i = 1; i < n+1; i++){
			sum[i] = sum[i - 1] + ary[i-1];
		}
		for (int i = 1; i < n + 1; i++){
			for (int j = i; j < n + 1; j++){
				max_ = max(max_, sum[j] - sum[i - 1]);
			}
		}
		cout << max_ << endl;
	}

	return 0;
}

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

int main(){
 string n;
 bool f=0;
    cin >>n;
    for(int i=0; i<3; i++){
    if(n[i]=='7') f=1;
}
if(f==1)cout <<"Yes" <<endl;
else cout <<"No" <<endl;;

    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            System.out.println("a > b");
        } else if (a < b){
            System.out.println("a < b");
        } else if (a == b){
            System.out.println("a == b");
        }
    }
}






Measured memory_bytes: 26268
S=[]
H=[]
C=[]
D=[]
n=int(input())
for i in range(n):
    a,b=map(str,input().split())
    if a=='S':
        S.append(int(b))
    if a=='H':
        H.append(int(b))
    if a=='C':
        C.append(int(b))
    if a=='D':
        D.append(int(b))
for i in range(1,14):
    if not (i in S):
        print(f'S {i}')
for i in range(1,14):
    if not (i in H):
        print(f'H {i}')
for i in range(1,14):
    if not (i in C):
        print(f'C {i}')
for i in range(1,14):
    if not (i in D):
        print(f'D {i}')


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define N 25
using namespace std;
int main(){
	int n,p[N],i,ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>p[i];
	}
	for(i=1;i<n-1;i++)
	{
		if(p[i]>p[i-1]&&p[i+1]>p[i]||p[i]<p[i-1]&&p[i+1]<p[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,a[201],sum=0,min=INT_MAX,s,j;
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		a[i]=l+i;
		sum+=a[i];
	}
	for(j=0;j<n;j++)
	{
		if(abs(a[j])<min)
		{
			min = abs(a[j]);
			s=j;
		}
	}	
	cout<<(sum-a[s]);
	return 0;
} 

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> grid(H+2, vector<char> (W+2, '#'));
  string S;
  rep(i, 1, H+1) {
    cin >> S;
    rep(j, 1, W+1) {
      grid[i][j] = S[j - 1];
    }
  }

  int INF = (int) 1e9+7;

  vector<vector<int>> dist(H*W, vector<int> (H*W, INF));
  vector<vector<int>> list(H*W);
  int x, y, v;
  rep(i, 0, H) {
    x = i + 1;
    rep(j, 0, W) {
      y = j + 1;
      v = i * W + j;

      if (grid[x][y] != '.') {
        continue;
      }

      dist[v][v] = 0;
      if (grid[x][y-1] == '.') { // left
        list[v].pb(v-1);
        list[v-1].pb(v);
        dist[v][v-1] = 1;
        dist[v-1][v] = 1;
      }

      if (grid[x-1][y] == '.') { // up
        list[v].pb(v-W);
        list[v-W].pb(v);
        dist[v][v-W] = 1;
        dist[v-W][v] = 1;
      }

      if (grid[x][y+1] == '.') { // right
        list[v].pb(v+1);
        list[v+1].pb(v);
        dist[v][v+1] = 1;
        dist[v+1][v] = 1;
      }

      if (grid[x+1][y] == '.') { // down
        list[v].pb(v+W);
        list[v+W].pb(v);
        dist[v][v+W] = 1;
        dist[v+W][v] = 1;
      }
    }
  }

  rep(i, 0, H*W) {
    rep(j, 0, H*W) {
      rep(k, 0, H*W) {
        chmin(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }

  int ans = 0;
  rep(i, 0, H*W) {
    rep(j, 0, H*W) {
      if (dist[i][j] == INF) {
        continue;
      } else {
        ans = max(ans, dist[i][j]);
      }
    }
  }

  cout << ans << endl;
};


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadText();
            var pre = 'x';
            var count = 0;
            foreach (var s in N)
            {
                if (pre == s)
                {
                    count++;
                    if (count == 3)
                    {
                        return "Yes";
                    }
                }
                else
                {
                    count = 1;
                }
                pre = s;
            }

            return "No";
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
typedef long long ll;
#define F first
#define S second
#define ii pair<ll , ll>
using namespace std;

const int N = 1e5 + 100;
int n , w;
ii a[120];
ll mem[N][100];

ll dp(int wt , int i){
	if( i == n ) return 0;
	ll &ret = mem[wt][i];
	if(ret != -1) return ret;
	return ret = max(
			dp(wt , i+1),
			(a[i].F + wt <= w ? a[i].S + dp(wt+a[i].F , i+1) : 0)
			);
}

int main(){
	memset(mem , -1 , sizeof mem);
	scanf("%d%d" , &n ,  &w);
	for(int i=0 ; i<n ; i++)
		scanf("%lld%lld" , &a[i].F , &a[i].S); 
	printf("%lld" , dp(0 , 0));
}


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int K, X; cin >> K >> X;
    for (int i=-K+1; i<K; ++i) {
        cout << X+i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		if(b - a < k*2) {
			for(int i = a; i <= b; i++) {
				System.out.println(i);
			}
		} else {
			for(int i = a; i < a+k; i++) {
				System.out.println(i);
			}
			for(int i = b-k+1; i <= b; i++) {
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 21844