akhauriyash/Code-Regression huggingface dataset:
#if 1

#include <bits/stdc++.h>
using namespace std;
int n;
map <string,long long> d[105];
int a[5] = {'A','C','G','T'};

int ok(string s)
{
    for(int i = 0;i < 4;i++)
    {
        string s2 = s;
        if(i != 0)
        {
            char s3 = s2[i];
            s2[i] = s2[i-1];
            s2[i-1] = s3;
        }
        if(s2.substr(0,3) == "AGC"||s2.substr(1) == "AGC") return 0;
    }
    return 1;
}

long long dfs(int x,string s)
{
    if(d[x].count(s))
    {
        return d[x][s];
    }
    if(x == n) return 1;
    long long ans = 0;
    for(int i = 0;i < 4;i++)
    {
        char y = a[i];
        if(ok(s+y)) ans += dfs(x+1,s.substr(1)+y);
    }
    d[x][s] = ans%1000000007;
    return d[x][s];
}

int main()
{
    cin >> n;
    cout << dfs(0,"TTT");
}

#endif // 1++

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
bool s[2000005], h[200005];
int main() {
	int a, b, c, d;
	cin >> a >> b;
	vector<pair<int, int>>p(b);
	for (int i = 0; i < b; ++i) {
		cin >> c >> d;
		if (c == 1) s[d] = true;
		if (d == a) h[c] = true;
	}
	for (int i = 0; i < a; ++i) {
		if (s[i] && h[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2176
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 2345
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 1e9 + 7;
int R, B;
ll c[N][N];
inline void init() {
	c[1][1] = 1;
	for (int i = 2; i <= max(R, B) + 10; ++i)
		for (int j = 1; j <= i; ++j)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % P;
}
inline ll get_c(int n, int m) {
	if (n < 0 || m < 0 || n - m < 0)	return 0;
	return c[n + 1][m + 1];
}

ll f[N][N];
inline void work() {
	for (int s = 0; s <= max(R, B); ++s) {
		ll nw = 1; f[s][0] = 1;
		for (int t = 1; t <= max(R, B); ++t) {
			nw = (nw + get_c(s, t)) % P;
			f[s][t] = (f[s][t - 1] + nw) % P;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= R; ++i) {
		ll res = 1;
		for (int j = 1; j <= R - i; ++j)
			res = (res + f[j - 1][R - i - j] * get_c(B - 1, j)) % P;
		ans = (ans + res) % P;
	}
	printf("%lld\n", (ans % P + P) % P);
}

int main() {
	read(R), read(B);
	init();
	work();
	return 0;
}



Measured memory_bytes: 63356
import java.util.Scanner;

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

    long a = scanner.nextInt();
    long b = scanner.nextInt();
    long c = scanner.nextInt();

    long d = c - a - b;
    if (d > 0 && 4 * a * b < d * d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23764
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    int a, b;
     
    int main()
    {
    	cin >> a >> b;
    	cout << b + (b - a)<<endl;
     
    	return 0;
    }

Measured memory_bytes: 256
s = input()
l = len(s)
ans = [0] * l
count = 0
ix = 0
for i in range(l-1):
    if s[i] == "R" and s[i+1] == "L":
        ans[i] += 1 + count//2
        ans[i+1] = 1 + count - count//2
        count = 0
        ix = i
    elif s[i] == "R":
        count += 1
    elif s[i] == "L" and s[i+1] == "R":
        pass
    else:
        if (i - ix)%2 == 1:
            ans[ix] += 1
        else:
            ans[ix+1] += 1
print(*ans)

Measured memory_bytes: 6400
#include <stdio.h>
int main(){
  int i=0,j=0,k=0,l=0;

while(1){
  if(scanf("%d%d",&i,&j)!=2) break;
  if(i<j){
    k=i;
    i=j;
    j=k;
  }


while((l=i%j)!=0){
  i=j;
  j=l;
}

printf("%d\n",j);
break;
}
return 0;
}



Measured memory_bytes: 2052
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		String [] words = new String[n];
		boolean flag = true;
		
		for(int i = 0; i < n; i++) {
			words[i] = stdIn.next();
		}
		
		for(int i = 0; i < n-1; i++) {
			for(int j = i+1; j < n; j++) {
				if(words[i].equals(words[j])) {
					flag = false;
				}
			}
		}
		for(int i = 0; i < n-1; i++) {
			if(words[i+1].charAt(0) != words[i].charAt(words[i].length()-1)) {
				flag = false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        Console.WriteLine(n*n*n);
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"}; 
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int N, M; cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char d[1000];
    char *a,b[10];
    int p,q;
    scanf("%[^\n]s",d);

    a=strtok(d," ");
    p=atoi(a);
    for(int i=0;a!=NULL;i++)
    {
        if(i==1)strcpy(b,a);
        if(i==2)q=atoi(a);
        a=strtok(NULL," ");
    }
     if(strcmp(b,"+")==0)cout<<p+q<<endl;
     else cout<<p-q<<endl;
    return 0;
}


Measured memory_bytes: 256
let n = Scanf.scanf "%d" (fun n -> n)

let rec f i ret =
  if i = n+1 then ret
  else
    let rec g = function
      [] -> i :: ret
    | p :: l ->
      if i mod p = 0 then ret
      else g l
    in f (i+1) (g ret)

let primes = f 2 []

let rec ans ret = function
  [] -> ret
| p :: l ->
  let rec f q x =
    if q > n then x
    else
      let rec g i x =
        if i = n+1 then x
        else if i mod q = 0 then g (i+1) (x+1)
        else g (i+1) x
      in f (q * p) (g 2 x)
  in ans (ret * (f p 1) mod 1000000007) l

let () = print_int (ans 1 primes)


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

namespace _1_1_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }

            else
            { 
            
                Console.WriteLine("No");
            }  
        }
    }
}



Measured memory_bytes: 18012
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define mod 1000000007
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x; i<n; i++)
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)),x.resize(distance(x.begin(),unique(all(x))))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
ll min(ll a,ll b)
{
 return a<b?a:b;
}
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	f(i,0,n)
	cin>>arr[i];
	
	ll dp[n+1];
	dp[0]=0;dp[1]=0;dp[2]=dp[1]+abs(arr[1]-arr[0]);
	
	f(i,3,n+1)
	{
		dp[i]=min((abs(arr[i-1]-arr[i-2])+dp[i-1]),(abs(arr[i-1]-arr[i-3])+dp[i-2]));
	}
// 	f(i,0,n+1)
// 	{
// 		cout<<dp[i]<<" ";
// 	}
	cout<<dp[n];
  return 0;
}

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

using namespace std;

long long func(long long a, long long b, long long x) {
    return floor(a * x / b) - a * floor(x / b);
}

int main() {
    long long a, b, n;
    cin >> a >> b >> n;

    long long x = min(n, b - 1);
    long long ans = func(a, b, x);

    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> food(M);
    rep(i, N) {
        int K;
        cin >> K;
        rep(j, K) {
            int A;
            cin >> A;
            food[A - 1] += 1;
        }
    }
    int ans = 0;
    rep(i, M) if (food[i] == N) ans += 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	ll temp = C % B;
	for(int i = 1; i <= B; i++) {
		if(temp == (A * i) % B) {
			printf("YES\n");
			quit;
		} 
	}
	printf("NO\n");
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
 {
    int n,max=0,h[101]={0};
    while(cin>>n)
   {
        h[n]++;
        if(h[n]>max)max=h[n];
    }
    for(int i=1;i<=100;++i)
    if(h[i]==max)
  cout<<i<<endl;
return 0;
}

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

#define REP(i,j,k) for( int i = j; i < k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

int main(){
	
	int N;
	string S;
	
	cin >> N >> S;
	
	vector<long int> c(26,0);
	
	rep(i,N)
		c[S[i]-'a']++;
	
	long int ans = 1;
	
	rep(i,26){
		ans *= c[i]+1;
		ans = ( ans-1 ) % 1000000007 + 1;
	}
	
	cout << ans-1 << endl;
	
	return 0;
	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main(){
    string S; cin >> S;

    int L = S.size();

    int K = 0;

    int count = 0;

    int flag = 0;

    while(count < L){
        if(flag == 0){

        if(S[count+1] != S[count]){
            K++;
            count++;
            flag = 0;
        }else{
            K++;
            count += 2;
            flag = 1;
        }
        }else{
            K++;
            count ++;
            flag = 0;
        }
    }

    cout << K <<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    long A, B;

    scanf("%ld %ld", &A, &B);

    for (int i=1; i < 100000; i++) {
        if ((A * i) % B == 0) {
            printf("%ld", A * i);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<int> G[100005];
int dp[100005];

int dfs(int v){
  if(dp[v] != -1) return dp[v];
  if(G[v].size() == 0) return dp[v] = 0;
  int ret = 0;
  rep(i,G[v].size()){
    ret = max(ret, dfs(G[v][i]));
  }
  return dp[v] = ret + 1;
}

int main(){
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
  }

  rep(i,100005) dp[i] = -1;
  
  int ret = 0;
  REP(i,1,N+1){
    ret = max(ret, dfs(i));
  }

  cout << ret << endl;
  
  return 0;
}


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

int main() {
  int N,A=0;
  cin>>N;
  if(N/100>0&&N/100<13){
    A+=2;
  }
  if(N%100>0&&N%100<13){
    A++;
  }
  if(A==3){
    cout<<"AMBIGUOUS"<<endl;
  }
  if(A==2){
    cout<<"MMYY"<<endl;
  }
  if(A==1){
    cout<<"YYMM"<<endl;
  }
  if(A==0){
    cout<<"NA"<<endl;
  }

}

Measured memory_bytes: 256
s = input()
lis = s.split()
a = int(lis[0])
b = int(lis[1])
c = int(lis[2])
if c - a - b < 0:
    print("No")
else:
    ee = (c - a - b) * (c - a - b)
    dd = 4 * a * b - ee
    if dd < 0:
        print("Yes")
    else:
        print("No")

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

lis = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

count = 0

for i in range(2**n):
    b = bin(i)
    sw = [False] * n
    for j in range(n):
        if (i >> j) & 1:
            sw[j] = True

    boollist = []
    for j in range(m):
        k = lis[j][0]
        sl = lis[j][1:]
        total = 0

        for x in sl:
            if sw[x-1]:
                total += 1
        
        if total % 2 == p[j]:
            boollist.append(1)
        else:
            boollist.append(0)
    
    if all(boollist):
        count += 1

print(count)

Measured memory_bytes: 9244
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
string s,t; cin >> s >> t;
vector<char> a(s.size());
vector<char> b(t.size());
rep(i,s.size()){
  a[i] = s[i];
}
rep(i,t.size()){
  b[i] = t[i];
}
sort(all(a));
sort(b.rbegin(),b.rend());
if(a < b) cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var n int
	var s string
	_, _ = fmt.Fscan(reader, &n)
	_, _ = fmt.Fscan(reader, &s)
	c1 := make([]int, n)
	c2 := make([]int, n)
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "#" {
			if i == 0 {
				c1[0] = 1
			} else {
				c1[i] = c1[i-1] + 1
			}
		} else {
			if i == 0 {
				c1[0] = 0
			} else {
				c1[i] = c1[i-1]
			}
		}
		j := len(s) - i - 1
		if string(s[j]) == "." {
			if j == len(s)-1 {
				c2[j] = 1
			} else {
				c2[j] = c2[j+1] + 1
			}
		} else {
			if j == len(s)-1 {
				c2[j] = 0
			} else {
				c2[j] = c2[j+1]
			}
		}
	}
	v := c2[0]
	for i := 0; i < len(s)-1; i++ {
		r := c1[i] + c2[i+1]
		if r < v {
			v = r
		}
	}
	if c1[len(s)-1] < v {
		v = c1[len(s)-1]
	}
	_, _ = fmt.Fprintf(writer, "%d", v)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5248
N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]


def xxx(n):
    if n == 0:
        return 1
    else:
        return n * xxx(n-1)


d = 0
for i in range(N-1):
    for j in range(i+1, N):
        d += xxx(N - 1) * 2 * ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2) ** 0.5

ans = d / xxx(N)
print(ans)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x, sum = 0;
  while(cin >> x) sum += x;
  cout << (sum <= 21 ? "win" : "bust");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int n,i;
    double a,s[10020],m,a2;
     
    while(1){
        m=0;
        a2=0;
        scanf("%d", &n);
        if(n==0) break;
     
        for(i=0;i<n;i++){
            scanf("%lf", &s[i]);
            m=m+s[i];
        }
        m=m/n;
     
        for(i=0;i<n;i++){
            a2=a2+(s[i]-m)*(s[i]-m);
        }
        a2=a2/n;
     
        printf("%.8lf\n", sqrt(a2));
    }
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  while (q--) {
    int a, b, c, d; cin >> a >> b >> c >> d, --c;
    int n = a + b;
    int k = n / (min(a, b) + 1);
    if (k == 1) {
      for (int i = c; i < d; ++i) {
        cout << (a < b ^ i & 1 ? 'B' : 'A');
      }
      cout << '\n';
      continue;
    }
    int mid = ((lint) (k + 1) * a - n) / (k - 1);
    for (int m = mid - 2; m <= mid + 2; ++m) if (0 <= m and m <= n) {
      if (m - m / (k + 1) + (n - m) / (k + 1) != a) continue;
      int la = m % (k + 1);
      int lb = m and !(m % (k + 1));
      int ra = (n - m) and !((n - m) % (k + 1));
      int rb = (n - m) % (k + 1);
      if (la + ra <= k and lb + rb <= k) {
        for (int i = c; i < min(d, m); ++i) {
          cout << (i % (k + 1) != k ? 'A' : 'B');
        }
        for (int i = max(c, m); i < d; ++i) {
          cout << ((n - 1 - i) % (k + 1) != k ? 'B' : 'A');
        }
        cout << '\n';
        break;
      }
    }
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
double heron(double a,double b,double c){
  double s = (a+b+c)/2;
  return sqrt(s*(s - a)*(s - b)*(s - c));
}

int main(){
  double x[4],y[4];
  while(cin >> x[0]>>y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]){
  
    double A,B,C;
    A = sqrt(pow(x[0] - x[1],2)+pow(y[0] - y[1],2));
    B = sqrt(pow(x[0] - x[2],2)+pow(y[0] - y[2],2));
    C = sqrt(pow(x[2] - x[1],2)+pow(y[2] - y[1],2));

    double S1 = heron(A,B,C);

    double XA,XB,XC;
    XA = sqrt(pow(x[0] - x[3],2)+pow(y[0] - y[3],2));
    XB = sqrt(pow(x[1] - x[3],2)+pow(y[1] - y[3],2));
    XC = sqrt(pow(x[2] - x[3],2)+pow(y[2] - y[3],2));

    double S2 = heron(XA,XB,A) + heron(XA,XC,B) + heron(XB,XC,C);
    if(fabs(S1-S2)<10e-8)cout <<"YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int main()
{
    int k, x;
    int i;
    cin >> k >> x;
    for ( i = x-k+1; i<=x+k-1; i++)
    {
        cout << i << " " ;
    }
    cout << "\n";
    return 0;
}


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

int main()
{
	int n,ans=0;
	scanf("%d",&n);
	ans+=min(9,n);
	ans+=min(900,max(0,n-99));
	ans+=min(90000,max(0,n-9999));
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007


int32_t main(){
    IOS;

int n,k;
cin>>n>>k;
int a[n] , dp[n];

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

for(int i=1;i<n;i++)
{
dp[i] = (int)INT_MAX;
     for(int j=1;j<=k && i-j>=0;j++)
     {

    dp[i] = min(dp[i-j] + abs(a[i] - a[i-j]),dp[i]);
     
}
}

cout<<dp[n-1]<<endl;


}


Measured memory_bytes: 1792
N = int(input())
p = list(map(int, input().split()))

sor_N = sorted(p)

cn = 0

for i in range(N):
    if p[i] != sor_N[i]:
        cn = cn + 1


if cn == 0 or cn == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61900
N=int(input())
S=input()


num=S.count("#")
if num>S.count("."):#全部黒にする
  num=S.count(".")
  
  
c_w=0
c_b=S.count(".")

for i in range(0,N): #i番目まで白
  if S[i]=="#":
    c_w+=1
  else:
    c_w=c_w
    c_b-=1
  num=min(num,c_w+c_b)
 
print(num)

Measured memory_bytes: 3500
"""
~~ author : dokueki
~~ created : 07~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def Try():
    a, b, n = map(int, sys.stdin.readline().split())
    x = min(b - 1, n)
    print((a*x)//b - a*(x//b))


def main():
    Try()


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) cin >> D[i];
  int answer = 0;
  for (int a = 0; a < N; a++) {
    for (int b = a + 1; b < N; b++) {
      answer += D[a] * D[b];
    }
  }
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;
#define MAX 10000003 
using namespace std; 

typedef long long ll; 
const int mod = 1000000007; 

int prime[MAX]; 
unordered_map<int, int> max_map; 

int power(int a, int n) { 
	if (n == 0) 
		return 1; 
	int p = power(a, n / 2) % mod; 
	p = (p * p) % mod; 
	if (n & 1) 
		p = (p * a) % mod; 
	return p; 
} 

void sieve() 
{ 
	prime[0] = prime[1] = 1; 
	for (int i = 2; i < MAX; i++) { 
		if (prime[i] == 0) { 
			for (int j = i * 2; j < MAX; j += i) { 
				if (prime[j] == 0) { 
					prime[j] = i; 
				} 
			} 
			prime[i] = i; 
		} 
	} 
} 

// Function to return the LCM modulo M 
ll lcmModuloM(const int* ar, int n) 
{ 

	for (int i = 0; i < n; i++) { 
		int num = ar[i]; 
		unordered_map<int, int> temp; 

		// Temp stores mapping of prime factor to 
		// its power for the current element 
		while (num > 1) { 

			// Factor is the smallest prime factor of num 
			int factor = prime[num]; 

			// Increase count of factor in temp 
			temp[factor]++; 

			// Reduce num by its prime factor 
			num /= factor; 
		} 

		for (auto it : temp) { 

			// Store the highest power of every prime 
			// found till now in a new map max_map 
			max_map[it.first] = max(max_map[it.first], it.second); 
		} 
	} 

	ll ans = 1; 
	for (auto it : max_map) { 
		ans = (ans * power(it.F, it.S)) % mod; 
	} 

	return ans; 
} 


#undef int
int main() {
#define int long long int 
	sieve(); 
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
	cin >> a[i];
	int lcm = lcmModuloM(a, n);
	int ans = 0;
	for(int i = 0; i < n; i++)
	ans = (ans + (lcm * power(a[i], mod - 2)) % mod) % mod;
	
	cout << ans << endl;
	return 0; 
} 


Measured memory_bytes: 78848
/*  -*- coding: utf-8 -*-
 *
 * 2921.cc: Working
 */

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

/* constant */

const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int minave = INF, sum = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    sum += ai;
    int ave = sum / (i + 1);
    if (minave > ave) minave = ave;
  }

  printf("%d\n", minave);
  return 0;
}



Measured memory_bytes: 3232
c = [[] for _ in range(3)]
for i in range(3):
    c[i] = list(map(int,(input().split())))
a1 = c[1][0] - c[0][0]
a2 = c[2][0] - c[0][0]
b1 = c[0][1] - c[0][0]
b2 = c[0][2] - c[0][0]

if c[1][1]-c[0][0] == a1+b1 and c[2][1]-c[0][0] == a2+b1 and c[1][2]-c[0][0] == a1+b2 and c[2][2]-c[0][0] == a2+b2:
    print("Yes")
else:
    print("No")    

Measured memory_bytes: 38256
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e9
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007 
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}



int main() {
    
    fastio;
    string s;
    int n;
    cin >> n;
    vector<ll> a(n);
    ll m;
    ll sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        if(i == 0)
            m = a[i];
        else
            m = max(m, a[i]);
        sum += (m - a[i]);
    }
    cout << sum;
    return 0; 
}

Measured memory_bytes: 4780
// #include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<numeric>
#include<bitset>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n); // 0で埋め尽くされる
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  rep(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 23424
A,B,C = map(int,input().split())
if A%2==1 or B%2==1 or C%2==1:
    print(0)
elif A==B and B==C:
    print(-1)
else:
    ans = 0
    while True:
        if A%2==0 and B%2==0 and C%2==0:
            ans+=1
            A,B,C = (B+C)//2,(C+A)//2,(A+B)//2
        else:break
    print(ans)

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = c - a - b;
    if(x > 0 && 4 * a * b < x * x){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
signed main(){
    int h,n,z;
    scanf("%d %d",&h,&n);
    z=h+n;
    if(z>0){
        z=1;
    }
    if(z<0){
        z=-1;
    }
    printf("%d\n",z);
 return(0);
}



Measured memory_bytes: 2104
def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors

a,b = map(int,input().split())
da = set(division(a))
db = set(division(b))
cnt = 0
for i in da:
    if i in db:
        cnt += 1
print(cnt)

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
ll keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
ll keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
ll ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll l[10];
ll N,A,B,C; 

ll solve(){
  cin >>N>>A>>B>>C;
  CINA(l,N);
  ll ans = pow(10,9);
  for(ll bits=0; bits<pow(4,N); ++bits){
    ll p = -30;
    ll temp = bits;
    ll x[4] = {0};
    for(ll i=0;i<N;++i){
      x[ temp%4 ] += l[i];
      if(temp%4>0){ p += 10; }
      temp /= 4;
    }
    x[0] = 0;
    sort(x,x+4);
    if(x[1]==0){ continue; }
    p += abs(x[3]-A) + abs(x[2]-B) + abs(x[1]-C);
    ans = min(p,ans);
  }
  return ans;
}

int main(){
  cout << solve() <<"\n";
}

Measured memory_bytes: 256
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 1/27/2019, 9:12:45 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int A[100010];
int B[100010];
set<int> V[100010];
set<int> W[100010];
int root;
int depth[100010];
int parent[100010];
typedef tuple<int, int, int> T; // v, pa, de
queue<T> Q;

void solve(int v)
{
  if (parent[v] != -2)
  {
    return;
  }
  for (auto x : W[v])
  {
    solve(x);
  }
  int maxi = -1;
  int ind = -1;
  for (auto x : W[v])
  {
    if (maxi < depth[x])
    {
      ind = x;
      maxi = depth[x];
    }
  }
  parent[v] = ind;
  depth[v] = maxi + 1;
  // cerr << "parent[" << v << "] = " << parent[v] << endl;
  // cerr << "depth[" << v << "] = " << depth[v] << endl;
}

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < N - 1 + M; i++)
  {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  for (auto i = 0; i < N - 1 + M; i++)
  {
    V[A[i]].insert(B[i]);
    W[B[i]].insert(A[i]);
  }
  fill(depth, depth + N, -1);
  fill(parent, parent + N, -2);
  int root_cnt = 0;
  for (auto i = 0; i < N; i++)
  {
    if (W[i].empty())
    {
      root_cnt++;
      root = i;
      depth[i] = 0;
      parent[i] = -1;
    }
  }
  assert(root_cnt == 1);
  for (auto i = 0; i < N; i++)
  {
    solve(i);
  }
  for (auto i = 0; i < N; i++)
  {
    cout << parent[i] + 1 << endl;
  }
}

Measured memory_bytes: 24064
#include <iostream>

using namespace std;

int f[100][10];
int p[100][11];

int n;

int calc(int x){
	int num[100];
	for(int i = 0;i < n;i++){
		num[i] = 0;
	}
	
	for(int i = 0;i < 10;i++){
		if((x&(1<<i)) != 0){
			for(int j = 0;j < n;j++){
				if(f[j][i]){
					num[j]++;
				}
			}
		}
	}
	
	int ret = 0;
	for(int i = 0;i < n;i++){
		ret += p[i][num[i]];
	}
	
	return ret;
}

int main(){
	cin >> n;
	
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 10;j++){
			cin >> f[i][j];
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 11;j++){
			cin >> p[i][j];
		}
	}
	
	int res = -1100000000;
	for(int i = 1;i < (1<<10);i++){
		res = max(res, calc(i));
	}
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
// #include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
// using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N, K; cin >> N >> K;
    vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(H.begin(), H.end(), greater<long long>());
    long long ans = 0;
    for (int i = K; i < N; i++) {
        ans += H[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;
 
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i,k,n,m,a[100],tmp;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(k=1;k<=m;k++){
		for(i=0;i<n-1;i++){
			if((a[i]%k)>(a[i+1]%k)){
				tmp=a[i];
				a[i]=a[i+1];
				a[i+1]=tmp;
			}
		}
	}
	for(i=0;i<n;i++)
		printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String strn=sc.next();
    String strnarr[]=strn.split("");
    int sum=0;
    for(int i=0;i<strn.length();i++){
      sum+=Integer.parseInt(strnarr[i]);
    }
    if(sum%9==0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 54788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const double PI=acos(-1);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
#define travel_set(it,a) for (set<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_map(it,a) for (map<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define travel_vec(it,a) for (vector<int>::iterator (it)=(a).begin();(it)!=(a).end();(it)++)
#define p(x) cout << x << endl;
#define def cout << "find" << endl;
#define what_is(x) cout << #x << " is " << x << endl;
template <class T>T sqr(T x){return x*x;}
template <class T>T alex(T x){return (x>0)?x:-x;}
template <class T>void read(T&x){
	x=0;T f=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if (ch=='-')f=-1,ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}

//---------------------------------------------------head---------------------------------------------------

#define maxn 100005
struct Ed{
	int sn[maxn<<1],nx[maxn<<1],ln[maxn],tt;
	void add(int x,int y){
		tt++;sn[tt]=y;nx[tt]=ln[x];ln[x]=tt;
		tt++;sn[tt]=x;nx[tt]=ln[y];ln[y]=tt;
	}
}ed;
int n;
bool vis[maxn],used[maxn];
void dfs(int x){
	vis[x]=true;int cn=0;
	for (int j=ed.ln[x];j;j=ed.nx[j])if (!vis[ed.sn[j]]){
		dfs(ed.sn[j]);if (!used[ed.sn[j]])cn++;
	}
	if (cn>1){printf("First\n");exit(0);}
	if (cn==1)used[x]=true;
}
int main(){
	read(n);if (n&1){printf("First\n");return 0;}
	Rep(i,1,n){
		int x,y;read(x);read(y);
		ed.add(x,y);
	}
	dfs(1);printf("Second\n");return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    long long dp[n+1][2];
    dp[0][0] = 0; dp[0][1] = 1e18;
    for (int i = 0; i < n; i++) {
        dp[i+1][0] = dp[i][0] + s[i] - '0';
        dp[i+1][1] = dp[i][0] + (10 - (s[i] - '0'));
        if (s[i] - '0' + 1 > 9) {
            dp[i+1][1] = min(dp[i+1][1], dp[i][1] + (s[i] - '0' - 9));
        } else {
            dp[i+1][0] = min(dp[i+1][0], dp[i][1] + (s[i] - '0' + 1));
            dp[i+1][1] = min(dp[i+1][1], dp[i][1] + 10 - (s[i] - '0' + 1));
        }
    }
    cout << min(dp[n][0], dp[n][1]+1) << "\n";
    return 0;
}

Measured memory_bytes: 16924
#include<stdio.h>
int main()
{
	int N,K,X,Y,C;
	1<=K<=10000;
	1<=N<=10000;
	1<=Y<X<=10000;
	scanf("%d%d%d%d",&N,&K,&X,&Y);
	if(K<N)
	C=X*K+(N-K)*Y;
	else
	C=N*X;
	printf("%d",C);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    
    ll a[n];memset(a,0,sizeof(a));
    ll m;
    
    rep(i,1,n-1){
        if(s[i]=='E'){
            a[0]++;
        }
    }
    m=a[0];
    rep(k,0,n-2){
        if(s[k+1]=='E'){
            a[k+1]=a[k]-1;
        }else{
            a[k+1]=a[k];
        }
        if(s[k]=='W'){
            a[k+1]=a[k+1]+1;
        }
        if(m>a[k+1]){
            m=a[k+1];
        }
    }
    
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
const int N=602,M=1000000007;
using namespace std;
int n,nn,x,y,op[N],f[N][N],g[N][N],fac,tp;
inline void tr(int x,int y){
	if(x>=0&&y>=0)
	(f[x][y]+=tp)>=M?f[x][y]-=M:0;
}
int main(){
	scanf("%d",&nn),f[0][0]=1;
	for(int i=0;i<nn;i++){
		scanf("%d%d",&x,&y);
		x=max(x,0),y=max(y,0);
		if(x&&y)op[x]=op[y]=2;
		else if(x||y)op[x]=op[y]=1;
		else f[0][0]=1ll*f[0][0]*++fac%M;
	}
	for(int i=1;i<=nn*2;i++)
	if(op[i]<2)op[n++]=op[i];
	for(int i=0;i<n/2;i++)swap(op[i],op[n-i-1]);
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++)
		for(int k=0;j+k<=i&&j+k<=n-i;k++)
		g[j][k]=f[j][k],f[j][k]=0;
		for(int j=0;j<=i;j++)
		for(int k=0;j+k<=i&&j+k<=n-i;k++)
		if(g[j][k]){
			tp=g[j][k];
			tr(j+!op[i],k+op[i]);
			tr(j-1,k);
			if(!op[i])
			tp=1ll*tp*k%M,tr(j,k-1);
		}
	}
	printf("%d",f[0][0]);
}

Measured memory_bytes: 1664
n,m = map(int,input().split())
h = list(map(int,input().split()))
tiisai_set = set()
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] > h[b-1]:
        tiisai_set.add(b)
    elif h[a-1] < h[b-1]:
        tiisai_set.add(a)
    else:
        tiisai_set.add(a)
        tiisai_set.add(b)
print(n-len(tiisai_set))

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

using namespace std;

#define int long long

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(b * c, max(a * d, b * d)));
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3648
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        long X = Long.parseLong(in.readLine());
        long base = 100;
        int ans = 0;
        while(base < X) {
            base = base + (base / 100);
            ++ans;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n;
    vector<ll> a(5);
    cin >> n;
    rep(i, 5) cin >> a[i];
    sort(whole(a));

    
    ll ans = 4LL + (n-1)/a[0] + 1;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List (elemIndex)
import Data.Maybe (fromJust)

cards :: [Int]
cards = [2 .. 13] ++ [1]

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    let i = fromJust $ elemIndex a cards
    let j = fromJust $ elemIndex b cards
    putStrLn $ f $ i - j
    where
        f x
            | x > 0 = "Alice"
            | x < 0 = "Bob"
            | otherwise = "Draw"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
string mp[101];
int h,w;
bool used[101][101];

void saiki(int x,int y,char ch){
  int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
  if(used[y][x]) return;
  used[y][x]=1;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!=ch)continue;
    saiki(nx,ny,ch);
  }
}


int main(){
  while(1){

  cin>>h>>w;
  if(!h&&!w)break;
  for(int i=0;i<h;i++)cin>>mp[i];

  memset(used,0,sizeof(used));
  int ans=0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(!used[i][j]) ans++,saiki(j,i,mp[i][j]);
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2492
#include <cstdio>
using namespace std;
int main(){
    int N,M,S=0;
    scanf("%d",&N);
    int A = N;
    while(N){
        M = N%10;
        S += M;
        N /= 10;
    }
    if(A%S==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

vector<vector<bool> > q(8, vector<bool>(8, false)), ans;
vector<bool> q2(8, false);

void makeok(int x, int y, vector<vector<bool> >& ok){
  for(int j = 0; j < 8; j++){
    ok[x][j] = false;
    ok[j][y] = false;
  }
  int i = x, j = y;
  while(i >= 0 && j >= 0){
    ok[i][j] = false;
    i--;
    j--;
  }
  i = x, j = y;
  while(i < 8 && j < 8){
    ok[i][j] = false;
    i++;
    j++;
  }
  i = x, j = y;
  while(i >= 0 && j < 8){
    ok[i][j] = false;
    i--;
    j++;
  }
  i = x, j = y;
  while(i < 8 && j >= 0){
    ok[i][j] = false;
    i++;
    j--;
  }
}

void func(int l, vector<vector<bool> >& ok){
  //cout << l << endl;
  if(l >= 8){
    ans = q;
    return;
  }
  if(q2[l] == true) func(l + 1, ok);
  for(int i = 0; i < 8; i++){
    if(ok[l][i] == true){
      vector<vector<bool> > ok2;
      ok2 = ok;
      makeok(l, i, ok);
      q[l][i] = true;
      func(l + 1, ok);
      ok = ok2;
      q[l][i] = false;
    }
  }
  return;
}

void solve(){
  int k; cin >> k;
  vector<vector<bool> > ok(8, vector<bool>(8, true));
  for(int i = 0; i < k; i++){
    int x, y; cin >> x >> y;
    q[x][y] = true;
    q2[x] = true;
    makeok(x, y, ok);
  }

  func(0, ok);

  /*for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
      if(ok[i][j] == true) cout << 'o';
      else cout << 'x';
      cout << " ";
    }
    cout << endl;
  }*/

  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
      if(ans[i][j] == true) cout << 'Q';
      else cout << '.';
    }
    cout << endl;
  }
  return;
}
int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3116