akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
int main() {

	int N;
	long long count=0;
	long long result=0;
	cin >> N;

	vector<string>s(N);

	for (int i = 0; i < N; i++)
	{
		cin >> s[i];

		sort(s[i].begin(),s[i].end());

	}

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

	for (int i = 1; i < N; i++) {
		if (s[i-1] == s[i])
		{
			count++;
		}
		else {
			result += (count * (count + 1)) / 2;
			count = 0;
		}

		if (i == (N - 1)) {
			result += (count * (count + 1)) / 2;
		}
	
	}
	cout << result;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

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

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return (a / g) * b;
}
int main()
{
	ll k; cin >> k;
	ll ans = 0;

	//diff 3
	ll p1 = 0;
	repe(x, 1, k) {
		repe(y, x+1, k) {
			repe(z, y+1, k) {
				if (x != y && y != z ) {
					p1 += gcd(gcd(x, y), z) * 6;
				}
			}
		}
	}

	//same 3
	ll p2 = 0;
	repe(i, 1, k) {
		p2 += gcd(gcd(i, i), i);
	}


	//same2 diff1 
	ll p3 = 0;
	repe(i, 1, k) {
		repe(j, 1, k) {
			if (i != j) {
				p2 += gcd(gcd(i, i), j)*3;
			}
		}
	}


	cout << p1+p2+p3 << endl;

    return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {

	string p;
	cin >> p;
	int x = 0;
	for (int i = 0; i < p.size(); i++)
		x += p[i] - '0';

	cout << x << endl;
	

	return 0;
} 

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

#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define ll  long long
#define ld	long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"

const ll MOD2 = 998244353;
const ll MOD = 1000*1000*1000 + 7;	
const ll N  = 1000*1000+5;
const double PI  = 3.14159265;

int main()
{
	string s;
	cin>>s;
	int flag=0;
	for (int i = 0; i < 3; ++i)
	{
		if(s[i]==s[i+1])
			flag++;
	}
	if(flag)
		cout<<"Bad";
	else
		cout<<"Good";
	return 0 ;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

static int N;
static int[] bit = new int[1000010];

public static void add(int a, int w) {
    for (int i=a;i<=N;i+=i&(-i)) {
        bit[i]+=w;
    }
}

public static int sum(int a) {
    int ret = 0;
    for (int i=a;i>0;i-=i&(-i)) {
        ret+=bit[i];
    }
    return ret;
}

public static int get(int k) { // 0_indexed find
    ++k;
    int res = 0;
    int nn = 1; while (nn < (int)N) nn *= 2;
    for (int i = nn / 2; i > 0; i /= 2) {
        if (res + i < (int)N && bit[res + i] < k) {
            k = k - bit[res + i];
            res = res + i;
        }
    }
    return res + 1;
}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        N = n+2;
        int[] A = new int[n];
        int[] inv = new int[n];
        for (int i=0;i<n;i++) {
            A[i] = Integer.parseInt(sc.next());
            inv[A[i]-1] = i;
        }
        long ans = 0L;
        add(1, 1);
        add(N+2, 1);
        for (int i=0;i<n;i++) {
            int index = inv[i]+1;
            ans+=(long)((index+1)-get(sum(index)-1))*(get(sum(index))-(index+1))*(i+1);
            add(index+1, 1);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64112
use std::io;
use std::str::FromStr;
use std::cmp::max;

static MOD: u64 = 1_000_000_007;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, m) = input_tuple();
    let s_vec = input_vec();
    let t_vec = input_vec();
    let mut dp = vec![vec![1; t_vec.len() + 1]; s_vec.len() + 1];
    for i in 0..s_vec.len() {
        for j in 0..t_vec.len() {
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD;
            if s_vec[i] != t_vec[j] {
                dp[i+1][j+1] = (dp[i+1][j+1] + MOD - dp[i][j]) % MOD;
            }
        }
    }
    println!("{:?}", dp[s_vec.len()][t_vec.len()]);
}


Measured memory_bytes: 33344
#include<iostream>
#include<string>

using namespace std;

int main(){
  string a, b;
  cin >> a >> b;
  bool ans;
  if(a.length()>b.length()){
    cout<<"GREATER"<<endl;
  }
  else if(b.length()>a.length()){
    cout << "LESS" << endl;
  }
  else{
    bool ans=true;
    for(int i=0;i<a.length();i++){
      if(a[i]>b[i]){
        cout<<"GREATER"<<endl;
        ans=false;
        break;
      }
      else if(a[i]<b[i]){
        cout << "LESS" << endl;
        ans=false;
        break;
      }
    }
    if(ans){
      cout<<"EQUAL" << endl;
    }
  }
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  double re = 0;
  int n;
  cin >> n;
  repi(n) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "BTC") x *= 380000;
    re += x;
  }
  cout << re << endl;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, d, x;
    cin >> r >> d >> x;
    REP(i, 10) {
        x = x * r - d;
        cout << x << ln;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 2000000000000LL
using namespace std;

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool shortestPath(Graph &g,
    Matrix &dist, vector<vector<int> > &prev) {
  int n = g.size()-1;
  Array h(n+1);
  h.assign(n,INF);
  REP(i,n) g[n].push_back(Edge(n,i,0));
  REP(k,n+1) REP(i,n+1) FOR(e,g[i]) {
    if (h[e->src]<INF && e->weight<INF && h[e->dst] > h[e->src] + e->weight) {
      h[e->dst] = h[e->src] + e->weight;
      if (k == n) return false; // negative cycle
    }
  }
  REP(i,n) FOR(e,g[i]) e->weight += h[i] - h[e->dst];
  dist.assign(n, Array(n, INF));
  prev.assign(n, vector<int>(n, -2));
  REP(s, n) {
    priority_queue<Edge> Q;
    Q.push(Edge(s, s, 0));
    while (!Q.empty()) {
      Edge e = Q.top(); Q.pop();
      if (prev[s][e.dst] != -2) continue;
      prev[s][e.dst] = e.src;
      FOR(f,g[e.dst]) {
        if (e.weight<INF && f->weight<INF && dist[s][f->dst] > e.weight + f->weight) {
          dist[s][f->dst] = e.weight + f->weight;
          Q.push(Edge(f->src, f->dst, e.weight + f->weight));
        }
      }
    }
    REP(u, n) {
      if(dist[s][u]<INF)dist[s][u] += h[u] - h[s];
    }
  }
  return true;
}

int main(){
	int r,T,V,E,s,t,e,i,j;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d",&V,&E);
		Graph g(V+1);
		Matrix dist;
		vector<vector<int> > prev;
		for(i=0;i<V;i++)g[i].push_back(Edge(i,i,0));
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e));
		if(!shortestPath(g,dist,prev))puts("NEGATIVE CYCLE");
		else for(i=0;i<V;i++)for(j=0;j<V;j++){
			/*if(i==j)printf("0");
			else*/ if(dist[i][j]>=INF)printf("INF");
			else printf("%lld",dist[i][j]);
			printf(j<V-1?" ":"\n");
		}
	//}
}

Measured memory_bytes: 1392
s = gets.chomp
c_index = s[2 .. -2].each_char.to_a.index{|_| _ == "C"}

if s[0] == "A" && s[2 .. -2].each_char.count{|_| _ == "C"} == 1
  s[0] = "a"
  s[c_index + 2] = "c"
  if s.downcase == s
    puts("AC")
  else
    puts("WA")
  end
else
  puts("WA")
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long ll;
const int N=2e5+10;
vector<int>G[N];
int n,col[N],cnt[N],all;
ll ans[N],sz[N];
ll dfs(int u,int fa)
{
    ll tmp=cnt[col[u]];
    sz[u]=1;
    for(int v:G[u]){
        if(v==fa) continue;
        ll l=all-cnt[col[u]];
        sz[u]+=dfs(v,u);
        ll r=all-cnt[col[u]];
        ll len=r-l;
        ans[col[u]]-=(len*(len-1)/2);
    }
    cnt[col[u]]=tmp+sz[u];
    all++;
    return sz[u];
;}
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&col[i]);
    rep(i,2,n)
    {
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }



    rep(i,1,n) ans[i]=1ll*n*(n-1)/2;
    dfs(1,-1);
    for(int i=1;i<=n;++i){
        //printf("i:%d cnt:%d ans:%lld\n",i,cnt[i],ans[i]);
        ll len=n-cnt[i];
        ans[i]-=(len*(len-1)/2);
    }
    for(int i=1;i<=n;++i) ans[col[i]]++;//每个单独的点是一条路径
    for(int i=1;i<=n;++i) printf("%lld\n",ans[i]);
}


Measured memory_bytes: 37968
chomp (my $k = readline ARGV);
chomp (my @l = split / /, readline ARGV);

inconsistent() unless $l[-1] <= 2;

my ($min, $max) = (1 , 2);
for my $l (reverse @l) {
  my $low  = (int(($min - 1) / $l) + 1) * $l;
  my $high = int($max / $l) * $l;
  inconsistent() if $low > $high;
  inconsistent() if $low < $min && $max < $high;
  ($min, $max) = ($low, $high + $l - 1);
}
print "$min $max\n";

sub inconsistent {
  print "-1\n";
  exit;
}

Measured memory_bytes: 17996
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll T1, T2, A1, A2, B1, B2;
ll d;

signed main(){

	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	if(A1 > B1){
		swap(A1, B1);
		swap(A2, B2);
	}
	d = (T1*A1+T2*A2) - (T1*B1+T2*B2);
	if(d == 0){
		cout << "infinity" << endl;
		return 0;
	}
	if(d < 0){
		cout << 0 << endl;
		return 0;
	}
	
	if((T1*B1-T1*A1)%d == 0) cout << (T1*B1-T1*A1)/d*2 << endl;
	else cout << (T1*B1-T1*A1)/d*2 + 1 << endl;
}

/*
1 1
2 3
3 1
*/

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String base = getString(sc.next().toCharArray());
		String next = getString(sc.next().toCharArray());
		if (base.equals(next)) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
	
	static String getString(char[] arr) {
	    char[] ans = new char[arr.length];
	    HashMap<Character, Character> map = new HashMap<>();
	    char now = 'A';
	    for (int i = 0; i < arr.length; i++) {
	        if (map.containsKey(arr[i])) {
	            ans[i] = map.get(arr[i]);
	        } else {
	            ans[i] = now;
	            map.put(arr[i], now);
	            now = (char)(now + 1);
	        }
	    }
	    return new String(ans);
	}
}


Measured memory_bytes: 28600
#include <iostream>
#include <string>

using namespace std;

int a[5];

int main()
{
    int n;
    cin>>n;
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        if(str=="AC")
        {
            a[0]++;
        }
        else if(str=="WA")
        {
            a[1]++;
        }
        else if(str=="TLE")
        {
            a[2]++;
        }
        else
        {
            a[3]++;
        }
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){

  int m, f, r, sum;

  while(1){
    sum = 0;
    scanf("%d %d %d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1)break;
    sum = m + f;
    if(30 > sum && sum >= 0 || m == -1 || f == -1)
      printf("F\n");
    else if(80 <= sum)
      printf("A\n");
    else if(80 > sum && sum >= 65)
      printf("B\n");
    else if(65 > sum && sum >= 50 || 50 > sum && sum >= 30 && r >= 50)
      printf("C\n");
    else if(50 > sum && sum >= 30)
      printf("D\n");
  }
  return 0;
}

Measured memory_bytes: 584
/*
 * Created by Dipta Das on 14-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> ar(n, 0);
    
    for (int i = 1; i < n; ++i) {
        ar[i] = ar[i-1];
        if (s[i] == 'C' && s[i-1] == 'A') ar[i]++;
    }

/*     for (int i = 0; i < n; ++i) cout << i; */
/*     cout << endl; */
/*     cout << s << endl; */
/*     for (int i = 0; i < n; ++i) cout << ar[i]; */
/*     cout << endl; */

    while (q--) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        cout << (ar[r] - ar[l]) << endl;
    }



    return 0;
}



Measured memory_bytes: 1488
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		
		boolean[] q = new boolean[n];
		int[] q_wa = new int[n];
		
		int ac = 0;
		int wa = 0;
		
		for(int i=0 ; i < n ; i++) {
			q[i] = false;
			q_wa[i] = 0;
		}
		
		for(int i=0 ; i < m ; i++) {
			int p = Integer.parseInt(sc.next());
			String s = sc.next();
			if(!q[p-1]) {
				if(s.equals("AC")) {
					ac++;
					wa += q_wa[p-1];
					q[p-1] = true;
				}else {
					q_wa[p-1]++;
				}
			}
			
			
			
		}
		
		System.out.println(ac + " " + wa);
		

	}
}

Measured memory_bytes: 50204
import Control.Monad
import Data.Array.IArray
import Data.Array.ST
import Data.Bool
import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines

put = C.pack . show

sol ([n,ma,mb]:abcs) = bool (-1) c (c < n*maxc)
  where
  tbl = dp (n*maxab) (n*maxc) abcs
  c = minimum . fmap (tbl!) . takeWhile (\(a,b) -> max a b<=n*maxab) $
    fmap ((,) <$>  (*ma) <*> (*mb)) [1..] 

maxab = 10 :: Int
maxc = 100 :: Int

dp sz mx abcs = runSTUArray $ do
  tbl <- newArray ((0,0),(sz,sz)) (mx :: Int)
  writeArray tbl (0,0) 0
  forM_ abcs $ \[a,b,c] -> do
    forM_ [sz,sz-1..a] $ \i -> do
      forM_ [sz,sz-1..b] $ \j -> do
        v <- readArray tbl (i-a,j-b)
        when (v<mx) $ do
          v' <- readArray tbl (i,j)
          writeArray tbl (i,j) (min v' (v+c))
  return tbl

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

vector<ll> v;

int main() {
    int cnt = 0;
    int k;
    cin >> k;
    queue<string> q;
    for (int i = 1; i <= 9; ++i) {
        q.push(to_string(i));
    }
    while (cnt < 100000) {
        int size = q.size();
        for (int i = 0; i < size; ++i) {
            string t = q.front();
            q.pop();
            cnt++;
            v.push_back(atol(t.c_str()));
            int m = t.size();
            q.push(t + (char)(t[m - 1]));
            if (t[m - 1] != '0')
                q.push(t + (char)(t[m - 1] - 1));
            if (t[m - 1] != '9')
                q.push(t + (char)(t[m - 1] + 1));
        }
    }

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

    cout << v[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 28784
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Judge Status Summary
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int an = 0, wn = 0, tn = 0, rn = 0;
  while (n--) {
    scanf("%s", s);
    if (s[0] == 'A') an++;
    else if (s[0] == 'W') wn++;
    else if (s[0] == 'T') tn++;
    else rn++;
  }

  printf("AC x %d\n", an);
  printf("WA x %d\n", wn);
  printf("TLE x %d\n", tn);
  printf("RE x %d\n", rn);
  return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c,d;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else
    {
        c=n/1000;
        d=((c+1)*1000)-n;
        cout<<d<<endl;
    }
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int N;
	int[][] t, memo;

	void run() {
		for (;;) {
			N = sc.nextInt();
			if (N == 0) return;
			t = new int[N][N + 1];
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N + 1; j++) {
					t[i][j] = sc.nextInt();
				}
			}
			memo = new int[N][1 << N];
			int min = Integer.MAX_VALUE / 2;
			for (int i = 0; i < N; i++) min = Math.min(min, t[i][0] + tsp(i, 1 << i));
			System.out.println(min);
		}
	}

	int tsp(int v, int mask) {
		if (memo[v][mask] != 0)    return memo[v][mask];
		if (mask == (1 << N) - 1)  return 0;

		int res = Integer.MAX_VALUE / 2;
		for (int i = 0; i < N; i++) {
			if ((mask & (1 << i)) != 0) continue;
			int s = t[i][0];
			for (int j = 0; j <= N; j++) {
				if (i != j && (mask & (1 << j)) != 0) s = Math.min(s, t[i][j + 1]);
			}
			res = Math.min(res, s + tsp(i, mask | 1 << i));
		}
		return memo[v][mask] = res;
	}

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

Measured memory_bytes: 70316
n , m = map(int, input().split(" "))

a = [0] * m
b = [0] * m
c = list()
d = list()

def to_int(c):
    a = [0 , 1, 2, 4, 8, 16 , 32, 64, 128, 256, 512, 1024, 2048]
    result = 0
    for ci in c:
        result += a[ci]
    return result


state = [-1] * 2**n
state[0] = 0

for i in range(m):
    a[i], b[i] = map(int, input().split(" "))
    c.append( list(map(int, input().split(" "))))
    d.append(to_int(c[i]))
    #print("-----")
    for j in range(0,2**n):
        #print("{} {} {}".format(j, state[j], (j|d[i])))

        if state[j] != -1 and (state[j | d[i]] == -1 or state[j | d[i]] > state[j] + a[i]):
            state[j | d[i]] = state[j] + a[i]
    #print(state)
#print(d)
#print(state)
print(state[2**n-1])


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

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



int n, q;
int par[maxn];
int siz[maxn];

int parent(int x) {
    return par[x]==x ? x : par[x]=parent(par[x]);
}

void join(int x, int y) {
    x = parent(x);
    y = parent(y);
    if (x==y) return;
    if (siz[x]<siz[y]) swap(x,y);
    siz[x] += siz[y];
    par[y] = x;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>q;
    for (int i=0; i<n; i++) {
	siz[i]=1;
	par[i]=i;
    }
    while (q--) {
	int t;
	cin>>t;
	int u,v;
	cin>>u>>v;
	if (t==0) {
	    join(u,v);
	} else {
	    cout<<(parent(u)==parent(v))<<"\n";
	}
    }
    
    
    return 0;
}


Measured memory_bytes: 5144
#include <stdio.h>

int main(void)
{
	char s;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%c",&s);
		if(s=='Y'){
			puts("Four");
			return 0;
		}
	}
	puts("Three");
	return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			int n = s.Length + 1;
			long[] a = new long[n];
			int count = 1;
			bool left = s[0] == '>';
			for (int i = 1; i < n - 1; i++) {
				if (s[i] == '>') {
					if (left) {
						++count;
					} else {
						for (int j = 0; j < count + 1; j++) {
							a[i - j] = count - j;
						}

						left = true;
						count = 1;
						
					}
				} else {
					if (left == false) {
						++count;
					} else {
						for (int j = 0; j < count + 1; j++) {
							a[i - j] = Math.Max(j, a[i - j]);
						}

						left = false;
						count = 1;
					}
				}
			}

			if (count >= 1) {
				if (left) {
					for (int j = 0; j < count + 1; j++) {
						a[n - 1 - j] = Math.Max(j, a[n - 1 - j]);
					}
				} else {
					for (int j = 0; j < count + 1; j++) {
						a[n - 1 - j] = count - j;
					}
				}
			}

			long ans = a.Sum();
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    vector<int> perm(n);
    for (int i = 0; i < n; i++) {
        perm[i] = i + 1;
    }
    while (1) {
        for (int i = 0; i < n - 1; i++) {
            int x_dist = x[perm[i + 1] - 1] - x[perm[i] - 1];
            int y_dist = y[perm[i + 1] - 1] - y[perm[i] - 1];
            sum += sqrt(x_dist * x_dist + y_dist * y_dist);
        }
        if (!next_permutation(all(perm))) break;
    }
    int fac = 1;
    for (int i = 1; i <= n; i++) {
        fac *= i;
    }
    cout << setprecision(10) << sum / fac << endl;
}

Measured memory_bytes: 256
//It is coded by ning_mew on 7.16
    #include<bits/stdc++.h>
    #define ls(x) (x*2)
    #define rs(x) (x*2+1)
    using namespace std;
     
    const int maxn=2e5+7,inf=1e9+7;
     
    int n,m,ans=0;
    struct Opt{int l,r;}p[maxn];
    struct Node{int lazy,maxx;}node[maxn*4];
     
    bool cmp(const Opt &A,const Opt &B){return A.l<B.l;}
    void pushdown(int num,int nl,int nr){
      if(!node[num].lazy)return;
      int lz=node[num].lazy; node[num].lazy=0;
      node[ls(num)].maxx+=lz;node[ls(num)].lazy+=lz;
      node[rs(num)].maxx+=lz;node[rs(num)].lazy+=lz;    
    }
    void update(int num){node[num].maxx=max(node[ls(num)].maxx,node[rs(num)].maxx);}
    void build(int num,int nl,int nr){
      node[num].lazy=0; if(nl==nr){node[num].maxx=nr-m-1;return;}
      int mid=(nl+nr)/2;
      build(ls(num),nl,mid);build(rs(num),mid+1,nr);
      update(num);
    }
    void add(int num,int nl,int nr,int ql,int qr,int ad){
      if(ql<=nl&&nr<=qr){node[num].maxx+=ad;node[num].lazy+=ad;return;}
      if(nr<ql||qr<nl)return;
      int mid=(nl+nr)/2;pushdown(num,nl,nr);
      add(ls(num),nl,mid,ql,qr,ad);add(rs(num),mid+1,nr,ql,qr,ad);
      update(num);return;
    }
    int quary(int num,int nl,int nr,int ql,int qr){
      if(ql<=nl&&nr<=qr)return node[num].maxx;
      if(nr<ql||qr<nl)return -inf;
      int mid=(nl+nr)/2;pushdown(num,nl,nr);
      return max(quary(ls(num),nl,mid,ql,qr),quary(rs(num),mid+1,nr,ql,qr));
    }
    int main(){
      scanf("%d%d",&n,&m);
      for(int i=1;i<=n;i++)scanf("%d%d",&p[i].l,&p[i].r);
      sort(p+1,p+n+1,cmp);p[n+1].l=inf;
      build(1,0,m+1);
      for(int i=1;i<=n;i++){
        add(1,0,m+1,0,p[i].r,1);
        if(p[i].l!=p[i+1].l&&p[i].l<=m-1)ans=max(ans,quary(1,0,m+1,p[i].l+1,m+1)-p[i].l);
      }ans=max(ans,n-m);printf("%d\n",ans);
      return 0;
    }

Measured memory_bytes: 7936
import math
from operator import itemgetter
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()
K = I()

tmp = s[K-1]

ans = ""
for i in range(N):
	if s[i] != tmp:
		ans += "*"
	else:
		ans += s[i]

print(ans)

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

int main() {
 string s;
  cin>>s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi") cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if(s == u) a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}


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

using namespace std;
#define int long long

signed main(){
    string N;
    string S;
    for(int i=0;i<4;i++){
        cin >> N;
        S += N;
    }
    sort(S.begin(),S.end());
    
    if(S == "1479") cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    b[0] = a[0];
    for(int i = 0; 2*i+2 < n; i++) {
        b[0] += -a[2*i+1] + a[2*i+2];
    }
    cout << b[0] << endl;
    rep(i, n-1) {
        b[i+1] = 2*a[i] - b[i];
        cout << b[i+1] << endl;
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int toll[7][7] = {
	{   0,  300,  500,  600,  700, 1350, 1650},
	{ 300,    0,  350,  450,  600, 1150, 1500},
	{ 500,  350,    0,  250,  400, 1000, 1350},
	{ 600,  450,  250,    0,  250,  850, 1300},
	{ 700,  600,  400,  250,    0,  600, 1150},
	{1350, 1150, 1000,  850,  600,    0,  500},
	{1650, 1500, 1350, 1300, 1150,  500,    0}  
};
int d[7][7] = {
	{ 0,  6, 13, 18, 23, 43, 58},
	{ 6,  0,  7, 12, 17, 37, 52},
	{13,  7,  0,  5, 10, 30, 45},
	{18, 12,  5,  0,  5, 25, 40},
	{23, 17, 10,  5,  0, 20, 35},
	{43, 37, 30, 25, 20,  0, 15},
	{58, 52, 45, 40, 35, 15,  0}
};

int half(int x){
	if((x / 2) % 50) x += 50;
	return x / 2;
}

bool is_half(int h, int m, int d){
	int t = h * 60 + m;
	return ( 17*60 + 30 <= t && t <= 19*60 + 30 && d <= 40 );
}

int main(){
	int s;
	while( cin >> s, s ){
		int h1, m1, h2, m2, g, ans;
		cin >> h1 >> m1 >> g >> h2 >> m2;
		s--; g--;
		bool flag = ( is_half(h1,m1,d[s][g]) || is_half(h2,m2,d[s][g]) );
		ans = flag? half(toll[s][g]) : toll[s][g] ;
		cout << ans << endl;
	}
}

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

using ll = long long;
using namespace std;

int main() {
    ll inf = 1e18;
    int n, m;
    cin >> n >> m;
    ll d[n];
    d[0] = 0;
    for (int i = 1; i < n; ++i) d[i] = inf;
    vector<vector<int>> a(m, vector<int>(3));
    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        a[i][0] = l-1;
        a[i][1] = r-1;
        a[i][2] = c;
    }
    sort(a.begin(), a.end());
    for (const auto& e : a) {
        int l = e[0], r = e[1], c = e[2];
        for (int j = l; j < r; ++j) {
            ll t = d[j] + c;
            if (t < d[r]) d[r] = t;
        }
    }
    if (d[n-1] == inf) cout << -1 << endl;
    else cout << d[n-1] << endl;
}

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

#define int long long

signed main()
{
  int n;
  std::cin >> n;
  
  std::pair<int, int> a[n];
  for(int i = 0; i < n; i++) {
    std::cin >> a[i].first;
    a[i].second = i%2;
  }
  
  std::sort(a, a+n);
  
  int ans = 0;
  for(int i = 0; i < n; i++)
    ans += (i%2 != a[i].second);
  
  std::cout << ans/2 << std::endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FIO                     ios::sync_with_stdio(false); cin.tie(nullptr)
#define TC(t)                   int t; cin >> t; for(int i = 1; i <= t; i++)
#define deb(x)                  cerr << #x << " = " << x << endl
#define deb2(x, y)              cerr << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)             for(i = a; i < n; i++)
#define f1(i, a, n)             for(i = a; i <= n; i++)
#define ini(x, y)               memset(x, y, sizeof(x))
#define all(x)                  x.begin(), x.end()
#define sz(x)                   x.size()
#define ll                      long long int
#define pb                      push_back
#define ppb                     pop_back
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define M                       1000000007
#define endl                    '\n'
#define bits(x)                 __builtin_popcountll(x)
#define zrbits(x)               __builtin_ctzll(x)
#define vi                      vector<int>
#define pii                     pair<int,int>
#define vpii                    vector<pii>
#define ordered_set             tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define multi_ordered_set       tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>

const int N = 1e5 + 1;
const int MX = 1e9;
const ll INF = 1e18;

using namespace std;
using namespace __gnu_pbds;

inline ll ceil(ll a,ll b) {return (a % b ? a / b + 1 : a / b);}
inline ll mod(ll x) {return ( (x % M + M) % M );}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {for(auto& x : v) os << x << " "; return os << '\n';}


vi g[N];
int vis[N];

void dfs(int n) {
        vis[n] = 1;
        for(auto it : g[n]) {
                if(vis[it] == 0) dfs(it);
        }
}

void solve() {
        ll n, m, i;
        cin >> n >> m;
        while(m--) {
                ll x, y;
                cin >> x >> y;
                g[x].pb(y);
                g[y].pb(x);
        }

        int ans = -1;
        f1(i, 1, n) {
                if(vis[i] == 0) {
                        ans++;
                        dfs(i);
                }
        }

        cout << ans << endl;
}

int main () {
        FIO;
        // TC(t)
        solve();
        return 0;
}

Measured memory_bytes: 9992
### constant

MAX_D = 10
GOAL = ' ABCDEFGHIJK '

NEIGHBORS = [
  [2],
  [2, 5],
  [0, 1, 3, 6],
  [2, 7],
  [5],
  [1, 4, 6, 9],
  [2, 5, 7, 10],
  [3, 6, 8, 11],
  [7],
  [5, 10],
  [6, 9, 11, 12],
  [7, 10],
  [10]
]

### subroutines

def move(s, i, j)
  s0 = s.clone
  s0[i] = s0[j]
  s0[j] = ' '
  s0
end

def neighbors(s)
  nbrs = []

  i0 = s.index(' ')
  for ni in NEIGHBORS[i0]
    nbrs << move(s, i0, ni)
  end

  i1 = s.index(' ', i0 + 1)
  for ni in NEIGHBORS[i1]
    nbrs << move(s, i1, ni)
  end

  nbrs
end

### main

gdists = {}
gdists[GOAL] = 0
queue = [GOAL]

while ! queue.empty?
  v = queue.shift
  next if gdists[v] >= 10

  for nv in neighbors(v)
    if gdists[nv].nil?
      gdists[nv] = gdists[v] + 1
      queue << nv
    end
  end
end

while true
  p1 = gets.strip.to_i
  break if p1 == -1

  ps = [p1]
  4.times.each do
    ps += gets.strip.split(' ').map{|s| s.to_i}
  end

  st = ps.map{|p| (p != 0) ? (p + 64).chr : ' '}.join('')

  queue = [st]
  dists = {}
  dists[st] = 0

  sumd = 'NA'

  while ! queue.empty?
    v = queue.shift
    if ! gdists[v].nil?
      sumd = dists[v] + gdists[v]
      sumd = 'NA' if sumd > 20
      break
    end

    next if dists[v] >= 10

    for nv in neighbors(v)
      if dists[nv].nil?
        dists[nv] = dists[v] + 1
        queue << nv
      end
    end
  end

  puts sumd
end

Measured memory_bytes: 13936
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const LL LINF = 1e18;
int n, m;
int cost[1005];
int mask[5000];
LL dp[5000];

int main(){
	n = re<int>();
	m = re<int>();
	for (int i = 1; i <= m; i++){
		cost[i] = re<int>();
		for (int j = 0, b = re<int>(); j < b; j++){
			mask[i] |= (1 << (re<int>() - 1));
		}
	}
	fill(dp + 1, dp + (1<<n), LINF);
	for (int i = 1; i <= m; i++){
		for (int b = 0; b < (1 << n); b++){
			dp[b | mask[i]] = min(dp[b | mask[i]], dp[b] + cost[i]);
		}
	}
	if (dp[(1 << n) - 1] == LINF) dp[(1<<n) - 1] = -1;
	printf("%lld\n", dp[(1<<n) - 1]);
	return 0;
}


Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

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

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var a, b int

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

	a, b = nextInt(), nextInt()

	if a <= 0 && b >= 0 {
		fmt.Println("Zero")
	} else if a > 0 {
		fmt.Println("Positive")
		return
	} else if b < 0 {
		if (1-a-b)%2 == 0 {
			fmt.Println("Positive")
		} else {
			fmt.Println("Negative")
		}
	}
}


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

void solve() {
    string s, t;
    cin >> s >> t;
    if(s.size() == t.size() - 1) {
        for(ll i = 0; i < s.size(); i++) {
            if(s[i] != t[i]) {cout << "No"; return;}
        }
        cout << "Yes";
    }
    else cout << "No";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
use proconio::input;
use std::collections::HashMap;

fn main() {
    input!(s: [String]);

    let mut map = HashMap::new();
    for s in &s {
        *map.entry(s).or_insert(0) += 1;
    }

    for s in &["AC", "WA", "TLE", "RE"] {
        println!("{} x {}", s, map.get(&s.to_string()).unwrap_or(&0))
    }
}


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


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

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

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


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
vector<vector<int> > v(26);
int main(void) {
    string s; cin >> s;
    for(int i=0; i<26; ++i){
        v[i].push_back(0);
    }
    for(int i=0; i<(int)s.size(); ++i){
        v[s[i]-'a'].push_back(i+1);
    }
    for(int i=0; i<26; ++i){
        v[i].push_back((int)s.size());
    }

    
    int ans=10000;
    for(int i=0; i<26; ++i){
        
        int t = s.size()-v[i][v[i].size()-2];
        int maxr=t;
        for(int j=1; j<(int)v[i].size(); ++j){
            maxr=max(v[i][j]-v[i][j-1]-1, maxr);
        }
        ans = min(ans, maxr);
    }
    if(ans==(int)s.size()) cout << 0 << endl;
    else cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    cout << (((s[0]==s[1] && s[0]==s[2]) || (s[1]==s[2] && s[2]==s[3])) ? "Yes":"No") << endl;
    
    return 0;
}


Measured memory_bytes: 3652
x = int(input())
if x<=599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9196
MOD = 10**9 + 7

N, K = map(int, input().split())
As = list(map(int, input().split()))

numInvs = [0] * N
for i, Ai in enumerate(As):
    for Aj in As[i+1:]:
        if Ai > Aj:
            numInvs[i] += 1

nums = [0] * N
for i, Ai in enumerate(As):
    for Aj in As:
        if Ai > Aj:
            nums[i] += 1

ans = 0
for numInv, num in zip(numInvs, nums):
    ans += numInv*K % MOD
    ans += num*K*(K-1)//2 % MOD
    ans %= MOD

print(ans)


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

int main() {
	long long int a, b, n[2000], i, s = 0;
	cin>>a>>b;
	n[0] = -1;
	for (i = 1; i < 2000; i++)
	{
	    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b)
	    {
	        n[s] = i;
	        s++;
	    }
	}
	sort(n, n + s);
	cout<<n[0];
	return 0;
}

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

using namespace std;

int getH(int N, const vector<int> &x, const vector<int> &y, const vector<int> &h, int cx, int cy)
{
	vector<int> d(201, -1);
	for (int i = 0; i < N; ++i) {
		int z = abs(x[i] - cx) + abs(y[i] - cy);
		if (d[z] < 0) {
			d[z] = h[i];
		}
		else if (d[z] != h[i]) {
			return -1;
		}
	}
	for (int z = 0; z <= 200; ++z) {
		if (d[z] > 0) {
			for (int k = 0; k < 200; ++k) {
				if (d[k] < 0) {
					continue;
				}
				if (d[k] != max(0, d[z] + (z - k))) {
					return -1;
				}
			}
			return d[z] + z;
		}
	}
	return -1;
}

void solve(int N, const vector<int> &x, const vector<int> &y, const vector<int> &h)
{
	for (int cx = 0; cx <= 100; ++cx) {
		for (int cy = 0; cy <= 100; ++cy) {
			int H = getH(N, x, y, h, cx, cy);
			if (H >= 0) {
				cout << cx << " " << cy << " " << H << endl;
				return;
			}
		}
	}
}

int main()
{
	int N;
	cin >> N;
	vector<int> x(N), y(N), h(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i] >> h[i];
	}
	solve(N, x, y, h);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
from math import gcd
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

K=int(input())
if K%7==0:
    K/=7
tmp=1%K
for i in range(1,10**7):
    if tmp==0:
        print(i)
        exit()
    tmp*=10
    tmp+=1
    tmp%=K
print(-1)

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

int main(){
    string N;
    cin >> N;
    bool x = false;
    rep(i,N.size()){
        if(N[i] == '7') x = true;
    }
    cout << (x ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3584
from collections import deque
from itertools import product


def bfs(x, y):
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([(x, y)])

    while len(que) > 0:
        x, y = que.popleft()
        if (x, y) == (Dw - 1, Dh - 1):
            return dist[y][x]

        for i, j in product(range(-2, 3), repeat=2):
            cnt = (abs(i) + abs(j) >= 2)
            i, j = x + i, y + j
            if (0 <= i < w and 0 <= j < h and
                    dist[j][i] > dist[y][x] + cnt and s[j][i] == '.'):
                dist[j][i] = dist[y][x] + cnt
                if cnt == 0:
                    que.appendleft((i, j))
                elif cnt == 1:
                    que.append((i, j))
    return -1


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

print(bfs(Cw - 1, Ch - 1))


Measured memory_bytes: 96700