akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll a, b, t;
int main() {
	cin >> a >> b >> t;
	cout << t / a * b << endl;
}

Measured memory_bytes: 256
L,R = map(int,input().split())
if(R-L<2019):    
    L = L%2019 
    R = R%2019
    ans = float('inf')
    for i in range(min(L,R),max(L,R)+1):
        for j in range(i+1,max(L,R)+1):
            ans=min(ans,(i*j)%2019)
    print(ans)
else:
    print(0)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int h,w,k,black=0;
char arr[6][6];
char brr[6][6];
void copy_array()
{
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            brr[i][j]=arr[i][j];
        }
    }
}
bool check_array(int i,int j)
{
    for(int x=0;x<h;x++)
    {
        if(i&(1<<x))
        {
            for(int j=0;j<w;j++)
            {
                brr[x][j]='$';
            }
        }
    }
    for(int x=0;x<w;x++)
    {
        if(j&(1<<x))
        {
        for(int j=0;j<h;j++)
        {
            brr[j][x]='$';
        }
        }
    }
    int testblack=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(brr[i][j]=='#')
            {
                testblack++;
            }
        }
    }
    if(testblack==k)
    return true;
    else
    {
        return false;
    }
    

}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>arr[i][j];
            if(arr[i][j]=='#')
            {
                black++;
            }
        }
    }
    int total=0;
    for(int i=0;i<(1<<h);i++)
    {
        for(int j=0;j<(1<<w);j++)
        {
            copy_array();
            bool flag = check_array(i,j);
            if(flag)
            total++;

        }
    }
    cout<<total<<"\n";

}

Measured memory_bytes: 3588
N = int(input())
p = list(map(int, input().split()))
yn = False
for i in range(N):
  for j in range(N-i-1):
    hika = list(p)
    if hika == sorted(p):
      yn = True
      break
    hika[j+i+1] = p[i]
    hika[i] = p[j+i+1]
    if hika == sorted(p):
      yn = True
      break
if yn == True:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 40048
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  vll b(0),a(n);
  rep(i,0,n){
    cin>>a[i];
  }
  reverse(a.begin(),a.end());
  b.push_back(a[0]);
  rep(i,1,n){
    int dist = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
    if(dist >= b.size()){
      b.push_back(a[i]);
    }
    else{
      b[dist] = a[i];
    }
  }
  cout<<b.size()<<endl;
}




Measured memory_bytes: 5072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

vector<P> g[100005];
vector<ll> ans(100005);
vector<bool> vi(100005);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	rep(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a].emplace_back(b, c);
		g[b].emplace_back(a, c);
	}
	int q, k;
	cin >> q >> k;
	k--;
	queue<int> que;
	que.push(k);
	ans[k] = 0;
	vi[k] = true;
	while (que.size()) {
		int a = que.front(); que.pop();
		for (auto& c : g[a]) {
			if (vi[c.first]) continue;
			vi[c.first] = true;
			ans[c.first] = ans[a] + (ll)c.second;
			que.push(c.first);
		}
	}
	rep(ri, q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		ll j_ans = ans[x] - ans[k];
		j_ans += ans[y] - ans[k];
		cout << j_ans << endl;
	}
	return 0;
}


Measured memory_bytes: 8820
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c > 0){
        a-=d;
        c-=b;
    }
    if(c <=0) cout<<"Yes\n";
    else cout<<"No\n";
}


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

int pow(int n) {
  int p = 1;
  for (int i = 0; i < n; i++) {
    p *= 4;
  }
  return p;
}
int main() {
  int res = 1e9; 
  int N, A, B, C; cin >> N >> A >> B >> C;
  int l[N];
  for (int i = 0; i < N; i++) {cin >> l[i];}
  
  for (int b4 = 0; b4 < pow(N); b4++) {
    int L0 = 0; int L1 = 0; int L2 = 0;
    int c0 = 0; int c1 = 0; int c2 = 0;
    
    int b[N]; int x = b4;
    for (int i = 0; i < N; i++) {
      b[i] = x/pow(N-1-i);
      x %= pow(N-1-i);
    }
    for (int i = 0; i < N; i++) {
      if (b[i] == 0) {c0++; L0+=l[i];}
      if (b[i] == 1) {c1++; L1+=l[i];}
      if (b[i] == 2) {c2++; L2+=l[i];}
      if (b[i] == 3) {continue;}
    }
    if (c0 == 0 || c1 == 0 || c2 == 0) {continue;}
    else {
      res = min(res, (c0+c1+c2-3)*10 + abs(A-L0)+abs(B-L1)+abs(C-L2));
    }
  }
  cout << res << endl;
}

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

int main() {
  string n; cin >> n;
  
  int check = 0;
  for(int i = 0; i < n.size(); i++) {
    int temp = n.at(i) - '0';
    check += temp;
    check %= 9;    
  }
  
  string ans = "No";
  if(check == 0) ans = "Yes";
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3760
# -*- coding: utf-8 -*-

import sys

def isRec(a, b, c):
    if a*a + b*b == c*c:
        return True
    return False

def isLoz(a, b, c):
    if a == b:
        return True
    return False

count_Rec = 0
count_Loz = 0
for line in sys.stdin:
    a, b, c = map(int, line.split(','))
    if isRec(a, b, c):
        count_Rec += 1
    if isLoz(a, b, c):
        count_Loz += 1
print count_Rec
print count_Loz

Measured memory_bytes: 6444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A<=C&&C<=B){
      cout<<"Yes"<<endl;
  }
  else if(B<=C&&C<=A){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
}


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

int main() {
	int H,W;
	int a,b;
	while(true){
		cin>>H>>W;
		if (H==0 && W==0)break;
		for(a=0;a<H;a=a+1){
			for(b=0;b<W;b=b+1){
				cout<<"#";
			}
			cout<<endl;
		}cout<<endl;
	}
}

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


int main(){
    int a;
    int b;
    char buf[30];

    fgets(buf, sizeof(buf), stdin);

    a = atoi(buf);
    b = a+a*a+a*a*a;
     
    printf("%d\n", b);
}

Measured memory_bytes: 1664
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var N int
	var A int

	N = nextInt()
	for i := 0; i < N; i++ {
		A = nextInt()
		if A%2 == 0 {
			if A%3 != 0 && A%5 != 0 {
				fmt.Println("DENIED")
				os.Exit(0)
			}
		}
	}
	fmt.Println("APPROVED")
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

Measured memory_bytes: 640
from collections import deque

s = input()
q = int(input())

query_list = []
for _ in range(q):
    query_list += [input()]

deq = deque(s)
true_position = True

for i in range(q):
    if len(query_list[i])==1:
        true_position = not true_position
        # print(s)
    else:
        if query_list[i][2]=="1":
            if true_position:
                deq.appendleft(query_list[i][4])
            else:
                deq.append(query_list[i][4])
        elif query_list[i][2]=="2":
            if true_position:
                deq.append(query_list[i][4])
            else:
                deq.appendleft(query_list[i][4])

if true_position:
    ans = "".join(deq)
else:
    deq.reverse()
    ans = "".join(deq)

print(ans)

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> a(N);
    vector<ll> b(N);
    vector<ll> c(N);
    for(int i=0;i<N;i++){
        int x,y,z;
        cin >> x >> y >> z;
        a[i]=x;
        b[i]=y;
        c[i]=z;
    }
    int lucky[N][3];
    lucky[0][0]=a[0];
    lucky[0][1]=b[0];
    lucky[0][2]=c[0];
    for(int i=1;i<N;i++){
        lucky[i][0]=max(lucky[i-1][1],lucky[i-1][2])+a[i];
        lucky[i][1]=max(lucky[i-1][0],lucky[i-1][2])+b[i];
        lucky[i][2]=max(lucky[i-1][0],lucky[i-1][1])+c[i];
    }
    cout << max({lucky[N-1][0],lucky[N-1][1],lucky[N-1][2]});

}

/*



 */



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



int main() {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	for (volatile unsigned long long i = 0; i < 500000000; i++) {
		p++;
	}
	p -= 500000000;
	cout << p / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#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)
 
int main()
{
  ll n, ans=(ll)0;
  cin >> n;
  vector<ll> a(n+1), b(n);

  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  
  rep(i, n){
    ans += min(a[i], b[i]);
    b[i] = max(b[i]-a[i], (ll)0);
    ans += min(a[i+1], b[i]);
    a[i+1] = max(a[i+1]-b[i], (ll)0);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define loop(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
ll f(ll x)
{
	 return max((ll)0,x);
}
int main()
{
ll n,i,j,k;
cin>>n>>k;
ll a[n],dp[n+3];
loop(i,0,n)
cin>>a[i];
dp[0]=0;


loop(i,1,n)
{dp[i]=10000000000;
	loop(j,1,k+1)
dp[i]=min(dp[f(i-j)]+abs(a[i]-a[f(i-j)]),dp[i]);}
cout<<dp[n-1]<<endl;
return 0;}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> t(n);
    int time=0;
    rep(i,n) {
        cin>>t.at(i);
        time+=t.at(i);
    }
    int m;
    cin>>m;
    vector<int> p(m),x(m);
    rep(i,m) {
        cin>>p.at(i)>>x.at(i);
        p.at(i)--;
    }
    
    rep(i,m) cout<<time-t.at(p.at(i))+x.at(i)<<endl;
    
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n, l[200];
	scanf("%d", &n);
	for (int i = 0; i < 2 * n; i++) {
		scanf("%d", &l[i]);
	}
	qsort(l, 2 * n, sizeof(int), cmpint);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += l[2 * i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1736
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

map<int,int> aa;

main(){
	int n;
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		amp(aa,t);
	}
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		if(aa[t]==0){
			dump("NO");return 0;
		}else{
			aa[t]--;
		}
	}
	dump("YES");
}

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	string s; cin >> s;
	stack<int> st1;
	stack<pair<int, int>> st2;
	rep(i, 0, s.size()) {
		if (s[i] == '\\') {
			st1.emplace(i);
		}
		else if (s[i] == '/'&&st1.size()) {
			int a = st1.top(); st1.pop();
			int b = i - a + 1;
			int c = (b + b - 2) * 1 / 2;
			while (st2.size() && a < st2.top().first) {
				c += st2.top().second; st2.pop();
			}
			st2.emplace(a, c);
		}
		dump(st1, st2);
	}

	vector<int> L;
	while (st2.size()) {
		L.emplace_back(st2.top().second);
		st2.pop();
	}
	reverse(all(L));
	cout << accumulate(all(L), 0) << endl;
	cout << L.size();
	rep(i, 0, L.size()) {
		cout << " " << L[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3284
import java.util.*;
public class Main {
	public static void main(String[] args) {
		C();
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int ret  = 0;
		for(int i=0;i<s.length();i++) {
			ret += Character.getNumericValue(s.charAt(i));
		}
		System.out.println(ret);
	}
	
	//0...M   2^M > 最小の要素 の範囲で 2^kで全て割り切れるかで２分探索 O(Nloglogminval)
	// 0...Mまで順に確かめると、O(Nlogminval)
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
  		}
		int maxdo = -1;
		boolean cansep = true;
		while(cansep) {
			maxdo++;
			for(int j=0;j<A.length;j++) {
				int sep = (int) Math.pow(2, maxdo);
				if(A[j]%sep != 0) {
					cansep = false;
					break;  
				}
			}
		}
		System.out.println(maxdo-1);
	}

	//出現回数が少ないものから書き換えるHashMapで文字->頻度を保持、頻度でソートして下からN-K
	public static void C() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		for(int i=0;i<N;i++) {
			int key = sc.nextInt();
			if(map.containsKey(key)) map.put(key,map.get(key)+1);
			else map.put(key,1);
		}
		sc.close();
		ArrayList<Integer> lis = new ArrayList<Integer>(map.values());
		Collections.sort(lis);
		int ret = 0;
		for(int i=0;i<map.keySet().size()-K;i++) {
			ret += lis.get(i);
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 97628
#include<cstdio>

int main()
{
    int n;
    scanf("%d", &n);
    int nc = n;

    int f = 0;
    while (n > 0) {
        int a = n % 10;
        f += a;

        n -= a;
        n /= 10;
    }

    if (nc % f == 0) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll h, w;
    cin >> h >> w;
    ll S_max=0, S_min=h*w, ans;

    if(h%3==0 || w%3==0) ans = 0;
    else {
        S_min = w * (h/3);
        S_max = w * (h/3 + 1);
        ans = S_max - S_min;

        S_min = h * (w/3);
        S_max = h * (w/3 + 1);
        ans = (ans>S_max-S_min)?(S_max-S_min):ans;

        if(h%3==1) {
            S_min = w * (h/3);
            S_max = (h-h/3) * (w/2 + w%2);
            ans = (ans>S_max-S_min)?(S_max-S_min):ans;
        } else if(h%3==2) {
            S_max = w * (h/3 + 1);
            S_min = (h-h/3-1) * (w/2);
            ans = (ans>S_max-S_min)?(S_max-S_min):ans;
        }

        if(w%3==1) {
            S_min = h * (w/3);
            S_max = (w-w/3) * (h/2 + h%2);
            ans = (ans>S_max-S_min)?(S_max-S_min):ans;
        } else if(w%3==2) {
            S_max = h * (w/3 + 1);
            S_min = (w-w/3-1) * (h/2);
            ans = (ans>S_max-S_min)?(S_max-S_min):ans;
        }


    }

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n;i++)
typedef long long ll;
using namespace std;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 1;i<=N;i++){
        if(i % 2 == 1){
            int ans = 1;
            vector<int> x(i+1);
            int num = i;
            for(int j = 2;j<=i;j++){
                while(num % j == 0){
                    x.at(j)++;
                    num /= j;
                }
            }
            for(int v:x){
                ans *= v+1;
            }
            if(ans == 8){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(){
	int m[10],m1=0,m2=0,m3=0;
	for(int i=0;i<10;i++){
		cin >> m[i];
	}
	for(int i=0;i<10;i++){
		if(m[i]>m1){
			m3=m2;m2=m1;m1=m[i];
		}
		else if(m[i]>m2){
			m3=m2;m2=m[i];
		}
		else if(m[i]>m3){
			m3=m[i];
		}
	}
	cout << m1 << endl << m2 << endl << m3 <<endl;
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = input()
dic="abcdefghijklmnopqrstuvwxyz"
maxcount = 0
for i in range(n):
  count = 0
  for j in range(26):
    if str(dic[j]) in a[:i] and str(dic[j]) in a[i:]:
      count+=1
  maxcount = max(count,maxcount)
print(maxcount)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,W;
    cin>>n>>W;
    long long int i,w[n+1],v[n+1];
    for(i=1;i<=n;i++) cin>>w[i]>>v[i];
    long long int j,dp[n+1][W+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=W;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(j>=w[i]){
             dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
        }
        else dp[i][j]=dp[i-1][j];
    }
    }
    cout<<dp[n][W]<<endl;
  return 0;
}

Measured memory_bytes: 79104
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n :i32 = read();
    let mut sn : Vec<String> = read_vec();
    sn.sort();
    sn.dedup();
    let ans = if sn.len() == 4 {
        "Four".to_string()
    }else {
        "Three".to_string()
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace().map(|e| e.parse().unwrap());
    let mut x: i64 = itr.next().unwrap();
    let mut n: i64 = itr.next().unwrap();
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut t = vec![true; 102];
    let mut p = is
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect::<Vec<usize>>();
    for i in p {
        t[i] = false;
    }

    let mut ans = x;
    let mut d = 0;
    loop {
        if x < d {
            ans = -1;
            break;
        }

        let index = (x - d) as usize;
        if t[index] {
            ans = index as i64;
            break;
        }

        let index = (x + d) as usize;
        if t[index] {
            ans = index as i64;
            break;
        }

        d += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    ll n; cin >> n;
    ll sumA = 0, sumB = 0;
    ll d;
    ll ans = 0;
    vector<ll> a(n),b(n),c;
    rep(i,n) {
        cin >> a[i];
        sumA += a[i];
    }
    rep(i,n) {
        cin >> b[i];
        sumB += b[i];
    }

    if(sumA < sumB){
        cout << -1;
        return 0;
    }else{
        rep(i,n){
            if(a[i] >= b[i]){
                c.push_back(a[i]-b[i]);
            }
        }
    }
    d = sumA-sumB;
    sort(c.begin(),c.end());
    ans = n;
    rep(i,c.size()){
        if(d - c[i] >= 0){
            ans --;
            d -= c[i];
        }
    }
    cout << ans;

    return 0;
}


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

int main() {
	string s;
	int K;
	cin >> s >> K;
	string line[25005];
	int k = 0;
	for (int i = 0; i < s.length(); i++) {
		for (int j = 1; j <= 5; j++) {
			if (i + j <= s.length()) {
				line[k] = s.substr(i, j);
				k++;
			} else {
				break;
			}
		}
	}

	sort(line, line + k);
	s = line[0];
	int num = 1;
	if (K != 1) {
		for (int i = 1; i < k; i++) {
		if (line[i] != s) {
			s = line[i];
			num++;
			if (num == K)
				break;	
		}
	}
	}
	
	cout << s << endl;
}

Measured memory_bytes: 1664
import scala.io.{StdIn => in}

object Main extends App {
  val tar = List(1,9,7,4)
  val n = in.readLine.split(" ").map(_.toInt).toList
  val ans = n.permutations
    .find(p => p.sameElements(tar)) match {
      case Some(v) => "YES"
      case None => "NO"
    }
  println(ans)
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;
long double A, B, H, M;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<int> cnt(N, 0);
  // a > b < c > 
  REP(i, N-1){
    if(i % 2){
      cnt[i]--;
      cnt[i+1]++;
    }
    else{
      cnt[i]++;
      cnt[i+1]--;
    }
  }
  sort(cnt.begin(), cnt.end());
  ll sum = 0;
  REP(i, N){
    sum += (ll)cnt[i]*A[i];
  }
  ll ans = sum;
  // a < b > c < 
  REP(i, N){
    cnt[i] = 0;
  }
  REP(i, N-1){
    if(i%2){
      cnt[i]++;
      cnt[i+1]--;
    }
    else{
      cnt[i]--;
      cnt[i+1]++;
    }
  }
  sort(cnt.begin(), cnt.end());
  sum =0;
  REP(i, N){
    sum += (ll)cnt[i]*A[i];
  }
  ans = max(ans, sum);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b;
 	cin >> a >> b;
 	if(b==100){b++;
 		for (int i = 0; i < a; i++){
 		b=b*100;
 	}
 	}else{
 	for (int i = 0; i < a; i++){
 		b=b*100;
 	}}
 	cout << b << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s; cin >> s;
    ll c = 0, ans = INT_MIN;
    for(ll i = 0; i < s.size(); i++) {
        if(s[i] == 'R') c++;
        else {
            ans = max(ans, c);
            c = 0;
        }
    }
        ans = max(ans, c);
        cout << ans << endl;
        return 0;

}


Measured memory_bytes: 3596
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int const MOD=1e9+7;
int main(){
	int r, c;
	cin>>r>>c;
	vector<vector<int>> v(r+1,vector<int>(c+1)), dp(r+1,vector<int>(c+1));
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++){
			char ch;
			cin>>ch;
			v[i][j]=(ch=='.')?0:1;
		}
	dp[r-1][c-1]=1;
	for(int i=r-1;i>=0;i--)
		for(int j=c-1;j>=0;j--)
			if(v[i][j]==0 && !(i==r-1 && j==c-1))
				dp[i][j]=(dp[i+1][j]+dp[i][j+1])%MOD;
	cout<<dp[0][0];
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  string s; cin >> s;
  map<char, int> m;
  rep(i,s.size()){
    m[s[i]]++;
  }
  string ans = yes;
  for(auto p : m){
    if(p.second != 2) ans=no;
  }
  cout << ans << endl;
  return 0;
}



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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};


int main(){
	int n,i;
	cin>>n;
	vi a(n);
	loop(i,0,n){
		cin>>a[i];
	}
	vi b(n,0);
	if(n%2 == 0){
		loop(i,0,n/2){
			b[n/2 + i] = a[2*i];
			b[n/2 - 1 - i] = a[2*i+1];
		}
	}else{
		b[n/2] = a[0];
		loop(i,0,n/2){
			b[n/2 + i + 1] = a[2*i + 1];
			b[n/2 - i - 1] = a[2*i + 2];
		}
	}
	loop(i,0,n-1){
		cout<<b[i]<<" ";
	}
	cout<<b[n-1]<<endl;
}

Measured memory_bytes: 3712
#include<cstdio>
constexpr int MAX_CHAR = 100000;
char s[MAX_CHAR+1],t[MAX_CHAR+1];
//next[c-'a'][i]=iから進んだ時に最初に現れるcの位置（i自身は含まない）
int next[26][MAX_CHAR];
bool exists[26];
int main(){
	scanf("%s%s",s,t);
	int len_s=0;
	while(s[len_s]!='\0')len_s++;
	for(char c='a';c<='z';c++){
		int i=len_s-1;
		while(i>=0 && s[i]!=c)i--;
		if(i<0){
			exists[c-'a']=false;
			for(int k=0;k<len_s;k++)next[c-'a'][k]=-1;
			continue;
		}
		exists[c-'a']=true;
		int last_i=i;
		bool is_second_loop=false;
		while(true){
			while(i>=0 && s[i]!=c){
				next[c-'a'][i]=last_i;
				i--;
			}
			if(i<0){
				if(is_second_loop){
					break;
				}else{
					is_second_loop=true;
					i=len_s-1;
				}
			}else{
				next[c-'a'][i]=last_i;
				last_i=i;
				i--;
			}
		}
	}
	long long ans=-len_s;
	int coord=len_s-1;
	for(int i=0;t[i]!='\0';i++){
		int new_coord = next[t[i]-'a'][coord];
		if(new_coord<0){
			printf("-1");
			return 0;
		}
		if(new_coord<=coord)ans+=len_s;
		coord=new_coord;
	}
	printf("%lld",ans+coord+1);
	return 0;
}

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

using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++){
        int tmp; cin >> tmp;
        arr[i] = tmp;
    }
    sort(arr, arr+n);
    int ans = 2000000000;
    for (int i = 0; i < n-k+1; i++){
        ans = min(ans, arr[i+k-1]-arr[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    cout << Yes(D <= S * T) << endl;
}

Measured memory_bytes: 3636
from queue import PriorityQueue


N, M = map(int, input().split())  # N件の日雇いアルバイト, M日後までに貯めれるお金

jobs = [[] for _ in range(M)]
for i in range(N):
    a, b = map(int, input().split())  # a日後に報酬bがもらえる
    if a > M:  # M日後までにもらえない仕事はスルー
        continue
    jobs[M-a].append(b)  # a日後に報酬がもらえるアルバイト一覧が完成していく
    # jobsは後ろのindexの方に、締め切りが近い仕事が溜まっている

pq = PriorityQueue()
ans = 0
for i in range(M-1, -1, -1):  # 後ろから見ていく
    for b in jobs[i]:  # 締め切りが近い仕事一覧
        pq.put(-b)  # pythonのpqは値が小さい方が優先度が高い？
    # 締め切りが近い仕事一覧をpqに追加し終えたあとに、報酬が一番大きいものを選ぶ
    if not pq.empty():  # 空のpqに対して要素を取り出すような指示を出すとエラーが起きてしまう
        ans += -(pq.get())

print(ans)


Measured memory_bytes: 20868
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],b[200005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) 
	    cin>>a[i],b[i]=a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		if(b[i]==a[n]) cout<<a[n-1]<<endl;
		else cout<<a[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

int a[310][310];
int used[310];
int cnt[310];

int main(){
    int n,m; cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int ans=n;
    for(int i=n;i>=0;i--){
        for(int j=0;j<310;j++){
            cnt[j]=0;
        }
        bool ok=true;
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                if(used[a[j][k]]&&k<m-1)continue;
                if(used[a[j][k]]&&k==m-1)ok=false;
                cnt[a[j][k]]++;
                break;
            }
        }
        if(ok==false)break;
        bool change=true;
        for(int j=0;j<310;j++){
            if(cnt[j]>i){
                change=false;
                used[j]=1;
            }
        }
        if(change)ans=i;
        else{
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
int top,s[1000005];
int a,b;
char c[1000005];
void push(int x)
{
    s[++top]=x;
}
int pop()
{
    top--;
    return s[top+1];
}
int main()
{
    while(scanf("%s",c)!=EOF)
    {
        if(c[0]=='+')
        {
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(c[0]=='-')
        {
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(c[0]=='*')
        {
            a=pop();
            b=pop();
            push(a*b);
        }
        else
        {
            push(atoi(c));
        }
    }
    printf("%d\n",pop());
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	
	cout<<(1000-n%1000)%1000;
	re 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%i",&n);
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
	}
	long long r=0;
	map <int,int> mapa;
	for(int i=1;i<=n;i++)
	{
		mapa[a[i]]++;
	}
	for(auto j:mapa)
	{
		r+=(long long)j.second*(j.second-1)/2;
	}
	long long k=r;
	for(int i=1;i<=n;i++)
	{
		mapa[a[i]]--;
		r-=(long long)mapa[a[i]]*(mapa[a[i]]-1)/2;
		r+=(long long)(mapa[a[i]]-1)*(mapa[a[i]]-2)/2;
		printf("%lld\n",r-1);
		r=k;
		mapa[a[i]]++;
	}
	return 0;
}


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

int main()
{
    long long l,r;
    cin >> l >> r;

    long long min=2020;
    if( r - l > 2020)
    {
        cout << "0" << endl;
    }
    else
    {
        for( long long i=l; i<=r-1; i++ )
        {
            for( long long j=i+1; j<=r; j++ )
            {
                if( (i*j)%2019 <= min ) min = (i*j)%2019;
            }
        }
        cout << min << endl;
    }

    return 0;
}


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

using namespace std;
int main() {
	long long int N,P,A,ans = 0,num = 0,n0 = 0,n1 = 0;
	vector<long long int> n0c,n1c;
	cin >> N >> P;
	for (int i = 0;i<N;i++) {
		cin >> A;
		if (A%2 == 0) {
			n0++;
		}
		else {
			n1++;
		}
	}
	n0c.push_back(n0);
	for (int i = 1; i < n0;i++) {
		n0c.push_back(n0c[i - 1]);
		n0c[i] *= n0 - i;
		n0c[i] /= i+1;
	}
	n1c.push_back(n1);
	for (int i = 1; i < n1; i++) {
		n1c.push_back(n1c[i - 1]);
		n1c[i] *= n1 - i;
		n1c[i] /= i + 1;
	}

	if (P == 0) {
		ans += n0 +1;
	}
	if (P == 1) {
		ans += n1;
	}


	for (int i = 2; i <= N; i++) {
		if (P == 0) {
			if (n0 >= i) {
				num = 1;
				num *= n0c[i-1];
				ans += num;
			}
			for (int j = 2; j <= i;j+=2) {
				if (n1 >= j && n0 >= i-j) {
					num = 1;
					num *= n1c[j - 1];
					if(i-j>0)num *= n0c[i - j - 1];
					ans += num;
				}
			}
		}
		else {
			for (int j = 1; j <= i; j += 2) {
				if (n1 >= j && n0 >= i - j) {
					num = 1;
					num *= n1c[j - 1];
					if(i-j>0)num *= n0c[i - j - 1];
					ans += num;
				}
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}



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

int digits(ll n) {
  int d = 0;
  while(n > 0) { n /= 10; d++; }
  return d;
}

int main() {
  ll n; cin >> n;
  int ans = digits(n);
  for(ll i = 1; i*i <= n; i++) {
    if (n%i != 0) continue;
    ans = min(ans, max(digits(i), digits(n/i)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define MAXWORD 1000
#define MAXCHARA 20

int main(void){

	int c;
	int i, j; i = j = 0;
	char a[MAXWORD][MAXCHARA] = {};
	char A[MAXWORD][MAXCHARA] = {};

	c = getchar();
	while (c != EOF)
	{
		
	if(c == ' ' || c == '\n'){	

	a[i][j] = '\0';
	i++; j = 0;
	c = getchar();

		} else {
			A[i][j] = (char)c;
			a[i][j] = (char)tolower(c);
			j++;
			c = getchar();
			}
	}		

	int count; count = 0;
	int k;

	for (k = 1; k <= i; k++){
		if ((strcmp(A[k], "END_OF_TEXT")) == 0){
			printf("%d\n", count);
			return 0;
				} else if ((strcmp(a[k], a[0])) == 0){
				count++;
				}
			}

	printf("%d\n", count);
	return 0;
	
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    string S;
    cin >> S;
    int max_count = 0;
    int count = 0;
    for(int i = 0 ; i < S.size(); i++){
        if( S[i] == 'S'){
            if( count > max_count){
                max_count = count;
            }
            count = 0;
        }else{
            count++;
        }
    }
    if( count > max_count){
        max_count = count;
    }
    cout << max_count << "\n";
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int[] b = { 1, 100, 10000 };
		System.out.println(b[D] * (N + (N / 100)));
	}
}


Measured memory_bytes: 21844
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
#define N 100001
//9/7

int main(void){
    int n;
    cin>>n;
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%4==0)x++;
        else if(a%2==0)y++;
        else z++;
    }
    //2の倍数の並びは倍数でないものと等しい
    bool ok;
    if(y==0){
        if(x>=z-1)ok=true;
        else ok=false;
    }else{
        if(x>=z)ok=true;
        else ok=false;
    }
    if(ok)printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
vector<int> g[MAX_N];
int dp[MAX_N];
int indeg[MAX_N];

int main2() {
  CLR(dp, 0);
  CLR(indeg, 0);
  REP(i, MAX_N) g[i].clear();

  int N = nextInt();
  int M = nextInt();

  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    indeg[b]++;
  }
  queue<int> q;
  REP(i, N) if (indeg[i] == 0) q.push(i);
  while (q.size() > 0) {
    int cur = q.front(); q.pop();
    for (int nxt : g[cur]) {
      chmax(dp[nxt], dp[cur] + 1);
      indeg[nxt]--;
      if (indeg[nxt] == 0) {
        q.push(nxt);
      }
    }
  }
  int ans = 0;
  REP(i, MAX_N) chmax(ans, dp[i]);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 6912
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String s = sc.next();
        if ((con(s,"N")&&con(s,"S"))&&(con(s,"W")&&con(s,"E"))) {
            System.out.println("Yes");
        } else if ((con(s,"N")&&con(s,"S"))&&(!con(s,"W")&&!con(s,"E"))) {
            System.out.println("Yes");
        } else if ((!con(s,"N")&&!con(s,"S"))&&(con(s,"W")&&con(s,"E"))) {
            System.out.println("Yes");
        } else if ((!con(s,"N")&&!con(s,"S"))&&(!con(s,"W")&&!con(s,"E"))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
    private static boolean con(String s1, String s2) {
        return s1.indexOf(s2) >= 0;
    }
}


Measured memory_bytes: 9684
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var N = input[0];
            var M = input[1];
            var S = Read();
            var T = Read();
            var G = Gcd(N, M);
            var L = Lcm(N, M);
            var n = N / G;
            var m = M / G;
            for (int i = 0; i < G; i++)
            {
                if (S[i * (int)n] != T[i * (int)m])
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            Console.WriteLine(L);
            Console.ReadLine();
        }

        static long Gcd(long a, long b) { if (b == 0) return a; return Gcd(b, a % b); }
        static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13792
n = int(input())
q = [ 3, 5, 7 ]

ans = 0
while len(q) != 0:
    x = q.pop(0)
    for i in [ 3, 5 , 7]:
        y = 10 * x + i
        if ( y <= n):
            q.append(y)
            if '3' in str(y) and '5' in str(y) and '7' in str(y):
                ans += 1
print(ans)

Measured memory_bytes: 3700
import math
import time
from collections import deque
from collections import defaultdict
from copy import deepcopy
import heapq

mod = 10 ** 9 + 7
t = time.time()



def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret


def conbination(n, r, mod):
    if n < r:
        return 0

    if r == 0 or n == 0:
        return 1

    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    #print(f"conbination {n}, {r} = {ret}")
    return ret

def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod

def main():
    N, K = iip()

    for i in range(1, K+1):
        a = conbination(N-K+1, i, mod)
        b = conbination(K-1, i-1, mod)
        ans = (a*b) % mod
        #print(a)
        #print(b)
        print(ans)


main()

Measured memory_bytes: 51160
n, k = gets.to_s.split.map{|t|t.to_i}

if k == 0
  puts n * n
  exit
end

ans = 0
(k+1).upto(n) do |b|
  set = (n-k+1) / b
  rem = (n-k+1) % b
  cnt = (b-k) * set + [rem, (b-k)].min
  # p [b, set, rem, cnt]
  ans += cnt
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
using ll = long long;
using namespace std;

signed main(){
    ll q, h, s, d, n, one, two;
    cin >> q >> h >> s >> d >> n;
    q *= 8;
    h *= 4;
    s *= 2;
    if(h <= q && h <= s){
        one = h / 2;
        two = h;
    }else if(q <= s){
        one = q / 2;
        two = q;
    }else{
        one = s / 2;
        two = s;
    }
    if(two > d){
        two = d;
    }
    if(n % 2){
        cout << (n - 1) / 2 * two + one << endl;
    }else{
        cout << n / 2 * two << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)1e6 + 5;
const int mod = (int)1e9 + 7;

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    int x, y;
    cin >> x >> y;
    if (abs(x) <= abs(y)) {
        int res = (x < 0 ? 1 : 0) + (y < 0 ? 1 : 0) + abs(y) - abs(x);
        cout << res << endl;
        return 0;
    }
    int res = (x > 0 ? 1 : 0) + (y > 0 ? 1 : 0) + abs(x) - abs(y);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n, W;

long long dp[110][100010];

int main() {
    cin >> n >> W;
    vector<long long> w(n, 0);
    vector<long long> v(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> w.at(i) >> v.at(i);
    }

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

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= W; ++j) {
            if(j+w.at(i) <= W) {
                dp[i+1][j+w.at(i)] = dp[i][j] + v.at(i);
            }

            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][W] << endl;
}

Measured memory_bytes: 80128