akhauriyash/Code-Regression huggingface dataset:
using System;
public class Class1
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		
		int x = 0;
	
		for (int i = 1; i <= n; i++) {
			x = i;
			if (i % 3 == 0 | i % 10 == 3) {
					
				Console.Write(" " + i);
				
			} else {
				while (x > 10) {
				
					x /= 10;
					if (x % 10 == 3) {
						Console.Write(" " + i);	
						break;
					}
				
						
				}
			}
			
		
		}Console.WriteLine();
	}
}

Measured memory_bytes: 9224
def is_eql(a, b):
    return abs(a - b) < 1e-9

W, H, x, y  = [int(i) for i in input().split()]

S = W * H / 2.
ans = 1 if is_eql(W/2., x) and is_eql(H/2., y) else 0

print("{} {}".format(S, ans))


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    string S;
    cin >> N >> S;
    map<pss, ll> mp;
    REP(i, (1<<N)){
    	string red = "";
    	string blue = "";
    	REP(j, N){
    		if(!((i>>j) & 1)){
    			red += S[j];
    		}
    		if((i>>(N-1-j)) & 1){
    			blue += S[N-1-j];
    		}
    	}
    	mp[{red, blue}]++;
    	//cout << red << " " << blue << endl;
    }

    ll res = 0;
    REP(i, (1<<N)){
    	string red = "";
    	string blue = "";
    	REP(j, N){
    		if(!((i>>j) & 1)){
    			red += S[j+N];
    		}
    		if((i>>(N-1-j)) & 1){
    			blue += S[N+N-1-j];
    		}
    	}
    	//cout << red << " " << blue << endl;
    	res += mp[{blue, red}];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 91904
#include <iostream>

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    size_t num_odd = 0;
    for (unsigned long long i = 0; i < n; ++i) {
        unsigned long long a;
        cin >> a;
        if (a % 2 != 0) ++num_odd;
    }
    cout << (num_odd % 2 == 0 ? "YES" : "NO") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

// NewSet is constructer of Set
func NewSet() *Set {
	s := new(Set)
	s.content = map[int]int{}
	return s
}

// Set for integer
type Set struct {
	content map[int]int
}

func (s *Set) insert(x int) int {
	_, ok := s.content[x]
	if !ok {
		s.content[x] = 1
	}
	return len(s.content)
}

func (s *Set) find(x int) int {
	v, ok := s.content[x]
	if ok {
		return v
	}
	return 0
}

func (s *Set) delete(x int) {
	delete(s.content, x)
}

func main() {
	scanner.Split(bufio.ScanWords)

	nQueries := nextInt()
	set := NewSet()
	for iQuery := 0; iQuery < nQueries; iQuery++ {
		queryType := nextInt()
		x := nextInt()
		if queryType == 0 {
			setSize := set.insert(x)
			fmt.Println(setSize)
		} else if queryType == 1 {
			fmt.Println(set.find(x))
		} else if queryType == 2 {
			set.delete(x)
		}
	}
}



Measured memory_bytes: 13888
#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 DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	if (n == 1) {
		if (m == 1)cout << 1 << endl;
		else cout << m - 2 << endl;
	}
	else if (m == 1){
		cout << n - 2 << endl;
	}
	else {
		cout<<(m - 2)*(n - 2) << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
AB = []
for _ in range(N) :
    AB.append(list(map(int, input().split())))

AB = sorted(AB, key=lambda x: x[1])

time = 0
ans = True

for i in range(N) :
    time += AB[i][0]
    if time > AB[i][1] :
        ans = False
        break

if ans :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 55260
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_left
from itertools import accumulate

import numpy as np

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索 """

    ok = mn
    ng = mx
    while ok+1 < ng:
        mid = (ok+ng) // 2
        if func(mid):
            # 上を探しに行く
            ok = mid
        else:
            # 下を探しに行く
            ng = mid
    return ok

# 右手と左手(a,b)の和がx以上となる組の数がM以上あるか
def calc(x):
    # 数列Aの二分探索をまとめて処理
    res = N - np.searchsorted(A, x - A)
    return res.sum() >= M

N, M = MAP()
A = np.array(LIST(), dtype=np.int64)

A.sort()
res = bisearch_max(0, 10**10 + 1, calc)

ans = m = 0
acc = [0] + list(A.cumsum())
for a in A:
    idx = bisect_left(A, res - a)
    cnt = N - idx
    # 幸福度
    ans += a * cnt + (acc[N] - acc[idx])
    # 握手の回数
    m += cnt

# 同値でMを超えた分の調整
ans -= res * (m - M)
print(ans)


Measured memory_bytes: 23484
#include <stdio.h>

int main (void){
char c;

while(1){
	scanf("%c",&c);
	
	if (c >= 65 && c <= 90){ /*??§????????¢???????????????????????????*/
		c = c + 32; /*ASCII???????????? ??§????????¢?????????????????? + 32 = ?°?????????¢??????????????????*/
		printf("%c",c);
	}
	
	else if (c >= 97 && c <= 122){ /*?°?????????¢???????????????????????????*/
		c = c - 32; /*ASCII???????????? ?°?????????¢?????????????????? - 32 = ??§????????¢??????????????????*/
		printf("%c",c);
}
	
	else{printf("%c",c);}
	
	
	
	if(c=='\n'){
	break;
	}
	
	
	

}



return 0;
}

Measured memory_bytes: 524
n=int(input())

a=[]
b=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x+y,x,y])
  b.append([x-y,x,y])
a.sort()
b.sort()
ans=abs(a[0][1]-a[n-1][1])+abs(a[0][2]-a[n-1][2])
aa=abs(b[0][1]-b[n-1][1])+abs(b[0][2]-b[n-1][2])
print(max(ans,aa))

  

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

const int mxn = 100010;
int N;
vector<int> G[mxn];
void dfs(int v, int p, int dist, vector<int>& depth) {
    depth[v] = dist;
    for(auto e : G[v]) {
        if(e != p) dfs(e, v, dist + 1, depth);
    }
}

int main() {
    cin >> N;
    for(int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> d1(N, 0), d2(N, 0);

    dfs(0, -1, 0, d1);
    dfs(N-1, -1, 0, d2);

    int cntb = 0, cntw = 0;
    for(int i = 1; i < N-1; i++) {
        if(d1[i] <= d2[i])  cntb++;
        else cntw++;
    }

    if(cntb > cntw) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX_INT 10e9
int main()
{
  	ll i,j,k,n;
  cin>>n;
  if(n<=9){
      cout<<n<<endl;
    return 0;
}
  ll sum=0;
  ll ans=10;
  while(ans<=n){
   	sum+=ans -(ans/10);
      ans=(ans*100);
  }
  //cout<<ans<<" "<<sum<<endl;
  int dig=0,m;
  m=n;
  while(m>0){
    dig++;
    m/=10;
  }
  if(dig%2==0)
  cout<<sum<<endl;
  else{
    dig--;
  	sum+=n-pow(10,dig)+1;
    cout<<sum<<endl;
  }
    return 0;
    
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
i, ans = 0, 0
while i < N:
    i = min(i+C, bisect_right(T, T[i]+K))
    ans += 1
print(ans)

Measured memory_bytes: 7860
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

long long int gcd(long long int x,long long int y){
    long long int r;
    if(x == 0 || y == 0)  return 0;
    while((r = x % y) != 0) 
    {
         x = y;
        y = r;
    }
    return y;
}

int main(){
    int t; cin >> t;
    rep(i,t){
        ll a,b,c,d; cin >> a >> b >> c >> d;
        if(a < b || d < b){cout << "No" << endl; continue;}
        if(b <= c){cout << "Yes" << endl; continue;}
        if(b == 1){cout << "Yes" << endl; continue;}
      	if(d % b == 0 && a % b > c){cout << "No" << endl; continue;}
        else if(d % b == 0){cout << "Yes" << endl; continue;}
        d = d % b;
        ll gc = gcd(b , d);
        if(b-c-1 >= gc){cout << "No" << endl; continue;}
        if((c%gc) < a%gc){cout << "No" << endl; continue;}
        bool flag = true;
        /*
        rep(i, 500000){
            a = a % b;
            if(a > c){flag = false; break;}
            a += d;
        }
        */
        if(flag){cout << "Yes" << endl; continue;}
        else{cout << "No" << endl; continue;}
    }
    return 0;
}


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

int n;
int a[1000005];
int main()
{
cin>>n;

for(int i=1;i<=n;i++)
    {
     a[i]=a[i-1]+1;
     for(int j=6;j<=i;j*=6)
         a[i]=min(a[i],a[i-j]+1);
     for(int j=9;j<=i;j*=9)
         a[i]=min(a[i],a[i-j]+1);
    }
cout<<a[n];

return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A, B,N;
  cin >> A >> B >> N;
  if(A<N){
    if(N-A>B)cout << 0 << " " << 0 << endl;
    else cout << 0 << " " << B-(N-A) << endl;
   }else{
  	cout << A-N <<  " " << B << endl;
  }
  return 0;
}

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

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

    vector<vector<int>> T(N+1, vector<int>(N+1));
    int ans = 0;
    for (int i=N-1; i>=0; i--)
        for (int j=0; j<N; j++)
        {
            if (S[i]==S[j])
                T[i][j] = T[i+1][j+1]+1;
            else
                T[i][j] = 0;
            ans = max(ans, min(T[i][j], abs(i-j)));
        }
    cout<<ans<<endl;
}


Measured memory_bytes: 98176
def power(a, k):
    N = len(a)
    r = [[1 if i==j else 0 for i in range(N)] for j in range(N)]
    while k:
        if k & 1:
            r = mul(r, a)
        k >>= 1
        a = mul(a, a)
    return r
def mul(a, b):
    return [[sum(ay * by for ay, by in zip(ax, bx)) % (10**9 + 7) for bx in zip(*b)] for ax in a]
def main():
    N, K = map(int, input().split())
    l = []
    for _ in range(N):
        l.append(list(map(int, input().split())))
    lt = [i for i in zip(*l)]
    return sum(mul([[1]*N], power(lt, K))[0])
    #return l
#print(main())
print(main() % (10**9 + 7))


Measured memory_bytes: 74716
#include <bits/stdc++.h>
#define ll long long
#define sz 3005
using namespace std;
int L[sz][sz];
bool vis[sz][sz];
string a, b;
int LCS(int lena , int lenb){
    int i , j;
    for(i=1;i<=lenb;i++){
        for(j=1;j<=lena;j++){
            if(b[i-1] == a[j-1])
                L[i][j] = L[i-1][j-1] + 1;
            else
                L[i][j] = max(L[i-1][j],L[i][j-1]);
        }
    }
    return L[lenb][lena];
}

string ans;
void PrintLcs(int lena , int lenb){
    int i = lenb , j = lena;
    while(i>0 && j>0){
        if(a[j-1] == b[i-1]){
            ans += a[j-1];
            j--;i--;
        }
        else{
            if(L[i-1][j] > L[i][j-1])i--;
            else j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
int main(){
    //freopen("riyad.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int lena , lenb , i , j;
    cin>>a>>b;
    lena = a.size();
    lenb = b.size();
    LCS(lena,lenb);
    PrintLcs(lena,lenb);
    return 0;
}



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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

const int maxn = 220;
int mp[220][220];
int n;
int col[maxn];

bool dfs(int u){
    for(int i = 1; i <= n; i++){
        if(i == u || mp[u][i] == inf) continue;
        if(col[i] == col[u]) {
            return false;
        }
        if(!col[i]){
            col[i] = 3 - col[u];
            if(!dfs(i)) return false;
        }
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; j++){
            scanf("%1d", &mp[i][j]);
            if(mp[i][j] == 0) mp[i][j] = inf;
        }
    }
    col[1] = 1;
    if(!dfs(1)) puts("-1");

    else {
        for (int k = 1; k <= n; ++k) {
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= n; ++j) {
                    mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
                }
            }
        }

        int res = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (mp[i][j] != inf) res = max(res, mp[i][j]);
            }
        }
        printf("%d\n", res + 1);
    }
    return 0;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(x <= 0 || y <= 0) {
			System.out.println("No");
		} else {
			if(W >= x + r && H >= y + r) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}


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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        if ((a + b) == c || (a + c) == b || (b + c) == a)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

        #if DEBUG
                Console.WriteLine("続行するには何かキーを押してください．．．");
                Console.ReadKey();
        #endif
    }
}


Measured memory_bytes: 2648
d[99][99],v,y,x,w,h;main(){scanf("%d%d",&h,&w);for(;y<h;y++)for(x=0;x<w;x++)scanf("%1d",&v),d[y+1][x+1]=v+(d[y+1][x]<d[y][x+1]&&x||!y?d[y+1][x]:d[y][x+1]);printf("%d\n",d[h][w]);exit(0);}

Measured memory_bytes: 0
//問題文をしっかり読む！。最後と空っぽに注意！メモリをしっかり確保すること。
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
using namespace std;
typedef vector<int> VI;
int n,k;
VI topic[11];
int DP[11][2001];
int main(){
	int i,t,u,qsize[10] = {0};
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>t>>u;
		u--;
		topic[u].push_back(t);
		qsize[u]++;
	}
	for(i=0;i<11;i++){
		for(int j=0;j<2001;j++){
			DP[i][j] = -1;
		}
		sort(topic[i].begin(),topic[i].end(),greater<int>());
	}
	DP[0][0]=0;
	//ジャンル番号の低いほうから売る本の数(0<=x<=size)を考える。
	//売った本の冊数と、今から売ることが可能な冊数が同じならば、
	//その時の売り上げが最大のものをとってみる。
	for(i = 0;i < 10;i++){
		for(int j = 0;j <= k;j++){
			if(DP[i][j]==-1)
				continue;
			int gokei;
			gokei = 0;
			for(int l = 0;l <= qsize[i] && j+l <= k;l++){
				if(DP[i+1][j+l] < DP[i][j]+gokei+(l>1?l*l-l:0)){
					DP[i+1][j+l] = DP[i][j]+gokei+(l>1?l*l-l:0);
				}
				if(l < qsize[i])
					gokei += topic[i][l];
			}
		}
	}
	//あとはk冊売った集合から最大値を貪欲法で探す
	int saidai = 0;
	for(i = 0;i < 11;i++){
		if(saidai < DP[i][k])
			saidai = DP[i][k];
	}
	cout << saidai << endl;
	return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
class finite_field {
  const int md;
  const int sz;
  vector<int> fct, fnv;
  void init () {
    if (sz) {
      fct[0] = 1;
      for (int i = 1; i < sz; i++) fct[i] = prod(fct[i - 1], i);
      fnv[sz - 1] = inv(fct[sz - 1]);
      for (int i = sz - 1; i >= 1; i--) fnv[i - 1] = prod(fnv[i], i);
    }
  }
  public:
    finite_field(
        const int md,
        const int init_factorial_size = 0,
        const int init_power_size = 0
      ) :
      md(md), sz(init_factorial_size),
      fct(sz), fnv(sz)
      {
        init();
      }
    inline void add (int& a, const int b) const {
      a += b;
      if (a >= md) a -= md;
    }
    inline void sub (int& a, const int b) const {
      a -= b;
      if (a < 0) a += md;
    }
    template<class... A> inline int sum (A... args) const {
      int ret = 0;
      for (int a : initializer_list<int>{args...}) {
        add(ret, a);
      }
      return ret;
    }
    inline int dif (int a, int b) const {
      sub(a, b);
      return a;
    }
    // inline int prod (int a, int b) const {
    //   return (long long)a * b % md;
    // }
    template<class... A> inline int prod (A... args) const {
      long long ret = 1;
      for (int a : initializer_list<int>{args...}) {
        ret *= a;
        ret %= md;
      }
      return (int)ret;
    }
    void mul (int& a, int b) const {
      a = prod(a, b);
    }
    inline int inv (int a) const {
      a %= md; if (a < 0) a += md;
      int b = md, u = 0, v = 1;
      while (a) {
        int t = b / a;
        b -= a * t; swap(a, b);
        u -= v * t; swap(u, v);
      }
      assert(b == 1);
      if(u < 0) u += md;
      return u;
    }
    inline int quat (int a, int b) const {
      return prod(a, inv(b));
    }
    inline void div (int& a, int b) const {
      a = quat(a, b);
    }
    inline int pow (int a, long long b) {
      int ret = 1;
      for (; b; b >>= 1) {
        if (b & 1) mul(ret, a);
        a = prod(a, a);
      }
      return ret;
    }
    inline int binom (int n, int k) const {
      assert(0 <= n && n < sz);
      if (k < 0 || n < k) return 0;
      return prod(fct[n], fnv[k], fnv[n - k]);
    }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = a[i] > a[j] ? 1 : 0;
    }
  }
  finite_field fld(1e9 + 7);
  int inv2 = fld.inv(2);
  int coeff = fld.pow(2, q);
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    auto half = [&] (int& a, int& b) -> void {
      fld.add(a, b);
      fld.mul(a, inv2);
      b = a;
    };
    half(dp[x][y], dp[y][x]);
    for (int z = 0; z < n; z++) if (z != x && z != y) {
      half(dp[x][z], dp[y][z]);
      half(dp[z][x], dp[z][y]);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      fld.mul(dp[i][j], coeff);
      fld.add(ret, dp[i][j]);
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 37632
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline 

n = int(input())
#s = input()
a = [int(i) for i in readline().split()]
#m = [[int(i) for i in readline().split()] for _ in range(n)]

MOD = 1000000007

ans = 1
res = [0,0,0]

for ai in a:
    c = res.count(ai)
    ans *= c
    ans %= MOD
    for i in range(3):
        if res[i] == ai:
            res[i] += 1
            break

print(ans)





Measured memory_bytes: 13304
n, m = map(int, input().split())
ab_list = [list(map(int, input().split())) for _ in range(m)]
ab_list.reverse()
par = list(range(n))
group_elems = [1] * n

def root(i):
    if par[i] == i:
        return i
    r = root(par[i])
    par[i] = r
    return r

counts = [0] * m
for i, (a, b) in enumerate(ab_list):
    a -= 1
    b -= 1
    root_a = root(a)
    root_b = root(b)
    if root_a == root_b:
        counts[i] = counts[i-1]
    else:
        elems_a = group_elems[root_a]
        elems_b = group_elems[root_b]
        if i > 0:
            counts[i] = counts[i-1] + elems_a * elems_b
        else:
            counts[i] = 1
        if elems_a > elems_b:
            par[root_b] = root_a
        else:
            par[root_a] = root_b
        group_elems[root_a] = elems_a + elems_b
        group_elems[root_b] = elems_a + elems_b

nC2 = n * (n - 1) // 2
for c in reversed(counts[:-1]):
    print(nC2 - c)
print(nC2)


Measured memory_bytes: 41680
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 998244353;

#define read_int(X) \
    ll X;           \
    scanf("%lld\n", &X);

#define read_two_int(X, Y) \
    ll X, Y;               \
    scanf("%lld %lld\n", &X, &Y);

#define read_three_int(X, Y, Z) \
    ll X, Y, Z;                 \
    scanf("%lld %lld %lld\n", &X, &Y, &Z);

#define read_four_int(X, Y, Z, W) \
    ll X, Y, Z, W;                \
    scanf("%lld %lld %lld %lld\n", &X, &Y, &Z, &W);

int main()
{
    read_two_int(N, K);
    vector<pair<ll, ll>> lr(K);
    for (ll i = 0; i < K; i++)
    {
        scanf("%lld", &(lr[i].first));
        scanf("%lld", &(lr[i].second));
    }

    vector<ll> dp(N, 0);
    dp[0] = 1;
    for (ll i = 1; i < N; i++)
    {
        ll sum = 0;
        for (ll k = 0; k < K; k++)
        {
            ll diff = 0;
            if (i - lr[k].first >= 0)
                diff = dp[i - lr[k].first];
            if (i - lr[k].second - 1 >= 0)
                diff -= dp[i - lr[k].second - 1];
            sum += diff;
            sum %= mod;
        }

        dp[i] = sum + dp[i - 1];
    }
    ll ans = dp[N - 1] - dp[N - 2];

    printf("%lld\n", ans);
}


Measured memory_bytes: 4820
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN=1e5+10;
int a[MAXN];
int m,n,l,p,k,ans,tot;
int inline read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
	n=read();
	k=read();
	ans=n%k;
	if (ans) ans=1;
	printf("%d",ans);


	return 0;
}



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

int main(){
    string s="";
    rep(i,3){
        rep(j,3){
            char c;cin >> c;
            if(i-j==0){
                s+=c;
            }
        }
    }
    cout << s << endl;
}

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

int main() {

string s;
  int min=-1,max;
  cin>>s;
  
  for(int i=0; i<s.length();i++){
    if(s.at(i)=='A'&&min<0){min =i;}
    if(s.at(i)=='Z'){max=i;}}
  
	
	cout<<max-min+1<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
   Scanner S = new Scanner(System.in);

      while(true){

      int x = S.nextInt();
      int y = S.nextInt();

      if (x == 0 && y ==0)break;

      if(x < y) System.out.printf("%d %d\n",x, y);

      else System.out.printf("%d %d\n",y, x);

      }
 }
}



Measured memory_bytes: 41096
from collections import Counter

S = input()

if Counter(S[2:-1])['C'] == 1:
    flag = True
else:
    flag = False

T = ''
for s in S:
    if s != 'C':
        T += s

if S[0] == 'A' and flag and T[1:].islower():
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3444
#include <stdio.h>

int main(void){
  int a=0;
  scanf("%d",&a);
  if(a==0 || a==1){
    printf("1\n");
    return 0;
  }
  int i=0;
  int m=1;
  int n=1;
  int ch=0;
  for(i=0;i<a-1;i++){
    n+=m;
    ch=m;
    m=n;
    n=ch;
  }
  printf("%d\n",m);
  return 0;
}

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

using namespace std;

int main(void){
    long long N;
    cin>>N;
    long long mini=1000000000000;
    for(int a=1;a<=sqrt(N);a++){
        long long result;
        if(N%a==0) result=a+N/a-2;
        mini=min(result,mini);
    }
    cout<<mini<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,m = map(int, input().split())
ns = defaultdict(set)
for _ in range(m):
    u,v,c = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add((c,v))
    ns[v].add((-c,u))
vals = [None] * n
def dijkstra(start):
    h = [start]
    vals[start] = 0
    ans = True
    while h:
        u = h.pop()
        for d, v in ns[u]:
            if vals[v] is None:
                vals[v] = vals[u]+d
                h.append(v)
            else:
                if vals[v]!=vals[u]+d:
                    return False
    return ans

for start in range(n):
    if vals[start] is not None:
        continue
    res = dijkstra(start)
    if not res:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 134944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    string S; cin >> S;

    ll ka = 0,  kak = 0;
    
    rep(i, S.size()) {
        if (S[i] == '0') { ++ka; }
        else if (S[i] == '1') { ++kak; }
    }

    cout << 2 * min(ka, kak) << endl;
}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

int v[100500];
int w[200500];

long long dp[100500];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, W;
    cin >> n >> W;
    forn (i, n)
        cin >> w[i] >> v[i];

    dp[0] = 0;
    for (int i = 1; i <= 100400; i++) {
        dp[i] = 1e18;
    }

    forn(i, n)
    for (int j = 100400; j >= 1; j--)
        if (j >= v[i])
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);

    int ans = 0;
    forn(i, 100400)
        if (dp[i] <= W)
            ans = max(ans, i);

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N;
    cin >> N;
    long long int i,j;
    long long int ans = 1e12+10;
    for(i=1;i*i<=N;i++){
        if(N%i==0){
            j=N/i;
            ans = min(ans,i+j-2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		BigInteger a = sc.nextBigInteger(), b = sc.nextBigInteger();
		System.out.println(a.compareTo(b)<0 ? "LESS" : a.compareTo(b)==0 ? "EQUAL" : "GREATER");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35788
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> w(n), v(n);
    rep(i, n)
    {
        cin >> w[i] >> v[i];
    }

    const int VMAX = 100'000;
    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(VMAX + 1));

    irep(i, n) irep(j, VMAX)
    {
        if (i == 0) {
            dp[i][j] = (j == 0 ? 0 : c + 1);
        } else {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i - 1] >= 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
            }
        }
    }

    rirep(i, VMAX)
    {
        if (dp[n][i] <= c) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define ll long long
using namespace std;

int main(){
	int N;
	cin >>N;
	struct P{
		int x;
		int y;
		int h;
	};
	P p[N];
	P sample;
	for(int i=0;i<N;i++){
		cin>>p[i].x>>p[i].y>>p[i].h;
		if(p[i].h>=1){
			sample=p[i];
		}
	}

	vector<P> ansPoss;
	for(int x=0;x<=100;x++){
		for(int y=0;y<=100;y++){
			bool flag=true;
			int V=sample.h+abs(sample.x-x)+abs(sample.y-y);
			V=max(V,0);
			for(int i=0;i<N;i++){
				if(p[i].h!=max(V-abs(p[i].x-x)-abs(p[i].y-y),0)){
					flag=false;
				}
			}
			if(flag==true){
				ansPoss.push_back(P{x,y,V});
			}
		}
	}
	P ans=ansPoss[0];
	cout<<ans.x <<" "<<ans.y <<" "<<ans.h <<endl;
	return 0;
}


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

int main() {
    int cnt[26] = {0};
    string w; cin >> w;
    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i < w.size(); i++) {
            if (w[i]==c) cnt[c - 'a']++;
        }
    }

    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 == 1) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}

Measured memory_bytes: 256
N = int(input())
sp_list = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    sp_list.append((s,p,i+1))
sp_list = sorted(sp_list, key=lambda x:x[1], reverse=True)
sp_list = sorted(sp_list, key=lambda x:x[0])

for i in sp_list:
    print(i[2])

Measured memory_bytes: 3060
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
c=0
for j in range(n):
  if l[j+1][0]-l[j][0]<abs(l[j+1][1]-l[j][1])+abs(l[j+1][2]-l[j][2]) or (l[j+1][0]-l[j][0]+abs(l[j+1][1]-l[j][1])+abs(l[j+1][2]-l[j][2]))%2==1:
    c=1
    break
if c==0:print('Yes')
else:print('No')

Measured memory_bytes: 27324
'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,K+1):
    for j in range(len(s)-i+1):
      d.append(s[j:j+i])
  ans=sorted(list(set(d)))
  print(ans[K-1])
  return
main()

#解説AC

Measured memory_bytes: 11208
#include<stdio.h>
int main(void){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %lf", d, r, f);
	return 0;
}


Measured memory_bytes: 2048
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let (n, max_w) = get!(usize, usize);
    let vw = get!(usize, usize; n);

    let mut dp = vec![0; max_w + 1];

    for &(v, w) in &vw {
        for i in (w..max_w + 1).rev() {
            dp[i] = max(dp[i], dp[i - w] + v);
        }
    }

    println!("{}", dp.iter().max().unwrap());
}



Measured memory_bytes: 5032
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        long[] h = new long[n];
        for(int i = 0;i < n;i++) {
            h[i] = stdIn.nextLong();
        }

        int count = 0;
        int c = 0;
        for(int i = 1; i < n;i++) {
            if(h[i] < h[i-1]){
                if(h[i-1] - h[i] >= 2) {
                    System.out.println("No");
                    System.exit(0);
                }else {
                    if(count >= 1) {
                        if(h[i] < h[c]){
                            System.out.println("No");
                            System.exit(0);
                        }else {
                            c = i;
                        }
                    }else {
                        count++;
                        c = i;
                    }
                }
            }
        }
        System.out.println("Yes");
    }

}

Measured memory_bytes: 57160
import java.io.*;
import java.util.*;

class Main {

  public static void main(String[] args) {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String[] nwInput = strLine.split(" ");
      int n = Integer.parseInt(nwInput[0]);
      int w = Integer.parseInt(nwInput[1]);
      int[][] wv = new int[n][2];
      for(int i = 0 ; i < n ; i++) {
      	strLine = br.readLine();
        wv[i][0] = Integer.parseInt(strLine.split(" ")[0]);
        wv[i][1] = Integer.parseInt(strLine.split(" ")[1]);
      }
      long[][] dp = new long[w+1][n+1];
      for(int i = 0 ; i <= n ; i++) {
      	dp[0][i] = 0;
      }
      for(int i = 0; i <= w; i++) {
      	dp[i][0] = 0;
      }
      for(int i = 1 ; i <= w; i++) {
        for(int j = 1 ; j <= n; j++) {
          dp[i][j] = dp[i][j-1];
          if(i >= wv[j-1][0]) {
          	dp[i][j] = Math.max(dp[i][j], dp[i-wv[j-1][0]][j-1] + wv[j-1][1]);
          }
          //System.out.print(dp[i][j] + " ");
        }
        //System.out.println();
      }
      //System.out.println("final " + dp[w][n]);
      System.out.println(dp[w][n]);
    } catch(Exception ex) {
    
    }
  }
}

Measured memory_bytes: 134656
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	rep(i, 0, n)cin >> a[i];
	vector<ll>b(n);
	ll ma = 0;
	ll mi = LLONG_MAX;
	rep(i, 0, n) {
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	cout << ma-mi;
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	ll N;
	cin >> N;
	set<string> s;
	for (ll n = 0; n < N; n++) {
		string sin;
		cin >> sin;
		s.insert(sin);
	}
	if (s.size() == 3)cout << "Three" << endl;
	else cout << "Four" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
/*

memory assignment

0:  !"#$%&'()* 33-42
1:  +,-./01234 43-52
2:  56789:;<=> 53-62
3:  ?@ABCDEFGH 63-72
4:  IJKLMNOPQR 73-82
5:  STUVWXYZ[\ 83-92
6:  ]^_`abcdef 93-102
7:  ghijklmnop 103-112
8:  qrstuvwxyz 112-122
9:  {|}~       123-126
*/


const int SIZE = 10;
int bound[] = {42,52,62,72,82,92,102,112,122};
int idx = 0;
int mem[SIZE];


int boundfor(char c){
  for(int i = 0; i < 9; i++)
    if((int)c < bound[i]) return i;
  return 9;
}

void print(char c){
  int pos = boundfor(c);

  if(pos > idx) while(idx!=pos){cout << ">"; idx++;}
  if(pos < idx) while(idx!=pos){cout << "<"; idx--;}

  if(mem[idx] > (int)c) while(mem[idx]!=c){cout << "-"; mem[idx]--;}
  if(mem[idx] < (int)c) while(mem[idx]!=c){cout << "+"; mem[idx]++;}
  cout << ".";
}

int main(){
  string s;  
  cin >> s;
  for(int i = 0; i < (int)s.length(); i++) print(s[i]);
  return 0;
}

Measured memory_bytes: 1164
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)

	if a <= 9 && b <= 9 {
		fmt.Println(a * b)
	} else {
		fmt.Println(-1)
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
import math

n, d = map(int, input().split())
points = [0] * n
for i in range(n):
    x = [int(x) for x in input().split()]
    points[i] = x
    
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        dist = 0
        for k in range(d):
            dist += (points[i][k] - points[j][k])**2
        ans = math.sqrt(dist)
        if ans.is_integer():
                count += 1
                
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

ll gcd(ll x, ll y)
{
   while(x!=y)
   {
       if(x>y) x=x-y;
       else
       	y=y-x;
   }
   return x;
   //辗转相除法
}

int main() {
	int n; cin >> n;
	long long sum = 0;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			for(int k = 1; k <= n; ++k){
				int x = gcd(j, k);
				int y = gcd(x, i);
				sum += y;
			}
		}
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 3200
import itertools as it
import copy

def main():
    H, W, K = map(int, input().split())
    C = []
    for h in range(H):
        C.append(list(input()))
    
    ans = 0
    Hlist = []
    Wlist = []

    for i in range(H+1):
        Hlist += list(it.combinations([x for x in range(H)], i))

    for j in range(W+1):
        Wlist += list(it.combinations([y for y in range(W)], j))

    for hli, wli in it.product(Hlist, Wlist):
        Ccopy = copy.deepcopy(C)
        for h in hli:
            Ccopy[h] = [0]*W
        
        for l in range(len(Ccopy)):
            for w in wli:
                Ccopy[l][w] = 0
        
        num = 0
        for li in Ccopy:
            num+= li.count('#')

        if num == K:
            ans += 1
    
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 73820