akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();

        int[] f = new int[10001];
        for (int x = 1; x < 100; x++) for (int y = 1; y < 100; y++) for (int z = 1; z < 100; z++) {
            int n = x * x + y * y + z * z + x * y + y * z + z * x;
            if (n <= 10000)
                f[n]++;
        }

        for (int n = 1; n <= N; n++)
            out.println(f[n]);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 34828
n = int(input())
cards = {}
for i in range(n):
  card = input()
  cards[card] = 1
 
for c in ['S', 'H', 'C', 'D']:
  for n in range(1,14):
    key = c + ' ' + str(n)
    if not key in cards:
      print(key)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
    long double w,h,x,y;
    cin >> w >> h >> x >> y;
    if(x==w/2.0 && y==h/2.0){
        long double ans = w*h/2.0;
        cout << fixed << setprecision(16);
        cout << ans << " " << 1 << endl;
    }
    else{
        long double ans = w*h/2.0;
        cout << fixed << setprecision(16);
        cout << ans << " " << 0 << endl;        
    }
}

Measured memory_bytes: 256
D, N = map(int, input().split())
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(101 * 100)
    else:
        print(N * 100)
else:
    if N == 100:
        print(101 * 100 * 100)
    else:
        print(N * 100 * 100)


Measured memory_bytes: 2940
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<list>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
//typedef pair<int, int>P;
const int MAX = 200020;


int N;
multiset<int>S;
int P[100010];
vector<pair<int, int>>V;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	S.insert(0); S.insert(0);
	S.insert(N+1); S.insert(N+1);
	REP(i, N) {
		cin >> P[i + 1];
		V.push_back({ P[i + 1], i + 1 });
	}
	VSORT(V);
	VREVERSE(V);
	ll ret = 0;
	for (auto v : V) {
		ll num = v.first;
		int id = v.second;
		auto it = S.lower_bound(id);
		int R1 = *it;
		it++;
		int R2 = *it;
		it--; it--;
		int L1 = *it;
		it--;
		int L2 = *it;
		if (R2 > R1) {
			ret += num * (R2 - R1)*(id - L1);
		}
		if (L2 < L1) {
			ret += num * (L1 - L2)*(R1 - id);
		}
		S.insert(id);
	}
	print(ret);
}

Measured memory_bytes: 6132
N = int(input())
S = [input() for _ in range(N)]
a2n = lambda c: ord(c) - ord('a')
n2a = lambda c: chr(c+97)

inf = 2 ** 30 - 1
idxs = [[0]*26 for _ in range(N)]
idx = [inf] * 26

for i in range(N):
    for s in S[i]:
        idxs[i][a2n(s)] += 1

for i in range(26):
    for j in range(N):
        idx[i] = min(idx[i],idxs[j][i])
        
ans = ''
for i in range(26):
    for j in range(idx[i]):
        ans += n2a(i)
print(ans)
        




Measured memory_bytes: 3064
let mul a b =
  let na0 = Array.length a in
  let nb0 = Array.length b in
  let nb1 = Array.length b.(0) in
  let c = Array.make_matrix na0 nb1 0 in
  for i = 0 to na0 - 1 do
    for k = 0 to nb0 - 1 do
      for j = 0 to nb1 - 1 do
        c.(i).(j) <- c.(i).(j) + a.(i).(k) * b.(k).(j)
      done
    done
  done;
  c

let fib n =
  let a = Array.make_matrix 2 2 0 in
  a.(0).(0) <- 1; a.(0).(1) <- 1;
  a.(1).(0) <- 1; a.(1).(1) <- 0;
  let b = Array.make_matrix 2 2 0 in
  b.(0).(0) <- 1; b.(0).(1) <- 0;
  b.(1).(0) <- 0; b.(1).(1) <- 1;
  let rec doit n a b =
    if n = 0 then b
    else doit (n / 2) (mul a a) (if n mod 2 = 0 then b else mul b a) in
  let c = doit (n + 1) a b in
  c.(1).(0)

let () = read_int () |> fib |> Printf.printf "%d\n"

Measured memory_bytes: 2324
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int A;
        A = input.nextInt();
        int B = input.nextInt();
        if (A==1 && B==2)
        System.out.print(3);
        else  if (A==2 && B==3) {
            System.out.println(1);
        } else  if (A==3 && B==2) {
            System.out.println(1);
        } else  if (A==2 && B==1) {
            System.out.println(3);
        } else  if (A==1 && B==3) {
            System.out.println(2);
        } else  if (A==3 && B==1)
            System.out.println(2);
    }
}


Measured memory_bytes: 35688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

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

  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      ac++;
    } else if (s == "WA") {
      wa++;
    } else if (s == "TLE") {
      tle++;
    } else {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 3188
// AtCoder Beginners Selection
// ABC168B - Triple Dots 

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
using namespace std::chrono;


int main()
{
	string S;
	size_t slength;
	int K;

    cin >> K;
    cin >> S;

	slength = S.length();
	int snorm = (int)slength;
	// 制約確認
	if (K < 1 || 100 < K)  {
        cout << "Kは条件を満たしていません!\n";
        return 0;
    }

	if (snorm < 1 || 100 < snorm)  {
        cout << "Sは条件を満たしていません!\n";
        return 0;
    }

	if (snorm <= K) {
		cout << S << endl;
	} else {
		cout << S.substr(0,K) << "..." << endl;
	}
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	long long n, m;
	long long k, s, t;

	s = 100;

	scanf("%lld", &n);
	for (long long i = 1; i*i <= n; i++){
		if (n%i == 0){
			m = n / i;
			k = 0;
			for (; m != 0;){
				if (m != 0){
					k++;
					m = m / 10;
				}
			}
			if (k < s)s = k;
		}
	}
	printf("%lld\n", s);


	return 0;
}

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

const int ROW = 10000 + 10;
const int COL = 10 + 5;

int n;

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



Measured memory_bytes: 256
from itertools import count
 
H, N = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(N)]
 
dp = [10 ** 9 for _ in range(H + 1)]
dp[0] = 0
for hp in range(1, H + 1):
    # print(dp)
    for A, B in ABs:
        if A <= hp:
            dp[hp] = min(dp[hp], dp[hp - A] + B)
        else:
            dp[hp] = min(dp[hp], B)
print(dp[-1])

Measured memory_bytes: 41200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> c[i][j];
    }
  }

  rep(i, h) {
    rep(k, 2) {
      rep(j, w) {
        cout << c[i][j];
      }
      cout << endl;
    }
  }


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m;
  cin >> n >> m;
  if(m < n) cout << "No" << endl;
  else cout << "Yes" << endl;
  }



Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    int r = sc.nextInt();
    int ans = r;

    if(n < 10){
      ans = r + 100 * (10 - n);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22740
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  string S, T, ans = "No";
  cin >> S >> T;

  for (size_t i = 0; i < S.size(); i++) {
    if (S == T) {
      ans = "Yes";
      break;
    }
    S = S.back() + S.substr(0, S.size() - 1);
  }

  cout << ans << endl;

  return 0;
}


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

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

  std::vector<int> l(n);
  for (auto&& li : l) std::cin >> li;
  std::sort(l.begin(), l.end());

  int count = 0;
  for (int i = 0; i < n; ++i) {
    const auto a = l[i];
    for (int j = i + 1; j < n; ++j) {
      const auto b = l[j];
      const auto start = l.begin() + j + 1;
      const auto it = std::lower_bound(start, l.end(), a + b);
      count += std::distance(start, it);
    }
  }

  std::cout << count << std::endl;
}

Measured memory_bytes: 256
#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;

string S;
bool dfs(string s){
    int n = s.length();
    int N = S.length();
    
    if(n > N) return false;

    if(S.substr(0, n) != s){
        return false;
    }

    if(S == s) return true;

}

int main(void)
{
    cin >> S;
    int N = S.length();
    vector<string> s = {"dreamer", "dream", "erase", "eraser"};

    queue<string> q;
    q.push("");
    while(!q.empty()){
        auto f = q.front();q.pop();
        int n = f.length();
        
        if(n > N) continue;
        if(S.substr(0, n) != f) continue;

        if(n == N) if(S == f){
            pr("YES");
            return 0;
        }

        for (int i = 0; i < 4; i++)
        {
            q.push(f + s[i]);
        }
    }

    pr("NO");
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int h, n, a, power = 0;
	cin >> h >> n;

	for(int i = 0; i < n; ++i)
	{
		cin >> a;
		power += a;
	}
	cout << (h <= power ? "Yes" : "No");
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # 
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

H, W, A, B = rl()
answer = ['0'*(W-A) + '1'*A for _ in range(H-B)]
answer += ['1'*(W-A) + '0'*A for _ in range(B)]
for x in answer:
    print(*x, sep='')


Measured memory_bytes: 6516
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pri = lambda x: print(*x, sep='\n')

X = int(input())

res = 1
for i in range(2, X):
    if X < i:
        break
    for j in range(2, 10):
        val = pow(i, j)
        if X < val:
            break
        if res < val:
            res = val
print(res)

Measured memory_bytes: 38256
s = input()
ans = "Yes"

if "N" in s:
    if "S" not in s: ans = "No" 
if "S" in s:
    if "N" not in s: ans = "No"
if "W" in s:
    if "E" not in s: ans = "No"
if "E" in s:
    if "W" not in s: ans = "No"

print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int R;
  cin >> R;
  printf("%6f\n", double(2 * R) * M_PI);
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll mn = min({A, B, C, D, E});
    cout << (N + mn - 1)/mn + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define N 1000000000
//ll primes[N];

//int seive()
//{
//	ll i,j,t=0,sq;
//	bool flag[N];
//	for(i=2;i<=N;i++) flag[i]=1;
//	sq=sqrt(N)+1;
//	for(i=2;i<sq;i++)
//		if(flag[i])
//			for(j=i;j*i<=N;j++)
//				flag[i*j]=0;
//	for(i=2;i<=N;i++)
//		if(flag[i])
//			primes[t++]=i;
//	return t;
//}

//     for(i=0;i<n;i++)
//     for(j=0;j<n;j++)

//int GCD(ll a, ll b)
//{
//    if(a==0)return b;
//    if(b==0)return a;
//    else return GCD(b,a%b);
//}




int main()
{
    ll i,j,k,m,n,q,t,a,b,c=0,r,x;
    cin>>a>>b;
    for(i=1;i<N;i++)
    {
        if(abs(a-i)==abs(b-i))
            {
                cout<<i<<endl;
                c++;
                break;
            }
    }
    if(c==0)
    cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;


int ss[ms]={0};


int main()
{
    idfc;

    int n;
    cin>>n;
    int i;

    string s;
    cin>>s;

    for(i=1;i<=n;i++)
    {
        ss[i]=ss[i-1];
        if(s[i-1]=='.')ss[i]++;
    }

    int ans=n;
    int a,b;
    for(i=0;i<=n;i++)
    {
        a=i-ss[i];
        b=ss[n]-ss[i];
        ans=min(ans,a+b);
    }
    cout<<ans;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;
typedef priority_queue<int> pr;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 1000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define yess cout<<"Yes\n"
#define noo cout<<"No\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define repi(i,n) fori(i,1,n-1)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
void solve()
{
    string s,t;
    int i;
    cin>>s>>t;
    int n=s.length();
    int ans=0;
    rep(i,n)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans;
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 3776
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(string, s);

  i64 red = 0, blue = 0;
  for (auto e : s) {
    if (e == '0') ++red;
    else ++blue;
  }

  i64 res = 2 * min<i64>(red, blue);
  outl(res);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll sum[n+1] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        sum[i+1] = sum[i]+a[i];
    }
    sort(sum,sum+n+1);

    ll ans = 0;
    ll count = 1;
    srep(i,1,n+1){
        if(sum[i]==sum[i-1]){
            count++;
        }else{
            ans += (count*(count-1))/2;
            count = 1;
        }
    }
    ans += (count*(count-1))/2;
    
    cout << ans << endl;
    return 0;
}
 
 


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> ans(100, 0);
    int tmp;
    rep(i, 1, n + 1){
        cin >> tmp;
        rep(j, 1, 101){
            ans[j] += (tmp - j) * (tmp - j); 
        }
    }
    int res = ans[1];
    rep(i, 1, 101){
        res = min(res, ans[i]);
    }
    cout << res << endl;
}

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

int main()
{
    int n;
    ll ans=0;
    cin>>n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
        ans+=mp[s]-1;
    }
    cout<<ans;
}

Measured memory_bytes: 11408
N = int(input())
A = list()
for n in range(N):
	A.append(list(map(int, input().split())))
dp = [[-1 for i in range(3)] for j in range(N)]
dp[0] = [A[0][0], A[0][1], A[0][2]]
for i in range(1, N):
	dp[i][0] = max(dp[i-1][1] + A[i][0], dp[i-1][2] + A[i][0])
	dp[i][1] = max(dp[i-1][0] + A[i][1], dp[i-1][2] + A[i][1])
	dp[i][2] = max(dp[i-1][0] + A[i][2], dp[i-1][1] + A[i][2])
# print(dp)
print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))


Measured memory_bytes: 76760
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
bitset<100005> vis;
vector<int> ans;
void dfs(int v1) 
{
	vis[v1]=true;
	ans.push_back(v1);
	for (int i=0; i<adj[v1].size(); i++)
	 {
		if (!vis[adj[v1][i]]) 
		{
			dfs(adj[v1][i]);
			break;
		}
	}
}
int main() {
//	freopen("input.txt","r",stdin);
	int n,m;
	scanf("%d%d", &n, &m);
	for (int i=0; i<m; i++) 
	{
		int a,b;
		scanf("%d%d", &a, &b);
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(0);
	reverse(ans.begin(),ans.end());
	for (int i=0; i<adj[0].size(); i++) 
	{
		if (!vis[adj[0][i]])
		 {
			dfs(adj[0][i]);
			break;
		}
	}
	printf("%d\n", ans.size());
	for (int i=0; i<ans.size(); i++) 
		printf("%d%c", ans[i]+1, i==ans.size()-1 ? '\n' : ' ');
}

Measured memory_bytes: 9720
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;
const int ALP = 26;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

template<typename T>
void dump_line(T *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

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

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;
}

ll sum(int n){
	return 1LL*n*(n+1)/2;
}

const int M=1e5;
ll s[M+2],t[M+2],x[M];

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

	int a,b,q;
	cin >> a >> b >> q;
	rep(i,a) cin >> s[i+1];
	rep(i,b) cin >> t[i+1];
	rep(i,q) cin >> x[i];

	s[0]=t[0]=-LINF;
	s[a+1]=t[b+1]=LINF;

	ll *sl,*sr,*tl,*tr;

	ll ans;
	rep(i,q){
		sl=lower_bound(s,s+a+2,x[i]);
		if(*sl > x[i]) sl--;
		
		sr=upper_bound(s,s+a+2,x[i]);
		
		tl=lower_bound(t,t+b+2,x[i]);
		if(*tl > x[i]) tl--;

		tr=upper_bound(t,t+b+2,x[i]);

		ans = min(max((*sr),(*tr))-x[i],x[i]-min((*sl),(*tl)));
		ans = min(ans,min(x[i]-(*sl),(*tr)-x[i])+(*tr)-(*sl));
		ans = min(ans,min(x[i]-(*tl),(*sr)-x[i])+(*sr)-(*tl));
		cout << ans << "\n";
	}

	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	VL k(4,0);
	for (int i = 0; i < 6; i++) {
		int a;
		cin >> a;
		k[a-1]++;
	}
	for (int i = 0; i < 4; i++) {
		if (k[i] == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


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

#define ll long long
#define inf 1e18
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << #y << "=" << y << endl
#define sp(x, y) fixed << setprecision(y) << x;
#define em emplace_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define nl '\n'

typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

const int maxn = 1e6;
const int mod = 1e9 + 7;

void solve()
{
    ll n, i, j;
    string s1, s2;
    cin >> s1 >> s2;
    n = s1.length();
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s1[i] != s2[i])
            ans++;
    }
    cout << ans << nl;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll test = 1;
    //cin >> test;
    while (test--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 0; j < a[i]; j++){
            int tmp_x, tmp_y;
            cin >> tmp_x >> tmp_y;
            x[i].push_back(tmp_x-1);
            y[i].push_back(tmp_y);
        }
    }
    int ans = 0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit){
        bool ok = true;
        int cnt = 0;
        /* bit で表される集合の処理を書く */
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                cnt++;
                // bitが立っているとき、正直者と仮定
                for(int j = 0; j < a[i]; j++){
                    if((y[i][j] == 0 && bit & (1<<x[i][j])) || (y[i][j] == 1 && !(bit & (1<<x[i][j])))){
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok == true){
            ans = max(ans, cnt);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	unsigned long long answer = 0;
	unsigned int n;
	int a[100000];
	unsigned int min;
	unsigned int minIdx;

	cin >> n;

	cin >> a[0];
	min = abs(a[0]);
	minIdx = 0;

	for (int i = 1; i < n; i++) {
		cin >> a[i];
		if (abs(a[i]) < min) {
			min = abs(a[i]);
			minIdx = i;
		}
	}
  
	for (int i = 0; i < minIdx; i++) {
		if (a[i] < 0) {
			a[i] *= -1;
			a[i+1] *= -1;
		}
	}
  
	for (int i = n-1; i > minIdx; i--) {
		if (a[i] < 0) {
			a[i] *= -1;
			a[i-1] *= -1;
		}
	}

	for (int i = 0; i < n; i++) {
		answer += a[i];
	}

	cout << answer;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
		cout<<"Possible\n";
	else
		cout<<"Impossible\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);
    int N,R;
    cin>>N>>R;
    if(N>=10){
        cout<<R<<endl;
    }else{
        cout<<R+100*(10-N)<<endl;
    }
}

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

vector<int> g[101010];
int dista[101010], distb[101010];

void dfs(int u, int p, int dist, bool a) {
    for (int v : g[u]) {
        if (v == p) continue;
        dfs(v, u, dist + 1, a);
    }
    if (a) {
        dista[u] = dist;
    }
    else {
        distb[u] = dist;
    }
}

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    if (u == v) {
        cout << 0 << endl;
        return 0;
    }

    dfs(u, -1, 0, true);
    dfs(v, -1, 0, false);

    int ma = 0;
    rep(i, N) {
        if (dista[i] < distb[i]) {
            ma = max(ma, distb[i]);
        }
    }

    cout << ma-1 << endl;

}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n, a, b, x;
    x = 0;
    cin >> n;
    rep(i, n) {
        cin >> a >> b;
        x += b - a + 1;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def dfs(s, count):
    if len(s) == n:
        print(s)
        return

    for z in range(count + 1):
        dfs(s + a[z], count + 1 if z == count else count)


dfs("", 0)





Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
a=gets.to_i
n=gets.chomp.split("")
xs=[]
n.each_with_index do |nString,index|
  tempValue = -1
  tempValue = 1 if nString == "I"
  tempValue = xs[index-1] + tempValue if index != 0
  xs << tempValue
end
puts (xs << 0).max

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

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

const int N = 6; // ティツ可イテ」ツ?ョテヲツ閉ー
const int M = 5; // テゥツ崢サテヲツーツ療」ツつキテ」ツδァテ」ツδε」ツつッテ」ツ?ョテ・ツ崢榲ヲツ閉ー
int H, W, C;

bool next_pattern(VI &pattern) {
	pattern[M - 2]++;
	
	for (int i = M - 2; i >= 0; i--) {
		if (pattern[i] > N) {
			if (i == 0) {
				return false;
			}

			pattern[i] = 1;
			pattern[i - 1]++;
		}
	}

	return true;
}

void update(VVI &panel, int old_c, int new_c, VVI &done, int x, int y) {
	if (done[y][x]) {
		return;
	}

	done[y][x] = 1;

	for (int d = 0; d < 4; d++) {
		int nx = x + dx[d];
		int ny = y + dy[d];

		if (nx < 0 || ny < 0 || nx >= W || ny >= H) {
			continue;
		}

		if (panel[ny][nx] == old_c) {
			panel[ny][nx] = new_c;
			update(panel, old_c, new_c, done, nx, ny);
		}
	}
}

void count_panel(VVI &panel, VVI &done, int &count, int x, int y) {
	if (done[y][x]) {
		return;
	}

	done[y][x] = 1;
	count++;

	for (int d = 0; d < 4; d++) {
		int nx = x + dx[d];
		int ny = y + dy[d];

		if (nx < 0 || ny < 0 || nx >= W || ny >= H) {
			continue;
		}

		if (panel[ny][nx] == panel[y][x]) {
			count_panel(panel, done, count, nx, ny);
		}
	}
}

int simu(VVI panel, VI pattern) {
	for (auto &c : pattern) {
		VVI done(H, VI(W, 0));
		int old_c = panel[0][0];
		panel[0][0] = c;
		update(panel, old_c, c, done, 0, 0);
	}
	
	VVI done(H, VI(W, 0));
	int cnt = 0;
	count_panel(panel, done, cnt, 0, 0);

	return cnt;
}

int main(void) {
	
	while (cin >> H >> W >> C, H) {
		VVI panel(H, VI(W));

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> panel[i][j];
			}
		}

		VI pattern(M, 1);
		pattern[M - 1] = C;

		int ans = 0;
		while (next_pattern(pattern)) {
			int t = simu(panel, pattern);
			ans = max(ans, t);
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A1(N), A2(N);
  for (int i = 0; i < N; i++) cin >> A1[i]; 
  for (int i = 0; i < N; i++) cin >> A2[i];
  
  for (int i = 1; i < N; i++) A1[i] += A1[i-1];
  for (int i = 1; i < N; i++) A2[N-i-1] += A2[N-i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) ans = max(ans,A1[i] + A2[i]);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
 
#define MAXN 500
#define INF 0x3fffffff
 
int n,m;
int itor[MAXN+5],level[MAXN+5];
pair<int,int> a[MAXN],b[MAXN];
struct node
{
    int v,d,res;
    node(){}
    node(int a,int b,int c)
    {
        v=a,d=b,res=c;
    }
};
vector <node> E[MAXN+5];
 
void bfs(int s)
{
    memset(level,-1,sizeof level);
    level[s]=0;
    queue <int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front(); q.pop();
        for(int i=0;i<E[u].size();i++)
        {
            int v=E[u][i].v;
            int d=E[u][i].d;
            if(d>0&&level[v]<0)
            {
                level[v]=level[u]+1;
                q.push(v);
            }
        }
    }
}
 
int dfs(int u,int e,int f)
{
    if(u==e)
        return f;
    for(int &i=itor[u];i<E[u].size();i++)
    {
        node now=E[u][i];
        if(now.d>0&&level[u]<level[now.v])
        {
            int ex=dfs(now.v,e,min(f,now.d));
            if(ex>0)
            {
                E[u][i].d-=ex;
                E[now.v][now.res].d+=ex;
                return ex;
            }
        }
    }
    return 0;
}
 
int Dinic(int s,int t)
{
    int ans=0;
    while(1)
    {
        bfs(s);
        if(level[t]<0)
            break;
        memset(itor,0,sizeof itor);
        int f;
        while((f=dfs(s,t,INF))>0)
            ans+=f;
    }
    return ans;
}
 
void add_edge(int u,int v,int va)
{
    E[u].push_back(node(v,va,E[v].size()));
    E[v].push_back(node(u,0,E[u].size()-1));
}
 
int main()
{
    scanf("%d",&n);
    m=2*n+2;
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].first,&a[i].second);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&b[i].first,&b[i].second);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i].first<b[j].first&&a[i].second<b[j].second)
                add_edge(i,j+n,1);
    for(int i=1;i<=n;i++)
        add_edge(2*n+1,i,1),add_edge(i+n,2*n+2,1);
    printf("%d\n",Dinic(2*n+1,2*n+2));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd(i,gcd(j,k));
				}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (1e+9)+7;
vector<ll> prod(2000003);
vector<ll> inv(2000003);
ll inverse(ll a){
    ll x = 1, p = MOD - 2;
    while(p != 0){
        if(p%2 == 1){ 
            x = (x * a) % MOD;
            p -= 1;
        }
        a = (a * a) % MOD;
        p /= 2;
    }        
    return x;
}

ll calc(ll x, ll y){
    ll ret = (((prod[x + y] * inv[x]) % MOD) * inv[y]) % MOD;
    return (ret == 0? ret + MOD - 1:ret-1);
}

int main(){
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll pv = 1;
    for(int i=1;i<=2000002;i++){
        pv = (pv * i) % MOD;
        prod[i] = pv;
        inv[i] = inverse(pv);
    }
    ll ans = calc(r2+1, c2+1);
    ans = ans - calc(r2+1, c1);
    ans = (ans < 0? ans + MOD: ans);
    ans = ans - calc(r1, c2+1);
    ans = (ans < 0? ans + MOD: ans);
    ans = (ans + calc(r1, c1))%MOD;
    cout << ans << endl;

}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define neko 100010 
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
__gnu_pbds::gp_hash_table<int,int>ht;
int dps,now,a[neko],s[neko],n;//disperse
int main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",&a[i]),s[i]=a[i];
	std::sort(s+1,s+n+1);
	f(i,1,n)if(!ht[s[i]])ht[s[i]]=++dps;
	f(i,1,n)
	{
		a[i]=ht[a[i]];
		if((i&1)^(a[i]&1))++now;
	}return printf("%d\n",now/2),0;
}

Measured memory_bytes: 5748
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct edge
{
	int s, t, c, rev;
	edge(int s, int t, int c, int rev) :s(s), t(t), c(c), rev(rev) {}
	edge() { s = -1, t = -1, c = -1, rev = -1; }
};

vector<vector<edge>> G;
bool used[101];

int dfs(int v, int t, int f)
{
	if (v == t)
	{
		return f;
	}
	used[v] = true;
	rep(i, 0, SZ(G[v]))
	{
		edge& e = G[v][i];
		if (used[e.t] || e.c == 0)
		{
			continue;
		}
		int d = dfs(e.t, t, min(f, e.c));
		if (d > 0)
		{
			e.c -= d;
			G[e.t][e.rev].c += d;
			return d;
		}
	}
	return 0;
}

int max_flow(int s, int t)
{
	int ans = 0;
	while (true)
	{
		rep(i, 0, 101)used[i] = false;
		int tans = dfs(s, t, INF);
		if (tans == 0)
		{
			return ans;
		}
		ans += tans;
	}
}

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

	int V, E, s, t, c;
	cin >> V >> E;
	G.resize(V);
	rep(i, 0, E)
	{
		cin >> s >> t >> c;
		G[s].push_back(edge(s, t, c, SZ(G[t])));
		G[t].push_back(edge(t, s, 0, SZ(G[s]) - 1));
	}

	cout << max_flow(0, V - 1) << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

#define FOR(a, b, i) for(int i=a; i<b; i++)
#define RFOR(a, b, i) for(int i=a; i>=b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1e9+7
#define newline cout<<"\n"


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, k; 
    cin>>n>>k;

    vector<int> a(n);

    FOR(0, n, i) cin>>a[i];

    // dp[i] - TRUE if the first player wins if there are i stones
    vector<bool> dp(k+1);

    FOR(0, k+1, i)
    {
        FOR(0, n, j)
        {
            if(i-a[j]>=0 && !dp[i-a[j]])
            {
                dp[i] = true;
            }
        }
    }

    if(dp[k]) cout<<"First";
    else cout<<"Second";
    newline;

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  if(a == b) ans = 2 * a;
  else if(a > b) ans = 2 * a - 1;
  else ans = 2 * b - 1;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256