akhauriyash/Code-Regression huggingface dataset:
//io
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <sstream>

//data structure
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <complex>
#include <bitset>
#include <list>
#include <tuple>


//algorithm
#include <algorithm>
#include <cmath>

//compilation
#include <cassert>
#include <ctime>
//#include <bits/stdc++.h>

#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define FOR(a,b,c) for (ll (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (ll (a)=(b);(a)<=(c);++(a))
#define DFOR(a,b,c) for (ll (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (ll (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define rep(i,n) FOR(i,0,n)
#define repn(i,n) FORN(i,1,n)
#define drep(i,n) DFOR(i,n-1,0)
#define drepn(i,n) DFOR(i,n,1)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = Min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define Reset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(all(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define forever for(;;)
#define PINF 1000000000000
#define newline '\n'

#define test if(1)if(0)cerr
using namespace std;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

ll max(ll a, ll b)
{
    return a>b?a:b;
}
int main()
{
    ll n, a, b; cin >> n >> a >> b;
    if (a > b)
    {
        cout << 0 << newline;
        return 0;
    }
    cout << max((n-1)*b+a-(n-1)*a-b+1, 0) << newline;
}

Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
eg = [[] for _ in range(n + 1)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)

cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x


q = deque()
q.append(1)
seen = {1}
ans = [0] * (n + 1)
ans[1] = cnt[1]
while len(q) > 0:
    v = q.pop()
    for t in eg[v]:
        if t in seen:
            continue
        q.append(t)
        seen.add(t)
        ans[t] = ans[v] + cnt[t]

print(*ans[1:])


Measured memory_bytes: 156712
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	string n,s;
    cin>> n;
    int q=0;
    while (cin>> s){
        for (int i=0;i<s.size();i++){
            if (s[i]<97){
                s[i]=s[i]+32;
            }
        }
        if (s==n){
            q++;
        }
    }
    cout<< q<< "\n";
	return 0;
}



Measured memory_bytes: 3220
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

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 ll = long long;

int main()
{
	int a, b;
	string s;
	cin >> a >> b;
	cin >> s;
	
	if (s.size() == a + b + 1 && s[a] == '-')
	{
		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] == '-' && i != a)
			{
				cout << "No" << endl;
				return 0;
			}
		}

		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    int col[w] = {}, rev_col[w] = {};
    int one = 0;
    REP(i,w){
        if(one < a){
            col[i] = 1;
            one++;
        }else{
            rev_col[i] = 1;
        }
    }
    int cnt = 0;
    REP(i,h){
        if(cnt < b){
            REP(j,w){
                cout << rev_col[j];
            }
            cnt++;
        }else{
            REP(j,w){
                cout << col[j];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int R, C, N; 
vector<pair<int, long long>> E[200010]; 
long long A[200010];  
bool seen[200010];
bool ok = true; 
long long mnr, mnc; 
long long INF = 1145141919810364364; 
void dfs(int i, long long &mnr, long long &mnc){
	seen[i] = true; 
	for(auto v : E[i]){
		if(A[v.first] != INF && A[i] + A[v.first] != v.second){
			ok = false; return; 	
		}
		if(A[v.first] != INF) continue; 
		A[v.first] = v.second - A[i]; 
		if(v.first < R) mnr = min(mnr, A[v.first]); 
		else mnc = min(mnc, A[v.first]); 
		dfs(v.first, mnr, mnc); 
	}
}
int main(){
	cin >> R >> C >> N; 
	fill(A, A+R+C, INF);
	while(N--){
		int r, c; long long a; 
		cin >> r >> c >> a; 
		r--; c--; 
		E[r].push_back(make_pair(R+c, a)); 
		E[R+c].push_back(make_pair(r, a)); 
	}
	for(int i = 0; i < R+C; i++){
		if(seen[i]) continue; 
		if(i < R){
			mnr = 0; mnc = INF;  
		}else{
			mnc = 0; mnr = INF; 
		}
		A[i] = 0; 
		dfs(i, mnr, mnc); 
		if(mnr + mnc < 0) ok = false; 
	}
	cout << (ok ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 16640
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    struct Bri {
        int64_t a;
        int64_t b;
    };

    std::vector<Bri> B;

    std::vector<int64_t> from_1;
    std::vector<int64_t> from_N;

    for (decltype(M) i = 0; i < M; ++i) {
        int64_t a, b;
        std::cin >> a >> b;

        if (a == 1) {
            from_1.push_back(b);
        }
        if (b == N) {
            from_N.push_back(a);
        }
    }

    std::sort(std::begin(from_1), std::end(from_1));
    std::sort(std::begin(from_N), std::end(from_N));

    std::vector<int64_t> result;
    std::set_intersection(from_1.begin(), from_1.end(),
                          from_N.begin(), from_N.end(),
                          std::inserter(result, result.end()));

    if (result.empty()) {
        std::cout << "IMPOSSIBLE" << std::endl;
    }
    else {
        std::cout << "POSSIBLE" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1984
//
//  main.cpp
//  AOJ
//
//  Created by user on 2014/02/01.
//  Copyright (c) 2014年 user. All rights reserved.
//

#include <iostream>
#include <memory>
#include <sstream>
using namespace std;

struct Tree {
    shared_ptr<Tree> L, R;
};

shared_ptr<Tree> parseTree(string str){
    shared_ptr<Tree> res(new Tree());
    
    int stack = 0;
    int ptr = -1;
    
    for(int i=0;i<str.size();i++){
        if(str[i] == '('){
            ++stack;
        } else if(str[i] == ')'){
            --stack;
        } else if(str[i] == ','){
            if(stack == 1){
                ptr = i;
                break;
            }
        }
    }
    
    string Ls = str.substr(1, ptr - 1);
    string Rs = str.substr(ptr + 1, str.size() - ptr - 2);
    
    if(!Ls.empty()){
        res->L = parseTree(Ls);
    }
    
    if(!Rs.empty()){
        res->R = parseTree(Rs);
    }
    
    return res;
}

shared_ptr<Tree> TreeInsect(shared_ptr<Tree> A, shared_ptr<Tree> B){
    shared_ptr<Tree> res(new Tree());
    
    if(A->L && B->L){
        res->L = TreeInsect(A->L, B->L);
    }
    
    if(A->R && B->R){
        res->R = TreeInsect(A->R, B->R);
    }
    
    return res;
}

shared_ptr<Tree> TreeUnion(shared_ptr<Tree> A, shared_ptr<Tree> B){
    shared_ptr<Tree> res(new Tree());
    
    {
        // L
        if(A->L && !(B->L)){
            res->L = A->L;
        }
        if(B->L && !(A->L)){
            res->L = B->L;
        }
        if(A->L && B->L){
            res->L = TreeUnion(A->L, B->L);
        }
    }
    
    {
        if(A->R && !(B->R)){
            res->R = A->R;
        }
        if(B->R && !(A->R)){
            res->R = B->R;
        }
        if(A->R && B->R){
            res->R = TreeUnion(A->R, B->R);
        }
    }
    
    return res;
}

string showTree(shared_ptr<Tree> T){
    string res = "(";
    if(T->L)res += showTree(T->L);
    res += ",";
    if(T->R)res += showTree(T->R);
    res += ")";
    
    return res;
}

int main(int argc, const char * argv[])
{
    string line;
    while(getline(cin, line)){
        stringstream ss(line);
        string com, As, Bs;
        ss >> com >> As >> Bs;
        
        shared_ptr<Tree> A = parseTree(As);
        shared_ptr<Tree> B = parseTree(Bs);
        shared_ptr<Tree> C;
        
        if(com == "i"){
            C = TreeInsect(A, B);
        }
        if(com == "u"){
            C = TreeUnion(A, B);
        }
        
        cout << showTree(C) << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
  int N, Y, A, B, C, x, y, z, p, q, r, sum;
  cin >> N >> Y;
  A = 10000;
  B = 5000;
  C = 1000;
  for (x = 0; x <= N; x++){
    for (y = 0; y <= N - x; y++){
      z = N - x - y;
      sum = A*x + B*y + C*z;
      if (sum == Y){
        cout << x << " " << y << " " << z <<endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n;
	cin >> n;
 
	ll a[n];
	rep(i, n) cin >> a[i];
 
	ll dp[n+1][n+1];
	rep(i, n+1) rep(j, n+1) dp[i][j] = 0;
	// dp[i][j] :
	//  ai+1からajでゲームをするときのX-Yの最大値
	//  ただし、手番は「元のゲームを行ってその局面になった時の手番」とする
 
	for(int len = 1; len <= n; len++){
		for(int l = 0; l < n - len + 1; l++){
			int r = l + len;
			if((n - len) % 2 == 0){
				dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
			}else{
				dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1]);
			}
		}
	}
 
	cout << dp[0][n] << endl;
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
	char a, b;
	cin >> a >> b;
	if (a > b)
		cout << ">";
	else if (a == b)
		cout << "=";
	else
		cout << "<";
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]
ans = 10**18

for i in range(2**(H-1)):
    s = set()
    
    for j in range(H-1):
        if (i>>j)&1:
            s.add(j)
    
    cnt = [0]*(len(s)+1)
    ans_cand = len(s)
    
    for j in range(W):
        add = [0]*(len(s)+1)
        add_idx = 0
        
        for k in range(H):
            add[add_idx] += S[k][j]
        
            if k in s:
                add_idx += 1
        
        if max(add)>K:
            ans_cand = 10**18
            break
        
        for k in range(len(s)+1):
            if cnt[k]+add[k]>K:
                ans_cand += 1
                
                for l in range(len(s)+1):
                    cnt[l] = add[l]
                    
                break
        else:
            for k in range(len(s)+1):
                cnt[k] += add[k]
        
    ans = min(ans, ans_cand)
    
print(ans)

Measured memory_bytes: 47836
#include<iostream>
#include<cstdio>
using namespace std;
int c[21],v[21];
int main ()
{
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&v[i]);
	for(i=1;i<=n;++i) scanf("%d",&c[i]);
	int s=0;
	for(i=1;i<=n;++i)
	  if(v[i]-c[i]>0) s+=v[i]-c[i];
	printf("%d",s);
}

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            string[] days = {"MON", "TUE", "WED", "THU", "FRI","SAT","SUN" };
            var S = GetStr();
            var ans = 0;
            for(int i = 0; i < 7; i++)
            {
                if (days[i] == S)
                {
                    ans = 6 - i;
                    break;
                }
            }
            ans = ans == 0 ? 7 : ans;

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11092
import numpy as np
a,b,x = map(int,input().split())
V = a * a * b
dV = V - x
if x == V:
  print("0")
  
elif x >= V / 2:
  h = dV / V * b * 2
  theta = np.arctan(a / h) * 360 / (2 * np.pi)
  print(90-theta)
  
else:
  h = x / V * a * 2
  theta = np.arctan(h / b) * 360 / (2 * np.pi)
  print(90-theta)
  

Measured memory_bytes: 12464
n = int(input())
a = list(map(int, input().split()))
box = [0]*n
for i in range(1,n):
    if i ==1:
        box[i] = abs(a[1]-a[0])
    else:
         box[i] = min(abs(a[i]-a[i-1])+box[i-1],abs(a[i]-a[i-2])+box[i-2])
print(box[-1])

Measured memory_bytes: 13980
N = int(input())
a_s = list(map(int,input().split()))
cnt = [0] * (max(a_s)+1)
for a in a_s:
    cnt[a] += 1
answer = 1
for i,c in enumerate(cnt):
    if i < 1:
        answer = max(answer, cnt[i])
        continue
    if i < 2:
        answer = max(answer, sum(cnt[i-1:i+1]))
        continue
    answer = max(answer, sum(cnt[i-2:i+1]))
print(answer)

Measured memory_bytes: 83896
#include<iostream>
#include<algorithm>
using namespace std;
int H,W,K;
string s[10];
main()
{
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)cin>>s[i];
	int ans=1e9;
	for(int z=0;z<1<<H-1;z++)
	{
		int cnt[15]={};
		int now=__builtin_popcount(z);
		bool out=false;
		for(int j=0;j<W;j++)
		{
			int id=0;
			bool take=false;
			for(int k=0;k<H;k++)
			{
				cnt[id]+=s[k][j]=='1';
				if(cnt[id]>K)take=true;
				if(z>>k&1)id++;
			}
			if(take)
			{
				now++;
				for(int k=0;k<=id;k++)cnt[k]=0;
				id=0;
				for(int k=0;k<H;k++)
				{
					cnt[id]+=s[k][j]=='1';
					if(cnt[id]>K)out=true;
					if(z>>k&1)id++;
				}
			}
		}
		if(!out&&ans>now)
		{
			ans=now;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

using namespace std;

int ar[100005];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
  }
  sort(ar, ar + n);
  int ans = 0;
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (i && ar[i] != ar[i-1]) {
      if (j % 2) {
        ans++;
      }
      j = 0;
    }
    j++;
  }
  if (j % 2) ans++;
  printf("%d\n", ans);
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  bool a = true;
  
  for (int i = 1; i < 10; i++) {
  if(N%i==0&&1<=N/i&&N/i<=9){
      a=false;
        cout << "Yes" << endl;
    break;
  }
  }
  
  
  if(a){
  cout << "No" << endl;
  }  

}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
//queue?????\??£???????????????????????????pop?????????
queue<std::vector<int> > cubes;
vector<int> puzzle;
vector<int> tmppuzzle;
namespace my{
int top,left,right,up,down,back;
}

void clear(){
  for(int i=0;i<31;i++){
    tmppuzzle[i] = puzzle[i];
  }
}

int  BFS(){

  while(!cubes.empty()){
    cubes.pop();
  }

  bool flag = true;
  puzzle[30] = 0;
  cubes.push(puzzle);

  while(1){





    flag = true;
    puzzle = cubes.front();
    cubes.pop();
    if(puzzle[30] == 8){
      return 8;
    }
    my::top = puzzle[0];
    my::left = puzzle[15];
    my::right = puzzle[12];
    my::up = puzzle[18];
    my::down = puzzle[9];
    my::back = puzzle[21];


    if(flag){
      for(int i=1;i<9;i++)
        if(my::top != puzzle[i]){
          flag = false;
          break;
        }
    }

    if(flag){
      for(int i=16;i<18;i++){
        if(my::left != puzzle[i]){
          flag = false;
          break;
        }
      }
    }

    if(flag){
      for(int i=13;i<15;i++){
        if(my::right != puzzle[i]){
          flag = false;
          break;
        }
      }
    }

    if(flag){
      for(int i=19;i<21;i++){
        if(my::up != puzzle[i]){
          flag = false;
          break;
        }
      }
    }

    if(flag){
      for(int i=9;i<12;i++){
        if(my::down != puzzle[i]){
          flag = false;
          break;
        }
      }
    }

    if(flag){
      for(int i=22;i<30;i++){
        if(my::back != puzzle[i]){
          flag = false;
          break;
        }
      }
    }

    if(flag){
      return puzzle[30];
    }


    puzzle[30] += 1;
    clear();
    swap(tmppuzzle[17],tmppuzzle[12]);
    swap(tmppuzzle[7],tmppuzzle[22]);
    swap(tmppuzzle[6],tmppuzzle[21]);
    swap(tmppuzzle[8],tmppuzzle[23]);
    swap(tmppuzzle[9],tmppuzzle[11]);//??´??¢
    cubes.push(tmppuzzle);

    clear();
    swap(tmppuzzle[0],tmppuzzle[27]);
    swap(tmppuzzle[1],tmppuzzle[28]);
    swap(tmppuzzle[2],tmppuzzle[29]);
    swap(tmppuzzle[14],tmppuzzle[15]);
    swap(tmppuzzle[18],tmppuzzle[20]);//??´??¢
    cubes.push(tmppuzzle);

    clear();
    swap(tmppuzzle[0],tmppuzzle[23]);
    swap(tmppuzzle[3],tmppuzzle[26]);
    swap(tmppuzzle[6],tmppuzzle[29]);
    swap(tmppuzzle[9],tmppuzzle[20]);
    swap(tmppuzzle[15],tmppuzzle[17]);//??´??¢
    cubes.push(tmppuzzle);

    clear();
    swap(tmppuzzle[2],tmppuzzle[21]);
    swap(tmppuzzle[5],tmppuzzle[24]);
    swap(tmppuzzle[8],tmppuzzle[27]);
    swap(tmppuzzle[11],tmppuzzle[18]);
    swap(tmppuzzle[12],tmppuzzle[14]);//??´??¢
    cubes.push(tmppuzzle);
  }

  return -1;
}

int main(){

  int n;
  cin >> n;

  puzzle.resize(31);
  tmppuzzle.resize(31);

  for(int i=0;i<n;i++){
    for(int i=0;i<30;i++){
      cin >> puzzle[i];
    }
    cout << BFS() << endl;
  }

  return 0;
}

Measured memory_bytes: 13760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);


    int n;
    string s;
    cin >> n >> s;
    int ans = 0;

    rep(i,10) rep(j,10) rep(k,10)
    {
        vector<char> c;
        c.push_back('0'+i);
        c.push_back('0'+j);
        c.push_back('0'+k);
        auto itr = c.begin();
        
        rep(l,n)
        {
            if (*itr == s[l]) ++itr;

            if (itr==c.end())
            {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a, b, N, s[100]={}, f[100]={}, i, x=0;
    cin >> a >> b >> N;
    for(i=0; i<N; i++){
        cin >> s[i] >> f[i];
        if(b > s[i] && a < f[i]){
            x=1;
            break;
        }
    }
    if(x == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}



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

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {
    int A, B;
    cin >> A >> B;
    
    int g = gcd(A, B);
    
    cout << A*B/g << endl;
    
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)

d=[abs(A[i]-A[i+1]) for i in range(N+1)]
S=sum(d)

for i in range(1,N+1):
    if (A[i]-A[i-1])*(A[i+1]-A[i])<0:
        print(S-d[i-1]-d[i]+abs(A[i-1]-A[i+1]))
    else:
        print(S)

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

#define ABS(X) (((X) > 0)?(X):-(X))

using namespace std;

int main(void)
{
    unsigned int N, i, j, k, a;
    unsigned long long out = 0;
    string S;
    vector <int> R;
    vector <int> G;
    vector <int> B;
    cin >> N;
    cin >> S;
    for(i = 0; i < S.size();i++)
    {
        if(S[i] == 'R')
        {
            R.push_back(i+1);
        }
        else if(S[i] == 'G')
        {
            G.push_back(i+1);
        }
        else if(S[i] == 'B')
        {
            B.push_back(i+1);
        }
    }
    for(i = 0; i < R.size(); i++)
    {
        for(j = 0; j < G.size(); j++)
        {
            a = B.size();
            if(binary_search(B.begin(), B.end(), 2*R[i] - G[j]))
            {
                a--;
            }
            if((((R[i]+G[j])&1) == 0) && binary_search(B.begin(), B.end(), (int)((R[i] + G[j])/2)))
            {
                a--;
            }
            if(binary_search(B.begin(), B.end(), 2*G[j] - R[i]))
            {
                a--;
            } 
            out += a;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3664
N = int(input())
A = map(int, input().split())
dict_A = {}
j = 0
for i in A:
    dict_A[j] = i
    j += 1
#print(dict_A)
attend_order = [k + 1 for k, v in sorted(dict_A.items(), key=lambda x: x[1])]
print(*attend_order, sep=" ")

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <cstdio>

using namespace std;

class DKnapsack1 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    long N, W;
	    in >> N >> W;
	    long dp[N+1][W+1];
	    long maxV = 0;

	    for (int i=1; i < N+1; i++) {
	        int w, v;
	        in >> w >> v;
	        for (int j = 1; j < W+1; j++) {
                if (i == 1) {
                    if (w <= j) {
                        dp[i][j] = v;
                    } else {
                        dp[i][j] = 0;
                    }
                } else {
                    if (j-w <= 0) {
                        dp[i][j] = dp[i-1][j];
                    } else {
                        dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j]);
                    }
                }

                maxV = max(maxV, dp[i][j]);
	        }
	    }

	    out << maxV;
	}
};


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


Measured memory_bytes: 78976
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 2e9;
const int N = 1e5 + 15;
int n, m, deg[N], cnt[N], d[N];
set <int> g[N];
vector <int> g0[N];
bool used[N];

void dfs0(int v, int p = -1) {
    used[v] = true;
    for(int to : g0[v]) {
        if(!used[to]) {
            d[to] = d[v] + 1;
            dfs0(to, v);
        }
        else if(to != p) {
            if(d[v] < d[to])
                g[v].insert(to);
        }
    }
    if(p != -1) {
        if(g[v].size() & 1)
            g[v].insert(p);
        else
            g[p].insert(v);
    }
}

main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g0[u].pb(v);
        g0[v].pb(u);
    }
    if(m & 1) {
        puts("-1");
        return 0;
    }
    dfs0(1);
    for(int i = 1; i <= n; ++i)
        for(int to : g[i])
            printf("%d %d\n", i, to);
    return 0;
}

Measured memory_bytes: 23680
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 998244353
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll


signed main() {
	fast;

	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];

	for(int i=0;i<n-k;i++) {
		lld x = (1.0*v[i+k])/v[i];
		if(x>1) cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll h, w;
	cin >> h >> w;
	ll ans = 1e9;
	if (w*h % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1;i < h;i++) {
		ll s1 = i * w, s2 = w / 2 * (h - i), s3 = h * w - s1 - s2;
		ll a = max(s1, max(s2, s3));
		ll b = min(s1, min(s2, s3));
		ans = min(ans, a - b);
		//printf("h=%d %d %d %d\n",i,s1,s2,s3);
		ll t1 = i * w, t2 = (h - i) / 2 * w, t3 = h * w - t1 - t2;
		ll c = max(t1, max(t2, t3));
		ll d = min(t1, min(t2, t3));
		ans = min(ans, c - d);
		//printf("h=%d %d %d %d\n",i,s1,s2,s3);
	}
	for (int i = 1;i < w;i++) {
		ll s1 = i * h, s2 = h / 2 * (w - i), s3 = h * w - s1 - s2;
		ll a = max(s1, max(s2, s3));
		ll b = min(s1, min(s2, s3));
		if (a - b >= 0)ans = min(ans, a - b);
		//printf("w=%d %d %d %d\n",i,s1,s2,s3);
		ll t1 = i * h, t2 = (w - i) / 2 * h, t3 = h * w - t1 - t2;
		ll c = max(t1, max(t2, t3));
		ll d = min(t1, min(t2, t3));
		if (c - d >= 0)ans = min(ans, c - d);
		//printf("w=%d %d %d %d\n",i,s1,s2,s3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		ArrayList<ArrayList<Integer>> g0 = new ArrayList<ArrayList<Integer>>();
		ArrayList<ArrayList<Integer>> g1 = new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<k; i++) {
			g0.add(new ArrayList<Integer>());
			g1.add(new ArrayList<Integer>());
		}
		for(int i=1; i<k; i++) {
			g0.get(i).add((i*10)%k);
			g1.get(i).add((i+1)%k);
		}
		ArrayDeque<Integer>deq = new ArrayDeque<Integer>();
		int dist[] = new int[k];
		int INF = 1001001001;
		for(int i=0; i<k; i++) dist[i] = INF;
		dist[1]=1;
		deq.push(1);
		while(!deq.isEmpty()) {
			int u = deq.poll();
			for(int v : g0.get(u)) {
				if(dist[v]>dist[u]) {
					dist[v]=dist[u];
					deq.addFirst(v);
				}
			}
			for(int v : g1.get(u)) {
				if(dist[v]>dist[u]) {
					dist[v] = dist[u]+1;
					deq.addLast(v);
				}
			}
		}
		System.out.println(dist[0]);
		sc.close();
	}

}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int M = max(max(A, B), C);

  int X = 0;
  if (M % 2 == (A + B + C) % 2) {
    X = M;
  } else {
    X = M + 1;
  }

  cout << ((3 * X - (A + B + C)) / 2) << endl;
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, k, q, a[101010];
int cnt[101010];

int main(){
	cin >> n >> k >> q;
	for(int i = 0; i < q; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for(int i = 1; i <= n; i++){
		if(q-cnt[i] < k){
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	
	return 0;
}

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

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

    if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
        std::cout << "hon" << std::endl;
    } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        std::cout << "pon" << std::endl;
    } else {
        std::cout << "bon" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    
    int n,m,p,sum=0;
    int x[1000]={0},i;
    
    while (1) {
        
        scanf("%d %d %d",&n,&m,&p);
        if (n==0&&m==0&&p==0) {
            break;
        }
        for (i = 0; i < n; i++) {
            scanf("%d",&x[i]);
        }
        
        if (x[m-1] == 0) {
            printf("0\n");
            continue;
        } else {
            for (i = 0; i < n; i++) {
                sum += x[i];
            }
            sum = sum*(100-p);
            sum /= x[m-1];
        
            printf("%d\n",sum);
        }
        
        
        sum=0;
        
        
    }
    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstdio>

using namespace std;

static const char DOWN = '\\';
static const char EVEN = '_';
static const char UP = '/';

struct AREA {
  int index;
  int area;
};

int main() {
  stack<int> input;
  vector<AREA> answer;

  int total = 0;
  string data;
  cin >> data;
  AREA current = {};
  int lastIndex = 0;
  for (int i = 0; i < data.length(); i++) {
    switch (data[i]) {
    case DOWN:
      input.push(i);
      break;
    case EVEN:
      break;
    case UP:
      if (input.empty()) {
        continue;
      }
      lastIndex = input.top();
      input.pop();
      current.area = i - lastIndex;
      current.index = lastIndex;
      total += current.area;
      while (answer.size() > 0 && answer[answer.size() - 1].index > lastIndex) {
        current.area += answer[answer.size() - 1].area;
        answer.pop_back();
      }
      answer.push_back(current);
      break;
    default:
      break;
    }
  }

  cout << total << endl;  
  cout << answer.size();
  for (AREA ans : answer) {
      cout << " " << ans.area;
  }  
  cout << endl;

  return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
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;
}
ll pw[1010101],cac[4][1010101];
int n,m,sg[1010101],vis[1010101];
vector<int> e[1010101];
inline void solve(int id){
	for (int i=1;i<=n;i++) e[i].clear(),sg[i]=vis[i]=0;
	m=read();
	for (int i=1;i<=m;i++){
		int x=read(),y=read();
		e[min(x,y)].push_back(max(x,y));
	}
	for (int i=n;i;i--){
		for (auto v:e[i]) vis[sg[v]]=1;
		while (vis[sg[i]]) sg[i]++;
		for (auto v:e[i]) vis[sg[v]]=0;
		cac[id][sg[i]]=(cac[id][sg[i]]+pw[i])%ljc;
	}
}
signed main(){
	n=read();
	pw[0]=1,pw[1]=1000000000000000000%ljc;
	for (int i=2;i<=n;i++) pw[i]=pw[i-1]*pw[1]%ljc;
	solve(1);
	solve(2);
	solve(3);
	ll _=0;
	for (int i=0;i<=1000;i++)
		for (int j=0;j<=1000;j++) _=(_+cac[1][i]*cac[2][j]%ljc*cac[3][i^j]%ljc)%ljc;
	cout<<_;
	return 0;
}



Measured memory_bytes: 31428
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String tar[] = {"Female", "Male", "Vacant"};
		int l = 0, r = n - 1;
		int m = (r + l) / 2;
		System.out.println(0);
		String s = sc.next();
		if(s.equals(tar[1])) {
			String tmp = tar[0];
			tar[0] = tar[1];
			tar[1] = tmp;
		}
		if (!s.equals(tar[2])) {
			while (l + 1 < r) {
				m = (r + l) / 2;
				System.out.println(m);
				s = sc.next();
				if(s.equals(tar[2]))break;
				else if(s.equals(tar[m % 2]))l = m;
				else r = m;
			}
			System.out.println(r);
		}
		sc.close();
	}

}


Measured memory_bytes: 23232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

public class Main {
    // driver function to test the above functions
    public static void main(String args[]) throws IOException {
        Reader.init(System.in);

        int k = Reader.nextInt();
        int n = Reader.nextInt();
        ArrayList<Integer> lis = new ArrayList<Integer>();
        for (int i=0; i<n; i++){
            int val = Reader.nextInt();
            lis.add(val);
            if (val!=0){
                lis.add(val-k);
            }

        }

        Collections.sort(lis);
        int ans=0;
        int prev = lis.get(0);
        int curr = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for (int i=1; i<lis.size(); i++){
            curr = lis.get(i);
            arr.add(Math.abs(curr-prev));
            prev = curr;
        }
        int ans_min=Integer.MAX_VALUE;
        for (int i=0; i<arr.size(); i++){
            if (i<n-1){
                ans=ans+arr.get(i);
            }
            else {
                int temp_1 = ans - (arr.get(i-(n-1))) + arr.get(i);
                if (temp_1<ans_min){
                    ans_min=temp_1;
                }
                ans=temp_1;
            }
        }

        System.out.println(ans_min);


    }
}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static String line() throws IOException {
        return reader.readLine();
    }
}

Measured memory_bytes: 55084
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto N = to!ulong(tokens[0]);
	auto T = to!ulong(tokens[1]);

	ulong c_min;
	c_min = ulong.max;
	foreach (i; 0..N)
	{
		auto tokens1 = split(chomp(readln()));
		auto c = to!ulong(tokens1[0]);
		auto t = to!ulong(tokens1[1]);

		if (t <= T && c < c_min)
		{
			c_min = c;
		}
	}

	if (c_min == ulong.max) writeln("TLE");
	else writeln(c_min);
	stdout.flush();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int a,b,c,i,x;
    scanf("%d %d %d",&a,&b,&c);
    x = 0;
    
    for( i=a; i<=b; i++){
       if( c % i == 0 ){
         x++;
      }
    }
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstdio>
using namespace std;



int main() {
	long long n,a,b;
	cin >> n >> a >> b;
	long long  x[n-1];
	long long left,right;
	long long ans = 0;
	cin >> left;
	for(int i = 0; i < n-1; i++){
		cin >> right;
		x[i] = (right - left)*a;
		left = right;
	}


	for(int i = 0; i < n-1; i++){
		long long tmp = x[i] < b ? x[i] : b;
		ans += tmp;
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
const ll MOD = 1000000007;
int main(){
    int h,w;
    cin >> h >> w;
    int a[h][w],b[h][w];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> b[i][j];
        }
    }
    int c[h][w];
    rep(i,h){
        rep(j,w){
            c[i][j]=a[i][j]-b[i][j];
        }
    }
    //MAX=80*80*80*160=10^8
    bool num[h][w][13000];
    memset(num,0,sizeof(num));
    if(0<=c[0][0] && c[0][0]<100) num[0][0][c[0][0]]=1;
    if(0<=-c[0][0] && -c[0][0]<100) num[0][0][-c[0][0]]=1;
    queue<P>  q;
    q.push({0,0});
    int dy[2]={0,1};
    int dx[2]={1,0};
    bool visit[h][w];
    memset(visit,false,sizeof(visit));
    visit[0][0]=1;
    while(!q.empty()){
        P d=q.front(); q.pop();
        rep(i,2){
            int ny=d.fi+dy[i]; int nx=d.se+dx[i];
            if(0<=ny && ny<h && 0<=nx && nx<w){
                rep(j,13000){
                    if(num[d.fi][d.se][j] && abs(j+c[ny][nx])<13000){
                        num[ny][nx][abs(j+c[ny][nx])]=1;
                    }
                    if(num[d.fi][d.se][j] && abs(j-c[ny][nx])<13000){
                        num[ny][nx][abs(j-c[ny][nx])]=1;
                    }
                }
                if(!visit[ny][nx]){
                    q.push({ny,nx});
                    visit[ny][nx]=1;
                }
            }
        }
    }
    rep(i,13000){
        if(num[h-1][w-1][i]){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 81664
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}

//Union-find木
struct UnionFind {
    vl par, rank, size; // par[i]:iの親の番号, rank:iの階数, size:木の要素

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        par.clear();
        rank.clear();
        size.clear();
        rep(i,N) {
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }

    ll root(ll x) { //root(x) = {xの木の根}
        if (par[x] == x) return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if(rank[rx] < rank[ry]) swap(rx,ry);
        par[ry] = rx;
        if(rank[rx] == rank[ry]) rank[rx]++;
        size[rx] += size[ry];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

/*------------------------------------------------*/

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

    UnionFind tree(n);

    rep(i,m){
        ll a,b; cin >> a >> b;
        tree.unite(a - 1,b - 1);
    }

    ll ans = 0;
    rep(i,n){
        if(ans < tree.size[i]){
            ans = tree.size[i];
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  int64_t ans = 0LL;
  cin >> n;
  for(int a = 1; a < sqrt(n); a++) {
    for(int b = a; b < n; b++) {
      if(a == b) ans++;
      else if(n - (a * b) > 0) ans += 2;
    }
  }
  cout << ans;
}

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T, A;
  cin >> N >> T >> A;
  int H[N];
  for(int n=0; n<N; n++)cin >> H[n];
  T -= A;
  float dif;
  int result = 0;
  float min = 100000;
  for(int n=0; n<N; n++){
    dif = abs(T - 0.006 * H[n]);
    if(min > dif){
      min = dif;
      result = n + 1;
    }
  }
  cout << result << "\n";
  return 0;
}

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


int main()
{
    int n;
    cin >> n;
    vector<long long int> a;
    for (int i = 0; i < n; i++) {
        long long int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }


    vector<long long int> res = a;
    while(1) {
        sort(res.begin(), res.end());
        long long int min = res.front();
        vector<long long int> tmpRes;
        for (int i = 1; i < res.size(); i++) {
            long long int modNum;
            modNum = res[i] % min;
            if (modNum != 0) {
                tmpRes.push_back(modNum);
            }
        }
        if (tmpRes.size() == 0) {
            cout << min << endl;
            return 0;
        } else {
            tmpRes.push_back(min);
            res = tmpRes;
        }
    }
}

Measured memory_bytes: 3316