akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    string s,t;
    cin >> s >> t ;
    sort(s.begin(), s.end() );
    sort(t.begin(), t.end() );
    reverse(t.begin(), t.end() ) ;
    if(s < t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long mod=1000000007;
int main(){
    long long A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    long long C=abs(A-B);
    
    
    long long Z=V-W;
  
      if(Z<=0) cout<<"NO"<<endl;
  else{
    long long N=C/Z;
    long long M=C%Z;
  
    if(T>N)cout<<"YES"<<endl;
    else if(T==N&&M==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    }
    



}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	int n;
	cin >> n;

	vector<double> p(n);
	for(int i = 0; i < n; i++)
		cin >> p[i];

	vector<vector<double> > dp(n+1, vector<double>(n+1, 0));
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		dp[i][0] = dp[i-1][0] * (1 - p[i-1]);
		for(int j = 1; j <= n; j++){
			dp[i][j] = dp[i-1][j] * (1 - p[i-1]) + dp[i-1][j-1] * p[i-1];
		}
	}

	double ans = 0;
	for(int i = n; i <= n; i++){
		for(int j = (i+2)/2; j <= i; j++){
			ans += dp[i][j];
		}
	}

	// for(int i = 0; i <= n; i++){
	// 	for(int j = 0; j <= n; j++){
	// 		cout << dp[i][j] << " ";
	// 	}
 //      cout << endl;
	// }

	cout <<fixed <<setprecision(12)<< ans << "\n";

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

int n, m;
const int N = 1e5;
char s[N + 7];
char t[N + 7];

int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  long long len = (long long) n * m;
  len /= __gcd(n, m);
  
  cin >> s;
  cin >> t;
  
  map <int, char> mapa;
  
  long long ll = len / n;
  for (int i = 0; s[i]; ++i) {
    mapa[ll * i + 1] = s[i];
  }

  bool ok = 1;
  
  ll = len / m;
  for (int i = 0; t[i]; ++i) {
    auto it = mapa.find(ll * i + 1);
    if (it != mapa.end() && (*it).second != t[i]) ok = 0;
  }
  
  if (ok) cout << len << endl;
  else cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 4736
# fLIP
n,m,k = list(map(int, input().split()))

f = False

for i in range(n//2+2):
    for j in range(m//2+2):
        t = i*j + (n-i)*(m-j)
        if ( t==k or n*m-t==k ):
            f = True
            break
if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
A = list(map(int, input().split()))
result = 0
for i in range(N):
    for j in range(i):
        if A[i-j-1] > A[i-j]:
            tmp = A[i-j]
            A[i-j] = A[i-j-1]
            A[i-j-1] = tmp

for i in range(K):
    result += A[i]

print(result)



Measured memory_bytes: 9116
let S = readLine()!.characters.map { String($0) }
let K = Int(readLine()!)!

func minReplacement(s: [String]) -> Int {
  var count = 0
  
  var left = 0
 
  while left < s.count {
    var right = left
    while right < s.count && s[left] == s[right] {
      right += 1
    }
    count += (right - left) / 2
    left = right
  }
  return count
}

if Set(S).count <= 1 {
  print(S.count * K / 2)
} else {
	let first = minReplacement(S)
	let second = minReplacement(S + S)
  	let diff = second - first
  	print(first + diff * (K - 1))
}

Measured memory_bytes: 6128
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
#define mod 998244353
#define N 1000010
using namespace std;
string s[N];
char ans[N];
int n;
void bfs(int x,int a,int b,int c)
{
    if(x>n)
    {
        cout<<"Yes"<<endl;
        for(int i=1; i<=n; i++)
        {
            cout<<ans[i]<<endl;
        }
        exit(0);
    }
    if(s[x]=="AB")
    {
        if(a)
        {
            ans[x]='B';
            bfs(x+1,a-1,b+1,c);
        }
        if(b)
        {
            ans[x]='A';
            bfs(x+1,a+1,b-1,c);
        }
    }
    if(s[x]=="AC")
    {
        if(a)
        {
            ans[x]='C';
            bfs(x+1,a-1,b,c+1);
        }
        if(c)
        {
            ans[x]='A';
            bfs(x+1,a+1,b,c-1);
        }
    }
    if(s[x]=="BC")
    {
        if(b)
        {
            ans[x]='C';
            bfs(x+1,a,b-1,c+1);
        }
        if(c)
        {
            ans[x]='B';
            bfs(x+1,a,b+1,c-1);
        }
    }
}
int main()
{
    int a,b,c;
    cin>>n>>a>>b>>c;
    for(int i=1;i<=n;i++)
        cin>>s[i];
    bfs(1,a,b,c);
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 42776
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int cnt2 =0 , cnt4 = 0, cnt = 0;
    for(int i = 0; i < N; i++){
        if(a[i] % 4 == 0) cnt4++;
        else if(a[i] % 2 == 0) cnt2++;
        else cnt++;
    }
    if(cnt2 == 0 && cnt <= cnt4 + 1) cout << "Yes" << endl;
    else if(cnt <= cnt4) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << ceil((double)(a + b) / 2) << "\n";
	return 0;
}

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

using namespace std;
typedef long long ll;

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

	int n;
	cin >> n;
	bool allEven = true;
	while(n--) {
		int x;
		cin >> x;
		allEven &= x%2 == 0;
	}
	cout << (allEven ? "second" : "first");
	return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 S              PIC X(11).
01 T              PIC X(11).

PROCEDURE DIVISION.
  ACCEPT S.
  ACCEPT T.

  IF S = T(1 : FUNCTION STORED-CHAR-LENGTH(T) - 1)
      DISPLAY "Yes"
  ELSE
      DISPLAY "No"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3736
w,h,n = map(int, input().split())
min_x = 0
min_y = 0
max_x = w
max_y = h
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    min_x = max(min_x, x)
  elif a == 2:
    max_x = min(max_x, x)
  elif a == 3:
    min_y = max(min_y, y)
  elif a == 4:
    max_y = min(max_y, y)
print(max(0, max_x - min_x) * max(0, max_y-min_y))

Measured memory_bytes: 3064
sub f{$p[$_]=$_-(local$_=$p[$_])?&f:$_}map{@p=0..$`;$p[f$_=/ /*$']=f$_=<>for 1..$_;@{$|--}=map f,@p}<>=~/ \d+/g;print$$_,$/for map{++${$t=\${$0[$_]}{$1[$_]}};$t}1..$`

Measured memory_bytes: 164736
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ll Mod = 1000000007;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
struct G {
	int x, y;
};
bool operator<(G a, G b) { 
	if(a.y!=b.y)return a.y < b.y;
	return a.x < b.x;
}
bool operator>(G a, G b) {
	if (a.y != b.y)return a.y > b.y;
	return a.x > b.x;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
int a[100], n;
signed main() {
	a[0] = 2, a[1] = 1;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[n] << endl;
	getchar(); getchar();
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 3");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 4");
            //7
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6 6");
            //12
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int A = wkArr[0];
        int B = wkArr[1];

        int Answer = 0;

        Action wkAct = () =>
        {
            if (A < B) {
                Answer += B;
                B--;
            }
            else {
                Answer += A;
                A--;
            }
        };

        wkAct();
        wkAct();
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}

Measured memory_bytes: 256
read a b c
read k
if [ $a -ge $b -a $a -ge $c ]
then
	p=$[a*2**k+b+c]
elif [ $b -ge $c -a $b -ge $a ]
then
	p=$[a+b*2**k+c]
else
	p=$[a+b+c*2**k]
fi
echo $p

Measured memory_bytes: 376
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.ElementType;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {



        int A = nextInt();
        long B = nextLong();
        long N = nextLong();
        long ans = 0;
        if(N>=B) {
            ans = floor(A, B, B - 1);
        }else {
            ans = floor(A,B,N);
        }
        
        System.out.println(ans);

    }
    private static long floor(int A,long B,long x){

        return (long) (Math.floor(A*x/B)-A*Math.floor(x/B));

    }
    private static final InputStream in = System.in;
    private static final byte[] buffer = new byte[1024];
    private static int ptr = 0;
    private static int buflen = 0;
    private static boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private static int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public static boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public static long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public static int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}

}


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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

const double PI = acos(-1.0);

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

int a,b;

int main()
{
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;

}




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

int main() {
	int a, b;
	cin >> a; 
  	cin >> b;
 if ((a+b)% 2 == 0)
 {
  	cout << (a+b)/2 << endl;
 }
  else
  {
    cout << (a+b)/2+1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
ll i;



int main(){
   ll ans=1LL;
   ll N;
   cin>>N;
   
   map<ll,ll>bsos; 
   ll kari=N-1;
   for(ll j=2;j*j<=N-1;j++){
      while(kari%j==0){
         kari/=j;
         if(bsos.count(j))bsos[j]++;
         else bsos[j]=1LL;
      }
   }
   if(kari!=1)bsos[kari]=1;
   kari=N;
   
   for(auto itr=bsos.begin();itr!=bsos.end();itr++){
      ans*=(1+itr->second);
   }
   for(ll j=2;j*j<=N;j++){
      bool jud=false;
      ll kari=N;
      while(kari%j==0){
         kari/=j;
         jud=true;
      }
      if(jud&&kari%j==1)ans++;
      kari=N;
      if(jud&&j!=N/j){
         ll p=N/j;
         while(kari%p==0)kari/=p;
         if(kari%p==1)ans++;
      }
      
      
      
   }
   cout<<ans<<endl;

   
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var x []byte
	fmt.Scan(&x)

	var cnt int
	for i := range x {
		if x[i] == '1' {
			cnt++
		}
	}
	ms := make([]int, 0)
	ms = append(ms, cnt+1)
	if cnt > 1 {
		ms = append(ms, cnt-1)
	}
	as := make([][]int, n)
	for i := range as {
		as[i] = make([]int, len(ms))
		if i == n-1 {
			for j := range ms {
				as[i][j] = 1
			}
		}
	}
	rs := make([]int, len(ms))
	for i := range ms {
		rs[i] = 0
	}

	for i := n - 1; i >= 0; i-- {
		for j := range ms {
			mod := ms[j]
			if x[i] == '1' {
				rs[j] += as[i][j]
				rs[j] %= mod
			}
			if i > 0 {
				as[i-1][j] = (as[i][j] * 2) % mod
			}
		}
	}

	for i := range x {
		if x[i] == '1' {
			if ms[0] == 2 {
				fmt.Println(0)
				continue
			}
			num := (rs[1] - as[i][1]) % ms[1]
			if num < 0 {
				num += ms[1]
			}
			fmt.Println(calc(num) + 1)
		} else {
			num := (rs[0] + as[i][0]) % ms[0]
			fmt.Println(calc(num) + 1)
		}
	}
}

func calc(num int) int {
	if num == 0 {
		return 0
	}
	cn := num
	var cnt int
	for i := 0; i < 20; i++ {
		if cn%2 == 1 {
			cnt++
			cn -= cn % 2
		}
		cn /= 2
		if cn == 0 {
			break
		}
	}
	return calc(num%cnt) + 1
}


Measured memory_bytes: 12188
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> h(n);
    long i;
    long cnt=0;
    long m=0;
    for(i=0; i<n; i++) {
        scanf("%ld", &h[i]);
        if(m<=h[i]) cnt++;
        m = MAX(m, h[i]);
    }
    printf("%ld\n", cnt);
 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int P=998244353;
int n;
struct pos{
	int x,y;
}ps[1007];
int ep=0,f[1007],sz[1007];
int gf(int x){while(x!=f[x])x=f[x]=x[f][f];return x;}
struct edge{
	int a,b;
	int v;
	bool operator<(const edge&e)const{return v<e.v;}
	void cal(){
		int x=gf(a),y=gf(b);
		if(x!=y)f[x]=y,sz[y]+=sz[x];
	}
}es[207*207];
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int pw[1007],ans;
int main(){
	scanf("%d",&n);
	pw[0]=1;
	for(int i=1;i<=n;++i)pw[i]=pw[i-1]*2%P;
	ans=(pw[n]-n-1)%P;
	for(int i=0;i<n;++i)scanf("%d%d",&ps[i].x,&ps[i].y);
	for(int i=0;i<n;++i){
		for(int j=0;j<i;++j){
			int x=ps[i].x-ps[j].x,y=ps[i].y-ps[j].y;
			int g=gcd(x,y);
			x/=g,y/=g;
			if(!x)y=1;
			if(!y)x=1;
			if(x<0)x=-x,y=-y;
			es[ep++]=(edge){i,j,x*30000+y};
		}
	}
	std::sort(es,es+ep);
	for(int i=0,j=0;i<ep;i=j){
		for(int a=0;a<n;++a)sz[f[a]=a]=1;
		for(;j<ep&&es[i].v==es[j].v;es[j++].cal());
		for(int a=0;a<n;++a)if(f[a]==a&&sz[a]>1)ans=(ans-pw[sz[a]]+sz[a]+1)%P;
	}
	printf("%d\n",(ans%P+P)%P);
	return 0;
}

Measured memory_bytes: 512
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public int nextInt(){
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        MyScanner sc = new MyScanner();
        int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        int c = 0, d = 0, e = 0;
        for(int i = 0; i < n; ++i){
            int s = sc.nextInt();
            if(s <= a){
                ++c;
            }else if(s <= b){
                ++d;
            }else{
                ++e;
            }
        }
        int min = c;
        if(min > d){
            min = d;
        }
        if(min > e){
            min = e;
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
using R = double;
using P = complex<R>;
#define x real()
#define y imag()
const R eps = 1e-9,PI = acos(-1);

bool equal(R a,R b){return abs(b-a)<eps;}
bool equal0(R a){return equal(a,0.0);}

P operator*(const P& p,const R& d){
    return P(p.x*d,p.y*d);
}

istream &operator>>(istream& is,P& p){
    R a,b;
    is >> a >> b;
    p = P(a,b);
    return is;
}

ostream &operator<<(ostream& os,P& p){
    os << fixed << setprecision(10) << p.real() << " " << p.imag();
}
//内積
double dot(P a,P b) {return (conj(a)*b).real();}
//外積
double cross(P a,P b) {return (conj(a)*b).imag();}

struct L{
    P a,b;
    L(P a,P b):a(a),b(b){}
    L(R A,R B,R C){
        if(equal(A,0)) a = P(0,C/B),b = P(1,C/B);
        else if(equal(B,0)) b = P(C/A,0),b = P(C/A,1);
        else a = P(0,C/B),b = P(C/A,0);
    }
};

//pをbに射影
P projection(P p,P b) {return b*dot(p,b)/norm(b);}

//pとp1 to p2 に射影
P projection(L l,P p){
    p -= l.a; l.b -= l.a;
    P proj = projection(p,l.b);
    return l.a+proj;
}

struct S:L{
    S(P a,P b):L(a,b){}
};

//点の回転方向を判定
int ccw(P p0,P p1,P p2){
    p1 -= p0,p2 -= p0;
    if(cross(p1,p2)>eps) return 1; //"COUNTER_CLOCKWISE"
    if(cross(p1,p2)<-eps) return -1; //"CLOCKWISE"
    if(dot(p1,p2)<0) return 2; //"ONLINE_BACK"
    if(norm(p1)<norm(p2)) return -2; //"ONLINE_FRONT"
    return 0; //"ON_SEGMENT"
}

bool is_parallel(L l1,L l2){
    return equal0(cross(l1.b-l1.a,l2.b-l2.a));
}

bool is_orthogonal(L l1,L l2){
    return equal0(dot(l1.b-l1.a,l2.b-l2.a));
}

//pをlに関して対称移動
P reflection(L l,P p){
    P pj = projection(l,p);
    return 2.0*pj-p;
}

//pがl上にあるか
bool is_online(L l,P p){
    return abs(ccw(l.a,l.b,p))!=1;
}

bool is_onsegment(S s,P p){
    return ccw(s.a,s.b,p)==0;
}

//線分の交差判定
bool intersect(S s,S t){
    return ccw(s.a,s.b,t.a)*ccw(s.a,s.b,t.b)<=0 && ccw(t.a,t.b,s.a)*ccw(t.a,t.b,s.b)<=0;
}

//2直線の交点
P crosspoint(L l1,L l2){
    R a = cross(l1.b-l1.a,l2.b-l2.a);
    R b = cross(l1.b-l1.a,l1.b-l2.a);
    if(equal0(abs(a)) && equal0(abs(b))) return l2.a;
    return l2.a+(l2.b-l2.a)*b/a;
}

P crosspoint(S s1, S s2){
    return crosspoint(L(s1),L(s2));
}

R dist(P a,P b){
    return abs(a-b);
}

R dist(L l,P p){
    return abs(p-projection(l,p));
}

R dist(L l1,L l2){
    return is_parallel(l1,l2)? 0:dist(l1,l2.a);
}

R dist(S s,P p){
    P r = projection(s,p);
    if(is_onsegment(s,r)) return abs(r-p);
    return min(dist(s.a,p),dist(s.b,p));
}

R dist (S s1,S s2){
    if(intersect(s1,s2)) return 0;
    return min({dist(s1,s2.a),dist(s1,s2.b),
    dist(s2,s1.a),dist(s2,s1.b)});
}

using Polygon = vec<P>;

R area_of_polygon(Polygon v){
    int n = v.size();
    R res = 0;
    for(int i=0;i+2<n;i++){
        res += cross(v[i+1]-v[0],v[i+2]-v[0]);
    }
    return res/2;
}

int main(){
    int N;
    cin >> N;
    Polygon pol(N);
    for(int i=0;i<N;i++){
        cin >> pol[i];
    }
    R ans = area_of_polygon(pol);
    cout << fixed << setprecision(1) << ans << endl;
}


Measured memory_bytes: 3300
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    dis = 4 * 10**8
    for i in range(m):
        (c, d) = cd[i]
        tmp = abs(a-c)+abs(b-d)
        if dis > tmp:
            ans = i
            dis = tmp
    print(ans+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int x;
  cin>>x;
  int a=gcd(x,360);
  cout<<360/a<<endl;
}

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

public class Main {

    String fileName = "";

    void solve() throws IOException {
        int n = readInt();
        char[] a = readString().toCharArray();
        for(int i=0;i<n/2;i++){
            char tmp = a[i];
            a[i] = a[n - 1 - i];
            a[n - 1 - i] = tmp;
        }
        int totalWhite = 0;
        for (int i = 0; i < n; i++) {
            totalWhite += (a[i] == '.' ? 1 : 0);
        }
        int ans = 1000_000_000;
        int leftAns = 0;
        for (int i = -1; i < n; i++) {
            if (i >= 0) {
                if (a[i] == '.') {
                    totalWhite--;
                    leftAns++;
                }
            }
            int leftSize = n - 1 - i;
            ans = Math.min(ans, leftAns + leftSize - totalWhite);
        }
        out.println(ans);
    }


    public static void main(String[] args) throws NumberFormatException, IOException {
        new Main().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    }

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";

    Main() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken(delim);
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    int[] readIntArray(int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = readInt();
        }
        return a;
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }

    void sortIntArray(int[] a) {
        Integer[] arr = new Integer[a.length];
        for (int i = 0; i < a.length; i++) {
            arr[i] = a[i];
        }
        Arrays.sort(arr);
        for (int i = 0; i < a.length; i++) {
            a[i] = arr[i];
        }
    }


}

Measured memory_bytes: 27216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> P(N);
    int a, b, ans = 0;
    rep(i, N)
    {
        cin >> a >> b;
        P[i] = {a, b};
    }
    sort(all(P));
    vvint DP(N + 1, vint(T));

    rep2(i, 1, N + 1)
    {
        rep(j, T)
        {
            DP[i][j] = DP[i - 1][j];
            ans = max(ans, DP[i][j] + P[i - 1].second);
            if (j >= P[i - 1].first)
                DP[i][j] = max(DP[i][j], DP[i - 1][j - P[i - 1].first] + P[i - 1].second);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 35712
N=int(input())
A=list(map(int,input().split()))

mod=10**9+7
ans=0
cnt=[[0]*2 for _ in range(60)]

for x in A:
    for i in range(60):
        a=x%2
        x//=2
        cnt[i][a]+=1

for p,q in enumerate(cnt):
    i,j=q
    ans+=((i*j)%mod)*pow(2,p,mod)
    ans%=mod
    
print(ans)


Measured memory_bytes: 125496
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int n;
int *S;

bool find(int t) {
	int left = -1;
	int right = n;

	while (right - left > 1) {
		int x = (right + left) / 2;
		if (S[x] < t) {
			left = x;
		}
		else {
			right = x;
		}
	}
	if (S[right] == t) {
		return true;
	}
	return false;
}
int main() {
	int count = 0;
	cin >> n;
	S = new int[n];
	for (int i = 0; i < n;i++) {
		string str; cin >> str;
		S[i] = atoi(str.c_str());
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int t;
		string str; cin >> str;
		t = atoi(str.c_str());
		if (find(t)) {
			count++;
		}
	}

	delete[] S;

	cout << count << endl;

	return 0;
}

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

int main() {
  int N;//データの数
  
  int count = 0;//何種類あるかを数える関数
  
  
    
  //　入力部
  cin >> N;
  vector <int> data(N) ;//　余裕をもって150個のデータを用意
  
  for(int i = 0; i < N ;i++){
  	cin >> data.at(i);  
  }
  
  //　データの並び替え
  sort(data.begin(),data.end());
    
  // 三つの組み合わせを決める
  if (N >=3){
  for(int i= 0; i<N-2;i++){
    for(int k=i+1; k<N-1;k++){
      
      for(int j=k+1;j<N;j++){
        
        if (data.at(i) != data.at(k) && data.at(j) != data.at(k) && (data.at(i) + data.at(k)) > data.at(j))
          
            count ++;
            }
            }
            }
  }
        cout << count <<endl;

     
}



Measured memory_bytes: 3612
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]

N = int(input())
r = [[0 for i in range(3)] for j in range(N)]
rsorted = [[0 for i in range(3)] for j in range(N)]

for i in range(N):
	r[i][0], r[i][1] = map(int, input().split())
	r[i][2] = r[i][0] + r[i][1]

rsorted = sorted(r, key = itemgetter(2), reverse=True)

a = 0
b = 0
turn = True

for i in range(N):
	if turn:
		a += rsorted[i][0]
	else:
		b += rsorted[i][1]
	turn = not(turn)
print(a-b)
		
		

Measured memory_bytes: 38684
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

signed main() {
	char s, d;
	cin >> s >> d;
	if (s > d)cout << '>' << endl;
	else if (s == d)cout << '=' << endl;
	else cout << '<' << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<string.h>
using namespace std;
int main() {
	int n,i;
	cin >> n;
	int s[150];
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	int ans = 0;
	for (i = 0; i < n; i++) {
		int cnt = 0;
		while (1) {
			if (s[i] == s[i + 1]) {
				i++;
				cnt++;
				if (cnt % 2 == 1) {
					ans++;
				}
			}
			else {
				break;
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
number = int(input())
if 400 <= number <= 599:
  print(8)
elif 600 <= number <= 799:
  print(7)
elif 800 <= number <= 999:
  print(6)
elif 1000 <= number <= 1199:
  print(5)
elif 1200 <= number <= 1399:
  print(4)
elif 1400 <= number <= 1599:
  print(3)
elif 1600 <= number <= 1799:
  print(2)
elif 1800 <= number <= 1999:
  print(1)


Measured memory_bytes: 9176
import sys

a, b, c = map(int, sys.stdin.readline().split())

def main():
    if c - a - b <= 2:
        return 'No'
    l = 4 * a * b
    r = pow(c - a - b, 2)
    return 'Yes' if r > l else 'No'

if __name__ == "__main__":
    ans = main()
    print(ans)

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<string> n;
  int N,Q;
  cin >> N >> Q;
  string s;
  for(int i=0;i<N;++i){
    cin >> s;
    n.push_back(s);
  }
  sort(n.begin(),n.end());
  //for(auto str:n) cout << str << '\n';
  string out;
  for(int i=0;i<n.size();++i){
    out += n[i];
  }
  cout << out;
  return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

pub fn divisor(n: u32) -> Vec<u32> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res.sort();
    res
}

fn main() {
    input! {
        n: u32,
    }
    let res = (1..n+1).filter(|i| {
        i % 2 != 0 && divisor(*i).len() == 8
    }).count();
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    string s = "ATCG";
    cout << s[s.find(c) ^ 1];
}


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

int N, Q;

int main() {

	while ( cin >> N >> Q && N ) {

		map<int,string> start;
		map<string,int> finish;
		string name;

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

			int local, western;

			cin >> name >> local >> western;

			start[western - local + 1] = name;

			if ( finish[name] < western ) {

				finish[name] = western;

			}

		}

		for ( int i = 0; i < Q; i++ ) {

			int western;

			cin >> western;

			bool ok = false;

			for ( map<int,string>::iterator s = start.begin(); s != start.end(); s++ ) {

				if ( s->first <= western && finish[s->second] >= western ) {

					cout << s->second << " " << western - s->first + 1 << endl;
					ok = true;
					break;

				}

			}

			if ( ! ok ) {

				cout << "Unknown" << endl;

			}

		}

	}

}

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

int main(){

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    rep(i, tx-sx) cout << "R";
    rep(i, ty-sy+1) cout << "U";
    rep(i, tx-sx+1) cout << "L";
    rep(i, ty-sy+1) cout << "D";
    cout << "RD" ;
    rep(i, tx-sx+1) cout << "R";
    rep(i, ty-sy+1) cout << "U";
    rep(i, tx-sx+1) cout << "L";
    rep(i, ty-sy) cout << "D";
    
    return 0;
}

Measured memory_bytes: 256
// AOJ 1195 Encryption System
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int c;
string buf;
vector<string> vs;

void check(string &s){
	for(char ch = 'b';ch <= 'z';++ch){
		int pos = s.find(ch);
		if(pos != string::npos){
			s[pos] = ch - 1;
		}
	}
}

void gen(string s, int idx){
	for(char ch = 'b';ch <= 'z';++ch){
		int pos = s.find(ch);
		if(pos != string::npos){
			if(s[pos] - 1 != buf[pos]) return;
		}
	}
	if(s.length() == buf.length()){
		++c;
		vs.emplace_back(s);
		check(s);
		if(s != buf) {
			vs.erase(vs.end());
			--c;
		}
		if(vs.size() > 10){
			vs.erase(vs.begin() + 5);
		}
		return;
	}
	else{
		char ch = buf[idx] + 1;
		gen(s + buf[idx], idx + 1);
		if(ch <= 'z') gen(s + ch, idx + 1);
	}
}



int main(){
	while(cin >> buf){
		c = 0;
		if(buf == "#") break;
		gen("", 0);
		sort(vs.begin(), vs.end());
		auto vit = vs.begin();
		cout << c << endl;
		for(;vit != vs.end();++vit){
			cout << *vit << endl;
		}
		vs.clear();
	}
	return 0;
}

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

        // 入力
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();

        String out = m1 == m2 ? "0" : "1";
        // 出力
		System.out.println(out);
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> p[i];
        if (p[i] != i+1){
            sum++;
        }
    }

    if (sum > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

char map[1005][1005];
int d[1005][1005];
int cx[12], cy[12];
int W, H, N;

typedef pair<int, int> P;

void solve(int x0, int y0, int hard, int* res) {
	queue<P> q;
	q.push(P(x0, y0));
	d[x0][y0] = 0;
	while (!q.empty()) {
		P pp = q.front(); q.pop();
		int x = pp.first, y = pp.second;
		int dx[4] = {0, -1, 0, 1};
		int dy[4] = {1, 0, -1, 0};
		int i;
		for (i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx >= 0 && nx < H && ny >= 0 && ny < W 
				&& map[nx][ny] != 'X' && d[nx][ny] == 0 
				&& !(nx == x0 && ny == y0)) {
				d[nx][ny] = d[x][y] + 1;
				if (nx == cx[hard] && ny == cy[hard]) {
					*res += d[nx][ny];
					return;
				}
				q.push(P(nx, ny));
			}
		}
	}
}

int main() {
	while (scanf("%d%d%d", &H, &W, &N) == 3) {
		getchar();
		int i, j;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				scanf("%c", &map[i][j]);
				if (map[i][j] >= '1' && map[i][j] <= '9') {
					cx[map[i][j] - '0'] = i;
					cy[map[i][j] - '0'] = j;
					map[i][j] = '.';
				}
				else if (map[i][j] == 'S') {
					cx[0] = i, cy[0] = j;
					map[i][j] = '.';
				}
			}
			getchar();
		}
		int res = 0;
		for (i = 0; i < N; i++) {
			memset(d, 0, sizeof(d));
			solve(cx[i], cy[i], i+1, &res);
		}
		cout << res << endl;
	}
	return 0;
}

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

long gcd(long a, long b) {

  if (b == 0) {
    return a;
  }

  return gcd(b, a % b);
}

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

}

int main() {

  int A, B;
  cin >> A >> B;

  long long answer = lcm(A, B);

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <iomanip>
#define int long long
#define endl "\n";
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
void solve() {
	string s, t;
	cin >> s >> t;
	if (t.substr(0, t.size() - 1) == s) cout << "Yes";
	else cout << "No";
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);
	int t;
	t = 1;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k; cin>>k;
	string s; cin>>s; 
	if (s.size()>k)	s=s.substr(0,k), s+="...";
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll n,m,a[100100];
pair < ll , ll > c[100100];

int main()
{
    int n,m;  cin >> n >> m;
    ll Ans = 0;
    for(int i = 0;i<n;i++)  cin >> a[i];
    sort(a , a + n);
    for(int i = 0;i<m;i++){
        cin >> c[i].second >> c[i].first;
    }
    sort(c , c + m);
    int j = m - 1;
    for(int i = 0;i<n;i++){
        if(j >= 0 && a[i] < c[j].first)  {
            Ans+=c[j].first;
            c[j].second--;
            if(c[j].second == 0)  j--;
        }
        else  Ans+=a[i];
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
void solve()
{
  string str;
  cin>>str;
  
  for(ll i=0;i<str.length();i++)
  {
      if(str[i]=='U'||str[i]=='D')
      continue;
      
      if(!(i&1)&&str[i]!='R')
      {
          cout<<"No";
          return;
      }
      
      else if((i&1)&&str[i]!='L')
      {
          cout<<"No";
          return;
      }
      
      
      
  }
  
  
  cout<<"Yes";
   return;
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int B[100];
    int sum_max = 0;
    
    cin >> N;
    
    for (int i = 0 ; i < N - 1 ; i++){
        cin >> B[i];
    }
    
    sum_max = B[0];
    for (int j = 0 ; j < N - 2 ; j++){
        sum_max = sum_max + min(B[j], B[j+1]);
    }
    sum_max = sum_max + B[N-2];
    
    cout << sum_max << endl;
}


Measured memory_bytes: 256
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
int n,x,y ;
vi v ;
map<int,int> cnt ;
void solve(){
    cin >> n >> x >> y ;
    for(int i =1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            cnt[(min(j-i,min(abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1)))]++;
    for(int k=1;k<n;k++)
        pf(cnt[k]) ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 384
import itertools,sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N, = I()
A = I()
d = dict()
def dd(n):
    if n in d:
        return d[n]
    else:
        if n < 2:
            return 0
        else:
            d[n] = math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
            return d[n]
c = collections.Counter(A)
total = 0
for e in c.items():
    total += dd(e[1])
for e in A:
    print(total -  dd(c[e]) + dd(c[e]-1))


Measured memory_bytes: 121160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define test ll t; cin>>t; while(t--)
int month(int m1,int m2){
    if((m1==1||m1==3||m1==5||m1==7||m1==8||m1==10||m1==12))
    return 1;
    else if((m1==4||m1==6||m1==9||m1==11))
    return 2;
    else 
    return 3;
}
int main() {
	fast;
	int m1,d1,m2,d2,f=0;
	cin>>m1>>d1>>m2>>d2;
	if(m1==m2){
	    if((month(m1,m2)==1&&d1==31)||(month(m1,m2)==2&&d1==30)||(month(m1,m2)==3&&d1==28))f=1;
	}
	else if(m1==m2-1){
	    if(d2==1)f=1;
	}
	if(f)cout<<"1";
	else cout<<"0";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N;
	cin >> N;

	string str;
	vector<int> c(4, 0);
	for (int i = 0; i < N; i++) {
		cin >> str;
		if (str == "AC") {
			c[0] += 1;
		}
		else if (str == "WA") {
			c[1] += 1;
		}
		else if (str == "TLE") {
			c[2] += 1;
		}
		else {
			c[3] += 1;
		}
	}

	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;

	return 0;
}

Measured memory_bytes: 3624