akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
  int n;
  cin >> n;
  
  ll l0 = 2, l1 = 1;
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  
  ll l = 0;
  for(int i = 2; i <= n; i++){
    l = l0 + l1;
    l0 = l1;
    l1 = l; 
  }
  
  cout << l << endl;
}


Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N, M;
	cin >> N >> M;

	vector <vector<pair<ll, ll>>> cd(N + 1);
	repn(i, M) {
		ll l, r, x;
		cin >> l >> r >> x;
		cd[r].push_back({ l, x });
	}

	vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(N + 1, vector<int>(N + 1, 0)));
	vector<vector<vector<int>>> rdp(N + 1, vector<vector<int>>(N + 1, vector<int>(N + 1, 0)));

	rep(i, N + 1)rep(j, N + 1)rep(k, N + 1) {
		if (k >= j && j >= i) {

			bool b = 1;
			for (auto p : cd[k]) {
				ll l = p.first;
				ll x = p.second;
				ll c = 1;
				if (i >= l) { c++; }
				if (j >= l) { c++; }
				if (c != x) {b = 0; }
			}

			if (b == 1) {
				if (k == 0) { dp[i][j][k] = 1; }
				else if (k - j == 1) { dp[i][j][k] = rdp[i][j][j]; }
				else if (k - j > 1) { dp[i][j][k] = dp[i][j][k - 1]; }
			}
		}

		else {
			ll v[3] = { i,j,k };
			sort(v, v + 3);
			dp[i][j][k] = dp[v[0]][v[1]][v[2]];
		}

		if (k == 0) { rdp[i][j][k] = dp[i][j][k]; }
		else { rdp[i][j][k] = rdp[i][j][k - 1] + dp[i][j][k]; }

		dp[i][j][k] %= MOD;
		rdp[i][j][k] %= MOD;

	}

	mint ans = 0;
	rep(i, N + 1)rep(j, N + 1) { ans += dp[i][j][N]; }
	ans *= 3;
	cout << ans << endl;



	system("PAUSE");
}


Measured memory_bytes: 222080
MAX = 151200

def lower(n, arr)
  l = -1; r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    arr[m] <= n ? l = m : r = m
  end
  arr[l]
end

cube = (0..53).map{ |i| i ** 3 }
tetra = (0..95).map{ |i| i * (i + 1) * (i + 2) / 6 }

a = []
cube.each do |c|
  tetra.each do |t|
    break if c + t > MAX
    a << c + t
  end
end
a.sort!.uniq!
while n = gets.to_i
  break if n == 0
  puts lower(n, a)
end

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

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

    vector<long long> A(N);
    vector<long long> B(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if (N % 2 == 0)
    {
        long long l2 = A[N / 2] + A[N / 2 - 1];
        long long r2 = B[N / 2] + B[N / 2 - 1];
        cout << r2 - l2 + 1 << endl;
    }
    else
    {
        long long l = A[N / 2];
        long long r = B[N / 2];
        cout << r - l + 1 << endl;
    }
}


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

double a, b, h, m;
double pi = atan(1) * 4;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> a >> b >> h >> m;
    h += m / 60;
    double angleH = 30 * h;
    double angleM = 360 * h;

    while (angleH > 360)
    {
        angleH -= 360;
    }
    while (angleM > 360)
    {
        angleM -= 360;
    }

    double angle = abs(angleH - angleM);

    cout.precision(17);
    cout << sqrt(a * a + b * b - 2 * a * b * cos(angle * pi / 180));
}

Measured memory_bytes: 4272
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <numeric>

int main(){
  int N;
  int K;
  std::vector<long long> h;
  std::cin >> N >> K;
  std::copy_n(std::istream_iterator<long long>(std::cin), N, std::back_inserter(h));

  std::sort(h.begin(), h.end());

  long long result = h[N-1] - h[0];
  for(int i = K - 1 ; i < N ; i++){
    long long gap = h[i] - h[i - K + 1];
    if(gap <= result){
      result = gap;
    }
  }
  std::cout << result << std::endl;
  return 0;
}


Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split(',');
          Console.WriteLine($"{s[0]} {s[1]} {s[2]}");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
a,b = map(int, input().split())

def xor_solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x+1
    else:
        return 0
        
print(xor_solve(b) ^ xor_solve(a-1))


Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	char exp[128];
	while(scanf("%s", exp) != EOF){
		int N = strlen(exp);
		char num[4][64];
		int len[4];
		
		{
			int index = 0;
			int count = 0;
			rep(j, N+1){
				if(j==N || !isalnum(exp[j])){
					strncpy(num[count], exp+index, j-index);
					num[count][j-index] = '\0';
					len[count] = strlen(num[count]);
					index = j+1;
					++count;
				}
			}
		}

		int ans = -1;
		rep(i, 10){
			bool ok = true;
			char a[4][64];
			rep(j, 3){
				strcpy(a[j], num[j]);
				rep(k, len[j]){
					if(a[j][k] == 'X'){
						if(k == 0 && i == 0 && len[j] > 1){
							ok = false;
							break;
						}
						a[j][k] = i + '0';
					}
				}
				if(!ok)
					break;
				reverse(a[j], a[j]+len[j]);
			}
			if(!ok)
				continue;

			int rise = 0;
			for(int j=0; j<max(len[0], len[1]) || rise; ++j){
				int next = (j<len[0] ? a[0][j]-'0' : 0) + (j<len[1] ? a[1][j]-'0' : 0) + rise;
				if(len[2]<=j || a[2][j]-'0' != next%10){
					ok = false;
					break;
				}
				rise = next / 10;
			}
			if(ok){
				ans = i;
				break;
			}
		}
		if(ans == -1)
			puts("NA");
		else
			printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
Volume0-0009
=end

require 'prime'
N=999999
#N=19
STDOUT.sync=true
f=Array.new(N,0)
f[2]=1
x = 1
3.step(N,2){|i|
  if Prime.prime?(i) then
    x = x + 1
  end
  f[i] = x
}
#puts f

#exit
while STDIN.gets do
  n = $_.to_i

  if n==2 then
    m = 1
  elsif n % 2 == 0 then
    m = f[n-1]
  else
    m = f[n]
  end
  puts m

end



Measured memory_bytes: 14840
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,Q;
  cin>>N>>Q;
  lint ans=(N-2)*(N-2);
  set<pair<int,int> > t,y; //key:-length, val:place 
  REP(q,Q){
    int f,x;
    cin>>f>>x;
    x--;
    int l;
    if(f==1){
      auto itr=y.lower_bound(make_pair(x,0));
      if(itr==y.end())l=N-2;
      else l=itr->second-1;
      t.insert(make_pair(l,x));
    }else{
      auto itr=t.lower_bound(make_pair(x,0));
      if(itr==t.end())l=N-2;
      else l=itr->second-1;
      y.insert(make_pair(l,x));      
    }
    // cerr<<"tate::";
    // for(auto e:t)cerr<<e.second<<":"<<e.first<<" ";
    // cerr<<endl<<"yoko::";
    // for(auto e:y)cerr<<e.second<<":"<<e.first<<" ";
    // cerr<<endl;
    // cerr<<" "<<l<<endl;
    ans-=l;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12928
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",(b-a)*(b-a-1)/2-a);
    return 0;
}


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

using namespace std;

int n,q;
int pos[1000000];
int tree[500010];
int ans[500010];

typedef struct Node{
    int s, e, val, pos;
    bool operator<(const Node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    Node(){};
    Node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}Node;


vector<Node> v;

void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main() {

    
    cin >> n >> q;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        v.push_back(Node(i, i, x, -1));
    }
    for(int i = 0; i < q; i++){
        int x,y;
        cin >> x >> y;
        v.push_back(Node(x, y, 0, i));
    }

    sort(v.begin(), v.end());

    for(int i = 0;i < (int)v.size(); i++){
        if(v[i].val == 0)
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        else {
            
            if(pos[v[i].val] != 0)
                update(pos[v[i].val], -1);

            update(v[i].s, 1);
            pos[v[i].val] = v[i].s;
        }
    }

    for(int i = 0; i < q; i++){
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 25352
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define erep(i, n) for(ll i = 1; i <= (n); i++)
#define trep(i, a, n) for(ll i = a; i <= (n); i++)
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main(void) {
  int n, m, a;
  cin >> n >> m;
  vector<bool> steps(n+10, true);
  rep(i, m){
    cin >> a;
    steps[a] = false;
  }
  vector<ll> dp(n+10,0);
  dp[0]=1;
  if(steps[1])dp[1]=1;
  trep(i, 2, n){
    if(steps[i-1]) dp[i] += dp[i - 1]; 
    if(steps[i-2]) dp[i] += dp[i - 2];
    dp[i] %= MOD;
  }
  cout << dp[n] << '\n';
  return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000010;
int n,ans,flg,a[MAXN];
char c[MAXN];
int main () {
	scanf("%d%s",&n,c+1);
	for (int i=1;i<=n;i++) {
		a[i]=c[i]-'1';
		if (a[i]==1) {flg=1;}
	}
	if (!flg) {
		for (int i=0;i<=n-1;i++) {
			if (((n-1)&i)==i) {
				ans^=a[i+1];
			}
		}
		printf("%d",ans);
	} else {
		for (int i=1;i<=n;i++) {
			if (a[i]==2) {a[i]=0;}
		}
		for (int i=0;i<=n-1;i++) {
			if (((n-1)&i)==i) {
				ans^=a[i+1];
			}
		}
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 5248
package main

import (
	"fmt"
)

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	w := Max(A-B*2, 0)
	fmt.Println(w)
}
func Max(a, b int) int {
	if b > a {
		return b
	}
	return a
}


Measured memory_bytes: 512
import java.util.Scanner;

import static java.lang.Math.pow;
import static java.lang.Math.sqrt;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int d = scanner.nextInt();
        int[][] x = new int[n][d];
        int count = 0;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] = scanner.nextInt();
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int tmp = 0;
                for (int k = 0; k < d; k++) {
                    tmp += pow(x[i][k] - x[j][k], 2);
                }
                double sroot = sqrt(tmp);
                if (sroot == (int) sroot) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    if((N - 1) * (N - 2) / 2 < K) {
        cout << -1 << endl;
    } else {
        cout << N - 1 + (N - 1) * (N - 2) / 2 - K << endl;
        for(int i = 2; i < N + 1; i++) {
            cout << 1 << " " << i << endl;
        }
        int p = (N - 1) * (N - 2) / 2 - K, r = 2, l = 2;
        while(p != 0) {
            l += 1;
            if(l > N) {
                r += 1;
                l = r + 1;
            }
            cout << r << " " << l << endl;
            p -= 1;
        }
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
const int mod=1000000007;

ll powmod(ll a,ll b){
    ll c=1;
    while(b){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll nCr(ll n,ll r){
	ll x=1,y=1;
	rep(i,r){
		x=x*(n-i)%mod;
		y=y*(i+1)%mod;
	}
	return x*powmod(y,mod-2)%mod;
}

int main()
{
	ll n,a,b,ans=0;
	cin >> n >> a >> b;
	ans=powmod(2,n)-1-nCr(n,a)-nCr(n,b);
	cout << (ans%mod+mod)%mod << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	total = A[0]
	for i,val in enumerate(A):
		if i == 0:
			continue
		total = total ^ val

	ans = []
	for i,val in enumerate(A):
		tmp =  total ^ val
		ans.append(tmp)

	print(*ans)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 117796
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int ans;
  cin >> s;
	if(s=="SUN")ans=7;
  	if(s=="MON")ans=6;
  	if(s=="TUE")ans=5;
  	if(s=="WED")ans=4;
  	if(s=="THU")ans=3;
  	if(s=="FRI")ans=2;
  	if(s=="SAT")ans=1;
  cout << ans;
  return 0;
}

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

int cnt[300001][2];

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

	int n;
	string s;

	cin >> n;
	cin >> s;

	memset(cnt,0,sizeof(cnt));

	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='W')
		{
			cnt[i][1] = cnt[i-1][1];
			cnt[i][0] = cnt[i-1][0] + 1;
		}
		else
		{
			cnt[i][1] = cnt[i-1][1] + 1;
			cnt[i][0] = cnt[i-1][0];
		}
	}

	int res = 1e9;
	for(int i=1;i<=n;i++)
	{
		int x = cnt[i-1][0];
		x += (cnt[n][1] - cnt[i][1]);
		res = min(res,x);
	}

	cout << res << '\n';
	
	return 0;	
}

Measured memory_bytes: 2964
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>

#define MAX_DIGIT 80
#define ERROR ("overflow")



int main(void){
	using namespace std;

	int N;
	cin >> N;

	vector< pair<string,string> > input;
	input.reserve(N);

	for(int i=1; i<=N; i++){

		string slhs, srhs;
		cin >> slhs >> srhs;

		reverse(slhs.begin(), slhs.end());
		reverse(srhs.begin(), srhs.end());

		input.push_back(make_pair(slhs,srhs));
	}

	for(auto p=input.begin(); p!=input.end(); p++){
		auto slhs = p->first, srhs = p->second;

		if(slhs.size()>MAX_DIGIT || srhs.size()>MAX_DIGIT){
			cout << ERROR << endl;
			continue;
		}

		int lhs[MAX_DIGIT], rhs[MAX_DIGIT], res[MAX_DIGIT];
		fill(lhs, lhs+MAX_DIGIT, 0);
		fill(rhs, rhs+MAX_DIGIT, 0);
		fill(res, res+MAX_DIGIT, 0);
		auto atoi_digit = [] (char x) -> int {
			return atoi(&x);
		};
		transform(slhs.begin(), slhs.end(), lhs, atoi_digit);
		transform(srhs.begin(), srhs.end(), rhs, atoi_digit);

		int headDigit;
		for (headDigit=MAX_DIGIT-1; headDigit>=0; headDigit--){
			if(lhs[headDigit]!=0 || rhs[headDigit]!=0){
				break;
			}
		}
		if(headDigit != MAX_DIGIT-1){
			headDigit++;
		}

		int carry = 0;
		for (int j=0; j<=headDigit; j++){
			auto d = div(lhs[j]+rhs[j]+carry,10);
			carry = d.quot;
			res[j] = d.rem;
		}
		if(headDigit==MAX_DIGIT-1 && carry !=0){
			cout << ERROR << endl;
			continue;
		}


		for (; headDigit>=1; headDigit--){
			if(res[headDigit]!=0){
				break;
			}
		}
		for (int j=headDigit; j>=0; j--){
			cout << res[j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l;
	cin >> n >> l;
	string s[n];
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++)
	{
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,a,b;
	cin >> n >> a;
	vector<vector<ll>> dp(n+1,vector<ll>(3001,0));
	vector<ll> x(n+1);
	for(int i = 0; i < n; i++) {
		cin >> b;
		x[i+1] = b - a;
	}
	dp[0][1500] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 3000; j++) {
			if (j - x[i] >= 0 && j - x[i] <= 3000){
				dp[i][j] = dp[i-1][j] + dp[i-1][j - x[i]]; 
			}
			else if(j - x[i] < 0 || j - x[i] > 3000){
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[n][1500] - 1 << endl; 
	return 0;
}

Measured memory_bytes: 1408
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

from itertools import product

ans = 0
for a, b, c in product([1, -1], repeat=3):
    tmp = []
    for x, y, z in List:
        tmp.append(a*x+b*y+c*z)
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:M]))
    
print(ans)

Measured memory_bytes: 3376
import sys
abcd = input()
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            siki = a+sign[i]+b+sign[j]+c+sign[k]+d
            ans = eval(siki)
            if ans == 7 :
                print(siki + '=7')
                sys.exit()


Measured memory_bytes: 3060
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 15 August 2020 01:13:26 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int m1,d1;
    cin>>m1>>d1;
    int m2,d2;
    cin>>m2>>d2;
    if( m1+1 == m2 ) {
        cout<<1<<endl;
        return;
    }
    cout<<0<<endl;
    return;
    int t1[] = { 1, 3, 5 , 7, 8, 10, 12 };
    int t2[] = { 4, 6, 9, 11 };
    for(int i=0; i<7; ++i){
        if(m1 == t1[i]){
            if(d2 == 31){
                cout<<1<<endl;
                return;
            }
        }
    }
    for(int i=0; i<4; ++i){
        if(m1 == t2[i]){
            if(d1 == 30){
                cout<<1<<endl;
                return;
            }
        }
    }
    if(m1 == 2 and d1 == 28){
        cout<<1<<endl;
        return;
    }
    cout<<0<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



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

int N, K, a[110];
bool dp[100100], cek[100100];

bool f(int k) {
	if (k==0) return 0;
	if (cek[k]) return dp[k];
	dp[k] = 0;
	for(int i=1; i<=N; i++) {
		if (k - a[i] >= 0) {
			dp[k] |= !f(k - a[i]);
		}
	}
	cek[k] = 1;
	return dp[k];
}

int main () {
	cin >> N >> K;
	for(int i=1; i<=N; i++)
		cin >> a[i];
	memset(cek, 0, sizeof(cek));
	if (f(K))
		cout << "First" << endl;
	else
		cout << "Second" << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int INF = 191919;

int main(){
    int n,c;
    while(cin >>n >>c,n){
        vector<vector<int>> a(n,vector<int>(n));
        rep(i,n)rep(j,i+1) cin >>a[i][j];

        map<pi,vector<pi>> G;
        auto ADD = [&](pi u, pi v){
            G[u].pb(v);
            G[v].pb(u);
        };

        rep(i,n){
            rep(j,i+1){
                pi u(i,j);

                if(i<n-1){
                    rep(k,2){
                        pi v(i+1,j+k);
                        ADD(u,v);
                    }
                }

                if(j<i){
                    pi v(i,j+1);
                    ADD(u,v);
                }
            }
        }

        auto CHECK = [&](){
            set<pi> vis;
            queue<pi> que;
            rep(i,n)rep(j,i+1){
                if(a[i][j]==0){
                    vis.insert({i,j});
                    for(const auto &p:G[{i,j}]){
                        vis.insert(p);
                        que.push(p);
                    }
                }
            }
            while(!que.empty()){
                pi p = que.front();
                que.pop();
                for(const auto &nx:G[p]){
                    if(!vis.count(nx) && a[nx.fi][nx.se]==a[p.fi][p.se]){
                        vis.insert(nx);
                        que.push(nx);
                    }
                }
            }

            int ret = 0;
            rep(i,n)rep(j,i+1){
                if(!vis.count({i,j})){
                    if(a[i][j]==c) --ret;
                    else ++ret;
                }
            }

            return ret;
        };

        int ans = -INF;
        rep(i,n)rep(j,i+1){
            if(a[i][j] != 0) continue;
            a[i][j] = c;
            ans = max(ans, CHECK());
            a[i][j] = 0;
        }
        cout << ans << endl;
    }
    return 0;
}



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

using namespace std;
#define int long long

signed main()
{
    int n, k;
    cin >> n;
    vector<int> numbers, freq(n+10, 0), freqSol(n+10, 0);
    unsigned long long freqSolSum = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        numbers.push_back(k);
        freq[k]++;
    }
    for (int i = 1; i <= n; i++)
    {
        freqSol[i] = (freq[i] * (freq[i] - 1)) / 2;
        if (freqSol[i] < 0)
            freqSol[i] = 0;
        freqSolSum += freqSol[i];
    }
    for (int i = 0; i < n; i++)
    {
        int cur = numbers[i];
        int nie = ((freq[cur] - 1) * (freq[cur] - 2)) / 2;
        long long l = 0;
        nie = max(l, nie);
        cout << freqSolSum - freqSol[cur] + nie << endl;
    }
    return 0;
}

/*using namespace std;
 
int main() {
	return 0;
}

using namespace std;
 
int main() {
	return 0;
}*/

Measured memory_bytes: 7408
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int b,c;
    cin>>b>>c;
    vector<int>a(13);
    a[1]=2;
    a[2]=3;
    a[3]=2;
    a[4]=1;
    a[5]=2;
    a[6]=1;
    a[7]=2;
    a[8]=2;
    a[9]=1;
    a[10]=2;
    a[11]=1;
    a[12]=2;
    if(a[b]==a[c]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int sum=0;
	int temp=n;
	while(temp)
	{
		sum+=temp%10;
		temp/=10;
	}
	if(n%sum)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

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

int main() {
int N;
  cin >> N;
  
  int a,b,c;
  a=N/100;
  b=(N-100*a)/10;
  c=N-100*a-10*b;
  
  if(a == 7 || b == 7 || c==7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}




Measured memory_bytes: 3572
/*
      author : nishi5451
      created: 12.08.2020 10:52:47
*/

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


int main(){
    string s;
    cin >> s;
    for(int i=0; i<s.size()-8; i++)
        cout << s[i];
    cout << endl;
    return 0;
}

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

#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 FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	string s; cin >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	string a,b,c; cin>>a>>b>>c;
	int ans=0;
	rep(i,0,n){
		if(a[i]!=b[i] && b[i]!=c[i] && a[i]!=c[i])ans+=2;
		else if(a[i]==b[i] && b[i]==c[i] && a[i]==c[i])ans=ans;
		else ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i <= 30; i++) if (n == (1 << i)) {
		std::cout << "No" << std::endl;
		return 0;
	}
	int nn;
	if (n % 4 == 3) nn = n;
	else nn = n / 4 * 4 - 1;
	std::vector<int> all;
	for (int i = 1; i <= nn; i++) all.push_back(i);
	std::vector<int> xorsum(nn + 1);
	for (int i = 0; i < nn; i++) xorsum[i + 1] = xorsum[i] ^ all[i];
	std::vector<std::pair<int, int> > add;
	if (n % 4 == 3) {}
	else if (n % 4 == 0) {
		int r0 = nn;
		int r1 = -1;
		for (int i = 0; i <= nn; i++) {
			if (xorsum[i] == ((nn + 1) ^ nn)) {
				r1 = i ? n + i : nn;
				break;
			}
		}
		if (r1 == -1) {
			std::cout << "No" << std::endl;
			return 0;
		}
		add.push_back({r0, nn + 1});
		add.push_back({r1, nn + n + 1});
	} else {
		add.push_back({n + 1, nn + 1});
		add.push_back({n + 1, nn + 2});
		add.push_back({nn + 1, n + nn + 2});
		add.push_back({nn + 2, n + nn + 1});
		if (n % 4 == 2) {
			add.push_back({nn + 3, n + 2});
			add.push_back({n + nn + 3, nn + 2});
		}
	}
	std::cout << "Yes" << std::endl;
	for (int i = 1; i < nn; i++) add.push_back({i, i + 1});
	add.push_back({nn, n + 1});
	for (int i = n + 1; i < n + nn; i++) add.push_back({i, i + 1});
	assert(add.size() == 2 * n - 1);
	for (auto i : add) std::cout << i.first << " " << i.second << std::endl;
	return 0;
}



Measured memory_bytes: 5232
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int d[N];
    for (int i = 0; i < N; ++i) cin >> d[i];
    sort(d, d + N);
    cout << (d[N / 2] - d[N / 2 - 1]) << endl;
}


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

int mp[10000];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		memset(mp, 0, sizeof(mp));
		unordered_set<int>se;
		for (int i = 1; i < n; i++)se.insert(i*i%n);
		for (auto i = se.begin(); i != se.end(); i++) {
			for (auto j = se.begin(); j != se.end(); j++) {
				if (i == j)continue;
				int d = *i - *j;
				if (d < 0)d += n;
				if (d > (n - 1) / 2) d -= n;
				mp[abs(d)]++;
			}
		}
		for (int i = 1; i <= (n - 1) / 2; i++)printf("%d\n", mp[i]);
	}
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main(){
  int n,min = 1000000,temp=0,i;
  while(1){
    cin >> n;
    if(n==0) break;
    int a[1000];
    for(i=0;i<n;i++){
    cin >> a[i];
    }
    for(int j=0;j<n-1;j++){  
      for(i=0;i<n-1;i++){
	if(a[i]>a[i+1]){
	  swap(a[i],a[i+1]);
	}
      }
    }
    
    for(i=0;i<n-1;i++){
      if((a[i+1]-a[i])<min){
	min = (a[i+1]-a[i]);
      }
    }
    if(min<0) min *= -1;
    cout << min << endl;
    min=1000000;
    temp=0;
    }
  return 0;
}
  



Measured memory_bytes: 3076
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	string s; cin >> s;
	lld n = (lld) s.length();
	unordered_set<char> letters;
	for (auto i : s) {
		letters.insert(i);
	}
	lld m = (lld) letters.size();
	puts((n == m) ? "yes" : "no");

	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3592
def play(line, N):
    C = [0] * N
    B = 0

    for i in range(len(line)):
        p = i%N
        if line[i] == 'M':
            C[p] += 1
        elif line[i] == 'S':
            C[p] += 1
            B += C[p]
            C[p] = 0
        elif line[i] == 'L':
            C[p] += B + 1
            B = 0

    C.sort();

    for c in C: print(c, end=" ")
    print(B)

while True:
    N = int(input())
    if N == 0: break
    line = input()
    play(line, N)
             


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, K, A[200001];

template<typename T> class BinaryIndexedTree {
  vector<T> vec;
  const ll n;

public:
  BinaryIndexedTree(T _n) : vec(_n + 1), n(_n) {}

  T query(ll x) {
    T ret = 0;
    for(ll i = x; i > 0; i -= i & (-i)) ret += vec[i];
    return ret;
  }

  void update(ll x, T k) { for(ll i = x; i <= n; i += i & (-i)) vec[i] += k; }
};

int main(void) {
  cin >> N >> K;
  A[0] = 0;
  REP(i, 1, N + 1) cin >> A[i];

  REP(i, 1, N + 1) A[i] += A[i - 1];
  REP(i, 0, N + 1) A[i] -= i * K;

  vector<ll> vec(N + 1);
  REP(i, 0, N + 1) vec[i] = A[i];
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  REP(i, 0, N + 1) A[i] = lower_bound(vec.begin(), vec.end(), A[i]) - vec.begin() + 1;

  BinaryIndexedTree<ll> bit(N + 1);
  ll ans = 0;
  REP(i, 0, N + 1) {
    ans += bit.query(A[i]);
    bit.update(A[i], 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
B = [e[:] for e in A]

for k in range(n):
    for i in range(n):
        for j in range(n):
            B[i][j] = min(B[i][k] + B[k][j], B[i][j])
ok = 1
for i in range(n):
    for j in range(n):
        if A[i][j] != B[i][j]:
            ok = 0
if not ok:
    print(-1)
    exit(0)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        need = 1
        for k in range(n):
            if i == k or j == k:
                continue
            if A[i][k] + A[k][j] == A[i][j]:
                need = 0
        if need:
            ans += A[i][j]
print(ans)


Measured memory_bytes: 48092
from collections import defaultdict

H,W,N=map(int,input().split())

XY=[]
ND=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,0],[0,1],[1,-1],[1,0],[1,1]]

M=defaultdict(int)
for i in range(N):
  a,b=map(int,input().split())
  XY.append([a-1,b-1])
  for c,d in ND:
    if 1 <= a-1+c < H-1 and 1 <= b-1+d < W-1:
      M[(a-1+c,b-1+d)]+=1

dict={1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0}
cnt=0
for a,b in M.items():
  dict[b]+=1
  cnt+=1
ans=(H-2)*(W-2)-cnt
print(ans)
for i in range(1,10):
  print(dict[i])

Measured memory_bytes: 183884
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

using namespace std;

typedef unsigned long long ULL;
typedef long long LL;

int main(){
    LL X,K,D;
    LL L;
    LL ans;
    cin >> X >> K >> D;
    X = abs(X);
    L = X / D;
    if( L >= K ){
        ans = X - K * D;
    }else{
        ans = X % D;
        K -= L;
        if( K % 2 == 1){
            if( D - ans < ans + D){
               ans = D - ans;
            }else{
               ans = ans + D;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
#include <set>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
#define int long long


const int SIZE = 200020;

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) { 
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { 
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { 
		int rx = root(x); 
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

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

	int maxtree(int N) {
		int kosuu[SIZE];
		for (int i = 0; i < N; i++) {
			kosuu[i] = 0;
		}
		for (int i = 0; i < N; i++) {
			kosuu[root(i)]++;
		}
		int max = 0;
		for (int i = 0; i < N; i++) {
			if(max<kosuu[i]) max=kosuu[i];
		}
		return max;
	}
};

signed main() {



	int N,M;

	int ans = 0;

	cin >> N >> M;

	int A[SIZE], B[SIZE];

	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}

	UnionFind tree(N);

	for (int i = 0; i < M; i++) {
		tree.unite(A[i] - 1, B[i] - 1);
	}

	ans = tree.maxtree(N);

	cout << ans << endl;

	cin >> ans;

	return 0;


}

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

uint64_t solve(const uint64_t h) {
    if(h == 1) {
        return 1;
    }

    return 2 * solve(h / 2) + 1;
}

int main() {
    uint64_t h;
    std::cin >> h;

    std::cout << solve(h) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r < 0 || y-r < 0 || W < x+r || H < y+r){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define csize 26
using namespace std;

struct data {
  int l, r, u, d;
};
int h, w, t;
string s[55];
data dummy{10000, -1, 100000, -1};
vector<data> lst(26);
bool memo[30][30] = {0};
vector<int> cperm;

bool solve();
void lstset(int x, int i, int j);

int main() {
  cin >> t;
  for(int tt = 0; tt < t; ++tt) {
    cin >> h >> w;
    for(int i = 0; i < h; ++i) cin >> s[i];
    for(int i = -0; i < csize; ++i) lst[i] = dummy;
    if(solve())
      cout << "SUSPICIOUS" << endl;
    else
      cout << "SAFE" << endl;
    for(int i = 0; i < 26; ++i)
      for(int j = 0; j < 26; ++j) memo[i][j] = 0;
    cperm.erase(cperm.begin(), cperm.end());
  }
  return 0;
}

bool solve() {
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      if(s[i][j] != '.') lstset(s[i][j] - 'A', i, j);
  for(int i = 0; i < csize; ++i)
    if(lst[i].r != -1) {
      for(int j = lst[i].u; j <= lst[i].d; ++j)
        for(int k = lst[i].l; k <= lst[i].r; ++k) {
          if(s[j][k] == '.')
            return 1;
          else if(s[j][k] - 'A' != i)
            memo[s[j][k] - 'A'][i] = 1;
        }
      cperm.push_back(i);
    }
  int cpermsize = cperm.size();
  do {
    bool ok = 1;
    for(int i = 0; i < cpermsize; ++i)
      for(int j = i + 1; j < cpermsize; ++j)
        if(memo[cperm[j]][cperm[i]]) ok = 0;
    if(ok) return 0;
  } while(next_permutation(cperm.begin(), cperm.end()));
  return 1;
}

void lstset(int x, int i, int j) {
  lst[x].l = min(lst[x].l, j);
  lst[x].r = max(lst[x].r, j);
  lst[x].u = min(lst[x].u, i);
  lst[x].d = max(lst[x].d, i);
}


Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}
//0:+, 1:-, 2:*

string s;
int ind;
vs in;

int number(){
  int ret = 0;
  while(isdigit(s[ind])){
    ret *= 10;
    ret += s[ind] - '0';
    ind++;
  }
  return ret;
}

int f(int a, int b, char c){
    if(c == '+')return a+b;
    if(c == '-')return a-b;
    if(c == '*')return a*b;
}


int expression(int id){

    if(id == in.size()){
        if(s[ind] == '('){
            ind++;
            int ret = expression(0);
            ind++;
            return ret;
        }else{
            return number();
        }
    }

    int ret = expression(id+1);
    while(ind < s.size()){
        bool c = true;
        rep(i,in[id].size()){
            char op = s[ind];
            if(op == in[id][i]){
                ind++;
                ret = f(ret,expression(id+1),op);
                c = false;
                break;
            }
        }
        if(c)break;
    }
    return ret;
}


signed main(void) {
    vector<vs> vvs;
    rep(i,3)rep(j,3)rep(k,3){
        vs t(3);
        t[i] += '+';
        t[j] += '-';
        t[k] += '*';
        int id = 0;
        while(id < t.size()){
            if(t[id].empty())t.erase(t.begin()+id);
            else id++;
        }
        vvs.push_back(t);
    }
    cin >> s;
    int ans = -(1LL<<63);
    rep(i,vvs.size()){
        ind = 0;
        in = vvs[i];
        int ret = expression(0);
        ans = max(ans, ret);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3224
k = int(input())
r = 0
def gcd(num1, num2):
	if num2 == 0:
		return num1
	return gcd(num2, num1 % num2)
for a in range(1, k+1):
	for b in range(1, k+1):
		for c in range(1, k+1):
			r += gcd(a, gcd(b, c))
print(r)


Measured memory_bytes: 79220
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i = (l); i < (n); i++)
using namespace std;
int main() {
  int a[3][3] = {};
  int n;
  int b[101] = {};
  bool flag = false;
  rep(i,0,3)rep(j,0,3) cin >> a[i][j];
  cin >> n;
  rep(i,0,n) {
    int tmp;
    cin >> tmp;
    b[tmp]++;
  }
  if(b[a[0][0]] > 0 && b[a[1][1]] > 0 && b[a[2][2]] > 0) flag = true;
  else if(b[a[0][2]] > 0 && b[a[1][1]] > 0 && b[a[2][0]] > 0) flag = true;
  rep(i,0,3)rep(j,0,3) {
    if(flag) break;
    if(b[a[i][0]] > 0 && b[a[i][1]] > 0 && b[a[i][2]] > 0) flag = true;
    if(b[a[0][i]] > 0 && b[a[1][i]] > 0 && b[a[2][i]] > 0) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    def Z(s):
        """
        param s:str
        return list of int with length len(s)
        """
        # initialization
        n=len(s)
        z=[0]*n
        z[0]=n
        # construct
        L,R=0,0
        for i in range(1,n):
            if i>R: # 過去の結果が全く使えない
                L=R=i
                while(R<n and s[R-L]==s[R]): R+=1
                z[i]=R-L
                R-=1 # 0-indexedでiと比較するため
            elif z[i-L]<R-i+1:
                z[i]=z[i-L]
            else:
                L=i
                R+=1 # Rまでは確定しているので、R+1から確認
                while(R<n and s[R-L]==s[R]): R+=1
                z[i]=R-L
                R-=1
        return z

    # input
    n=int(input())
    s=input()
    ans=0
    for i in range(n):
        z=Z(s[i:])
        k=len(z) # k=n-i
        for j in range(k):
            ans=max(ans,min(j,z[j]))
    print(ans)
resolve()

Measured memory_bytes: 47196
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, M = map(int, raw_input().split())
c = [0,2,5,5,4,5,6,3,7,6]
A = sorted(map(int, raw_input().split()))

D = [0] + [-1] * N * 9
a = [0, 0] * N

for i in range(1, N + 1):
    for j in A:
        p = i - c[j]
        if min(p, D[p], D[p] + 1 - D[i]) >= 0:
            D[i], a[i] = D[p] + 1, j

S, p = "", N
while p:
 S+=str(a[p])
 p-=c[a[p]]
###while p:S,p=S+str(a[p]),p-c[a[p]]
print S

Measured memory_bytes: 4216
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_L = 200050;
int L;
long long A[MAX_L];
long long AC_L[MAX_L], AC_R[MAX_L];
long long REV_C[MAX_L], REV_L[MAX_L], REV_R[MAX_L];
long long ARB_L[MAX_L], ARB_R[MAX_L];


int main(int argc, char **argv) {
    std::cin >> L;

    for (int i = 1; i <= L; i++) {
        std::cin >> A[i];
    }

    for (int i = 1; i <= L; i++) {
        if (A[i] == 0) {
            REV_C[i] = 2;
        } else if (A[i] % 2 == 1) {
            REV_C[i] = 1;
        } else {
            REV_C[i] = 0;
        }
    }

    for (int i = 1; i <= L; i++) {
        AC_L[i] = AC_L[i-1] + A[i];
        REV_L[i] = std::min(AC_L[i], REV_C[i] + REV_L[i-1]);
        ARB_L[i] = std::min(REV_L[i], ARB_L[i-1] + 1 - (A[i] % 2) );
    }

    for (int i = L; 1 <= i; i--) {
        AC_R[i] = AC_R[i+1] + A[i];
        REV_R[i] = std::min(AC_R[i], REV_C[i] + REV_R[i+1]);
        ARB_R[i] = std::min(REV_R[i], ARB_R[i+1] + 1 - (A[i] % 2) );
    }

    long long ret = AC_L[L];
    for (int i = 0; i <= L; i++) {
        ret = std::min(ret, ARB_L[i] + ARB_R[i+1]);
    }

    std::cout << ret << std::endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s1, s2;
	cin>>s1>>s2;
	int a, b;
	cin>>a>>b;
	string s3;
	cin>>s3;
	if(s3==s1)
	{
		cout<<--a<<" "<<b<<endl;
	}
	else
	{
		cout<<a<<" "<<--b<<endl;
	}
}

Measured memory_bytes: 256