akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
//int main() {
//	int a, b;
//	cin >> a >> b;
//  if (a * b % 2 == 0) {
//	  cout << "Even" << endl;
//  } else {
//	  cout << "Odd" << endl;
//  }
//  return 0;
//}

// 文字列を1文字ずつループ
int main() {
  string str;
  cin >> str;
  int sum = 0;
  int A = int(str[0]) - 48;
  int B = int(str[1]) - 48;
  int C = int(str[2]) - 48;
  int D = int(str[3]) - 48;
  vector<string> sign{"+", "-"};
  bool breakFlag = false;
  int res = A;
  for (int i = 0; i < 2 && breakFlag == false; i++) {
    for (int j = 0; j < 2 && breakFlag == false; j++) {
      for (int k = 0; k < 2 && breakFlag == false; k++) {
          if (i == 0) {
            res += B;
          } else {
            res -= B;
          }
          if (j == 0) {
            res += C;
          } else {
            res -= C;
          }
          if (k == 0) {
            res += D;
          } else {
            res -= D;
          }
          if (res == 7) {
            cout << A << sign[i] << B << sign[j] << C << sign[k] << D << "=7" << endl;
            breakFlag = true;
          }
          res = A;
      }
    }
  }
  return 0;
}

// ビット全探索
// int main() {
// 	int K, S;
// 	cin >> K >> S;
//   int counter = 0;
//   for (int bit = 0; bit < (1<<K); bit++) {
//     vector<int> combination;
//     for (int i = 0; i < K; i++) {
//       if (bit & (1<<i)) {
//         combination.push_back(i);
//       }
//     }
//
//     int sum = accumulate(combination.begin(), combination.end(), 0);
//     if (sum == S) {
//       counter++;
//     }
//
//     cout << bit << ": {";
//     for (int i = 0; i < (int)combination.size(); ++i) {
//         cout << combination[i] << " ";
//     }
//     cout << "}" << endl;
//
//   }
//   cout << counter << endl;
//   return 0;
// }



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N,T;
    int c[101];
    int t[101];
    cin>> N>>T ;
    int mincost=1001;
    for(int i=1;i<=N;i++){
        cin>>c[i]>>t[i];
        if(t[i]<=T && c[i]<mincost)mincost=c[i];
    }
    
    if(mincost<=1000)cout<< mincost <<endl;
    else cout<<"TLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

cntMIN = float("inf")
for s in range(len(S)):
    if s + len(T) - 1 > len(S) - 1:
        break

    cnt = 0
    for i in range(len(T)):
        if S[s + i] != T[i]:
            cnt += 1
    
    cntMIN = min(cnt, cntMIN)

print(cntMIN)

Measured memory_bytes: 67508
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let mut count = [0,0,0];
    for i in 0..n {
        let a: usize = sc.next();
        if a % 2 == 1 {
            count[0] += 1;
        } else if a % 4 == 0 {
            count[1] += 1;
        } else {
            count[2] += 1;
        }
    }
    if count[1] >= count[0] || (count[1] + 1 == count[0] && count[2] == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
import numpy as np

N, D = map(int, input().split())
xlist = np.array([tuple(map(int, input().split())) for i in range(N)])

from scipy.spatial import distance
smm = distance.cdist(xlist, xlist)

c = 0
for i in smm.flatten():
  if i != 0 and i.is_integer():
  	c += 1

print(int(c/2))

Measured memory_bytes: 19536
class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0


N, M = map(int, input().split())

MOD = 10 ** 9 + 7

F = Factorial(M + 1, MOD)

ans = 0
for k in range(N + 1):
    tmp1 = F.comb(N, k)
    tmp2 = (F.factorial(M) * F.ifactorial(M - k)) % MOD
    tmp3 = ((F.factorial(M - k) * F.ifactorial(M - N))) ** 2 % MOD
    tmp = (tmp1 * tmp2 * tmp3) % MOD
    if k % 2 == 0:
        ans += tmp
    else:
        ans -= tmp
    ans %= MOD

print (ans)

Measured memory_bytes: 48568
#include<cstdio>
#include<cmath>
int s[100005],a[100005];
int main()
{
	a[1]=1;int n=100000;
	for(int i=2;i<=sqrt(n);i++)
	{
		if(a[i]) continue;
		for(int j=i*i;j<=n;j+=i) a[j]=1;
	}
	for(int i=1;i<=n;i+=2)
	if(!a[i]&&!a[(i+1)/2]) s[i]=1;
	for(int i=1;i<=n;i++) s[i]+=s[i-1];
	scanf("%d",&n);
	for(;n--;)
	{
		int x,y;scanf("%d%d",&x,&y);
		printf("%d\n",s[y]-s[x-1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }
    
const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 500;
    
     
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  char s[32];
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
    
  fgets(s, sizeof(s), stdin);
  sscanf(s, "%d %d", &N, &Q);
      
  while(Q--) {
    int t, a, b;
    fgets(s, sizeof(s), stdin);
    sscanf(s, "%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      bool update = small[curr] == A[a];
      A[a] = b;
      if(small[curr] >= b) {
        small[curr] = b;
      } else if(update) {
        small[curr] = INF;
        for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
      }
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        if(ret > small[begin - 1]) for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        if(ret > small[end]) for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}


Measured memory_bytes: 7140
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c;
int main()
{
    cin >> a >> b >> c;
    if(a == b || b == c || c == a)
    {
        if(a == b && b == c) cout << "No";
        else cout << "Yes";
    }
    else cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, a, b, c, d);
	if (a + b == c + d)
		print("Balanced");
	else if (a + b > c + d)
		print("Left");
	else
		print("Right");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()
#define clr(a,v) memset((a),(v),sizeof(a))

using ll = long long;

constexpr int MAX_N = 100010;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll N, K;
std::vector<ll> G[MAX_N];
ll L[MAX_N], R[MAX_N], A[MAX_N];
bool used[MAX_N];
bool fl = true;

bool dfs( int v, int prv )
{
  used[v] = true;

  //printf( "(%d,%d)\n", v, prv );

  for( auto &u : G[v] ) if( !used[u] )
  {
    if( R[u] < L[v]-1 || R[v]+1 < L[u] )
    { fl = false; return false; }

    L[u] = std::max( L[u], L[v]-1 );
    R[u] = std::min( R[u], R[v]+1 );

    if( !dfs( u, v ) )
      return false;
  }

  if( R[prv] < L[v]-1 || R[v]+1 < L[prv] )
  { fl = false; return false; }

  L[prv] = std::max( L[prv], L[v]-1 );
  R[prv] = std::min( R[prv], R[v]+1 );

  return true;
}

void calc( int v, int prv )
{
  used[v] = true;

  //printf( "{%d}\n", v+1 );

  if( v == prv )
    A[v] = std::max( 0ll, L[v] );
  else if( L[v] <= A[prv]+1 && A[prv]+1 <= R[v] )
    A[v] = A[prv]+1;
  else if( L[v] <= A[prv]-1 && A[prv]-1 <= R[v] )
    A[v] = A[prv]-1;
  else
    fl = false;

  for( auto &u : G[v] ) if( !used[u] )
    calc( u, v );

  return;
}

int main()
{
  scanf( "%lld", &N );
  rep( i, N-1 )
  {
    ll a, b;
    scanf( "%lld%lld", &a, &b );
    --a; --b;
    G[a].emplace_back( b );
    G[b].emplace_back( a );
  }

  scanf( "%lld", &K );

  std::fill( L, L+N, -INF );
  std::fill( R, R+N, INF );

  rep( i, K )
  {
    ll V, P;
    scanf( "%lld%lld", &V, &P );
    --V;
    L[V] = R[V] = A[V] = P;
  }

  clr( used, false );

  dfs( 0, 0 );

  //rep( i, N )
    //printf( "[%d] [%d,%d]", i+1, L[i], R[i] );

  //puts( fl ? "[Yes]" : "[No]" );

  clr( used, false );

  calc( 0, 0 );

  //rep( i, N )
    //printf( "[%d] %lld\n", i+1, A[i] );

  if( !fl )
  {
    puts("No");

    return 0;
  }


  puts("Yes");

  rep( i, N )
    printf( "%lld\n", A[i] );
  
  return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,K;
	cin >> N >> K;
	cat mod =1'000'000'007;

	cat sum0 =N*K*(K+1)/2;
	for(int i =0; i < N-1; i++) sum0 =(sum0*(K+1))%mod;

	vector< vector<int> > cnt(N+1,vector<int>(N*K+1,0));
	cnt[N][0] =1;
	for(int i =N; i > 0; i--) for(int j =0; j <= K; j++) {
		if(j > i) {
			for(int o =0; o <= N*K; o++) if(cnt[i][o]) {
				cnt[i-1][o] +=cnt[i][o];
				if(cnt[i-1][o] >= mod) cnt[i-1][o] -=mod;
			}
			continue;
		}
		for(int o =0; o <= N*K; o++) if(cnt[i][o]) {
			cnt[i-1][o+(o+j)/i] +=cnt[i][o];
			if(cnt[i-1][o+(o+j)/i] >= mod) cnt[i-1][o+(o+j)/i] -=mod;
		}
	}

	cat ops =0;
	for(int i =0; i <= N*K; i++) ops +=(1LL*i*cnt[0][i])%mod;
	cat ans =(sum0-ops)%mod;
	if(ans < 0) ans +=mod;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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

int main() {
    string s; cin >> s;
    string hit = "";
    bool ans = false;
    for (int i = 1; i <= 5; i++) {
        hit += "hi";
        if (hit == s) {
            ans = true;
            break;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;
char c;
int main() {
	bool tag=0;
	for(int i=1; i<=3; i++) {
		cin>>c;
		if(c=='7') tag=1;
	}
	if(tag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3632
<?php 
  fscanf(STDIN,"%d%d%d",$c1,$c2,$c3);
  fscanf(STDIN,"%d%d%d",$c21,$c22,$c23);
  fscanf(STDIN,"%d%d%d",$c31,$c32,$c33);

$diff_11 = $c1-$c2;
$diff_21 = $c21-$c22;
$diff_31 = $c31-$c32;

$diff_1 = $c2-$c3;
$diff_2 = $c22-$c23;
$diff_3 = $c32-$c33;


if($diff_11 == $diff_21 && $diff_21 == $diff_31 && 
  $diff_1 == $diff_2 && $diff_2 == $diff_3){
  echo "Yes\n";
}else{
  echo "No\n";
}


Measured memory_bytes: 4728
#include <iostream>
#include <fstream>
#include <cmath>
#include <list>
#include <vector>
#include <tuple>
using namespace std;
//#define FILENAME "./F/in/b04"
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

#define MOD 1000000007

int n,d;

int main(int argc, char *argv[]) {

#ifdef FILENAME
  ifstream file(FILENAME);
  cin.rdbuf(file.rdbuf());
#endif

  cin >> n >> d;
  int r = n/(2*d+1);
  if(n%(2*d+1)!=0) r++;
  cout << r << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define ll long long
ll p[200005];
int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> p[i];
    sort(p + 1, p + 1 + n);
    ll minn = 1000000001;
    for (int i = 1; i <= n - k + 1; i++)
    {
        // printf("%lld %lld\n",p[i+k-1],p[i]);
        if (p[i + k - 1] - p[i] < minn)
            minn = p[i + k-1] - p[i];
        // cout << minn << endl;
    }

    cout << minn << endl;

    return 0;
}


Measured memory_bytes: 1024
main = do
  (a:b:_) <- getLine >>= return . map read . words :: IO [Int]

  putStrLn "100 100"

  mapM_ putStrLn $ concat [[replicate 100 '.', concat (replicate x ".#") ++ (replicate (100-x*2) '.')] | x <- take 25 (f (b-1))]
  mapM_ putStrLn $ concat [[replicate 100 '#', concat (replicate x "#.") ++ (replicate (100-x*2) '#')] | x <- take 25 (f (a-1))]

  where
    f n = (if n >= 50 then 50 : (f (n-50)) else if n >= 0 then n : (f 0) else 0 : (f 0))


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int x,y;
    cin>>x>>y;
    if(2*y-x<0||2*x-y<0||(2*y-x)%3!=0||(2*x-y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int a=(2*y-x)/3;
    int b=(2*x-y)/3;
    COMinit();
    cout<<COM(a+b,a)<<endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl phe(400,0);
    rep(i,n){
        ll l,r,s;cin >> l >>r >>s;
        repl(j,l,r+1){
            chmax(phe[j],s);
        }
    }
    ll m;cin >> m;
    vl ans;bool check=false;
    rep(i,m){
        ll p;cin >> p;
        vl dp(p+1,0);
        rep(j,400){
            rep(k,p+1){
                if(k+j<=p)chmax(dp[k+j],dp[k]+phe[j]);
            }   
            //if(j<=10){rep(k,p+1)cout << dp[k] <<" ";cout <<endl;}
        }
        ans.pb(dp[p]);
        if(dp[p]==0)check=true;
    }
    if(check)cout << -1 <<endl;
    else rep(i,m)cout << ans[i] <<endl;
}


Measured memory_bytes: 3168
N = gets.to_i
ps = gets.split(' ').map(&:to_i)
sorted_ps = ps.sort
diffs = 0
ps.each_with_index{ |p, i| diffs += 1 if p != sorted_ps[i] }
puts (diffs == 0 || diffs == 2) ? 'YES' : 'NO'

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

int main(){
  string str;
  string t;
  string kekka;
  cin >> str >> t;
  
  bool chk = true;
  if(str.size() >= 1 && str.size() <= 10) chk = true;
  else chk = false;
  
  if(str == t.substr(0,str.size())) chk = true;
  else chk = false;
  
  if(chk == true)  cout << "Yes";
  else cout << "No";
}

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

using namespace std;

int a[10000],b[10000];

int main()

{
    int i,j,k,l,n,m,o,p;

    while(cin>>n>>m>>k)
    {
        l=0;

        a[0]=n;
        a[1]=m;
        a[2]=k;

        sort(a,a+3);
        for(i=1;i<3;i++)
        {
            l+=a[i]-a[i-1];
        }
        l=abs(l);
        printf("%d\n",l);
    }

}



Measured memory_bytes: 256
N = int(input())
S =list(map(int,input()))

ans = 0

for x in [0,1,2,3,4,5,6,7,8,9]:
  if x in S:
    x_index = S.index(x)
    for y in [0,1,2,3,4,5,6,7,8,9]:
      if y in S[x_index+1:]:
        y_index = S[x_index+1:].index(y)
        for z in [0,1,2,3,4,5,6,7,8,9]:
          if z in S[x_index + 1 + y_index+1:]:
            ans += 1
print(ans)

Measured memory_bytes: 9484
#!/usr/bin/env python
from __future__ import division, print_function

import io
import os
import sys
from collections import Counter

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from cStringIO import StringIO
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    from io import BytesIO as StringIO

sys.stdout, stream = io.IOBase(), StringIO()
sys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
sys.stdout.write = stream.write if sys.version_info[0] < 3 else lambda s: stream.write(s.encode())

input, flush = sys.stdin.readline, sys.stdout.flush
input = StringIO(os.read(0, os.fstat(0).st_size)).readline


def main():
    n = int(input())
    s = Counter(input())
    print('Yes' if s['R'] > s['B'] else 'No')


if __name__ == '__main__':
    main()


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

#define REP(i,n) for(int (i)=0; i<(int)(n); i++)

int main(void) {
	set <int> s;
	REP(i,3) {
		int x;
		cin >> x;
		s.insert(x);
	}
	if(s.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(void){
    int H, W, A, B;

    scanf("%d%d%d%d", &H, &W, &A, &B);

    int **s = (int **) malloc(sizeof(int *) * H);

    int i, j, k;

    for(i = 0; i < H; i ++){
        s[i] = (int *) malloc(sizeof(int) * W);

        for(j = 0; j < W; j ++){
            s[i][j] = 0;
        }
    }
    for(i = 0; i < B; i ++){
        for(j = 0; j < A; j ++){
            s[i][j] = 1;
        }
    }
    for(i = B; i < H; i ++){
        for(j = A; j < W; j ++){
            s[i][j] = 1;
        }
    }
    for(i = 0; i < H; i ++){
        for(j = 0; j < W; j ++){
            printf("%d", s[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 5120
/**
*@author: Ritchie Zhang
*@date:2020-4-26
**/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include <set>
typedef long long ll;
using namespace std;
int a[100010];

int main()
{
	int a, b, c, d,x,y;
	cin >> a >> b >> c >> d;
	c = c-b; // qingmu
	a = a-d; // gaoqiao
	while (c>0 && a>0)
	{
		c = c - b;
		a = a - d;
	}

	if (c <= 0)
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    cin >> K >> X;
    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############



N,T = IL()
A = IL()

ans = T

for i in range(N-1):
  ans += min(T,A[i+1]-A[i])
  
print(ans)


Measured memory_bytes: 78844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    string S;
    cin>>S;
    int zero=0,one=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='0') zero++;
        else if(S[i]=='1') one++;
    }
    cout<<min(zero,one)*2<<endl;
    return 0;
}

Measured memory_bytes: 512
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 2000000007
#define EPS 1e-9

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

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

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

bool cmp(const ii &a, const ii &b) {
    return ((a.ff > b.ff) || (a.ff == b.ff && a.ss < b.ss));
}

int n, m, cnt[maxN];
bool red[maxN];

int main () {
    scanf("%d%d", &n, &m);
    fto(i, 1, n) cnt[i] = 1;
    red[1] = true;

    fto(i, 1, m) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (red[x]) red[y] = true;
        --cnt[x]; ++cnt[y];
        if (cnt[x] == 0) red[x] = false;
    }

    int ans = 0;
    fto(i, 1, n) ans += red[i];
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 768
// B. 

#include <iostream>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int N, M, cnt[100000] = {}, red[100000] = { 1 };
	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cnt[i] = 1;
	}
	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y;
		--x, --y;
		if (red[x]) {
			red[y] = 1;
		}
		if (--cnt[x] == 0) {
			red[x] = 0;
		}
		++cnt[y];
	}
	int ans = accumulate(red, red + N, 0);
	cout << ans << endl;
	return 0;
}


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

#define ll long long 

const int mod=1e9+7;

ll ls[2*100001];

int main(){
    ll n;
    cin>>n;
    vector<ll> v;
    ll x;
    cin>>x;
    v.push_back(x);
    for(ll i=1;i<n;i++){
        cin>>x;
        if(x!=v.back()) v.push_back(x);
    }
    // for(auto it:v){
    //     cout<<it<<endl;
    // }
    n=v.size();
    ll dp[(ll)v.size()];
    dp[0]=1;
    memset(ls,0,sizeof(ls));
    ls[v[0]]=1;
    for(ll i=1;i<v.size();i++){
        if(ls[v[i]]){
            dp[i]=dp[i-1]+dp[ls[v[i]]-1];
        }
        else{
            dp[i]=dp[i-1];
        }
        dp[i]%=mod;
        ls[v[i]]=i+1;
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s,t;
    int flg = 1;
    cin >> s;
    cin >> t;
    string a = {},b = {};
    
    for(int i = 0;i < s.length();i++){
        string a = s.substr(0,i);
        string b = s.substr(i);
        string c = b + a;
        int x = c.compare(t);
        if(x == 0){
            flg = 0;
            break;
        }
    }

    if(flg == 1){
     cout << "No" << endl;
    }
    else if(flg == 0){
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int a[10002];
    a[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    int c[102][102];
    int count = 0;
    int nowc = 1;
    for(int i = 0; i < h; i++){
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                count++;
                c[i][j] = nowc;
                if(count >= a[nowc]) nowc++;
            }
        }
        else{
            for(int j = w - 1; j >= 0; j--){
                count++;
                c[i][j] = nowc;
                if(count >= a[nowc]) nowc++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] count = new int[26];
            var line = "";
            while ((line = Console.ReadLine()) != null)
            {
                var c = line.ToCharArray();
                for (int i = 0; i < c.Length; i++)
                {
                    if (char.IsLower(c[i]))
                    {
                        count[c[i] - 'a']++;
                    } else if (char.IsUpper(c[i]))
                    {
                        count[c[i] - 'A']++;
                    }
                }
            }

            for (int i = 0; i < count.Length; i++)
            {
                Console.WriteLine(Convert.ToChar('a' + i) + " : " + count[i]);
            }
        }
    }
}


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

int K;

int main()
{
    cin >> K;
    queue<long long> que;
    for(int i = 1; i < 10; i++) que.push(i);
    int count = 0;
    long long res;
    while(true)
    {
        res = que.front();
        count++;
        if(count == K) break;
        que.pop();
        long long mod = res % 10;
        if(mod != 0) que.push(10*res - 1 + mod);
        que.push(10 * res + mod);
        if(mod != 9) que.push(10*res + 1 + mod);
    }

    cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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

	int ans = false;
	
	int i, j, k;

	for (i = 0; i < n + 1; i++)
	{
		for (j = 0; j < n + 1 - i; j++)
		{
			k = n - i - j;

			int yy = 10000 * i + 5000 * j + 1000 * k;

			if (yy == y)
			{
				cout << i << " " << j << " " << k << endl;

				return 0;
			}
		}
	}
	
	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

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

	seiyaku_check(a,0,100);
	seiyaku_check(b,2,1000);

	if(a>=13)cout << b << endl;
	else if(6<=a && a<=12)cout << b/2 << endl;
	else cout << "0" << endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int x;
  cin>>x;
  int MAX=1;
  for(int i=2;i*i<=x;i++){
    int p=i;
    while(p*i<=x){
      p*=i;
    }
    chmax(MAX,p);
  }
  cout<<MAX<<endl;
  return 0;  
}

Measured memory_bytes: 3624
#include <iostream>

int main() {
    int H, W;
    while (true) {
        std::cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i ++) {
            for (int j = 0; j < W; j++) {
                std::cout << '#';
            }
            std::cout << std::endl;
        }
        std::cout <<std::endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, ans = inf, a[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++)
		scanf("%d",a + i);
	for(int i = 1; i <= 100; i++){
		int top = 0;
		for(int j = 1; j <= n; j++)
			top += (a[j] - i) * (a[j] - i);
		ans = min(ans, top);
	}
	printf("%d\n", ans);
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL

template<typename T>
void show(vector<T>& v) {
    cout << '[';
    for (const T& e : v) {
        cout << e << ',';
    }
    cout << ']' << endl;
}

#endif

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

template<typename T>
vector<T> read_n(const size_t n) {
    T dummy;
    vector<T> v(n);
    for (size_t i = 0; i < n; i++) {
        cin >> dummy;
        v[i] = dummy;
    }
    return v;
}

template<typename T>
vector<T> read_n() {
    size_t n;
    cin >> n;
    return read_n<T>(n);
}

int main() {
  init();

  size_t n;
  cin >> n;
  vector<int> v = read_n<int>(n);

  ull ave = (ull)round(accumulate(all(v), 0.0) / (double)n);
  ull res1 = 0;
  for (const auto& e: v) {
      res1 += (e - ave) * (e - ave);
  }
  cout << res1 << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int k = *max_element(a, a+n), l = *min_element(a, a+n);
    if (k - l >= 2) { cout << "No\n"; return  0; }
    if (k == l) {
        cout << (k == n-1 || n/2 >= k ? "Yes\n" : "No\n");
        return 0;
    }
    int x = 0;
    for (int b : a) if (b == k-1) x++;
    cout << (x <= k-1 && n-x >= 2 * (k-x) ? "Yes\n" : "No\n");
}


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

using namespace std;

const double EPS = 1e-8, PI = acos(-1);

inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

struct Point
{
  double x, y;

  Point() {}

  Point(double x, double y) : x(x), y(y) {}

  Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); }

  Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }

  Point operator*(const double b) const { return Point(x * b, y * b); }

  Point operator*(const Point &b) const { return Point(x * b.x - y * b.y, x * b.y + y * b.x); }

  Point operator/(const double b) const { return Point(x / b, y / b); }

  bool operator<(const Point &b) const { return x != b.x ? x < b.x : y < b.y; }

  bool operator==(const Point &b) const { return eq(x, b.x) && eq(y, b.y); }

  double norm() { return x * x + y * y; }

  double arg() { return atan2(x, y); }

  double abs() { return sqrt(norm()); }

  Point rotate(double theta) { return Point(cos(theta) * x - sin(theta) * y, sin(theta) * x + cos(theta) * y); }

  Point rotate90() { return Point(-y, x); }

  friend ostream &operator<<(ostream &os, Point &p) { return os << "(" << p.x << "," << p.y << ")"; }

  friend istream &operator>>(istream &is, Point &a) { return is >> a.x >> a.y; }
};

double DegreeToRadian(double d)
{
  return (d * acos(-1) / 180.0);
}

int main()
{
  cout << fixed << setprecision(10);

  int N, D;
  while(cin >> N >> D, N) {
    Point a(-D, 0), b(D, 0);
    while(N--) {
      double L, R, T;
      cin >> L >> R >> T;
      L = DegreeToRadian(L);
      R = DegreeToRadian(R);

      Point delta = (b - a) / (b - a).abs();

      if(L == R) {
        delta = delta.rotate90() * L * T;
        a = a + delta;
        b = b + delta;
      } else {
        double rr = D * (L + R) / (L - R);
        Point cc = ((a + b) * 0.5) + delta * rr;
        double theta;
        if(L == 0) theta = -T * R / (rr - D);
        else theta = -T * L / (rr + D);
        a = cc + (a - cc).rotate(theta);
        b = cc + (b - cc).rotate(theta);
      }
    }

    Point c = (a + b) * 0.5;

    cout << c.x << endl;
    cout << c.y << endl;
  }
}

Measured memory_bytes: 3504
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int inp[N];

int main(){
  int n, m;
  fastScan(m);
  fastScan(n);
  for(int i = 1; i <= n; i++){
    int x;
    fastScan(x);
    inp[x]++;
  }
  int ans = 0, diff = 222;
  for(int i = 0; i <= 200; i++){
    if(inp[i] == 0){
      int d = abs(i - m);
      if(d < diff){
        diff = d;
        ans = i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3752
# 全ての重さがw1,w1 + 1,w1 + 2,w1 + 3のいずれかである
# 共通の重さであるw1を引いた値、0,1,2,3で重さナップサック
# ただし、そこまでに使った物の数もdpで管理し、[数] * w1 + [0,1,2,3の重さ]がWを越えないようにDPする。
# 配列の長さは3 * N + 1(0の状態を管理するため+1)でOK

N,W = map(int,input().split())
items = [None] * N
items[0] = list(map(int,input().split()))
base = items[0][0]
items[0][0] = 0
for i in range(1,N):
  items[i] = list(map(int,input().split()))
  items[i][0] -= base

# dp[0,1,2,3の重さ(3 * N + 1)][商品数(N)] = 価値の最大値
dp = [[-1 for i in range(N + 1)] for j in range(3 * N + 1)]
# 重さ0で商品を一つも入れていない状態は価値0
dp[0][0] = 0
for i in range(len(items)):
  w = items[i][0]
  v = items[i][1]
  for j in range(len(dp)-1,-1,-1):
    # jは[重さ]
    for k in range(len(dp[j])-1,-1,-1):
      # kは商品の個数
      if dp[j][k] != -1:
        if j + w < len(dp) and k * base + j <= W:
          if dp[j + w][k + 1] < dp[j][k] + v:
            dp[j + w][k + 1] = dp[j][k] + v
            
ans = 0
for i in range(len(dp)):
  for j in range(len(dp[i])):
    if i + j * base <= W and ans < dp[i][j]:
      ans = dp[i][j]
      
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <stdlib.h> 
using namespace std;

void dfs(int x, int y, char s);

int H,W;
char** field;

int main() {
  while(cin >> H >> W && H && W){
      field =(char**) malloc(sizeof(char*)*H);
    
      for(int i=0; i<H;i++){
          char* row = (char*)malloc(sizeof(char)*W);
          cin >> row;
          field[i] = row;
      }
    
      int result = 0;
    
      for(int i=0; i < H; i++){
          for(int j=0; j < W; j++){
    
              if(field[i][j] == '#' || field[i][j] == '*' || field[i][j]=='@'){
                  dfs(j, i, field[i][j]);
                  result++;
              }
          }
      }
    
      cout << result << endl;

      for(int i=0; i<H; i++){
          free(field[i]);
      }

      free(field);
  }

  return 0;
}

void dfs(int x, int y, char s){

    field[y][x] = '0';

    int pattern[4][2]= { {-1,0}, {1,0}, {0,-1}, {0,1}};

    for(int i = 0; i<4; i++){
    
        int nx = x + pattern[i][0];
        int ny = y + pattern[i][1];
       
        if(0<=nx && nx < W && 0<=ny && ny < H && field[ny][nx]==s){
            dfs(nx,ny,s);
        }
    }
}

Measured memory_bytes: 2144
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s;
    cin >> s;

    int ans = 0;
    REP(j, s.size()) {
        int cand = 0;
        RANGE(i, j, s.size()-1) {
            if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') break;
            cand++;
        }
        chmax(ans, cand);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)

using namespace std;

int main(){
	string S;
	cin >> S;
	if(S== "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3128
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(sum(map(abs, a)))
  exit()
minus = len([i for i in range(n) if a[i]<0 ])
if minus % 2 == 0:
  print(sum(map(abs, a)))
else:
  a = sorted(a, key=lambda x: abs(x))
  print(sum(map(abs, a[1:]))-abs(a[0]))


Measured memory_bytes: 14412
n = int(int(input()))
s = [0]*n
t = [0]*5
for i in range(n):
    s[i] = input()
    if s[i][0] == "M":
        t[0] += 1
    elif s[i][0] == "A":
        t[1] += 1
    elif s[i][0] == "R":
        t[2] += 1
    elif s[i][0] == "C":
        t[3] += 1
    elif s[i][0] == "H":
        t[4] += 1
import itertools
data = list(range(5))
r = 3
C = list(itertools.combinations(data, r))
ans = 0
for L in C:
    ans += t[L[0]] * t[L[1]] * t[L[2]]
print(ans)

Measured memory_bytes: 9716