akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	ll ak1 = t1 * a1, ak2 = t2 * a2;
	ll bk1 = t1 * b1, bk2 = t2 * b2;
	if (ak1 > bk1) {
		if (ak1 + ak2 > bk1 + bk2) {
			cout << 0;
		}
		else if(ak1 + ak2 == bk1 + bk2){
			cout << "infinity";
		}
		else {
			ll d = (bk1 + bk2) - (ak1 + ak2);
			ll ans = 1 + ((ak1 - bk1) / d) * 2;
			if ((ak1 - bk1) % d == 0)ans--;
			cout << ans;
		}
	}
	else {
		if (ak1 + ak2 < bk1 + bk2) {
			cout << 0;
		}
		else if (ak1 + ak2 == bk1 + bk2) {
			cout << "infinity";
		}
		else {
			ll d = (ak1 + ak2) - (bk1 + bk2);
			ll ans = 1 + ((bk1 - ak1) / d) * 2;
			if ((bk1 - ak1) % d == 0)ans--;
			cout << ans;
		}
	}
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m, c) = scan!(usize, usize, i64);
    let bs = scan!(i64;;);
    let vs = scan!(i64;;n);
    let mut ans = 0;
    for v in vs {
        if v.iter().zip(bs.iter()).map(|(&x, &y)| x * y).sum::<i64>() + c > 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

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

int main(){
    ios::sync_with_stdio(false);
    int x; cin >>x;
    int n=x/100;
    if(x<=n*105) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args)
	{
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(br.readLine());
			int[] A = new int[n];
			for(int i = 0; i<n ; i++)
			{
				A[i] = Integer.parseInt(br.readLine());
			}
			shellSort(A,n);
			
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shellSort(int[] arr , int l)
	{
		
		int m = 1 ,cnt =0;
		int G[] = new int[15];
		G[0] = 1;
		while((G[m] = G[m-1] * 3 +1) <= l){
			m++;
		}
		sb.append(m).append('\n');
		m--;
		for(; m >= 0 ; m--){
			sb.append(G[m]);
			if(m!=0)
				sb.append(' ');
			cnt += insertionSort(arr,l,G[m]);
		}
		sb.append('\n').append(cnt).append('\n');
		
		for(m = 0 ; m < l ; m++){
			sb.append(arr[m]).append('\n');
		}
			System.out.print(sb.toString());
	}
	public static int insertionSort(int[] a,int n , int g)
	{
		int cnt = 0;
		int v;
		for(int i = g ; i < n ; i++)
		{
			v = a[i];
			int j = i-g;
			while(j >= 0 && a[j] > v)
			{
				a[j+g] = a[j];
				a[j] = v;
				j -= g;
				cnt++;
			}
		}
		return cnt;
	}
}

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


import math

K = input()
K = int(K)
A,B = map(int,input().split())

j_a = math.floor(float(A)/float(K))
j_b = math.floor(float(B)/float(K))

if(float(A)%float(K) ==0):
    print('OK')
elif(float(B)%float(K) ==0):
    print('OK')
elif(j_b-j_a >= 1):
    print('OK')
    
else:
    print('NG')


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

void chmax(int &a,int b) { a=max(a,b); }
void chmin(int &a,int b) { a=min(a,b); }

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

int n;
ll a,b,x;

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

	cin>>a>>b>>x;
	cout<<b/x+1-(a==0?0:(a-1)/x+1)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void HinaArare() {
	int N;
	cin >> N;
	map<char, int> m;
	for (size_t i = 0; i < N; i++)
	{
		char g;
		cin >> g;
		m[g]++;
	}
	if (m.size() == 3) {
		cout << "Three" << endl;
	}
	else
	{
		cout << "Four" << endl;
	}
}
int main() {
	HinaArare();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
int INF=1001001001;

int mini(int x,int y){
  if(x<y){
    return x;
  }else{
    return y;
  }
}

int main(){
  std::string str1,str2;
  int A[1001][1001];
  std::cin>>str1;
  std::cin>>str2;
  for(int i=0;i<=str1.size();i++){
    for(int j=0;j<=str2.size();j++){
      A[i][j]=INF;
    }
  }
 
  for(int i=0;i<=str1.size();i++) A[i][0]=i;
  for(int i=0;i<=str2.size();i++) A[0][i]=i;
 
  for(int i=0;i<str1.size();i++){
    for(int j=0;j<str2.size();j++){
      A[i+1][j+1]=mini(A[i][j],mini(A[i+1][j],A[i][j+1]))+1;
 
      if(str1[i]==str2[j]) A[i+1][j+1]=mini(A[i+1][j+1],A[i][j]);
 
    }
  }
 
  std::cout<<A[str1.size()][str2.size()]<<"\n";
  return 0;
}



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int64 N, A, B;
  cin >> N >> A >> B;
  vector< int > D(N);
  cin >> D;

  int64 ret = 0;
  for(int i = 1; i < N; i++) {
    ret += min(1LL * (D[i] - D[i - 1]) * A, B);
  }
  cout << ret << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  long long a,i,b[30]={};
  char s[200010];
  scanf("%s",s);
  for(i=0;s[i];i++)b[s[i]-'a']++;
  a=i*(i-1)/2;
  for(i=0;i<26;i++)a-=b[i]*(b[i]-1)/2;
  printf("%lld\n",a+1);
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
char ch[1001];
int q[1000001][2],sx,sy,ans,b[1001][1001],i,j,k,n,m,a[1001][1001],w;
void bfs(){
	int x,y,tx,ty,i,j,l,r;
	for (i=1;i<=n;i++)
	 for (j=1;j<=m;j++) b[i][j]=-1;
	b[sx][sy]=0;l=0;r=1;q[1][0]=sx;q[1][1]=sy;
	while (l<r){
		x=q[++l][0];y=q[l][1];
		if (b[x][y]==w) return;
		for (i=0;i<4;i++){
			tx=x+dx[i];ty=y+dy[i];
			if (tx<1||tx>n||ty<1||ty>m||a[tx][ty]||b[tx][ty]!=-1) continue;
			b[tx][ty]=b[x][y]+1;q[++r][0]=tx;q[r][1]=ty;
		}
	}
}
int calc(int x){
	if (x==0) return 0;
	return (x-1)/w+1;
}
int main(){
	scanf("%d%d%d",&n,&m,&w);
	for (i=1;i<=n;i++){
		scanf("%s",ch);
		for (j=0;j<m;j++){
			if (ch[j]=='#') a[i][j+1]=1;else a[i][j+1]=0;
			if (ch[j]=='S') sx=i,sy=j+1;
		}
	}
	bfs();
	for (ans=n*m,i=1;i<=n;i++)
	 for (j=1;j<=m;j++)
	  if (b[i][j]!=-1){
	  	ans=min(ans,1+min(calc(min(i-1,n-i)),calc(min(j-1,m-j))));
	  }
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14464
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")
 
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;
 
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
 
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);
 
const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 50 + 5;

int n, k;

struct Matrix {
    int a[maxn][maxn];
    
    Matrix operator * (Matrix &rhs) {
        Matrix tmp;
        for (int i = 0; i < n; ++i) memset(tmp.a[i], 0x00, sizeof(tmp.a[i]));
        
        for (int i = 0; i < n; ++i) {
            for (int tr = 0; tr < n; ++tr) {
                for (int j = 0; j < n; ++j) {
                    tmp.a[i][j] = (tmp.a[i][j] + a[i][tr] * rhs.a[tr][j]) % mod;
                }
            }
        }
        
        return tmp;
    }
};

int32_t main() {
    fastIO();
    
    cin >> n >> k;
    
    Matrix base, ans;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) cin >> base.a[i][j];
        ans.a[i][i] = 1;
    }
    
    while (k) {
        if (k & 1) ans = ans * base;
        base = base * base;
        k >>= 1;
    }
    
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) sum += ans.a[i][j];
        sum %= mod;
    }
    
    cout << sum << "\n";
    
    return 0;
}

Measured memory_bytes: 384
// AOJ 2108 Aaron and Bruce
// 2018.3.4

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int  m, lim;
char hi[51], to[51][51];
char dp[51][51][102];

int dfs(int a, int b, int t)
{
	int i, x, ans;

	if (a == b) return t;
	if (t >= lim) return lim;
	if (dp[a][b][t] >= 0) return dp[a][b][t];
	if (t & 1) {
		ans = lim;
		for (i = 0; i < hi[b]; i++) {
			x = dfs(a, to[b][i], t+1);
			if (x < ans) ans = x;
		}
	} else {
		ans = 0;
		for (i = 0; i < hi[a]; i++) {
			x = dfs(to[a][i], b, t+1);
			if (x > ans) ans = x;
		}
	}
	return dp[a][b][t] = ans;
}

int main()
{
	int cno, r, c, a, b, ans;

	cno = in(); while (cno--) {
		m = in(), lim = m << 1;
		for (r = 0; r < m; r++) {
			hi[r] = 1, to[r][0] = r;
			for (c = 0; c < m; c++)	if (in()) to[r][hi[r]++] = c;
		}
		a = in(), b = in();

		memset(dp, -1, sizeof(dp));
		ans = dfs(a, b, 0);
		if (ans >= lim)	puts("infinity");
		else printf("%d\n", ans >> 1);
	}
	return 0;
}


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

int main() {
    int n;cin >> n;
    vector<int> a(n); for(int i=0;i<n;i++) cin >> a[i];
    int m;cin >> m;
    vector<int> t(m);for(int i=0;i<m;i++) cin >> t[i];
    if(n<m){
        cout << "NO" << endl;
        return 0;
    }
    sort(a.begin(),a.end());
    sort(t.begin(),t.end());
    int i=-1;
    bool ans=true;
    for(int j = 0; j < m; j++) {
        while(i<n){
            i++;
            if(i<n && t[j]==a[i]) break;
        }
        if(i>=n) {
            ans = false;
            break;
        }
    }

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 4820
def canCommunicate(arr)
  if (arr[0] - arr[2]).abs <= arr[3]
    return "Yes"
  end
  if (arr[0] - arr[1]).abs <= arr[3] && (arr[1] - arr[2]).abs <= arr[3]
    return "Yes"
  end
  return "No"
end

arr = gets.chomp.split().map!(&:to_i)
puts canCommunicate(arr)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,cnt = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < n; ++i) {
        if(i + 2 < n && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt ++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int m[] = new int[n];
    int sum = 0;
    int count = 0;
    for(int i = 0 ; i < n ; ++i){
      m[i] = sc.nextInt();
      sum += m[i];
      count++;
    }
    
    Arrays.sort(m);
    
    for(int i = 0 ; i < 100000 ; ++i){
      if(sum<x){
        sum += m[0];
        count++;
      }else{
        break;
      }
    }
    
    if(sum>x){
      count -= 1;
    }

    
    
    System.out.println(count);
    
  }
}


Measured memory_bytes: 35968
#include <stdio.h>

#define MAX 100

int selectionSort(int *,int);

int main (void)
{
  int array[MAX],N,i,count;

  scanf ("%d",&N);
  for (i = 0 ; i < N ; i++)
    scanf ("%d",&array[i]);

  count = selectionSort(array,N);

  for (i = 0 ; i < N ; i++){
    printf ("%d",array[i]);
    if (i < N-1)
      printf (" ");
    else printf ("\n");
  }
  
  printf ("%d\n",count);
  return 0;
}

int selectionSort(int *array, int N)
{
  int i,j,minj,a,b,count=0;

  for (i = 0 ; i < N ; i++){
    minj = i;
    for (j = i ; j < N ; j++){
      if (array[j] < array[minj]){
	minj = j;
      }
    }
    a = array[i];
    b = array[minj];
    array[i] = b;
    array[minj] = a;
    if (a != array[i])
      count++;
  }

  return count;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int K,A,B;
long long Ans;
int main(){
	scanf("%d%d%d",&K,&A,&B);
	if(B-A<=1){
		Ans=K+1;
		printf("%lld\n",Ans);
		return 0;
	}
	if(A-1>K){
		printf("%lld\n",Ans);
		return 0;
	}
	Ans=A;
	K-=A;K+=1;
	Ans=Ans+1ll*(K/2)*(B-A);
	if(K&1)Ans++;
	printf("%lld\n",Ans);
	return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var xs = new int[seqA.Length];
        for (int i = 0; i < seqA.Length; ++i)
        {
            xs[seqA[i] - 1] = i + 1;
        }
        Console.WriteLine(string.Join(" ", xs));
    }
}


Measured memory_bytes: 29788
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>
#include <limits.h>

using namespace std;
int main(){
    
    int h,w;
    
    cin >> h >> w;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            string str;
            cin >> str;
            if (str == "snuke") {
                cout << (char)('A'+j) << i +1 <<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> ans(3);
    for(int i=0;i<3;i++){
        cin>>ans[i];
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout<<ans[0]*10+ans[1]+ans[2];
    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
P = set(list(map(int, input().split())))
notP = set(list(range(-1, 102))) - P
#print(notP)

min_dif = 10000
ans = 10000
for num in list(notP):
    dif = abs(x - num)
    if dif < min_dif:
        min_dif = dif
        ans = num
    elif dif == min_dif and num < ans:
        min_dif = dif
        ans = num
print(ans)

Measured memory_bytes: 61996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	string s;
	cin >> s;
	ll ans = 0;
	int whiteCanbeSwapped = 0;
	for(int i = (int)s.length(); i >= 0; i--){
		if(s[i] == 'W'){
			whiteCanbeSwapped++;
		}
		else{
			ans += whiteCanbeSwapped;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

#define int long long
#define double long double
#define endl '\n'
#define gcd __gcd
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(), x.end()
const int inf = __LONG_LONG_MAX__;

using namespace std;

void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

signed main() {
  fast_io();

  string a, b;
  cin >> a >> b;
  cout << b + a << "\n";

  return 0;
}


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

void solve(){
    int count = 0 , max = 0;
    string weather;
    cin >> weather;
    for(int i = 0; i < weather.size() ; i++){

        if (weather[i] == 'R'){
            count++;
        }
        else{
            if (count > max){
                max = count;
            }
            count = 0;

        }

        if (count > max){
            max = count;
        }
    }
    cout << max;
}

int main(){
    solve();


}


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

int main() {
  int n; cin >> n;
  vector<pair<int, int>> v(n);

  int a, b;
  for(int i=0; i<n; ++i){
    cin >> a >> b;
    v[i] = pair<int, int>(b, a);
  }

  sort(v.begin(), v.end(), std::greater<pair<int, int>>());

  int wt = v[0].first;
  for(int i=0; i<n; ++i){
    if(wt > v[i].first) wt = v[i].first;
    wt -= v[i].second;
    if(wt < 0){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 205;
const int inf = 1e9;
int h, w;
char a;
struct edge{int t, c, r;};
vector<edge> G[mx];
bool used[mx];

void add_edge(int f, int t, int c = 1){
	G[f].push_back((edge){t,c,(int)G[t].size()});
	G[t].push_back((edge){f,0,(int)G[f].size()-1});
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(auto &it: G[v]) if(!used[it.t] && it.c){
		int d = dfs(it.t, t, min(f,it.c));
		if(d){
			it.c -= d;
			G[it.t][it.r].c += d;
			return d;
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int res = 0, f = 1;
	while(f){
		fill(used,used+mx,0);
		f = dfs(s,t,inf);
		res += f;
	}
	return res;
}

int main(){
	scanf("%d%d\n", &h, &w);
	rep(i,h) rep(j,w+1){
		scanf("%c", &a);
    	if(j==w || a == '.') continue;
    	add_edge(a-'S'?i:w+h, a-'T'?j+h:w+h+1, a-'o'?inf:1);
    	add_edge(a-'S'?j+h:w+h, a-'T'?i:w+h+1, a-'o'?inf:1);
	}
	int ans = max_flow(w+h,w+h+1);
	printf("%d\n", ans >= inf ? -1 : ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repd(i,a,b) for(ll i=a;i>=b;i--)
#define ford(i,n)  for(ll i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
// const ll mod=998244353;	
const ll mod = 1e9 + 7;
const ll inf = std::numeric_limits<ll>::max();
const ll infi = std::numeric_limits<int>::max();
const double pi = acos(-1.0);
ll gcd(ll a, ll b){if(b == 0) return a; return gcd(b%a, a);}
ll fastexp(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%mod; y=y>>1; x=(x*x)%mod;} return res; }
ll inv_mod(ll n){return fastexp(n,mod-2);}
bool isPrime(ll n){ll srt = sqrt(n);rep(i,3,srt)if(n%i == 0)return false;return true;}
char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

void solve() {
  int n,k;cin>>n>>k;
  vi h(n), minc(n,infi);
  fori(i,n)cin>>h[i];
  minc[0] = 0;
  rep(i, 1,n-1){
    rep(j,i-k,i-1)if(j>=0)minc[i] = min(minc[i], minc[j] + abs(h[i] - h[j]));
  }
  cout<<minc[n-1];
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin>>t;
  while(t--){
    solve();
  }
  return 0;
}


Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
int bord[101][101]={},playx[2],playy[2];
int movex[]={1,0,-1,0},movey[]={0,1,0,-1};
int serch(int x,int y,int color)
{
    if(color==0)return 0;
    int now=0;
    bord[y][x]=0;
    if(x==playx[1]&&y==playy[1])return 1;
    for(int i=0;i<4&&now==0;i++)
        if(bord[movey[i]+y][movex[i]+x]==color)now=serch(movex[i]+x,movey[i]+y,color);
    return now;
}
int main()
{
    int  h,w;
    while(cin>>h>>w,h,w){
        for(int i=0;i<=h+1;i++){
                for(int j=0;j<=w+1;j++)bord[i][j]=0;
        }
        for(int i=0;i<2;i++)cin>>playx[i]>>playy[i];
        int n;
        cin>>n;
        for(int i=0,co,mu,x,y;i<n;i++){
            cin>>co>>mu>>x>>y;
            for(int j=0;j<4;j++){
                if(mu==1){
                    bord[y+j][x]=co;
                    bord[y+j][x+1]=co;
                }
                else{
                    bord[y][x+j]=co;
                    bord[y+1][x+j]=co;
                }
            }
        }
        if(serch(playx[0],playy[0],bord[playy[0]][playx[0]]))cout<<"OK\n";
        else cout<<"NG\n";
    }
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int t, n, b;
		int up, down;
		int [] block;
		
		t = scan.nextInt();
		
		for(int i = 0; i < t; i++){
			n = scan.nextInt();
			
			up = 0;
			down = 0;
			block = new int[n];
			for(int j = 0;j < n; j++){
				b = scan.nextInt();
				block[j] = b;
			}
			
			for(int j = 0; j < n - 1; j++){
				if(block[j] < block[j + 1]){
					if(up < block[j + 1] - block[j])up = block[j + 1] - block[j];
				}else if(block[j] > block[j + 1]){
					if(block[j] - block[j + 1] > down)down = block[j] - block[j + 1];
				}
			}
			
			System.out.println(up + " " + down);
		}
	}
}

Measured memory_bytes: 35464
#include<bits/stdc++.h>
#define mx 200005
using namespace std;

int n;
long long l, x[mx], ac1[mx], ac2[mx], ans;

int main(){
	scanf("%lld%d", &l, &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &x[i]);
		ac1[i] = ac1[i-1] + x[i];
	}
	for(int i = n; i > 0; i--) ac2[i] = ac2[i+1] + l - x[i];
	for(int i = 1; i <= n; i++){
		if(n != i){
			int k = min(n-i, i);
			long long a1 = (ac1[i] - ac1[i-k])*2 + (ac2[i+1] - ac2[i+1+k])*2 - min(x[i], (l - x[i+1]));
			ans = max(ans, a1);
		}
		int k2 = min(n-i, i-1);
		long long a2 = (ac1[i-1] - ac1[i-k2-1])*2 + (ac2[i+1] - ac2[i+1+k2])*2 + max(x[i], (l - x[i]));
		ans = max(ans, a2);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 5050;
int MOD;

int add(ll a, int b){
	return (a + b + 2LL*MOD) % MOD;
}

int mul(ll a, int b){
	return (a * b) % MOD;
}

void sadd(int &a, int b){
	a = add(a, b);
}

int dp[N], c[N];

void apply(int ind, int x){
	for(int i=0 ; i<=ind ; i++)
		c[i] += x;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(NULL);
    int n;cin >> n >> MOD;
    for(int i=0 ; i<(n+1)/2 ; i++)
    	apply(i, -1);
    int t = (n+1)/2 - 1;
    for(int i=n-1 ; t ; ){
    	apply(i, 1);
    	t --;
    	i --;
    }
    for(int i=0 ; i<n ; i++)
    	c[i] ++;
    dp[0] = 1;
    for(int i=1 ; i<n ; i++)
    	for(int j=c[i] ; j<=n ; j++)
    		sadd(dp[j], dp[j-c[i]]);

    int ans=0;
    for(int i=0 ; i<=n ; i++)
    	sadd(ans, mul(dp[i], n-i));
    cout << ans << "\n";
}

























Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=998244353;
const ll MAXN=1e4+5;
const ll inf=1e17;

int main()
{
    fastio;
    ll n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else{
        cout << r + 100*(10 - n) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <random> 
#include <vector>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>

#define ID(x,y) (((x)-1) * m + (y))
#define CL clear
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define low_bit(x) ((x)&(-(x)))
#define dmp(x) cerr<<#x<<"="<<x<<"\n"  
#define MIN(a,b,c) min(a,min(b,c))
#define MAX(a,b,c) max(a,max(b,c))
#define SZ(x) ((int)(x.size())) 
#define sc scanf
#define pf printf
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dep(i,a,b) for(int i=(a);i>=(b);i--)

#define int long long

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;

const int N = (int)1e6+10;
const int mod = 1e9+7;
const int inf = 1e9;
const double eps = 1e-16;
const double pi = acos(-1);


inline int rd() {
  int p=0; int f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f*=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}

int A,B,n;

signed main() {
  // freopen("a.in","r",stdin);
  // freopen("a.out","w",stdout);
  int A=rd(); int B=rd(); int n=rd();
  int x = (n+1) / B; x=x*B-1;
  printf("%lld\n",max((A*x/B) - A*(x/B) , (A*n/B) - A*(n/B)));
  return 0;
}

/*
*/


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  long a,b,n;
  cin >> a >> b >> n;
  long r;
  if(n >= b-1) r = b-1;
  else r = n;
  cout << a*r/b << endl;
}

Measured memory_bytes: 3596
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i=3; i<=n; i+=2){
            int cnt = 0;
            for(int j=1; j<=i; j++){
                if(i % j == 0) cnt++;
            }
            if(cnt == 8) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string o="NG";
  int k,a,b;
  cin>>k>>a>>b;
  for(int c=0; c<=1000; c++){
    if(a<=k*c&&k*c<=b){
      o="OK";
    }
  }
    cout<<o<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const double EPS = 1e-12;

struct Point{
  double x,y;
  Point(double x = 0.0, double y = 0.0): x(x), y(y) {}
  Point operator + (Point p){
    return Point(x + p.x,y + p.y);
  }
  Point operator - (Point p){
    return Point(x - p.x,y - p.y);
  }
  Point operator * (double lambda){
    return Point(x * lambda,y * lambda);
  }
  Point operator / (double lambda){
    return Point(x / lambda,y / lambda);
  }
  double norm(){
    return x * x + y * y;
  }
  double abs_(){
    return sqrt(norm());
  }
  bool operator == (const Point &p)const
  {
    return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
  }
  bool operator < (const Point &p)const{
    if(abs(x - p.x) < EPS) return y < p.y;
    return x < p.x;
  }
};
typedef Point Vector;
double dot(Vector a,Vector b){
  return a.x * b.x + a.y * b.y;
}
double det(Vector a,Vector b){
  return a.x * b.y - a.y * b.x;
}
struct Segment{
  Point p1,p2;
  Segment(Point p1 = Point(),Point p2 = Point()): p1(p1), p2(p2) {}
};
typedef Segment Line;
typedef vector <Point> Polygon;
#define maxn 105
Point crossPoint(Line a,Line b){
  double r = det(b.p2 - b.p1,a.p1 - b.p1) / det(a.p2 - a.p1,b.p2 - b.p1);
  return a.p1 + (a.p2 - a.p1) * r;
}
double calc(Polygon P,double x0){
  double miny = 101.0, maxy = -101.0;
  int n = P.size();
  Line l = Line(Point(x0,-101.0),Point(x0,101.0));
  for(int i = 0;i < n;i++){
    if(P[i].x == P[(i + 1) % n].x) continue;
    if((P[i].x - x0) * (P[(i + 1) % n].x - x0) <= 0.0){
      Point p = crossPoint(Line(P[i],P[(i + 1) % n]),l);
      miny = min(miny,p.y);
      maxy = max(maxy,p.y);
    }
  }
  return max(0.0,maxy - miny);
}
int m,n;
Polygon c1,c2;
vector <double> xs;
double f(double x0){
  return calc(c1,x0) * calc(c2,x0);
}
int main(){
  while(~scanf("%d%d",&m,&n) && m){
    xs.clear();
    c1.resize(m);
    c2.resize(n);
    for(int i = 0;i < m;i++){
      double x,y;
      scanf("%lf%lf",&x,&y);
      c1[i] = Point(x,y);
      xs.push_back(x);
    }
    for(int i = 0;i < n;i++){
      double x,y;
      scanf("%lf%lf",&x,&y);
      c2[i] = Point(x,y);
      xs.push_back(x);
    }
    sort(xs.begin(),xs.end());
    double ans = 0.0;
    for(int i = 0;i < n + m - 1;i++){
      double l = xs[i] + EPS, r = xs[i + 1] - EPS, mid = (l + r) / 2.0;
      ans += (r - l) * (f(l) + 4.0 * f(mid) + f(r)) / 6.0;
    }
    printf("%.10f\n",ans);
  }
  return 0;
}



Measured memory_bytes: 3204
fun main(args: Array<String>) {
    // Your code here!
    var n = readLine()!!.toInt()
    var numList = readLine()!!.split(" ").map{it.toInt()}
    numList.forEach {
        if (it % 2 == 0 && it % 3 != 0 && it % 5 != 0) {
            println("DENIED")
            return
        }
    }
    println("APPROVED") 
}

Measured memory_bytes: 35944
h, w = (int(v) for v in input().split())
a = [input() for _ in range(h)]

my = [True for _ in range(h)]
mx = [True for _ in range(w)]

for y in range(h):
    for x in range(w):
        if a[y][x] != '.':
            break
    else:
        my[y] = False

for x in range(w):
    for y in range(h):
        if a[y][x] != '.':
            break
    else:
        mx[x] = False

for y in range(h):
    for x in range(w):
        if my[y] and mx[x]:
            print(a[y][x], end='')
    if my[y]:
        print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    *t++;
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c;
    deque<int> v(0);
    cin >> n;
    rep(i, n) {
        cin >> a >> b;
        if(a == 0) {
            cin >> c;
            if(b)
                v.push_back(c);
            else
                v.push_front(c);
        } else if(a == 1) {
            cout << v.at(b) << "\n";
        } else {
            if(b)
                v.pop_back();
            else
                v.pop_front();
        }
    }
}



Measured memory_bytes: 4632
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    string A;
    cin >> A;
    if( (A[0] - 'a') >=0){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;

    }
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	string s;
	cin >> s;
	ll cntB=0;
	ll ans = 0;
	rep(i, s.size()) {
		if (s[i] == 'B') cntB++;
		else {
			ans += cntB;	
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[N,M,R]=i2()
r=i2()
f=float("inf")
d=[[f for j in range(N)]for i in range(N)]
for i in range(N):d[i][i]=0
for i in range(M):
    a=i2()
    d[a[0]-1][a[1]-1]=a[2]
    d[a[1]-1][a[0]-1]=a[2]
for i in range(N):
    for j in range(N):
        for k in range(N):
            d[j][k]=min(d[j][k],d[j][i]+d[i][k])
c=float("inf")

import itertools
for i in list(itertools.permutations(r)):
    ddd=0
    for j in range(len(i)-1):
       ddd+=d[i[j]-1][i[j+1]-1]
    c=min(c,ddd)

print(c)


Measured memory_bytes: 72792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin >> n >> t >> a ;
  double ans = 50;
  double max1 = 1000000;
  int index;
  for(int i=0;i<n;i++){
    int h;
    cin >> h;
    ans = t - h*0.006;
    if(abs(a-ans)<max1){
      max1 = abs(a-ans);
      index = i+1;
    }
  }
  cout << index << endl;
}

Measured memory_bytes: 256
w = input().upper()
flg = True
count = 0

while flg:
    string = input().split()
    #print(string)
    
    if "END_OF_TEXT" in string:
        flg = False

    for i in range(len(string)):
        if w == string[i].upper():
            count += 1
        
        
print(count)



Measured memory_bytes: 5560
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    string S;
    ll C0 = 0, C1 = 0, C2 = 0, C3 = 0;

    REP(i, N)
    {
        cin >> S;

        if (S == "AC")
        {
            C0++;
        }
        else if (S == "WA")
        {
            C1++;
        }
        else if (S == "TLE")
        {
            C2++;
        }
        else
        {
            C3++;
        }
    }

    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;

    return 0;
}


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    string s;
    cin >> s;
    int count=0;
    int max=0;
    rep(i,3){
        if(s[i]=='R'){
            count++;
        }else{
            if(max<count)
                max=count;
            count=0;
        }
    }
    if(max<count){
        max=count;
    }
    cout << max << endl;
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder st = new StringBuilder();
        
        int i = 1;
        
        while(true){
            int line = Integer.parseInt(br.readLine());
            if(line == 0){
                break;
            }
            
            st.append("Case ").append(i).append(": ").append(line).append("\n");
            i++;
        }
        
        System.out.print(st);
    }
}

Measured memory_bytes: 30648
def solve():
    X, N = map(int, input().split())
    ps = set(map(int, input().split()))

    for i in range(100):
        if X - i not in ps:
            return X - i
        if X + i not in ps:
            return X + i
        

def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
vector < char > v;
ll dp[5000][5000];

ll lcs(int a, int b){
	if(a < 0 || b < 0) return 0;
	if(dp[a][b] != -1) return dp[a][b];
	if(s[a] == t[b]){
		dp[a][b] = lcs(a - 1,b - 1) + 1;
	}else{
		dp[a][b] = max(lcs(a - 1,b),lcs(a,b - 1));
	}
	
	return dp[a][b];
}

void rec(int a, int b){
	if(a < 0 || b < 0) return;
	if(s[a] == t[b]){
		v.push_back(s[a]);
		rec(a - 1, b - 1);
	}else if(lcs(a - 1,b) > lcs(a,b - 1)){
		rec(a - 1,b);
	}else rec(a, b - 1);
}
int main (){
	memset(dp,-1,sizeof dp);
	cin >> s >> t;
	
	rec(s.length() - 1, t.length() - 1);
	
	for(int i = v.size() - 1; i >= 0; i--){
		cout << v[i];
	}
	cout << endl;
}

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

int main()
{
    int n,k;
    cin >> n>>k;
    vector<ll> x(n);
    for(int i=0;i<n;i++){
        cin>>x.at(i);
    }
    ll ans=100000000000;
    ll memo;
    for(int i=0;i<n-k+1;i++){
        memo=min(abs(x.at(i)),abs(x.at(i+k-1)))+abs(x.at(i+k-1)-x.at(i));
        ans=min(memo,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 0 && 0 <= b) puts("Zero");
	else {
		ll c = (b - (a - 1));
		if (a > 0 || c % 2 == 0) puts("Positive");
		else puts("Negative");
	}
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(int i=1;i<n;i++)
#define out(s) cout << s << endl

int main(){
    int w,a,b;cin >> w >> a >> b;
    int m;
    int x,y;
    if(a+w>=b && a+w<=b+w)m=0;
    else{
        x=min(a,b);
        y=max(a,b);
        m=y-(w+x);
    }
    cout << m << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
h = tuple(map(int, input().split()))
cost = [0] * (n + 1)

inf = 10**18
dp = [inf]*(n+5)
dp[0] = 0

for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i+2 < n:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))

ans = dp[n-1]
print(ans)


Measured memory_bytes: 14052
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def find(x): # 木の根を求める
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
        
def unite(x,y): # xとyの属する集合を併合
    x=find(x)
    y=find(y)
    if x==y:return
    if rank[x]<rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1

def same(x,y): # xとyが同じ集合に属するか判定
    return find(x)==find(y)

def main():
    n,m = map(int,input().split()) 
    global par,rank
    par=[i for i in range(n)]  # 親
    rank=[0 for _ in range(n)] # 木の深さ
    for _ in range(m):
        a,b,z = map(int,input().split())
        unite(a-1,b-1)
    dic=defaultdict(int)
    ans=0
    for i in range(n):
        if dic[find(i)]==0:
            ans+=1
            dic[find(i)]=1
    print(ans)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 75808