akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <bitset>
#include <vector>

int main() {
    int N, K;
    std::cin >> N >> K;
    std::string S;
    std::cin >> S;

    std::vector<std::pair<char, int>> sequence;

    int count = 1;
    for (auto itr = S.begin() + 1; itr != S.end(); itr++) {
        if (itr[-1] == itr[0]) {
            count++;
        } else {
            sequence.push_back(std::make_pair(itr[-1], count));
            count = 1;
        }
    }
    sequence.push_back(std::make_pair(*(S.end() - 1), count));

    int seq_size = sequence.size();
    int seq = 0, idx = 0, start_idx = 0;
    for (int cnt = 0; cnt < K && idx < seq_size; idx++) {
        seq += sequence[idx].second;
        if (sequence[idx].first == '0') {
            cnt++;
        }
        if (cnt == K && idx < seq_size - 1) {
            idx++;
            seq += sequence[idx].second;
            idx++;
            break;
        }
    }

    int max_seq = seq;
    for (; idx < seq_size; idx += 2) {
        if (sequence[start_idx].first == '0') {
            seq += sequence[idx].second + sequence[idx + 1].second - sequence[start_idx].second;
            start_idx++;
        } else {
            if (idx < seq_size - 1) {
                seq += sequence[idx].second + sequence[idx + 1].second
                    - sequence[start_idx].second - sequence[start_idx + 1].second;
            } else {
                seq += sequence[idx].second
                    - sequence[start_idx].second - sequence[start_idx + 1].second;
            }
            start_idx += 2;
        }
        if (seq > max_seq) {
            max_seq = seq;
        }
    }

    std::cout << max_seq << std::endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);	
	int n;
	cin >> n;
	set<string> ans;
	while (n--) {
		string s;
		cin >> s;
		ans.insert(s);
	}
	cout << ans.size() << "\n";
	return 0;
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main() {
int N;
cin >> N;
string S;
cin >> S;
int dp[5005][5005];
for(int i = N-1;i>=0;i--){
    for(int j = N-1;j>=0;j--){
    if(S[i] != S[j]) dp[i][j] = 0;//i,jから始めた時に一致する最大長さ
    else dp[i][j] = dp[i+1][j+1]+1;
    }
}
int ans = 0;
for(int i = 0;i<N;i++){
    for(int j = 0;j<N;j++){
        if(i >= j) continue;
        int now = min(dp[i][j],j-i);/*i,jからスタートする同じ部分文字列の最大長さが
        j-iを超えれいれば,重なりがない場合の最大長さはj-i*/
        ans = max(ans,now);
    }
}
cout << ans << endl;
}

Measured memory_bytes: 98048
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
vector<ll> adj[100100];
vector<ll> ans;
ll recurse(ll idx) {
	if(adj[idx].size() == 0) return 0;
    if(ans[idx] != -1) return ans[idx];
    ans[idx] = 0;
    for(auto it: adj[idx]) {
    	ans[idx] = max(ans[idx], 1 + recurse(it));
    }
    return ans[idx];
}
int main(){
 IOS
#ifdef SHAN

    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, m;
  cin >> n >> m;
  for(ll i = 0; i < m; i++) {
  	ll x, y;
  	cin >> x >> y;
  	adj[x].push_back(y);
  }
  ans.resize(n+1, -1);
  for(ll i = 1; i <= n; i++) recurse(i);
  // for(ll i = 1; i <= n; i++) {
  // 	for(auto it: adj[i]) cout << it << " ";
  // 	cout << endl;	
  // }
  cout << *max_element(ans.begin(), ans.end());


  return 0;
} //good night.

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
string s[3]={"Sunny","Cloudy","Rainy"};
string a;

int main()
{
	cin>>a;
	if(a=="Rainy")puts("Sunny");
	else if(a=="Cloudy")puts("Rainy");
	else puts("Cloudy");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const ll inf = 1e9+7;
vector<int>p[maxn];
int a[maxn];
int main() {
    ios::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1,x,y;i<=m;i++){
        cin>>x>>y;
        p[x].push_back(y);
        p[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int f=0;
        for(int j:p[i]){
            if(a[j]>=a[i])
                f=1;
        }
       // cout<<i<<" "<<f<<endl;
        if(!f)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11504
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


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

    LLI x, k, d;

    cin >> x >> k >> d;

    if (x < 0)x = -x;

    if (x / d >= k)
    {
        cout << abs(x - d * k);
    }
    else
    {
        LLI c = x / d;
        x -= c*d;
        k -= c;

        if (k % 2 == 0)
        {
            cout << _min(x, abs(x-2*d));
        }
        else
        {
            cout << _min(abs(x-d), abs(x + d));
        }
    }


    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n;
	cin >> n;

	cout << (int)((n + 1) / 2) << endl;

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,k,q,i;
	int am[100001];
	int a[100001];
	scanf("%d%d%d",&n,&k,&q);
	for(i=0;i<q;i++)scanf("%d",&a[i]),a[i]--;
	for(i=0;i<q;i++)am[a[i]]++;
	for(i=0;i<n;i++)am[i]-=q;
	for(i=0;i<n;i++)am[i]+=k;
	for(i=0;i<n;i++){
		if(am[i]>0)puts("Yes");
		else puts("No");
	}
	return 0;
}

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

int main()
{
    long n, i, j;
    cin >> n;
    vector<int> cnt(26, 0);
    string t;
    cin >> t;
    for (i = 0; i < t.size(); i++)
    {
        cnt.at(t.at(i) - 'a')++;
    }
    for (i = 1; i < n; i++)
    {
        string s;
        cin >> s;
        vector<int> cnt2(26, 0);
        for (j = 0; j < s.size(); j++)
        {
            cnt2.at(s.at(j) - 'a')++;
        }
        for (j = 0; j < 26; j++)
        {
            cnt.at(j) = min(cnt.at(j), cnt2.at(j));
        }
    }
    for (i = 0; i < 26; i++)
    {
        for (j = 0; j < cnt.at(i); j++)
        {
            cout << (char)('a' + i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 3604
char s[8002];
x,y;
d[2][40000];
t[40000];
i,j,f,l;
main(){
	scanf("%s%d%d",s,&x,&y);
	s[strlen(s)]='T';
	s[strlen(s)]=0;
	for(i=0;s[i]=='F';++i);
	d[0][20000+i]=1;
	d[1][20000+0]=1;
	for(;s[i];++i){
		if(s[i]=='F'){
			++l;
		}else{
			for(j=-8000;j<=8000;++j)t[20000+j]=0;
			for(j=-8000;j<=8000;++j){
				if(d[f][20000+j]){
					t[20000+j+l]=1;
					t[20000+j-l]=1;
				}
			}
			for(j=-8000;j<=8000;++j)d[f][20000+j]=t[20000+j];
			l=0;
			f^=1;
		}
	}
	puts(d[0][20000+x]&&d[1][20000+y]?"Yes":"No");
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];
	bool flag = true;
	h[0]--;
	for (int i = 1; i < n; ++i) {
		if (h[i - 1] < h[i]) h[i]--;
		if (h[i - 1] > h[i]) flag = false;
	}
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int p[100000] = { 0 };
int main() {
	int i, j, n, k, q,a;
	scanf("%d%d%d", &n, &k, &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &a);
		p[a - 1]++;
	}
	for (i = 0; i < n; i++) {
		if (k > q - p[i])
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let mut count = vec![0; 100001];
    for num in a {
        count[num] += 1;
    }
    let mut ans = 0i64;
    for i in 0..100001 {
        ans += i as i64 * count[i];
    }
    let q = read::<usize>();
    for _ in 0..q {
        let v = read_vec::<usize>();
        let (b, c) = (v[0], v[1]);
        ans -= b as i64 * count[b];
        ans += c as i64 * count[b];
        println!("{}", ans);
        count[c] += count[b];
        count[b] = 0;
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3780
import sys
# W, H, x, y, r
nums = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
W = nums[0]
H = nums[1]
x = nums[2]
y = nums[3]
r = nums[4]

if x - r < 0 or x + r < 0 or y - r < 0 or y + r < 0:
  ret = 'No'
elif x - r > W or x + r > W or y - r > H or y + r > H:
  ret = 'No'
else:
  ret = 'Yes'

print(ret)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
long long int val[1000],weight[1000];
long long int n,w,i,j,ans;
long long int vis[110][100005],dp[110][100005];
long long int knap(long long int pos,long long int curweight)
{
    if(pos>n)
        return 0;
    if(curweight >w)
        return 0;

    if(vis[pos][curweight])
        return dp[pos][curweight];

    vis[pos][curweight]=1;

    long long int p=0,q=0;

    if(curweight+weight[pos]<=w)
        p=knap(pos+1,curweight+weight[pos])+val[pos];

    q=knap(pos+1,curweight);

    dp[pos][curweight]=max(p,q);

    return dp[pos][curweight];
}
int main()
{
    memset(vis,0,sizeof(vis));
    memset(dp,0,sizeof(dp));
    cin>>n>>w;
    long long int dp[n][w],vis[n][w];
    for(i=0; i<n; i++)
        cin>>weight[i]>>val[i];
    n--;
    ans=knap(0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 172160
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});

reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
  var NQ = lines[0].split(" ");
  var N = +NQ[0];
  var Q = +NQ[1];
  var S = lines[1];
  var l = new Array(Q);
  var r = new Array(Q);
  for(var i = 0; i<Q; i++){
    var lr = lines[i+2].split(" ");
    l[i] = +lr[0];
    r[i] = +lr[1];
  }
  
  var countAC = new Array(N);
  countAC[0] = 0;
  for(var i=1; i<N; i++){
	if(S[i-1]+S[i] == "AC") {
	  countAC[i] = countAC[i-1]+1;
	} else {
      countAC[i] = countAC[i-1];
    }
  }

  var ans = [];
  for(var i = 0; i<Q; i++){
	  ans.push(countAC[r[i]-1]-countAC[l[i]-1]);
  }
  console.log(ans.join("\n"));
});

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

int main() {
	/*int x,a,b;
	cin >> x>>a>>b;
	x = (x - a) % b;
	cout << x <<endl;
	int n,a;
	cin >> n >> a;
	n = n * n - a;
	cout << n << endl;*/
	double r, g;
	cin >> r >> g;
	cout << 2*g - r << endl;


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin >> a >> b >> c;
	long long max = a;
	if(b > max)max = b;
	if(c > max)max = c;
	if(max == a)cout << b + c << endl;
	else if(max == b)cout << a + c << endl;
	else if(max == c)cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	char b;
	scanf("%c", &b);
	switch (b) {
	case 'A':
		printf("T\n");
		break;
	case 'T':
		printf("A\n");
		break;
	case 'C':
		printf("G\n");
		break;
	case 'G':
		printf("C\n");
		break;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <climits>
#include <cfloat>
#include <cstring>
#include <fstream>
#include <vector>
#include <iterator>
#include <typeinfo>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <sstream>

#define endl "\n"
#define pub push_back
#define pob pop_back
#define ins insert
#define mp make_pair

using namespace std;

typedef long long ll;

float d,t,s;

void solve(){
    cin >> d >> t >> s;
    cout << ( d/s<=t ? "Yes" : "No");
    return;
}

int main(){
    //Read input from STDIN, then print the output to STDOUT.
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cin >> t; 
    //while (t--) 
        solve();
    return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n, x;
vi a;
int main()
{
    cin >> n >> x;
    REP(i, n)
    {
        int c;
        cin >> c;
        a.push_back(c);
    }
    int sum = accumulate(ALL(a), 0);
    int xx = x - sum;
    int ans = 0;
    sort(ALL(a));
    ans += n + xx / a[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

import static java.lang.Integer.parseInt;

public class Main {
    public static void main(String[] args) {
        var sc = new Scanner(System.in);
        var k = parseInt(sc.next());
        var s = sc.next();

        var writer = new PrintWriter(System.out);
        if (s.length() <= k) {
            writer.println(s);
        } else {
            writer.println(s.substring(0, k) + "...");
        }
        writer.flush();
    }
}


Measured memory_bytes: 38404
N = int(input())
T, A = [int(num) for num in input().split()]
H = [int(num) for num in input().split()]

best_diff = None
best_height = None
for h in H:
    avg_tmp = T - h * 0.006
    diff = abs(A - avg_tmp)

    if best_diff is None:
        best_diff = diff
        best_height = h
    elif diff < best_diff:
        best_diff = diff
        best_height = h
    else:
        pass

print([i for i, val in enumerate(H, 1)
       if val == best_height][0])


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

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    char s;
    cin >> s;
    if (s == 'Y')
    {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

ll mod_pow(ll x, ll n, ll mod){
  if(n == 0)return 1;
  ll res;
  if(mod == -1)res = mod_pow(x * x,n/2,mod);
  else res = mod_pow(x * x % mod,n/2,mod);
  if(n%2 == 1 && mod != -1)res = res * x % mod;//(nが2の累乗ではない時にもう一度処理を行う)
  else if(n%2 == 1)res = res * x;
  return res;
}
int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  int ans = (n-m) * 100 + m * 1900;
  ans *= mod_pow(2,m,-1);
  DUMP(mod_pow(2,m,-1));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n;
int a[2005];
int G[2005][2005];
int gcd(int a, int b){
    return a == 0 ? b:gcd(b%a,a);
}
int vis[2005];
int nxt[2005];
vector<int> dfs(int u){
    vector<vector<int> > pos;
    for (int i = 1; i <= n; i++){
        if (G[u][i] && vis[i] == 0){
            //printf("%d -> %d: gcd(%d,%d) is %d\n",u,i,a[i],a[u],gcd(a[i],a[u]));
            vis[i] = 1;
            pos.push_back(dfs(i));
        }
    }
    int NUM = pos.size();
    int ct[NUM];
    memset(ct,0,sizeof(ct));
    priority_queue<ii> pq;
    for (int i = 0; i < NUM; i++){
        pq.push({pos[i][0],i});
    }
    vector<int> ans;
    if (u != 0) ans.push_back(a[u]);
    while (pq.size()){
        ii cur = pq.top(); pq.pop();
        ans.push_back(cur.first);
        int id = cur.second;
        ct[id]++;
        if (ct[id] != pos[id].size()){
            pq.push({pos[id][ct[id]],id});
        }
    }
    return ans;
}
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for (int i = 0 ; i <= n; i++){
        for (int j =0 ; j <= n; j++){
            if (a[i] == 1 || a[j] == 1){
                if (a[i] == 0 || a[j] == 0) G[i][j] = 1;
                else G[i][j] = 0;
            }
            else G[i][j] = (gcd(a[i],a[j]) != 1);
        }
    }
    vector<int> v = dfs(0);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n-1; j++){
            if (gcd(v[j],v[j+1]) == 1 && v[j] < v[j+1]){
                swap(v[j],v[j+1]);
            }
        }
    }
    for (auto x : v){
        printf("%d ",x);
    }

}


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

int main() {
  double W;
  double H;
  double x;
  double y;
  bool judge = 0;
  cin >> W;
  cin >> H;
  cin >> x;
  cin >> y;
  if(W/2 == x && H/2 == y)
  {
    judge = 1;
  }
  cout << W*H/2 << " "<< judge <<endl;
  
}


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

int prime(int n) {
  	if(n == 1) return 0;
  	if(n == 2) return 1;
  	
  	bool flag = true;
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
          	flag = false;
        }
        if(flag == false) break;
    }

  	if(flag == false) return 0;
    else return 1;
}

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

    vector<int> a(N);

    for(int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    int count = 0;

    for(int i = 0; i < N; i++) {
        if(prime(a.at(i)) == 1) {
            count++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3032
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#define N_MAX 100005

using namespace std;
typedef long long ll;

int main(){
	int N;
  	cin >> N;
  	int a[N];
  	int ball[N];
  	fill(ball, ball+N, 0);
  	map<int, int> mp;
  	int all=0;
	for(int i = 0; i < N; i++){
    	cin >> a[i];
      	all += a[i];
    }
  	int M = 0;
  	for(int i = N; i >= 1; i--){
      	int sum = 0;
    	for(int j = 2; i*j <= N; j++){
        	sum += ball[i*j-1];
        }
	    if(sum%2 != a[i-1]){
          ball[i-1]++;
          M++;
        }
    }
  	cout << M << endl;
      for(int i = 0; i < N; i++){
          if(ball[i] == 1) cout << i+1 << endl;
      }
}

Measured memory_bytes: 2432
#include<iostream>
#include<cmath>
#include <iomanip>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

long long x,a=100;

long long res;

int main() {

	cin >> x;

	while (true) {
		a *= 1.01;
		res++;
		if (a >= x)break;
	}

	cout << res << endl;

	return 0;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[40]={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 main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	cin >> n;
	cout << a[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

const int NMAX = 1e2 + 5;

vector <pii> res;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;

	if(n%2 == 0){
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				if(j != n-i+1){
					res.pb(mp(i, j));
				}
			}
		}
	}else{
		n--;
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				if(j != n-i+1){
					res.pb(mp(i, j));
				}
			}
		}
		n++;
		for(int i=1; i<n; i++)
			res.pb(mp(i, n));
	}

	cout << res.size() << endl;
	for(pii r: res) {
		cout << r.fi << " " << r.sc << endl;
	}

	return 0;
}

Measured memory_bytes: 384
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static List<HashSet<Integer>> group ;
    static List<HashSet<Integer>> group2 ;
    static int[] roads ;
    static int[] rialways ;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int k = in.nextInt();
        int l = in.nextInt();
        roads = new int[n+1];
        rialways = new int[n+1];
        group = new ArrayList<>(n+1);
        group2 = new ArrayList<>(n+1);
        String [] ans = new String[n+1];
        HashMap<String,Integer> mem = new HashMap<>();
        for(int i=1;i<=n;i++){
            roads[i]=i;
            rialways[i]=i;
        }
        for(int i =0;i<=n;i++){
            group.add(new HashSet<>());
            group2.add(new HashSet<>());
        }
        for(int i=0;i<k;i++){
            int a = in.nextInt();
            int b = in.nextInt();
            int boss1 = find_parent(roads,roads[a],a);
            int boss2 = find_parent(roads,roads[b],b);
            int mn = Math.min(boss1,boss2);
            roads[boss1]=mn;
            roads[boss2]=mn;
        }
        for(int i=0;i<l;i++){
            int a = in.nextInt();
            int b = in.nextInt();
            int boss1 = find_parent(rialways,rialways[a],a);
            int boss2 = find_parent(rialways,rialways[b],b);
            int mn = Math.min(boss1,boss2);
            rialways[boss1]=mn;
            rialways[boss2]=mn;
        }
        for(int i=1;i<=n;i++){
            int boss = find_parent(roads,roads[i],i);
            group.get(boss).add(i);
            roads[i]=boss;
            int j = boss;
            boss = find_parent(rialways,rialways[i],i);
            group2.get(boss).add(i);
            rialways[i]=boss;
            String t = Integer.toString(j)+"-"+Integer.toString(boss);
            ans[i]=t;
            if (mem.containsKey(t))
                mem.put(t,mem.get(t)+1);
            else mem.put(t,1);

        }

        for(int i=1;i<=n;i++){
            out.print(mem.get(ans[i])+" ");
        }
        out.close();
    }
    static int find_parent(int[] arr,int p,int i){
        if(p==i){
            return i;
        }
        else {
            return find_parent(arr,arr[p],p);
        }
    }

}


Measured memory_bytes: 233468
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S, T;
    cin >> S >> T;
    cout << (T.substr(0, S.size()) == S ? "Yes" : "No") << endl;
    return 0;
};

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
int arr[6][6];
int temp[6][6];
void copy(){
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++) temp[i][j] = arr[i][j];
	}
}
int solve(){
	int ret = 0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(temp[i][j]==1) ret++;
		}
	}
	return ret; 
}
void paint(int row_state,int col_state){
	for(int i=0; i<h; i++){
		if((1<<i)&row_state){
			for(int j=0; j<w; j++) temp[i][j] = 2;
		}
	}
	for(int i=0; i<w; i++){
		if((1<<i)&col_state){
			for(int j=0; j<h; j++) temp[j][i] = 2;
		}
	}
}
int main(){
	cin>>h>>w>>k;
	for(int i=0; i<h; i++){
		string s;
		cin>>s;
		for(int j=0; s[j]; j++){
			if(s[j]=='#') arr[i][j] = 1;
		}
	}
	int ret = 0;
	for(int i=0; i<(1<<h); i++){
		for(int j=0; j<(1<<w); j++){
			copy();
			paint(i,j);
			if(solve()==k) ret++;
		}
	}
	cout<<ret;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,i;
	string s1,s2;
	cin>>s1>>s2;
	int zh(string p);
	s1+=s2;
	a=zh(s1);
	if (sqrt(a)==int(sqrt(a)))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}
int zh(string p)
{
	int o=0;
	for (int i=0;i<p.size();i++)	o=o*10+(p[i]-'0');
	return o;	
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ac = [0]*n
wa = [0]*n
count_ac = 0
count_wa = 0

for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]:
        continue
    
    if s == "WA":
        wa[p-1] += 1
    else:
        ac[p-1] = True
        count_ac += 1
        count_wa += wa[p-1]
        
print(count_ac,count_wa)

Measured memory_bytes: 10300
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if V > W and abs(B-A)/(V-W) <= T:
        print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()


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

ll sum(vector<ll> arr) {
    ll sum = 0;
    for (ll x: arr) sum += x;
    return sum;
}

ll knapsack(int W, vector<ll> weights, vector<ll> values) {
    int n = weights.size();
    ll m = sum(values);
    vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
    for (int i = 1; i <= m; i++) dp[0][i] = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (j >= values[i-1]) {
                if (dp[i-1][j - values[i-1]] == LLONG_MAX)
                    dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = min(dp[i-1][j], dp[i-1][j - values[i-1]] + weights[i-1]);
            }
            else dp[i][j] = dp[i-1][j];
        }
    }

//    for (int i = 0; i <= n; i++) {
//        for (int j = 0; j <= m; j++)
//            cout << dp[i][j] << " ";
//        cout << endl;
//    }

    for (int i = m; i >= 0; i--)
        if (dp[n][i] <= W) return i;
    return 0;
}

int main() {
    int n, w;
    cin >> n >> w;
    vector<ll> weights(n);
    vector<ll> values(n);
    for (int i = 0; i < n; i++) cin >> weights[i] >> values[i];
    cout << knapsack(w, weights, values) << endl;
    return 0;
}

Measured memory_bytes: 83212
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1e18
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
/*
ll v[500001], size[500001];
vector<ll>ve(0);
ll fin(ll x){
    //using path compression optimization
    if(x == v[x]){
        return x;
    }
    return v[x] = fin(v[x]);
}
void uni(ll x, ll y){
    x = fin(x);
    y = fin(y);
    if(x == y){
        return ;
    }
    //Using Union by size method, to reduce long chains
    if(size[x] < size[y]){
	size[x]+= size[y];
    	v[y] = x;}
    else{
	size[y]+=size[x];
	v[x]=y;
	}
}
*/
int main()
{
   // ios::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll t;
    cin>>t;
    ll ar[t][3];
    ll dp[t][3];
    REP(i, 0, t){
        REP(j, 0, 3)
        {
        cin>>ar[i][j];
        }
    }

    dp[0][0] = ar[0][0];
    dp[0][1] = ar[0][1];
    dp[0][2] = ar[0][2];
    REP(i, 1, t){
        dp[i][0] = ar[i][0]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = ar[i][1]+max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = ar[i][2]+max(dp[i-1][1], dp[i-1][0]);
    }
    cout<<max(dp[t-1][0], max(dp[t-1][1], dp[t-1][2]));

}

Measured memory_bytes: 4992
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

sx, sy, tx, ty = na()

ans = []
for i in range(abs(sx - tx)):
    ans.append('R')

for i in range(abs(sy - ty)):
    ans.append('U')

ans.append('R')
for i in range(abs(sy - ty) + 1):
    ans.append('D')

for i in range(abs(sx - tx) + 1):
    ans.append('L')

ans.append('U')

for i in range(abs(sy - ty)):
    ans.append('U')

for i in range(abs(sx - tx)):
    ans.append('R')

ans.append('U')

for i in range(abs(sx - tx) + 1):
    ans.append('L')

for i in range(abs(sy - ty) + 1):
    ans.append('D')

ans.append('R')

print(*ans, sep="")

Measured memory_bytes: 4852
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

class UF {
private:
  vector<int> data; // parent or size
  vector<int> next;
  vector<int> last;
  void init(int n) {
    data.assign(n, -1);
    next.assign(n, -1);
    last.resize(n);
    for (int i = 0; i < n; ++i) {
      last[i] = i;
    }
  }

public:
  UF() {}
  UF(int n) {
    init(n);
  }
  int root(int x) {
    if (data[x] < 0) return x;
    return data[x] = root(data[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y); // data[x] and data[y] are negative.
    data[x] += data[y];
    data[y] = x;
    next[last[x]] = y;
    last[x] = last[y];
    return true;
  }
  int size(int x) {
    return -data[root(x)];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int get_next(int x) {
    return next[x];
  }
};

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vvi edge(m, vi(3));
  rep (i, m) {
    scanf("%d%d%d", &edge[i][1], &edge[i][2], &edge[i][0]);
    edge[i][1] -= 1; edge[i][2] -= 1;
  }
  sort(all(edge));
  UF uf(n);
  vvi maxcost(n, vi(n));
  ll cost = 0;
  cost += edge[0][0];
  uf.unite(edge[0][1], edge[0][2]);
  maxcost[edge[0][1]][edge[0][2]] = maxcost[edge[0][2]][edge[0][1]] = edge[0][0];
  FOR (i, 1, m) {
    int x = edge[i][1];
    int y = edge[i][2];
    if (!(uf.same(x, y))) {
      cost += edge[i][0];
      for (int j = uf.root(x); j != -1; j = uf.get_next(j)) {
        for (int k = uf.root(y); k != -1; k = uf.get_next(k)) {
          maxcost[j][k] = maxcost[k][j] = edge[i][0];
        }
      }
      uf.unite(x, y);
    }
  }
 
  int q;
  cin >> q;
  vll ans(q, 0);
  rep (j, q) {
    int s, t;
    cin >> s >> t;
    s -= 1; t -= 1;
    ans[j] = cost - maxcost[s][t];
  }
  rep (i, q) {
    printf("%lld\n", ans[i]);
  }
 
  return 0;
}


Measured memory_bytes: 86784
#include<stdio.h>

int main(){
  int num1,num2,temp,rem;
  
  scanf("%d%d",&num1,&num2);
  
  if(num1<num2){
    temp=num1;
    num1=num2;
    num2=temp;
  }

  rem=num1%num2;

  
  while(rem!=0){
    num1=num2;
    num2=rem;
    rem=num1%num2;
  }

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



Measured memory_bytes: 2120
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll x,n,a[200005],i,sum=0;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i],a[i]-=i;
	sort(a+1,a+n+1);
	x=a[n/2+1];
	for(i=1;i<=n;i++)sum+=abs(a[i]-x);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>
#include <stack>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<ll> to[200010];
vector<ll> p;
int ans[200010];
ll a[200010];
int dp[200010];
stack<pair<int*, int>> g;
void search(int n, int pre){
    p.push_back(a[n]);
    auto point = lower_bound(dp,dp+p.size(),a[n]);
    g.push(make_pair(point, *point));
    *lower_bound(dp,dp+p.size(),a[n]) = a[n];
    ans[n] = lower_bound(dp,dp+p.size(),999999999) - dp;
    for(int i = 0; i < to[n].size(); i++){
        if(to[n][i] == pre) continue;
        search(to[n][i], n);
    }
    auto m = g.top();
    *m.first = m.second;
    g.pop();
}

int main(){
    ll n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n-1; i++){
        int u,v;
        cin >> u >> v;
        to[u].push_back(v);
        to[v].push_back(u);
    }

    fill(dp,dp+n, 999999999);
    search(1,0);

    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 36316
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;

int dp[1000010][2];
string S;
int N;
bool done[1000010][2];
int rec(int i, bool flag) {
	if (i == N) {
		return flag;
	}
	if (done[i][flag])return dp[i][flag];
	done[i][flag] = true;
	int num = (S[i] - '0') + flag;
	int res1=0,res2 = 0;
	if (num < 10) {
		//自分が払う
		res1 += num;
		res1 += rec(i + 1, false);
		//相手が払う
		res2 += 10 - num;
		res2 += rec(i + 1, true);
		return dp[i][flag] = min(res1, res2);
	}
	else {
		res1 = rec(i + 1, true);
		return dp[i][flag] = res1;
	}
}


void solve(){
	cin >> S;
	N = S.size();
	VREVERSE(S);
	print(rec(0, 0));
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Eratosthenes();
	//VSORT(sosuu);
	//REP(_, 100)test();
	//cerr << "done" << endl;
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 68844
import java.util.*;

import javax.lang.model.util.ElementScanner6;

public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		String s=scan.next();

		int[] w =new int [n];
		int[] e =new int [n];
		for (int i=0;i<n;++i){
			if (i==0){
				if(s.charAt(i)=='W'){
					w[i]=1;
				}else{
					w[i]=0;
				}

				if(s.charAt(n-i-1)=='E'){
					e[n-i-1]=1;
				}else{
					e[n-i-1]=0;
				}

			}else{
				if(s.charAt(i)=='W'){
					w[i]=w[i-1]+1;
				}else{
					w[i]=w[i-1];
				}

				if (s.charAt(n-i-1)=='E'){
					e[n-i-1]=e[n-i]+1;
				}else{
					e[n-i-1]=e[n-i];
				}
			}
		}
		int min=Integer.MAX_VALUE;
		for(int i=1;i<n-1;++i){
			min=Math.min(min,w[i-1]+e[i+1]);
		}

		min=Math.min(min,e[1]);
		min=Math.min(min,w[n-2]);

		System.out.print(min);


	}
}
//end

Measured memory_bytes: 30884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,m,k,a,b,x; cin>>h>>m; a=60*h+m; cin>>h>>m>>k; b=60*h+m; x=b-a;
  if(x<0) x+=1440;
  cout<<x-k<<endl;
}

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


int main()
{
    string a,b,c,nana,n0,n1,n2;
    cin >> a >> b >> c;
    n0=a[0];
    n1=b[1];
    n2=c[2];
    nana = n0 + n1 + n2;
    cout << nana << endl;
    return 0;
    
    
}


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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b;
  cin >> a >> b;
  if(a*b%2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main(){
  long x;
  cin >> x;
  long a = x/500;
  long b = (x-a*500)/5;
  cout << a*1000+b*5 << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
        int sum = 0;
        int x = n;
        while (x > 0)
        {
            sum += x % 10;
            x /= 10;
        }
		Console.WriteLine(n % sum == 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  set<int> s;
  for (int i = 0; i < 3; ++i) {
    int a;
    cin >> a;
    s.insert(a);
  }
  if (s.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    if(n <= 2){
        cout << 2 << endl;
    }else{
        if(n % 2 == 0){
            cout << n << endl;
        }else{
            cout << 2 * n << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, D,an=0;
	cin >> N >> D;
	ll X[11][11];
	rep(i, N) {
		rep(j, D) {
			cin >> X[i][j];
		}
	}
	for (ll i = 0; i < N-1; i++) {
		for (ll j = i + 1; j < N; j++) {
			ll dis = 0;
			rep(k, D) {
				dis += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			ll m = 0;
			while (m * m < dis) {
				m++;
			}
			if (m * m == dis) {
				an++;
			}
		}
	}
	cout << an << endl;

}

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

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> FI(h);
    rep(i, h) cin >> FI[i];

    vector<vector<int>> dist(h, vector<int>(w, -1));
    dist[0][0] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    while (!que.empty())
    {
        pair<int, int> current_pos = que.front();
        int y = current_pos.first;
        int x = current_pos.second;
        que.pop();
        for (int direction = 0; direction < 4; ++direction)
        {
            int next_x = x + dx[direction];
            int next_y = y + dy[direction];
            if (next_y < 0 || next_y >= h || next_x < 0 || next_x >= w)
                continue;
            if (FI[next_y][next_x] == '#')
                continue;

            if (dist[next_y][next_x] == -1)
            {
                que.push(make_pair(next_y, next_x));
                dist[next_y][next_x] = dist[y][x] + 1;
            }
        }
    }
    if (dist[h - 1][w - 1] == -1)
    {
        cout << -1 << endl;
        return 0;
    }
    int cnt = 0;
    rep(y, h)
    {
        rep(x, w)
        {
            if (FI[y][x] == '.')
                cnt++;
        }
    }
    cout << cnt - dist[h - 1][w - 1] - 1 << endl;
}

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

bool res;
string str,ans;
void solve(){
  res = false ;
  char tmp;
  for(int i = 0; i < str.size()+1; i++){
    if(ans == str){
      res = true;
      break;
    }
    tmp = (char)str[str.size()-1];
    for(int j = str.size()-1; j >= 1; j--){
      str[j] = str[j-1];
    }
    str[0] = tmp;

    //cout << str << endl;
  }
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
  return ;
}
int main(){
  cin >> ans >> str;
  solve();
  return 0;
}


Measured memory_bytes: 256