akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using F = double;

struct Point {F x, y;};
struct Interval {
  F lx, rx;
  int l, r;
  Interval(F lx, F rx, int l, int r) : lx(lx), rx(rx), l(l), r(r) {}
  bool operator<(auto o) const {
    if(lx != o.lx) return lx < o.lx;
    if(rx != o.rx) return rx < o.rx;
    if(l != o.l) return l < o.l;
    return r < o.r;
  }
};

const F PI = acos(-1);
const F INF = 1e9;

int N;
vector<Point> P;

F tune(auto a) {
  while(a  < 0) a += PI;
  while(PI < a) a -= PI;
  return a;
}

F projection(auto p, auto a) {
  return p.x * sin(a) + p.y * cos(a);
}

tuple<F, F, F> coefficient(auto a) {
  vector<pair<F, int>> lx;
  for(auto i = 0; i < P.size(); ++i) lx.emplace_back(projection(P[i], a) - 1, i);
  sort(begin(lx), end(lx));

  vector<pair<int, int>> shadow;
  shadow.emplace_back(lx.front().second, lx.front().second);
  for(auto i: lx) {
    auto rx = projection(P[shadow.back().second], a) + 1;
    if(rx < i.first) shadow.emplace_back(i.second, i.second);
    else             shadow.back().second = i.second;
  }

  F A = 0, B = 0, C = 0;
  for(auto s: shadow) {
    auto l = P[s.first];
    auto r = P[s.second];
    A += r.x - l.x;
    B += r.y - l.y;
    C += 1 - -1;
  }
  return make_tuple(A, B, C);
}

vector<F> solve() {
  vector<F> angle = {0, PI};
  for(auto j = 0; j < N; ++j) for(auto i = 0; i < j; ++i) {
    auto dx = P[i].x - P[j].x;
    auto dy = P[i].y - P[j].y;
    auto d = hypot(dx, dy);
    auto a = atan2(dy, dx);
    angle.emplace_back(tune(-a));
    angle.emplace_back(tune(asin(2 / d) - a));
    angle.emplace_back(tune(asin(-2 / d) - a));
  }
  sort(begin(angle), end(angle));
  angle.erase(unique(begin(angle), end(angle)), end(angle));

  F a_min = INF, a_max = -INF;
  F s_min = INF, s_max = -INF;
  for(auto i = 1; i < angle.size(); ++i) {
    auto low  = angle[i - 1];
    auto high = angle[i];
    auto middle = (low + high) / 2;

    F a, b, c;
    tie(a, b, c) = coefficient(middle);

    for(auto i: {low, tune(PI / 2 - atan2(b, a)), high}) if(low <= i && i <= high) {
      auto s = a * sin(i) + b * cos(i) + c;
      if(s_min > s) {
        s_min = s;
        a_min = i;
      }
      if(s_max < s) {
        s_max = s;
        a_max = i;
      }
    }
  }

  return {a_min, a_max};
}

int main() {
  while(cin >> N, N) {
    P = vector<Point>(N);
    for(auto& i: P) cin >> i.x >> i.y;

    for(auto i: solve()) cout << setprecision(15) << fixed << i << endl;
  }
}

Measured memory_bytes: 3832
#include <stdio.h>

int main(){
    int A,B,C,ans;
    scanf("%d %d %d", &A, &B, &C);
    if (A>=B && A>=C) {
        ans = 10*A+B+C;
    } else if (B >= C){
        ans = A+10*B+C;
    } else {
        ans = A+B+10*C;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

int main(){
   int N;
   std::cin >> N;
   std::vector<std::string> s(N);
   for(int i=0; i<N; ++i)
      std::cin >> s[i];

   int countA = 0;
   int countB = 0;
   int countAB = 0;
   int ans = 0;
   for(int i=0; i<N; ++i){
      if(s[i][0]=='B'){
         if(s[i][s[i].size()-1]=='A') ++countAB; 
	 ++countB; 
      }
      if(s[i][s[i].size()-1]=='A') ++countA; 
      for(int j=0; j<s[i].size()-1; ++j)
	 if(s[i][j]=='A' && s[i][j+1]=='B') ++ans;
   }
   int n = std::min(countA,countB);
   ans += n;
   if(countAB>0 && countAB==countA && countAB==countB) ans -= 1;
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;



int main()
{
    //int m,n,o=0,i,j,k;
    int sum=0,range=0;
    long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>m;
    n=o=0;
    while(m>=10)
    {
        n+=m%10;
        m/=10;
        k++;
    }
    o=9*k+m-1;
    n+=m%10;
    cout<<max(o,n);
    return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int n, t;
    cin >> n >> t;

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

    int sum = 0;
    for(int i = 0; i < n - 1; i++){
        sum += min(t, a[i+1] - a[i]);
    }
    sum += t;

    cout << sum << endl;

    return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
int get(int x){
    return (x * (x - 1)) / 2;
}
signed main(){

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

    int n;
    cin >> n;
    int a[n+1]{};
    int b[n+1]{};

    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    int res = 0;
    for(int i = 1 ; i <= n ; i++){
        res += get(b[i]);
    }
    for(int i = 1 ; i <= n ; i++){
        int x = b[a[i]];
        int ans = res - get(x);
        ans += get(x - 1);
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

#define N 1010
ll a[N][N];
int main(){
    ll k,n;
    cin>>k;
    if(k==1){
	cout<<1<<endl;cout<<1<<endl;
	return 0;
    }
    n=(k+3)/4*2;
    cout<<n<<endl;
    lol(i,n/2){
	lol(j,n)a[i*2][(j+i*2)%n]=j;
	lol(j,n){
	    ll res=j;
	    if(n+j<k)res+=n;
	    a[i*2+1][(j+1+i*2)%n]=res;
	}
    }
    lol(i,n){
	lol(j,n){
	    if(j)cout<<" ";
	    cout<<a[i][j]+1;
	}cout<<endl;
    }
    return 0;
}


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

n = int(readline())
lst1 = list(map(int,readline().split()))

lst2 = [0]*n

for i in range(n-1):
    lst2[lst1[i]-1] += 1

for i in lst2:
    print(i)

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

int main(){
	
	int c[6]={500,100,50,10,5,1};
	int n;
	
	
	while(cin>>n){
		if(n!=0){
		int k=0;
		int s=0;
		n=1000-n;
	
	while(n>0){
		if(n-c[k]>=0){
			n=n-c[k];
			s++;
		}
		else
			k++;
	}
			cout<<s<<endl;
	}
	
	else
		break;
	}
	
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
int main(void){
    
    int X;
    cin >> X;
    
    int Prime[110000];
    for(int i=2;i<110000;i++){
        for(int j=i;j<110000;j=j+i){
            if(j==i&&Prime[j]==0)continue;
            Prime[j]=-1;
        }
    }
    for(int i=X;i<110000;i++){
        if(Prime[i]==0){
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
#define INF 1L << 50

typedef pair<int, int> P;

signed main() {
  int n, C;
  cin >> n >> C;
  int d[C + 1][C + 1];
  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= C; j++) {
      cin >> d[i][j];
    }
  }
  int c[n + 1][n + 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> c[i][j];
    }
  }
  int count[3][C + 1];
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j <= C; j++) {
      count[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      count[(i + j) % 3][c[i][j]]++;
    }
  }
  int ans = INF;
  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= C; j++) {
      for (int k = 1; k <= C; k++) {
        if (i == j || j == k || k == i) continue;
        int res = 0;
        for (int l = 1; l <= C; l++) {
          res += count[0][l] * d[l][i];
          res += count[1][l] * d[l][j];
          res += count[2][l] * d[l][k];
        }
        //cout << i << " " << j << " " << k << " " << res << endl;
        ans = min(ans, res);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using  namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
        inverse[MAX] = {0};

void smodfact() {
    factorial[0] = factorial[1] = 1;
    finverse[0] = finverse[1] = 1;
    inverse[1] = 1;
    for(int i = 2; i < MAX; ++i) {
        factorial[i] = factorial[i - 1] * i % N;
        inverse[i] = N - (inverse[N % i] * (N / i)) % N;
        finverse[i] = finverse[i - 1] * inverse[i] % N;
    }
}

long long calccomb(long long n, long long k) {
    if(n == k && n == 0) return 1;
    if(n < 0 || k < 0 || n < k) return 0;
    return factorial[n] * finverse[k] % N * finverse[n - k] %
           N;
}

long long n,m;

long long solve();

int main(){
    smodfact();
    cin >> n >> m;
    cout << solve() << endl;
    return 0;
}

long long solve(){
    long long ans = 1;
    for(long long i = 2;i * i <= m;++i){
        long long cnt = 0;
        while(m % i == 0){
            ++cnt;
            m /= i;
        }
        ans *= calccomb(n+cnt-1,n-1);
        ans %= N;
    }
    if(m > 1)ans *= calccomb(n,n-1);
    return ans % N;
}

Measured memory_bytes: 11904
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
    let _n = read_line().trim().parse::<u64>().unwrap();
    let line = read_line();
    let mut v: Vec<&str> = line.split_whitespace().collect();
    v.reverse();
    println!("{}", v.join(" "));
}



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

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

  int n;
  cin >> n;

  if(n % 1000 == 0) {
    cout << 0 << '\n';
  } else {
    cout << 1000 - n % 1000 << '\n';
  }
}


Measured memory_bytes: 3648
#include <stdio.h>

int n,A[50];

int solve(int i,int m){
	if(m==0) return 1;
	if(i>=n) return 0;
	int res = solve(i+1,m)||solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

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

int main(){
    int k,s;
    cin >> k >> s;
    int ans = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-i-j>=0 && s-i-j<=k)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){

  int n;
  cin >> n;
  int a[n];
  int b[n];
  int c[n-1];
  int i = 0;
  for(i = 0;i<n;i++){
    cin >> a[i];
  }
  for(i = 0;i<n;i++){
    cin >> b[i];
  }
  for(i = 0;i<n-1;i++){
    cin >> c[i];
  }

  int sum = 0;

  for(i = 0;i < n;i++){
    sum += b[a[i]-1];
   
    if(a[i] - a[i-1] == 1){
      sum += c[a[i-1]-1];
    }
    
    
  }

  cout << sum << endl;
  
  return 0;

}

Measured memory_bytes: 256
//X3, Y3 = (0, 0)とおいて、X1Y2 - X2Y1 = Sを目指す.
//ピンとこないので、具体例を試す。
//S = 10^9なら簡単で、10^9・1 - 0・0 = 10^9
//S = 10^9 + 7なら、  10^9・2 - 1・(10^9-7) = 10^9 + 7
//
//S = Q * 10^9 + R (Rは余り）とおく
//X1 = 10^9, Y2 = Q + 1, X2 = 1, Y1 = 10^9 - Rとしてみると、面積はちょうどSになる。
//S = 10^18のとき、Q + 1が10^9 + 1になるので注意。
//このときは、10^9・10^9 - 1・0 = 10^18にすればOK。
#include <iostream>
#define int long long
using namespace std;

signed main() {
	int s;
	cin >> s;
	
	int m = 1e+9;
	int q = s / m;
	int r = s % m;
	
	int x1 = m;
	int y2 = q + 1;
	int x2 = 1;
	int y1 = m - r;
	
	if (y2 > m) {
		y2--;
		y1 -= m;
	}
	
	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << 0 << " " << 0 << endl;
	cerr << "area = " << x1 * y2 - x2 * y1 << endl;
	return 0;
}

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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for (int i = 0; i * R <= N; i++)for (int j = 0; i * R + j * G <= N; j++) {
		if ((N - i * R - j * G) % B == 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int z=sc.nextInt();
		System.out.println(z+" "+x+" "+y);
	}
}


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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3,y3, x4,y4;
    if(x1 == x2 || y1 == y2) {
        if(x1 == x2) {
            if(y1 > y2) {
                int diff = abs(y1-y2);
                x3 = x2+diff; y3 = y2;

                x4 = x3; y4 = y3+diff;
            }
            else {
                int diff = abs(y1-y2);
                x3 = x2-diff; y3 = y2;
                x4 = x3; y4 = y3-diff;
            }
        }
        else {
            if(x1<x2) {
                int diff = abs(x2-x1);
                x3 = x2; y3 = y2+diff;
                x4 = x3-diff; y4 = y3;
            }
            else {
                int diff = abs(x2-x1);
                x3 = x2; y3 = y2-diff;
                x4 = x3+diff; y4 = y3;
            }

        }
    }
    else {
        int vecx = x2-x1, vecy = y2 - y1;
        x3 = x2 - vecy, y3 = y2 + vecx;
        //vecx = (x3-x2), vecy =  (y3-y2);
        x4 = x1 - vecy, y4 = y1 + vecx;
    }
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";

    return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    H = [int(c) for c in input().split()]
    for i in range(N - 1):
        if (H[i] > H[i + 1]):
            print("No")
            sys.exit()
        elif (H[i] == H[i + 1]):
            continue
        else:
            H[i + 1] -= 1
    print("Yes")

if __name__ == '__main__':
    main()

Measured memory_bytes: 23120
main = do
  s <- getLine
  print (revcomp s)

revcomp s = comb2 l - sum (map comb2 napp) + 1
  where
    l = length s
    napp = map (\c -> length (filter (==c) s)) ['a'..'z']

comb2 n = div (n * (n-1)) 2

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

string yesNo(bool val)
{
  if(val)
  {
    return "Yes";
  }
  else {
    return "No";
  }
}
int main()
{
  int a;
  cin >> a;
  int ans = a;

  cout << fixed << yesNo(a >= 30) << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int a[101];
    a[1]=2;
    cin>>n;
    if(n==1) {
        cout<<1<<endl;
        return 0;
    }
    for(int i=2; i<=100; i++) {
        a[i]=a[i-1]*2;
    }
    for(int i=1; i<=100; i++) {
        if(n>=a[i]&&n<a[i+1]) {
            cout<<a[i]<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int HP = Integer.parseInt(S[1]);
    
    int[][] val = new int[N][2];
    int max = 0;
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      val[i][0] = Integer.parseInt(T[0]);
      val[i][1] = Integer.parseInt(T[1]);
      max = val[i][0] > max ? val[i][0] : max;
    }
    
    Arrays.sort(val, (a, b)->Integer.compare(b[1], a[1]));
    int ans = 0;
    for(int i = 0; i < N; i++){
      if(max < val[i][1]){
        HP -= val[i][1];
        ans++;
      }
      if(HP <= 0){
        System.out.println(ans);
        return;
      }
    }
    
    ans += HP / max;
    if(HP%max != 0){
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 128832
#include <iostream>
using namespace std;
typedef long long ll;

ll ncr(ll n , ll r){
	long long ans = 1;
	int d[64] = {0};
	for(int i = 1 ; i <= r ; i++) d[i] = 1;
	for(int i = 0 ; i < r  ; i++){
		ans *= n-i;
		for(int j = 1 ; j <= r ; j++)
			if(d[j] && ans % j == 0){
				ans /= j;
				d[j] = 0;
			}
	}
	return ans;
}

string f(ll n,ll bit,ll m){
	if(bit == 0) return string(n,'0');
	ll cur = 0;
	for(int i = bit ; i <= n ; i++){
		ll next = cur+ncr(i-1,bit-1);
		if(m <= next && m >= cur+1) return f(i-1,bit-1,m-cur) + "1" + string(n-i,'0');
		cur = next;
	}
}
int main(){
	ll n,m;
	while(cin >> n >> m && (n||m) ){
		int bit = n;
		ll cur = 0;
		for(int i = 0 ; i <= n ; i++){
			ll next = cur + ncr(n,i);
			if(m <= next && m >= cur+1){ bit = i; break;}
			cur = next;
		}
		m -= cur;
		if(bit == 0) cout << string(n,'0') << endl;
		else{
			string r = f(n,bit,m);
			for(int i = 0 ; i < r.size() ; i++) cout << r[r.size()-1-i];
			cout << endl;
		}
	}
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const double EPS=1e-7;
struct edge{
    int to,dis,lim;
    edge(int a,int b,int c):to(a),dis(b),lim(c){}
};
typedef tuple<double,int,int,int>state;
vector<edge>G[30];
double dist[30][30][31];

signed main(){
    int N,M;
    int S,T;
    while(cin>>N>>M,N||M){
        cin>>S>>T;
        S--;T--;

        rep(i,N)G[i].clear();

        rep(i,M){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            a--;b--;
            G[a].pb(edge(b,c,d));
            G[b].pb(edge(a,c,d));
        }
        fill_n(**dist,30*30*31,1001001001);
        dist[S][S][0]=0;
        priority_queue<state,vector<state>,greater<state>>que;
        que.push(make_tuple(0,S,S,0));
        while(que.size()){
            double c;
            int v,p,vv;
            tie(c,v,p,vv)=que.top();
            que.pop();
            if(dist[v][p][vv]<c)continue;
            for(auto &e:G[v]){
                if(e.to==p)continue;
                for(int dv=-1;dv<=1;dv++){
                    int nv=vv+dv;
                    if(nv<=0||nv>e.lim)continue;
                    double nc=c+1.0*e.dis/nv;
                    if(dist[e.to][v][nv]<nc+EPS)continue;
                    dist[e.to][v][nv]=nc;
                    que.push(make_tuple(nc,e.to,v,nv));
                }
            }
        }

        double ans=1001001001;
        for(int i=0;i<N;i++)chmin(ans,dist[T][i][1]);
        if(ans==1001001001)cout<<"unreachable"<<endl;
        else printf("%.20f\n",ans);
        }
    return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int q;
string x, y;
int n, m;
int dp[1001][1001];
int main()
{
	cin >> q;
	for(int i=0; i<q; i++)
	{
		for(int j=0; j<1001; j++)
		{
			for(int k=0; k<1001; k++)
			{
				dp[j][k]=0;
			}
		}
		cin >> x >> y;
		n=x.size();
		m=y.size();
		for(int j=1; j<=n; j++)
		{
			for(int k=1; k<=m; k++)
			{
				if(x[j-1]==y[k-1])
				{
					dp[j][k]=dp[j-1][k-1]+1;
				}
				else
				{
					dp[j][k]=max(dp[j-1][k], dp[j][k-1]);
				}
			}
		}
		cout << dp[n][m] << endl;
	}
	return 0;
}

Measured memory_bytes: 7116
N=int(input())
ame=list(map(str,input().split()))
species =0
if 'Y' in ame:
    species += 1
if 'P' in ame:
    species +=1
if 'W' in ame:
    species += 1
if 'G' in ame:
    species += 1
if species ==3:
    print ('Three')
else:
    print('Four')
                

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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const int N = (int) 1e6 + 5;
const int mod = (int) 1e9 + 7;

int n,a[N],l = 1,t,cnt;

int main () {
        cin >> n;

        for(int i = 1; i <= n; i ++)
                cin >> a[i];

        sort(a + 1,a + n + 1, greater<int> ());

        while(a[l] >= l)
                l ++;

        l --;

        for(int i = 1; i <= n; i ++)
                if(a[i] >= l)
                        cnt ++;

        if((a[l] - l) % 2 == 1 || (cnt - l) % 2 == 1)
                cout << "First" << endl;
        else
                cout << "Second" << endl;
        return 0;
}


Measured memory_bytes: 640
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

def solve():
    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def setInit(As):
        for iB, A in enumerate(As, 1):
            data[iB] = A
        for iB in range(1, numPow2):
            i = iB + (iB & -iB)
            data[iB] -= data[i]
    def addValue(iA, A):
        iB = iA + 1
        while iB > 0:
            data[iB] += A
            iB -= iB & -iB
    def getValue(iA):
        iB = iA + 1
        ans = 0
        while iB <= numPow2:
            ans += data[iB]
            iB += iB & -iB
        return ans


    N, D, A = map(int, input().split())
    XHs = [tuple(map(int, input().split())) for _ in range(N)]

    XHs.sort()
    Xs, Hs = [], []
    for X, H in XHs:
        Xs.append(X)
        Hs.append(H)

    data, numPow2 = makeBIT(N)
    setInit(Hs)

    ans = 0
    for i in range(N):
        rest = getValue(i)
        if rest <= 0: continue
        pos = Xs[i] + D
        iR = bisect_right(Xs, pos + D) - 1
        num = -(-rest // A)
        ans += num
        damage = num*A
        addValue(iR, -damage)

    print(ans)


solve()


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

int main(){
  int N,K; cin >>N >>K;
  int V[N];
  for(int i=0;i<N;i++){
    cin >>V[i];
  }

  int sum1=0, sum2, sum3, max=0;
  vector<int> minus1,minus2;
  for(int i=0;i<K && i<N;i++){
    sum1 += V[i];
    if(V[i]<0) minus1.push_back(V[i]);

    sum2 = sum1;
    minus2.clear();
    for(int j=0;j<minus1.size();j++){
      minus2.push_back(minus1[j]);
    }

    for(int j=0;j<K-i && j<N-i;j++){
      if(j>0){
        sum2 +=V[N-j];
        if(V[N-j]<0) minus2.push_back(V[N-j]);
      }
      sort(minus2.begin(), minus2.end());

      sum3 = sum2;
      for(int k=0;k<K-1-i-j && k<minus2.size(); k++){
        sum3 -= minus2[k];
      }
      if(sum3>max) max = sum3;
    }
  }

  cout << max << endl;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io;

fn main(){
    let mut t_cases = 1;
    for i in 0..t_cases{
        solve();
    }
}
fn solve(){
    let MOD = 10i32.pow(9)+7;
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap());
    let n = iter.next().unwrap();
    let k = iter.next().unwrap();
    // buf.clear();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect::<Vec<_>>();
    let mut dp = vec![0i32;k+1];
    dp[0] = 1;
    for item in a{
        let mut tdp = dp.clone();
        let mut s = dp[0];
        for i in 1..(k+1){
            s+=dp[i];
            if i > (item){
                s-=dp[i-item-1];
            }
            s = (s)%MOD;
            tdp[i] = (s+MOD)%MOD;
        }
        dp = tdp;
        // println!("{:?}",dp);
    }
    println!("{}",dp[k]);
    // println!("{}",(-6)%5);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

const int max_n = 1e3 + 5;

int sum[100005];


int main() {
	sum[0] = 0;
	FOR(i,1,1e5+1) {
		sum[i] = (i%10) + sum[i/10];
	}
	make(n);
	int best = 1e5;
	FOR(i,1,n) {
		best = min(best, sum[i] + sum[n-i]);
	}
	printf("%d\n", best);
}


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

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a


G = A[0]/2
for a in A[1:]:
    G *= (a/2)/gcd(G,a//2)
for a in A:
    if G % a == 0:
        print(0)
        exit()
print(int(M//G - M//G//2))

Measured memory_bytes: 20080
class UnionFind:
    """素集合を木構造として管理する"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """頂点xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
 
    def merge(self, x, y):
        """頂点xを含む集合と頂点y含む集合を結合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """頂点xと頂点yが同じ集合に属するかどうかを返す"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """頂点xを含む集合の要素数を返す"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を返す"""
        return self.cnt


import sys
input = sys.stdin.readline

    
n, m = list(map(int,input().split()))
info = [list(map(int, input().split())) for i in range(m)]

uf = UnionFind(n)
ans = [0] * (m + 1)
ans[-1] = n * (n - 1) // 2

for i in reversed(range(m)):
    x, y = info[i]
    x -= 1
    y -= 1
    if uf.is_same(x, y):
        ans[i] = ans[i + 1]
    else:
        ans[i] = ans[i + 1] - uf.get_size(x) * uf.get_size(y)
        uf.merge(x, y)

for res in ans[1:]:
    print(res)


Measured memory_bytes: 103440
#include <cstdio>

typedef long long i64;

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

	i64 mi = 1;
	i64 ma = n - d;

	i64 r = (ma - mi + 1) * 2;
	if(d == 0)
		r = n;

	double p = r / (double)(n * n) * (m - 1);

	printf("%.20lf\n", p);

	return 0;
}


Measured memory_bytes: 128
S=input()
ez=0
oz=0
eo=0
oo=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=="0":
      ez+=1
    else:
      eo+=1
  else:
    if S[i]=="0":
      oz+=1
    else:
      oo+=1
print(min(eo+oz,ez+oo))

Measured memory_bytes: 3188
#include <iostream>
#include <climits>

using namespace std;

int main() {
    int N;

    cin >> N;

    int W[N];
    int w, s2 = 0;
    for(int i = 0; i < N; i++) {
        cin >> w;
        W[i] = w;
        s2 += w;
    }

    int diff = INT_MAX, s1 = 0;
    for(int i = 0; i < N; i++) {
        s1 += W[i];
        s2 -= W[i];
        if(diff > abs(s1 - s2)) {
            diff = abs(s1 - s2);
        } else {
            break;
        }
    }
    
    cout << diff << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()


void solve(){
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n)cout<<s[i]<<t[i];
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

struct Card
{
	char mark;
	int number;
};

Card cards[52];

int compareCard(Card c1, Card c2)
{
	if (c1.mark == c2.mark)
	{
		if (c1.number == c2.number)
		{
			return 0;
		}
		else if (c1.number < c2.number)
		{
			return -1;
		}
		else
		{
			return 1;
		}
	}
	if (c1.mark == 'S')
	{
		return -1;
	}
	if (c1.mark == 'H')
	{
		if (c2.mark == 'S')
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}
	if (c1.mark == 'C')
	{
		if (c2.mark == 'S' || c2.mark == 'H')
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}
	if (c1.mark == 'D')
	{
		return 1;
	}
}

void swap(Card *array, int i, int j)
{
	Card temp;
	temp = array[i];
	array[i] = array[j];
	array[j] = temp;
}


void bubbleSort(Card *array, int len, int (*compareCard)(Card,Card))
{
	for (int i = 0; i < len - 1; i++)
	{
		for (int j = len - 1; j > 0; j--)
		{
			if (compareCard(array[j - 1], array[j]) > 0)
			{
				swap(array, j - 1, j);
			}
		}
	}
}


bool binarySearch(Card *array, int len, char mark, int number)
{
	int left = 0;
	int right = len - 1;
	Card target;
	target.mark = mark;
	target.number = number;
	while (left<=right)
	{
		int middle = (left + right) / 2;
		if (compareCard(target, array[middle]) == 0)
		{
			return true;
		}
		else if(compareCard(target, array[middle]) < 0)
		{
			right = middle - 1;
		}
		else
		{
			left = middle + 1;
		}
	}
	return false;
}

int main()
{
	int len;
	std::cin >> len;
	for (int i = 0; i < len; i++)
	{
		std::cin >> cards[i].mark >> cards[i].number;
	}

	bubbleSort(cards, len, compareCard);

	char marks[] = { 'S','H','C','D' };
	int marks_len = 4;

	for (int i = 0; i < marks_len; i++)
	{
		for (int j = 1; j <= 13; j++)
		{
			if (!binarySearch(cards, len, marks[i], j))
			{
				std::cout << marks[i] << " " << j;
				std::cout << std::endl;
			}
		}
	}


}


Measured memory_bytes: 3056
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int a = sc.nextInt();
	if(a<1200){
		System.out.println("ABC");
	}else{
	// 出力
	System.out.println("ARC");
	}
 }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];
typedef unsigned int Hash;
const Hash base = 10007ll;
Hash hsh[125252];
Hash bpow[125252];
typedef short Hash2;
const Hash2 base2 = 29;
const Hash2 mod2 = 251;
Hash2 hsh2[125252];
Hash2 bpow2[125252];
Hash2 mdmp[65536];

typedef pair<Hash,Hash2> yo;
struct yosh {
  size_t operator()(const yo &yey) const {
    hash<int> hasher;
    return hasher((int)yey.first)^hasher((int)yey.second);
  }
};

int calc(int x){
  unordered_set<yo,yosh> S;
  REP(i,n-x+1){
    // substr
    int l = i;
    int r = l+x;
    Hash h = hsh[r] - hsh[l]*bpow[x];
    Hash hh = mdmp[hsh2[r] - mdmp[hsh2[l]*bpow2[x]] + mod2];
    S.insert(yo(h,hh));
  }
  return S.size();
}

int main(){
  scanf("%s",s);
  n = strlen(s);
  REP(i,65536)mdmp[i] = i%mod2;
  // create hash
  REP(i,n)hsh[i+1] = hsh[i]*base + (Hash)s[i];
  bpow[0] = 1ll;
  REP(i,n)bpow[i+1] = bpow[i]*base;
  // create hash 2
  REP(i,n)hsh2[i+1] = mdmp[ mdmp[hsh2[i]*base2] + (Hash2)(s[i]-'a') ];
  bpow2[0] = 1;
  REP(i,n)bpow2[i+1] = mdmp[ bpow2[i]*base2 ];
  // go
  int low = 1, high = n;
  while(low+2<high){
    int ml = (low+high)/2;
    int mh = ml+1;
    if(calc(ml)<calc(mh)){
      low = ml;
    }else{
      high = mh;
    }
  }
  int ans = 0;
  FOR(i,low,high+1)CHMAX(ans,calc(i));
  printf("%d\n",ans);
  return 0;
}


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

int main() {
  int N = 13, M = 1e9 + 7;
  vector<int> DP(N);
  DP.at(0) = 1;
  char c;
  while (cin >> c) {
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
      if (c != '?') (V.at((i * 10 + c - '0') % 13) += DP.at(i)) %= M;
      else for (int j = 0; j < 10; j++) (V.at((i * 10 + j) % 13) += DP.at(i)) %= M;
    }
    DP = V;
  }

  cout << DP.at(5) << "\n";
}

Measured memory_bytes: 256
s = input()
nbit = len(s) - 1
ans = 0
for bit in range(1 << nbit):
    f = s[0]
    for i in range(nbit):
        if bit & (1 << i):
            f += "+"
        f += s[i+1]

    ans += sum(map(int, f.split("+")))

print(ans)


Measured memory_bytes: 41452
/* https://atcoder.jp/contests/abc125/tasks/abc125_d */

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

/* {{{ Variables */
int N;
vector<int> A;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  cin >> N;

  A = vector<int>(N);

  for (int& e: A)
    cin >> e;
  /* }}} */

  /* {{{ Output */
  int min_abs = 1e9;
  int min_arg = -1;
  int num_minus = 0;

  for (int i = 0; i < N; ++i) {
    int a = A.at(i);

    if (a < 0) {
      num_minus++;
    }

    if (abs(a) <= min_abs) {
      min_abs = abs(a);
      min_arg = i;
    }
  }

  long long sum = 0;

  for (int i = 0; i < N; ++i) {
    long long a = abs(A.at(i)*1ll);

    if (num_minus%2 == 1 && min_arg == i) {
      sum -= a;
    } else {
      sum += a;
    }
  }

  cout << sum << endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;cin>>n>>k;
    ll cnt = 0;
    map<int ,int> mp;
    for(int i=1; i<=n; ++i) {
        mp[i]=0;
    }
    rep(i,k) {
        int d;
        cin >> d;
        rep(i,d) {
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    for(auto x:mp) {
        if (x.second==0) {
            cnt++;
        }
    }
    ct (cnt);
}


Measured memory_bytes: 3668
def check(m, f, r)
  return '-1' =~ /^(#{m}|#{f})/ ? 'F' :
         m + f >= 80 ? 'A' :
         m + f >= 65 ? 'B' :
         m + f >= 50 || m + f >= 30 && r >= 50 ? 'C' :
         m + f >= 30 ? 'D' : 'F'
end

while (n = gets.split(' ').map(&:to_i)) != [-1, -1, -1]
  m, f, r = n
  puts check(m, f, r)
end

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

int main()
{
  int a, b,c,d;
  cin >> a >> b >> c >> d;
  if((a + b) > (c + d)) cout << "Left" <<endl;
  else if((a + b) == (c + d))cout << "Balanced" <<endl;
  else if((a + b) < (c + d))cout << "Right" <<endl;
  return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

if L >= 0:
    print(((L + 1) + (L + N - 1)) * (N - 1) // 2)
else:
    if N + L > 0:
        print((L + (L + N - 1)) * N // 2)
    else:
        print((L + (L + N - 2)) * (N - 1) // 2)


Measured memory_bytes: 2940
S = list(input())
cum_s = []
count_b, count_w = 0, 0
for s in S:
  if s == 'B':
    count_b += 1
    if count_w > 0:
      cum_s.append(count_w)
      count_w = 0
  else:
    count_w += 1
    if count_b > 0:
      cum_s.append(count_b)
      count_b = 0
cum_s.append(max(count_b, count_w))
print(len(cum_s)-1)

Measured memory_bytes: 4648
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

struct UnionFind { // {{{
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return -u[root(x)]; }
    int  root(int x)        { return (u[x] < 0)? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
}; // }}}

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

    var(int, N, M);
    vector<vector<int>> ks(M);

    rep(i, 0, N) {
        var(int, K);
        rep(k, 0, K) {
            var(int, x);
            --x;
            ks[x].push_back(i);
        }
    }

    UnionFind uf(N);
    rep(i, 0, M) {
        rep(k, 1, ks[i].size()) {
            uf.unite(ks[i][k], ks[i][k-1]);
        }
    }

    dump(uf.size(0));
    if (uf.size(0) == N) {
        print("YES");
    } else {
        print("NO");
    }

    return 0;
}


Measured memory_bytes: 4608
from math import gcd
def main():
  K = int(input())
  ans = 0
  
  for i in range(1, K + 1):
    for j in range(1, K + 1):
      for k in range(1, K + 1):
        ans += gcd(i, gcd(j, k))
        
  print(ans)

if __name__ == '__main__':
  main()

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

using namespace std;

struct Shop {
	char name;
	int sell[2];
	int total;
};

bool compare(Shop i, Shop j) {
	return (i.total < j.total);
}

int main() {
	
	Shop shop[5];
	bool test = false;

	while (true) {

		shop[0].name = 'A';
		for (int i = 0; i < 5; i++) {
			cin >> shop[i].sell[0] >> shop[i].sell[1];
			if (shop[0].sell[0] == 0 && shop[0].sell[1] == 0 && i == 0) {
				test = true;
				break;
			}
			shop[i].total = shop[i].sell[0] + shop[i].sell[1];
			shop[i].name = 'A' + i;

		}
		if (test)
			break;
		sort(shop, shop + 5, compare);
		cout << shop[4].name << " " << shop[4].total << "\n";

	}
	
	return 0;

}







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

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

using namespace std;

ll MOD = 1000000007LL;

ll dp[2005][2005] = {};
ll sum[2005][2005] = {};

int main()
{
  int n, m;
  cin >> n >> m;
  int s[2000], t[2000];
  REP(i, n)
  {
    dp[i][0] = 0LL;
    cin >> s[i];
  }
  dp[n][0] = 0LL;

  REP(i, m)
  {
    dp[0][i] = 0LL;
    cin >> t[i];
  }
  dp[0][m] = 0LL;

  REP(i, n + 1)
  {
    sum[i][0] = 0LL;
  }

  REP(i, m + 1)
  {
    sum[0][i] = 0LL;
  }

  FOR(i, 1, n + 1)
  {
    FOR(j, 1, m + 1)
    {
      if (s[i - 1] != t[j - 1])
      {
        dp[i][j] = 0;
      }
      else
      {
        dp[i][j] = sum[i - 1][j - 1] + 1 % MOD;
      }
      sum[i][j] = (((sum[i - 1][j] + sum[i][j - 1]) % MOD - sum[i - 1][j - 1] + MOD) % MOD + dp[i][j]) % MOD;
    }
  }

  cout << (sum[n][m] + 1) % MOD << endl;
}


Measured memory_bytes: 62976
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
}

int main(){
    int n, m;
    cin >> n >> m;
    char a[n][n];    
    char b[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }    
    for(int i = 0; i < m; i++){
        for(int j = 0; j < m; j++){
            cin >> b[i][j];
        }
    }
    bool ans = false;
    for(int i = 0; i <= n - m; i++){
        for(int j = 0; j <= n - m; j++){
            bool res = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    res &= (b[k][l] == a[i+k][j+l]);
                    if(!res){
                        break;
                    }
                }
            }
            if(res){
                ans = true;
                break;
            }
        }
        if(ans){
            break;
        }
    }
    print_ans(ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iK = int.Parse(sS[1]);
            List<ClsJan> lstJan = new List<ClsJan>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            lstJan.Add(new ClsJan() { cJ = 'r', cA = 's', iG = int.Parse(sS[0]) });
            lstJan.Add(new ClsJan() { cJ = 's', cA = 'p', iG = int.Parse(sS[1]) });
            lstJan.Add(new ClsJan() { cJ = 'p', cA = 'r', iG = int.Parse(sS[2]) });
            string sT = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstJan.Sort(delegate (ClsJan mca1, ClsJan mca2) { return (int)(mca2.iG - mca1.iG); });     // 点の降順
            int iOut = 0;
            List<char> lstMyj = new List<char>();
            for (int i = 0; i < sT.Length; i++) { lstMyj.Add(' '); }
            for (int j = 0; j < lstJan.Count; j++)
            {
                for (int i = 0; i < sT.Length; i++)
                {
                    if (sT[i] == lstJan[j].cA)
                    {
                        if (i - iK >= 0)
                        {
                            if (lstMyj[i - iK] != lstJan[j].cJ) { lstMyj[i] = lstJan[j].cJ; iOut += lstJan[j].iG; }
                            else { lstMyj[i] = ' '; }
                        }
                        else { lstMyj[i] = lstJan[j].cJ; iOut += lstJan[j].iG; }
                    }
                }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

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

        // 結果情報
        private class ClsJan
        {
            public char cJ { get; set; } = ' ';     // 自分文字
            public char cA { get; set; } = ' ';     // 相手文字
            public int  iG { get; set; } = 0;       // 点
        }

}


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

int main(void)
{
    //string a,b;
    int a,b,c,d;
    //char a,b='.';
    //int i=1;
    cin>>a>>b>>c;
    if(a*b>=c) cout<<c;
    else cout<<a*b;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int x,y,r;
	int W,H;
	
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	
	if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
//#define ll long long
#define ll int

using namespace std;


//操作:任意のカードを3枚抜き出し、最大と最小を取り除く
//残ったカードが互いに異なるようにするには、最小で何回操作を行えばよいか
int main(){
    int N;
    cin >> N;
    int cnt = 0;
    vector <int> a(100001,0);
    for(int i = 0; i < N; ++i)
    {
        int tmp;
        cin >> tmp;
        --tmp;
        if(a[tmp] > 0)++cnt;
        ++a[tmp];
    }
    if(cnt % 2 == 1)++cnt;

    int res = N - cnt;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640