akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n+1];
  for(int i=1;i<=n;i++)
    cin>>arr[i];
  
  int dp[k+1][n+1];
  for(int i=0;i<=k;i++)
    dp[i][0]=2;
  for(int j=0;j<=n;j++)
    dp[0][j]=2;
  
  
  for(int i=1;i<=k;i++)
  {
    for(int j=1;j<=n;j++)
    {
     if(i<arr[j])
     {
       dp[i][j]=2;
     }
      else
      {
        int s=i-arr[j];
        if(dp[s][0]==1)
          dp[i][j]=2;
        else
        {
          dp[i][j]=1;
          dp[i][0]=1;
        }
          
      }
      
        
    }
  }
  
 /** for(int i=0;i<=k;i++)
  {
    for(int j=0;j<=n;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }**/
 	string ans="";
  if(dp[k][0]==1)
    ans="First";
  else
    ans="Second";
  
  cout<<ans<<endl;

   
  
  return 0;
}

Measured memory_bytes: 39680
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[300010];
int mod;
char s[300010]; 
int mp[10010];
int main(){
	int n;
    while(cin>>n>>mod){
    	scanf("%s",s);
    	reverse(s, s+n);
    	if(10%mod==0){
    		ll ans=0;
    		if(mod==10){
    			for(int i=0; i<n; ++i){
    				if(s[i]=='0'){
    					ans+=n-i;
    				}
    			}
    		}
    		else if(mod==2){
    			for(int i=0; i<n; ++i){
    				if((s[i]-'0')%2==0){
    					ans+=n-i;
    				}
    			}
    		}
    		else{
    			for(int i=0; i<n; ++i){
    				if(s[i]=='0' || s[i]=='5'){
    					ans+=n-i;
    				}
    			}
    		}
    		cout<<ans<<endl;
    		continue;
    	}
    	int tmp=1, tmp1=0;
    	for(int i=0; i<n; ++i){
    		a[i]=s[i]-'0';
    		tmp1+=tmp*(a[i]);
    		tmp*=10;
    		tmp%=mod;
    		tmp1%=mod;
    		++mp[tmp1];
    	}
    	ll ans=mp[0];
    	tmp=1;
    	tmp1=0;
    	for(int i=0; i+1<n; ++i){
			tmp1+=a[i]*tmp;
			tmp*=10;
			tmp%=mod;
			tmp1%=mod;
			--mp[tmp1];
			ans+=mp[tmp1];
			for(int j=mod; j/(10%mod)<mod; j+=mod){
				if(j%(10%mod)==0){
					ans-=mp[j/(10%mod)];
				}
			}
    	}
    	cout<<ans<<endl;
    }
  return 0;
}




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

ll gcd(ll a , ll b){
    ll r = b%a;
    while(r!=0){
        b = a;
        a = r;
        r = b%a;
    }
    return a;
}

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll lcm = C*D/gcd(C,D);
    ll ans1 = (A-1) - (A-1)/C - (A-1)/D + (A-1)/lcm;
    ll ans2 = B - B/C - B/D + B/lcm;
    cout << ans2 - ans1 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int a,b,X,Y,r,c=0;



scanf("%d %d",&a,&b);

while(a!=0 && b!=0){
if(a<b){
X=b;
Y=a;
}
else{
X=a;
Y=b;
}
c=0;

for( ;Y!=0; )
{

r=X%Y;
X=Y;
Y=r;
c=c+1;
}


printf("%d %d\n",X,c);
scanf("%d %d",&a,&b);
}
return (0);
}





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

int main(){

    int result=0;
    for(int i=1; i<10; i++)
    {
        for(int j=1; j<10; j++)
        {
            result+=i;
            cout<<i<<"x"<<j<<"="<<result<<endl;
        }
        result=0;
    }

    return 0;
}



Measured memory_bytes: 3084
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*N
for i in range(0, N-1):
    B[i] = abs(A[i+1]-A[i])
B[N-1] = K + A[0] - A[N-1]
print(K-max(B))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int f(ll x){
    if(x==0) return 0;
    int ans = 1;
    int p = __builtin_popcount(x);
    while((x%p)){
        x = (x%p);
        p = __builtin_popcount(x);
        ans++;
    }
    return ans;
}


int main(void)
{
    int N;
    cin >> N;
    string X;
    cin >> X;
    reverse(ALL(X));
    
    ll n = 0;
    REP(i, N) if(X[i]=='1') n++;

    vector<ll> x0(N), x1(N);
    x0[0] = x1[0] = 1;
    Rep(i, 1, N){
        x0[i] = (x0[i-1]*2) % (n+1);
        if(n!=1) x1[i] = (x1[i-1]*2) % (n-1);
    }

    ll X0 = 0, X1 = 0;
    REP(i, N){
        if(X[i]=='1'){
            (X0 += x0[i]) %= (n+1);
            if(n!=1) (X1 += x1[i]) %= (n-1);
        }
    }

    vector<int> ans;
    REP(i, N){
        if(X[i]=='0'){
            ll tmp = X0;
            (tmp += x0[i]) %= (n+1);
            ans.pb(f(tmp));
        }else{
            if(n==1){
                ans.pb(-1);
                continue;
            }
            ll tmp = X1;
            ((tmp -= x1[i]) += (n-1)) %= (n-1);
            ans.pb(f(tmp));
        }
    }
    reverse(ALL(ans));
    REP(i, N){
        pr(ans[i]+1);
    }
}

Measured memory_bytes: 7664
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String tapDance = sc.next();
        boolean returnBoo = true;
        String[] tapDanceAr = tapDance.split("");
        for(int i = 0;i < tapDanceAr.length;i++){
            if(tapDanceAr[i].equals("R") || tapDanceAr[i].equals("U") || tapDanceAr[i].equals("L") ||tapDanceAr[i].equals("D")){
                if(i % 2 == 0){
                    if(tapDanceAr[i].equals("L") ){
                        returnBoo = false;
                        break;
                    }
                } else{
                    if(tapDanceAr[i].equals("R") ){
                        returnBoo = false;
                        break;
                    }
                }          
            } else{
                returnBoo = false;
                break;
            }
        }

        if(returnBoo){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define int long long

main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 0;
		return 0;
	}
	cout << (n - k + 1) - 1;	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define db double
#define il inline
#define re register
#define mkpr make_pair

using namespace std;
const int N=300+10,mod=1e9+7;
il LL rd()
{
    LL x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
int f[N][N][N],n,m,s[3];
struct qu
{
	int l,r,z;
	bool operator < (const qu &bb) const {return r<bb.r;}
}qq[N];
bool ck(int l,int r)
{
	for(int i=l;i<=r;++i)
	{
		int cn=0;
		for(int j=0;j<3;++j) cn+=s[j]>=qq[i].l;
		if(cn!=qq[i].z) return 0;
	}
	return 1;
}

int main()
{
	n=rd(),m=rd();
	for(int i=1;i<=m;++i) qq[i].l=rd(),qq[i].r=rd(),qq[i].z=rd();
	sort(qq+1,qq+m+1);
	f[0][0][0]=1;
	for(int i=0,h=1;i<n;++i)
	{
		int l=h,r=h-1;
		while(r<=m&&qq[r+1].r==i+1) ++r;
		for(int j=0;j<=i;++j)
			for(int k=0;k<=j;++k)
			{
				if(!f[i][j][k]) continue;
				s[0]=i+1,s[1]=j,s[2]=k;
				if(ck(l,r)) f[s[0]][s[1]][s[2]]=(f[s[0]][s[1]][s[2]]+f[i][j][k])%mod;
				s[0]=i+1,s[1]=i,s[2]=k;
				if(ck(l,r)) f[s[0]][s[1]][s[2]]=(f[s[0]][s[1]][s[2]]+f[i][j][k])%mod;
				s[0]=i+1,s[1]=i,s[2]=j;
				if(ck(l,r)) f[s[0]][s[1]][s[2]]=(f[s[0]][s[1]][s[2]]+f[i][j][k])%mod;
			}
		h=r+1;
	}
	int ans=0;
	for(int j=0;j<=n;++j)
		for(int k=0;k<=j;++k)
			ans=(ans+f[n][j][k])%mod;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 112896
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,t;

ll a[100005],b[100005],c[100005],s;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.in");
#endif
	
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	for(int i=1;i<=n;i++){
		cin >> b[i];
		if(a[i]>=b[i]) c[i]=a[i]-b[i];
		else s+=b[i]-a[i],t++;
	}
	sort(c+1,c+n+1);
	for(int i=n;i>=1;i--){
		if(s<=0) break;
		s-=c[i];
		t++;
	}
	if(s>0) cout << -1;
	else cout << t;
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0*clock()/CLOCKS_PER_SEC << " \n";
#endif
}


Measured memory_bytes: 2560
package main

import "fmt"

type Combination struct {
	n int
	f *Factorial
}

func NewCombination(n int, m int64) *Combination {
	f := NewFactorial(n, m)
	return &Combination{n, f}
}

func (c *Combination) Combination(n, k int) int64 {
	return c.f.F[n] * c.f.Inv[k] % c.f.Mod * c.f.Inv[n-k] % c.f.Mod
}

func (c *Combination) Permutation(n, k int) int64 {
	return c.Combination(n, k) * c.f.F[k] % c.f.Mod
}

func (c *Combination) Factorial(n int) int64 {
	return c.f.F[n]
}

type Factorial struct {
	n      int
	Mod    int64
	F, Inv []int64
}

func NewFactorial(n int, m int64) *Factorial {
	f := Factorial{n, m, nil, nil}
	f.F = make([]int64, n+1)
	f.Inv = make([]int64, n+1)
	f.F[0] = 1
	for i := 1; i <= n; i++ {
		f.F[i] = f.F[i-1] * int64(i) % f.Mod
	}
	f.Inv[n] = pow(f.F[n], f.Mod-2, f.Mod)
	for i := n; i > 0; i-- {
		f.Inv[i-1] = f.Inv[i] * int64(i) % f.Mod
	}
	return &f
}

func pow(x, n, m int64) int64 {
	if n == 0 {
		return 1
	}
	if n&1 == 0 {
		r := pow(x, n/2, m)
		return r * r % m
	}
	return x * pow(x, n-1, m) % m
}

func div(x, n, m int64) int64 {
	return x * pow(n, m-2, m) % m
}

func main() {
	var n, m int
	const M int64 = int64(1e9) + 7
	fmt.Scan(&n, &m)
	c := NewCombination(m, M)
	var ret int64
	for i := 0; i <= n; i++ {
		v := c.Combination(n, i)
		v *= c.Permutation(m, i)
		v %= M
		var r int64 = 1
		if i < m {
			r = c.Permutation(m-i, n-i)
		}
		v *= r * r % M
		v %= M
		if i%2 == 1 {
			v = M - v
		}
		ret += v
		ret %= M
	}
	fmt.Println(ret)
}


Measured memory_bytes: 9956
#include<stdio.h>

void leap_year(int start_year, int end_year);

int main(void)
{
    int start_year;
    int end_year;
    int i = 0;
    while(1) {
        scanf("%d %d", &start_year, &end_year);
        if (start_year == 0 && end_year == 0) {
            break;
        } else {
            if ( i == 1) {
                printf("\n");
            }
            leap_year(start_year, end_year);
            i = 1;
        }
    }
    return 0;
}

void leap_year(int start_year, int end_year)
{
    int n = 0;
    int year = start_year;
    while (year <= end_year) {
        if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
            printf("%d\n", year);
            n++;
        }
        year++;
    }
    if (n == 0) {
    printf("NA\n");
    }
}

 

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


int main(){
    int64_t result=0;
    int N,A,highest;
    cin>>N;
    cin>>A;
    highest=A;
    for(int i=1;i<N;i++){
        cin>>A;
        if(highest<=A){
            highest=A;
            continue;
        }
        else{
            result+=highest-A;
        }
    }
    cout<<result<<endl;
}

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

void solve(long long A, long long B)
{
    if (A - B * 2 <= 0)
        cout << 0 << endl;
    else
        cout << A - B * 2 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		double[] p=new double[n];
		for (int i=0;i<n;++i)
			p[i]=in.nextDouble();
		double[][] dp=new double[n+1][n+1];
		dp[0][0]=1;
		for (int i=0;i<=n;++i)
			for (int j=0;j<=n;++j) if (i>0||j>0) {
				if (i+j>n) break;
				int t=i+j-1;
				if (i>0) dp[i][j]+=dp[i-1][j]*p[t];
				if (j>0) dp[i][j]+=dp[i][j-1]*(1-p[t]);
			}
		double res=0;
		for (int i=n/2+1;i<=n;++i)
			res+=dp[i][n-i];
		System.out.printf("%.12f\n",res);
	}
}

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

const ll mod = 1e9 + 7;

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

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

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

    int n, k, s;
    cin >> n >> k >> s;
    rep(i, k) cout << s << " ";
    rep(i, n - k) cout << (s == 1e9 ? 1 : s + 1) << " ";
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<1200){
        cout<<"ABC"<<endl;
    }
    else if(n<2800){
        cout<<"ARC"<<endl;
    }
    else {
        cout<<"AGC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    //let n = s.len();
    //let mut pos = 0;
    //let mut a = 0;
    //let mut ans = 0;
    //while pos < n {
        //if s[pos] == 'A' {
            //a += 1;
        //} else if pos + 1 < n && s[pos] == 'B' && s[pos + 1] == 'C' {
            //ans += a;
            //pos += 1;
        //} else {
            //a = 0;
        //}
        //pos += 1;
    //}
    //println!("{}", ans);
    let n = s.len();
    let mut result = 0usize;
    let mut i = 0;
    let mut a = 0;
    while i < n {
        if s[i] == 'A' {
            a += 1;
        } else if i + 1 < n && s[i] == 'B' && s[i + 1] == 'C' {
            result += a;
            i += 1;
        } else {
            a = 0;
        }
        i += 1;
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>                      
using namespace std;                          
int main()                                    
{                                             
    int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
        int MAX = max(a,c);                   
        int MIN = min(b,d);                   
    if(MIN-MAX<=0) printf("0\n");             
    else                                      
        printf("%d\n",MIN - MAX);             
                                              
    return 0;                                 
}                                             

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){ 
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll ans = 0,mx = a[0];
    for (int i = 1; i < n; i++)
    {
        if(a[i]<mx)ans += mx-a[i];
        else mx = max(mx,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4836
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    A--; B--; C--; D--;

    if (C < D) {
        //普通にBから移動
        bool ok_B = true;
        for (ll i = B + 1; i < D; i++) {
            if (S[i] == '#' && S[i + 1] == '#') {
                ok_B = false;
                break;
            }
        }

        bool ok_A = true;
        for (ll i = A + 1; i < C; i++) {
            if (S[i] == '#' && S[i + 1] == '#') {
                ok_A = false;
                break;
            }
        }

        cout << (ok_A && ok_B ? "Yes" : "No") << endl;
    } else {
        //普通にBから移動
        bool ok_B = false;
        for (ll i = B; i <= D; i++) {
            //左右が空ならOK
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                ok_B = true;
                break;
            }
        }

        bool ok_A = true;
        for (ll i = A + 1; i < C; i++) {
            if (S[i] == '#' && S[i + 1] == '#') {
                ok_A = false;
                break;
            }
        }

        cout << (ok_A && ok_B ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<functional>
#include<unordered_map>
#include<unordered_set>

using ll = long long;
using namespace std;

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

    vector<string> s(n);

    for( int i = 0; i < n; ++i) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    // unordered_set<string> cache;
    unordered_map<string, int> cache;

    // sort(s.begin(), s.end());

    ll ans = 0;
    for( int i = 0; i < n; ++i) {
        if ( cache.count(s[i]) == 0) {
            cache[s[i]]++;
        } else {
            ans += cache[s[i]]++;
        }
        // for(int j = i +1; j < n; ++j) {
        //     if (cache.count(s[j])!= 0) {
        //         ans++;
    //     }

            /*
            else if (s[i] == s[j]) {
                ans++;
                cache.insert(s[i]);
            } 
            */
            
            //else {
             //   break;
            //}
        // }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17700
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(20)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

ld calcAngle(ld h, ld m) {
	if (h == 12) h = 0;
	if (m == 60) m = 0;

	ld hour_angle = 0.5 * (h * 60 + m);
	ld minute_angle = 6 * m;

	ld angle = abs(hour_angle - minute_angle);

	angle = min(360 - angle, angle);

	return angle;
}

void solve() {
	ld a, b, h, m;
	cin >> a >> b >> h >> m;
	ld ang = calcAngle(h, m);
	ang = ang * M_PI / 180;
	ld ans = (2 * a * b) * cos(ang);
	cout << prec << sqrt((a * a + b * b) - ans);
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

Measured memory_bytes: 4180
S = input()

ans = "No"
if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]: 
  ans = "Yes"
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]: 
  ans = "Yes"
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]: 
  ans = "Yes"
  
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int gcd(int a,int b)
{
	int r=1;
	if(b == 0)
		return a;
	if(a == 0)
		return b;
	while(r!=0){
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main()
{
	int n, i;
	scanf("%d", &n);
	int a[100000], b[100000], c[100000];
	lop(i, n){ scanf("%d", &a[i]); }
	
	b[0]=0, c[0]=0;
	int max=0;
	
	lop(i, n){ b[i+1]=gcd(b[i], a[i]); }
	lop(i, n){ c[i+1]=gcd(c[i], a[n-i-1]); }
	
	lop(i, n){
		int x;
		x=gcd(b[i], c[n-i-1]);
		if(x>max) max=x;
	}
	
	printf("%d", max);
	
return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

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

Measured memory_bytes: 256
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(arr):
  ans = 1
  for i in arr:
    ans = (ans*i)//gcd(ans,i)
  return ans
n = int(input())
arr = list(map(int,input().split())) #list(map(int, input().split()))
l = lcm(arr)
ans = 0;
for i in arr:
  ans+= l//i
print(ans%(10**9+7))


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

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

int visit[3][100005];
int n, k;

int main()
{
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>arr[i];
    }
    int Ans = 0;
    int mx = arr[0];
    for(int i=0 ; i<n ; i++){
        if(mx >= arr[i]) Ans++;
        mx = min(mx, arr[i]);
    }
    cout<<Ans<<endl;

    return 0;
}





Measured memory_bytes: 15872
#include <iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include <cmath>
using namespace std;
const long long N = 100005;
long long M= 1000000007;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	pair<string,pair<int,int>>p[105];
	for (int i = 0; i < n; i++) {
		int r;
		string l;
		cin >> l >> r;
		p[i] = make_pair(l, make_pair(-r,i));
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		cout << p[i].second.second+1<<endl;
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int num;
while(true)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans / (num - 2) << endl;
}
else
{
return 0;
}
}
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>
 
int main()
{
  	char Str1[1300];
  	int i = 0; 
  	while(fgets(Str1, 1300, stdin))
  	{
  		for(i=0;i<strlen(Str1);i++)
  		if(Str1[i] >= 'a' && Str1[i] <= 'z')
  		{
  			Str1[i] -= 32;
		}	
  		else if(Str1[i] >= 'A' && Str1[i] <= 'Z')
  		{
  			Str1[i] += 32;
		}
		printf("%s", Str1);	
  	}
  	return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
//#pragma GCC optimize 3
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
int dirx[4] = {-1,1,0,0};//four directions
int diry[4] = {0,0,-1,1};//four directions
//int dirx[8]={0,0,-1,1,1,1,-1,-1};//eight directions
//int diry[8]={1,-1,0,0,-1,1,-1,1};//eight directions
#define inf 0x3f3f3f3f
//#define inf 0x7fffffff
#define prev PrEv
#define next NeXt
#define rank RaNk
#define left LeFt
#define right RiGhT
#define list LiSt
//#define map MaP
#define debug(x) cerr << #x << "=" << x << endl
// freopen("in.txt","r",stdin);
// ios::sync_with_stdio(false);
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
vector<pair<int, int> > rec;
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    cin >> n;
    int k = (n % 2 == 1) ? n : n + 1;
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j)
            if(i + j != k)
                rec.push_back({i, j});
    cout << rec.size() << endl;
    for(int i = 0; i < rec.size(); ++i)
        cout << rec[i].first << " " << rec[i].second << endl;
    return 0;
}








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

int main(){
  int A,B,K;
  cin >> A >> B >> K;

  for(int i=min(A,B); i>=1; --i){
    if(A%i==0 && B%i==0){
      --K;
      if(K==0){
        cout << i << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a[m+1][n+1];
    int k[m],p[m];
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>a[i][j];
            a[i][j]--;
        }
    }
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    int ans=0;

    for(int i=0;i<(1<<n);i++){
        vector<int> v;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                v.pb(1);
            }
            else{
                v.pb(0);
            }

        }
        bool maki=true;
        for(int j=0;j<m;j++){
            int num=0;
            for(int x=0;x<k[j];x++){
                if(v[a[j][x]]==1){
                    num++;
                }

            }
            if((num%2)!=p[j]){
                maki=false;
            }
        }
        if(maki==true){
            ans++;
        }
    }
    cout << ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
  int n,k;
  cin >> n >> k;
  int ans = n / 2;
  if (n % 2 != 0) {
    ans++;
  }

  if (k <= ans) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << endl;
}

Measured memory_bytes: 256
function main(input){
  const N=input.trim();
  const S = N.split('');
  var result = [];
  for(var i=0;i<S.length;i++){
    if(S[i]=='9'){
      result.push('1');
    }else{
      result.push('9');
    }
  }
  console.log(result.join(''));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

ll cx(ll n) {
    ll ret = (n ^ (n >> 1)) & 1LL;
    for (ll i = 1; (1LL << i) <= n; ++i) {
        ret |= ~(n << i) & n & (1LL << i);
    }
    return ret;
}

int main() {
    ll a, b;
    cin >> a >> b;

    cout << (cx(b) ^ (cx(a) ^ a)) << endl;

    return 0;
}


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

int main() {
  int N=0,x=0,y=0,z=0,a=0,b=0;
  cin>>N;//148
  b=N;
  for(x=0;x<8;x++){
   if(x!=0){
  	b=y;
  }
    z=b%10;//
    y=b/10;
    a+=z;
    if(y==0)
      break;	
  }
  if(N%a){
  	cout<<"No";
  }else{
    cout<<"Yes";
  }
  
}

Measured memory_bytes: 256
/*
    author: Salam_35
    problem name: The Knapsack Problem
*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define load(array,size)  for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(int i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>

ll s,n;
ll price[2005],weight[2005];

ll dp[150][100050];

ll solve(ll i, ll w)
{
    int profit1=0,profit2=0;
    if(i==(n+1))
        return 0;

    if(dp[i][w]!=-1) return dp[i][w];
    if(w+weight[i]<=s)
       return dp[i][w] =max( solve(i+1,w), price[i]+solve(i+1,w+weight[i]));
    else
        return dp[i][w]=solve(i+1,w);
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n >> s;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin >> weight[i] >> price[i];
    }
    cout<<solve(0,0)<<endl;
}

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

int main() {

int D;
cin >> D ;

int c[26+1]; //満足度の下がりやすさ
for(int i = 1; i < 26+1 ; i++){
  cin >> c[i];
}

int s[D+1][26+1]; //満足度の増加量(D日目,タイプ)
for(int i = 1; i < (D+1); i ++){
  for(int j = 1; j <26+1; j++){
    cin >> s[i][j];
  }
}

int S = 0; //満足度

int t[D+1]; //d日目に開催するコンテストのタイプ
for(int i = 1; i < (D+1); i++){
    cin >> t[i];
}

int last[26+1] = {};//最後にコンテストを開催した日

for(int d=1; d < (D+1); d++){
  S += s[d][t[d]];
  last[t[d]] = d;
  for(int i=1; i < 26+1; i++){
      S -= c[i] * (d - last[i]);
  }
  cout << S <<endl;
}

return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cout << #x << " = " << (x) << "\n"
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int N, M, r, q;
int students[ 10001 ][ 1262 ] = {};

void solve() {
  while ( cin >> N >> M && N && M ) {
    cin >> r;
    CLR( students );
    while ( r-- ) {
      int t, n, m, s;
      cin >> t >> n >> m >> s;
      if ( s ) {
        students[ m ][ t + 1 ]++;
      }
      else {
        students[ m ][ t + 1 ]--;
      }
    }
    for ( int i = 1; i <= M; i++ ) {
      for ( int j = 540; j < 1262; j++ ) {
        students[ i ][ j ] += students[ i ][ j - 1 ];
      }
    }
    cin >> q;
    while ( q-- ) {
      int s, g, m, ans = 0;
      cin >> s >> g >> m;
      for ( int i = s + 1; i <= g; i++ ) {
        ans += !!students[ m ][ i ];
      }
      cout << ans << "\n";
    }
  }
}

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

Measured memory_bytes: 50508
#include<stdio.h>

void swap(int a[],int i,int j){
	int t=a[i];
	a[i]=a[j];
	a[j]=t;
}

void qsort(int a[],int left,int right){
	int i=left,j=right,p=a[(left+right)/2];
	
	while(1){
		while(a[i]>p) i++;
		while(p>a[j]) j--;
		if(i>=j) break;
		swap(a,i,j);
		i++;
		j--;
	}

	if(left<i-1) qsort(a,left,i-1);
	if(j+1<right) qsort(a,j+1,right);
}

int main(void){
	int N,i,min,j;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	while(1){
		qsort(A,0,N-1);
		if(A[1]==0) break;
		for(i=N-1;i>=0;i--){
			if(A[i]!=0){
				min=A[i];
				break;
			}
		}
		for(j=0;j<=i-1;j++) A[j]%=min;
	}
	
	printf("%d",A[0]);
}

Measured memory_bytes: 512
var
	n:Smallint;
begin
    read(n);
    if n=0 then begin
        write(0)
    end
    else if n<=1000 then begin
        write(1000-n)
    end
    else if n<=2000 then begin
        write(2000-n)
    end
    else if n<=3000 then begin
        write(3000-n)
    end
    else if n<=4000 then begin
        write(4000-n)
    end
    else if n<=5000 then begin
        write(5000-n)
    end
    else if n<=6000 then begin
        write(6000-n)
    end
    else if n<=7000 then begin
        write(7000-n)
    end
    else if n<=8000 then begin
        write(8000-n)
    end
    else if n<=9000 then begin
        write(9000-n)
    end
    else begin
        write(10000-n)
    end;
end.

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

int main() {
  int N, K, P,Q;
  cin >> N >> K;
  P=1;
  Q=1;
  while(N-Q>=0){
    if(P<K){
      P=P*2;
      Q++;
     }
  
  else if(P>=K){
    P=P+K;
    Q++;
   }
  }
  cout << P << endl;
}


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

using namespace std;
const long long MOD=1e9+7;
int n,k,a[105];
long long f[105][100005],s[100005];
long long dq(int i, long long s)
{
    if (i>n)
    {
        return int(s==k);
    }
    if (s>k) return 0;
    if (f[i][s]!=-1) return f[i][s];
    long long x=0;
    for(int j=0;j<=a[i];j++)
        x=(x+dq(i+1,s+j))%MOD;
    return f[i][s]=x;
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=0;i<=k;i++) f[0][i]=0;
    for(int i=0;i<=n;i++) f[i][0]=1;
    for(int i=1;i<=n;i++)
    {
        s[0]=0;
        for(int j=1;j<=k+1;j++)
            s[j]=s[j-1]+f[i-1][j-1];
        for(int j=1;j<=k;j++)
        {
            f[i][j]=(s[j+1]-s[max(0,j-a[i])])% MOD;
        }
    }
    cout<<f[n][k];
    //memset(f,-1,sizeof(f));
    //cout<<dq(1,0);
    return 0;
}


Measured memory_bytes: 80128
#include <stdio.h>

int isPrime(int x) {
  int i;
  if (x == 1) return 0;
  if (x == 2) return 1;
  if (x == 3) return 1;
  if (x % 2 == 0) return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0) return 0;
  return 1;
}

int main(void) {
  int a, d, n, c;

  while (1) {
    scanf("%d %d %d", &a, &d, &n);
    if (a == 0 && d == 0 && n == 0) break;

    c = 0;
    while (1) {
      if(isPrime(a)) c++;
      if (c == n) break;
      a += d;
    }

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

Measured memory_bytes: 600
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		int N;
		
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			N = sc.nextInt();
			
			if(N == 0)
				break;
			
			int[][] array = new int[N+1][N+1];
			
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					array[i][j] = sc.nextInt();
					array[i][N] += array[i][j];
					array[N][j] += array[i][j];
					array[N][N] += array[i][j];
				}
			}
			
			for(int i = 0; i < N + 1; i++){
				for(int j = 0; j < N + 1; j++){
					System.out.printf("%5d",array[i][j]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 22152
n = int(input())
a = list(map(int, input().split()))
a.sort()

for _ in range(10**12):
    if len(a)==1:
        print(a[0])
        exit()
    z=0
    for i in range(1,len(a)):
        tmp = a[i]%a[0]
        if tmp==0:
            z+=1
        a[i]=tmp
    a.sort()
    a=a[z:]


Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
string c;
int n;
int k;
set <string> squ;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>c;
	n=c.size();
	cin>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i+j>n) break;
			squ.insert(c.substr(i,j));
		}
	}
	k--;
	while(k--)
	{
		string c=*squ.begin();
//		cout<<c<<endl;
		squ.erase(c);
	}
	cout<<*squ.begin()<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void) {
	double w;
	while(scanf("%lf",&w) != EOF){
		if(w <= 48.00){
			printf("light fly\n");
		}
		if(48.00 < w && w <= 51.00){
			printf("fly\n");
		}
		if(51.00 < w && w <= 54.00){
			printf("bantam\n");
		}
		if(54.00 < w && w <= 57.00){
			printf("feather\n");
		}
		if(57.00 < w && w <= 60.00){
			printf("light\n");
		}
		if(60.00 < w && w <= 64.00){
			printf("light welter\n");
		}
		if(64.00 < w && w <= 69.00){
			printf("welter\n");
		}
		if(69.00 < w && w <= 75.00){
			printf("light middle\n");
		}
		if(75.00 < w && w <= 81.00){
			printf("middle\n");
		}
		if(81.00 < w &&  w <= 91.00){
			printf("light heavy\n");
		}
		if(91.00 < w){
			printf("heavy\n");
		}
	}
	return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

double DIST;

struct Point{
	double x,y;
};

double dot(Point a,Point b){
	return a.x*b.x + a.y*b.y;
}

double calc_len(Point a){
	return sqrt(a.x*a.x+a.y*a.y);
}

void func(){

	Point p,v;

	scanf("%lf %lf %lf %lf",&p.x,&p.y,&v.x,&v.y);

	double cos_value = dot(p,v)/(calc_len(p)*calc_len(v));

	double ans;
	if(fabs(cos_value+1.0) < EPS){
		ans = calc_len(p);
	}else if(fabs(cos_value-1.0) < EPS){
		ans = 2.0-calc_len(p);
	}else{
		ans = DBL_MAX;
	}

	if(ans <= DIST){
		printf("%.10lf\n",ans);
	}else{
		printf("impossible\n");
	}
}

int main(){

	while(true){
		scanf("%lf",&DIST);
		if(fabs(DIST) < EPS)break;

		func();
	}

	return 0;
}

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

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int main(){
  int X;
  cin >> X;
  int i = X;
  int ans = 0;

  while(true){
      if(is_prime(i)){
        ans = i;
        break;
      }
      i++;
  }
  cout << i << endl;

 }

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

int main() {
  
  int N ;
  cin >> N ;
  string S ;
  cin >> S ; 
  int ans = N ;
  int counter = 0 ;
  rep(i,N-1){
    if( S[i] == S[i+1] ) counter++ ;
    else{
      ans -= counter ;
      counter = 0 ;
    }
    if (i == N-2 ) ans -= counter ;
}
   cout << ans << endl; 
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN


int main() {
	ll n,m,q,l,r,a[100010],b[100010],dp[510][510];
	cin>>n>>m>>q;
	reg(i,0,n)reg(j,0,n)dp[i][j]=0;
	for(ll i=0;i<m;i++){
		cin>>l>>r;
		dp[l][r]++;
	}
	//累積和
	for(r=1;r<=n;r++){
		for(l=1;l<=n;l++){
			dp[l][r]+=dp[l][r-1];
		}
	}
	for(l=n;l>=1;l--){
		for(r=1;r<=n;r++){
			dp[l][r]+=dp[l+1][r];
		}
	}
	rep(i,q)cin>>a[i]>>b[i];
	rep(i,q){
		cout<<dp[a[i]][b[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define STEP 0.0005
// sort(a.begin(), a.end(), std::greater<int>());

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main()
{
    string a;
    cin >> a;
    while (a.size() != 0)
    {
        if (a.size() >= 7)
        {
            auto temp = a.substr(a.size() - 7, 7);
            if (temp == "dreamer")
            {
                a = a.substr(0, a.size() - 7);
                continue;
            }
            //check dreamer
        }
        if (a.size() >= 6)
        {
            auto temp = a.substr(a.size() - 6, 6);
            if (temp == "eraser")
            {
                a = a.substr(0, a.size() - 6);
                continue;
            }
        }
        if (a.size() >= 5)
        {
            auto temp = a.substr(a.size() - 5, 5);
            if (temp == "dream")
            {
                a = a.substr(0, a.size() - 5);
                continue;
            }
            if (temp == "erase")
            {
                a = a.substr(0, a.size() - 5);
                continue;
            }
        }
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
int qread()
{
	char c; int s=0,t=1; while ((c=getchar())<'0' || c>'9') (c=='-') && (t=-1);
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s*t;
}
 
//Pay attention to read!
 
int n;
#define maxn 211
struct Edge{int to,next;}edge[maxn]; int first[maxn],le=2;
void in(int x,int y) {Edge &e=edge[le]; e.to=y; e.next=first[x]; first[x]=le++;}
void insert(int x,int y) {in(x,y); in(y,x);}
 
int du[maxn];
int ans1,ans2; int dep;
void dfs(int x,int fa,int ddd)
{
	dep=max(dep,ddd);
	int now=0;
	for (int i=first[x];i;i=edge[i].next)
	{
		Edge &e=edge[i]; if (e.to==fa) continue;
		dfs(e.to,x,ddd+1); now++;
	}
	du[ddd]=max(du[ddd],now);
}
void calc(int x)
{
	dep=0; memset(du,0,sizeof(du)); dfs(x,0,1);
	int pp=1; for (int i=dep-1;i;i--) {pp*=du[i];}
	if (dep<ans1)
	{
		ans1=dep;
		ans2=pp;
	}
	else if (dep==ans1) ans2=min(ans2,pp);
}
void calc(int x,int y)
{
	dep=1; memset(du,0,sizeof(du)); dfs(x,y,2); dfs(y,x,2); du[1]=2;
	int pp=1; for (int i=dep-1;i;i--) {pp*=du[i];}
	if (dep-1<ans1)
	{
		ans1=dep-1;
		ans2=pp;
	}
	else if (dep-1==ans1) ans2=min(ans2,pp);
}
	#undef int 
int main()
#define int long long
{
	n=qread();
	for (int i=1,x,y;i<n;i++) {x=qread(); y=qread(); insert(x,y);}
	
	ans1=1e18; ans2=1e18;
	for (int i=1;i<=n;i++) calc(i);
	for (int i=1;i<=n;i++)
		for (int j=first[i];j;j=edge[j].next)
			if (i<edge[j].to) calc(i,edge[j].to);
	printf("%lld %lld\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p, ans = 0;
  cin >> n;
  for(int i =1;i <= n;i++){
    cin >> v[i];
  }
  while(v[pos] != 0 && pos != 2){
    p = pos;
    pos = v[pos];
    v[p] = 0;
    ans++;
  }
  if(pos == 2){
    cout << ans;
  }else{
    cout << -1;
  }
  return 0;
}


Measured memory_bytes: 3972
#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 <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n;
vector<ll> divisor(ll n)
{
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
        if (n % i == 0)
        {
            //res.push_back(i);
            //if (i != n / i)
            res.push_back(n / i);
        }
    return res;
}
ll GetDigit(ll num)
{
    return to_string(num).length();
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<ll> v = divisor(n);
    ll ans = 11;
    for (ll i : v)
    {
        ans = min(ans, GetDigit(i));
    }
    cout << ans << "\n";
}

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

typedef long long ll;
int MOD = 1000000007;

int main() {
  int N; cin >> N;
  
  int ans = 0;
  for (int a = 1; a < N; a++) {
    int cur = N / a;
    if (N % a == 0) cur--;
    ans += cur;
  }
  
  cout << ans << endl;
}   

Measured memory_bytes: 3604
n, m = [int(item) for item in input().split()]
lr = [[int(item) for item in input().split()] for _ in range(m)]

passable = [0] * (n+1)
for l, r in lr:
    passable[l-1] += 1
    passable[r] -= 1
for i in range(n):
    passable[i+1] += passable[i]
print(passable[:n].count(m))

Measured memory_bytes: 25900