akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << endl
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;

  vvll to(N);
  rep(i, N - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].pb(b);
    to[b].pb(a);
  }

  queue<P> q1;
  q1.push({u, 1});
  vll d1(N);
  while (!q1.empty()) {
    ll index = q1.front().first;
    ll distance = q1.front().second;
    q1.pop();
    if (d1[index] != 0) continue;
    d1[index] = distance;
    rep(i, to[index].size()) {
      q1.push({to[index][i], distance + 1});
    }
  }

  debugV(d1);

  queue<P> q2;
  q2.push({v, 1});
  vll d2(N);
  while (!q2.empty()) {
    ll index = q2.front().first;
    ll distance = q2.front().second;
    q2.pop();
    if (d2[index] != 0) continue;
    d2[index] = distance;
    rep(i, to[index].size()) {
      q2.push({to[index][i], distance + 1});
    }
  }

  debugV(d2);

  ll ans = 0;
  rep(i, N) {
    if (d1[i] < d2[i]) ans = max(ans, d2[i]);
  }
  ans--;
  ans--;
  COUT(ans);
  return 0;
}

Measured memory_bytes: 11296
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,m,K;
// f[i][j][0/1] i*(k-1)+1-n<=j<=m
ll f[4004][4004][2],S[4040];
signed main(){
	n=read(),m=read(),K=read();
	f[0][0][0]=1;
	for (int i=1;i<=max(n,m)*2;i++){
		S[0]=(f[i-1][0][0]+f[i-1][0][1])%ljc;
		for (int j=1;j<=max(n,m);j++) S[j]=(S[j-1]+f[i-1][j][0]+f[i-1][j][1])%ljc;
		for (int j=0;j<=max(n,m);j++){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%ljc;
			f[i][j][1]=(f[i][j][1]+S[j-1]-(j>=K?S[j-K]:0)+ljc)%ljc;
		}
	}
	ll _=0;
	for (int i=1;i<=max(n,m)*2;i++){
		for (int j=0;j<=max(n,m);j++){
			if (j%(K-1)==m%(K-1)&&j<=m&&j>=i*(K-1)+1-n) _=(_+f[i][j][1])%ljc;
		}
	}
	cout<<_;
	return 0;
}



Measured memory_bytes: 144632
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<pair<int,int>>> tree(n);
	vector<int> parent(n,-1);
	vector<long long> d(n);

	queue<int> q;
	


	for (int i = 0;i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;

		u--;
		v--;

		tree[u].emplace_back(make_pair(v, w));
		tree[v].emplace_back(make_pair(u, w));
	}
	q.push(0);

	while (!q.empty()) {
		int v = q.front();
		q.pop();
		
		for (int i = 0; i < tree[v].size(); i++) {
			int u = tree[v][i].first;
			int w = tree[v][i].second;

			if (u != parent[v]) {
				parent[u] = v;
				d[u] = d[v] + w;
				q.push(u);

			}
		}

	}

	for (int i = 0; i < n; i++) {
	
		cout << (d[i] % 2) << endl;
	}
	
}

Measured memory_bytes: 7552
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> S(H, vector<int>(W));
  for (auto& row : S)for (auto& e : row) {
    char c;
    cin >> c;
    e = c - '0';
  }
  vector<vector<int>> sum(H + 1, vector<int>(W + 1, 0));
  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      sum[h + 1][w + 1] = sum[h + 1][w] + sum[h][w + 1] - sum[h][w] + S[h][w];
    }
  }
  auto get_sum = [&sum](int h1, int w1, int h2, int w2) { return sum[h2][w2] - sum[h2][w1] - sum[h1][w2] + sum[h1][w1]; };
  const int limit = 1 << (H - 1);
  int ans = INT_MAX;
  for (int mask = 0; mask < limit; ++mask) {
    vector<pair<int, int>> sep;
    {
      int sum = 0;
      for (int i = 0, count = 0; i < H; ++i) {
        ++count;
        if ((mask >> i) & 1)sep.emplace_back(sum, count), sum += count, count = 0;
      }
      sep.emplace_back(sum, H - sum);
    }
    int cost = sep.size() - 1;
    int prev_w = 0;
    for (int w = 0; w < W; ++w) {
      bool ok = true;
      for (auto& p : sep) {
        int y, n;
        tie(y, n) = p;
        if (get_sum(y, prev_w, y + n, w + 1) <= K)continue;
        ok = false;
        break;
      }
      if (ok)continue;
      ++cost;
      prev_w = w;
    }
    bool ok = true;
    for (auto& p : sep) {
      int y, n;
      tie(y, n) = p;
      if (get_sum(y, prev_w, y + n, W) <= K)continue;
      ok = false;
      break;
    }
    if (!ok)continue;
    ans = min(ans, cost);
  }
  cout << ans << endl;
}


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

const int maxn = 105;
int q;
const long double eps = 1e-9;

int main()
{
    scanf("%d", &q);
    for(int i = 0; i < q; i ++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if(a > b)
            swap(a, b);

        long double t = (long double) a * (long double) b - 1;
        long double sqt = floorl(sqrtl(t));
        long double ans = 2 * sqt;
        if(fabsl(floorl(t / sqt) - sqt) <= eps)
            ans -= 1.0;
        if(a - sqt <= 0.0 || fabsl(a - sqt) <= eps)
            ans -= 1.0;
        printf("%.0Lf\n", ans);
    }
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		String S=sc.next();
		int s=S.length();
		if(s<=K) {
			System.out.println(S);
		}
		else {
		String str=S.substring(0,K);
		System.out.println(str+"...");
		}
	}
}


Measured memory_bytes: 38700
#include<cstdio>

#define MAXN 100000
int N;
long long A[MAXN+5],B[MAXN+5];

int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
        scanf("%lld%lld",&A[i],&B[i]);
    long long Ans=0;
    for(int i=N;i>=1;i--){
        A[i]+=Ans;
        Ans+=(B[i]-(A[i]%B[i]))%B[i];
    }
    printf("%lld",Ans);
}


Measured memory_bytes: 1664
def solve():
  n,k=[int(i) for i in input().split()]
  h=[int(i) for i in input().split()]
  dp=[0]*n
  for i, hi in enumerate(h):
    if i==0: continue
    dp[i]=min([dp[j] + abs(hi-h[j]) for j in range(max(i-k,0),i)])
  return dp[n-1]
print(solve())


Measured memory_bytes: 13928
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int K;
    cin >> K;
    int X;
    cin >> X;
    int Y;
    cin >> Y;
    if(N <= K){
        cout << N * X << endl;
    }else{
        cout << K * X + (N - K) * Y << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

char buf1[5];
char buf2[5];

int main(void) {
  cin >> buf1 >> buf2;
  int res = 0;
  REP(i, 3) {
    if(buf1[i] == buf2[i]) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m, x;
int ans[5];
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	scanf("%d", &n);
	int prev, eqc = 0, pcomp=-1;
	scanf("%d", &prev);
	REP(i, n-1){
		scanf("%d", &x);
		if(prev == x){
			eqc ++;
			continue;
		}
		int comp = prev < x;
		if(pcomp >= 0){
			if(comp == pcomp && eqc){
				if(eqc) ans[2] ++;
			}
			if(pcomp == 1 && comp == 0){
				if(eqc) ans[0] ++;
				else ans[3] ++;
			}
			if(pcomp == 0 && comp == 1){
				if(eqc) ans[1] ++;
				else ans[4] ++;
			}
		}
		prev = x;
		pcomp = comp;
		eqc = 0;
	}
	printf("%d %d %d %d %d\n", ans[0], ans[1], ans[2], ans[3], ans[4]);
	return 0;
}


Measured memory_bytes: 1196
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Long X = sc.nextLong();
        Long Y = sc.nextLong();

        int i=0;
        while(X<=Y){
            i++;
            X*=2;
        }

        System.out.println(i);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main () {
  vector <string> T{"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;
  
  for (int i = 0; i < T.size(); i++) reverse(T[i].begin(), T[i].end());
  reverse(S.begin(), S.end());
  bool flag = false;
  
  string t;
  int i = 0;
  while (i != S.size()) {
    flag = false;
    for (int j = 0; j < T.size(); j++) {
      if (S.substr(i, T[j].size()) == T[j]) {
        i += T[j].size();
        flag = true;
      }
    }
    if(!flag) {
      cout << "NO" << endl;
      break;
    }
  }
  
  if(flag) cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 512
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#else
#include <bits/stdc++.h>
#endif // VS

#define long long long
using namespace std;

#pragma region CS_COMPATIBLE
#define var auto
#define Max std::max
#define Min std::min
#define Abs std::abs
//#define List std::vector;
//#define Add push_back
#pragma endregion

void read(uint32_t& x)
{
	x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0' || k > '9')	break;
		x = x * 10 + k - '0';
	}
}

void sread(int32_t& x)
{
	bool flag;
	x = 0;
	int k = getchar_unlocked();
	if (flag = (k == '-')) k = getchar_unlocked();

	while (true)
	{
		if (k < '0' || k > '9')	break;
		x = x * 10 + k - '0';
		k = getchar_unlocked();
	}
	if (flag) x *= -1;
}

void sprint(int64_t x) {
	if (x == 0) {
		putchar_unlocked('0');
		return;
	}
	if (x < 0) {
		putchar_unlocked('-');
		x *= -1;
	}
	int s = 0;
	char f[15];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int32_t a[200000];
int main() {
	uint32_t n;
	read(n);
	for (size_t i = 0; i < n; i++) sread(a[i]);
	int64_t res;
	if (n & 1) {
		//Odd
		var sum = 0L;
		for (int i = 0; i < n - 1; i += 2) sum += a[i];
		res = sum;
		int64_t tailDiff = 0, tailDiffMax = 0;
		for (int i = n - 3; i >= 0; i -= 2)
		{
			sum -= a[i]; sum += a[i + 1];
			tailDiff += a[i + 2]; tailDiff -= a[i + 1];
			tailDiffMax = max(tailDiffMax, tailDiff);
			res = max(res, sum + tailDiffMax);
		}
	}
	else {
		//Even
		int64_t sum = 0;
		for (size_t i = 0; i < n; i += 2) sum += a[i];
		res = sum;
		for (int i = n - 1; i >= 0; i -= 2)
		{
			sum += a[i]; sum -= a[i - 1];
			res = max(res, sum);
		}
	}
	sprint(res);
}


Measured memory_bytes: 4400
#include <iostream>
#include <cstdio>

using namespace std;

int table[11][11];
int main() {
  int N;
  while (cin >> N) {
    if (N == 0) break;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> table[i][j];
      }
    }
    int total = 0;
    for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = 0; j < N; j++) {
        sum += table[i][j];
      }
      table[i][N] = sum;
      total += sum;
    }
    for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = 0; j < N; j++) {
        sum += table[j][i];
      }
      table[N][i] = sum;
    }
    table[N][N] = total;
    for (int i = 0; i < N+1; i++) {
      for (int j = 0; j < N+1; j++) {
        printf("%5d", table[i][j]);
      }
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(){
   char st[103];
   int l,i,j,count,flag;
   gets(st);
   l=strlen(st);
   flag=1;
   for(i=0;i<l;i++){
      if(st[i]>='a' && st[i]<='z'){
        count=1;
        for(j=i+1;j<l;j++){
           if(st[i]==st[j]){
              count++;
              st[j]='0';
           }
      
        }
      }
      if(count%2==1){
         flag=0;
         break;
      }
   }
   if(flag)
     printf("Yes\n");
   else
     printf("No\n");

   return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
//#include<bits/stdc++.h>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

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

	map<int, int> oMp;
	map<int, int> eMp;

	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if ((i + 1) % 2 == 1) {
			oMp[a]++;
		}
		else {
			eMp[a]++;
		}
	}

	priority_queue<pair<int, int>> oQue;// oQue.push(make_pair(0, 0));
	priority_queue<pair<int, int>> eQue;// eQue.push(make_pair(0, 0));
	for (auto iter = begin(oMp); iter != end(oMp); ++iter) {
		oQue.push(make_pair(iter->second, iter->first));
	}
	for (auto iter = begin(eMp); iter != end(eMp); ++iter) {
		eQue.push(make_pair(iter->second, iter->first));
	}

	int oMode = oQue.top().second;
	int oCount = oQue.top().first;
	oQue.pop();
	int eMode = eQue.top().second;
	int eCount = eQue.top().first;
	eQue.pop();

	if (oMode == eMode) {
		if (oCount + eCount == N) {
			cout << N / 2 << endl;
		}
		else {
			int ans = min(N - oCount - eQue.top().first, N - oQue.top().first - eCount);
			cout << ans << endl;
		}
	}
	else {
		cout << N - oCount - eCount << endl;
	}

	return 0;
}

Measured memory_bytes: 6136
#include<stdio.h>


int main(void) {
  int ld;
  int antennas[5];
  for(int i=0;i<5;i++) {
    scanf("%d", &antennas[i]);
  }
  scanf("%d", &ld);

  if(antennas[4] - antennas[0] <= ld) {
    printf("Yay!\n");
  } else {
    printf(":(\n");
  }

  return 0;
}


Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
dic = {}
for aa in a:
    if aa in dic:
        dic[aa] += 1
    else:
        dic[aa] = 1
a_sum = sum(a)
q = int(input())

for i in range(q):
    b, c = map(int, input().split())
    if b not in dic or dic[b] == 0:
        pass
    else:
        if c not in dic:
            dic[c] = 0
        numOfb = dic[b]
        a_sum += c * numOfb - b * numOfb
        dic[c] += numOfb
        dic[b] -= numOfb
    print(a_sum)


Measured memory_bytes: 20872
#include<bits/stdc++.h>
#define forz(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define lli long long int
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    faster
    int n;
    cin>>n;;
    int a[n+1];
    foro(i,n)cin>>a[i];
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
         dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);

    }
    cout<<dp[n]<<'\n';
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

struct Data
{
	char c;
	int win;
	int lose;
	Data() : win(0), lose(0) {}
	bool operator< (const Data& d)const{
		return win!=d.win ? win>d.win : lose<d.lose;
	}
};

int main()
{
	int n;
	while(scanf("%d", &n), n){
		Data data[10];
		rep(i, n){
			scanf(" %c", &data[i].c);
			rep(j, n-1){
				int tmp;
				scanf("%d", &tmp);
				if(tmp == 0)
					++data[i].win;
				else if(tmp == 1)
					++data[i].lose;
			}
		}
		sort(data, data+n);
		rep(i, n)
			printf("%c\n", data[i].c);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    rep(i, k){
        vector<int> cnt(n+1, 0);
        rep(j, n){
            cnt[max(0, j-a[j])]++;
            cnt[min(n, j+a[j]+1)]--;
        }
        int mn = 1001001001;
        rep(j, n){
            a[j] = cnt[j];
            mn = min(mn, a[j]);
            cnt[j+1] += cnt[j];
        }
        if(mn == n)break;
    }
    rep(i, n)cout << a[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 4780
while 1:
    n, r=map(int, input().split())
    if n==0:
        break
    a=[n-i for i in range(n)]
    for _ in range(r):
        p, c=map(int, input().split())
        a=a[p-1:p-1+c] + a[0:p-1] + a[p-1+c:]
    print(a[0])


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int solve(){
  int n;
  cin>>n;
  vector<int> vec(3,0);
  rep(i,n){
    int d;
    cin>>d;
    vec[d%3]++;
  }

  if(vec[1]==0 && vec[2]==0) return 1;

  int tmp=0;
  if(vec[1] > vec[2]) tmp=1,vec[1]--;
  else tmp=2,vec[2]--;

  int ans = 0;
  int x = min(vec[1], vec[2]);
  ans = 1 + vec[0] + 2*x;
  vec[1] -= x;
  vec[2] -= x;

  while(tmp%3>0 && vec[1]>0){
    tmp += 1;
    vec[1]--;
    ans++;
  }
  while(tmp%3>0 && vec[2]>0){
    tmp += 2;
    vec[2]--;
    ans++;
  }
  return ans;
}


int main(){
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 3128
#include<cstdio>
#define ll long long
const int N=2005,mo=1e9+7;
int n,k,i,j,f[N][N][2];
void add(int &x,int k){x=(x+k)%mo;}
int main(){
	scanf("%d%d",&n,&k);f[n+1][0][0]=1;
	for (i=n+1;i>=2;i--){
		for (j=n+1-i;j>=0;j--){
			add(f[i][j][0],f[i][j+1][0]);
			for (int x=0;x<2;x++)
				add(f[i-1][j+1][1],f[i][j][x]),
				add(f[i-1][j][0],f[i][j][x]);
		}
	}
	int ans=f[1][n-k][0];
	for (i=n-k-1;i>=1;i--) ans=2ll*ans%mo;
	printf("%d",ans);
}

Measured memory_bytes: 31104
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main()
{
    string S;
    string T;
    cin >> S >> T;

    bool ok = true;

    for (int i = 0; i < S.size(); ++i){
        if(S[i] == T[i]){
            continue;
        }else{
            ok = false;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
        return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool solve(string s){
    if(s.empty()){
        return true;
    }

    int n = s.size();
    vector<int> v;
    rep(i, n - 2){
        if(s.substr(i, 3) == "mew"){
            v.emplace_back(i);
        }
    }

    if(v.empty()){
        return false;
    }

    int m = v.size();
    rep(i, m - 1){
        if(v[i + 1] - v[i] == 3){
            return false;
        }
    }

    string t = "";
    int j = 0, k = 0;
    while(j < n){
        if(k < m && v[k] == j){
            j += 3;
            ++k;
            continue;
        }
        t.push_back(s[j]);
        ++j;
    }

    return solve(t);
}

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

    string s;
    cin >> s;

    if(solve(s)){
        cout << "Cat" << endl;
    }else{
        cout << "Rabbit" << endl;
    }

    return 0;
}


Measured memory_bytes: 3296
program main
  implicit none
  
  integer ::n, h(20), c=1,i,j,y
  
  read(*,*)n
  read(*,*)(h(i),i=1,n)
  
  if (n == 1) then
    write(*,*)c
    stop
  end if
  
  do i = 2, n
    y = 1
    do j = 1, i
      if (h(j) > h(i)) then
        y = 0
      end if
    end do
    if (y == 1) then
      c = c + 1
    end if
  end do
  
  write(*,*)c
end program main

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

using ll = long long;
int pre[41];

void fill() {
    for(int i = 1; i < 41; i++) {
        int l = 1, r = i;
        int p;
        while(l <= r) {
            int k = l + (r-l)/2;
            if(k*(k+1)/2 <= i) {
                p = k;
                l = k+1;
            }
            else {
                r = k-1;
            }
        }
        pre[i] = p;
        //cout << "pre[" << i << "] = " << p << endl;
    }
}

int main()
{
    ll n;
    cin >> n;
    if(n == 1) {
        cout << "0" << endl;
        return 0;
    }
    fill();
    ll ans = 0;
    for(ll i = 2; i*i <= n; i++) {
        if(n%i == 0) {
            //cout << "i = " << i << endl;
            int count = 0;
            while(n%i == 0) {
                n = n/i;
                count++;
            }
            //TODO
            //cout << "count = " << count << endl;
            ans += pre[count];
        }
    }

    if(n > 1) {
        ans++;
    }
    cout << ans;
}


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

#define fastio  ios::sync_with_stdio(false); cin.tie(0);

class BeingZero{
    public:
        ll minCost(vector<int> a, int k){
            ll n = a.size();
            int dp[n];
            dp[0] = 0;
            dp[1] = abs(a[1]-a[0]);
            for(int i=2;i<n;i++){
                dp[i] = INT_MAX;
                for(int j=1;i-j>=0 && j<=k;j++)
                    dp[i] = min( dp[i], abs(a[i]-a[i-j]) + dp[i-j]);
            }
            return dp[n-1];
        }
};

int main() {
    fastio;
    BeingZero bz;
    int n, k;
    while(cin>>n>>k){
        if(n==-1) break;
        vector<int> v(n);
        for(int i=0;i<n;i++)
            cin>>v[i];
        cout<<bz.minCost(v, k)<<"\n";
    }
    return 0;
}



Measured memory_bytes: 4480
import math
NOTCOM = "not coprime"
SETWISE = "setwise coprime"
PAIRWISE = "pairwise coprime"

def calc_prime(N):
    prime, i = set(), 1
    while i * i <= N:
        if N % i == 0:
            yield i
            if i != N//i: yield N//i
        i += 1

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = list(set(A))
    cnt2 = 0
    cnt3 = 0
    allgcd = A[0]
    for a in A:
        allgcd = math.gcd(allgcd, a)
        if a % 2 == 0:
            cnt2 += 1
        if a % 3 == 0:
            cnt3 += 1
    if allgcd != 1:
        return NOTCOM
    
    if cnt2 >= 2 or cnt3 >= 2:
        return SETWISE

    allprime = set()
    for a in A:
        for t in calc_prime(a):
            if t in allprime and t != 1:
                return SETWISE
            allprime.add(t)
    return PAIRWISE

print(main())


Measured memory_bytes: 225148
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	for(int s = 1; s * s - s <= 2 * n; s++){
		if(s * s - s == 2 * n){
			vector<vector<int>> v(s);
			int cur = 1;
			rep(i,s){
				int t = i + 1;
				while(v[i].size() < s - 1){
					v[i].emplace_back(cur);
					v[t++].emplace_back(cur);
					cur++;
				}
			}

			cout << "Yes" << endl;
			cout << s << endl;
			rep(i,s){
				cout << s - 1 << ' ';
				rep(j,s - 1){
					cout << v[i][j] << ' ';
				}
				cout << endl;
			}
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

int main() {
    ll A,B;
    cin >> A >> B;
    cout << lcm(A,B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int t, n;
  for(int i=0; i<4; ++i) {
    cin >> t >> n;
    if(t == 1) cout << 6000 * n << endl;
    else if(t == 2) cout << 4000 * n << endl;
    else if(t == 3) cout << 3000 * n << endl;
    else cout << 2000 * n << endl;
  }
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  int n, cnt = 0;
  cin >> n;
  ll sum = 0;
  bool zero = false;
  vector<ll> a(n), b(n);
  rep(i,n) {
    cin >> a[i];
    b[i] = abs(a[i]);
    sum += b[i];
    if (a[i] < 0) cnt++;
    if (a[i] == 0) zero = true;
  }
  sort(all(b));
  if(cnt%2==0 || zero) cout << sum << endl;
  else cout << sum-2*abs(b[0]) << endl;

  return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
using namespace std;
int n=0, k=0, a[100000] = {}, sam, b[100000] = {}, roop = 0, save[100000] = {0}, ans[100000] = {}, w = 0;
int main(void){
    while (1){
        int n=0, k=0, a[100000] = {}, sam, b[100000] = {}, roop = 0, save[100000] = {0}, ans[100000] = {}, w = 0;
        cin >> n >> k;
        if (n == 0 && k == 0)
            break;
        for (int i = 0; i<k; i++){
            cin >> a[i];
        }
        sort(a, a + k);
        for (int i = 0; i<k; i++){
            if (a[i + 1] - a[i] == 1){
                sam++;
            }
            else if (a[i + 1] - a[i] != 1){
                b[roop] = sam+1;
                if(a[0]==0){
                    if (a[i + 1] - a[i] == 2){
                        save[w] = roop;
                        w++;
                    }
                }
                sam = 0;
                roop++;
            }
        }
        for (int i = 0; i <= roop; i++){
            if (save[i] != 0){
                ans[i] = b[save[i]];
                ans[i]+= b[save[i] + 1] + 1;
            }
        }
        sort(b, b + roop+1);
        sort(ans, ans + roop+1);
        if (ans[roop]>b[roop])
        cout << ans[roop] << endl;
        if (ans[roop] <= b[roop]){
            if(a[0]==0){
                cout << b[roop]+1 << endl;
            }
            else{
            cout << b[roop] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2744
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> ans(N,0);
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int a = 0;
      cin >> a;
      ans[a-1]++;
    }
  }
   int num=0;
  for(int i=0;i<ans.size();i++){
    if(ans[i] == 0){
       num++;
    }
  }

  cout << num << endl;
}

Measured memory_bytes: 3200
n, W = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
for i in range(1, n+1):
	for w in range(W+1):
		if t[i-1][0] > w:
			dp[i][w] = dp[i-1][w]
		else:
			dp[i][w] = max(dp[i-1][w], dp[i-1][max(0, w - t[i-1][0])] + t[i-1][1])
print(dp[-1][-1])

Measured memory_bytes: 173832
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,num[100][100],min=INF;
	REP(i,100)REP(j,100){
		num[i][j]=0;
	}
	cin>>n;
	REP(i,n){
		string s;
		cin>>s;
		REP(j,s.size()){
			num[i][s[j]-'a']++;
		}
	}
	for(int i=0;i<100;i++){
		min=INF;
		for(int j=0;j<n;j++){
			if(min>num[j][i]){
				min=num[j][i];
			}
		}
		if(min!=0){
			for(int j=0;j<min;j++){
				putchar(i+'a');
			}
		}
	}
	cout<<endl;
	return 0;
}

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

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	
	if(k<=a)
	{
		cout<<k;
	}	
	else if(k>a&&k<=a+b)
	{
		cout<<a;
	}
	else
	{
		cout<<a-(k-a-b);
	}
	return 0;
}

Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(
        it,
        n: usize,
        m: usize,
        k: usize,
        mut a: [usize; n],
        mut b: [usize; m]
    );
    let mut s: usize = a.iter().sum();
    while s > k {
        let p = a.pop().unwrap();
        s -= p;
    }
    let mut ret = a.len();
    let mut count = ret;
    'outer: for bi in b {
        s += bi;
        count += 1;
        while s > k {
            if let Some(p) = a.pop() {
                s -= p;
                count -= 1;
            } else {
                break 'outer;
            }
        }
        ret = max(ret, count);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 9348
n, k = map(int, input().split())
xys = [tuple(map(int, input().split())) for _ in range(n)]
x = list(sorted([xy[0] for xy in xys]))
y = list(sorted([xy[1] for xy in xys]))

ans = int(4e18)
for i0 in range(len(x) - 1):
    x0 = x[i0]
    for i1 in range(i0 + 1, len(x)):
        x1 = x[i1]
        for j0 in range(len(y) - 1):
            y0 = y[j0]
            for j1 in range(j0 + 1, len(y)):
                y1 = y[j1]
                s = (x1 - x0) * (y1 - y0)
                cnt = 0
                for xy in xys:
                    if x0 <= xy[0] <= x1 and y0 <= xy[1] <= y1:
                        cnt += 1
                if k <= cnt:
                    ans = min(ans, s)
print(ans)

Measured memory_bytes: 49776
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];

    vi dp(n, INFLL);
    dp[0] = 0;

    for(ll i=1; i<n; i++){
        chmin(dp[i], dp[i-1] + abs(h[i-1]-h[i]));
        if(i>=2) chmin(dp[i], dp[i-2] + abs(h[i-2]-h[i]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n, k, ans;
  scanf("%lld%lld", &n, &k);
  if(n % k == 0)
    ans = 0;
  else if(k > n)
    ans = min(n, k-n);
  else{
    ans=n%k;
    n%=k;
    ll mn = ans+1;
    while(ans < mn){
      mn = ans;
      ans= abs(ans-k);      
    }
    ans = min(ans, mn);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int>a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    a.resize(3);
    rep(i,3)cin>>a[i];
    sort(ALL(a));
    if(a[0]+a[1]==a[2])yes;
    else no;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main() {
	string not_exist_msg = "IMPOSSIBLE";
	int a, b;
	cin >> a >> b;
	int sum = a + b;
	if (sum % 2 == 0)cout << sum / 2 << endl;
	else cout << not_exist_msg << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>


int main() {
	std::string s, t; std::cin >> s >> t;
	int min = INT_MAX;
	for (auto i = 0; i <= s.size() - t.size(); ++i) {
		int count{ 0 };
		for (auto j = 0; j < t.size(); ++j) {
			if (s[i + j] != t[j]) {
				++count;
			}
		}
		min = std::min(min, count);
	}
	std::cout << min << '\n';
}

Measured memory_bytes: 3628
from math import atan2, sqrt
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
P.sort(key=lambda p: atan2(p[1], p[0]))

ans = 0
for i in range(N):
    cx = cy = 0
    for j in range(N):
        x, y = P[(i+j) % N]
        cx += x; cy += y
        ans = max(ans, cx**2 + cy**2)
print("%.16f" % sqrt(ans))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  	int a,b,c,d;
  	int cnt=0;
  	cin >> a >> b >> c >> d;
    for(int i=0;i<a+1;++i){
    	for(int j=0;j<b+1;++j){
          for(int k=0;k<c+1;++k){
            if(i*500+j*100+50*k==d){
              ++cnt;
            }
          }
        }
    }
 
    cout << cnt << endl;
}

Measured memory_bytes: 3600
require 'matrix'

n, m, l = gets.split.map(&:to_i)
a = []
n.times do
  a << gets.split.map(&:to_i)
end
b = []
m.times do
  b << gets.split.map(&:to_i)
end
ma = Matrix[*a]
mb = Matrix[*b]

mc = ma * mb
mc.to_a.each { |r| puts r.join(" ")}

Measured memory_bytes: 9820
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct P {
  int a,b;
  double w;
  double v;
};

int main() {
  int D;
  cin >> D;
  while(D--){
    int n;
    cin >> n;
    int wallx[n+2], wallh[n+2];
    wallx[0] = 0; wallx[n+1] = 100;
    wallh[0] = wallh[n+1] = 50;
    REP(i,n) {
      cin >> wallx[i+1]>>wallh[i+1];
    }
    int m;
    cin >> m;
    int faucetx[n], faucetv[n];
    int N = n+1;
    double v[N];
    memset(v,0,sizeof(v));
    REP(i,m) {
      cin >> faucetx[i] >> faucetv[i];
      REP(j,N) {
        if (wallx[j] < faucetx[i] && faucetx[i] < wallx[j+1]) {
          v[j] += faucetv[i];
          break;
        }
      }
    }
    int l;
    cin >> l;
    double ans[l];
    int anx[l], time[l];
    REP(i,l) {
      cin >> anx[i] >> time[i];
      ans[i] = 50;
    }
    vector<P> V(N);
    REP(i,N) {
      V[i] = (P){i,i+1,0,v[i]};
    }
    double t = 0;
    while(t<1000000) {
      double mi = INF;
      int idx = 0;
      bool right = 0;
      REP(i,V.size()) {
        int a = V[i].a, b = V[i].b;
        double hoge = (wallx[b]-wallx[a])*30*min(wallh[a], wallh[b]);
        if (V[i].v > 0 && mi > (hoge - V[i].w) / V[i].v) {
          mi = (hoge - V[i].w) / V[i].v;
          idx = i;
          if (wallh[a] > wallh[b]) right = 1;
          else right = 0;
        }
      }
      
      REP(i, l) {
        if (t <= time[i] && time[i] < t+mi) {
          FOR(it,V) {
            if (wallx[it->a] < anx[i] && anx[i] < wallx[it->b]) {
              // cout << anx[i] << " " << wallx[it->a] << " ";
              // cout << (it->w + (time[i]-t)*it->v) << endl;
              ans[i] = (it->w + (time[i]-t)*it->v) / ((wallx[it->b]-wallx[it->a])*30);
            }
          }
        }
      }
      
      t += mi;
      REP(i,V.size())
        V[i].w += mi*V[i].v;


      // cout << "t=" << t << endl;
      // FOR(it, V) {
      //   printf("(%d,%d) w=%f, v=%f\n",it->a,it->b,it->w,it->v);
      // }
      
      if (V.size()==1) {
        break;
      }
      if (right) {
        if (abs(V[idx+1].w - (wallx[V[idx+1].b]-wallx[V[idx+1].a]) * 30 * wallh[V[idx+1].a]) < 1e-8) { // Ì
          V[idx+1] = (P){V[idx].a, V[idx+1].b, V[idx].w+V[idx+1].w, V[idx].v+V[idx+1].v};
          V.erase(V.begin() + idx);
        } else {                // ¬o
          V[idx+1].v += V[idx].v;
          V[idx].v = 0;
        }
      } else {
        if (abs(V[idx-1].w - (wallx[V[idx-1].b]-wallx[V[idx-1].a]) * 30 * wallh[V[idx-1].b]) < 1e-8) { // Ì
          V[idx] = (P){V[idx-1].a, V[idx].b, V[idx].w+V[idx-1].w, V[idx].v+V[idx-1].v};
          V.erase(V.begin() + idx-1);
        } else {                // ¬o
          V[idx-1].v += V[idx].v;
          V[idx].v = 0;
        }
      }
    }
    REP(i,l) {
      printf("%.5lf\n", ans[i]);
    }
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b,c,x,i=0;
cin>>a>>b>>c;
for(x=a;x<=b;x++){
if(c%x==0){
i+=1;
}
else if(c%x!=0){
i+=0;
}
}
cout<<i<<endl;
     return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(){
	int K;
	cin>>K;
	if(K%2==1){
		cout<<(K/2)*(K/2+1)<<endl;
		
	}
	else if(K%2==0){
		cout<<(K/2)*(K/2)<<endl;
	}
	return 0;
}

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

int main(){
  int n,p;
  cin >> n >> p;
  int a=0;
  int b=0;
  int temp;
  for(int i=0;i<n;i++){
    cin >> temp;
    if(temp%2==0)a++;
    else b++;
  }
  long long int ans=0;
  if(p==1){
    if(b==0){ans=0;
    }else if(b%2==0){
      ans=floor(pow(2,b-1));
    }else{
      ans=floor(pow(2,b-1));
    }
    
  }else{
    if(b==0){ans=1;
    }else{
      ans=floor(pow(2,b-1));
    }
  }
  ans=ans*floor(pow(2,a));
  cout << ans << endl;
  return 0;
}
  


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

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


int main() {
	int a, b, c, d;
	cin >> a>>b;
	if (a >= 13) {
		cout << b << endl;
		return 0;
	}
	if ( a >= 6){
		cout << b / 2 << endl;
		return 0;
	}
	else { 
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

    int min_val = MAX;
    rep(i, n.size()-2){
        min_val = min(min_val, abs(stoi(n.substr(i, 3)) - 753));
    }

    cout << min_val << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int k;
vector<string>v;
set<string>ss;
int main()
{
	cin>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		for(int j=1;j<=5;j++)
		{
			if(i+j>s.size())
			{
				break;
			}
			ss.insert(s.substr( i,j ));
		}
	}
	for(set<string>::iterator it=ss.begin();it!=ss.end();it++)
	{
		v.push_back(*it);
	}
	sort(v.begin(),v.end());
	cout<<v[k-1]<<endl;
	return 0;
}


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

int dfs(vector< vector<int> > &G, vector<int> &D, int v){
  if(D[v] >= 0) return D[v];
  int t = 0;
  for(size_t i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i];
    t = max(t,dfs(G,D,v_)+1);
  }
  D[v] = t;
  return t;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N);
  for(int i = 0; i < M; ++i){
    int x, y;
    cin >> x >> y;
    --x,--y;
    G[y].push_back(x);
  }
  vector<int> D(N,-1);
  int ans = 0;
  for(int i = 0; i < N; ++i){
    if(D[i] < 0) dfs(G,D,i);
    ans = max(ans,D[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 12160