akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

// 入次数と出次数がともに1である ⇒ 辺の向きが揃ったループ（v1 -> v2 -> ... -> vn -> v1）
// ⇒ ある点を出発して戻って来られるかを調べる
//
// ループを構成する経路が複数あれば、より短い方が条件を満たす（(v1 -> v2 -> v3, v1 -> v3)の場合、条件に合わない(v1,v2,v3)を採用しない）
// ⇒最短経路のループを探せば良い
int main() {
  int N;  // 頂点の数
  int M;  // 辺の数
  std::cin >> N >> M;

  // 頂点の親子関係のマップを作る
  std::unordered_map<int, std::vector<int>> children_map;  // 親頂点から子供を探すためのマップ
  for (int i = 0; i < M; ++i) {
    int A, B;  // AからBへの辺
    std::cin >> A >> B;
    children_map[A].push_back(B);
  }

  // 最短のループを探す
  std::vector<bool> visited(N + 1);  // 訪問を記録するフラグ列
  std::vector<int> path;             // 見つけた頂点をたどる経路
  std::vector<int> shortest_path;    // 見つけたループの最短経路
  path.reserve(N + 1);
  shortest_path.reserve(N + 1);
  bool quit = false;  // 処理を終了するためのフラグ
  for (int start = 1; start <= N; ++start) {
    // 初期化
    std::fill(visited.begin(), visited.end(), false);
    path.clear();
    visited[start] = true;
    path.push_back(start);

    while (true) {
      // まだ訪問していない子頂点に訪問する
      bool all_visited = true;  // すべての子頂点が訪問済みだったか
      for (const auto& child : children_map[path.back()]) {
        // 始点に戻ってこられる最短経路を記録する
        if (child == start) {
          if (shortest_path.empty() || path.size() < shortest_path.size()) {
            shortest_path = path;

            // これ以上ない最短経路が見つかれば、そこで終了する
            if (shortest_path.size() == 2) quit = true;
          }
        } else if (!visited[child]) {
          // 未訪問の子頂点があれば、その先も訪問する
          path.push_back(child);
          visited[child] = true;
          all_visited = false;
          break;
        }
      }
      if (quit) break;

      // すべての子頂点が訪問済みとなれば、1つ前の頂点に戻る
      if (all_visited) {
        path.pop_back();

        // すべての頂点を確認し終えたら調査を終了する
        if (path.empty()) break;
      }
    }

    if (quit) break;
  }

  // 結果発表
  if (shortest_path.empty()) {
    // ループが見つからなかった場合
    std::cout << "-1";
  } else {
    // ループを見つけた場合
    std::cout << shortest_path.size() << '\n';
    for (const auto& v : shortest_path) {
      std::cout << v << '\n';
    }
  }

  return 0;
}


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

int main(){
    int x, n;
    cin >> x >> n;
    int ng[102] = {};
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        ng[p] = true;
    }
    int ret = 0, score = 1<<30;
    for(int i = 0; i <= 101; i++){
        if(ng[i])   continue;
        if(abs(x-i) < score){
            ret = i;
            score = abs(x-i);
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int visited[31];
int main()
{
	int n,m,u,a,i,j,ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&u);
		for(j=1;j<=u;j++)
		{
			scanf("%d",&a);
			visited[a]++;
		}
	}
	for(i=1;i<=m;i++)
		if(visited[i]==n)
			ans++;
	printf("%d",ans);
	return 0;
}

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

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SSS") cout<<0<<endl;
  else if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR") cout<<1<<endl;
  else if(s=="RRS"||s=="SRR") cout<<2<<endl;
  else if(s=="RRR") cout<<3<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>


int main(){

  int m, f, r;

  while(1){
    scanf("%d %d %d", &m, &f, &r);
    if(m==-1 && f==-1 && r==-1)break;
    if(m==-1 || f==-1){
      printf("F\n");
    }else if(m+f>=80){
      printf("A\n");
    }else if(65<=m+f && m+f<80){
      printf("B\n");
    }else if(50<=m+f && m+f<65){
      printf("C\n");
    }else if(30<=m+f && m+f<50){
      if(50<=r){
	printf("C\n");
      }else{
	printf("D\n");
      }
    }else if(m+f<30){
      printf("F\n");
    }
  }


  
  return 0;
  
}

Measured memory_bytes: 584
#include <iostream>

using namespace std;

int main () {
    int a, b;
    char op;

    while (true) {
        cin >> a >> op >> b;
        
        if (op == '?') break;

        if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else cout << a / b << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}
ll power(ll a,ll b) {long long res = 1; while (b > 0) {if (b & 1)res = res * a;a = a * a;b >>= 1;} return res;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    
    for(int p=0;p<testcase;p++){
        ll a=0,b=0,m=0;
        cin>>a>>b>>m;
        ll array[a]={0};
        ll array2[b]={0};
        ll array3[m]={0};
        ll mina=9999999999,minb=9999999999;
        for(int i=0;i<a;i++){
            cin>>array[i];
            mina=min(array[i],mina);
        }
        for(int i=0;i<b;i++){
            cin>>array2[i];
            minb=min(array2[i],minb);
        }
        ll min1=9999999999; 
        ll min_index=0;
        for(int i=0;i<m;i++){
            ll tempa=0,tempb=0,tempc=0;
            cin>>tempa>>tempb>>tempc;
            array3[i]=array[tempa-1]+array2[tempb-1]-tempc;
            if(array3[i]<=min1)
            min1=array3[i];
        }
        min1=min(min1,mina+minb);
        

        cout<<min1;
        
        
        
        
        
        
        
        }

    return 0;
}


Measured memory_bytes: 5956
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
//#define fi first
//#define se second
//#define P pair<int,int>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int NM = 2e5+5, M = 6e5+5, p = 924844033, g = 5; 
struct edge{ int to, nxt; } e[NM<<1];
int head[NM], cnt = 0;
inline void add(int x,int y) {
	e[++cnt].to = y, e[cnt].nxt = head[x], head[x] = cnt;
	e[++cnt].to = x, e[cnt].nxt = head[y], head[y] = cnt;
}
ll fac[NM] = {1}, ni[NM], ans[NM]; 
inline ll C(int n,int m) { return fac[n] * ni[m] % p * ni[n-m] % p; }
inline ll Pow(ll x,int t) {
	ll ret = 1;
	while( t ) {
		if( t & 1 ) ret = ret * x % p;
		x = x * x % p, t >>= 1; 
	} return ret;
}

int q[M], fa[M], sz[M]; 

ll gn, P[M], a[M], b[M], c[M]; int N = 1, L = 0, rev[M]; 
inline void _(ll &x) { x = x >= p ? x - p : (x < 0 ? x + p : x); }
inline void ntt(ll *a,int flag) { 
	rep(i,0,N-1) if( i < rev[i] ) swap(a[i],a[rev[i]]);
	ll x, y, w;
	for(register int i = 2; i <= N; i <<= 1) { 
		for(register int j = 0; j < (i>>1); j++) { 
			w = flag == 1 ? P[N/i*j] : P[N-N/i*j];
			for(register int k = j, kk = j + (i>>1); k < N; k += i, kk += i) { 
				x = a[k], y = a[kk] * w % p;
				_(a[k] = x + y), _(a[kk] = x - y);
			}
		} 
	}
	if( flag == -1 ) rep(i,0,N-1) a[i] = a[i] * gn % p;
}

int main() {
	int n = read(), x, l = 0, r = 0;
	rep(i,1,n) fac[i] = fac[i-1] * i % p;
	ni[n] = Pow(fac[n],p-2);
	dow(i,n-1,0) ni[i] = ni[i+1] * (i+1) % p;
	rep(i,1,n-1) add(read(),read());
	
	q[++r] = 1;
	while( l < r ) { 
		x = q[++l], sz[x] = 1;
		for(register int i = head[x]; i; i=e[i].nxt) if( e[i].to != fa[x] ) fa[q[++r]=e[i].to] = x;
	}
	dow(i,n,2) { 
		x = q[i];
		b[sz[x]]++, b[n-sz[x]]++;
		sz[fa[x]] += sz[x];
	}
	
	rep(i,1,n) ans[i] = n * C(n,i) % p;
	while( N <= 2 * n ) N <<= 1, L++;
	gn = Pow(N,p-2);
	rep(i,1,N-1) rev[i] = (rev[i>>1] >> 1) | ((i & 1) << L-1);
	P[0] = 1, P[1] = Pow(g,(p-1)/N);
	rep(i,2,N) P[i] = P[i-1] * P[1] % p;
	
	rep(i,0,n) b[i] = b[i] * fac[i] % p;
	rep(i,0,n) c[i] = ni[n-i];
	ntt(b,1), ntt(c,1);
	rep(i,0,N-1) a[i] = b[i] * c[i] % p;
	ntt(a,-1);
//	rep(i,0,N-1) cout<<a[i]<<" "; cout<<endl;
//	rep(i,0,n) { 
//		rep(j,0,n) (a[i+j] += b[i] * c[j]) %= p;
//	}
	rep(i,n+1,n+n) (ans[i-n] -= a[i] * ni[i-n]) %= p;
	rep(i,1,n) printf("%lld\n", (ans[i]+p)%p); 
}

Measured memory_bytes: 38912
n, m = map(int, input().split())
l = []
for i in range(m):
    l.append(list(map(str, input().split())))

#print(l)

wa_ct = 0
ac_ct = 0
wa_l = [0] * (n+1)
ac_l = [False] * (n+1)

for item in l:
    if ac_l[int(item[0])] == True:
        continue
    else:
        if item[1] == 'WA':
            #wa_ct += 1
            wa_l[int(item[0])] += 1
        else:
            ac_ct += 1
            wa_ct += wa_l[int(item[0])]
            ac_l[int(item[0])] = True

#print(ac_l)
print(ac_ct, wa_ct)

Measured memory_bytes: 33716
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const int inf = 2000000;
int n;
int t[20][20];
int dp[1<<20];

int main() {
    while (cin >> n, n) {
        rep(i,n) rep(j,n+1) cin >> t[i][j];
        rep(i,1<<n) dp[i] = inf;
        dp[0] = 0;

        rep(bit,1<<n) {
            if (dp[bit] == inf) continue;
            rep(i,n) {
                if (bit & (1<<i)) continue;
                int mn = t[i][0];
                rep(j,n) {
                    if (bit & (1<<j)) {
                        chmin(mn, t[i][j+1]);
                    }
                }
                chmin(dp[bit|(1<<i)], dp[bit]+mn); 
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(U == S){
        A--;
    }
    else{
        B--;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  vector<string> s(3);
  rep(i,3)cin>>s[i];
  vector<int> vec(3);
  int x=0;
  while(1){
    if(vec[x]==s[x].size()){
      cout<<(char)(x+'A')<<endl;
      return 0;
    }
    vec[x]++;
    x=s[x][vec[x]-1]-'a';
  }
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

bool search(int a[], int start, int end, int x){

  if(start==end && x!=a[start]) return false;
  int mid=(start+end)/2;
  if(x<a[mid]) return search(a, start, mid-1,x);
  else if(x>a[mid]) return search(a, mid+1, end,x);
  else if(x==a[mid]) return true;
  return false;
}

int ans_sea(int a[], int b[], int c[], int x){
  if(search(a,0,6, x)) return 1;
  if(search(b,0,3, x)) return 2;
  if(search(c,0,0, x)) return 3;
  return 0;
}

int main(){
  int a[]={1,3,5,7,8,10,12};
  int b[]={4,6,9,11};
  int c[]={2};
  
  int x, y;
  cin >> x >> y;
  if(ans_sea(a,b,c,x)==ans_sea(a,b,c,y)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{

	ll a[5];
	for(ll i=0;i<5;i++)
		cin>>a[i];
	ll k;
	cin>>k;
	for(ll i=0;i<5;i++)
		for(ll j=0;j<5;j++)
			if(a[j]-a[i]>k)
			{
				cout<<":(";
				return;
			}
	cout<<"Yay!";
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////
signed main() {
  int n,m;
  cin>>n>>m;
  int ans=0;
  vector<vector<int>>b(100001,vector<int>(0));
  priority_queue<int>kouho;
  //b[i]はi日かかるバイトの報酬一覧
  rep(i,n){
    int ta,tb;
    cin>>ta>>tb;
    b[ta].push_back(tb);
  }

  for(int yuuyo=1; yuuyo<=m; yuuyo++){
    rep(i,b[yuuyo].size())kouho.push(b[yuuyo][i]);
    if(kouho.size()){
    int t=0;
    t=kouho.top();
    kouho.pop();
    ans+=t;
    }
  }
    cout<<ans<<endl;
  }


Measured memory_bytes: 8720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

   for(int c=1; c<=3; c++) if(c!=a && c!=b) cout<<c<<endl;
   return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int n,x;
  cin>>n;
  map<int,int> um;
  vector<int> V;
  for(int i=0;i<n-1;i++)
  {
    cin>>x;
    um[x]++;
  }
  map<int,int>::iterator it;
  for(int i=1;i<=n;i++)
  {
    if(um[i]==0)
    cout<<0<<endl;
    else
    {
      cout<<um[i]<<endl;
    }
  }
}

int main()
{
  fastio
  solve();
}


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

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

    std::vector<int> waits(n);
    int sum = 0;
    for(int idx = 0; idx < n; ++ idx){
        int num;
        std::cin >> num;
        sum += num;
        if(idx == 0){
            waits[idx] = num;
        }else{
            waits[idx] = waits[idx - 1] + num;
        }
    }

    int ans = 999999999;
    for(int idx = 0; idx < n; ++ idx){
        ans = std::min(ans, std::abs(waits[idx] - (sum - waits[idx])));
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            var dict = new Dictionary<int, List<int>>();
            for(int i = 1; i <= N; i++)
            {
                dict.Add(i, new List<int>());
            }
            for (int i = 0; i < M; i++)
            {
                line = Console.ReadLine();
                strs = line.Split(' ');
                var A = int.Parse(strs[0]);
                var B = int.Parse(strs[1]);
                dict[A].Add(B);
                dict[B].Add(A);
            }
            int[] distance = new int[N + 1];
            for(int i = 0; i <= N; i++)
            {
                distance[i] = 9999999;
            }
            distance[1] = 0;
            int[] direction = new int[N + 1];

            List<int> next_places = new List<int>();
            List<int> nextnext = new List<int>();
            next_places.Add(1);
            int depth = 1;
            while (next_places.Count() > 0)
            {
                foreach (var next in next_places)
                {
                    foreach(var data in dict[next])
                    {
                        if (distance[data] > depth)
                        {
                            distance[data] = depth;
                            nextnext.Add(data);
                        }
                    }
                }
                depth++;
                next_places.Clear();
                next_places.AddRange(nextnext);
                nextnext.Clear();
            }

            for (int i = 2; i <= N; i++)
            {
                foreach(var next in dict[i])
                {
                    if (distance[next] == distance[i] - 1)
                    {
                        direction[i] = next;
                        break;
                    }
                }
            }
            Console.WriteLine("Yes");

            for (int i = 2; i <= N; i++)
            {
                Console.WriteLine(direction[i]);
            }
        }
    }
}


Measured memory_bytes: 55748
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, W, a, b);
  if (a < b) {
    print(max(b - a - W, 0));
  } else {
    print(max(a - b - W, 0));
  }
}


Measured memory_bytes: 256
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)

inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void scd(int &a){scanf("%d",&a);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a;
	scd(a);
	int h=a/3600;
	a%=3600;
	int m=a/60;
	a%=60;
	printf("%d:%d:%d\n",h,m,a);
	
	return 0;
}

Measured memory_bytes: 3204
from collections import deque

k = int(input())
n = deque([1,2,3,4,5,6,7,8,9])

n_popleft = n.popleft
n_append = n.append
for i in range(k) :
  ans = n_popleft()
  a = ans*10+ans%10
  if a%10 == 0 :
    ap = [a,a+1]
  elif a%10 == 9 :
    ap = [a-1,a]
  else :
    ap = [a-1,a,a+1]
  for num in ap :
    n_append(num)
  
print(ans)

Measured memory_bytes: 11876
#include<bits/stdc++.h>
using namespace std;
const int N=200007;
struct node{int mx,ls,rs;}t[N*350];
vector<int>e[N];int n,m,tot,ans[N],a[N],h[N],root[N];
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
#define mid ((l+r)/2)
void build(int&p,int l,int r)
{
    p=++tot;
    if(l^r) build(t[p].ls,l,mid),build(t[p].rs,mid+1,r);
}
int query(int p,int l,int r,int L,int R)
{
    if(L>R||l>R||L>r) return 0;
    if(L<=l&&r<=R) return t[p].mx;
    return max(query(t[p].ls,l,mid,L,R),query(t[p].rs,mid+1,r,L,R));
}
void update(int&p,int pre,int l,int r,int x,int v)
{
    t[p=++tot]=t[pre],t[p].mx=max(t[p].mx,v);
    if(l==r) return ;
    x<=mid? update(t[p].ls,t[pre].ls,l,mid,x,v):update(t[p].rs,t[pre].rs,mid+1,r,x,v);
}
void dfs(int u,int fa)
{
    ans[u]=query(root[fa],1,m,1,a[u]-1)+1;
    update(root[u],root[fa],1,m,a[u],ans[u]);
    ans[u]=max(ans[u],ans[fa]);
    for(int v:e[u]) if(v^fa) dfs(v,u);
}
#undef mid
int main()
{
    n=read();
    for(int i=1;i<=n;++i) h[i]=a[i]=read();
    for(int i=1,u,v;i<n;++i) u=read(),v=read(),e[u].push_back(v),e[v].push_back(u);
    sort(h+1,h+n+1),m=unique(h+1,h+n+1)-h-1;
    for(int i=1;i<=n;++i) a[i]=std::lower_bound(h+1,h+m+1,a[i])-h;
    build(root[0],1,m),dfs(1,0);
    for(int i=1;i<=n;++i) printf("%d\n",ans[i]);
}


Measured memory_bytes: 73712
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

string ans = "Yes";

void solve(){
	LL mod9 = 0;
	int N = S.size();
	for(int i=0;i<N;i++){
		mod9 = (mod9 + (S[i]-'0'))%9LL;
	}
	if(mod9>=1) ans = "No";
}

int main(){
    cin >> S;

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3380
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int r=0,b=0;
  rep(i,n){
    if(s[i]=='R')++r;
    else ++b;
  }
  if(r>b)cout<<"Yes\n";
  else cout<<"No\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

int main() {
    char c;  cin >> c;
    if(c == 'A')  cout << 'T' << endl;
    if(c == 'C')  cout << 'G' << endl;
    if(c == 'G')  cout << 'C' << endl;
    if(c == 'T')  cout << 'A' << endl;
}

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

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void Main()
{
    int n;
    cin >> n;
    mint a = 10;
    mint b = 9;
    mint c = 8;
    a = a.pow(n);
    b = b.pow(n);
    c = c.pow(n);
    mint ans = a - b*2 + c;
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3652
A=[]

for i in range(5):
    A.append(int(input()))

m=10
s=10

for i in range(5):
    if A[i]%10<m and A[i]%10!=0:
        m=A[i]%10
        s=i

su=0

for i in range(5):
    if i==s:
        su+=A[i]
    elif A[i]%10!=0:
        su+=(A[i]//10+1)*10
    else:
        su+=A[i]
        
print(su)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
main(){
int N;
string S;
  
  cin>>N;
  cin>>S;
  if(N%2 ==1){
  cout<<"No"<<endl;
  return 0;}
for(int i =0;i<N/2;i++){
if(S.at(i)!=S.at(i+N/2)){
cout<<"No"<<endl;
  return 0;
}
}
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s[1000007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s+1;
    int n=strlen(s+1);
    int ans=0;
    for(int i=n;i;--i){
        if(s[i]<'5'||s[i]=='5'&&s[i-1]<'5')
            ans+=s[i]-'0';
        else{
            ans+=10-(s[i]-'0');
            ++s[i-1];
        }
    }
    if(s[0])
        ++ans;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005
#define inf 100000000000
// for a particular cell we want min capacity and max profit, as i can have profit of x with y cpacity why i take y+z capcity
// to pick a items we need  profit >= of this price (price<= profit)
// we are building table where we have n items and p amt of proift
// dp[i][j] -> what will be min cpacity i must have if i can pick i total itmes with p max profit

ll *weight, *price;
ll n, capacity;
ll dp[101][MAX];
// as we have total max 100 items and 10^5 max profit 

// dp[i][j] -> min capcity we require if we can pick from total i items and we must have j profit

// in this problem we map item with profit rather than item with capcity
// so in end we traverse last row and check all capcity that we fill in table which are less than bag capacity, this will gives max profir (which is nothing but j col val)

ll knapsack(ll max_profit){

    for(ll items=0; items<=n; items++){ 
        // so for total i items we will min cpacity if we have 0-max_profit profit
        for(ll profit=0; profit<=max_profit; profit++){
            if(items==0){
                if(profit==0) dp[items][profit]=0;// if we have 0 profit and 0 item, 0 will be our req capcity
                else dp[items][profit]=inf; // but if we have 0 item and need some profit then INF will be needed capcity(we take INF as we find ans using min)
            }
            else if(price[items-1]<=profit){
                // if we can we have 2 possibility
                // 1. don't pick, normal get min capcity with this given profit with total (item-1) elemnts
                // 2. if we pick, we check what will be min capcity req when we have total (item-1) elemnts and (profit-price[i-1]) total profit
                // so int this case min cap will be dp[items-1][profit-price[items-1]]+weight[items-1]
                dp[items][profit] = min(dp[items-1][profit-price[items-1]]+weight[items-1], dp[items-1][profit]);
            }
            else{
                // if we can't pick the ith item we will consider min cpacity for this profit without taking this item
                // that is dp[item-1][profit]
                dp[items][profit] = dp[items-1][profit];
            }
        }
    }

    ll ans=0;
    for(ll profit=0; profit<=max_profit; profit++){
        if(dp[n][profit]<=capacity) ans=profit;
    }

    return ans;
}

int main(){
    cin>>n>>capacity;
    weight = new ll[n];
    price = new ll[n];
    ll max_profit=0;
    for(int i=0; i<n; i++){
        cin>>weight[i]>>price[i];
        max_profit += price[i];
    }

    cout<<knapsack(max_profit)<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

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

    cin>>s>>w;

    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var srh = new RollingHash(s);
        var thash = new RollingHash(t).Slice(0, t.Length);
        for (int i = 0; i <= s.Length - t.Length; i++)
        {
            var shash = srh.Slice(i, t.Length);
            if (shash == thash) Console.WriteLine(i);
        }
        Console.Out.Flush();
    }
}


class RollingHash
{
    const ulong MASK30 = (1UL << 30) - 1;
    const ulong MASK31 = (1UL << 31) - 1;
    const ulong MOD = (1UL << 61) - 1;
    const ulong POSITIVIZER = MOD * ((1UL << 3) - 1);
    static uint Base;
    static ulong[] powMemo = new ulong[500000 + 1];
    static RollingHash()
    {
        Base = (uint)new Random().Next(129, int.MaxValue);
        powMemo[0] = 1;
        for (int i = 1; i < powMemo.Length; i++)
            powMemo[i] = CalcMod(Mul(powMemo[i - 1], Base));
    }

    ulong[] hash;

    public RollingHash(string s)
    {
        hash = new ulong[s.Length + 1];
        for (int i = 0; i < s.Length; i++)
            hash[i + 1] = CalcMod(Mul(hash[i], Base) + s[i]);
    }

    public ulong Slice(int begin, int length)
    {
        return CalcMod(hash[begin + length] + POSITIVIZER - Mul(hash[begin], powMemo[length]));
    }

    private static ulong Mul(ulong l, ulong r)
    {
        var lu = l >> 31;
        var ld = l & MASK31;
        var ru = r >> 31;
        var rd = r & MASK31;
        var middleBit = ld * ru + lu * rd;
        return ((lu * ru) << 1) + ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    private static ulong Mul(ulong l, uint r)
    {
        var lu = l >> 31;
        var rd = r & MASK31;
        var middleBit = lu * rd;
        return (l & MASK31) * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    private static ulong CalcMod(ulong val)
    {
        val = (val & MOD) + (val >> 61);
        if (val >= MOD) val -= MOD;
        return val;
    }
}




Measured memory_bytes: 33176
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
int main(){
    vector<int> ans(10001);
    fill(All(ans),0);
    for(int i = 1;i<=100;i++){
        for(int j = 1;j<=100;j++){
            for(int k = 1;k<=100;k++){
                int t = (i*i+j*j+k*k+i*j+j*k+k*i);
                if(t<=10000) ans[t]++;
            }
        }
    }
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++) cout << ans[i] << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,sum,ans;
    cin>>n;
    long long a[n];
    f(i,0,n){
        cin>>a[i];
    }
    f(i,1,101){
        sum=0;
        f(j,0,n){
            sum+=(a[j]-i)*(a[j]-i);
        }
        if(i==1){
            ans=sum;
        }
        else{
            if(ans>sum){
                ans=sum;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def f(x):
    if x > 0:
        return x * (x-1) // 2
    else:
        return 0

def solve(n, m):
    return f(n) + f(m)

assert solve(2, 1) == 1
assert solve(4, 3) == 9
assert solve(1, 1) == 0

n, m = map(int, input().split())
print(solve(n, m))

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var a, b, c, d, e int

	fmt.Scan(&a, &b, &c, &d, &e)

	al := []int{a, b, c, d, e}

	for n, i := range al {
		if i == 0 {
			fmt.Println(n + 1)
			break
		}
	}
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
int n,m;

void dfs(vector<vector<int>>&graph, vector<int>&longst_path,vector<bool>&visited,
    int i){
    visited[i]=1;
    int deg=graph[i].size(),k;
    //cout<<i<<": "<<deg<<endl;
    for(int j=1;j<deg;j++){
        k=graph[i][j];
        if(!visited[k])dfs(graph,longst_path,visited,k);
        longst_path[i]=max(longst_path[i],1+longst_path[k]);
    }
    return;
}
int main(){
    int x,y;
    scanf("%d %d",&n,&m);
    vector<vector<int>>graph(n+1,vector<int>(1,0));
    for(int i=0;i<m;i++){
        scanf("%d %d",&x,&y);
        graph[x].push_back(y);
    }
    vector<int>longst_path(n+1,0);
    vector<bool>visited(n+1,0);
    for(int i=1;i<=n;i++){
        if(!visited[i])dfs(graph,longst_path,visited,i);
    }
    cout<<*max_element(longst_path.begin(),longst_path.end());
    return 0;
}

Measured memory_bytes: 13044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


struct UnionFind{
    vector<int> par;
 
    UnionFind(int n) : par(n, -1){ }
    void init(int n){ par.assign(n, -1); }
 
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
 
    bool issame(int x, int y){
        return root(x) == root(y);
    }
 
    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
 
    int size(int x){
        return -par[root(x)];
    }
};


int main(){
    ll n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }
    ll ans = -1;
    rep(i, n){
        chmax(ans, (ll)uf.size(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4024
<?php
fscanf(STDIN, "%d %d %d", $N, $A, $B);

$numOfBlue = 0;

if ($A !== 0) {
  
  $I = (int) floor($N / ($A + $B)) ;
  $J = $N % ( $A + $B );
  
  if ($J > $A) {
    
    $K = $A;
  
  } else {
    
    $K = $J;
  }
  
  $numOfBlue = $I * $A + $K;
}

echo  $numOfBlue;

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

ll a, b, c, d, n;

void prework(){

}

void read(){

}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> a >> b >> c >> d;
	b = min(2 * a, b);
	c = min(2 * b, c);
	d = min(2 * c, d);
	cin >> n;
	if (n & 1){
		cout << d * (n / 2) + c << endl;
	}
	else
		cout << d * (n / 2) << endl;
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<48


def solve(N: int, K: int, a: "List[int]"):

    v = [0] * (N+1)
    for i in range(N):
        v[i+1] = v[i]+a[i]
    w = [0] * (N+1)
    for i in range(N):
        w[i+1] = w[i] + max(0, a[i])

    ans = -INF
    for i in range(0, N-K+1):
        tmp = w[N]
        tmp += max(v[i+K]-v[i], 0)
        tmp -= w[i+K]-w[i]
        
        ans = max(ans, tmp)

    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25476
import math
while 1:
    N = int(input())
    if N == 0:
        break
 
    PS = []
    for i in range(N):
        x, y = map(float, input().split(','))
        PS.append((int(x * 100000), int(y * 100000)))
 
    D2 = 100000**2
    ans = 0
    for i in range(101):
        py = i * 10000
        for j in range(101):
            px = j * 10000
            cnt = 0
            for x, y in PS:
                if (px - x) ** 2 + (py - y) ** 2 <= D2:
                    cnt += 1
            ans = max(ans, cnt)
    print(ans)


Measured memory_bytes: 5672
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int A,B;
    cin >> A >> B;
    REP(i, 2000){
        int a = (i*0.08);
        int b = (i*0.1);
        if(a==A && b == B){
            pr(i);
            return 0;
        }
    }
    pr(-1);
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> array(N);

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

    sort(array.begin(), array.end());
    long long b = array.at(N/2), sum=0;

    for(int i=0;i<N;i++){
        sum += abs(array.at(i) - b);
    }

    cout << sum << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int sx = 0, sy = 0, st = 0;
    bool sol = true;
    for(int i=0;i<n;i++){
        int t,x,y;
        cin>>t>>x>>y;
        int dis = abs(x-sx)+abs(y-sy);
        if(dis%2==0 && (t-st)%2!=0){
            sol = false;
        }else if(dis%2!=0 && (t-st)%2==0){
            sol = false;
        }else if(dis > t-st){
            sol = false;
        }
        sx = x;
        sy = y;
        st = t;
    }
    if(sol){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 
template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}
 
const int N = 2000005;
 
int main(){
  FASTER;
  int n;
  ll k;
  cin >> n >> k;
  vector<ll>ar(N + 2, 0);
  int mx = -1;
  for (int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;  
    ar[a] += b;
  }
  ll sum = 0;
  for (int i = 0; i < N; i++){
    sum += ar[i];
    if (sum >= k){
      cout << i << '\n';
      return 0;
    }
  }
  cout << mx << "\n"; 
  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=400;
ll h,w,s1,s2;
string s[maxn];
bool vis[maxn][maxn];

void dfs(ll i,ll j,char c){
    //cout<<i<<" "<<j<<endl;
    if(vis[i][j]) return;
    if(i==h||j==w||i<0||j<0) return ; 
    if(c=='#'){
        if(s[i][j]=='#') return ;
    }
    if(c=='.'){
        if(s[i][j]=='.') return ;
    }
    vis[i][j]=true;
    if(s[i][j]=='#') s1++;
    else s2++;
    dfs(i+1,j,s[i][j]);
    dfs(i,j+1,s[i][j]);
    dfs(i-1,j,s[i][j]);
    dfs(i,j-1,s[i][j]);

}

int main(){

cin>>h>>w;
memset(vis,false,sizeof(vis));
ll ans=0;
for(ll i=0;i<h;i++) cin>>s[i];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){

            if(!vis[i][j]){
            //    cout<<i<<" "<<j<<endl;
                s1=0;s2=0;
                if(s[i][j]=='#')
                dfs(i,j,'.');
                else
                dfs(i,j,'#');
               // cout<<s1<<" "<<s2<<endl;
                ans+=s1*s2;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>

int main() {
    int a, b, N, M, K;
    scanf("%d %d %d", &N, &M, &K);
    for (a=0; a<=M; ++a) {
        for (b = 0; b <= N; ++b) {
            if (a * N + b * M - 2 * a * b == K) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    auto X = aryread();
    foreach (i; 0 .. 5)
        if (X[i] != i + 1)
        {
            writeln(i + 1);
        }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = a[i] - i;
    }
    sort(begin(b) + 1, end(b));
    int mid = (n % 2 ? b[(n+1)/2] : (b[n/2] + b[n/2+1]) / 2);
    for(int i = 1; i <= n; i++){
        b[i] = abs(b[i] - mid);
    }
    cout << accumulate(begin(b) + 1, end(b), 0LL) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

static const ll MOD = 1000000007;
ll fact[1005];
ll dp[1005][1005];
int N, A, B, C, D;

ll f(int i, int j, int x) {
  if (x == 0) return 1;
  if (N - j + i * x < i * x) return 0;
  ll ret1 = fact[N - j + i * x];
  ll ret2 = fact[N - j];
  ret2 %= MOD;
  ret2 *= mod_pow(fact[i], x, MOD);
  ret2 %= MOD;
  ret2 *= fact[x];
  ret2 %= MOD;
  return ret1 * mod_inverse(ret2, MOD) % MOD;
}

int main() {
  ll p = 1;
  fact[0] = 1;
  REP(i, 1, 1005) {
    p *= i;
    p %= MOD;
    fact[i] = p;
  }

  cin >> N >> A >> B >> C >> D;

  dp[0][0] = 1;
  REP(i, 1, N + 1) {
    rep(j, N + 1) {
      dp[i][j] = dp[i - 1][j];
      if (A <= i && i <= B) {
        REP(x, C, D + 1) {
          if (j - i * x < 0) break;
          dp[i][j] += f(i, j, x) * dp[i - 1][j - i * x] % MOD;
          dp[i][j] %= MOD;
        }
      }
    }
  }

  cout << dp[N][N] << endl;

  return 0;
}


Measured memory_bytes: 8064