akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 1095
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    ll n, i, j;
    ll sum, mod=1000000007, tmp1, str, tmp2;
    scanf("%lld", &n);
    ll arr1[n], arr2[n];
    for (i=0; i<n; i++) scanf("%lld", &arr1[i]);
    for (i=0; i<n; i++) arr2[i]=arr1[i];
    for (i=1; i<n; i++) arr1[i]+=arr1[i-1];
    sum=0;
    str=arr1[n-1];
    for (i=0; i<n; i++) {
        tmp1=arr1[i];
        tmp2=str-tmp1;

        tmp1=arr2[i];
        tmp2=((tmp2%mod)*(tmp1%mod))%mod;
        sum=((sum%mod)+(tmp2%mod))%mod;
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 6940
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;


int main()

{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	char n, m; cin >> n >> m;
	if ((int)n > (int)m)
		cout << '>' << endl;
	else if ((int)n < (int)m)
		cout << "<" << endl;
	else cout << '=' << endl;
	return 0;

}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  pair<int,pair<int,int> > a[100000];
  rep(i,n){
    int c,b;
    cin>>c>>b;
    a[i]=make_pair(b-c+1,make_pair(c,b));
  }
  sort(a,a+n);
  int flag[100000]={0};
  flag[n-1]=1;
  int al,ar,bl,br;
  int cl,cr,dl,dr;
  int ap=0,anum=INF;
  repn(i,n-2){
    if(anum>=a[i].scd.scd){
      ap=i;
      anum=a[i].scd.scd;
    }
  }
  al=a[ap].scd.fst;ar=a[ap].scd.scd;
  flag[ap]=1;
  bl=a[n-1].scd.fst;br=a[n-1].scd.scd;
  dl=bl;dr=br;
  //cout<<al<<" "<<ar<<" "<<bl<<" "<<br<<endl;
  rep(i,n){
    if(flag[i]==1) continue;
    int aal=al,aar=ar,bbl=bl,bbr=br;
    int aap=aar-aal+1,bbp=bbr-bbl+1;
    int acnt=0,bcnt=0;
    aal=max(a[i].scd.fst,aal);
    aar=min(a[i].scd.scd,aar);
    bbl=max(a[i].scd.fst,bbl);
    bbr=min(a[i].scd.scd,bbr);
    //cout<<" "<<aal<<" "<<aar<<" "<<bbl<<" "<<bbr<<endl;
    acnt=max((int)0,aar-aal+1);
    bcnt=max((int)0,bbr-bbl+1);
    if(aap-acnt<=bbp-bcnt){
      al=aal;
      ar=aar;
    }else{
      bl=bbl;
      br=bbr;
    }
    //cout<<al<<" "<<ar<<" "<<bl<<" "<<br<<endl;
  }
  //cout<<al<<" "<<ar<<" "<<bl<<" "<<br<<endl;
  int ans=max((int)0,ar-al+1)+max((int)0,br-bl+1);
  flag[ap]=0;
  ap=0;anum=0;
  rep(i,n-1){
    if(anum<=a[i].scd.fst){
      ap=i;
      anum=a[i].scd.fst;
    }
  }
  al=a[ap].scd.fst;ar=a[ap].scd.scd;
  flag[ap]=1;
  bl=a[n-1].scd.fst;br=a[n-1].scd.scd;
  rep(i,n){
    if(flag[i]==1) continue;
    int aal=al,aar=ar,bbl=bl,bbr=br;
    int aap=aar-aal+1,bbp=bbr-bbl+1;
    int acnt=0,bcnt=0;
    aal=max(a[i].scd.fst,aal);
    aar=min(a[i].scd.scd,aar);
    bbl=max(a[i].scd.fst,bbl);
    bbr=min(a[i].scd.scd,bbr);
    //cout<<" "<<aal<<" "<<aar<<" "<<bbl<<" "<<bbr<<endl;
    acnt=max((int)0,aar-aal+1);
    bcnt=max((int)0,bbr-bbl+1);
    if(aap-acnt<=bbp-bcnt){
      al=aal;
      ar=aar;
    }else{
      bl=bbl;
      br=bbr;
    }
    //cout<<al<<" "<<ar<<" "<<bl<<" "<<br<<endl;
  }
  ans=max(max((int)0,ar-al+1)+max((int)0,br-bl+1),ans);
  cout<<ans<<endl;
      
    
  return 0;
}


Measured memory_bytes: 3328
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int M;
    static int A;
    static long B;
    static long C;
//    static int[][] map;
    static int min = 9999999;


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

        N = scanner.nextInt();
        M = scanner.nextInt();
        
        if(N % M == 0){
            System.out.println(0);
        }else{
            System.out.println(1);
        }


    }




}



Measured memory_bytes: 21844
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	n := readInt()
	a := make([]int, 3*n)
	for i := range a {
		a[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	var ans int64
	for i := 1; i < 2*n; i = i + 2 {
		ans += int64(a[i])
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 6144
fun main(args: Array<String>) {
        val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
        solve(sc)
    }

    fun solve(sc: java.util.Scanner) {
        val N = sc.nextInt()
        val S = (1..N).map { sc.next() }.toSet()
        println(if (S.count() == 3) "Three" else "Four")
    }


Measured memory_bytes: 31520
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
l = []

for i in range(n):
    ans = abs((t -h[i] * 0.006) - a )
    l.append(ans)

x = (min(l))

print(l.index(x) + 1)

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int D;
    cin >> D;
    if (D==25) {
        print("Christmas");
    } else if (D==24) { 
        print("Christmas Eve");
    } else if (D==23) {
        print("Christmas Eve Eve");
    } else if (D==22) {
        print("Christmas Eve Eve Eve");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

s = readline().rstrip().decode('utf-8')

res = ""

for i in s:
    if i == "0":
        res = res+i
    elif i == "1":
        res = res+i
    else:
        if len(s) != 0:
            res = res[:-1]

print(res)

Measured memory_bytes: 38256
a,b,c,x,y = map(int,input().split())
s = 0
k = 2 * c
money = 0
s = min(a+b,k)
if k<a:
    a = k
if k<b:
    b = k
little = min(x,y)
money = little * s
x -= little
y -= little
if x:
    money += x*a
elif y:
    money += y*b
print(money)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define N 100100

int n,ans;
int a[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		if (i&1)
		{
			int cnt=0;
			for (int j=1;j<=i;j++)
				if (i%j==0) cnt++;
			if (cnt==8) ans++;
		}
	printf("%d\n",ans);
	return 0;
}

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

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  vector<int> t;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    t.push_back(tmp);
  }
  int m;
  cin>>m;
  int p[m],x[m];
  for(int i=0;i<m;i++){
    cin>>p[i]>>x[i];
  }

  for(int i=0;i<m;i++){
    long int ans;
    vector<int> t2;
    copy(t.begin(),t.end(),back_inserter(t2));
    t2[p[i]-1]=x[i];
    ans=accumulate(t2.begin(),t2.end(),0);
    cout<<ans<<endl;
  }
  return 0;
}


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

using namespace std;

int main(){
    string b;
    cin >> b;
    map<string, string> mp;
    mp["A"] = "T"; mp["T"] = "A"; mp["G"] = "C"; mp["C"] = "G";
    cout << mp[b] << endl;
}

Measured memory_bytes: 888
# 解説参照後コード
n = gets.chomp.to_i

a = [*1..n].map{ gets.to_i }.sort

m = n - 2

m1 = (m/2.0).ceil
m2 = m - m1

n_mod2 = n % 2

# 1つ目の候補 (a1 >= a2 <= ...)
coefA = [-2]*m2 + [-1] + [(-1)**n_mod2] + [2]*m1
A = coefA.zip(a).map{|c, v| c*v }.inject(:+)

# 2つ目の候補 (a1 <= a2 >= ...)
coefB = [-2]*m1 + [(-1)**(n_mod2+1)] + [1] + [2]*m2
B = coefB.zip(a).map{|c, v| c*v }.inject(:+)

puts([A, B].max)


Measured memory_bytes: 17904
/*
     _              ,_,                 
    / \   _ __, ___,| |__   __ _,_ __  
   / ^ \ | '_ \/ _ \| '_ \ / _` | /_/  
  /-/-\-\|-| |--| |-|-|_)-|-(_|-|-|    
 /_/   \_\_| |__| |_|_.__/ \__,_|_|    
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(a)       (a).begin(),(a).end()
#define rep(i,a,n)   for(int i=a ; i<n ; i++)
 
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<ll,ll> mii;
typedef map<char,ll> mci;
 
ll gcd(ll a, ll b){
	if(b==0)return a;
	else return gcd(b, a%b);
}

signed main(){
    ll test=1;
    // cin>>test;
    while(test--){
        ll n, w; cin>>n>>w;
        vi wt(n), val(n);
        rep(i, 0, n)cin>>wt[i]>>val[i];
        ll dp[n+1][w+1];
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<n+1; i++){
        	for(int j=1; j<w+1; j++){
        		if(j>=wt[i-1])dp[i][j]=max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
        		else dp[i][j]=dp[i-1][j];
        	}
        }
        cout<<dp[n][w]<<endl;
 
    }    
}


Measured memory_bytes: 82468
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

x=ii()
lol=[1,2,3,4,5,6,7,8,9]
ans=9
if(x>9):
    for i in lol:
        k=str(i)
        a=int(k[len(k)-1])
        if(a-1>=0):
            lol.append(k+str(a-1))
            ans+=1
            if(ans==x):
                print(lol[x-1])
                break
        lol.append(k+str(a))
        ans+=1
        if(ans==x):
            print(lol[x-1])
            break
        if(a+1<=9):
            lol.append(k+str(a+1))
            ans+=1    
            if(ans==x):
                print(lol[x-1])
                break
else:
    print(lol[x-1])

Measured memory_bytes: 50812
#include <stdio.h>
#include <string.h>

#define N (1000 + 10)

#define max(a, b) (a < b ? b : a)

int dp[N][N];
char P[N], Q[N];

int LCS(void)
{
  int P_size = strlen(P) - 1; 
  int Q_size = strlen(Q) - 1;
  int i, j;
  memset(dp, 0, sizeof(dp));
  for (i = 1; i < P_size + 1; ++i) {
    for (j = 1; j < Q_size + 1; ++j) {
      int MAX = max(dp[i][j - 1], dp[i - 1][j]);
      if (P[i - 1] == Q[j - 1]) {
        MAX = max(MAX, dp[i - 1][j - 1] + 1);
      }
      dp[i][j] = MAX;
    }
  }

  return dp[P_size][Q_size];
}

int main(){

  int n, i;
  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    fgets(P, N, stdin);
    fgets(Q, N, stdin);
    printf("%d\n", LCS());
  }
  return 0;
}


Measured memory_bytes: 5844
#include <iostream>
using namespace std;
int main(void){
    int N;
    int K;
    cin >> N >> K;
    int x =1;
    for (int i=0; i<N; i++){
        if(2 * x < x + K){
            x = 2*x;
        }
        else if(2 * x >= x + K){
            x = x + K;
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 3624
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<long long , int> PII;

const int N = 2e5 + 10;

int n, m, k, q, x, y;
int h[N], e[N], ne[N], idx;
long long w[N];
long long  dist[N];
bool st[N];

void add(int a, int b, int c)
{
    e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void dijkstra()
{
    memset(dist, 0x3f, sizeof dist);
    
    dist[k] = 0;
    priority_queue<PII, vector<PII>, greater<PII>> heap;
    heap.push({0, k});

    while (heap.size())
    {
        auto t = heap.top();
        heap.pop();

        int ver = t.second; long long distance = t.first;

        if (st[ver]) continue;
        st[ver] = true;

        for (int i = h[ver]; i != -1; i = ne[i])
        {
            int j = e[i];
            if (dist[j] > distance + w[i])
            {
                dist[j] = distance + w[i];
                heap.push({dist[j], j});
            }
        }
    }
}

int main()
{
    scanf("%d",&n);
    m = n - 1;
    memset(h, -1, sizeof h);
    while (m -- )
    {
        int a ,b ,c;
        cin >>a >> b >> c;
        add(a, b, c);
        add(b, a, c);
    }
    
    cin >> q>> k;
    dijkstra();
    while(q--)
    {
        cin >>x >>y;
        cout << dist[x] + dist[y] <<endl;
    }

    return 0;
}

Measured memory_bytes: 7924
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
t = readline().rstrip().decode('utf-8')
ls = len(s)
lt = len(t)
ans = 10**18
for i in range(ls-lt+1):
    res = 0
    for j in range(lt):
        if s[i+j] != t[j]:
            res += 1
    ans = min(ans,res)

print(ans)

Measured memory_bytes: 67624
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;

/**Problem1275 : And Then There Was One **/
int main()
{
	int n, k, m;
	
	while (cin>>n>>k>>m, n||k||m) {
		vector<int> v;
		rep(i, n) {
			v.push_back(i+1);
		}
		int pos=m-1;
		rep(i, n-1) {
			v.erase(v.begin()+pos);
			pos+=k-1;
			pos%=v.size();
		}
		cout << v[0] << endl;
	}
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } 

void solve(ll ts){
	//ll n=2; vector<ll> arr(n); rep(n) cin>>arr[i];
    ll n; cin>>n; vector<ll> arr,brr; rep(n){ ll a,b; cin>>a>>b; arr.append(a+b); brr.append(a-b); }
    sort(all(brr));
    sort(all(arr));
//    for(auto i:arr) cout<<i<<" "; cout<<endl;
    cout<<max(abs(arr.back()-arr[0]),abs(brr.back()-brr[0]))<<endl;
} 

//
int main(){
    ffast
    ll t=1;
   // cin>>t;
    rep(t) solve(i+1);
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll dp[105][10]; // height, Line
int H, W, K;
const ll mod = 1e9+7;

ll calc(int l){
	ll memo[10][2];
	memset(memo, 0, sizeof(memo));
	memo[0][0] = 1;
	for (int i = 0;i < W-1;i++){
		if(i == l){
			memo[i+1][1] += memo[i][0];
			continue;
		}
		memo[i+1][0] += memo[i][0]+memo[i][1];
		memo[i+1][1] += memo[i][0];
	}
	return memo[W-1][0]+memo[W-1][1];
}

ll calc2(int l){
	ll memo[10][2];
	memset(memo, 0, sizeof(memo));
	memo[0][0] = 1;
	for (int i = 0;i < W-1;i++){
		if(i == l || i+1 == l){
			memo[i+1][0] += memo[i][0] + memo[i][1];
			continue;
		}
		memo[i+1][0] += memo[i][0]+memo[i][1];
		memo[i+1][1] += memo[i][0];
	}
	return memo[W-1][0]+memo[W-1][1];
}

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

	cin >> H >> W >> K;

	dp[0][0] = 1;

	for (int i = 0;i < H;i++){
		for (int j = 0;j < W;j++){
			if(dp[i][j] == 0) continue;
			dp[i+1][j] += dp[i][j]*calc2(j);
			dp[i+1][j] %= mod;
			if(j != 0){
				dp[i+1][j-1] += dp[i][j]*calc(j-1);
				dp[i+1][j-1] %= mod;
			}
			if(j != W-1){
				dp[i+1][j+1] += dp[i][j]*calc(j);
				dp[i+1][j+1] %= mod;	
			}
		}
	}

	cout << dp[H][K-1] << endl;

	return 0;

}


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


public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int i = 0;
		int yy = 0;
		int xx=0;
		int xe=0;
		int ye=0;
		
		while (scanner.hasNextLine()) {
			i++;
			String sc = scanner.nextLine();
			String[] list = sc.split(" ", 0);
			ArrayList<Integer> list2 = new ArrayList<Integer>();

			if(i==1){
				xe = Integer.parseInt(list[2]);
				ye = Integer.parseInt(list[3]);
			}

			if(i==2){
			for(int j=0; j<list.length; j++){
				list2.add(Integer.parseInt(list[j]));
			}
			list2.add(xe);
			Collections.sort(list2);
			Integer x = list2.get(list2.size()-1);
			xx = x.intValue();
			}

			if(i==3){
			list = sc.split(" ", 0);
			for(int j=0; j<list.length; j++){
				list2.add(Integer.parseInt(list[j]));
			}
			list2.add(ye);
			Collections.sort(list2);
			Integer y = list2.get(0);
			yy = y.intValue();
			}
		}
		if(xx >= yy){
			System.out.print("War");	
		}else{
		    System.out.print("No War");
		}
	}
}

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

int main(int,char**){
	int loops;
	std::cin >> loops;
	int a,b,c;
	while(loops--){
		std::cin >> a >> b >> c;
		if(a*a-b*b-c*c && b*b-c*c-a*a && c*c-a*a-b*b) std::cout << "NO" <<std::endl;
		else std::cout << "YES" <<std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
import collection.mutable.Stack
import java.util._
 
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val str = sc.nextLine.split(" ")
    val stack = Stack[Int]()
 
    str foreach {
      case "*" => stack.push(stack.pop * stack.pop)
      case "+" => stack.push(stack.pop + stack.pop)
      case "-" => stack.push(- stack.pop + stack.pop)
      case df => stack.push(df.toInt)
    }
    println(stack.pop)
  }
}

Measured memory_bytes: 45092
from sys import stdin

N,M,C = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
raw_data = [stdin.readline().rstrip().split() for _ in range(N)]
data = [list(map(int, x)) for x in raw_data]

result = 0
for i in range(N):
  a = sum([x*y for x,y in zip(B, data[i])]) + C
  if a > 0:
    result += 1
  else:
    result += 0

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;

vector<int>v;
int x[3333],y[3333],n,ans,c;
char s[3333];
map<P,char>A;
map<int,int>M;
map<char,int>Dir;
bool used[3001][3001];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

int get(int idx){
    memset(used,0,sizeof(used));
    int res=1,d;
    int X=x[idx];
    int Y=y[idx];
    d=Dir[A[P(X,Y)]];
    used[X][Y]=1;
    while(1){
        X+=dx[d];
        Y+=dy[d];
        if(X<0||Y<0||X>3000||Y>3000)break;
        if(used[X][Y])continue;
        if(A.count(P(X,Y))){
            used[X][Y]=1;
            d=Dir[A[P(X,Y)]];
            res++;
        }
    }
    return res;
}

int main(){
    Dir['^']=0;
    Dir['>']=1;
    Dir['v']=2;
    Dir['<']=3;
    cin>>n;
    r(i,n){
        cin>>x[i]>>y[i]>>s[i];
        v.push_back(x[i]);
        v.push_back(y[i]);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    r(i,v.size())M[v[i]]=c++;
    r(i,n){
        x[i]=M[x[i]];
        y[i]=M[y[i]];
        A[P(x[i],y[i])]=s[i];
    }
    r(i,n)ans=max(ans,get(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 12360
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    LL ans = 0;
    REP(i,1,n) if (a[i-1] == a[i]) {
        if (ans == 0) {
            ans = a[i];
            ++i;
        } else {
            cout << ans * a[i] << endl;
            return;
        }
    }
    cout << 0 << endl;
}

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

Measured memory_bytes: 1024
a1,b1,a2,b2=map(int,input().split())
c=a2-a1
d=b2-b1
e=-d
f=c
a3=a2+e
b3=b2+f
a4=a3-c
b4=b3-d
print(a3,b3,a4,b4)

Measured memory_bytes: 3064
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdlib>

using namespace std;

int main()
{
    int a,b,c,d;
    long long Max;
    long long arr[4];
    scanf("%d %d %d %d", &a, &b, &c, &d);

    arr[0] = (long long)a*c;
    arr[1] = (long long)a*d;
    arr[2] = (long long)b*c;
    arr[3] = (long long)b*d;

    Max = arr[0];
    for(int i = 1; i<4; i++)
    {
        Max = max(Max, arr[i]);
    }
    printf("%lld", Max);
    return 0;
    

    
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int heap[250];

int main() {
    int k;
    cin >> k;
    REP(i, k) cin >> heap[i];
    REP(i, k){
        int parent = (i-1)/2;
        int left = 2 * (i + 1) - 1;
        int right = left + 1;
        cout << "node " << i+1 << ": key = " << heap[i] << ", ";
        if(i != 0 && 0 <= parent)
            cout << "parent key = " << heap[parent] << ", ";
        if(left < k)
            cout << "left key = " << heap[left] << ", ";
        if(right < k)
            cout << "right key = " << heap[right] << ", ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
use proconio::input;

fn main() {
    input! {
        a: u64, b: String,
    }
    let b = b
        .chars()
        .into_iter()
        .filter(|&c| c != '.')
        .collect::<String>();
    let b = b.parse::<u64>().ok().unwrap();
    println!("{}", a * b / 100);
}


Measured memory_bytes: 2192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = 0, b = 0, c = 0, count = 0;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		for(int i = a; i <= b; i++) {
			if(c % i == 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26188
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

ll Search(vector<vector<ll>> & dp, vector<vector<char>> & ok, const vector<ll> & d, int l, int r, char p = 0) {
	if (l > r)
		return 0;
	if (ok[l][r])
		return dp[l][r];
	ll a, b;
	a = Search(dp, ok, d, l + 1, r, !p);
	b = Search(dp, ok, d, l, r - 1, !p);
	ok[l][r] = 1;
	return dp[l][r] = p ? min(a - d[l], b - d[r]) : max(a + d[l], b + d[r]);
}

int main(void) {
	int num, i;
	ll ans;
	cin >> num;
	vector<ll> d(num);
	vector<vector<char>> ok(num, vector<char>(num, 0));
	vector<vector<ll>> dp(num, vector<ll>(num, 0));
	rep(i, num)
		cin >> d[i];
	ans = Search(dp, ok, d, 0, num - 1);
	cout << ans << "\n";
	return 0;
}

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

a = 0
for i in range(N):
    if i % 2 == 0:
        a += A[i]
    else:
        a -= A[i]

B = []

for i in range(N):
    if i == 0:
        B.append(a)
    else:
        B.append(-B[i-1]+2*A[i-1])

print(*B)

Measured memory_bytes: 69988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int[] A;

        public void Run()
        {
            {
                A = Input.ReadIntArray();
            }

            Array.Sort(A);

            int ret = int.MaxValue;
            for (int i = 0; i < 100; i++)
            {
                int r = 0;
                for (int k = 0; k < 3; k++)
                {
                    r += T(i - A[k]);
                }
                ret = Math.Min(ret, r);

            }
            Console.WriteLine(ret);

        }

        public int T(int n)
        {
            if (n < 0) return -n;
            return (n + 1) / 2 + n % 2;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
def check(i):
    num=int(i**0.5)
    if i==1:return 0
    if i==2:return 1
    for j in range(2,num+1):
        if i%j==0:break

    else:return 1
    return 0
q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]

L=[0]*(10**5+1)#0~100000
for i in range(10**5+1):
    if i%2==0:
        L[i]=L[i-1]
    else:
        L[i]=L[i-1]+check(i)*check((i+1)//2)

for l,r in lr:
    cnt=L[r]-L[l-1]
    print(cnt)

Measured memory_bytes: 30528
N = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0] * 1000001
res = 0
for i in range(N):
    if check[A[i]]:
        continue
    if i == N-1 or A[i] != A[i+1]:
        res += 1
    for j in range(A[i], 1000001, A[i]):
        check[j] = 1
print(res)

Measured memory_bytes: 32112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	string S;
	cin>>S;
	string ans=S.substr(0,S.size()-8);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return i*2;}
int right(int i){return i*2+1;}

int main() {
  int H,i,A[MAX+1];

scanf("%d\n", &H);
for(i=1;i<=H;i++) {
  scanf("%d\n", &A[i]);
}

for(i=1;i<=H;i++) {
  printf("node %d: key = %d, ", i,A[i]);
  if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
  if(left(i) <= H) printf("left key = %d, ", A[left(i)]);
  if(right(i) <= H) printf("right key = %d, ", A[right(i)]);
  printf("\n");

}

return 0;
}

Measured memory_bytes: 612
def gcd(a,b):
    if b==0:
        return abs(a)
    return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)

#n,m=map(int,input().split())
#print(gcd(n,m))
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
#a=list(map(int,input().split()))
m=a[0]
for i in range(1,len(a)):
    m=lcm(m,a[i])

print(m)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(x) ((int)(x).size())
#define el "\n"
#ifdef LOCAL_tqk
#define gc() getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

	lint n, k;
	char s[256];
	cin >> n >> k;
	cin.getline(s, sizeof(s));
	cin.getline(s, sizeof(s));
	cout << ceil((double)(n - 1) / (k - 1)) << el;
	gc();
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int p1, p2;
  p1 = A * N;
  p2 = B;
  if (p1 >= p2) {
    cout << p2 << endl;
  }
  
  else {
    cout << p1 << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	int n, r;

	cin >> n >> r;

	int ans = r;

	if (n >= 10) {

	}
	else {
		ans = r +( 100 * (10 - n));
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    const a = Number.parseInt(lengthList[0]);
    const b = Number.parseInt(lengthList[1]);
    const d = Math.floor(a/b);
    const r = a%b;
    const f = (a/b).toFixed(5);
    console.log(d + " "+ r + " " + f)
  }

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 15408
N, K = map(int, input().split())
mod = 10 ** 9 + 7
def mod_cmb(n, r, mod=10 ** 9 + 7):
	assert n >= r >= 0

	def ex_euclid(x, y):
		a, b = 1, 0
		while y != 0:
			a, b = b, (a - x // y * b)
			x, y = y, x % y
		return a

	p = q = 1
	for i in range(n - r + 1, n + 1):
		p *= i
		p %= mod
	for i in range(2, r + 1):
		q *= i
		q %= mod
	p *= ex_euclid(q, mod)
	p %= mod
	return p
print(mod_cmb(N+K-1,N))


Measured memory_bytes: 5600
n,a=map(int,input().split())
nums=[int(i)-a for i in input().split()]
d={0:1}
for i in nums:
  s = [[j, d[j]] for j in d]
  for j in s:
    if j[0] + i in d:
      d[j[0]+i] += j[1]
    else:
      d[j[0]+i] = j[1]
print(d[0]-1)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[][] g = new int[n+1][n+1];
        
        for (int i = 0; i < n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int v = sc.nextInt();
                g[u][v] = 1;
            }
        }
        
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                System.out.print(g[i][j] + ((j == n) ? "" : " "));
            }
            System.out.println();
            
        }
    }
}



Measured memory_bytes: 31508
def main():
    # 整数問題で処理していく解法
    limit, divisor = map(int, input().split(" "))
    if divisor % 2:
        print((limit // divisor) ** 3)
    else:
        print((limit // divisor) ** 3 + ((limit + divisor // 2) // divisor) ** 3)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, p string
	fmt.Scan(&s, &p)
	sd := s + s[:len(p)]
	if strings.Contains(sd, p) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    long long res = 0;
    for (int d = 60; d >= -1; --d) { // d = -1 は X = K の場合
        if (d != -1 && !(K & (1LL<<d))) continue;

        long long tmp = 0;
        for (int e = 60; e >= 0; --e) {
            long long mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;

            if (e > d) {
                if (K & mask) tmp += mask * (N - num);
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num;
            }
            else {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
      solve();
    }
}


void solve() {
  ll a, b, c;
  cin >> a >> b >> c;

  ll tmp = min(a, c);
  a -= tmp;
  c -= tmp;
  b -= min(b, c);
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

const int mod = 1000000007;
 
using namespace std;
typedef long long ll;

ll calc(vector<int> v[], int parent, int node, int level, int K, int bro){
	ll value;
	int color = level == 0 ? K : level == 1 ? K-1 : K-2;
	color -= bro;
	
	value = color;
	int count = 0;
	for(int i = 0; i < v[node].size(); i++){
		if(v[node][i] != parent){
			value = (value * calc(v, node, v[node][i], level+1, K, count)) % mod;
			count++;
		}
	}

	return value;
}

int main()
{
	int N, K;
	vector<int> v[100000];
	
	scanf("%d %d", &N, &K);
	for(int i = 0; i < N-1; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	
	ll ans = calc(v, -1, 0, 0, K, 0);
	
	printf("%lld\n", ans);
	
	return 0;
}

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

int main(){

  int i,j,n,min,swap,count=0;
  int a[100];

  cin >> n;

  for (i=0;i<n;i++){
    cin >> a[i];
  }

  for (i=0;i<n;i++){
    min = i;
    for (j=i;j<n;j++){
      if (a[j]<a[min]){
	min = j;
      }
    }
    if (min > i){
      swap = a[i];a[i] = a[min];a[min] = swap;
	count++;    
    }
  }

  for (i=0;i<n;i++){
    cout << a[i];
    if (i<n-1){
      cout << " ";
    }
  }
  cout << endl << count << endl;

  return 0;

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

class max_flow {
	struct edge {
		ll to, cap, rev;
		edge(ll to_, ll cap_, ll rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	ll V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	ll DFS(int v, int t, ll f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				ll d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	max_flow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, ll cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	ll dinic(int s, int t) {
		ll flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			ll f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

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

    int h,w;cin>>h>>w;
    vector<string> s(h);
    int sx,sy,gx,gy;
    vector<P> ls;
    for(int i=0;i<h;i++){
        cin>>s[i];
        for(int j=0;j<w;j++){
            if(s[i][j]=='S'){
                sx=i+1;
                sy=j+h+1;
            }
            else if(s[i][j]=='T'){
                gx=i+1;
                gy=j+h+1;
            }
            else if(s[i][j]=='o'){
                ls.push_back(P(i+1,j+h+1));
            }
        }
    }
    max_flow mf(h+w+2);
    mf.add(0,sx,INF);
    mf.add(0,sy,INF);
    mf.add(gx,h+w+1,INF);
    mf.add(gy,h+w+1,INF);
    int sz=ls.size();
    for(int i=0;i<sz;i++){
        mf.add(ls[i].first,ls[i].second,1);
        mf.add(ls[i].second,ls[i].first,1);
    }
    ll res = mf.dinic(0,h+w+1);
    cout<< (res>=INF ? -1 : res) <<endl;
}


Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = input()
    chars = set([x for x in s])
    mn = len(s)
    for c in chars:
        mx = max([len(x) for x in s.split(c)])
        mn = min(mn, mx)
    print(mn)
    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


Measured memory_bytes: 9184
k = int(input())


def make_runrun(n, depth):
    r = [n]
    if depth == 0:
        return r
    x = n % 10

    if x >= 1:
        r.extend(make_runrun(n * 10 + x - 1, depth - 1))
    r.extend(make_runrun(n * 10 + x, depth - 1))
    if x < 9:
        r.extend(make_runrun(n * 10 + x + 1, depth - 1))
    
    return r

r = []
for i in range(1, 10):
    r.extend(make_runrun(i, 10))
r = sorted(r)
print(r[k - 1])


Measured memory_bytes: 36068
def read_input():
    n, m = map(int, input().split())

    slist = []
    for i in range(m):
        temp = list(map(int, input().split()))
        k = temp[0]
        s = temp[1:]
        slist.append((k, s))

    p = list(map(int, input().split()))

    return n, m, slist, p


def switch_gen(n):
    curr = 0

    while True:
        bincurr = bin(curr)[2:]

        if len(bincurr) > n:
            return None
        bincurr = [int(c) for c in bincurr]
        t = [0] * (n - len(bincurr))
        t.extend(bincurr)
        yield t

        curr += 1


def check_condition(switch, slist, plist):
    for s, p in zip(slist, plist):
        count = 0
        for i in s[1]:
            if switch[i - 1] == 1:
                count += 1

        if count % 2 != p:
            return False

    return True


def submit():
    n, m, slist, p = read_input()

    count = 0
    for switch in switch_gen(n):
        if check_condition(switch, slist, p):
            count += 1

    print(count)




if __name__ == '__main__':
    submit()


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;


#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)   for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<ll, ll>
#define    mem(a)       memset(a,0,sizeof(a))
const ll mod = 1000000007;

void fio()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}

template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}




void solve(){

    // std::vector<int> v;
    // for(int i=0;i<1;i++)
    // {
    //     int x;
    //     cin>>x;
    //     v.push_back(x);

    // }

    ll n,m;
    cin>>n>>m;
    bool v[n];
    vector<ll> adj[n];

    while(m--){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    ll mx=INT_MIN;
    memset(v,0, sizeof(v));

    for(int i=0;i<n;i++){
        if(!v[i]){
            queue<ll> q;
            q.push(i);
            v[i]=1;
            ll count=0;
            while(!q.empty()){
                ll cur = q.front();
                q.pop();
                count++;
                
                for (ll j : adj[cur]){
                    if(!v[j]){
                    v[j]=1;
                    q.push(j);
                    }
                }
                
            }
            mx= max(mx, count);
        }

    }

    cout<<mx;


}

int main()
{
    //auto start = chrono::high_resolution_clock::now();
    boost;
    fio();
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    //auto end = chrono::high_resolution_clock::now();
    //TIME(start, end);
    return 0;
}

Measured memory_bytes: 17404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1000000000000;
const ll mod=1000000007;

int main(){
  ll n;cin>>n;
  ll ans=INF;
  for(ll i=1;i*i<=n;i++){
    ll now=n;
    if(now%i!=0) continue;
    now/=i;
    ans=min(ans,(i+now)-2);
  }
  
  cout<<ans<<endl;
}



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n, -1), prev(n, -1);
    queue<int> que;
    que.push(0);
    dist[0] = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto nv : g[v]) {
            if(dist[nv] == -1) {
                dist[nv] = dist[v] + 1;
                prev[nv] = v;
                que.push(nv);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=1; i<n; i++) cout << prev[i] + 1 << "\n";
}

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

int main() {
    int N; cin >> N;
    vector<ll> vec(90, 0);
    vec[0] = 2LL;
    vec[1] = 1LL;
    for (int i = 2; i < 90; i++) {
        vec[i] = vec[i-1] + vec[i-2];
    }
    cout << vec[N] << endl;
}

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

int main() {
  int A,B,ans=0;
  cin >> A >> B;
  for(int i=1;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        if(A<=10001*i+1010*j+100*k && 10001*i+1010*j+100*k<=B){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll answer = 0;
	for(ll i = 1; i * i <= n; ++i){
		const ll m = (n - i) / i;
		if(m != 0 && n % m == n / m){ answer += m; }
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   ll x,y;
   cin>>x>>y;
   y=y/2;y+=x;
   cout<<y<<"\n";
   return 0;

}


Measured memory_bytes: 256