akhauriyash/Code-Regression huggingface dataset:
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
#include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define sz(a) (int)(a.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, t;
    cin>>n>>t;
    int arr[n];
    arrinput;
    map<int, int> my;
    int mx = -1, ans = -1;
    forr(i,n) {
        mx = max(mx, arr[i]);
        ans = max(ans, mx - arr[i]);
        my[mx - arr[i]]++;
    }
    cout<<my[ans];

    return 0;
}   

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
main()
{
long long int n,m,i,j,k,c,count,temp;
cin>>n>>m;
long long int a[n][2],b[m][2];
for(i=0;i<n;i++)
{
cin>>a[i][0]>>a[i][1];
}
for(i=0;i<m;i++)
{
cin>>b[i][0]>>b[i][1];
}
for(i=0;i<n;i++)
{
count=pow(10,15);
for(j=0;j<m;j++)
{
temp=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]);
if(temp<count)
{
count=temp;
c=j;
}

}


cout<<c+1<<endl;
}






}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#define MN 50005
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<int,ll> f;
int n,k,num[10000005],a[MN],sum[MN],tot,tt;ll ans;
ll pow(int x,int y){
	ll tmp=1;
	while(y){
		if(y&1)tmp=tmp*x%mod;
		y>>=1,x=1ll*x*x%mod;
	}return tmp;
}
void add(ll &x,int y){(x+=y)>=mod?x-=mod:0;}
void dec(ll &x,int y){(x-=y)<0?x+=mod:0;}
void dfs(int u,int now){
	if(u==tot+1){num[++tt]=now;return ;}
	for(int i=0;i<=sum[u];i++)dfs(u+1,now*pow(a[u],i));
}
int main(){
	bool pd=0;scanf("%d%d",&n,&k);int tmp=(int)sqrt(n);f[1]=k;
	int now=n;
	for(int i=2;i<=tmp;i++)if(now%i==0){
		a[++tot]=i;
		while(now%i==0)now/=i,sum[tot]++;
	}if(now!=1)a[++tot]=now,sum[tot]=1;dfs(1,1);
	sort(num+1,num+tt+1);
//	for(int i=1;i<=tt;i++)printf("%d ",num[i]);puts("");
	for(int i=2;i<=tt;i++){
		f[num[i]]=pow(k,(num[i]+1)/2);
		for(int j=2;j<sqrt(num[i]);j++)if(num[i]%j==0){
		//	if(f[j]==0)puts("bad!"),printf("%d %d\n",num[i],j);
		//	if(f[num/j]==0)puts("bad!"),printf("%d %d\n",num[i],num[i]/j);
			dec(f[num[i]],f[j]),dec(f[num[i]],f[num[i]/j]);
		}dec(f[num[i]],f[1]);
		if((int)sqrt(num[i])*(int)sqrt(num[i])==num[i])dec(f[num[i]],f[(int)sqrt(num[i])]);
	}//printf("%lld %lld %lld %lld\n",f[1],f[2],f[3],f[6]);
	ans=k;for(int i=2;i<=tt;i++)if(num[i]%2==1)add(ans,f[num[i]]*num[i]%mod);else add(ans,f[num[i]]*num[i]/2%mod);
	printf("%lld\n",ans);
}

Measured memory_bytes: 384
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
sorted_ab = sorted(ab, key=lambda AB: AB[1])
ans = 'Yes'
t = 0
for AB in sorted_ab:
  t += AB[0]
  if t > AB[1]:
    ans = 'No'
    break

print(ans)

Measured memory_bytes: 55264
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 2e5;
int pre[MAXN + 5],last[MAXN + 5],other[MAXN + 5],vis[MAXN + 5];
int all = -1,n,m,cnt,a,b,flag = 0;
void Build(int x,int y){
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}
void dfs(int x,int cnt){
	int dt,dr = 0;
	dt = last[x];
	if(x == n && cnt <= 2) flag = 1;//return;
	while(dt != -1){
			dr = other[dt];
				if(vis[dr] == 0){
					vis[dr] = 1;
					dfs(dr,cnt + 1);
					//cnt++;
			}
			dt = pre[dt];
		}
	//if(cnt <= 2) flag = 1;
//	else flag = 2;
}
int main()
{
	cnt = 0;
	memset(vis,0,sizeof(vis));
	memset(last,-1,sizeof(last));
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= m; i++){
		scanf("%d%d",&a,&b);
		Build(a,b);
	}
	dfs(1,0);
	if(flag == 1) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}


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

using namespace std;

int main() {
  int n, a[100], cnt = 0, minv = 100, p;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (minv > a[j]) {
        minv = a[j];
        p = j;
      }
    }
    if (a[i] != minv) {
      a[p] = a[i];
      a[i] = minv;
      cnt++;
    }
    minv = 100;
  }
  for (int i = 0; i < n; i++) {
    i == n - 1 ? printf("%d\n", a[i]) : printf("%d ", a[i]);
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 3228
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        
        for(int i=0; i<k; i++){
            if(i%2==0){
                if(a%2==1){
                    a=a-1;
                }
                a=a/2;
                b=a+b;
            }else{
                if(b%2==1){
                    b=b-1;
                }
                b=b/2;
                a=a+b;
            }
        }
		
		System.out.print(a+" "+b);
	}
}


Measured memory_bytes: 38712
#include <iostream>
#include <vector>
#include <climits>
#include <utility>
using namespace std;

int main()
{
    int N,T;
    int mincost=INT_MAX, indexCost=-1;
    cin >> N >> T;
    vector<pair<int,int>> v;
    for(int i=0;i<N;i++){
        int c,t;
        cin >> c >> t;
        v.push_back(pair<int,int>(c,t));
        if(t<=T && c<mincost) {
            mincost=c;
            indexCost=i;
        }
    }

    if(mincost==INT_MAX) cout << "TLE" << endl;
    else cout << mincost << endl;

    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(0,A+1):
    for b in range(0,B+1):
        for c in range(0,C+1):
            if (a*500)+(b*100)+(c*50)==X:
                ans+=1
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int t,n,datas[100],dataf[100],i,j,m,s;
	scanf("%d",&t);
	while(t !=0){
		j=0;
		scanf("%d",&n);
			for(i=0;i<n;i++){
				scanf("%d %d",&datas[i],&dataf[i]);
				j+=dataf[i]-datas[i];
			}
			m=t-j;		
				if(m<0){
					printf("OK\n");
				}
				else if(m>0){
					printf("%d\n",m);
				}
				else{
					printf("OK\n");
				}
			
		scanf("%d",&t);
	}
		return 0;
}

Measured memory_bytes: 1040
#include"bits/stdc++.h"
using namespace std;
int main(){
	int num;
	string ch;
	long long ans1=0,ans2=0;
	cin>>ch>>num;
	if (ch == string(ch.length(), ch[0])) {
    	cout <<  ch.length()* num / 2 << '\n';
  	}
  	else {
  		for(int i=0;i<ch.length();i++){
			if(ch[i]==ch[i+1]){
				ans1++;
				i++;
			}
		}
		for(int i=0;i+1<ch.length()*2;i++){
			if(ch[i%ch.length()]==ch[(i+1)%ch.length()]){
				ans2++;
				i++;
			}
		}
		long long ans=0;
		cout<<ans1+(ans2-ans1)*(num-1)<<endl;
	}
	
}//&&i+1<ch.length()*2

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(x,y) x=min(x,y)
using namespace std;
using P = pair<int,int>;

const int INF = 1001001001;

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> matrix(h,vector<char>(w));
  rep(i,h) rep(j,w) cin >> matrix.at(i).at(j);
    
  vector<vector<char>> ans(h,vector<char>(w));
  vector<vector<char>> ans1(h,vector<char>(w));
  
  int ans_h = 0;
  int ans_w = 0;
  rep(i,h) {
    bool judge = true;
    rep(j,w) if(matrix.at(i).at(j) == '#') judge = false;
    if(!judge) {
      rep(j,w) ans.at(ans_h).at(j) = matrix.at(i).at(j);
      ans_h++;
    }
  }
   rep(j,w) {
    bool judge = true;
    rep(i,h) if(ans.at(i).at(j) == '#') judge = false;
    if(!judge) {
      rep(i,h) ans1.at(i).at(ans_w) = ans.at(i).at(j);
      ans_w++;
    }
  }
  rep(i,ans_h) {
    rep(j,ans_w) cout << ans1.at(i).at(j);
    cout << endl;
  }
      
}


Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  2 11:00:10 2020
//
package main

import "fmt"

var N int
var P []int

func main() {
	fmt.Scan(&N)
	P = make([]int, N)
	for i := range P {
		fmt.Scan(&P[i])
	}

	n := N + 1
	ans := 0
	for _, p := range P {
		if n > p {
			ans++
			n = p
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Main {

    public static void main(String[] args) throws IOException {

        int n = 0;      //??\??????????????????2???????????´??°?????°???
        int min = 0;    //????°????
        int max = 0;    //?????§???
        double sum = 0; //????¨????

        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String input = br.readLine();

//          ??\??????1?????????2???????????´??°?????°??????????????????
            n = Integer.parseInt(input);

            input = br.readLine();
            String[] strArray =input.split(" ");

//          1???????????´??°???????°??????¨?????§????????£??\
            min = Integer.parseInt(strArray[0]);    //????°????
            max = min;   //?????§???
            sum += (double)min;  //????¨????

//          2????????\????????´??°
            for(int i = 1; i < n ; i++){

                int x = Integer.parseInt(strArray[i]);

//              1???????????´??°??¨????????????x????°?????????´??????min?????£??\
                if(x < min){
                    min = x;
                }
//              1???????????´??°??¨????????????x?????§????????´??????max?????£??\
                if(max < x){
                    max = x;
                }
//              ????¨???????x?????????
                sum += (double)x;
            }
            DecimalFormat DF = new DecimalFormat("0");

            System.out.println(min + " " + max + " " + DF.format(sum));

        }catch(IOException e) {

            //??????????????????
            System.out.println(e);

        }catch(NumberFormatException e) {

            //??°?????\????????\????????§??????
            System.out.println("??°?????§??\??????????????????");
        }
    }
}

Measured memory_bytes: 29884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
   
    int N;cin>>N;
    vector<int> S(N),T;
    int m=0,m2=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
        if(m<=S[i]){
            m2=m;
            m=S[i];
        }else if(m2<=S[i]){
            m2=S[i];
        }
    }
    
    for(int i=0;i<N;i++){
        if(S[i]==m) T.push_back(i);
    }
    
    if(T.size()>=2){
        for(int i=0;i<N;i++){
            cout<<m<<endl;
        }
    }else{
        for(int i=0;i<N;i++){
            if(S[i]==m) cout<<m2<<endl;
            else cout<<m<<endl;
        }
    }
}


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

ll dp[110][10];
ll fib[1010];

int main(void){
	int H,W,K;
	cin>>H>>W>>K;
	dp[0][1]=1;
	fib[0]=1;
	fib[1]=1;
	for(int i=2;i<1010;i++){
		fib[i] = (fib[i-1]+fib[i-2])%N;
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(j==1){
				dp[i][j] = (dp[i-1][j]*fib[W-1])%N;
				if(W-j>=0){
					ll t = (dp[i-1][j+1]*fib[W-j-1])%N;
					dp[i][j] = (dp[i][j]+t)%N;
				}
			}
			else{
				if(j==W){
					dp[i][j] = (dp[i-1][j]*fib[j-1])%N;
					if(j-2>=0){
						ll t = (dp[i-1][j-1]*fib[j-2])%N;
						dp[i][j] = (dp[i][j]+t)%N;
					}
				}
				else{
					ll t1 = (fib[j-2]*fib[W-j])%N;
					ll t2 = (fib[j-1]*fib[W-j-1])%N;
					ll t3 = (fib[j-1]*fib[W-j])%N;
					t1 = (dp[i-1][j-1]*t1)%N;
					t2 = (dp[i-1][j+1]*t2)%N;
					t3 = (dp[i-1][j]*t3)%N;
					dp[i][j] = ((t1+t2)%N+t3)%N;
				}
			}
		}
	}
	/*for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[H][K]<<endl;
	return 0;

}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
signed main(){
  	int ans=0,sma,n,p;
  	cin>>n;
  	for(int i=0;i<n;i++){
      cin>>p;
      if(i == 0)
        sma=p;
      sma = min(sma,p);
      if(sma >= p)
        ans++;
    }
  	cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    char a;
    cin >> a;

    char ans = 'A';
    if(!isupper(a)){
        ans = 'a';
    }

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


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
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
}

int32_t main(){
zz();
int n;cin>>n;
int s=0;
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
		for(int k=1;k<=n;k++){
			int x=__gcd(i,j);
			x=__gcd(x,k);
			// cout<<x<<" ";
			s+=x;
		}
	}
}
cout<<s<<endl;

}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
  int i, j, k, H, W;

  for (i=0; ; i++){
    scanf("%d %d", &H, &W);

    if ( !H && !W)
      break;

    for (j = 0; j < H; j++){
      for ( k = 0; k < W; k++)
	printf("#");
      printf("\n");
    }
    printf ("\n");
  }

  return 0;
}

      

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int B = 450;

// 現在の状態
int s[B][B] = {};

int F[B];
int T[B];
bool bad[B]={};

void push(int bid){
    if(bad[bid]){
        rep(i,B) s[bid][i] = -1;
        return;
    }
    if(F[bid] == -1) return;

    rep(i,B){
        if(s[bid][i] == F[bid]) s[bid][i] = T[bid];
        else s[bid][i] = -1;
    }

    F[bid] = -1;
    T[bid] = -1;
}

void D(int l, int r, int x){
    int lid = l/B, rid = r/B;
    if(lid == rid){
        push(lid);
        for(int i=l; i<=r; ++i){
            if(s[i/B][i%B] == x-1) s[i/B][i%B] = x;
            else s[i/B][i%B] = -1;
        }
    }
    else{
        push(lid);
        push(rid);

        for(int i=l; i<B*(lid+1); ++i){
            if(s[i/B][i%B] == x-1) s[i/B][i%B] = x;
            else s[i/B][i%B] = -1;
        }

        for(int bid=lid+1; bid<rid; ++bid){
            if(F[bid] == -1){
                F[bid] = x-1;
                T[bid] = x;
            }
            else{
                if(T[bid] == x-1) T[bid] = x;
                else bad[bid] = true;
            }
        }

        for(int i=B*rid; i<=r; ++i){
            if(s[i/B][i%B] == x-1) s[i/B][i%B] = x;
            else s[i/B][i%B] = -1;
        }
    }
}

int main(){
    int n,k,t;
    scanf(" %d %d %d", &n, &k, &t);

    fill(F,F+B,-1);
    fill(T,T+B,-1);
    rep(i,t){
        int l,r,x;
        scanf(" %d %d %d", &l, &r, &x);
        --l;
        --r;
        D(l,r,x);
    }

    rep(i,B) push(i);

    int ans = 0;
    rep(i,n) ans += (s[i/B][i%B] == k);
    printf("%d\n", ans);
    return 0;
}



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

#define mcqn ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define test int t;cin>>t;while(t--)
#define ll   long long
#define lli long long int
#define PI   3.1415926
#define fori(i,a,b) for(long long i=a;i<b;i++)
#define M ((int)1e9+7)
#define deb(x) cout << #x << "=" << x << endl;

long long expo(long long x,long long y){ long long res=1; while(y) {if(y%2) res=(res*x%M)%M; x=(x*x)%M; y/=2; } return res;}
long long add (long long a, long long b) {return (a%M + b%M + M)%M;}
long long sub (long long a, long long b) {return (a%M - b%M + M)%M;}
long long mul (long long a, long long b) {return ((a%M)*(b%M) + M)%M;}

using namespace std;

int main(){

    string s;
    cin>>s;

    int count=0;
    int max=0;

    fori(i,0,3){
        if(s[i]=='S')
            count=0;
        else{
            count++;
        }
        if(max<=count)
            max=count;
    }
    cout<<max<<endl;    
}

Measured memory_bytes: 3624
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(0, max(N, M)-2))
elif N == 2 or M == 2:
    print(0)
else:
    print((N-2)*(M-2))


Measured memory_bytes: 3316
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int X,A;
int ans=0;
signed main(){
    scanf("%lld %lld",&X,&A);
    if(X<A)ans=0;
    else ans=10;
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<"";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
// #define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

#define upb upper_bound
#define lwb lower_bound


const int N = 1e5 + 5; 

vector<pair <ll, ll > > gr[N];
ll d[N];
bool vis[N];

void dfs(ll u, ll p, ll dis){
	d[u] = dis;
	for (auto x : gr[u]){
		ll v = x.ff, w = x.ss;
		if (v == p) continue;
		dfs(v, u, dis+w);
	}
}

int main(int argc, char const *argv[])
{
	crap;
	rep(i, N){
		d[i] = 1e16 + 9;
	}

	int n;
	cin >> n;
	ll u, v, w;
	rep(i, n-1){
		cin >> u >> v >> w;
		gr[u].pb(mp(v, w));
		gr[v].pb(mp(u, w));
	}
	dfs(1, 0, 0);
	F(i, 1, n){
		cout << d[i] % 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 12160
def multiples_of(num)
  if num % 4 == 0
    4
  elsif num % 4 != 0 && num % 2 == 0
    2
  else
    1
  end
end

n = gets.to_i
nums = gets.split.map(&:to_i)
memo = Hash.new(0)
nums.each do |num|
  memo[multiples_of(num)] += 1
end
ans = [4]
n.times do |i|
  case ans[i]
  when 1
    if memo[4] > 0
      memo[4] -= 1
      ans << 4
    else
      puts "No"
      exit
    end
  when 2
    if memo[2] > 0
      memo[2] -= 1
      ans << 2
    elsif memo[4] > 0
      memo[4] -= 1
      ans << 4
    else
      puts "No"
      exit
    end
  when 4
    if memo[1] > 0
      memo[1] -= 1
      ans << 1
    elsif memo[2] > 0
      memo[2] -= 1
      ans << 2
    elsif memo[4] > 0
      memo[4] -= 1
      ans << 4
    else
      puts "No"
      exit
    end
  end
end
puts "Yes"


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

//ｘ番目の要素を求める関数
void Lucas_Number(int x,vector<int64_t> &L){
  if(L[x-1] == 0){
    Lucas_Number(x-1,L);//ｘ－１番目の要素を求める
  }
  if(L[x-2] == 0){
    Lucas_Number(x-2,L);//ｘ－２番目の要素を求める
  }
  L[x] = L[x-1] + L[x-2];
}

int main()
{
  int N;
  scanf("%d",&N);
  vector<int64_t> L(N+1,0);
  L[0] = 2;
  L[1] = 1;
  if(N >= 2){
    Lucas_Number(N,L);
  }
  printf("%ld\n",L[N]);
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


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> PII;
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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#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)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int N = 200005, mo = 1000000007;
long long fac[N], inv[N];
 


int main() {
	int H, W, K; cin >> H >> W >> K;
	vector<vector<int>> dp(H + 1, vector<int>(W, 0));
	dp[0][0] = 1;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {

			//横線のパターンを全部発生させる。
			//横線の数は縦線の数-1
			for (int k = 0; k < (1 << (W - 1)); k++) {
				bool ok = true;

				//横線が2個つながっていると無効なので
				//そういう箇所がある場合は使わない
				for (int l = 0; l < W - 2; l++) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}

				if (ok) {
					//左への移動
					//jからj-1への遷移

					//範囲内かつ、辺がはられている場合のみ。
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mo;
					}//右への移動
					else if (j <= W - 2 && ((k >> j) & 1)) {
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mo;
					}
					//真下は、範囲外も辺の有無も関係ない
					else {
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mo;
					}
				}
					
			}
		}
	}

	cout << dp[H][K - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
typedef pair<int, int> p;

int k;
vector<string> ban;

void move(int i, int j, int time, map<vector<p>, int> &before, map<vector<p>, int> &after, bool turn) {
    for (auto back:before) {
        vector<p> now;
        bool shouldAdd = '0' <= ban[i][j] && ban[i][j] <= '9';
        for (auto place:back.first) {
            if (turn || place.first + place.second >= i + j - (k - time))now.push_back(place);
            if (place.first == i && place.second == j)shouldAdd = false;
        }
        if (shouldAdd)now.push_back(p(i, j));

        int cost = back.second + (shouldAdd ? ban[i][j] - '0' : 0);
        if (after.find(now) == after.end() || after[now] < cost) after[now] = cost;
    }
}

int main() {
    int h, w;
    cin >> h >> w >> k;
    ban = vector<string>(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    vector<vector<map<vector<p>, int>>> dp(h, vector<map<vector<p>, int>>(w, map<vector<p>, int>()));
    dp[0][0][{}] = 0;

    for (int time = 0; time <= k; time++) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (ban[i][j] == '#')continue;

                if (i - 1 >= 0) { //down
                    move(i, j, time, dp[i - 1][j], dp[i][j], false);
                }
                if (j - 1 >= 0) { //right
                    move(i, j, time, dp[i][j - 1], dp[i][j], false);
                }
            }
        }

        if (time == k) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (ban[i][j] == '#')continue;

                if (i + 1 < h) { // up
                    move(i, j, time, dp[i + 1][j], dp[i][j], true);
                }
                if (j + 1 < w) { // left
                    move(i, j, time, dp[i][j + 1], dp[i][j], true);
                }
            }
        }
    }

    int ret = -1145141919;
    for (auto x:dp[h - 1][w - 1]) ret = max(ret, x.second);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 147608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String x=sc.next();
		String y=sc.next();
		int n=sc.nextInt();
		int h=sc.nextInt();
		String s=sc.next();
		if(s.equals(y))
			h--;
		else
			n--;
		System.out.println(n+" "+h);




	}

}


Measured memory_bytes: 21716
import sys
sys.setrecursionlimit(1000000)
 
n,x = map(int,input().split())
l = list(map(int,input().split()))

ans = 1
now = 0

for i in range(n):
    now += l[i]
    if now <= x:
        ans += 1
        
print(ans)
    

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int gcd(int $a,int $b) {
    if ($b == 0)
        return $a;

    return gcd($b, $a % $b);
}
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j){
      for(int k=1;k<=n;++k){        
        ans+=gcd(gcd(i,j),k);
      }
    }
  }
  cout<<ans;
}

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

int n, in[26], out[26], G[26][26];
bool visited[26];

bool check(){
  rep(i, 26) if (in[i] != out[i]) return false;
  return true;
}

void dfs(int u){
  visited[u] = true;
  rep(v, 26) if (!visited[v] && G[u][v]) dfs(v);
}

int getNComponent(){
  int nc = 0;
  rep(i, 26){
    if (in[i] == 0 && out[i] == 0) continue;
    if (!visited[i]){nc++; dfs(i);}
  }
  return nc;
}

int main(){
  while(cin>>n && n){
    rep(i, 26){
      in[i] = out[i] = 0;
      visited[i] = false;
      rep(j, 26) G[i][j] = 0;
    }

    string str;
    rep(i, n){
      cin>>str;
      int first = str[0]-'a';
      int last = str[str.size()-1]-'a';
      in[first]++;
      out[last]++;
      G[first][last] = 1;
      G[last][first] = 1;
    }
    cout<<((check() && getNComponent()==1)?"OK":"NG")<<endl;
  }
  return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);

    for(int i{0}; i<N; ++i){
        cin >> a[i];
    }
    int next{1};
    for(int i{1}; i<=N; ++i){
        next = a[next-1];
        if(next == 2){
            cout << i << endl;
            return(0);
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int N;
string S;
int main() {
	cin >> N >> S;
	int m=0;
	int c=0;
	for(int i=0;i<N;i++){
		if(S[i]=='('){
			c++;
		}
		else{
			c--;
		}
		m=min(m,c);
	}
	for(int i=0;i<-m;i++){
		cout << '(';
	}
	cout << S;
	c-=m;
	for(int i=0;i<c;i++){
		cout << ')';
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int tmp[10];

int main(){

	int a_0,L;
	while(1){
		cin >> a_0 >> L;
		if(a_0 + L == 0 ) break;
		int a = a_0;
		map<int,int> mp;
		mp[a_0] = -1;
		int ans = 0;
		while(1){
			ans++;
			for(int i = 0;i < L;i++){
				int div = 1;
				for(int j = 0;j < i;j++){
					div *= 10;
				}
				tmp[i] = (a/div)%10;
			}
			sort(tmp,tmp + L);
			int aa = 0,b = 0;
			int pow = 1;
			for(int i = 0;i < L;i++){
				aa += tmp[i]*pow;
				b += tmp[L-i-1]*pow;
				pow *= 10;
			}
			int a_next = aa-b;
			a = a_next;
	//		cout << "a_next:" << a_next << endl;
			if(mp[a_next] > 0){
				cout << mp[a_next] << " " << a_next << " " << ans - mp[a_next] << endl;
				break;
			}else if(mp[a_next] == -1){
				cout << 0 << " " << a_next << " " << ans << endl;
				break;
			}else{
				mp[a_next] = ans;
			}

		}
	}
}


Measured memory_bytes: 3160
c = int(input())
j =  [0]*4
for i in range(c):
  a = input()
  if a == "AC":
    j[0] += 1
  elif a == "WA":
    j[1] += 1
  elif a == "TLE":
    j[2] += 1
  else:
    j[3] += 1
    
print("AC x "+ str(j[0]))
print("WA x "+ str(j[1]))
print("TLE x "+ str(j[2]))
print("RE x "+ str(j[3]))

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15);

signed main(){
    int n; cin >> n;
    string s; cin >> s;
    s.erase(unique(all(s)),s.end());
    cout<<s.size()<<endl;
    /*
    int res=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]) res++;
    }
    cout<<res<<endl;
    */
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int N, X;
    cin >> N >> X;
    int L[110];
    rep(i, 0, N) { cin >> L[i]; }
    int d = 0;
    int count = 1;
    rep(i, 0, N) {
        if(d + L[i] <= X) {
            count++;
        }
        d = d + L[i];
    }
    cout << count << endl;
}

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

int main() {
  LL X;
  cin >> X;
  LL deposit = 100;
  long double interest;
  int i = 0;
  while (deposit < X) {
    deposit = deposit + (LL)(deposit/100 + 0.001);
    i++;
  }
  cout << i << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  float N,T,A,H;
  cin>>N>>T>>A;
  float Mini = 90000000000;
  int ans;
  for(int i=0;i<N;i++){
    cin>>H;
    float tmp = T-(H*0.006);
    float abtmp = abs(A-tmp);
    Mini = min(Mini,abtmp);
    if(Mini==abtmp){
      ans = i;
    }
  }
  cout<<ans+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, c;
    cin >> n >> c;
    vector<int> l(n);
    for (int i = 0; i < n; ++i)
        cin >> l[i];
    sort(l.begin(), l.end());
    
    vector<int> perm(n - 1);
    iota(perm.begin(), perm.end(), 0);
    LL total = 0;
    LL dp[301][32][301];
    do {
        memset(dp, 0, sizeof(dp));
        dp[0][0][l.back() * n] = 1;
        for (int i = 0; i < c * n; ++i) {
            for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
                for (int j = i; j <= c * n; ++j) {
                    dp[i + 1][mask][j] += dp[i][mask][j];
                    if (i % n != 0 && (~mask >> (i % n - 1) & 1))
                        dp[i + 1][mask | 1 << (i % n - 1)][min(c * n, max(j, i + l[perm[i % n - 1]] * n))] += dp[i][mask][j];
                }
            }
        }
        total += dp[c * n][(1 << (n - 1)) - 1][c * n];
    } while (next_permutation(perm.begin(), perm.end()));
    
    long double ans = total;
    for (int i = 1; i < n; ++i)
        ans /= i * c;
    cout << setprecision(20) << fixed << ans << endl;
    return 0;
}

Measured memory_bytes: 23040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n;
  cin >> n;
  set<string> s;
  rep(i,n){
    string x;
    cin >> x;
    s.insert(x);
  }
  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 19108
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,z,x,zx;
long long f(long long q, long long w){
    if(q<=0) return 0; else return q/w;
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b>>c>>d;
    z=f(b,c)-f(a-1,c);
    x=f(b,d)-f(a-1,d);
    zx=f(b,c*d/__gcd(c,d))-f(a-1,c*d/__gcd(c,d));
    cout<<b-a+1-(z+x-zx);
    return 0;
}


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

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

#define MAX_N 105
int n; int arr[MAX_N];

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;
    list(i,n) cin >> arr[i];

    int total = 0;
    list(i,n) total += arr[i];

    //calculate prefixes
    int prev = arr[0];
    int ans = total - prev - prev;
    rep(i,1,n){
        prev += arr[i];
        ans = min(ans,abs(total-prev-prev));
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long a[10000],n,sum=0,max,min,i;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&a[i]);

  for(i=0;i<n;i++)sum+=a[i];
  max=a[0];
  for(i=1;i<n;i++)if(max<a[i])max=a[i];
  min=a[0];
  for(i=1;i<n;i++)if(min>a[i])min=a[i];

  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
}

Measured memory_bytes: 680
import random
import time
import copy
start=time.time()
d=int(input())
c=list(map(int, input().split()))
s=[]
solution=[]
last=[0]*26
sco=0
for i in range(d):
  s.append(list(map(int, input().split())))
for day in range(1,d+1):
  man=[]
  for i in range(26):
    man.append(s[day-1][i]+last[i]*c[i])
  con=man.index(max(man))
  sco+=s[day-1][con]
  last[con]=day
  for (i,j) in zip(last,c):
    sco-=i*j
  solution.append(con)
while time.time()-start<1.9:
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(10)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,c):
      sc-=i*j
  if sc>sco:
    solution=sol
    sco=sc
for i in solution:
  print(i+1)

Measured memory_bytes: 10088
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if (!(a&1)||!(b&1)||!(c&1)) puts("0");
		else printf("%lld\n",min(a*b,min(b*c,c*a)));
	return 0;
}

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

int main() {
    string buf, yama;
    istringstream strm;
    int player[11], i, N;

    while (cin) {
        getline(cin, buf);
        strm.str(buf);
        strm.seekg(0);
        strm >> N;
        if (N == 0) break;

        for (i = 0; i <= N; i++) {
            player[i] = 0;
        }
        getline(cin, yama);
        for (i = 0; i < 100; i++) {
            int *p = &player[i % N];
            switch (yama[i]) {
                case 'M':
                    *p += 1;
                    break;
                case 'S':
                    player[N] += *p + 1;
                    *p = 0;
                    break;
                case 'L':
                    *p += player[N] + 1;
                    player[N] = 0;
                    break;
                default: break;
            }
        }
        sort(player, player+N);
        cout << player[0];
        for (i = 1; i <= N; i++) {
            cout << " " << player[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);
using ll = long long;
using namespace std;
typedef pair<int,int> ii;
const int mod= 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    double a;
    int n;
    cin >> n;
    double sum=0;
    for(int i=0; i<n; ++i)
    {
        cin >> a;
        sum+=(1/a);
    }
    cout << setprecision(10) << fixed << 1/sum;

    return 0;
}



Measured memory_bytes: 256
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	int a,b,c,k,j=0;
	cin>>a>>b>>c;
	cin>>k;
	
	while(true){	
		if(b>a)
			break;
		b=b*2;
		j++;
	}
	while(true){
		if(c>b)
			break;
		c=c*2;
		j++;
	}
	if(j<=k) cout<<"Yes";
	else cout<<"No";
}

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


Measured memory_bytes: 3620
n,m = map(int,input().split())
query = [list(map(int,input().split())) for _ in range(m)]
if n == 1:
    for i in range(10):
        k = str(i)
        flag = True
        for s,c in query:
            if int(k) != c:
                flag = False
        if flag:
            print(i)
            exit()
else:
    for i in range(10**(n-1),10**n):
        k = str(i)
        flag = True
        for s,c in query:
            if k[s-1] != str(c):
                flag = False
        if flag and len(k) == n:
            print(i)
            exit()
print(-1)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;

std::list<int> board;

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

    while(true){
        int N;
        std::cin >> N;

        if(N == 0){
            break;
        }

        board.clear();

        for(int i=0;i<N;++i){
            int D, P, Q;
            std::cin >> D >> P >> Q;

            Q -= 1;

            if(D == 1){
                if(P == 5){
                    continue;
                }

                int block = ((1 << P) - 1) << Q;

                auto it = board.end();
                while(it != board.begin() &&
                      (*std::prev(it) & block) == 0){
                    std::advance(it, -1);
                }

                if(it == board.end()){
                    board.push_back(block);
                }else{
                    *it |= block;

                    if(*it == 31){
                        board.erase(it);
                    }
                }
            }else{
                auto it = board.end();
                while(it != board.begin() &&
                      (*std::prev(it) >> Q & 1) == 0){
                    std::advance(it, -1);
                }

                for(int i=0;i<P;++i){
                    if(it == board.end()){
                        board.push_back(1 << Q);
                    }else{
                        *it |= 1 << Q;
                        if(*it == 31){
                            it = board.erase(it);
                        }else{
                            std::advance(it, 1);
                        }
                    }
                }
            }
        }

        int cnt = 0;
        
        for(int l : board){
            cnt += __builtin_popcount(l);
        }

        std::cout << cnt << std::endl;
    }
}



Measured memory_bytes: 3168
n = int(input())
p = list(map(int,input().split()))
q = []
for i in range(n):
    if p[i] == i+1:
        continue
    else:
        q.append(i)
if len(q) == 2 or len(q) == 0:
    print('YES')
else:
    print('NO')

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


void solve(){
    int a,b;
    cin >> a >> b;
    int ans;
    if(a>=13) ans = b;
    else if(a>=6) ans = b/2;
    else ans = 0;
    cout << ans << endl;
}

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

Measured memory_bytes: 256