akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long N; cin >> N;

    long long ans = 0;
    map<int,int> mp;

    for(int i=0; i<N; i++){
        int A; cin >> A;
        int target = i-A;
        if(target >= 0){
            ans += mp[target];
        }
        mp[A+i] = mp[A+i] +1 ;
    }

    cout << ans << endl;

}

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

ass = list(map(int,input().split()))

ans = 0
for i in range(60):
    k = 1 << i
    i_1 = sum([k & a for a in ass]) >> i
    ans += i_1 * (n - i_1) << i
    ans = ans % ((10**9) + 7)

print(ans)


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

const int vmax=110;
const int inf=1023456789;

int N,M;
int S,T;
struct node{int to,cap,rev;};
vector<node> graph[vmax];
bool used[vmax];

int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v]=true;
	for(auto &e:graph[v]){
		if(!used[e.to] && e.cap > 0){
			int d= dfs(e.to,t,min(f,e.cap));
			if(d > 0){
				e.cap-=d;
				graph[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	for(;;){
		rep(i,vmax) used[i]=false;
		int f=dfs(s,t,inf);
		if(f==0) break;
		flow+=f;
	}
	return flow;
}

int main(void){
	cin >> N >> M;
	rep(i,M){
		int a,b,c;
		cin >> a >> b >> c;
		graph[a].push_back({b,c,(int)graph[b].size()});
		graph[b].push_back({a,0,(int)graph[a].size()-1});
	}
	cout << max_flow(0,N-1) << endl;
	return 0;
}

Measured memory_bytes: 1264
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

x,y = map(int,input().split())

flag=False
if (x+y)%3 == 0:
    k = (x+y)//3
    if abs(x-y) <=k :
        l = abs(x-y)
        if (k-l)%2==0:
            flag=True
            a = (k+l)//2
            #b = (k-l)//2
            c = comb(k,a ,10**9+7)

if flag:
    print(c)
else:
    print(0)



Measured memory_bytes: 39024
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

bool ss(int i1, int i2, int i3, int i4, int i5, int i6, int X){
    int sum = 100*i1+101*i2+102*i3+103*i4+104*i5+105*i6;
    return sum == X;
}

int main(void){

    int X;
    cin >> X;

    bool flag=false;
    int mn = floor(X/105), mx = ceil(X/100);

    int sum=0;
    REP(i1,mx+1){
            REP(i2,mx+1-i1){
                REP(i3,mx+1-i1-i2){
                    REP(i4,mx+1-i1-i2-i3){
                        REP(i5,mx+1-i1-i2-i3-i4){
                            int a = X-(i1+2*i2+3*i3+4*i4+5*i5);
                            if(a%100 == 0 & mn <= a/100 && a/100 <= mx){
                                cout << 1 << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
    }

    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    status = "undefined"
    ans = 1
    for i in range(N - 1):
        diff = A[i + 1] - A[i]
        if status == "undefined":
            if diff == 0:
                pass
            elif diff > 0:
                status = "increase"
            else:
                status = "decrease"
        elif status == "increase":
            if diff >= 0:
                pass
            else:
                ans += 1
                status = "undefined"
        else:
            if diff <= 0:
                pass
            else:
                status = "undefined"
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e5+10,mod=1e9+7;
vector<int> G[N];
ll dp[N][2],n;
ll dfs(int u,int p,bool col){
    ll &ret = dp[u][col];
    if(ret+1) return ret;
    ret = 1;
    for(auto v:G[u]){
        if(v!=p){
            int cur = dfs(v,u,1);
            if(col){
                cur += dfs(v,u,0);
                cur %= mod;
            }
            ret *= cur;
            ret %= mod;
        }
    }
    return ret;
}
int main()
{
    FASTIO
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=1;i<n;i++){
        int u,v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    ll ans=dfs(1,-1,0)+dfs(1,-1,1);
    ans %= mod;
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 15616
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
int main()
{
	ll x;
	ll a=100,c=0;
	cin>>x;
	while(x>a){
		a+=(a/100);
		c++;
	}
	cout<<c<<endl;
	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    int K=S.size();
    int ans;
    ans=K;
    for (int i=0;i<K-1;i++)
    {
        if (S[i]!=S[i+1])
        {
            ans=min(ans,max(i+1,K-i-1));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

#define MAX 100000
#define KAZU 1000000000

struct Card{
  char suit;
  int value;
};


struct Card LEFT[MAX/2+2], RIGHT[MAX/2+2];

void merge(struct Card *, int , int , int);
void mergeSort(struct Card *, int, int);
int partition(struct Card *, int, int);
void quickSort(struct Card *, int ,int);

int n;

int main(){
  int n, i, z,stable=1;
  struct Card a[MAX],b[MAX];
  char S[10];
  scanf("%d",&n);
  
  for (i=0;i<n; i++ ) {
    scanf("%s %d", S, &z);
    a[i].suit=S[0];
    b[i].suit=S[0];
    a[i].value=z;
    b[i].value=z;
    
  }
  
  mergeSort(a,0, n);
  quickSort(b,0, n-1);
  
  for ( i = 0; i < n; i++ ){
    if ( a[i].suit != b[i].suit ){
      stable = 0;
    }
  }
  
  if ( stable == 1 ) printf("Stable\n");
  if ( stable == 0 )printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", b[i].suit, b[i].value);
  }

return 0;
}

void merge(struct Card a[],int left2,int mid,int right2){
  int i,j,k,n1,n2;
  
  n1=mid-left2;
  n2=right2-mid;
  for(i=0;i<n1;i++){
    LEFT[i]=a[left2+i];
  }
  for(i=0;i<n2;i++){
    RIGHT[i]=a[mid+i];
  }
  LEFT[n1].value=KAZU;
  RIGHT[n2].value=KAZU;
  i=0;
  j=0;
  for(k=left2;k<right2;k++){
    if(LEFT[i].value<=RIGHT[j].value){
      a[k]=LEFT[i];
      i=i+1;
	}
    else{
      a[k]=RIGHT[j];
      j=j+1;
    }
  }
}

void mergeSort(struct Card a[],int left2,int right2){
  int mid;
  if(left2+1<right2){
    mid=(left2+right2)/2;
    mergeSort(a,left2,mid);
    mergeSort(a,mid,right2);
    merge(a,left2,mid,right2);
  }
  
}
  
int partition(struct Card a[],int p,int r){
  
  int i,j;
  struct Card c, x;
  x=a[r];
    i=p-1;
    for(j=p;j<r;j++){
      if(a[j].value<=x.value){
	i=i+1;
	c=a[i];
	a[i]=a[j];
	a[j]=c;
      }
    }
    c=a[i+1];
    a[i+1]=a[r];
    a[r]=c;
    
    return i+1;
  }

 void quickSort(struct Card a[], int p, int r){
  int q;
  if (p<r){
    q=partition(a, p, r);
    quickSort(a, p, q - 1);
    quickSort(a, q + 1, r);
  }
 }



Measured memory_bytes: 4044
#include <iostream>
#include <algorithm>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main() {
  string s;
  int n;
  cin>>n;
  cin>>s;
  if(n>=s.size()) cout<<s;
  else{
    for(int i=0;i<n;i++) cout<<s[i];
    cout<<"...";
  }
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (auto &x : p) {
		cin >> x;
	}

	int ans = 0;
	for (int i = 1; i + 1 < n; ++i) {
		vector<int> q = { p[i - 1],p[i],p[i + 1] };
		sort(q.begin(), q.end());
		if (p[i] == q[1]) {
			++ans;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

#define PI 3.14159265358979323846

double getradian(double num)
{
	return num * (PI/180);
}

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

	cout << fixed;
	cout.precision(9);
	double a,b,h,m;

	cin >> a >> b >> h >> m;

	double hx,hy,mx,my;
	double x = (h/12)*360 + 30*(m/60);
	double y = (m/60)*360;
	x = 90 - x;
	y = 90 - y;
	//cout << x << ' ' << y << '\n';
	if(x < 0)
	{
		x += 360;
	}
	if(y < 0)
	{
		y += 360;
	}
	//cout << x << ' ' << y << '\n';
	double angleh;
	double anglem;
	if(x<=90)
	{
		angleh = getradian(x);
		hx = a*cos(angleh);
		hy = a*sin(angleh);
	}
	else if(x<=180)
	{
		angleh = getradian(180 - x);
		hx = -a*cos(angleh);
		hy = a*sin(angleh);
	}	
	else if(x<=270)
	{
		angleh = getradian(x - 180);
		hx = -a*cos(angleh);
		hy = -a*sin(angleh);
	}
	else
	{
		angleh = getradian(360 - x);
		hx = a*cos(angleh);
		hy = -a*sin(angleh);		
	}
	if(y<=90)
	{
		anglem = getradian(y);
		mx = b*cos(anglem);
		my = b*sin(anglem);
	}
	else if(y<=180)
	{
		anglem = getradian(180 - y);
		mx = -b*cos(anglem);
		my = b*sin(anglem);
	}	
	else if(y<=270)
	{
		anglem = getradian(y - 180);
		mx = -b*cos(anglem);
		my = -b*sin(anglem);
	}
	else
	{
		anglem = getradian(360 - y);
		mx = b*cos(anglem);
		my = -b*sin(anglem);		
	}	
	//cout << mx << ' ' << my << ' ' << hx << ' ' << hy << '\n';
	//cout << angleh << ' ' << anglem << ' ' << hx << ' ' << hy << '\n';
	double res = sqrt((hx - mx)*(hx - mx) + (hy - my)*(hy - my));

	cout << res << '\n';

	return 0;
}

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

int main() {
  int n, m = 1000000000;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  rep(i, 201){
    int tmp = 0;
    rep(j, n) tmp += pow((v[j]-i+100), 2);
    m = min(m, tmp);
  }
  cout << m << endl;
  return 0;
}

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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    long long a, b, c;
    cin >> a >> b >> c;
    
    long long ans = 0;
    
    if(c <= b)
        ans = b + c;
    else
    {
        if(c <= a + b + 1)
            ans = b + c;
        else
            ans = b + a + 1 + b;
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
program abc163a
  implicit none
  integer n, m, a(10005), total, i
  total = 0
  read (*,*) n, m
  read (*,*) (a(i), i=1, m)
  do i=1, m
    total = total + a(i)
  end do
  if (n >= total) then
    print *, n-total
  else
    print *, -1
  end if
end program abc163a


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

template<typename T>
ll binary_search(ll limit, bool (*func)(ll)) {
    ll left = 1, right = limit;
    while ( right >= left ) {
        ll mid = left + (right - left) / 2;
        bool ans = func(mid);
        if (ans) right = mid;
        else left = mid;
    }
    return right;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll m = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        m = max(A[i], m);
    }
    auto f = [&](ll key) -> bool{
        ll cnt = 0;
        for (int i = 0; i < N; ++i) {
            cnt += (A[i] / key) + min(A[i] % key, 1ll) - 1;
        }
        if (cnt <= K) return true;
        return false;
    };
    ll left = 0, right = m+1;
    while ( right - left > 1 ) {
        ll mid = (left + right) / 2;
        bool ans = f(mid);
        if (ans) right = mid;
        else left = mid;
    }
    cout << right << endl;
}


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

using namespace std;

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    for(int i = 0; i < n; i++)
        ans += a[a[i] - 1] == i + 1;
    cout << ans / 2 << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s; 
    int b = 0; 
    long long ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'W')
            ans += b;
        else b++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;

  vector<int> BOX(N, 1);
  vector<bool> RED(N, false);
  RED[0] = true;

  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;

    if (RED[x]) RED[y] = true;
    BOX[x]--;
    BOX[y]++;
    if (BOX[x] == 0) RED[x] = false;
  }

  int64_t answer = 0;
  rep(i, N) {
    if (RED[i]) answer++;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

/**
 * お遊び
 *
 * @author s-sugimoto
 */
public class Main {

	/**
	 * 隠蔽
	 */
	private Main() {
	}

	/**
	 * main
	 *
	 * @param args 起動引数
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num1 = scanner.nextInt();
		int num2 = scanner.nextInt();

		int output = getLogic(num1, num2);
		System.out.println(output);
	}

	/**
	 * ロジック群
	 */
	private static int getLogic(int num1, int num2) {
		if (num1 < num2) {
			return 0;
		}
		int result = num1 - num2;
		return result;
	}
}


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

constexpr int MAXN = (int)2e5;
constexpr long long INF = (long long)1e15;


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

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int d[10010][2]={0};
  string s;
  
  cin >> n;
  m=0;
  rep(i,n){
    cin >> d[i][0] >> d[i][1];
    if(d[i][0]==d[i][1]) m++;
    else m=0;
    if(m>=3) result=1;
  }
  
  cout << (result==1 ? "Yes" : "No") << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, M;
    cin >> N >> M;

    if(N % 2){
        REP(i,M){
            ll left, right;
            left = i+1;
            right = left + 2*(M-i);
            printf("%lld %lld\n", left ,right);
        }
    }
    else{
        int num = 0;
        int idx = 1;
        for(int x = N/2-1; x >= 1; x -= 2){
            if(num == M)
                break;
            printf("%lld %lld\n", idx ,idx+x);
            idx++;
            num++;
        }

        idx = 1+N/2;
        for(int x = N/2-2; x >= 1; x -= 2){
            if(num == M)
                break;
            printf("%lld %lld\n", idx ,idx+x);
            idx++;
            num++;
        }
    }
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <set>

using namespace std;

namespace {
const set<int> group_a = {1, 3, 5, 7, 8, 10, 12};
const set<int> group_b = {4, 6, 9, 11};
}

int main() {
  int X, Y;
  cin >> X >> Y;
  
  if ((group_a.count(X) != 0 && group_a.count(Y) != 0) 
       || (group_b.count(X) != 0 && group_b.count(Y) != 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main(void){
  int N;
  int cnt=1;
  scanf("%d",&N);
  char s[N][11];
  for(int i = 0;i < N;i++){
    scanf("%s",s[i]);
  }

  qsort(s,N,11,strcmp);

  for(int i=1;i<N;i++){
    if(strcmp(s[i],s[i-1])!=0){
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}


Measured memory_bytes: 5736
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S, T;
	cin >> S >> T;
	cout << T << S << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

vector<vector<int>>adj;
int vis[200001];

void dfs(int node,int &c){
  vis[node] = 1;
  for(auto p : adj[node]){
    if(vis[p]==0){
      c++;
      dfs(p,c);
    }
  }
}
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   int n,m;
   cin >> n >> m;
   adj.resize(n+1);
   int x,y;
   for(int i = 0 ; i < m ; i++){
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
   }
   int ans = 0;
   int c = 1;
   for(int i = 1 ; i<=n ; i++){
      c = 1;
    if(vis[i]==0){
      dfs(i,c);
      ans = max(ans,c);
    }
   }
   cout << ans;

   
}


Measured memory_bytes: 25064
#!usr/bim/python
#! -*- coding: utf-8 -*-

abcd = raw_input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])

op1 = "+"
op2 = "+"
op3 = "+"

if a+b+c+d==7:
    pass
elif a+b+c-d==7:
    op3 = "-"
elif a+b-c+d==7:
    op2 = "-"
elif a+b-c-d==7:
    op2 = "-"
    op3 = "-"
elif a-b+c+d==7:
    op1 = "-"
elif a-b+c-d==7:
    op1 = "-"
    op3 = "-"
elif a-b-c+d==7:
    op1 = "-"
    op2 = "-"
else:
    op1 = "-"
    op2 = "-"
    op2 = "-"

ans = abcd[0]+op1+abcd[1]+op2+abcd[2]+op3+abcd[3]+"=7"

print ans


Measured memory_bytes: 2696
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#define Rep(i,n) for(int i = 0;i < (n);i++)	
typedef long long ll;

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b); }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

int main() {
	std::string n;
	std::cin >> n;
	int k;
	k = atoi(n.c_str());
	if (k < 10) {
		if (n[0] == '2' || n[0] == '4' || n[0] == '5' || n[0] == '7' || n[0] == '9') {
			std::cout << "hon" << std::endl;
		}
		if (n[0] == '0' || n[0] == '1' || n[0] == '6' || n[0]=='8') {
			std::cout << "pon" << std::endl;
		}
		if (n[0] == '3') {
			std::cout << "bon" << std::endl;
		}
	}
	else if (k >= 10&&k<100) {
		if (n[1] == '2' || n[1] == '4' || n[1] == '5' || n[1] == '7' || n[1] == '9') {
			std::cout << "hon" << std::endl;
		}
		if (n[1] == '0' || n[1] == '1' || n[1] == '6' || n[1] == '8') {
			std::cout << "pon" << std::endl;
		}
		if (n[1] == '3') {
			std::cout << "bon" << std::endl;
		}
	}
	else {
		if (n[2] == '2' || n[2] == '4' || n[2] == '5' || n[2] == '7' || n[2] == '9') {
			std::cout << "hon" << std::endl;
		}
		if (n[2] == '0' || n[2] == '1' || n[2] == '6' || n[2] == '8') {
			std::cout << "pon" << std::endl;
		}
		if (n[2] == '3') {
			std::cout << "bon" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

constexpr int INF{1001001001};
constexpr lint LINF{1001001001001001001ll};
constexpr int MOD{(int)1e9 + 7};
constexpr double EPS{1e-9};
const double PI{acos(-1)};
constexpr int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)(v.size() - 1) ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int p[110] = {};
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  rep(i, a, b) {
    p[i] += 1;
  }
  rep(i, c, d) {
    p[i] += 1;
  }

  int res = 0;
  rep(i, 110) {
    if (p[i] == 2) res++;
  }
  print(res);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// #define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  cin >> n;
  m = INF;
  l = -1;
  rep(i,0,n){
    ll p;
    cin >> p;
    m = min(m,p);
    l = max(l,p);
  }
  print(l-m);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/

void go(){
    int n;
    R(n);
    int ans=0;
    int mx=0;
    rep(i,1,n){
        int x;
        R(x);
        if(x>=mx){
            ans++;
        }
        mx=max(mx,x);
    }
    W(ans);
}


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

constexpr int mod = 1e9 + 7;

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

/*-------------------------------------------*/

struct edge {
    int to, num;
};

int n, m;
vector<pair<int, bool>> bom;
vector<edge> e[100009];
vector<int> ans;

bool visit[100009], cnt[100009];

bool dfs(int x) {
    visit[x] = true;
    rep(i, e[x].size()) {
        if(visit[e[x][i].to]) continue;
        if(dfs(e[x][i].to)) {
            cnt[x] = !cnt[x];
            ans.push_back(e[x][i].num);
        }
    }
    return cnt[x];
}

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

    cin >> n >> m;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        bom.push_back({a, (bool)b});
    }
    // 番兵
    bom.push_back({0, false});
    bom.push_back({mod, false});

    sort(ALL(bom));

    rep(i, bom.size() - 1) cnt[i] = (bom[i].second != bom[i + 1].second);

    rep(i, m) {
        int l, r;
        cin >> l >> r;
        int L = lower_bound(ALL(bom), make_pair(l, false)) - bom.begin() - 1;
        int R = upper_bound(ALL(bom), make_pair(r, true)) - bom.begin() - 1;
        e[L].push_back({R, (int)i + 1});
        e[R].push_back({L, (int)i + 1});
    }

    rep(i, bom.size() - 1) {
        if(visit[i]) continue;
        if(dfs(i)) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans.size() << endl;
    sort(ALL(ans));
    rep(i, ans.size()) {
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 14068
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
s = input()
q = I()
straight = True
ans = deque(s)
for i in range(q):
    A = input().split()
    if A[0] == '1':
        straight = not straight
    else:
        if straight:
            if A[1] == '1':
                ans.appendleft(A[2])
            else:
                ans.append(A[2])
        else:
            if A[1] == '1':
                ans.append(A[2])
            else:
                ans.appendleft(A[2])
if straight:
    print(*ans,sep='')
else:
    print(*reversed(ans),sep='')


Measured memory_bytes: 17644
# include<iostream>
# include<algorithm>

using namespace std;

int main(){
  int k, x;
  cin >> k >> x;
  int start = max(-1000000, x-k+1);
  int end = min(1000000, x+k-1);
  for(int i=start; i<=end; ++i)
    cout << i << ' ';
  cout << '\n';
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong A;
  ldbl B;
  cin >> A >> B;

  cout << (llong)(A * B) << endl;

  return 0;
}

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


int main(){
	int M[10];
	for(int i=0;i<10;i++){
		cin>>M[i];
	}
	sort(M,M+10);
	for(int i=9;i>6;i--){
		cout<<M[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
const int sz=1e5+9;
int n,x,arr[sz][3],dp[sz][3];

int clac(int i,int ignore ,int value){
    if(i>n)return value;
    if(dp[i][ignore]!=-1)return dp[i][ignore];
    int ret=0;
    for(int j=0;j<3;j++){
        if(j==ignore)
            continue;
        ret=max(ret,value+clac(i+1,j,arr[i][j]));
    }
    return dp[i][ignore]=ret;
}

void solve(){
    cin>>n;
    reset(dp,-1);
    //cout<<dp[2][0]<<tab<<dp[2][1]<<tab<<dp[2][2]<<endl;
    lp(i,1,n+1)cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    int ans1=clac(2,0,arr[1][0]);
    //cout<<dp[2][0]<<tab<<dp[2][1]<<tab<<dp[2][2]<<endl;
    int ans2=clac(2,1,arr[1][1]);
    int ans3=clac(2,2,arr[1][2]);
    //cout<<ans1<<tab<<ans2<<tab<<ans3<<endl;
    //int ans=max(ans1,(max(ans2,ans3)));
   // bug(ans1,1);
    cout<<max(ans1,(max(ans2,ans3)))<<"\n";
}

int main(){
    //FasterIO;
    #ifndef ONLINE_JUDGE
       //freopen("1.txt","r",stdin);
    #endif
    // int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=303;
const ll INF=1LL<<60;
ll dp[MAX][MAX][MAX];

int main(){
    
    int N,K;cin>>N>>K;
    vector<ll> H(N+1,0);
    for(int i=0;i<N;i++){
        cin>>H[i+1];
    }
    
    for(int i=0;i<MAX;i++) for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++) dp[i][j][k]=INF;
    
    dp[0][0][0]=0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<=i;k++){
                if(H[k]<H[i+1]) dp[i+1][j][i+1]=min(dp[i+1][j][i+1],dp[i][j][k]+H[i+1]-H[k]);
                else dp[i+1][j][i+1]=min(dp[i+1][j][i+1],dp[i][j][k]);
                //変えない
                
                dp[i+1][j+1][k]=min(dp[i+1][j+1][k],dp[i][j][k]);
                //変える
            }
        }
    }
    
    ll ans=INF;
    
    for(int j=0;j<=K;j++){
        for(int k=0;k<=N;k++){
            ans=min(ans,dp[N][j][k]);
        }
    }
    
    cout<<ans<<endl;
}




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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


ll solve(long long A, long long B, long long C, long long K){
	ll ans = 0;
	if(A >= K) {
		return K;
	} else if(A+B >= K) {
		return A;
	} else {
		return A-(K-A-B);
	}
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    cout << solve(A, B, C, K) << endl;
    return 0;
}



Measured memory_bytes: 3724
N = int(input())

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

lst = [0] * 9

for i in range(N):
    lst[min(a[i]//400, 8)] += 1

count = lst[:8].count(0)

kind_max = min(8-count+lst[8], 100)
kind_min = max(8-count,1)

print (kind_min, kind_max)

Measured memory_bytes: 3060
program ABC165_C
  integer::N,M,Q,ans=0,i
  integer,allocatable::a(:),b(:),c(:),d(:),x(:)
  read(*,*)N,M,Q
  allocate(a(Q),b(Q),c(Q),d(Q),x(N))
  do i=1,Q
     read(*,*)a(i),b(i),c(i),d(i)
  end do
  x(1)=1
  call DFS(2)
  write(*,*)ans
contains
  recursive subroutine DFS(K)
    integer::K,i   !このiの宣言はなぜか必要
    if(K==N+1) then !AをN個決定した(11...1~MM...M)
       ans=max(ans,calc())
       return
    end if
    do i=x(K-1),M !Aを小さい順になるよう決めていく．
       x(K)=i
       call DFS(K+1)
    end do
  end subroutine DFS
  integer function calc()
    calc=0
    do i=1,Q
       if(x(B(i))-x(A(i))==c(i)) calc=calc+d(i)
    end do
  end function calc
end program ABC165_C

Measured memory_bytes: 2872
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<usize>(n);

    let mut money = 1000_usize;
    let mut kabu = 0_usize;
    for i in 0..n - 1 {
        if a[i] < a[i + 1] {
            kabu += money / a[i];
            money %= a[i];
        }
        if a[i] > a[i + 1] {
            money += kabu * a[i];
            kabu = 0;
        }
    }
    money += kabu * a[n - 1];
    println!("{}", money);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  if(n==3) {
    pr(2,5,63);
    return;
  }
  vector<ll> a,b;
  REP(i,2,30001) {
    if(i%2==0) a.pb(i);
    else if(i%3==0) b.pb(i);
  }
  REP(j,1,b.size()+1) {
    int i=n-j;
    if(i>a.size()) continue;
    ll sum=0,z=b[0];
    rep(k,i) sum+=a[k];
    rep(k,j) sum+=b[k];
    rep(k,i) {
      if(__gcd(sum-a[k],a[k])==1) goto next;
    }
    rep(k,j) {
      if(__gcd(sum-b[k],b[k])==1) goto next;
    }
    rep(k,i) z=__gcd(z,a[k]);
    rep(k,j) z=__gcd(z,b[k]);
    if(z==1) {
      vector<int> ans;
      rep(k,i) ans.pb(a[k]);
      rep(k,j) ans.pb(b[k]);
      PR(ans,n);
      return;
    }
  next:;
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N,A,K=MOD,M=0;cin >> N;
    rep(i,N){
      cin>>A;
      K=min(K,A);
      M=max(M,A);
    }
    cout << M-K << endl;
}

Measured memory_bytes: 256
// AtCoder Regular Contest 079
// D - Decrease (Contestant ver.)

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const ll MAX_K = (ll)5e17;
const ll MAX_N = 50;

ll K;
ll N;

int main() {

    ll a;

    cin >> K;
    N = MAX_N;
    cout << N << endl;
    for (ll i = 0; i < N; i++) {
        a = N - 1 + K / N;
        if (i < K % N) {
            a += N - K % N + 1;
        } else {
            a -= K % N;
        }
        cout << a << (i == N - 1 ? '\n' : ' ');
    }


    return 0;

}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, D, X; cin >> N >> D >> X;
	int A[N];
	for(int i = 0; i < N; i++) cin >> A[i];
	int eat = 0;
	for (int i = 0; i < N; i++)
	{
		eat += (D - 1) / A[i] + 1;
	}
	cout << eat + X << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S,T;
int A,B;
string U;

signed main(){
	cin>>S>>T>>A>>B>>U;
	if(S==U){
		cout<<A-1<<" "<<B<<endl;
	}
	else{
		cout<<A<<" "<<B-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
R,G,B,N = map(int,input().split())

ans = 0


for r in range(N+1) :
    
    for g in range(N+1) :
        if (N - (r*R + g*G)) < 0 : continue
        if (N - (r*R + g*G)) % B == 0 :
            ans += 1
            #print(r,g)
print(ans)
        

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

int main(void)
{
    char str[1001] = {0};
    int q;
    
    fgets(str, sizeof(str), stdin);
    if ( str[strlen(str) - 1] == '\n' ) {
        str[strlen(str) - 1] = '\0';
    }
    scanf("%d\n", &q);
    
    for ( int i = 0; i < q; i++ ) {
        char instr[1001] = {0};
        char ope[1001] = {0};
        int a;
        int b;
        char *tp;
        fgets(instr, sizeof(instr), stdin);
        if ( instr[strlen(instr) - 1] == '\n' ) {
            instr[strlen(instr) - 1] = '\0';
        }
        tp = strtok(instr, " ");
        memcpy(ope, tp, sizeof(ope));
        tp = strtok(NULL, " ");
        a = atoi(tp);
        tp = strtok(NULL, " ");
        b = atoi(tp);
        if ( strcmp(ope, "print") == 0 ) {
            for ( int i = a; i <= b; i++ ) {
                printf("%c", str[i]);
            }
            printf("\n");
        } else if ( strcmp(ope, "reverse") == 0 ) {
            char buf[1001] = {0};
            int j;
            memcpy(buf, &str[a], sizeof(char) * (b - a + 1));
            j = strlen(buf) - 1;
            for ( int i = a; i <= b; i++ ) {
                str[i] = buf[j];
                j--;
            }
        } else if ( strcmp(ope, "replace") == 0 ) {
            int j = 0;
            tp = strtok(NULL, " ");
            for ( int i = a; i <= b; i++ ) {
                str[i] = tp[j];
                j++;
            }
        }
    }

    return 0;
}


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

void solve(vector<vector<int>> &h,vector<vector<int>> &v)
{ 
    int n=h.size();
  	    for(int i=n-2;i>=0 ;i--)
  	       for(int j=0;j<3;j++)
  	       v[i][j]= h[i][j]+ max(v[i+1][(j+1)%3],v[i+1][(j+2)%3]);
}
int main()
{
    int n;
    cin>>n;
    vector<vector<int>>h(n,vector<int>(3)),v(n,vector<int>(3));

  for(int i=0;i<n;i++)
	cin>>h[i][0]>>h[i][1]>>h[i][2];
   // memset(v,0,sizeof(v));
    v[n-1][0]=h[n-1][0];
    v[n-1][1]=h[n-1][1];
    v[n-1][2]=h[n-1][2];
 	for(int i=0;i<n-1;i++)
 	v[i][0]=0,v[i][1]=0,v[i][2]=0;
  solve(h,v);
  cout<<max(max(v[0][0],v[0][1]),v[0][2])<<endl;
//   for(auto a:v)
//   for(auto b:a)
//   cout<<b<<' ';
  
}

Measured memory_bytes: 11136
import fractions
list = list(map(int,input().split()))
x = (list[2] * list[3]) // fractions.gcd(list[2], list[3])
p = (list[0]-1)//list[2]
q = list[1]//list[2]
r = (list[0]-1)//list[3]
s = list[1]//list[3]
t = (list[0]-1)//x
u = list[1]//x
l = list[1]-list[0]+1
print(l+p-q+r-s-t+u)


Measured memory_bytes: 5048