akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline

    X = int(input())
    for a in range(-200, 200):
        a5 = a**5
        b5 = a5-X
        for b in range(-200, 200):
            if b**5 == b5:
                print(a, b)
                exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 9020
u = [raw_input() for i in range(input())]
t = [raw_input() for i in range(input())]
isopen = -1
for id in t:
	if id in u:
		print "Opened by %s"%(id) if isopen < 0 else "Closed by %s"%(id)
		isopen *= -1
	else:
		print "Unknown",id

Measured memory_bytes: 4216
from typing import List


def compute_lcs(x_str: str, y_str: str) -> int:
    if len(x_str) <= len(y_str):
        shorter_str, longer_str = x_str, y_str
    else:
        shorter_str, longer_str = y_str, x_str

    lcs_idx: List[int] = []
    for s_ch in shorter_str:
        l_bgn_idx = 0
        for i, l_cur_idx in enumerate(lcs_idx):
            l_idx = longer_str.find(s_ch, l_bgn_idx)
            if -1 == l_idx:
                break
            lcs_idx[i] = min(l_cur_idx, l_idx)
            l_bgn_idx = l_cur_idx + 1  # Move to the next ch.
        l_idx = longer_str.find(s_ch, l_bgn_idx)
        if -1 != l_idx:
            lcs_idx.append(l_idx)
    return len(lcs_idx)


if __name__ == "__main__":
    num_pairs = int(input())

    for _ in range(num_pairs):
        x_str = input()
        y_str = input()
        lcs = compute_lcs(x_str, y_str)
        print(f"{lcs}")



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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j]= f[k]; f[k] = f[l]; f[l] = t;
  }
};

int getRight(Cube c1, int f1, int f2){
  for ( int i = 0; i < 6; i++ ){
    for ( int j = 0; j < 4; j++ ){
      if (c1.f[0] == f1 && c1.f[1] == f2 ) return c1.f[2];
      c1.roll_z();
    }
    if (i % 2 == 0 ) c1.roll_y();
    else c1.roll_x();
  }
  return -1;
}

int main(){
  Cube c;
  int f1, f2;

  for (int i = 0; i <6; i++ ) cin >> c.f[i];
  int q; cin >> q;

  for (int i = 0; i < q; i++ ){
    cin >> f1 >> f2;
    cout << getRight(c, f1, f2 ) << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;

	vl a(n);
	FOR(i,0,n) cin >> a[i];

	ll sum = 0;
	FOR(i,0,k) sum += a[i];
	
	ll res = sum;
	FOR(i,k,n) {
		sum += a[i] - a[i-k];
		res = max(res,sum);
	}
	
	cout << fixed << setprecision(1) << double(res+k)/2 << endl;

}



Measured memory_bytes: 1792
solve :: Int ->  Int -> Int -> Int -> [Int]
solve 10 r d x = [r * x - d]
solve count r d x = x' : solve (count + 1) r d x'
  where x' = r * x - d

main :: IO ()
main = do
  [r, d, x] <- map read . words <$> getLine
  mapM_ print $ solve 1 r d x



Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
using namespace std;
string s;
bool p=0;
int main()
{
	cin>>s;
	int l=s.size();
	for (int i=0;i<l;i++)
	{
		if (s[i]=='C')
		p=1;
		if (p==1&&s[i]=='F')
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll int64_t
#define ld long double
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type , less<ll>,rb_tree_tag,tree_order_statistics_node_update> set_2i;
typedef tree<ld,null_type , less<ld>,rb_tree_tag,tree_order_statistics_node_update> set_2d;
typedef tree<string,null_type , less<string>,rb_tree_tag,tree_order_statistics_node_update> set_2s;
const ll INF = 99999999999;
string yes = "YES", no = "NO";
void Oli(){
    int a;
    cin>>a;
    for(int i=0;i<a;i++){
    cout<<"ACL";

    }
}
int main()
{
    int times  = 1;
    //cin>>times;
    while( times--) Oli();
    //BY ME
}


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

signed main()
{
   int N,M,A,B; cin>>N>>M>>A>>B;
   vector<int> d(N);
   for(int i=0;i<N;i++){
      cin>>d[i];
   }

   int cnt=0;
   vector<bool> flag(N);
   for(int i=0;i<N;i++){
      if(d[i]>=A){
         flag[i]=true;
         cnt++;
      }else{
         break;
      }
   }
   if(N-cnt>=M){
      cout<<cnt<<endl;
   }else{
      for(int i=N-1;i>=0;i--){
         if(flag[i]){
            if(d[i]<=B){
               cnt--;
            }else{
               break;
            }
         }
      }
      cout<<cnt<<endl;
   }
}




Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int a[101010],b[101010];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]+=i;
		b[x]+=i;
	}
	for(int i=2;i<=n;i++)
		a[i]+=a[i-1];
	for(int i=n-1;i>=1;i--)
		b[i]+=b[i+1];
	for(int i=1;i<=n;i++)
	{
		a[i]+=i;
		b[i]+=n-i+1;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;
	for(int i=1;i<=n;i++)
		cout<<b[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 768
n = int(input())
nums = list(map(int, input().split()))


def gcd(a, b):
    while True:
        a, b = b, a % b
        if b == 0:
            break
    return a


res = nums[0]
for x in nums[1:]:
    res = gcd(res, x)

print(res)

Measured memory_bytes: 14224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(void){
    int N, M;
    cin >> N >> M;
    int r[N];
    FOR(i,0,N) r[i] = 0;
    FOR(i,0,M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        r[a]++;
        r[b]++;
    }
    FOR(i,0,N) cout << r[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200005];
int main()
{
    int num1=0;
    int num2=0;
    scanf("%s",s+1);
    int n=strlen(s+1);
    long long ans=0;
    for(int i=1;i<n;i++)
    {
        if(num1!=0&&s[i]=='B'&&s[i+1]=='C'&&i<n)
        {
            i++;
            ans+=num1;
        }
        else if(s[i]=='A')
        {
            num1++;
        }
        else
        {
            num1=0;
        }
    }
    printf("%lld\n",ans);
}





Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int N, L, T, w, x[100009]; long long s[500009], t[500009];
int main() {
	scanf("%d %d %d", &N, &L, &T);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x[i], &w);
		for (int j = 0; j < 5; j++) {
			s[i + j * N] = x[i] + (w == 1 ? 1LL : -1LL) * L + 1LL * j * L;
			t[i + j * N] = x[i] + (w == 1 ? 1LL : -1LL) * (T % L) + 1LL * j * L;
		}
	}
	sort(s, s + 5 * N);
	sort(t, t + 5 * N);
	int r = 1LL * (lower_bound(x, x + N, s[2 * N] % L) - x) * (T / L) % N;
	for (int i = 0; i < N; i++) printf("%d\n", t[(r + i) % N + 2 * N] % L);
	return 0;
}

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

const int N=100050;
int dp[N];
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    long long sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        sum+=a[i];
        dp[a[i]]++;
    }
    int q;
    scanf("%d",&q);
    while(q--){
        int a,b;
        scanf("%d%d",&a,&b);
        sum-=(long long)(dp[a])*(long long)(a);
        sum+=(long long)(dp[a])*(long long)(b);
        dp[b]+=dp[a];
        dp[a]=0;
        printf("%lld\n",sum);
    }
    return 0;
}

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

int main() {
  int a, x, y, z;
  cin >> a;
  
  x = a / 100;
  y = (a - (x * 100) ) / 10;
  z = a - (x * 100) - (y * 10);
  
  cout << x + y + z << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 200;
int main(){
    int a,b,k;
    while(cin>>a>>b>>k){
        int ans[N];
        int cnt = 0;
        for(int i=max(a,b);i>=1;i--){
            if(a % i ==0 && b % i == 0){
                ans[cnt++] = i;
            }
        }
        //for(int i = 0;i<cnt;i++){
        //    cout<<ans[i]<<' ';
        //}
        cout<<ans[k-1]<<endl;
    }
    return 0;
}


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

#define ll long long
#define N 100005
#define mod 1000000007


int main() 
{
    int h,w,m[200][200],i,j,a[50000],n;
    
    for(i=0;i<200;i++)  for(j=0;j<200;j++)  m[i][j]=0;
    
    cin>>h>>w;
    cin>>n;
    
    for(i=0;i<n;i++)  cin>>a[i];
    
    i=0;j=0;
    int k=0;
    
    while(k<n)
    {
       // cout<<k<<endl;
        if(i%2==0)
        {
            while(a[k] && j<w)
            {
                m[i][j++]=k+1;
                a[k]--;
            }
            if(j==w)
            {i++;j--;}
            if(!a[k])
            k++;
        }
        else
        {
             while(a[k] && j>=0)
            {
                m[i][j--]=k+1;
                a[k]--;
            }
            if(j==-1)
           { i++;j++;}
            if(!a[k])
            k++;
        }
    }
    
    for(i=0;i<h;i++)
    {
        if(i>0)
        cout<<endl;
        for(j=0;j<w;j++)
        cout<<m[i][j]<<" ";
    }
    
    return 0;
}

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

int main() {
  int N, count = 0;
	cin >> N;
  if(N >= 1) {
    for(int i = 1; i <= N; i++) {
      if(to_string(i).length() % 2 == 1)
        count++;
    }
 }
  cout << to_string(count);
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
if n == 1:
    print('Hello World')
else:
    a, b = map(int, read().split())
    print(a + b)


Measured memory_bytes: 2940
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

const MOD: i64 = 1_000_000_007;

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b != 0 {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    } else {
        *x = 1; *y = 0;
    }
    d
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x = 0;
    let mut y = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

fn mod_fact(n: i64, p: i64, e: &mut i64, fact: &Vec<i64>) -> i64 {
    *e = 0;
    if n == 0 {
        return 1;
    }

    let res = mod_fact(n/p, p, e, fact);
    *e += n/p;
    if (n/p %2 != 0) {
        return res * (p - fact[(n%p) as usize]) % p;
    }
    res * fact[(n%p) as usize] % p
}

fn mod_comb(n: i64, k: i64, memo: &Vec<i64>) -> i64 {
    let mut ans = 1;
    for i in 0..k {
        ans *= (n-i);
        ans %= MOD;
    }
    let mut div = memo[k as usize];
    ans * mod_inverse(div, MOD) % MOD
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let a = line[1];
    let b = line[2];
    let mut memo = vec![0i64; cmp::max(a,b)+10];
    memo[0] = 1;
    memo[1] = 1;
    for i in 2..memo.len() {
        memo[i] = memo[i-1] * (i as i64) % MOD;
    }
    let mut ans = 1;
    let mut tmp = 2;
    for i in 0..50 {
        if (n as i64) & (1 << i) > 0 {
            ans = ans * tmp % MOD;
        }
        tmp = tmp * tmp % MOD;  
    }
    ans += MOD-1;
    ans %= MOD;
    ans += MOD - mod_comb(n as i64, a as i64, &memo);
    ans %= MOD;
    ans += MOD - mod_comb(n as i64, b as i64, &memo);
    ans %= MOD;
    println!("{}", ans);
}


Measured memory_bytes: 6396
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	string s;
 	cin>>s;
 	if(s=="ABC")
 	{
 		cout<<"ARC"<<endl;
 	}
 	else
 	{
 		cout<<"ABC"<<endl;
 	}
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
	
	
	
	
	
	
	return 0;
}

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

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define INF 1e+18

using namespace std;

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;
    
    int n ;
    cin >> n ;
    int a[n] , dp[n] ;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i] ; 
        if(i - 2 >= 0){
            dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]) , dp[i - 2] + abs(a[i] - a[i - 2])) ; 
        }
        else if(i - 1 >= 0){
            dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]) ;
        }
        else{
            dp[i] = 0 ;
        }
    }

    cout << dp[n - 1] << endl ; 

    return 0 ; 
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100
int n;
int a[MAXN+5];
long long ans,ans2=100000000;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int maxx=*max_element(a+1,a+1+n);
	int minn=*min_element(a+1,a+1+n);
	for(int i=minn;i<=maxx;i++) {
		ans=0;
		for(int j=1;j<=n;j++)
			ans+=(a[j]-i)*(a[j]-i);
		ans2=min(ans2,ans);
	}
	printf("%lld\n",ans2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
int cnt = 0;
vector<int> a;
int mp[1000001];

int main() {
    scanf(" %d", &n);
    rep(0,1000001) mp[i] = 0;
    rep(0,n) {
        scanf(" %d", &m);
        a.push_back(m);
        mp[m]++;
    }
    if (mp[1] == 1) {
        printf("%d\n", 1);
        exit(0);
    } else if (mp[1] > 1) {
        printf("%d\n", 0);
        exit(0);
    }
    for (auto it = a.begin(); it != a.end(); it++) {
        if (mp[*it] > 1) continue;
        int div = 2;
        bool check = true;
        while (div <= (int)sqrt(*it)) {
            if (*it % div == 0) {
                if (mp[div] > 0 || mp[*it/div] > 0) {
                    check = false;
                    break;
                }
            }
            div++;
        }
        if (check) cnt++;
    }
    printf("%d\n", cnt);
}

Measured memory_bytes: 8172
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            System.out.println(Math.min(Math.min(a + b, b + c), c + a));
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main() {
	int n, a[100][2], sum = 0, max = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i][0]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i][1]);
		sum += a[i][1];
	}
	sum += a[0][0];
	max = sum;
	for (int i = 0; i < n - 1; i++) {
		sum = sum - a[i][1] + a[i + 1][0];
		if (max < sum) {
			max = sum;
		}
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
from bisect import bisect_left
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

q = deque([A[0]])
for i in range(1,N):
    insert_index = bisect_left(q,A[i])
    if insert_index == 0:
        q.appendleft(A[i])
    else:
        q[insert_index-1] = A[i]

print(len(q))


Measured memory_bytes: 46940
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << setprecision(7) << (x) << endl;

long double pi = 3.14159265359;

long long int factorial(long long int n){
    long long int res;
    if (n == 0) return 1;
    res = (n)*factorial(n-1);
    return res;
}

int h,w,K;
int c[10][10];
char a;
int nb,nw;
int ans=0;

int main(){
    cin >> h >> w >> K;
    rep(i,h){
        rep(j,w){
            cin >> a;
            if(a == '.'){
                c[i][j] = 1;
                nw ++;
            }
            else if(a == '#'){
                c[i][j] = 2;
                nb++;
            }
        }
    }
    // rep(i,h){{rep(j,w) cout << c[i][j] << " ";}cout << endl;}
    int cnt=nb;
    // cout << cnt << endl;
    rep(i,1<<h){
        rep(j,1<<w){
            // cout << bitset<8>(i) << " " << bitset<8>(j) << endl;
            rep(k,h){
                    // cout << bitset<3>(i>>k) << " " << bitset<3>(j>>l) << endl;
                    if(i>>k & 1 ){
                        rep(m,w){
                            if(c[k][m] == 2){
                                cnt --;
                            }
                        }
                    }
            }
            rep(l,w){
                    if(j>>l & 1){
                        rep(n,h){
                            if(c[n][l] == 2 && (!(i>>n & 1))){
                                // cout << "hello" << endl;
                                cnt --;
                            }
                        }
                    }
                    // cout << cnt << endl;
            }
            if(K == cnt) ans++;
            cnt = nb;
        }
    }
    cout << ans << endl;






return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

#define rr register

// #define int long long
#define db double

#define inf 1e10
#define mod 10007

using namespace std;

const int MAXN = 1e5 + 5;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return f ? -s : s;
}

int n, ans;

int a[105];

signed main(signed argc, char const *argv[]) {
	n = read();
	for (rr int i = 1; i <= n - 1; i++)
		a[i] = read();
	for (rr int i = 2; i <= n; i++)
		ans += min(a[i], a[i - 1]);
	cout << ans + a[1] + a[n - 1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	stack<int> a;
	stack<pair<int,int> > b;
	int tot=0;
	string s;
	getline(cin,s);
	for (int i=0; i<s.length(); i++){
	    if (s[i]=='\\')
			a.push(i);
		if (s[i]=='/' && !a.empty()){
			   tot+=i-a.top();
			   int tot1=i-a.top();
		      
	           while (b.size()>0 && b.top().first>a.top()){
	           	    tot1+=b.top().second;
	           	    b.pop();
			   }
			  b.push(make_pair(a.top(),tot1)); 
			  a.pop();
		}
		 
	}
	cout<<tot<<endl;
	int m=b.size();
	cout<<m;
	vector<int> ans;
	for (int i=0; i<m; i++){
		ans.push_back(b.top().second);
		b.pop();
	}
	reverse(ans.begin(),ans.end());
	for (int i=0; i<m; i++){
		  cout<<' '<<ans[i];
	}
	cout<<endl;
	return 0;
} 


Measured memory_bytes: 3300
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const ll MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
int N;
string ans;
vector<bool> s;




//サブ関数
//入力
void input()
{
	string ss;
	cin >> N >> ss;

	for (auto c : ss)s.push_back(c == 'o');
}

string check(string sug)
{
	FOR(i, 1, N) {
		if (sug[i] == 'S') {
			if (sug[i - 1] == 'S') {
				sug += (s[i] ? "S" : "W");
			}
			else {
				sug += (s[i] ? "W" : "S");
			}
		}
		else {
			if (sug[i - 1] == 'S') {
				sug += (s[i] ? "W" : "S");
			}
			else {
				sug += (s[i] ? "S" : "W");
			}
		}
	}
	// different
	if (sug.back() != sug.front())return "";
	sug.pop_back();
	
	if (sug[1] == sug.back()) {
		if (sug[0] == 'S' && !s[0])return "";
		if (sug[0] == 'W' && s[0])return "";
	}
	else {
		if (sug[0] == 'S' && s[0])return "";
		if (sug[0] == 'W' && !s[0])return "";
	}
	return sug;
}

//計算
void calc()
{
	REP(i, 4) {
		string sug = "";
		sug += (i % 2 == 0 ? "S" : "W");
		sug += (i > 1 ? "S" : "W");
		
		string res = check(sug);
		if (res != "") {
			ans = res;
			return;
		}
	}
	ans = "-1";
}


//出力
void output()
{
	cout << ans << endl;
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 608
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
#define sz(v) int((v).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	rrep(l,0,n+1){
		if(s.substr(n-l,l) != t.substr(0,l)) continue;
		cout << 2*n-l << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int N, M;
int a[1050], b[1050], c[1050][20];

void input() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for(int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
}

void solve() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++) {
        int now = 0;
        for(int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j] - 1));
        }
        for(int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int a,b,c;
    cin>>a>>b>>c;
    if((100*a+10*b+c)%4==0)
    {
        cout <<"YES"<<endl;
    }
    else
    {
        cout <<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for(int x = 0; x <= k; ++x){
		for(int y = 0; y <= k; ++y){
			int z = s - x - y;
			if(0 <= z && z <= k) ++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


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

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

  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int ans = 0;
  for(int i = 0; i < a+1; i++){
    for(int j = 0; j < b+1; j++){
      for(int k = 0; k < c+1; k++){
        if(i*500 + j*100 + k*50 == x) ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  static String a = "";
  static String b = "";
  static String c = "";

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    a = sc.next();
    b = sc.next();
    c = sc.next();

    judge('a');
  }

  public static void judge(char ch) {

    if (ch == 'a') {
      if (a.length() == 0) {
        System.out.println("A");
        return;
      } else {
        char card = a.charAt(0);
        a = a.substring(1);
        judge(card);
      }
    }

    if (ch == 'b') {
      if (b.length() == 0) {
        System.out.println("B");
        return;
      } else {
        char card = b.charAt(0);
        b = b.substring(1);
        judge(card);
      }
    }

    if (ch == 'c') {
      if (c.length() == 0) {
        System.out.println("C");
        return;
      } else {
        char card = c.charAt(0);
        c = c.substring(1);
        judge(card);
      }
    }
  }
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;
    
    ll i;
    for(i=0;i*i<=n;++i);--i;
    cout<<i*i<<endl;
    
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    
    cout << min(A, B) << endl;
    if((A + B) - N < 0)
        cout << 0 << endl;
    else
        cout << (A + B) - N << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int H, W, N;
char table[1010][1010];
int sy, sx;
int solve(int y, int x, int target)
{
    queue<P> que;
    int cost[1010][1010];
    memset(cost, -1, sizeof(cost));
    que.push(P(y, x));
    cost[y][x] = 0;
    while(que.size())
    {
        P now = que.front(); que.pop();
        for(int i = 0; i < 4; i++)
        {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];
            if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
            if(table[ny][nx] == 'X' || cost[ny][nx] != -1) continue;
            cost[ny][nx] = cost[now.first][now.second] + 1;
            if(table[ny][nx] - '0' == target) 
            {
                sy = ny, sx = nx;
                return cost[ny][nx];
            }
            que.push(P(ny, nx));
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> N;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cin >> table[i][j];
            if(table[i][j] == 'S') sy = i, sx = j;
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        ans += solve(sy, sx, i);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 8124
#include <iostream>
#include "string.h"
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define MAX_N 2000000
int N,T;
int t[MAX_N];


unsigned long long gcd(unsigned long long a,unsigned long long b){
	if(b == 0) return a;
	return gcd(b,a % b);
}

unsigned long long lcm(unsigned long long a,unsigned long long b){
	if(a == b) return a;
	return  a / gcd(a,b) * b;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> T;
	for(int i = 0;i < N;i++) cin >> t[i];
	int ans = 0;
	int pos = 0;
	for(int i = 0;i < N;i++){
		if(i < N - 1 && pos + T >= t[i+1]) ans += (t[i+1] - pos);
		else ans += T;
		pos = t[i+1];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,a;
    cin>>n>>a;
    a+=n*3;
    cout<<a/2<<endl;
return 0;
}


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

using namespace std;



int main()
{
    long long x;
    cin >> x;
    long long nr = 100;

    int cr=0;
    while(nr < x)
    {
        cr ++;
        nr = nr + nr / 100;
    }

    cout<<cr<<"\n";

    return 0;
}


Measured memory_bytes: 3636
n,k = map(int,input().split())

mod = 10**9 + 7

ans = 0
for i in range(k,n+2):
    min = i*(i-1)//2
    max = (n+1)*n//2 - (n+1-i)*(n-i)//2
    ans += (max - min + 1)%mod
print(ans%mod)


Measured memory_bytes: 9176
#include <bits/extc++.h>
using namespace std;
using i64 = int64_t;
#define mod 1000000007
i64 power(i64 a, i64 b) {
  i64 ret{1};
  while (b) {
    if (b & 1) ret *= a, ret %= mod;
    a *= a;
    a %= mod;
    b /= 2;
  }
  return ret;
}

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

  vector<pair<i64, i64>> ps;
  for (auto i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
  }

  i64 ans = 0;
  for (int sx : {-1, 1}) {
    for (int sy : {-1, 1}) {
      i64 ma = -2e9, mi = 2e9;
      for (auto [x, y] : ps) {
        ma = max(ma, x * sx + y * sy);
        mi = min(mi, x * sx + y * sy);
      }
      ans = max(ans, ma - mi);
    }
  }
  cout << ans;
}


Measured memory_bytes: 7452
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Virus Tree 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_K = 100000;
const int MOD = 1000000007;

/* typedef */

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

/* global variables */

vi nbrs[MAX_N];
int ps[MAX_N], cns[MAX_N], ds[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }
  
  ps[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u];
    vi &nbru = nbrs[u];

    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (v != up) {
	cns[u]++;
	ps[v] = u;
	q.push(v);
      }
    }
  }

  for (int u = 0; u < n; u++)
    if (cns[u] == 0) q.push(u);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = ps[u];
    vi &nbru = nbrs[u];

    ds[u] = 1;
    int m = k - (up >= 0 ? 2 : 1);
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (v != up) {
	if (m == 0) {
	  puts("0");
	  return 0;
	}

	ds[u] = (ll)ds[u] * m % MOD * ds[v] % MOD;
	m--;
      }
    }

    if (up >= 0 && --cns[up] == 0) q.push(up);
  }

  printf("%lld\n", (ll)ds[0] * k % MOD);
  return 0;
}


Measured memory_bytes: 7420
#include<stdio.h>

void bubbleSort(int,int[]);

int main(){

  int length;
  int data[100];
  int i = 0;

  scanf("%d",&length);


  for(i = 0; i < length; i++){

    scanf("%d",&data[i]);

  }

  bubbleSort(length,data);

  return 0;

}

void bubbleSort(int length, int data[]){

  int flag = 1;
  int j,change;
  int count = 0;

  
  while(flag){

    flag = 0;

    for(j = length-1; j !=0; j--){


      if(data[j] < data[j-1]){

	change = data[j-1];

	data[j-1] = data[j];

	data[j] = change;

	flag = 1;

	count = count + 1;

      }
    }
  }


  for(j = 0; j < length; j++){

    if(j != length-1){

    printf("%d ",data[j]);

  }

    else{

      printf("%d\n",data[j]);

    }

  }

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

}
 

Measured memory_bytes: 600
#include <stdio.h>

int main(){

	int  a=0,b=0,c=0;
	
	scanf("%d%d%d", &a, &b, &c);

	if (c == 1 || a == 1 && b == 1){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}

	return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#define N 20
#define M 31
using namespace std;
typedef pair<string,int> P;

int n,cnt[M],point[N],k,m,tim,minp;
vector<P> t[N];
string s;

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<M;i++)cnt[i]=0;
    for(int i=0;i<n;i++){
      cin>>s;
      cin>>m;
      t[i].push_back(P(s,-1));
      for(int j=0;j<m;j++){
	cin>>tim;
	t[i].push_back(P(s,tim));
	cnt[tim]++;
      }
      point[i]=0;
    }
    minp=(1e9);
    sort(t,t+n);
    for(int i=0;i<n;i++){
      for(int j=0;j<t[i].size();j++){
	int idx=t[i][j].second;
	if(idx==-1)continue;
	point[i]+=n-cnt[idx]+1;
      }
      minp=min(minp,point[i]);
    }
    for(int i=0;i<n;i++){
      if(minp==point[i]){
	cout<<minp<<' '<<t[i][0].first<<endl;
	break;
      }
    }
    for(int i=0;i<n;i++)t[i].clear();
  }
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
using namespace std;
int K, S;
int main() {
    cin >> K >> S;
    int cnt=0;
    for(int i=K; i>=0; --i){
        for(int j=0; j<=K; ++j){
            if(S-i-j<0||S-i-j>K) {
               continue;
            }else{
                cnt++;
            }
        }
    }
    cout << cnt <<endl;
    return 0;
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n; cin >> n;
    string s; cin >> s;
    char cur = s[0];
    int ans = 1;
    for(int i = 1; i < n; ++i){
        if(s[i] == cur){
            continue;
        }else{
            ++ans;
            cur = s[i];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

main()
{
	int Stu[30]={0},a,b;
	
	for(a=0;a<28;a++){
		scanf("%d",&b);
		Stu[b-1]=1;
	}
	
	for(a=0;a<30;a++){
		if(Stu[a]!=1){printf("%d\n",a+1);}
	}
	
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();

		long count = 0;
		count = b/x - a/x;

		if(a % x == 0 ){
			count = count + 1 ;
		}

		System.out.println(count);

	}
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> Dice;
//---------------------------------------
void roll_n(Dice &dice);
void roll_e(Dice &dice);
void roll_s(Dice &dice);
void roll_w(Dice &dice);

//---------------------------------------

int main(void)
{
	Dice dice;
	int num;
	string rolling;
	
	for(int i = 0; i < 6; i++){
		cin >> num;
		dice.push_back(num);
	}
	cin >> rolling;
	
	for(int i = 0; i < rolling.size(); i++){
	
		switch(rolling[i]){
		case 'N' :
			 roll_n(dice);
			 break;
		case 'E' :
			 roll_e(dice);
			 break;
		case 'S' :
			 roll_s(dice);
			 break;
		case 'W' :
			 roll_w(dice);
			 break;
		}
	}
	
	cout << dice[0] << endl;
	
	
	return 0;
	
}
//-------------------------------------
void roll_n(Dice &dice)
{
	Dice copy = dice;
	
	dice[4] = copy[0];
	dice[5] = copy[4];
	dice[1] = copy[5];
	dice[0] = copy[1];
}

//--------------------------------------
void roll_e(Dice &dice)
{
	Dice copy = dice;
	
	dice[0] = copy[3];
	dice[2] = copy[0];
	dice[5] = copy[2];
	dice[3] = copy[5];
}

//--------------------------------------
void roll_s(Dice &dice)
{
	Dice copy = dice;
	
	dice[1] = copy[0];
	dice[5] = copy[1];
	dice[4] = copy[5];
	dice[0] = copy[4];
}

//--------------------------------------
void roll_w(Dice &dice)
{
	Dice copy = dice;
	
	dice[3] = copy[0];
	dice[5] = copy[3];
	dice[2] = copy[5];
	dice[0] = copy[2];
}
/*
Top  [0]
Front [1]
Right [2]
Left [3]
Back [4]
Bottom [5]
*/

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

int n,m,a[305][305],cnt[305],used[305],ans=1e9;

int get(int l){
	for (int i=1;i<=m;++i){
		if (used[a[l][i]]) continue;
		return a[l][i];
	}
	return -1;
}

int main(){
	cin>>n>>m;
	for (int i=1;i<=n;++i){
		for (int j=1;j<=m;++j){
			scanf("%d",&a[i][j]);
		}
	}
	for (int i=1;i<=m;++i){
		memset(cnt,0,sizeof(cnt));
		for (int j=1;j<=n;++j){
			cnt[get(j)]++;
		}
		int Tans=0,id=0;
		for (int j=1;j<=m;++j){
			if (Tans<cnt[j]){
				Tans=cnt[j];
				id=j;
			}
		}
		ans=min(ans,Tans);
		used[id]=1;
		// cout<<id<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
    double a, b, c, d, e, f;
    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
        double x, y;
        x = (c * e / b - f) / (a * e / b - d);
        y = (c * d / a - f) / (b * d / a - e);
        if (-0.0005 < x && x <= 0)
            x = 0;
        if (-0.0005 < y && y <= 0)
            y = 0;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 652
#include <iostream>

int main() {

	int s, h, m, s2;

	std::cin >> s;
	h = s / 3600;
	m = (s % 3600) / 60;
	s2 = (s % 3600) % 60;


	std::cout << h << ":" << m << ":" << s2 << "\n";


}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(){
  int a,b;
  double ans;
  cin >> a >> b;
  ans = (a+b)%2;
  if(ans == 0) cout << (a+b)/2 << endl;
  else{
    a = (a+b)/2 + 1;
    cout << a << endl;
  }
}

Measured memory_bytes: 256
fun main() {
    val n = readLine()?.toInt() ?: return
    var c = 0L
    val memo = hashMapOf<Int, Boolean>()
    repeat(n) {
        val prev = memo.getOrDefault(it - 1, false)
        var a = readLine()?.toLong() ?: return
        if (prev && a > 0) {
            c++
            a--
        }
        c += a / 2
        memo[it] = a % 2 == 1L
    }
    println(c.toString())
}


Measured memory_bytes: 63408
#include <iostream>

using namespace std;

int main()
{
    string S, T;

    cin >> S;
    cin >> T;
    int count = 0;
    for (int i = 0; i < S.size(); i++){
        if(S[i] != T[i]){
            count++;
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll INF = 1e+18;

int main(){
    int N;
    ll C;
    ll ans=0;
    cin >>N>>C;
    vector<ll> x(N),v(N),L(N),R(N),L_MAX(N),R_MAX(N);
    rep(i,N) cin >> x[i] >> v[i];


    //時計回り
    L[0]=v[0]-x[0];
    L_MAX[0]=max((ll)0,L[0]);

    rep2(i,1,N){
        L[i]=L[i-1]+(v[i]-abs(x[i]-x[i-1]));
        L_MAX[i]=max(L_MAX[i-1],L[i]);
    }

    //反時計回り
    R[0]=v[N-1]-(C-x[N-1]);
    R_MAX[0]=max((ll)0,R[0]);
    
    rep2(i,1,N){
        R[i]=R[i-1]+(v[N-1-i]-abs(x[N-1-i]-x[N-i]));
        R_MAX[i]=max(R_MAX[i-1],R[i]);
    }

    ll tmp;
    //初手時計回り
    rep(i,N){//左番号iまで食べる
        tmp=L[i];
        if(i!=N-1) tmp+=max((ll)0,R_MAX[N-i-2]-x[i]);

        ans=max(tmp,ans);
    }

    //初手反時計回り
    rep(i,N){//右番号iまで食べる
        tmp=R[i];
        if(i!=N-1) tmp+=max((ll)0,L_MAX[N-i-2]-(C-x[N-i-1]));
        ans=max(tmp,ans);
    }

    cout << ans << endl;



}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<list>
#include<utility>
#include<string>

using namespace std;

list<int> l;

int main()
{
	cin.tie(0);
	ios::ios_base::sync_with_stdio(false);
	int orders, x; cin >> orders;
	string order;
	for (int i = 0; i < orders; ++i) {
		cin >> order;
		if (order[0] == 'i') {
			cin >> x;
			l.emplace_front(x);
		}
		else if (order[6] == 'F')l.pop_front();
		else if(order[6]=='L')l.pop_back();
		else{
			cin >> x;
			for (auto ite = l.begin(); ite != l.end(); ++ite) {
				if (*ite == x) {
					l.erase(ite);
					break;
				}
			}
		}
	}
	auto ite = l.begin();
	cout << *ite; ++ite;
	while (ite != l.end()) {
		cout <<" " << *ite;
		++ite;
	}cout << endl;
}

Measured memory_bytes: 32468
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def find_negative_loop(n,w,es):
  dist=[float("inf")]*n
  #この始点はどこでもよい
  dist[1]=0
  
  for i in range(n):
    for j in range(w):
      e=es[j]
      if dist[e[1]]>dist[e[0]]+e[2]:
        dist[e[1]]=dist[e[0]]+e[2]
        if i==n-1:
          return True
  return False

def shortest_path(s,n,w,es):
  #s→iの最短距離
  #s:始点, n:頂点数, w:辺の数, es[i]:[辺の始点,辺の終点,辺のコスト]
  dist=[float("inf")]*n
  #d[i]: s→iの最短距離
  dist[s]=0

  while True:
    update=False
    for p,q,r in es:
      # e: 辺iについて [from,to,cost]
      if dist[p]!=float("inf") and dist[q]>dist[p]+r:
        dist[q]=dist[p]+r
        update=True
    if not update:
      break
      
  return dist

graph=[[] for _ in range(N+1)]
elist=[]
for _ in range(M):
  a,b,c=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b,-c))
  
#remove unnecessary vertex and edge
visited=[None]*(N+1)
def check_reachable(u):
  if u==N:
    reachable[u]=True
    return True
  
  visited[u]=True
  cnt=0
  for v in graph[u]:
    if not visited[v]:
      ret=check_reachable(v)
      if ret:
        reachable[u]=True
        cnt+=1
        
  if cnt>0:
    return True
  else:
    return False

reachable=[None]*(N+1)
for i in range(1,N+1):
  if reachable[i]==None:
    visited=[False]*(N+1)
    check_reachable(i)
#print(reachable)
  
elist2=[]
for a,b,nc in elist:
  if reachable[b]:
    elist2.append((a,b,nc))
  
M2=len(elist2)
res1=find_negative_loop(N+1,M2,elist2)

if res1:
  print("inf")
else:
  res2=shortest_path(1,N+1,M2,elist2)
  print(-res2[N])

Measured memory_bytes: 4340
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    if((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) 
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128