akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

ll ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for(int i = 1; i < n; i++) {
    ans += (n-1)/i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;
typedef long long ll;

template <class T = ll>
T input(){T x;cin >> x;return x;}

template <class T>
void output(T x){cout << x << endl;}

//#define int long log

#define debug(x) cerr << #x<< ": " << x<< '\n';

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  int N = input();
  int A = input();
  int B = input();
  output(min(A*N,B));

  return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

struct edge {
  ll to, cap, rev;
};

vector<vector<edge>> to;
vector<bool> used;
void addE(ll u, ll v, ll w) {
  to[u].push_back({v, w, (ll)to[v].size()});
  to[v].push_back({u, 0, (ll)to[u].size() - 1});
}

ll dfs(ll u, ll t, ll f) {
  assert(f > 0);
  if (u == t) return f;
  used[u] = true;
  for (edge& e : to[u]) {
    if (used[e.to] || e.cap <= 0) continue;
    ll d = dfs(e.to, t, min(f, e.cap));
    if (d == 0) continue;
    e.cap -= d;
    to[e.to][e.rev].cap += d;
    return d;
  }
  return 0;
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n), bs(n), cs(n), ds(n);
  rep(i, n) cin >> as[i] >> bs[i];
  rep(i, n) cin >> cs[i] >> ds[i];

  to.resize(2 * n + 2);
  rep(i, n) rep(j, n) {
    bool ok = as[i] < cs[j] && bs[i] < ds[j];
    if (ok) {
      addE(i, n + j, 1);
    }
  }
  rep(i, n) addE(2 * n, i, 1);
  rep(j, n) addE(n + j, 2 * n + 1, 1);

  ll ans = 0;
  while (true) {
    used.assign(2*n + 2, false);
    ll add = dfs(2*n, 2*n+1, INF);
    if (add == 0) {
      cout << ans << endl;
      return 0;
    } else
      ans += add;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const int mod = 1000000007;
const int inf = (1<<30);
const ll infll = (1ll<<60);
using namespace std;

int sz;
ll st[500000];

void init( int n ){
	sz = 1;
	while( sz < n ) sz = 2*sz;
}

void update( int k, ll a ){
	k += sz-1; st[k] = a;
	while( k ){
		k = (k-1)/2;
		st[k] = max( st[2*k+1], st[2*k+2] );
	}
}

ll query( int a, int b, int k = 0, int l = 0, int r = sz ){
	if( b <= l || r <= a ){
		return 0;
	} else if( a <= l && r <= b) {
		return st[k];
	} else {
		return max(
			query( a, b, 2*k+1, l, (l+r)/2 ),
			query( a, b, 2*k+2, (l+r)/2, r )
		);
	}
}

int main(){
	int n; cin >> n;
	vector<int> h(n);
	vector<ll> a(n);
	for( auto &k : h ) cin >> k;
	for( auto &k : a ) cin >> k;
	init(n+1);
	for( int i = 0; i < n; ++i ){
		update( h[i], query(0, h[i])+a[i] );
	}
	cout << query(0, n+1) << endl;
}

Measured memory_bytes: 5760
#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() {

    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        rep(i, n) cin >> a[i];

        sort(a.begin(), a.end());
        ll ans = 1e8;
        for (int i=0; i<n-1; ++i) {
            ans = min(ans, (ll)abs(a[i] - a[i+1]));
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3144
import math
a,b,h,m = map(int,input().split())

hr = h*30+m/2
mr = m*6
r = abs(hr-mr)
r = min(r, 360-r)

ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(r))

print(math.sqrt(ans))

Measured memory_bytes: 9448
#include<iostream>
using namespace std;
int main(){
	int H,W;
	int i,j;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i%2==0&&j%2==0||i%2==1&&j%2==1)cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int X[3];

int main() {
  for (int i = 0; i < 3; ++i) {
    cin >> X[i];
  }
  sort(X, X + 3);
  int ba = X[1] - X[0];
  int ca = X[2] - X[0];
  int cb = X[2] - X[1];
  if (cb % 2 == 0 && ca % 2 == 0) {
    printf("%d\n", (ca + cb) / 2);
  } else if (ba % 2 == 0) {
    printf("%d\n", 1 + (ca - 1 + cb - 1) / 2);
  } else {
    printf("%d\n", (cb + ca + 1) / 2 + 1);
  }
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{
    string s;
    cin >> s;
    
    int t = int(s.length());

    
    ve<ve<ll>> dp(t+1,ve<ll>(4,0));
    
    for (int i = t; i >= 0; i--) {
        for (int j = 3; j >= 0; j--) {
            if(i == t){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3:1);
                if(j < 3 && (s[i]=='?'||s[i]=="ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= mod;
            }
            
        }
    }
    out(dp[0][0]);

    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int A,B;
  int max;
  cin >> A >> B ;
  
  max = A+B;
  if(max < A-B){
  	max = A-B;
  }
  if(max < A*B){
  	max = A*B;
  }

  cout << max << endl;

  
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

class UnionFind:
    def __init__(self,N): # 頂点数 N
        self.table = [i for i in range(N)]    #木の親 table[x] == x なら根
        self.rank  = [1 for i in range(N)]    #木の長さ
        self.size  = [1 for i in range(N)]    #集合のサイズ

    def Find(self,x):    #xの根を返す
        if self.table[x] == x:
            return x
        else:
            self.table[x] = self.Find(self.table[x])    #親の更新(根を直接親にして参照距離を短く)
            self.size[x] = self.size[self.table[x]]
            return self.table[x]

    def Unite(self,x,y):    #xとyを繋げる
        x,y = self.Find(x), self.Find(y)
        sx,sy = self.Size(x), self.Size(y)
        if x == y: return
        if self.rank[x] > self.rank[y]:
            self.table[y] = x
            self.size[x] = sx + sy
        else:
            self.table[x] = y
            self.size[y] = sx + sy
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def Check(self,x,y):
        return self.Find(x) == self.Find(y)

    def Size(self,x):
        return self.size[self.Find(x)]



N = int(input())
UF = UnionFind(10**5+1)

xys = [inpl() for _ in range(N)]
xys.sort()
tatedict = defaultdict(list)
xx = set()
for x,y in xys:
    tatedict[x].append(y)
    xx.add(x)

for x in xx:
    s = tatedict[x][0]
    for t in tatedict[x]:
        if not UF.Check(s,t):
            UF.Unite(s,t)

ans = 0
for x in xx:
    s = tatedict[x][0]
    ans += UF.Size(s) - len(tatedict[x])

print(ans)


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

int main () {
  int n, k;
  cin >> n >> k;
  
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p.at(i);
  
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < k; i++) sum += p.at(i);
  
  cout << sum << endl;
}

Measured memory_bytes: 3164
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=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;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    map<string, int> mp;
    int n;
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        mp[s]--;
    }

    int ma = 0;
    for (auto p : mp){
        ma = max(ma, p.second);
    }
    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int h, w;
int dx[9] = {-1,-1,-1,0,0,0,1,1,1}, dy[9] = {-1,0,1,-1,0,1,-1,0,1};

bool isin(int i, int j){
    return i >= 1 && j >= 1 && i < h-1 && j < w-1;
}

int main() {
    int n;
    cin >> h >> w >> n;
    VI a(n), b(n);
    REP(i,n) scanf("%d %d", &a[i], &b[i]);
    map<P,int> M;
    REP(i,n){
        REP(k,9){
            int ii = a[i]-1+dx[k], jj = b[i]-1+dy[k];
            if (isin(ii,jj)) M[make_pair(ii, jj)]++;
        }
    }

    ll ans[10] = {};
    ans[0] = (ll)(h-2)*(w-2) - M.size();
    for (map<P,int>::iterator itr = M.begin(); itr != M.end(); ++itr){
        ans[itr->second]++;
    }

    REP(i,10) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 57216
#include <stdio.h>
#include <iostream>
// #include <math.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(b-a == c-b) print("YES");
  else print("NO");
}



Measured memory_bytes: 256
x = [0, 0, 0, 0]
for n in 0..2
  a, b = gets.chomp.split.map(&:to_i)
  x[a - 1] = x[a - 1] + 1
  x[b - 1] = x[b - 1] + 1
end
if x.max > 2 or x.min < 1
  puts "NO"
  exit
else
  puts "YES"
end


Measured memory_bytes: 1788
package main
import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  var min, max int
  min = 1000000000
  for i := 0; i < n; i++ {
    var a int
    fmt.Scan(&a)
    if max < a {
      max = a
    }
    if min > a {
      min = a
    }
  }
  fmt.Println(max - min)
}



Measured memory_bytes: 512
import java.io.*
import java.util.*

const val YES = "Yes"
const val NO = "No"
fun solve(a: String, b: String){
    if(isSquare((a+b).toLong())) println(YES)
    else println(NO)
    return
}

fun isSquare(num: Long): Boolean {
    val sqrt = Math.sqrt(num.toDouble()).toLong()
    return sqrt * sqrt == num || (sqrt + 1L) * (sqrt + 1L) == num
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    solve(a, b)
}



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

int main(){
   int N, M;
   std::cin >> N >> M;
   std::vector<bool> q(N,false);
   std::vector<int> r(N,0);
   int p;
   std::string S;
   for(int i=0; i<M; ++i){
      std::cin >> p >> S;
      --p;
      if(S=="AC") q[p] = true;
      else if(q[p]==false) ++r[p];
   }
   int penalty = 0;
   for(int i=0; i<N; ++i){
      if(q[i]) penalty += r[i];
   }
   std::cout << std::count(q.begin(), q.end(), true) << ' ' << penalty << std::endl;
   return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            Console.WriteLine(Ans(s) ? "Bad":"Good");

        }

        private static bool Ans(string a)
        {
            bool flag = false;

            for (int i = 0; i < 3; i++)
            {
                if (a[i] == a[i+1])
                {
                    flag = true;
                }
                
            }

            return flag;

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>weights,values;
    weights.pb(-1);
    values.pb(-1);
    ll total = 0;
    for(ll i = 0; i < n; i++)
    {
        ll a,b;
        cin>>a>>b;
        weights.pb(a);
        values.pb(b);
        total += b;
    }
    ll ans = 0;
    vector<vector<ll> >dp(n+1,vector<ll>(total+1));
    for(ll i = 0; i <= total; i++)
        dp[0][i] = INT_MAX;
    dp[0][0] = 0;
    for(ll i = 1; i<= n; i++)
    {
        for(ll j = 1; j <= total; j++)
        {
            if(j >= values[i])
            {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-values[i]]+weights[i]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            if(dp[i][j] <= w)
                ans = max(ans,j);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 83132
n, l = gets.split.map &:to_i

if l >= 0 then
	puts (2 + n) * (n - 1) / 2 + l * (n - 1) - (n - 1)
elsif l <= -n then
	puts n * (n - 1) / 2 + l * (n - 1) - (n - 1)
else
	puts n * (n + 1) / 2 + l * n - n
end


Measured memory_bytes: 1788
while gets
  v, d = $_.split.map(&:to_i)
  arr = Array.new
  pre = cur = 1
  v.times do
    arr << (fwd = (pre + cur) % 1001)
    pre = cur
    cur = fwd
  end
  p arr.sort!.zip(arr[1,v])[0,v-1].count{|a| a[1] - a[0] >= d} + 1
end

Measured memory_bytes: 8868
import java.util.Scanner;
public class Main {

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

		String s=sc.next();		//
		
		if(s.equals("AAA")||s.equals("BBB")) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
		sc.close();
	}
}

Measured memory_bytes: 21844
import sys
S = input()
length = 4

for i in range(1 << (length - 1)):
    s = S[0]
    for j in range(length - 1):
        if i & (1 << j):
            s += "+"
        else:
            s += "-"
        s += S[j + 1]
    if eval(s) == 7:
        print(s + "=7")
        sys.exit(0)
        

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

int main() {
  int64_t a, b;
  cin >> a >> b;
  
  //2019=3*673 672*671/2=225456
  if(a%673==0 || a%673+b-a>=673) {
    if(b-a>=2) cout << 0 << endl;
    else cout << a*b%2019 << endl;
  }
  else {
    int64_t ans = 2020;
    for(int64_t i=a; i<=b-1; i++) {
      for(int64_t j=i+1; j<=b; j++) {
        ans = min(ans, i*j%2019);
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if ((a < b) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2592
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val YES = "Yes"
const val NO = "No"
fun solve(N: Int, S: String){
    if(N % 2 != 0){
        println(NO)
    }else if (S.slice(0 until N / 2) == S.slice(N/2 until N)) println(YES)
    else println(NO)
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val S = sc.next()
    solve(N, S)
}



Measured memory_bytes: 31620
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()

{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    set<int> S;
    rep(i, N)
    {
        cin >> A[i];
        S.insert(A[i]);
    }
    vector<int> count(S.size());
    rep(i, S.size())
    {
        count[i] = 1;
    }
    sort(A.begin(), A.end());
    int i = 0, j = 1, k = 0;
    while (j < N)
    {
        if (A[i] == A[j])
        {
            count[k]++;
        }
        else
        {
            k++;
            i = j;
        }
        j++;
    }
    sort(count.begin(), count.end());
    int n;
    n = S.size() - K;
    int sum = 0;
    if (n > 0)
    {
        rep(i, n)
        {
            sum += count[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	vector<vi> e(6);
	e[0].pb(1); e[0].pb(2);
	e[1].pb(-1); e[1].pb(3);
	e[2].pb(1); e[2].pb(-1);
	e[3].pb(4); e[3].pb(5);
	e[4].pb(5); e[4].pb(2);
	e[5].pb(2); e[5].pb(1);
	
	string s;
	while(cin >> s, s != "#"){
		int c = 0;
		for(char k : s){
			c = e[c][k - '0'];
			if(c < 0) break;
		}
		cout << (c == 5 ? "Yes" : "No") << endl;
	}
	return 0;
}


Measured memory_bytes: 3188
import sys

sys.setrecursionlimit(10000) # 再帰深度を変更しておく

l1 = sys.stdin.readline().strip().split()
l2 = sys.stdin.readline().strip().split()
l1 = [int(x.strip()) for x in l1]
N = l1[0]
M = l1[1]


A = [int(x.strip()) % M for x in l2] # N
l2 = []



# 解法1: n^2分→10^10でアウト
# 解法2:左から、和のmod Mをつくる（つくらなくてもいいかも）→その値が1どうし、2どうし、3どうし……をペアにする。それぞれの「＠どうし」組について、その組の要素の数C2が、できるやつの個数である。その輪を求める。

B = {0:1}

S = 0
for i in range (0, N):
	S = (S+A[i]) % M
	if S in B:
		value = B.pop(S)
		B[S] = value + 1
	else:
		B[S] = 1

# print(B)

res = 0
for key in B: #高々数はN
	value = B[key]
	res += int((value) * (value -1) /2)

print(res)

Measured memory_bytes: 62576
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    static long form_pair_with(int man, int mask, int n, long dp[][], int arr[][]){

        if(mask == (1 << n) - 1)
            return 1l;

        if(man == n)
            return mask == (1 << n) - 1 ? 1l : 0l;

        if(dp[man][mask] != -1){
            return dp[man][mask];
        }

        long res = 0l; // don't form a pair with this 'man'
        int tmp = mask;

        for(int woman = 0; woman < n; woman++){
            if((tmp & 1) == 0 && arr[man][woman] == 1){
                res += form_pair_with(man + 1, mask | (1 << woman), n, dp, arr);
                res %= mod;
            }

            tmp = (tmp >> 1);
        }

        return dp[man][mask] = res;
    }

    public static void process(int test_number)throws IOException
    {
        int n = ni(), arr[][] = new int[n][n];
        dp = new long[n][(1 << n) - 1]; // states(ith man, mask of woman where 
                                        // ith bit = 1 means ith woman has already formed a pair with a man);

        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                arr[i - 1][j - 1] = ni();

        for(long row[] : dp) Arrays.fill(row, -1l);

        pn(form_pair_with(0, 0, n, dp, arr));
    }
     
    static long dp[][];
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        process(1);
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0; i<h; ++i) cin >> s[i];

  //const int x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  //const int y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int x[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  int y[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  for(int i=0; i<h; ++i) {
    for(int j=0; j<w; ++j) {
      if(s[i][j] == '#') continue;
      int count = 0;
      for(int k=0; k<8; ++k) {
        int ni = i + y[k];
        int nj = j + x[k];
        if(ni < 0 || ni >= h) continue;
        if(nj < 0 || nj >= w) continue;
        if(s[ni][nj] == '#') count++;
      }
      s[i][j] = char(count + '0');
    }
  }
  for(int i=0; i<h; ++i) cout << s[i] << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3612
N = int(input())
a = list(map(int, input().split()))

ans = 0
i = 0
while i < N:
    j = i + 1
    while j < N:
        if a[j] != a[i]:
            break
        j += 1
    ans += (j - i) // 2
    i = j
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
	ll N,sum=0,ans1,ans2;
	cin>>N;
	vector<ll> A(N);
	for(int i=0;i<N;i++) cin>>A[i];
	sort(A.begin(),A.end());
	cout<<A[N-1]<<" ";
	auto ite=lower_bound(A.begin(),A.end(),A[N-1]/2);
	if(*ite==A[N-1]) cout<<*(ite-1);
	else if(*ite==A[0]) cout<<*ite;
	else{
		if(abs(A[N-1]/2 - *ite) > abs(A[N-1]/2 - *(ite-1))){
			cout<<*(ite-1);
		}else{
			cout<<*ite;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
struct Array
{
	long long num;
	long long count;
};
bool com(struct Array p,struct Array q)
{
	return p.num<q.num;
}
int main()
{
	long long n,k;
	cin>>n>>k;
	struct Array a[100001];	
	for(int i=0;i<n;i++)
	{
		cin>>a[i].num>>a[i].count;
	}
	sort(a,a+n,com);
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i].count;
		if(sum>=k)
		{
			cout<<a[i].num<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(3);
    rep(i, 3) cin >> A[i];
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    ll ans = inf;
    rep(i, 1 << (N * 2)) {
        ll tmp = 0;
        vector<int> P(4);
        rep(j, N) {
            if(P[(i >> (j * 2)) & 3] > 0 && ((i >> (j * 2)) & 3) < 3) tmp += 10;
            P[(i >> (j * 2)) & 3] += L[j];
        }
//        voutput(P);
        bool ok = true;
        rep(j, 3) {
            if(P[j] == 0) {
                ok = false;
                break;
            }
            tmp += abs(A[j] - P[j]);
        }
        if(!ok) continue;
        ans = min(ans, tmp);
    }
    output(ans);
    
    return 0;
}


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

int main(){
    string H;
    cin >> H;

    int ans1 = 0;
    int ans2 = 0;
    int ans = 0;
    for(int i = 0; i < H.size(); i++){
        if(i%2 == 1){
            if(H[i] != '1'){
                ans1++;
            }
            if(H[i] != '0'){
                ans2++;
            }
        }else{
            if(H[i] != '0'){
                ans1++;
            }
            if(H[i] != '1'){
                ans2++;
            }
        }
    }
    
    ans = min(ans1, ans2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	for (int i = 0; 4 * i <= n; i++) {
		for (int j = 0; 4 * i + 7 * j <= n; j++) {
			if (4 * i + 7 * j == n) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Vector;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int q = Integer.parseInt(tmpArray[1]);

		@SuppressWarnings("unchecked")
		Vector<Integer>[] vecArray = new Vector[n];
		for(int i = 0; i < n; i++){
			vecArray[i] = new Vector<Integer>();
		}

		for(int i = 0; i < q; i++){
			tmpArray = br.readLine().split(" ");

			//pushBack
			if(tmpArray[0].equals("0")){
				int t = Integer.parseInt(tmpArray[1]);
				int x = Integer.parseInt(tmpArray[2]);

				vecArray[t].add(x);
//				printVec(vecArray[t]);
			}
			//dump
			else if(tmpArray[0].equals("1")){
				int t = Integer.parseInt(tmpArray[1]);

				printVec(vecArray[t]);
			}
			//clear
			else {
				int t = Integer.parseInt(tmpArray[1]);

				vecArray[t] = new Vector<Integer>();
				
//				System.out.println("removed : "+t);
			}
		}

	}
	
	static void printVec(Vector vec){
		Iterator it = vec.iterator();

		StringBuffer sb = new StringBuffer();
		while(it.hasNext()){
			sb.append(it.next());

			if(it.hasNext()){
				sb.append(" ");
			}
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 114884
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main() {
    for(int i=1; ; i++) {
        int W = readln.chomp.to!int;
        if (W==0) break;
        writeln("Case "~i.to!string~":");

        int[] dp = new int[W+1];
        int N = readln.chomp.to!int;
        N.iota.map!(_=>readln.chomp.split(",").to!(int[])).each!((a) {
            int v = a[0];
            int w = a[1];
            foreach_reverse(j; w..W+1) {
                if (j==w || dp[j-w]>0) dp[j] = max(dp[j], dp[j-w]+v);
            }
        });
        int m = dp.reduce!max;
        m.writeln;
        dp.countUntil(m).writeln;
    }
}

Measured memory_bytes: 2624
import sys
fin = sys.stdin.readline

N, x = [int(elem) for elem in fin().split()]
a_list = [int(elem) for elem in fin().split()]

a_list.sort()
rest_money = x
num_happy_kids = 0
for a in a_list:
    if rest_money >= a:
        rest_money -= a
        num_happy_kids += 1
    else:
        break
else:
    if rest_money > 0:
        num_happy_kids -= 1
print(num_happy_kids)


Measured memory_bytes: 3064
#include<iostream>
#include<ios>
#include<algorithm>
#include<cmath>
using namespace std;
double w,r[12];
double dp[1<<12][12];
main()
{
	while(~scanf("%lf ",&w))
	{
		int n=0;char c;
		while(scanf("%lf%c",r+n++,&c),c==' ');
		for(int i=0;i<n;i++)for(int j=0;j<1<<n;j++)dp[j][i]=w+1;
		for(int i=0;i<n;i++)dp[1<<i][i]=r[i];
		for(int i=1;i<1<<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(!(i&1<<j))continue;
				for(int k=0;k<n;k++)
				{
					if(i&1<<k)continue;
					double dis=2*sqrt(r[j]*r[k]);
					dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+dis);
				}
			}
		}
		double ans=w+1;
		for(int i=0;i<n;i++)ans=min(ans,dp[(1<<n)-1][i]+r[i]);
		puts(ans>w?"NA":"OK");
	}
}



Measured memory_bytes: 3408
k = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[k-1])

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

#define sf scanf
#define pf printf
#define endl "\n"
#define off ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr freopen("in.txt", "r", stdin)
#define fw freopen("out.txt", "w", stdout)
#define pb push_back
#define eb emplace_back
#define PII pair<int, int>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define pass printf("Passed Here\n")

typedef long long ll;
typedef unsigned int ui;
int mod = 1000000007;

int main()
{
    int n,m;
    cin>>n>>m;
    ll ara[n+2][4];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++)
            cin>>ara[i][j];
    }
    ll sum = 0, ans = 0; 
    for(int i = 0; i < 8; i++) {
        vector<ll>v;
        ll s = 0;
        for(int k = 0; k < n; k++) {
            for(int j = 0; j < 3; j++) {
                if(i&(1<<j)) s += ara[k][j];
                else s+= -ara[k][j];
            }
            v.pb(s);
            s = 0;
        }
        sort(v.begin(), v.end()); reverse(v.begin(), v.end());
        sum = 0;
        for(int x = 0; x < m; x++) sum += v[x];
        ans = max(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

int N;
unordered_set<int> visited;
map<int, vector<int>> edges;
map<int, vector<int>> subtree_sizes;

ll mod_exp(ll x, ll exp) {
    ll ans = 1;
    ll base = x % MOD;
    while (exp > 0) {
        if (exp % 2 == 1) {
            ans = (ans * base) % MOD;
        }
        base = (base * base) % MOD;
        exp /= 2;
    }
    return ans;
}

ll mod_inv_prime(ll x) {
    return mod_exp(x, MOD-2);
}

int dfs(int v) {
    // cout << v << endl;
    visited.insert(v);
    int total_size = 0;
    for (int ne : edges[v]) {
        // cout << "attempt visit " << ne << endl;
        if (!visited.count(ne)) { 
            int subtree_size = dfs(ne) + 1;
            // cout << "subtree size " << subtree_size << endl;
            if (subtree_size > 0) {
                subtree_sizes[v].push_back(subtree_size);
            }
            total_size += subtree_size;
        }
    }
    if (N - 1 - total_size > 0) {
        subtree_sizes[v].push_back(N-1-total_size);
    }
    return total_size;
}

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

    dfs(0);

    ll ev = 0;
    ll two_inv = mod_inv_prime(2);
    vector<ll> two_inv_pow = {1};
    ll curr = 1;
    for (int i = 0; i < N; i++) {
        curr = (curr * two_inv) % MOD;
        two_inv_pow.push_back(curr);
    }

    for (int i = 0; i < N; i++) {
        if (subtree_sizes[i].size() < 2) continue;
        ll p_all_white = 1;
        for (int subtree_size : subtree_sizes[i]) {
            p_all_white = (p_all_white * two_inv_pow[subtree_size]) % MOD;
        }
        ll p_one_black = 0;
        for (int subtree_size : subtree_sizes[i]) {
            ll p_t_white = two_inv_pow[subtree_size];
            ll p_t_black = (1 - p_t_white + MOD) % MOD;
            ll prob = (p_all_white * ((p_t_black * mod_inv_prime(p_t_white)) % MOD)) % MOD;
            p_one_black = (p_one_black + prob) % MOD;
        }
        ll cond_prob = (1 - ((p_all_white + p_one_black) % MOD) + MOD) % MOD;
        ll total_prob = (two_inv * cond_prob) % MOD;
        ev = (ev + total_prob) % MOD;
    }

    cout << ev << endl;

}


Measured memory_bytes: 68680
/********************************************
 *Author*        :Kwansy
 *Created Time*  : 2018年12月22日 星期六 21时05分18秒
 * Ended  Time*  : 2018年12月22日 星期六 21时07分36秒
*********************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main()
{
    LL N,A;
    cin >> N;
    bool win = false;
    while (N--)
    {
        cin >> A;
        if (A % 2 != 0) { win = true; break;}
    }
    if (win) cout << "first";
    else cout << "second";
    return 0;
}


Measured memory_bytes: 256
import sys


def main():
    n = int(input())
    s = set()

    p = input()
    s.add(p)

    for i in range(n - 1):
        w = input()

        if w in s or w[0] != p[-1]:
            print('No')
            return
        
        p = w
        s.add(w)
    
    print('Yes')
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define ceil(a, b) a / b + !!(a % b)
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

using P = complex<double>;
struct S { P p1, p2; };
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
const double eps = 1e-8;

double norm(P a) { return real(a) * real(a) + imag(a) * imag(a); }
double abs(P a) { return sqrt(norm(a)); }

P projection(P p, P p1, P p2) {
    double t = dot(p - p1, p2 - p1) / abs(p2 - p1);
    return p1 + t / abs(p2 - p1) * (p2 - p1);
}
int main() {
    double x, y, r;
    cin >> x >> y >> r;
    P p = P(x, y);
    
    int query;
    cin >> query;
    
    while (query--) {
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        P p1 = P(x1, y1), p2 = P(x2, y2);
        
        double d = abs(cross(p - p2, p1 - p2)) / abs(p1 - p2);
        
        double sca = sqrt(r * r - d * d);
        
        P r = projection(p, p1, p2);
        
        P p3 = r + sca * (p2 - p1) / abs(p2 - p1);
        P p4 = r - sca * (p2 - p1) / abs(p2 - p1);
        if (real(p3) > real(p4)) swap(p3, p4);
        // cout << real(p3) << " " << imag(p3) << " " << real(p4) << " " << imag(p4) << endl;
        if (real(p3) >= real(p4) && imag(p3) > imag(p4)) swap(p3, p4);
        
        cout << fixed << setprecision(10);
        cout << real(p3) << " " << imag(p3) << " " << real(p4) << " " << imag(p4) << endl;
    }
}



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

int main(){
    // input
    int N, M; cin >> N >> M;
    vector<vector<int>> S(M);
    vector<int> P(M);
    for (int m=0; m<M; m++){
        int K; cin >> K;
        for (int k=0; k<K; k++){
            int s; cin >>s;
            S[m].push_back(s);
        }
    }
    for ( int m=0; m<M; m++) cin >> P[m];

    // bit全探索
    int ans = 0;
    for (int ptn=0; ptn<(1<<N); ptn++){
        for(int m=0; m<M; m++){
            int cnt = 0;
            for(int k=0; k<S[m].size(); k++){
                if( (ptn>>(S[m][k]-1))&1 ) cnt++; // S[m][k]-1 桁目にフラグ存在すればcnt++
            }

            if( P[m] != (cnt%2) ) break;
            if( m == M-1 ) ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
      
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

using namespace std;

const int N = 205;
string s[N];
int col[N], d[N];
int n;

bool dfs(int node, int c, vector<int> &comp) {
    col[node] = c;
    comp.push_back(node);
    for (int to = 0; to < n; to++) {
        if (s[node][to] == '1') {
            if (!col[to]) {
                if (dfs(to, 3 - c, comp))
                    return true;
            }
            else if (col[to] == col[node]) {
                return true;
            }
        }
    }
    return false;
}

int handle(vector<int> comp) {
    int ans = 0;

    for (int x : comp) {
        for (int y : comp)
            d[y] = -1;
        d[x] = 1;
        queue<int> q;
        q.push(x);

        while (!q.empty()) {
            int node = q.front();
            q.pop();

            for (int to = 0; to < n; to++) {
                if (s[node][to] == '1' && d[to] == -1) {
                    d[to] = d[node] + 1;
                    q.push(to);
                }
            }
        }

        for (int y : comp)
            ans = max(ans, d[y]);
    }

    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n;

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

    // for (int i = 0; i < n; i++) {
    //     for (int j = i + 1; j < n; j++) {
    //         if (s[i][j] == '1') {
    //             cout << i << " " << j << "\n";
    //         }
    //     }
    // }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        if (!col[i]) {
            vector<int> comp;
            if (dfs(i, 1, comp)) {
                cout << -1;
                return 0;
            }
            ans += handle(comp);
        }
    }
    
    cout << ans << "\n";

    return 0;
}

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

int main(){
    string S;
    cin >> S;
    string ans;
    if(S[0] == 'S')ans = "Cloudy";
    else if(S[0] == 'R')ans = "Sunny";
    else ans = "Rainy";
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();

        int tx = sc.nextInt();
        int ty = sc.nextInt();

        int dx = tx - sx;
        int dy = ty - sy;

        StringBuilder path = new StringBuilder();

        for(int i = 0; i < dy; i++)
        	path.append('U');
        for(int i = 0; i < dx; i++)
        	path.append('R');

        for(int i = 0; i < dy; i++)
        	path.append('D');
        for(int i = 0; i < dx; i++)
        	path.append('L');

        path.append('L');
        for(int i = 0; i < dy+1; i++)
        	path.append('U');
        for(int i = 0; i < dx+1; i++)
        	path.append('R');
        path.append('D');

        path.append('R');
        for(int i = 0; i < dy+1; i++)
        	path.append('D');
        for(int i = 0; i < dx+1; i++)
        	path.append('L');
        path.append('U');

        System.out.println(path.toString());
    }

}   

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n;
int M;
int dp[2][5005][5005];
inline void add(int &a,int b)
{
	a+=b;
	if(a>=M)a-=M;
}
int main()
{
	scanf("%d%d",&n,&M);
	int p=0,q=1;
	for(int i=1;i<=n;i++)
		dp[p][n-i+1][i]=1;
	int k=(n+3)/2;
	for(int i=2;i<k;i++)
	{
	//	cout<<i<<endl;
		int lim=min(n,n/(i-1)+1);
		for(int j=1;j<=lim*2&&j<=n;j++)for(int k=1;k<=n;k++)
			dp[q][j][k]=0;
		for(int k=1;k<=n;k++)//sum
		{
			int ans=0,presum=0;
			for(int j=lim;j>=1;j--)//val=j-1
			{
				add(presum,dp[p][j][k]);
				add(ans,presum);
				if(k-j+1>0)
				{
					add(dp[q][j][k-j+1],ans);
				}
			}
		}
		swap(p,q);
	}
	int ans=0;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
	{
		add(ans,dp[p][i][j]*1ll*(n&1?1:i)%M);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 195840
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N;
    private int[] A;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }


    public void Solve()
    {
        Scan();
        var ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 0)
            {
                ans[i / 2] = A[N - i - 1];
            }
            else
            {
                ans[N-i/2-1] = A[N - i - 1];
            }
        }
        Console.WriteLine(string.Join(" ", ans));
    }
}


Measured memory_bytes: 49720
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  vector<LL> n(4, 0);
  REP(i,6){
    LL a;
    cin>>a;
    n[a - 1]++;
  }
  bool flag = false;
  REP(i, 4)
  {
    if(n[i]>=3){
      flag = true;
    }
  }
  if(flag){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256