akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[55];
int k;
int main(){
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	ll ans = -1e18;
	for(int i=-1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(i+1+n-j > k) continue;
			int zan = k - (i+1+n-j);
			vector<ll>vec;
			for(int x=0;x<=i;x++) vec.pb(a[x]);
			for(int x=j;x<n;x++) vec.pb(a[x]);
			SORT(vec);
			ll sum = 0;
			rep(i,vec.size()) sum += vec[i];
			for(int i=0;i<vec.size();i++){
				if(zan == 0 || vec[i] > 0) continue;
				sum -= vec[i];
				zan--;
			}
			ans = max(ans,sum);
		}}
	cout<<ans<<endl;
}

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

int minCost(int* arr, int n)
{
	int dp[n + 1];
	dp[1] = 0;
	dp[2] = abs(arr[2] - arr[1]);
	for(int i = 3; i <= n; i++)
	{
		int op1 = dp[i - 1] + abs(arr[i]-arr[i-1]);
		int op2 = dp[i - 2] + abs(arr[i]-arr[i-2]);
		dp[i] = min(op1, op2);
	} 
	return dp[n];
}
int main()
{
	int n;
	cin >> n;
	int arr[n + 1];
	for(int i = 1; i <= n; i++)
		cin >> arr[i];
	cout << minCost(arr, n);
	return 0;
}

Measured memory_bytes: 4316
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 1;
        for (int i = 0; i < n - 1; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
	x = 0;
	char ch = 0;
	bool sign = false;
	while (ch < '0' || '9' < ch) sign |= ch == '-', ch = getchar();
	while ('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	x = sign ? -x : x;
}
typedef long long ll;
#define rint register int
#define rep(it, f, e) for (rint it = f; it <= e; ++it)
#define per(it, f, e) for (rint it = f; it >= e; --it)
const int MAXN = 2e5 + 10;
const ll Inf = 1ll << 62;
int A[MAXN], n;
ll dp[MAXN][5], ans = Inf;
inline int wei(int i, int j) {
	if (j == 0 || j == 4) return A[i];
	if (j == 1 || j == 3) {
		return A[i] ? A[i] % 2 : 2;
	}
	return (A[i] + 1) % 2;
}
int main() {
	read(n);
	rep (i, 0, n - 1) {
		read(A[i]);
	}
	fill(dp[1], dp[n + 1], Inf);
	rep (i, 0, n - 1) {
		rep (j, 0, 4) {
			if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + wei(i,j));
		}
	}
	rep (i, 0, 4) {
		ans = min(ans, dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8832
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;

char S[10010];
int main()
{
	int c;
	scanf("%d%s",&c, S);
	int len = strlen(S);
	for (int i = 0; i < len; i++) {
		int x = (S[i] - 'A' + c) % 26;
		S[i] = x + 'A';
	}
	printf("%s", S);
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a==1&&b==2)||(a==2&&b==1)){
     cout << 3 << endl;
  }
  else if((a==2&&b==3)||(a==3&&b==2)){
     cout << 1 << endl;
  }
  else if((a==3&&b==1)||(a==1&&b==3)){
     cout << 2 << endl;
  }
}

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

int N,M;
char D[110][10010];
int cnt[10010] = {};

int main(){
    cin >> N >> M;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=N;j++){
            cin >> D[i][j];
            if(D[i][j]=='W') cnt[j]++;
        }
    }
    for(int i=1;i<=N;i++) cnt[i] += cnt[i-1];
    int l = 0,r = 1,mi = cnt[N];
    for(int i=1;i<=N;i++){
        int e1 = i*M-cnt[i],e2 = cnt[N]-cnt[i];
        if(e1+e2<mi){
            l = i; r = i+1; mi = e1+e2;
        }
    }
    cout << l << " " << r << endl;
}


Measured memory_bytes: 4104
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

char a[4010], b[4010];
int dp[4010][4010];

int main()
{
	while (cin >> a) {
		cin >> b;
		int len_a = strlen(a);
		int len_b = strlen(b);
		for (int i = 0; i <= len_a; i++)
			for (int j = 0; j <= len_b; j++)
				dp[i][j] = 0;
		for (int i = 0; i < len_a; i++) {
			for (int j = 0; j < len_b; j++) {
				if (a[i] == b[j])
					dp[i + 1][j + 1] = dp[i][j] + 1;
			}
		}
		int ans = 0;
		for (int i = 0; i <= len_a; i++)
			for (int j = 0; j <= len_b; j++)
				ans = max(ans, dp[i][j]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 65748
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define _USE_MATH_DEFINES

using namespace std;
int main(){
  int l,a;
  string sl,sa;
  double x,y,aa;
  x=y=aa=0;
  while(true){
  getline(cin,sl,',');
  getline(cin,sa,'\n');
  l = atoi(sl.c_str());
  a = atoi(sa.c_str());
  if (!l&&!a)break;
  x += sin(aa*(2*M_PI)/360)*l;
  y += cos(aa*(2*M_PI)/360)*l;
  aa += a;
  }
  cout << (int)x << endl << (int)y << endl;
}

Measured memory_bytes: 0
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		Long[] Ai = new Long[N];
		Long sum = (long) 0;
		
		for(int i = 0; i<N; i++) {
			Ai[i] = sc.nextLong();
		}
	  
		Long max = (long) 0;

		for(int i = 0; i<N-1; i++) {
			long a1 = Ai[i];
			long a2 = Ai[i+1];
          
          	if(a1>max){
				max=a1;
			}
          
			if(max>a2){
				sum += (max-a2);
              	
			}
		}

		System.out.println(sum);	
		return;
	}

}


Measured memory_bytes: 65132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
using namespace std;
struct __INIT { __INIT() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } __init;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main(){
	
	string s;
	cin >> s;
	ll n = s.length();
	vector<ll>ans(n,0);
	for (ll i = 0; i < n; i++) {
		if ((s[i] == 'R' && s[i + 1] == 'L') && (i+1 < n)) {
			ans[i] += 1;
			ans[i + 1] += 1;
			i++;
		}
	}
	s += 'R';
	ll Rcnt = 0, Lcnt = 0, Rindex = -1, Lindex = -1;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R' && s[i + 1] == 'L') {
			Rindex = i;
			Lindex = i + 1;
		}
		else {
			if (s[i] == 'L' && s[i + 1] == 'R') {
				if(i != Lindex)Lcnt++;
				ll tmpR = ceil((Rcnt) / 2.0);
				ll tmpL = ceil((Lcnt) / 2.0);
				ans[Rindex] += Rcnt - tmpR + tmpL;
				ans[Lindex] += Lcnt - tmpL + tmpR;
				Rcnt = 0;
				Lcnt = 0;
			}
			else if (s[i] == 'R' && i != Rindex)Rcnt++;
			else if (s[i] == 'L' && i != Lindex)Lcnt++;
		}
	}
	rep(i, n) { cout << ans[i] << " "; }
	cout << endl;
}



Measured memory_bytes: 1488
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;



int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>>vec(123456);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		vec[a].push_back(b);
	}
	priority_queue<int>que;
	LL ans = 0;
	++M;
	for (int j = M - 1; j >= 0; --j) {
		for (auto elm : vec[M - 1 - j]) {
			que.push(elm);
		}
		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const int N = 1e+6 + 10;
#include <bitset>
const int PRIME_SIZE = N + 100;
int psize;
bitset<PRIME_SIZE + 1> bprime;
int prime[PRIME_SIZE / 10 + 1000];
int Eratosthenes(int n) {
  psize = 0;
  bprime.set();
  bprime[0] = bprime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (!bprime[i]) { continue; }
    prime[psize++] = i;
    if ((long long)i * i > n) { continue; }
    for (int j = i * i; j <= n; j += i) {
      bprime[j] = false;
    }
  }
  return psize;
}


int m, s;
pair<int, int> memo[N + 100];
map<int, map<int, int> > mapto;
map<int, pair<int, int> > mapfrom;

pair<int, int> calc(int f) {
  pair<int, int> &ret = memo[f];
  if (ret.first != -1) { return ret; }
  ret = make_pair(0, 0);
  if (f > m) { return ret; }
  int y = mapfrom[f].first;
  int x = mapfrom[f].second;
  FOREQ(dx, -1, 1) {
    int nx = x + dx;
    int ny = y + 1;
    if (!mapto[ny].count(nx)) { continue; }
    int nf = mapto[ny][nx];
    //cout << nf << " " << x << " " << nx << " " << dx << endl;
    ret = max(ret, calc(nf));
  }
  if (bprime[f]) {
    ret.first++;
    if (ret.second == 0) { ret.second = f; }
  }
  return ret;
}

int main() {
  Eratosthenes(N);
  {
    int dir = 3;
    int dx[4] = { 1, 0, -1, 0 };
    int dy[4] = { 0, -1, 0, 1 };
    int x = 0;
    int y = 0;
    REP(i, N) {
      mapto[y][x] = i + 1;
      mapfrom[i + 1] = make_pair(y, x);
      dir = (dir + 1) % 4;
      int nx = x + dx[dir];
      int ny = y + dy[dir];
      if (mapto[ny].count(nx)) {
        dir = (dir + 3) % 4;
        nx = x + dx[dir];
        ny = y + dy[dir];
      }
      x = nx;
      y = ny;
    }
  }
  // FOREQ(y, -5, 5) {
  //   FOREQ(x, -5, 5) {
  //     printf("%3d ", mapto[y][x]);
  //   }
  //   puts("");
  // }
  while (cin >> m >> s, m|s) {
    MEMSET(memo, -1);
    pair<int, int> ans = calc(s);
    printf("%d %d\n", ans.first, ans.second);
  }
}

Measured memory_bytes: 119328
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = s.length();

    int num = 0;

    for(int i=0; i<a/2; i++){
       if(s.charAt(i) != s.charAt(a-i-1)){
         num++;
       }
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 23764
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
use std::usize;
#[allow(unused_imports)]
use std::vec::Vec;

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

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

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

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

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

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

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

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

fn main() {
    input!{
        s: usize,
    }
    let mut current = s;
    let mut next = f(current);
    let mut hset = HashSet::new();
    hset.insert(current);
    let mut i = 2;
    while !hset.contains(&next) {
        // eprintln!("{} {}", next, current);
        current = next;
        hset.insert(current);
        next = f(current);
        i += 1;
    }
    println!("{}", i);
}

fn f(n: usize) -> usize {
    if n % 2 == 0 {
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            '\n'
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

bool check(int m, vector<int> &a, int k)
{
    int n = a.size();
    int c = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] > m && m != 0)
            c += (a[i] / m);
    }

    if (c <= k)
        return 1;
    else
        return 0;
}

int32_t main()
{
    aksh();
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    int mx = INT_MIN;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    int l = 0, h = mx;
    int ans = mx;

    while (l <= h)
    {
        int m = (l + h) / 2;
        if (check(m, a, k))
        {
            ans = min(ans, m);
            h = m - 1;
        }
        else
            l = m + 1;
    }

    cout << max(ans, 1ll) << endl;


}

Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
int h,n,sum;
int a[100005];
int main()
{
	cin>>h>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=h) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    vector< T > m_data;
    CumulativeSum() {};
    CumulativeSum(int sz) : m_data(sz, 0) {};

    // k に x を加える O(1)
    void Add(int k, int x) {
        assert(m_data.size() >= k);
        if(m_data.size() <= k) { m_data.push_back(x); }
        else { m_data[k] += x; }
    }

    // 累積和の構築 O(m_data.size())
    void Build() { for(int i = 1; i < m_data.size(); i++) { m_data[i] += m_data[i - 1]; } }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return 0; }
        return (m_data[min(k, (int) m_data.size() - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) { return this->Query(h) - this->Query(l-1); }
};

ll N;
string S;

signed main()
{
    cin >> N >> S;

    CumulativeSum<ll> toE(N), toW(N);

    REP(i, N) {
        if(S[i] == 'E') { toW.Add(i, 1); }
        else { toE.Add(i, 1); }
    }
    toE.Build(); toW.Build();
    ll ans = LLINF;
    REP(i, N) {
        ll left = 0, right = 0;
        if(i != 0) {
            left = toE.Query(0, i-1);
        }
        if(i != N-1) {
            right = toW.Query(i+1, N-1);
        }
        ans = min(ans, left + right);
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
    int temp, cnt5=0, cnt7=0;

    for (int i = 0 ; i < 3 ; ++i) {
        cin >> temp;
        if (temp == 5) cnt5++;
        if (temp == 7) cnt7++;
    }

    cout << (cnt5 == 2 && cnt7 == 1 ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
using namespace std;


void solve(long long N, std::vector<long long> A){
    vector<long long> cnt(N+1);
    for(int i = 0; i < N+1; i++) {
        cnt[i] = 0;
    }

    for(int i = 0; i < N; i++) {
        if(cnt[A[i]] == -1) cnt[A[i]] = 0;
        cnt[A[i]] += 1;
    }

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

    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-2+1);
    for(int i = 0 ; i < N-2+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

void print(const vi& num) {
    int n = num.size();
    rep(i, 0, n) {
        cout << num[i];
        if (i != n - 1) { cout << " "; }
        else { cout << endl; }
    }
}

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

    vi num(n);
    rep(i, 0, n) { cin >> num[i]; }

    bool flag = true;
    int cnt = 0;

    while (flag) {
        flag = false;
        rrep(i, 1, n) {
            if (num[i - 1] > num[i]) {
                swap(num[i - 1], num[i]);
                flag = 1;
                ++cnt;
            }
        }
    }
    print(num);
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3096
n = int(raw_input())

for i in range(n):
    y, m, d = map(int, raw_input().split())
    cnt = 0

    while y < 1000:
        while m <= 10:
            while d <= 20:
                cnt += 1
                d += 1
                if m % 2 == 0 and d > 19 and y % 3 != 0:
                    break
            m += 1
            d = 1
        y += 1
        m = 1
    print cnt

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

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  long long res = 0;
  if (K == 0) {
    cout << (long long) N * N << endl;
    return 0;
  }
  for (int i = K+1; i <= N; i++) {
    int t = i;
    res += N / t * (t - K);
    t = N - N / t * t;
    res += max(0, t - K + 1);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}


int main() {
	double r;
	cin >> r;
	double ans = 2 * M_PI*r;
	printf("%lf\n", ans);
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) (v.begin(), v.end())
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v) {  \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
  lint n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  string tt = t;
  map<char, lint> mp;
  mp['r'] = r;
  mp['s'] = s;
  mp['p'] = p;
  for (int i = 0; i < tt.size(); i++) {
    if (tt[i] == 'r')
      tt[i] = 'p';
    else if (tt[i] == 's')
      tt[i] = 'r';
    else if (tt[i] == 'p')
      tt[i] = 's';
  }

  lint ans = 0;
  for (int i = 0; i < k; i++) {
    int pos  = 0 + i;
    int step = k;
    while (pos < t.size()) {
      ans += mp[tt[pos]];
      if (tt[pos] == tt[pos + step]) { pos += step; }
      pos += step;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int T = 4;
const int INF = 1e9;

int cost[4] = {10, 50, 100, 500}, C, coins[4];

vector<int> check(int c){
  vector<int> res(T);
  int d = abs(c - C);
  for(int i = T - 1; i >= 0; --i){
    res[i] = d / cost[i];
    d %= cost[i];
  }
  return res;
}

int main(){
  bool f = false;
  while(cin >>C && C){
    if(f) cout <<endl;
    f = true;
    int sum = 0;
    REP(i, T){
      cin >>coins[i];
      sum += cost[i] * coins[i];
    }
    vector<int> res = check(sum);
    //cout <<sum <<endl;
    //REP(i, T) cout <<coins[i] <<", "; cout <<endl;
    //REP(i, T) cout <<res[i] <<", "; cout <<endl;
    REP(i, T) if(coins[i] - res[i] > 0) cout <<cost[i] <<" " <<coins[i] - res[i] <<endl;
  }

  return 0;
}

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

int main() {
    int n; cin >> n;
    bool can = true;
    int pret = 0;
    int prex = 0;
    int prey = 0;
    rep(i, n) {
        int t, x, y;
        cin >> t >> x >> y;
        int dt = t - pret;
        int dx = abs(x - prex);
        int dy = abs(y - prey);
        if ((dx + dy) > dt) can = false;
        if ((dx + dy)%2 != dt%2) can = false;
        pret = t;
        prex = x;
        prey = y;
    }
    cout << (can ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace std;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


    int main()
    {
                           
             

            
                        
              fio

             
              set<lli> ans;
              lli n;
              cin>>n;
              ans.insert(n);

              for(lli i=2;i<=sqrt(n);i++)
                if(n%i==0)
                {
                    lli x=n;
                    while(x%i==0)x/=i;
                    if(x%i==1)ans.insert(i);

                }

             n--;
             ans.insert(n);


             for(lli i=2;i<=sqrt(n);i++)
                if(n%i==0)
                {
                      
                    ans.insert(i);
                    ans.insert(n/i);

                }
               
            ans.erase(1);
               cout<<ans.size();





              
              
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  int d = 0, ans = 0;
  rep(i,n){
    if(h[i]>d) ans += h[i]-d;
    d = h[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    const i64 MOD=1e9+7;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y;
        y.a=n;
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y=*this;
        return y+=x;
    }
    modint operator-(const modint& x){
        modint y=*this;
        return y-=x;
    }
    modint operator*(const modint& x){
        modint y=*this;
        return y*=x;
    }
    modint operator/(const modint& x){
        modint y=*this;
        return y/=x;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this*=x.inv();
        return *this;
    }
};

istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}

vector<vector<vector<modint>>> dp;
vector<vector<vector<bool>>> vis;
modint rec(int i,int j,int k){
    //cout<<i<<" "<<j<<" "<<k<<endl;
    if(j<0||j>i||k<0) return 0;
    if(i==0){
        if(j==0&&k==0) return 1;
        else return 0;
    }
    if(vis[i][j][k]) return dp[i][j][k];
    vis[i][j][k]=1;
    return dp[i][j][k]=rec(i-1,j-1,k-2*j)+rec(i-1,j,k-2*j)*(2*j+1)+rec(i-1,j+1,k-2*j)*(j+1)*(j+1);
}

class FPermutationOddness {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k;
        in>>n>>k;
        dp.resize(n+1,vector<vector<modint>>(n+1,vector<modint>(k+1)));
        vis.resize(n+1,vector<vector<bool>>(n+1,vector<bool>(k+1)));
        out<<rec(n,0,k)<<endl;
    }
};

int main() {
    FPermutationOddness solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 104064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

int main() {
	//ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ans = 0;
	for (int i = 2; i < s.size(); i+=2) {
		string t, u;
		for (int j = 0; j < i / 2; j++) {
			t.push_back(s[j]);
		}
		for (int j = i / 2; j < i; j++) {
			u.push_back(s[j]);
		}
		if (t == u) {
			ans = max((int)ans, i);
		//	cout << i << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll n, m;
    cin >> n >> m;

    cout << (n - 1) * (m - 1) << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
    
using namespace std;
    
using ll = long long;
using Pii = pair<int, int>;
    
const ll INF = (ll)1e11;

template<typename T>
struct UnionFind {
    std::vector<T> parent;
    std::vector<T> rank;

    UnionFind(T n) : parent(n), rank(n, 0) {
        std::iota(parent.begin(), parent.end(), 0);
    }

    T find(T x) {
        return (parent[x] == x ? x : (parent[x] = find(parent[x])));
    }

    void unite(T x, T y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else{
            parent[y] = x;
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
        }
    }
    
    bool inSame(T x, T y) {
        return find(x) == find(y);
    }
};

int main() {
    ios::sync_with_stdio(false);
    int n, k, l;
    cin >> n >> k >> l;

    UnionFind<int> a(n), b(n);

    for (int i = 0; i < k; ++i) {
        int p, q;
        cin >> p >> q;
        --p; --q;
        a.unite(p, q);
    }

    for (int i = 0; i < l; ++i) {
        int p, q;
        cin >> p >> q;
        --p; --q;
        b.unite(p, q);
    }

    map<Pii, int> dict;
    for (int i = 0; i < n; ++i) {
        ++dict[{a.find(i), b.find(i)}];
    }

    for (int i = 0; i < n; ++i) {
        cout << (i > 0 ? " " : "") << dict[{a.find(i), b.find(i)}];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 15104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = 5009;
const int M = 205;

struct Node{    
    ll value;
    ll lazy;
};

Node T[N * 4 + 512];

void push(int node, int cl, int cr){
    T[node].value += T[node].lazy;
    if(cl != cr){
        T[node * 2].lazy += T[node].lazy;
        T[node * 2 + 1].lazy += T[node].lazy;
    }
    T[node].lazy = 0;
}

int n;
void update(int node, int cl, int cr, int tl, int tr, ll fy){   
    push(node, cl, cr);
    if(cr < tl)
        return;
    if(cl > tr)
        return;
    if(cl >= tl && cr <= tr){
        T[node].lazy = fy;
        push(node, cl, cr);
        return;
    }
    int mid = (cl + cr) / 2;
    update(node * 2, cl, mid, tl, tr, fy);
    update(node * 2 + 1, mid + 1, cr, tl, tr, fy);
    T[node].value = max(T[node * 2].value, T[node * 2 + 1].value);
}
void upd(int l, int r, ll d){
    update(1, 1, n, l, r, d);
}

ll z[N];

ll g[N][M];
ll d[N];

stack<pii> ff[M];

int main(){
    fastIO;
    int m;
    cin >> n >> m;
    for(int i = 2; i <= n; i ++ ){
        cin >> d[i];
    }
    int id;
    ll res = 0;
    for(int i = 1; i <= n; i ++ ){
        if(i>1){
            upd(1, i - 1, -d[i]);
        }
        for(int j = 1; j <= m ; j ++ ){
            cin >> g[i][j];
            id = i;
            upd(id, id, g[i][j]);
            while(!ff[j].empty() && ff[j].top().fi < g[i][j]){
                upd(ff[j].top().se, id-1, g[i][j] - ff[j].top().fi);
                id = ff[j].top().se;
                ff[j].pop();
            }
            ff[j].push(mp(g[i][j], id));
        }
        res = max(res, T[1].value);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 8832
gets
w=gets.split.map.with_index{|l,i|[l.to_i,i]}
x=w.sort_by{|l|l[0]}
x.map.with_index{|l,i|w[w.index l]<<i}
c=0
w.map{|l|_,a,b=l
a==b&&next
q=*a
(_,a,b=w.find{|k|b==k[1]}
q<<a)while q[0]!=b
s=q.map{|r|w[r][2]=r
w[r][0]}
t=s.reduce:+
c+=[t+s[-1]+x[0][0]*z=-~s.size,t+s[-1]*(z-3)].min}
p c

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,m;
vector<ll> g[1010];
vector<P> es;
ll cnt[1010][1010];
bool vis[1010];

void dfs(ll v,ll st){
  vis[v]=true;
  cnt[st][v]++;
  for(ll nv : g[v]){
    if(vis[nv]||nv==st||cnt[st][nv]>=2)continue;
    dfs(nv,st);
  }
}

int main(){
  cin>>n>>m;
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    es.push_back(P(a,b));
  }

  rep(i,n){
    for(ll v : g[i]){
      memset(vis,0,sizeof(vis));
      dfs(v,i);
    }
  }

  rep(i,m){
    ll a=cnt[es[i].fi][es[i].se];
    ll b=cnt[es[i].se][es[i].fi];
    if((a>=2&&b>=1)||(a<2&&b<1))cout<<"same"<<endl;
    else cout<<"diff"<<endl;
  }
  return 0;
}


Measured memory_bytes: 15720
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
vector<int> A;
const int mod = 1e9+7;

int main() {
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  int ans = 0;
  for(int i = 0; i < tx-sx; i++) cout << "R";
  for(int i = 0; i < ty-sy; i++) cout << "U";
  for(int i = 0; i < tx-sx; i++) cout << "L";
  for(int i = 0; i < ty-sy; i++) cout << "D";
  cout << "D";
  for(int i = 0; i < tx+1-sx; i++) cout << "R";
  for(int i = 0; i < ty+1-sy; i++) cout << "U";
  cout << "L";
  cout << "U";
  for(int i = 0; i < tx+1-sx; i++) cout << "L";
  for(int i = 0; i < ty+1-sy; i++) cout << "D";
  cout << "R";
  cout << endl;

  return 0;
}



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

int main(){
    int N, L;
    cin >> N >> L;
    vector<int> a(N+1);
    for(int i = 1;i <= N;i++)    cin >> a[i];
    int b = 0;
    for(int i = 1;i < N;i++){
        if(a[i]+a[i+1] >= L){
            b = i;
            break;
        }
        if(i == N-1){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    for(int i = 1;i < b;i++)    cout << i << endl;
    for(int i = N-1;i > b;i--)    cout << i << endl;
    cout << b << endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.Arrays;

public class Main { //HDL-style Disjoint Set
	static int N; // int_maxsize > 10000 (constrain)
	static int Q; // int_maxsize > 110000 (worstcase = 10000initial set  + 100000 new set)
	static boolean Com; //com only have two kind;
	static int V1;
	static int V2;
	static int[] S;
	static Scanner scanner;
	public static void main(String[] args){
		scanner = new Scanner(System.in);
		N = scanner.nextInt();
		N = 100000;
		S = new int[N];
		reset();
		Q = scanner.nextInt();
		FSM();
	}
	//end of main
	private static void reset(){
		Com = false;
		V1 = 0;
		V2 = 0;
		for(int i = 0; i<N; i++){
			S[i]=i;
		}
	}
	//end of reset
	private static void FSM(){
		while(Q>0){
			fetch();
			dispatch();
			Q--;
		}
	}
	//end of FSM
	private static void fetch(){
		Com = (scanner.nextInt() > 0)?true:false;
		V1 = scanner.nextInt();
		V2 = scanner.nextInt();
	}
	//end of feteh
	private static void dispatch(){
		if(Com){
			same();
		}else {
			unite();
		}
	}
	//end of dispatch
	private static void unite(){
		if(S[V1] == S[V2]){
			return;
		}else{
			merge();
		}
	}
	//end of unite
	private static void same(){
		if(S[V1] == S[V2]){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
	//end of same
	private static void merge(){
		V1 = S[V1];// use variable 1 to store the set code of V1
		V2 = S[V2];// use variable 2 to store the set code of V2
		for(int i = 0; i< N;i++)
		{
			if(S[i] == V1){
				S[i] = V2;
			}else{
				continue;
			}
		}
	}
}	



Measured memory_bytes: 105112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  string s;
  char f = 'a';
  in(s);
  rep(i, 26){
    a = 0;
    rep(j, s.size()){
      if(s[j] == f)
        a++;
    }
    if(a == 0){
      out(f);
      memi;
      return 0;
    }
    f++;
  }
  out("None");
  memi;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) {
        cout << c << endl;
    }
    else if(a == c) {
        cout << b << endl;
    }
    else cout <<a << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
string s, t;
int N;

vector<int> z_algorithm(string s){
    int n = s.size();
    vector<int> ans(n);
    ans[0] = n;
    int i = 1, j = 0;
    while(i < s.size()){
        while(i+j < s.size() && s[i+j] == s[j]) j++;
        if(j == 0) {
            i++;
            continue;
        }
        ans[i] = j;
        int k = 1;
        while(k < j && ans[k]+k < j){
            ans[i+k] = ans[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return ans;
}

bool same(int n){
    for(int i = 0; i < N; i++){
        if(s[i] != s[i%n]) return false;
    }
    return true;
}

set<int> st;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> s;
    N = s.size();
    if(same(1)){
        cout << N << endl;
        cout << 1 << endl;
        return 0;
    }
    bool ok = true;
    for(int i = 2; i < N; i++){
        if(N%i == 0){
            if(same(i)) ok = false;
        }
    }
    if(ok){
        cout << 1 << endl;
        cout << 1 << endl;
        return 0;
    }
    for(int i = N-1; i >= 0; i--) t += s[i];
    auto vs = z_algorithm(s);
    auto vt = z_algorithm(t);
    for(int i = 1; i*2 <= N; i++){
        int m = vs[i];
        if(m < i) continue;
        for(int j = 1; i*j <= m; j++){
            st.insert(i+i*j);
        }
    }
    for(int i = 1; i*2 <= N; i++){
        int m = vt[i];
        if(m < i) continue;
        for(int j = 1; i*j <= m; j++){
            st.insert(N-(i+i*j));
        }
    }
    // for(int i : st) cout << i << endl;
    if(st.size() == 0){
        cout << 1 << endl;
        cout << 1 << endl;
    }else{
        st.erase(N);
        st.erase(0);
        cout << 2 << endl;
        cout << N-1-st.size() << endl;
    }
}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N;
	ll res=0;
	string sres;
	string s,t,u;
	cin>>s;
	ll tlen=SIZE(s);
	REPD(i,SIZE(s)){
		if(i==0) continue;
		s=s.erase(i);
		//s=s.substr(0,tlen-i);
		ll len=SIZE(s);
		if(len%2==1) continue;
		t=s.substr(0,len/2);
		u=s.substr(len/2,len/2);
		if(t==u) {
			COUT(i);
			return;
		}
	}

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
n = int(input())
pos = []
for i in range(n):
  b = list(input().split( ))
  pos.append(b)
tp, xp, yp = 0, 0, 0
rflag = True
for p in pos:
  t = int(p[0])
  x = int(p[1])
  y = int(p[2])
  tint = t - tp
  xd = x - xp
  yd = y - yp
  pd = abs(xd) + abs(yd)
  if ((tint >= pd) & ((tint % 2) == (pd % 2))):
    continue
  else:
    rflag = False
    break
  
if rflag == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 27444
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    int A,B,M;
    cin>>A>>B>>M;
    vector<int>a(A);
    vector<int>b(B);
    int mia=100000,mib=100000;
    rep(i,A){
        cin>>a[i];
        mia=min(a[i],mia);
    }
    rep(i,B){
        cin>>b[i];
        mib=min(b[i],mib);
    }
    vector<int>x(M);
    vector<int>y(M);
    vector<int>c(M);
    rep(i,M){
        cin>>x[i]>>y[i]>>c[i];
    }
    int mini=200000;
    //int nedan=0;
    int nedan;
    rep(i,M){
        nedan=a[x[i]-1]+b[y[i]-1]-c[i];
        mini=min(mini,nedan);
    }
    int ans=min(mini,mia+mib);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176