akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>
#include <complex>
#include <cmath>
#include <iostream>
#include <iomanip>

int A, B, H, M;
long  double gannma, c ,zeta;
const double PI=3.14159265358979323846;

int main() {
  std::cin >> A >> B >> H >> M;
  zeta = std::abs(((long double)(H+((long double)M)/60))/12 - ((long double)M)/60);
  gannma = 2 * PI * zeta;
  c = std::sqrt(std::abs(A*A + B*B - 2*A*B*std::cos(gannma)));

  std::cout << std::fixed << std::setprecision(10) <<  c << std::endl;
}



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

int main() {
int tot=0,i,n,k;
string s;
cin>>s;
n=s.size();
for(i=0;i<n;i++){
    k=(int)(s[i]-'0');
    tot+=k;
}
if(tot%9){cout<<"No";}
else{cout<<"Yes";}
	return 0;
}


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

int main(void) {
    int i, j, N, S, a[10010], d, e[10010];
    scanf("%d", &N);
    for (i=0;i<N;i++) {
        scanf("%d", &a[i]);
    }

    memset(e,0,N);
    for (i=0;i<N;i++) {
        d = a[i];
        j = 0;
        while (d%2 == 0) {
            d /= 2; j++;
        }
        e[i] = j;
    }
    S = 0;
    for (i=0;i<N;i++) S += e[i];
    printf("%d\n", S);
    return 0;
}

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

int main(){
  int N;
  int K;
  cin >> N >> K;
  
  int out=1;
  for(int i=0;i<N;i++){
    out=min(out*2, out+K);
  }
  
  cout << out << endl;
  
}

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

int main() {
  int N;
  cin >> N;
  string S = "No";
  for (int i = 1; i < 10; i++) {
    if (N % i == 0 && N / i < 10) {
      S = "Yes";
    }
  }
  cout << S << endl;
      
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int td(int n,vector<int> a,int k)
{
    vector<int> dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=i-1;j>=1 && (i-j)<=k;j--)
        {
           //cout<<"++";
           dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
        }
    }
    return dp[n];
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    cout<<td(n,a,k);
}


Measured memory_bytes: 4304
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
//#define endl "\n"
#define fi first
#define se second
#define fr front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}




signed main() {
	int l, r, ans=2018;
	cin >> l >> r;
	if (r / 2019 - l / 2019 >= 1) {
		cout << 0 << endl;
		return 0;
	}
	l %= 2019;
	r %= 2019;

	for (int i = l; i <= r; i++) {
		for (int j = i+1; j <= r; j++) {
			ans = min(ans, (i * j) % 2019);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def solve(H: int):

    if H == 1:
        print("1")
        return

    i = 1
    m = 1

    while True:
        H = H // 2
        i *= 2
        if H == 1:
            i += i
            i -=1
            break
    print(i)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import string
while True:
    try:
        pd=0
        n=int(input())
        l=list(map(int,input().split()))
        L=l[:]
        L.sort()
        for i in range(n):
            for j in range(n):
                l[i],l[j]=l[j],l[i]
                if L==l:
                    pd=1
                    break
                else:
                    l[i], l[j] = l[j], l[i]
            if pd==1:
                break
        if pd==1:print("YES")
        else:print("NO")
    except:break

Measured memory_bytes: 3772
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count-1 << endl;
}

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

int main() {
    int n;
    int m;
     int l;
  
   
   cin >> n >> m >>l;
  
  if (n*m < l){
    
    
    cout << n*m << endl;
    
  }else{
    
    cout << l << endl;
    
  }
  

  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int k, n, a, b, pr, m;

int main () {
  cin >> k >> n;
  cin >> pr; b = pr;
  for (int i = 2; i <= n; i++) {
    cin >> a;                  //[ideea de rezolvare] e
    m = max (m, a - b); //(perimetru - distana maxima dintre doua case)
    b = a;
  }
  m = max (m, pr + k - b); // daca te intoarci din casa (1) in casa (n)
  cout << k - m << endl;
  return 0;
}


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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> v(m);
  ll sum = 0;
  for(int i = 0; i < m; i++){
    cin >> v[i];
    sum += v[i];
  }
  if(sum > n){cout << -1 << endl;}
  else{cout << n-sum << endl;}

}


Measured memory_bytes: 3680
//Something on It
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    vector<int>price={100,100,100};
    int sum=700;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='o')sum+=price.at(i);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  long N, K;
  cin  >> N >> K;

  //a%bがk以上a%b >= k
  //→ a-b >=k && gcd(a,b) >=k
  //n= ab +r (r >= k)
  // a%bのかずは 0から b-1までこっからkを引くから
  long count=0;
  for(int b=1;b<=N;b++){
    count+= (N/b)*max((long)0,b-K) + max((long)0,N-((N/b)*b)-K+1 ) ;
    if (K==0)count--;
  }


   cout << count ;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a, b, r;
  string text;

  cin >> a >> b;
  r =  a * b;
  if (r % 2 == 0) {
    text = "Even";
  } else {
    text = "Odd";
  }

  cout << text << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
void sortarry(int* Array,int n )
{
int Tmp=0;
int i=0;
int j=0;

for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(Array[i]<Array[j] )
{
Tmp=Array[i];
Array[i]=Array[j];
Array[j]=Tmp;
}
}
}

return ;
}

int main( void )
{
int Array[10];
int i=0;

for(i=0;i<10;i++ )
{
scanf("%d",&Array[i] );
}
sortarry(Array,10 );

for(i=0;i<3;i++)
{
printf("%d\n",Array[i] );
}
}

Measured memory_bytes: 0
function Main(input) {
	const col = input.split("\n");
	const row = col[1].split(" ");

	if(row.length < 3){
		console.log(0);
	} else {
		const triangle = function(a, b, c) {
			const check = (d, e ,f) => (d + e) > f;
			return check(a, b, c) && check(b, c, a) && check(c, a, b);
		}
		const diff = (a, b, c) => a !== b && b !== c && c !== a;

		let list = [];
		for(let s=0; s < row.length; s++){
			list.push(parseInt(row[s], 10));
		}
		let cnt = 0;
		for(let i=0; i < list.length-2; i++){
			for(let j=i+1; j < list.length-1; j++){
				for(let k=j+1; k < list.length; k++){
					if(triangle(list[i],list[j],list[k]) && diff(list[i],list[j],list[k])) {
						cnt++;
					}
				}
			}
		}
		
		console.log(cnt);
	}
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32468
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);

void solv()
{
    char s[70];
    scanf(" %s", s);
    s[3] = 0;
    printf("%s\n", s);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 3696
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

x = 100000
ans = 0

for i in range(N):
    temp = abs(A -(T - H[i]*0.006))
    if abs(A -(T - H[i]*0.006)) < x:
        x = abs(A -(T - H[i]*0.006))
        ans = i

print(ans+1)







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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

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

    vector<vector<int>> students = vector<vector<int>>(n, vector<int>(2, 0));

    rep(i, n) {
        int c;
        cin >> c;

        students[i][0] = i;
        students[i][1] = c;


    }

    sort(students.begin(), students.end(), [](vector<int> a, vector<int> b) {
        return a[1] < b[1];
    });

    rep(i, n) {
        cout << students[i][0] + 1 << endl;
    }


}


Measured memory_bytes: 6272
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define maxn 1000000000
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    ull s;
    cin>>s;
    if(s<=maxn) cout<<0<<' '<<0<<' '<<0<<' '<<s<<' '<<1<<' '<<0<<endl;
    else if(s==1e18) cout<<0<<' '<<0<<' '<<0<<' '<<maxn<<' '<<maxn<<' '<<0<<endl;
    else{
        ull s1=s/maxn;
        s1++;
        ull s2=s1*maxn-s;
        cout<<0<<' '<<0<<' '<<s1<<' '<<1<<' '<<s2<<' '<<maxn<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
  let lines = input.split("\n");
  let numInfo = lines.shift().split(" ")[1];
  // 答えを調べる用のMap
  let ansObj = {};
  for(let i = 0; i < numInfo;i++){
    	let quesNum = lines[i].split(" ")[0];
    	let ansKind = lines[i].split(" ")[1];
    	if(ansObj[quesNum] === undefined){
          ansObj[quesNum] = `${ansKind}`;
        } else {
        ansObj[quesNum] += `,${ansKind}`;
        }
  }
  let WANum = 0;
  let ACNum = 0;
  // objectは直接要素数は取れないらしい
  let ansObjKeys = Object.keys(ansObj);
    for(let i = 0; i < ansObjKeys.length; i++){
      let targetKey = ansObjKeys[i];
      // 対象を配列として切り出したもの
      let target = ansObj[targetKey].split(",");
      // 今回の解答対象になるのはACを含んでいる時だけなのでそのことを追加
      if(target.indexOf('AC')!= -1){
        for(let j = 0; j < target.length; j++){
          if(target[j] == 'AC') {
            ACNum++;
            break;
          } else {
            WANum++;
          } 
        }
      }
    }
  console.log(ACNum + " " + WANum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 47892
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  [h, w] <- map (read::String -> Int) . words <$> getLine
  [x, y] <- map (read::String -> Int) . words <$> getLine
  print $ h * w - x * w - y * h + x * y

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,p,pt[200010],i;
  cin >> n;
  if (n==1){
    cout << 0 << endl;
    return 0;
  }
  for (i=0;i<n;i++){
    cin >> p;
    pt[p-1]=i+1;
  }
  int l=0,r=1,m=0;
  while (r<n){
    while (r<n && pt[r]>pt[r-1]) r++;
    if (m<r-l) m=r-l;
    l=r;
    r++;
  }
  cout << n-m << endl;
  return 0;
}

Measured memory_bytes: 1024
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/29/20 20:54:54
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int d,t,s; cin>>d>>t>>s;
  bool ans = (d-1)/s+1 <= t;
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 10;
ll n, a[N], B[N];
int main(){
	scanf("%lld", &n);
	ll sum = 0;
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sum = a[n];
	ll sum1 = 0;
	for(int i = 1; i <= n - 1; i += 2) sum1 += a[i + 1] - a[i];
	//cout << sum << " " << sum1 << endl;
	ll Bn = (sum + sum1) / 2, B1 = sum - Bn;B[1] = B1 * 2;
	for(int i = 1; i <= n - 1; i++) B[i + 1] = (a[i] - B1) * 2, B1 = B[i + 1] / 2;
	for(int i = 1; i <= n; i++) printf("%lld ", B[i]);
	return 0;
}




Measured memory_bytes: 2944
#include<stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	int A[N];
	for(int i=0;i<N;i++) scanf("%d",&A[i]);
	int ans=0;
	while(1){
		int check=1;
		for(int i=0;i<N;i++){
			if(A[i]%2!=0) check=0;
			A[i]/=2;
		}
		if(!check) break;
		ans++;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    v1 = v2 = 0
    for line in readlines():
        a, b, c = map(int, line.split(","))
        if a**2 + b**2 == c**2:
            v1 += 1
        if a == b:
            v2 += 1
    write("%d\n" % v1)
    write("%d\n" % v2)
solve()



Measured memory_bytes: 5608
import java.util.Scanner;

public class Main{
	public static void main(String[]args){

		Scanner sc=new Scanner(System.in);

		int r=sc.nextInt();
		if(r<1200){
			System.out.println("ABC");
		}else if(r<2800){
			System.out.println("ARC");
		}else{
			System.out.println("AGC");
		}

	}
}



Measured memory_bytes: 20692
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vl m(n);
	vl v(n);
	vl l(n);
	REP(i, n)cin >> v[i];
	vl dp(n + 1, INF);
	vector<set<pll>> st(n + 1);
	st[0].insert({ -1,0 });
	REP(i, n) {
		int c = lower_bound(ALL(dp), v[i]) - dp.begin();
		dp[c] = v[i];
		auto it = st[c].lower_bound({ v[i],0 });
		it--;
		m[i] = (*it).second + v[i];
		l[i] = c + 1;
		st[c + 1].insert(pll(v[i], m[i]));
	}
	int k = *max_element(ALL(l));
	ll ans = 0;
	REP(i, n)if (l[i] == k)chmax(ans, m[i]);
	cout << ans << endl;
}


Measured memory_bytes: 16744
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int n = int(s.size()) + 1;
    V<ll> res(n);    
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == '<') res[i + 1] = max(res[i + 1], res[i] + 1);
    }
    for (int i = n - 1; i >= 1; i--) {
        if (s[i - 1] == '>') res[i - 1] = max(res[i] + 1, res[i - 1]);
    }
    dbg(res);
    ll ans = 0;
    for (auto x: res) ans += x;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4764
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		
		int x3 = x2 - y2 + y1;
		int y3 = y2 + x2 - x1;
		int x4 = x3 - y3 + y2;
		int y4 = y3 + x3 - x2;
		
		StringBuilder sb = new StringBuilder();
		sb.append(x3).append(" ").append(y3).append(" ").append(x4).append(" ").append(y4);
		System.out.println(sb);
	}
}

Measured memory_bytes: 22612
using System;

namespace AtCoder20200426second
{
    class Program
    {
        static void Main(string[] args)
        {
            var q = Console.ReadLine()?.Split(" ");

            int[] t = new[] {int.Parse(q[0]), int.Parse(q[1]), int.Parse(q[2]), int.Parse(q[3])};

            int i = 1;
            string a = "";

            while (true)
            {
                if (t[2] <= t[1] * i)
                {
                    a = "Yes";
                    break;
                }

                if (t[0] <= t[3] * i)
                {
                    a = "No";
                    break;
                }

                i++;
            }

            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 27424
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

vec kmp_table(string W) {
    ll i = 2, j = 0;
    vec T(W.size(), -1);
    T[1] = 0;

    while (i < W.size()) {
        if (W[i-1] == W[j]) {
            T[i] = j+1;
            i++;
            j++;
        } else if (j > 0) j = T[j];
        else {
            T[i] = 0;
            i++;
        }
    }

    return T;
}

vec kmp_search (string S, string W, vec T) {
    vec ret;
    ll m = 0, i = 0;
    while (m+i < S.size()) {
        if (W[i] == S[m+i]) {
            i++;
            if (i == W.size()) {
                if (m % 32 == 0) ret.push_back(m/32);
                i--;
                m = m+i-T[i];
                i = T[i];
            }
        } else {
            m = m+i-T[i];
            if (i > 0) i = T[i];
        }
    } 
    return ret;
}

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

    ll N;
    cin >> N;
    vec A(N), B(N);
    Rep (i, N) cin >> A[i];
    Rep (i, N) cin >> B[i];

    vec da(N), db(N);
    stringstream ssa, ssb;
    Rep (i, N) {
        da[i] = A[i] ^ A[(i+1)%N];
        db[i] = B[i] ^ B[(i+1)%N];
        ssa << bitset<32>(da[i]);
        ssb << bitset<32>(db[i]);
    }

    string sa = ssa.str();
    string sb = ssb.str();

    // cout << sa << "\n";
    // cout << sb << "\n";

    sa += sa;
    sa.pop_back();
    vec t = kmp_table(sb);
    t = kmp_search(sa, sb, t);
    Rep (i, t.size()) {
        cout << t[i] << " " << (A[0] ^ B[(N-t[i])%N]) << "\n";
    }

}

Measured memory_bytes: 162492
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;

fn main() {

    input!{
       n:usize,
    }

    for i in 0..26 {
        for j in 0..15 {
            if( 4*i + 7*j) ==n {
                println!("Yes");
                return;
            }

        }
    }

    println!("No")



}


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

int main(){
  long n; cin >> n;
  vector<pair<string, long>> p(n);
  for(int i = 0; i < n; i++){
    long point;
    cin >> p.at(i).first;
    cin >> point;
    p.at(i).second = point * 1000 + (i + 1); 
  }
  if(n == 1){
    cout << 1;
    return 0;
  }
  sort(p.begin(), p.end());
  priority_queue<long> que;
  que.push(p.at(0).second);
  for(int i = 1; i < n; i++){
    if(p.at(i).first == p.at(i - 1).first){
      que.push(p.at(i).second);
    }else{
      while(!que.empty()){
        cout << que.top() % 1000 << endl;
        que.pop();
      }
      que.push(p.at(i).second);
    }
    if(i == n - 1){
      while(!que.empty()){
        cout << que.top() % 1000 << endl;
        que.pop();
      }
    }
  }
}


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

l=-1
while l-2>=-len(S):
    k=S[l:l-3:-1]
    if k=="mae":
        T+="dream"[::-1]
        l-=5
    elif k=="rem":
        T+="dreamer"[::-1]
        l-=7
    elif k=="esa":
        T+="erase"[::-1]
        l-=5
    elif k=="res":
        T+="eraser"[::-1]
        l-=6
    else:
        break
if S=="".join(T[::-1]):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 49136
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
#include <functional>

using namespace std;

const int N = 2e5 + 7;

int n;
vector<int> a;

int fnd = 0;
int used[4 * N];
vector<int> ng[4 * N];

int new_state(int v, int x) {
    return 4 * v + x;
}

void add_edge(int v, int xv, int u, int xu) {
    ng[new_state(v, xv)].push_back(new_state(u, xu));
}

void dfs(int cur) {
    used[cur] = 1;
    for (auto t : ng[cur]) {
        if (used[t] == 1) {
            fnd = 1;
        }
        if (!used[t]) {
            dfs(t);
        }
    }
    used[cur] = 2;
}

int solve() {
    for (int i = 0; i < 4 * n; i++) {
        if (!used[i]) {
            dfs(i);
        }
    }
    return fnd;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        a.push_back(c == 'A');
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> nd = {0, 0, 1, 1};
    for (int i = 0; i < n; i++) {
        for (auto t : g[i]) {
            for (int f = 0; f < 4; f++) {
                for (int s = 0; s < 4; s++) {
                    if (nd[f] == a[i] && nd[s] == a[t] && (f + 1) % 4 == s) {
                        add_edge(i, f, t, s);
                    }
                }
            }
        }
    }
    if (solve()) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}   


Measured memory_bytes: 43892
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int N, K;
    cin >> N >> K;
    vector<ll> h(N), dp(N, 1e15);
    for (int i = 0; i < N; i++)
        cin >> h[i];
    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            if (i + j >= N)
                break;
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n;

void Input() {
	cin >> n;
}

void Solve() {
	vll a(n + 1);
	for (ll i = 1; i <= n; i++) cin >> a[i];
	ll dp[n + 1][n + 1];
	for (ll l = n; l >= 1; l--) {
		for (ll r = l; r <= n; r++) {
			if (l == r)dp[l][r] = a[l];
			else dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
		}
	}
	cout << dp[1][n];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

Measured memory_bytes: 49752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const ll inf = 1e18;

ll mxnonleaf[N], leaf[N], nonleaf[N];

int main() {

  int n; cin >> n;
  for(int i = 0; i <= n; i++) cin >> leaf[i];
  ll now = 1;
  bool flag = 1;
  for(int i = 0; i <= n; i++){
    if(i and mxnonleaf[i - 1] >= inf){
      mxnonleaf[i] = inf; continue;
    }
    if(now < leaf[i]){
      flag = 0; break;
    }
    now -= leaf[i];
    mxnonleaf[i] = now;
    now *= 2LL;
  }
  if(!flag){
    cout << -1 << endl;
    return 0;
  }
  for(int d = n; d >= 1; d--){
    ll nodes = nonleaf[d] + leaf[d];
    // cout << d << ' ' << nodes << endl;

    if(nodes <= mxnonleaf[d - 1]){
      nonleaf[d - 1] = nodes;
      continue;
    }

    if(nodes > 2 * mxnonleaf[d - 1]){
      flag = 0; break;
    }
    ll one = 2 * mxnonleaf[d - 1] - nodes;
    ll two = (nodes - one + 1) / 2;
    nonleaf[d - 1] = one + two;
  }
  if(!flag){
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0LL;
  for(int i = 0; i <= n; i++){
    ans += nonleaf[i] + leaf[i];
  }
  cout << ans << endl;

  return 0; 
}

Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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 INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = -INF;
    vector<int> V(n);
    for(int i = 0; i < n; i++) cin >> V[i];

    for(int take = 0; take <= k; take++){
        for(int l = 0; l <= take; l++){

            if(l > n) break;

            int r = min(take - l, n - l);
            vector<int> mine;

            for(int i = 0; i < l; i++){
                mine.pb(V[i]);
            }
            for(int i = 0; i < r; i++){
                mine.pb(V[n-i-1]);
            }

            sort(all(mine));

            for(int i = 0; i < min((int)mine.size(), k - take); i++){
                if(mine[i] >= 0) break;
                mine[i] = 0;
            }

            int sum = 0;
            for(int i = 0; i < mine.size(); i++){
                sum += mine[i];
            }
            chmax(ans, sum);
        }
    }
    cout << ans <<  endl;
    return 0;
}


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

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

ll L[51];
ll a[51];

ll patty(ll x,int n){
  if(x<=0)return 0;
  if(n==0)return 1;
  if(x>=L[n])return a[n];
  ll cnt=patty(x-1,n-1)+patty(x-2-L[n-1],n-1);
  if(x>L[n-1]+1)cnt++;
  return cnt;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int m=(n+1)/2;
  ll sum=0,ma=0;
  if(n%2==0){
    sum+=a[m];
    for(i=m+1;i<n;i++)sum+=2*a[i];
    sum-=a[m-1];
    for(i=0;i<m-1;i++)sum-=2*a[i];
    cout<<sum<<endl;
    return 0;
  }
  for(i=m;i<n;i++)sum+=2*a[i];
  sum-=a[m-1]+a[m-2];
  for(i=0;i<m-2;i++)sum-=2*a[i];
  ma=sum;sum=0;
  sum+=a[m-1]+a[m];
  for(i=m+1;i<n;i++)sum+=2*a[i];
  for(i=0;i<m-1;i++)sum-=2*a[i];
  cout<<max(ma,sum)<<endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

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

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	map<int, int> a, b;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if (i % 2 == 0)
		{
			a[x]++;
		}
		else
		{
			b[x]++;
		}
	}

	int m = n / 2;

	vector<pair<int, int>> ap;
	for (map<int, int>::iterator it = a.begin(); it != a.end(); it++)
	{
		pair<int, int> i = *it;
		ap.push_back(make_pair(i.second, i.first));
	}

	sort(ap.begin(), ap.end());
	reverse(ap.begin(), ap.end());

	vector<pair<int, int>> bp;
	for (map<int, int>::iterator it = b.begin(); it != b.end(); it++)
	{
		pair<int, int> i = *it;
		bp.push_back(make_pair(i.second, i.first));
	}

	sort(bp.begin(), bp.end());
	reverse(bp.begin(), bp.end());

	int ans = 0;
	if (a.size() == 1 && b.size() == 1)
	{
		if (ap.front().second == bp.front().second)
		{
			ans = m;
		}
		else
		{
			ans = 0;
		}
	}
	else
	{
		if (ap.front().first == bp.front().first)
		{
			if (ap.front().second == bp.front().second)
			{
				if (ap.at(1).first > bp.at(1).first)
				{
					ans = (m - bp.front().first) + (m - ap.at(1).first);
				}
				else
				{
					ans = (m - ap.front().first) + (m - bp.at(1).first);
				}
			}
			else
			{
				ans = 2 * (m - ap.front().first);
			}
		}
		else
		{
			if (ap.front().first > bp.front().first)
			{
				ans = m - bp.front().first;
			}
			else
			{
				ans = m - ap.front().first;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    string s1; cin >> s1;
    if(s1 == ".") break;
    string s2; cin >> s2;
    vector<string> v1, v2;
    vector<string> c1, c2;
    vector<string> p1, p2;
    int pos = 0;
    bool odd = false;
    for(int i=0;i<(int)(s1.size());++i) {
      if(s1[i] == '"') {
        if(odd) {
          v1.push_back(s1.substr(pos+1, i - pos - 1));
          c1.push_back(s1.substr(pos+1, i - pos - 1));
          odd = false;
        } else {
          pos = i;
          odd = true;
        }
      } else if(!odd) {
        v1.push_back(s1.substr(i, 1));
        p1.push_back(s1.substr(i, 1));
      }
    }
    for(int i=0;i<(int)(s2.size());++i) {
      if(s2[i] == '"') {
        if(odd) {
          v2.push_back(s2.substr(pos+1, i - pos - 1));
          c2.push_back(s2.substr(pos+1, i - pos - 1));
          odd = false;
        } else {
          pos = i;
          odd = true;
        }
      } else if(!odd) {
        v2.push_back(s2.substr(i, 1));
        p2.push_back(s2.substr(i, 1));
      }
    }
    if((int)(v1.size()) != (int)(v2.size()) || (int)(c1.size()) != (int)(c2.size()) || (int)(p1.size()) != (int)(p2.size())) {
      cout << "DIFFERENT" << endl;
      continue;
    }
    int cnt1 = 0;
    for(int i=0;i<(int)(v1.size());++i) {
      if(v1[i] != v2[i]) cnt1++;
    }
    int cnt2 = 0;
    for(int i=0;i<(int)(p1.size());++i) {
      if(p1[i] != p2[i]) cnt2++;
    }
    int cnt3 = 0;
    for(int i=0;i<(int)(c1.size());++i) {
      if(c1[i] != c2[i]) cnt3++;
    }
    if(cnt2 != 0 || cnt3 > 1 || cnt1 != cnt2 + cnt3) {
      cout << "DIFFERENT" << endl;
    } else if(cnt3 == 0) {
      cout << "IDENTICAL" << endl;
    } else if(cnt3 == 1) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }
}



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

int main() {
    string s,ans="No";
    cin >> s;

    if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) ans="Yes";

    cout<<ans<<endl;
}


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>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int k,n;
    cin>>k>>n;
    int a[n];
    int a0=0;
    int b=0;
    int bmax=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b=a[i]-a0;
        a0=a[i];
        if(b>bmax){
            bmax=b;
        }
    }
    if(k-a[n-1]+a[0]>bmax){
        bmax=k-a[n-1]+a[0];
    }
    cout<<k-bmax;
}

Measured memory_bytes: 1152
#https://atcoder.jp/contests/dp/tasks/dp_d
#2019-01-13
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]

DP = [0] * (W+1)
# i 円以下で買える商品の最大価値
for i in range(N):
    for weight in range(W,-1,-1):
        if weight - w[i] < 0 :continue
        DP[weight] = max(DP[weight], DP[weight - w[i]] +v[i])
print(DP[-1])

Measured memory_bytes: 41708
def sub():
    N, Hs = [input() for _ in range(2)]
    Hs = [int(e) for e in Hs.split(" ")]
    count = 1
    maxH = Hs[0]
    for i in range(1, int(N)):
        h = Hs[i]
        if h >= maxH:
            count = count + 1
            maxH = h


    print("{}".format(count))

sub()



Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		ll N, a;

		cin >> N;
		if (cin.fail()) break;

		auto count = [](ll a) {
			int result = 0;
			while ((a & 1) == 0) {
				a >>= 1;
				result++;
			}
			return result;
		};
		
		cin >> a;
		int result = count(a);
		while (--N) {
			cin >> a;
			result += count(a);
		}
		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  string s,t;
  cin>>s>>t;
  int n=s.length(),flag=0;
  if(s==t) flag=1;
  rep(i,0,n){
    string h=s.substr(i)+s.substr(0,i);
    if(t==h) flag=1;
  }
  // int flag=0;
  if(flag) cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 500005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	string s;
	cin>>s;
	ll i,j,k,mx=0;
	k=0;
	for(i=0;i<3;i++){
		if(s[i]=='R') k++;
		else k=0;
		mx=max(mx,k);
	}
	cout<<mx<<endl;

	return 0;	
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,d,h;
  cin>>h;
  cin>>a;
  cin>>b;
  c=0;
  for(int i=a;i<=b;i++){
    if(h%i==0)
      c=c+1;
  }
  cout<<c<<endl;
  return(0);
}

    



Measured memory_bytes: 3108
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		int b = in[a-1];
        System.out.println(b);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll ans = llINF;
  for(ll i=-111;i<=111;i++){
    ll sum = 0;
    for(auto a:A){
      sum += (a-i)*(a-i);
    }
    ans = min(sum,ans);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int s;
	cin >> s;
	set<int>ss;
	int i = 0;
	while (!ss.count(s)) {
		ss.insert(s);
		if (s % 2 == 0)s /= 2;
		else s = 3 * s + 1;
		++i;
	}
	cout << i + 1 << endl;
}

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

int main() {
  // 科目の数Nを受け取る
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  const int max = min(S, K); 
  for(int X = 0; X <= max; X++)
  {
    const int resX = S - X; // this must be equal or larger than 0 
    if( resX <= K )
    {
      // Y = 0, 1, ..., resX 
      // Z = resX, resX -1, ..., 0 
      count += resX + 1;
    }
    else if( resX <= 2 * K)
    {
      // Y = resX - K, resX - K + 1, ..., K + 1, K
      // Z = K, K + 1, ..., resX - K + 1, resX - K
      count +=  2 * K - resX + 1; // K - (resX - K) + 1;
    }
  }
  cout << count << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int k = int.Parse(cin[1]);

        if (n < k) Console.WriteLine(0);
        else Console.WriteLine(n + 1 - k);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

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

    if(n<=9){
        cout << r+100*(10-n) << endl;
    }else{
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

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

    int ans = 0;
    map <int, int> m;

    for (int i = 0; i < N; i++){
        int A;
        cin >> A;
        if (m[A] == 0){
            m[A] ++;
            ans ++;
        }else{
            m[A] --;
            ans --;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	private static final long x = (long) Math.pow(10, 18);

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t[] = new int[n];

		int sum = 0;
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			sum += t[i];
		}

		int m = sc.nextInt();
		int px[][] = new int[m][2];

		for (int i = 0; i < m; i++) {
			px[i][0] = sc.nextInt();
			px[i][1] = sc.nextInt();
		}

		for (int i = 0; i < m; i++) {
			System.out.println(sum - t[px[i][0] - 1] + px[i][1]);
		}

		sc.close();
	}

}


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

int ans[100005];

int main() {

  int N;
  cin >> N;
  vector< vector< pair<int,ll> > > to(N);
  REP(i,N-1) {
    int u,v;
    ll w;
    cin >> u >> v >> w;
    u--; v--;
    to[u].emplace_back( v, w );
    to[v].emplace_back( u, w );
    ans[i] = -1;
  }
  ans[N-1] = -1;
  queue<int> q;
  q.push(0);
  ans[0] = 0;
  while( !q.empty() ) {
    int v = q.front(); q.pop();
//    cout << " " << v << endl;
    for ( auto nv: to[v] ) {
//      cout << " -  " << nv.first << endl;
      if ( ans[nv.first] != -1 ) continue;
      if ( ans[v] == 0 ) {
        ans[nv.first] = (nv.second % 2==0) ? 0 : 1;
      } else {
        ans[nv.first] = (nv.second % 2==0) ? 1 : 0;
      }
      q.push( nv.first );
    }
  }
  REP(i,N)
    cout << ans[i] << endl;

}


Measured memory_bytes: 8320