akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	v.sort()
	ans = v[0]
	for i in range(1, n):
		ans = (ans+v[i])/2
	print("{:.5f}".format(ans))


if __name__ == '__main__':
	main()


Measured memory_bytes: 38768
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    ll N, M, K;
    io.read(N, M, K);
    auto A = io.read_vec<ll>(N);
    auto B = io.read_vec<ll>(M);

    for(int i = 1; i < N; i++){
        A[i] += A[i - 1];
    }
    A.insert(A.begin(), 0);
    for(int i = 1; i < M; i++){
        B[i] += B[i - 1];
    }
    B.insert(B.begin(), 0);
    int ans = 0;
    for(int i = 0; i <= N; i++){
        ll r = K - A[i];
        auto uitr = upper_bound(B.begin(), B.end(), r);
        if(uitr == B.begin()) break;
        int bidx = uitr - B.begin() - 1;
        ans = max(ans, i + bidx);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] hn = br.readLine().split(" ");
		int h = Integer.parseInt(hn[0]);
		int n = Integer.parseInt(hn[1]);
		long[] darray = new long[h+1];
		int[] a = new int[n];
		int[] b = new int[n];
		int bmin = Integer.MAX_VALUE;
		for(int i = 0 ; i < n ; i++) {
			String[] ab = br.readLine().split(" ");
			a[i] = Integer.parseInt(ab[0]);
			b[i] = Integer.parseInt(ab[1]);
			bmin = Math.min(bmin, b[i]);
		}
		for(int i = 0 ; i < h+1 ; i++) {
			darray[i] = Long.MAX_VALUE;
		}
		for(int i = 0; i <= h ; i++) {
			for(int j = 0 ; j < n ; j++) {
				if(i >= a[j]) {
					darray[i] = Math.min(darray[i], darray[i-a[j]]+b[j]);
				}else {
					darray[i] = Math.min(darray[i], darray[0]+b[j]);
				}
			}
			if(i == 0){
				darray[i] = 0;
			}else if(darray[i] == Long.MAX_VALUE) {
				darray[i] = bmin;
			}
		}
		System.out.println(darray[h]);
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n, h;
int ans;

struct PP {
	int a;
	int b;
} p[maxx];

bool cmp(PP x, PP y) { return x.b > y.b; }

int main() {
	cin >> n >> h;
	int max0 = 0;
	for(int i = 1; i <= n; i++) {
		cin >> p[i].a >> p[i].b;
		max0 = max(max0, p[i].a);
	}
	p[n + 1].a = 0, p[n + 1].b = max0;
	sort(p + 1, p + n + 2, cmp);
	for(int i = 1; i <= n + 1; i++) {
		if(p[i].b > max0) {
			ans++;
			h -= p[i].b;
		}
		else if(p[i].b == max0) {
			ans += h / max0;
			if(h % max0) ans++;
			h -= ans * max0;
		}
		if(h <= 0) break;
	}
	cout << ans << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<ll>nums;
    nums.push_back(2);
    nums.push_back(1);
    
    
    for(int i = 2;i<=n;i++){
       nums.push_back(nums[i-1]+nums[i-2]);
    }
    cout<<nums[n]<<"\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k; cin >> n >> k;
  vector<ll> a(n);
  rep (i, n) cin >> a[i];

  for (int i = k; i < n; i++) {
    if (a[i] > a[i-k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4816
#include <stdio.h>
int main(){
int a,b,c,d,e,max=-1000;
scanf ("%d%d",&a,&b);
c=a+b;
d=a-b;
e=a*b;
if (max<c){
max=c;
}
if (max<d){
max=d;
}
if (max<e){
max=e;
}
printf("%d",max);
return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define maxn 777

using namespace std;
bool f[maxn][maxn],g[maxn][maxn*2],vis[maxn],flag,h[maxn];
int n,m,a[maxn],b[maxn],p,q,r,o;

void dfs(int u,bool d){
    h[u]=d; vis[u]=true; if (d) p++; else q++;
    for (int i=1;i<=n;i++) if (f[u][i]){
        if (!vis[i]) dfs(i,d^1);
        else if (d==h[i]) flag=true;
    }
}

int main(){
    cin >> n >> m;
    memset(f,true,sizeof(f));
    for (int i=1;i<=n;i++) f[i][i]=0;
    for (int i=0;i<m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        f[u][v]=f[v][u]=0;
    }
    for (int i=1;i<=n;i++) if (!vis[i]) {
        dfs(i,0); r++;
        a[r]=p; b[r]=q;
        p=0; q=0;
    }
    if (flag) {cout << -1 << endl; return 0;}
    g[0][n]=true;
    for (int i=1;i<=r;i++)
        for (int j=0;j<=n*2;j++)
            if (g[i-1][j]) g[i][j+b[i]-a[i]]=true,g[i][j-b[i]+a[i]]=true;
    o=n;
    for (int i=0;i<=n*2;i++) if (g[r][i]) o=min(o,abs(n-i));
    p=(n+o)/2; q=(n-o)/2;
    printf("%d\n",p*(p-1)/2+q*(q-1)/2);
    return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for(int i = 0; i < N; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int a;
      cin >> a;
      a--;
      A[a]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < M; i++) if(A[i] == N) ans++;
  cout << ans <<endl;
}


Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for(int i=0; i<n; i++) {
            a.add(i+1);
        }
        for(int i=0; i<k; i++) {
            int b = sc.nextInt();
            for(int j=0; j<b;j++) {
                int c = sc.nextInt();
                a.remove(Integer.valueOf(c));
            }
        }
        System.out.println(a.size());
    }
}

Measured memory_bytes: 37672
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL unsigned long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 100 + 10;
const int INF = 0x3f3f3f3f;
int x[N], y[N];
int main() {
	int n, m, X, Y, mx, mn;
	scanf("%d %d %d %d", &n, &m, &X, &Y);
	mx = X;
	mn = Y;
	for (int i = 0; i < n; i++) scanf("%d", &x[i]), mx = max(mx, x[i]);
	for (int i = 0; i < m; i++) scanf("%d", &y[i]), mn = min(mn, y[i]);
	if(mx >= mn) puts("War");
	else puts("No War");
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

#pragma warning(disable : 4996)

int N, Y, M, D;

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

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &Y);
		scanf("%d", &M);
		scanf("%d", &D);

		if (Y == 0 && M == 0 && D == 0) break;

		int ret = 0;

		for (int i = 1; i < Y; i++)
		{
			if (i % 3 == 0)
			{
				ret += 200;
			}
			else
			{
				ret += 195;
			}
		}

		for (int i = 1; i < M; i++)
		{
			if (Y % 3 != 0 && i % 2 == 0)
			{
				ret += 19;
			}
			else
			{
				ret += 20;
			}
		}

		ret += D;

		printf("%d\n", 196471 - ret);
	}

	return 0;
}

Measured memory_bytes: 2680
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let mut colors:Vec<i32> = (0..3).map(|_| sc.read()).collect();
    colors.sort();
    colors.dedup();
    println!("{}", colors.len())


}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 4352
W, H, N = map(int, raw_input().split())
x = []
y = []
a = []
for i in range(N):
    xi, yi, ai = map(int, raw_input().split())
    x.append(xi)
    y.append(yi)
    a.append(ai)

xs = set(range(W))
ys = set(range(H))
for i in range(N):
    xi, yi, ai = x[i], y[i], a[i]
    if ai == 1:
        xs -= set(range(xi))
    elif ai == 2:
        xs -= set(range(xi, W))
    elif ai == 3:
        ys -= set(range(yi))
    elif ai == 4:
        ys -= set(range(yi, H))
    else:
        continue
print len(xs) * len(ys)


Measured memory_bytes: 2948
//
// Created by watemus on 08.09.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

using ll = long long;
using ld = long double;

#define int ll

template<typename T>
using vec = std::vector<T>;

template<typename T>
using uset = std::unordered_set<T>;

template<typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);

#ifdef LOCAL
std::mt19937 rnd(228);
#else
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
#endif

vec<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

/*
template<class... Args>
auto Vec(size_t n, Args&&... args) {
  if constexpr(sizeof...(args) == 1)
    return vector(n, args...);
  else
    return vector(n, Vec(args...));
}*/

#ifdef LOCAL
#else
#endif

void run() {
  int x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  int iter = min(k, x / d);
  x -= iter * d;
  int ans = x;
  if ((k - iter) % 2) {
    x -= d;
    ans = abs(x);
  }
  cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int t = 1;
  //cin >> t;
  while (t--) {
    run();
  }
  return 0;
}




Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int A, B;

int recur_sum(int N){
    if(N==1) return 1;
    return N + recur_sum(N-1);
}

void solve(){
    int diff = B - A;

    cout << recur_sum(diff) - B << endl;
}

int main(){
    cin >> A >> B;

    solve();
}


Measured memory_bytes: 256
# abc110_c

from collections import Counter
from operator import itemgetter


def solve(seq1, seq2):
    if len(seq1) != len(seq2):
        return "No"
    letters1 = sorted(Counter(seq1).most_common(), key=itemgetter(1, 0), reverse=True)
    letters2 = sorted(Counter(seq2).most_common(), key=itemgetter(1, 0), reverse=True)
    for i in range(len(letters1)):
        if letters1[i][1] != letters2[i][1]:
            return "No"
    return "Yes"


if __name__ == "__main__":
    seq1 = input("")
    seq2 = input("")
    print(solve(seq1, seq2))


Measured memory_bytes: 4144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();

            var n = cin.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = cin.nextInt();
            }

            int ans = 0;
            for (int i = 1; i < n-1; i++)
            {
                if(p[i] < p[i+1] && p[i] >= p[i - 1])
                {
                    ans++;
                }
                else if (p[i] < p[i - 1] && p[i] >= p[i + 1])
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);

        }

       
    }

    class Point
    {
        public int x { get; set; }
        public int y { get; set; }
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

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

        public long nextLong()
        {
            return long.Parse(next());
        }

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

        public double nextDouble()
        {
            return double.Parse(next());
        }


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

Measured memory_bytes: 11220
#include <cstdio>
#include <algorithm>
using namespace std;

int n, a[15], x[15][15], y[15][15], ans;

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        for(int j = 0; j < a[i]; j++) scanf("%d %d", &x[i][j], &y[i][j]), x[i][j]--;
    }
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        for(int i = 0; i < n; i++) if((bit >> i) & 1){
            for(int j = 0; j < a[i]; j++)
                flag = flag && (((bit >> x[i][j]) & 1) == y[i][j]);
        }
        if(flag) ans = max(ans, __builtin_popcount(bit));
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 200005
int a[N],n,k;
vector<int> b,c;
int ze=0;
bool judge(int dat)
{
	int sum=0;
	if(dat<0)
	{
		int cur=b.size()-1;
		for(int i=0;i<c.size();i++)
		{
			while(cur>=0&&b[cur]*c[i]<=dat) cur--;
			sum+=(b.size()-cur-1);
		}
	}
	if(dat==0)
	{
		sum=b.size()*c.size()+ze*(n-ze)+ze*(ze-1)/2;
	}
	if(dat>0)
	{
		int cur=b.size()-1;
		for(int i=0;i<b.size();i++)
		{
			while(cur>=0&&b[i]*b[cur]>dat) cur--;
			sum+=cur+1;
			if(b[i]*b[i]<=dat) sum--;
		}
		cur=c.size()-1;
		for(int i=0;i<c.size();i++)
		{
			while(cur>=0&&c[i]*c[cur]>dat) cur--;
			sum+=cur+1;
			if(c[i]*c[i]<=dat) sum--;
		}
		sum/=2;
		sum+=b.size()*c.size();
		sum+=ze*(n-ze)+ze*(ze-1)/2;
	}
//	printf("%lld %lld\n",dat,sum);
	return sum>=k;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
//		cout<<a[i]<<endl;
	}
//	cout<<"passed\n";
	for(int i=1;i<=n;i++)
	{
		if(a[i]>0) b.pb(a[i]);
		if(a[i]==0) ze++;
		if(a[i]<0) c.pb(a[i]);
	}
	sort(b.begin(),b.end());
	sort(c.begin(),c.end(),greater<int>());
	int l=-(int)1e18-10,r=(int)1e18+10,ans;
	while(l<=r)
	{
//		printf("%lld %lld\n",l,r);
		int mid=(l+r)/2;
		if(judge(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

int main()
{
	char s[4];

	cin >> s;

	FOR(i, 0, 3){
		switch(s[i]){
		case '1': s[i] = '9'; break;
		case '9': s[i] = '1'; break;
		}
	}

	cout << s << endl;

	return 0;
}



Measured memory_bytes: 256
# C - K-th Substring

s = str(input())
K = int(input())

str_list = set()
for i in range(len(s)+1):
    for j in range(i+1, i+K+1):
        if j > len(s):
            break
        str_list.add(s[i:j])

str_list = list(str_list)
str_list.sort()
print(str_list[K-1])



Measured memory_bytes: 10436
import sys
from collections import deque

sys.setrecursionlimit(50000)

n = int(input())

data = [[] for _ in range(n)]
answer = [-1]*n
answer[0] = 0
for i in range(n):
    line = list(map(int, input().split(" ")))
    if line[1] != 0:
        for e in line[2:]:
            data[i].append(e)


def bfs(vs, count=0):
    next_vs = []
    for v in vs:
        for n_v in data[v-1]:
            if answer[n_v-1] == -1:
                answer[n_v-1] = count+1
                next_vs.append(n_v)
    if not next_vs == []:
        bfs(next_vs, count+1)


bfs([1])

for i in range(n):
    line = str(i+1) + " " + str(answer[i])
    print(line)



Measured memory_bytes: 6000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int X = reader.nextInt();
		int[] A = new int[N];
		int ans1 = 0;
		int ans2 = 0;
		for (int i = 0; i < M; i++) {
			A[reader.nextInt()] = 1;
		}

		for (int i = X; i < N; i++) {
			ans1 += A[i];
		}
		for (int i = X; i > 0; i--) {
			ans2 += A[i];
		}
		System.out.println(Math.min(ans1, ans2));
		reader.close();
	}
}



Measured memory_bytes: 23764
card = list()
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
card.append(a1)
card.append(a2)
card.append(a3)

res = list()
res1 = list(False for i in range(3)) 
res2 = list(False for i in range(3)) 
res3 = list(False for i in range(3)) 
res.append(res1)
res.append(res2)
res.append(res3)
res

for _ in range(n):
    num = int(input())
    for i in range(len(card)):
        for j in range(len(card)):
            if num == card[i][j]:
                res[i][j] = True

final = "No"
for r in range(len(res)):
    tmp = []
    tmp.append(all(res[r]))
    if all(tmp) == True:
        final = "Yes"

for c in range(len(res)):
    tmp = []
    for r in range(len(res)):
        tmp.append(res[r][c])
    if all(tmp) == True:
            final = "Yes"

tmp = []
for i in range(len(res)):
    tmp.append(res[i][i])
if all(tmp) == True:
    final = "Yes"

tmp = []
for i in range(len(res)):
    j = len(res) - i - 1
    tmp.append(res[i][j])
if all(tmp) == True:
    final = "Yes"

print(final)

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

using namespace std;

int main(int argc, char const* argv[]){
    int n,m;
    cin >> n >> m;
    vector<int> a;
    vector<int> b;

    for(int i=0;i<m;++i){
        int tmp_a,tmp_b;
        cin >> tmp_a >> tmp_b;
        a.push_back(tmp_a);
        b.push_back(tmp_b);
    }

    a.insert(a.end(),b.begin(),b.end());

    for(int i=0;i<n;i++){
        int n_count = std::count(a.begin(),a.end(),i+1);
        cout << n_count << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main(){
    ll n;
    cin >> n;

    ll res[4] = {0, 0, 0, 0};

    rep(i, n){
        string s;
        cin >> s;
        if(s == "AC"){
            res[0]++;
        }else if(s == "WA"){
            res[1]++;
        }else if(s == "TLE"){
            res[2]++;
        }else{
            res[3]++;
        }
    }

    cout << "AC x " << res[0] << endl;
    cout << "WA x " << res[1] << endl;
    cout << "TLE x " << res[2] << endl;
    cout << "RE x " << res[3] << endl;

}

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

using namespace std;

int main() {
  int K;
  string S;

  cin >> K;
  cin >> S;

  if (S.size() <= K) {
    cout << S << endl;
    return 0;
  }

  cout << S.substr(0, K) << "..." << endl;

  return 0;
}


Measured memory_bytes: 3564
n = int(input())
a = [0]*n
xy = [[] for _ in range(n)]
for i in range(n):
    a[i] = int(input())
    xy[i] = [[int(j) for j in input().split()] for _ in range(a[i])]
ans = 0

for i in range(0,2**n+1):
    cnt = 0
    for j in range(len(a)):
        if i>>j & 1 == 0:
            continue
        st = True
        for k in range(a[j]):
            if i>>(xy[j][k][0]-1) & 1 != xy[j][k][1]:
                st = False
        if st == False:
            break
        cnt += 1
    else:
        ans = max(ans, cnt)
            
print(ans)


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

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

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

    int res = 0;
    for (int i = 0; i <= 100000; i++) {
        int abc = lower_bound(D.begin(), D.end(), i) - D.begin();
        if (abc == N / 2) res++;
    }

    cout << res << endl;
    return 0;
}

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

const int maxn = 200005;

int64_t dp[maxn];
int cnt[26];

signed main () {
    string a;
    cin >> a;
    int n = a.size();
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i - 1];
        dp[i] += (i - 1) - cnt[a[i - 1] - 'a'];
        ++cnt[a[i - 1] - 'a'];
    }
    cout << dp[n] << '\n';
}


Measured memory_bytes: 2180
import sys

a, b = map(int, sys.stdin.readline().split())

canvas = [['#'] * 100 for _ in range(50)] + [['.'] * 100 for _ in range(50)]
a -= 1; b -= 1

def paint(color, cnt):
    if color == '.':
        i = j = 0
    else:
        i = 51; j = 0
    
    while cnt:
        canvas[i][j] = color
        cnt -= 1
        j += 2
        if j == 100:
            j = 0
            i += 2

def main(a, b):
    yield '100 100'

    paint('.', a)
    paint('#', b)

    for i in range(100):
        yield ''.join(canvas[i])

if __name__ == '__main__':
    ans = main(a, b)
    print(*ans, sep='\n')

Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val S = listOf(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)
    println(S[readLine()!!.toInt()-1])
}

Measured memory_bytes: 33740
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 1000

int n, L, P[MAX+1];

void compute(){
    vector<int> v;
    for ( int i = 0; i < n+1; i++ ){
	for ( int j = i; j < n+1; j++ ){
	    v.push_back(P[i] + P[j]);
	}
    }
    sort(v.begin(), v.end());
    int maxv = 0;

    for ( int i = 0; i < v.size(); i++ ){
	if ( v[i] > L ) break;
	int first = v[i];
	int target = L - v[i];
	
	int t = distance(v.begin(), upper_bound(v.begin(), v.end(), target));

	if ( v[t] + first <= L && maxv < v[t]+first ) maxv = v[t]+first;
	if ( t+1 < v.size() && v[t+1] + first <= L && maxv < v[t+1]+first ) maxv = v[t+1]+first;
	if ( t-1 >= 0 && v[t-1] + first <= L && maxv < v[t-1]+first ) maxv = v[t-1]+first;
    }

    cout << maxv << endl;
    

}

main(){
    while( cin >> n >> L && n ){
	P[0] = 0;
	for ( int i = 1; i <= n; i++ ) cin >> P[i];
	compute();
    }
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000
int main(){
	string sd,t,ins;cin>>sd>>t;
	ins=sd;

	int tsize=t.size(),sdsize=sd.size();
	bool changed=false;

	for(int i=sdsize-1;i>=tsize-1;i--){
		bool ok=true;
		for(int j=i;j>i-tsize;j--){//tsize個の文字が全て?かsd=tなるものであれば、そのtsize個とsdの部分列は置き換え可能
			if(sd[j]=='?' || sd[j]==t[tsize-1-(i-j)]) continue;
			ok=false;break;
		}
		
		if(ok){//置き換え可能な場合(一番後ろの方から見て)交換する
			for(int j=i;j>i-tsize;j--){
				sd[j]=t[tsize-1-(i-j)];
				changed=true;//置き換えした
			}
			break;
		}
	}

	
	if(sd==ins && !changed){cout<<"UNRESTORABLE"<<endl;return 0;}//置き換えがない場合->置き換え不可能

	for(int i=0;i<sdsize;i++){//辞書順で最小だから'a'で残りの?を埋める
		if(sd[i]=='?'){sd[i]='a';}
	}

	cout<<sd<<endl;
	return 0;
}

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

abcd=[]
for i in range(Q):
  abcd.append(list(map(int,input().split())))
  abcd[i][0]-=1
  abcd[i][1]-=1

  
def calcScore(target):
  score=0
  for i in range(Q):
    if target[abcd[i][1]]-target[abcd[i][0]]==abcd[i][2]:
      score+=abcd[i][3]
  return score

def makeTarget():
  list=[1]*N
  list[-1]=0
  while True:
    list[-1]+=1
    for i in range(len(list)):
      if list[-i-1]>M:
        if len(list)==i+1:return
        list[-i-2]+=1
        list[-i-1]=0
    for i in range(len(list)-1):
      if list[i]>list[i+1]:list[i+1]=list[i]
    yield list.copy()

ans=0
for i in makeTarget():
  ans=max(ans,calcScore(i))
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9;
typedef long long LL;
const LL MOD = 1e9+7;

int main() {
  string S;
  cin >> S;
  
  int a=0, b=0, c=0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == 'a') a++;
    else if (S[i] == 'b') b++;
    else c++;
  }
  
  string answer = "No";
  if (a == 1 && b == 1 && c == 1) answer = "Yes";

  cout << answer << endl;
  return 0;
}


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

int game(int n,int p,int *data){
	int i,p2;

	i = 0;
	p2 = p;

	while(1){
		if(p2 == 0){
			p2 += data[i];
			data[i] = 0;
		}else{
			p2--;
			data[i]++;
			if(data[i] == p){
				break;
			}
		}
		i = (i + 1) % n;
	}

	return i;
}

int main(){
	int p,n;
	int *data;

	while(1){
		scanf("%d %d",&n,&p);
		if(n == 0 && p == 0){
			break;
		}

		data = (int *)calloc(n,sizeof(int));

		printf("%d\n",game(n,p,data));
	}

	return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

static const int MAX = 200000;
static const int INFTY = (1<<21);

vector<int> M[MAX];
vector<int> blue;
vector<int> red;
int n;

void bfs(int s)
{
    int d[MAX];
    queue<int> q;
    int u;

    q.push(s);
    blue.push_back(s);
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
    }
    d[s] = 0;

    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int i = 0; i < M[u].size(); i++) {
            int v = M[u][i];
            if (d[v] != INFTY) continue;
            d[v] = d[u] + 1;
            if (d[v] % 2 == 0) {
                blue.push_back(v);
            } else {
                red.push_back(v);
            }
            q.push(v);
        }
    }
}

int main()
{
    int i;
    int a, b;

    cin >> n;

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

    bfs(0);

    {
        vector<int> ans(n);
        int k0 = 3;
        int k1 = 1;
        int k2 = 2;

        if (blue.size() > n / 3 && red.size() > n / 3) {
            for (i = 0; i < blue.size(); i++) {
                int v = blue[i];
                if (k1 <= n) {
                    ans[v] = k1; k1 += 3;
                } else {
                    ans[v] = k0; k0 += 3;
                }
            }
            for (i = 0; i < red.size(); i++) {
                int v = red[i];
                if (k2 <= n) {
                    ans[v] = k2; k2 += 3;
                } else {
                    ans[v] = k0; k0 += 3;
                }
            }
        } else if (red.size() <= n / 3) {
            for (i = 0; i < red.size(); i++) {
                int v = red[i];
                ans[v] = k0; k0 += 3;
            }
            for (i = 0; i < blue.size(); i++) {
                int v = blue[i];
                if (k1 <= n) {
                    ans[v] = k1; k1 += 3;
                } else if (k2 <= n) {
                    ans[v] = k2; k2 += 3;
                } else {
                    ans[v] = k0; k0 += 3;
                }
            }
        } else {
            for (i = 0; i < blue.size(); i++) {
                int v = blue[i];
                ans[v] = k0; k0 += 3;
            }
            for (i = 0; i < red.size(); i++) {
                int v = red[i];
                if (k1 <= n) {
                    ans[v] = k1; k1 += 3;
                } else if (k2 <= n) {
                    ans[v] = k2; k2 += 3;
                } else {
                    ans[v] = k0; k0 += 3;
                }
            }
        }

        for (auto itr = ans.begin(); itr != ans.end(); itr++) {
            if (itr != ans.begin()) cout << " ";
            cout << *itr;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 16372
for a,b,r,c,d,s in[map(float,raw_input().split())for i in range(input())]:
	d=((a-c)**2+(b-d)**2)**0.5
	if d>r+s:print 0
	elif d+min(r,s)>=max(r,s):print 1
	elif r>s:print 2
	else:print -2

Measured memory_bytes: 4284
#include<iostream>
using namespace std;
const long long INF = 1000000007;
int main () {
  int N;
  cin >> N;
  int co[200001];
  long long dp[200001];
  long long cs[200001];
  for (int i = 1; i <= N; i ++) cin >> co[i];
  co[0] = 0;
  dp[0] = 0;
  for (int i = 1; i < 200001; i ++) cs[i] = 0;
  cs[co[0]] = 1;
  for (int i = 1; i <= N; i ++) {
    if (co[i] != co[i - 1]) cs[co[i]] += cs[co[i - 1]];
    dp[i] = cs[co[i]];
    dp[i] = dp[i] % INF;
    cs[co[i]] = cs[co[i]] % INF;
  }
  cout << dp[N] << endl;
}



Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    edge = [[] for i in range(N)]
    for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

    def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
    x=dfs()
    for xi in x:
        if xi==1:
            print(0)
        else:
            print(1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 97332
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  int k, a, b;
  cin >> k >> a >> b;
  for(int i = a; i <= b; ++i) {
    if(i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    ll n,k;
    std::cin >> n >> k;

    ll ans = k*pow(k-1,n-1);
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int bs(int , vector<int> &);
int main(){
    vector<int> vec = {1};
    for (int penambah = 2 ; *rbegin(vec) < 64 ; penambah++)
        vec.push_back(*rbegin(vec) + penambah);
    long long N;
    int ans = 0;
    cin >> N;
    for (int i = 2 ; i <= sqrt(N) ; i++){
        if (N % i == 0){
            int frek = 0;
            while(!(N % i))
                ++frek , N /= i;
            ans += bs(frek , vec);
        }
    }
    if (N > 1)
        ans++;
    cout << ans << endl;
}
int bs(int cnt , vector<int> &vec){
    int l = 0 , r = vec.size() - 1;
    while(l <  r){
        int mid = ceil(double(l + r) / 2);
        if (vec[mid] <= cnt)
            l = mid;
        else
            r = mid - 1;
    }
    return l + 1;
}



Measured memory_bytes: 3696
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>

using namespace std;
typedef pair<double, double> P;

double helon(P p1, P p2, P p3)
{
	double a = sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
	double b = sqrt((p1.first - p3.first) * (p1.first - p3.first) + (p1.second - p3.second) * (p1.second - p3.second));
	double c = sqrt((p2.first - p3.first) * (p2.first - p3.first) + (p2.second - p3.second) * (p2.second - p3.second));
	double z = (a + b + c) / 2;
	return(sqrt(z * (z - a) * (z - b) * (z - c)));
}

void solve()
{
	vector<P> Vec;
	double x, y;
	while(scanf("%lf,%lf", &x, &y) != EOF)
	{
		Vec.push_back(make_pair(x, y));
	}
	double sum = 0;
	for(int i = 1; i < Vec.size() - 1; ++i)
	{
		sum += helon(Vec[0], Vec[i], Vec[i + 1]);
	}
	cout << sum << endl;
}

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

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

namespace AGC029E
{
    class Program
    {
        const int maxN = 200003;
        static int[] ans = new int[maxN];
        static List<int>[] vec = new List<int>[maxN];

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            {
                for (int i = 0; i < maxN; i++)
                {
                    vec[i] = new List<int>();
                    dp[i] = new Dictionary<int, int>();
                }
                for (int i = 0; i < N - 1; i++)
                {
                    var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    vec[input[0]].Add(input[1]);
                    vec[input[1]].Add(input[0]);
                }
            }
            foreach (int i in vec[1])
            {
                dfs(i, 1, 1, 0);
            }
            for (int i = 2; i <= N; i++) Console.Write("{0} ", ans[i]);

            Console.ReadKey();
        }

        static void dfs(int x, int ba, int pr, int cc)
        {
            cc += dfs2(x, ba, Math.Max(ba, pr));
            if (pr > x) cc -= dfs2(x, ba, pr);
            ans[x] = cc;
            foreach (int y in vec[x])
            {
                if (y == ba) continue;  //自分自身はスルー
                dfs(y, x, Math.Max(pr, ba), cc);
            }
        }

        static Dictionary<int, int>[] dp = new Dictionary<int, int>[maxN];
        static int dfs2(int x, int ba, int v)
        {
            if (dp[x].ContainsKey(v)) return dp[x][v];
            int sm = 1;
            foreach (int y in vec[x])
            {
                if (y == ba) continue;
                if (y < v) sm += dfs2(y, x, v);
            }
            return dp[x][v] = sm;
        }
    }
}


Measured memory_bytes: 109584
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};

int num_points;

typedef Point Vector;
typedef vector<Point> Polygon;

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -1;
static const int ON_SEGMENT = 0;

int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

Point calc_Cross_Point(double x1,double x2,double x3,double x4,double y1,double y2,double y3,double y4){
	Point ret;
	ret.x = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
	if(x1 != x2){
		ret.y = ((y2-y1)*ret.x+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
	}else{
		ret.y = ((y4-y3)*ret.x+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
	}
	return ret;
}

Point calc_Cross_Point(Point a,Point b,Point c,Point d){
	return calc_Cross_Point(a.x,b.x,c.x,d.x,a.y,b.y,c.y,d.y);
}

Polygon ConvexCut(Polygon g,Point a,Point b){

	Polygon ret;
	int N = g.size();

	for(int i = 0; i < g.size(); i++){
		Point A = g[i], B = g[(i+1)%N];
		if(ccw(a,b,A) != -1)ret.push_back(A);
		if(ccw(a,b,A)*ccw(a,b,B) == -1)ret.push_back(calc_Cross_Point(a,b,A,B));
	}

	return ret;
}

double calc_S(Polygon g){

	int N = g.size();
	double ret = 0;

	for(int i = 0; i < g.size(); i++){
		ret += cross(g[i],g[(i+1)%N]);
	}
	return ret/2.0;
}

Polygon g,ans;

void func(){

	g.clear();
	ans.clear();

	double x,y;

	for(int loop = 0; loop < num_points; loop++){
		scanf("%lf %lf",&x,&y);
		g.push_back(Point(x,y));
	}

	ans = g;

	Point a,b;
	int SIZE = g.size();

	for(int i = 0; i < g.size(); i++){
		a = g[i];
		b = g[(i+1)%SIZE];
		ans = ConvexCut(ans,a,b);
	}

	if(ans.size() == 0){
		printf("0\n");
	}else{
		printf("1\n");
	}
}

int main(){

	while(true){
		scanf("%d",&num_points);
		if(num_points == 0)break;

		func();
	}

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int a, b;
  cin >> a >> b;
  if((a*b)%2) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
}

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


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

int main(){
  int n, T;
  int c[110];
  int t[110];
  int cc[110];
  int check =0;
  cin >> n >> T;
  for(int i=0;i<n;i++){
    cin >> c[i] >> t[i];
  }

  for(int i =0;i<n;i++){
    if(t[i] <= T){
      cc[i] = c[i];
      check++;
    }
    else{
      cc[i] =0;
    }
  }
  sort(cc, cc+n);
  if(check > 0){
    for(int i=0;i<n;i++){
      if(cc[i] > 0){
        cout << cc[i] << endl;
    	break;
      }
    }
  }
  else if(check ==0){
    cout << "TLE" << endl;
  }

}

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

typedef pair<int, bool> P;

int main(){
    int n; cin>>n;
    for(int i=0; i<n; i++){
        string s; cin>>s;
        int m = s.size();

        int depth = 0;
        vector<vector<P>> v(10010);
        for(int j=0; j<m; j++){
            if(s[j] == '[') depth++;
            else if(s[j] == ']'){
                depth--;
                if(j + 1 < m && s[j+1] == ']'){
                    sort(v[depth].begin(), v[depth].end());
                    int sum = 0;
                    if(v[depth][0].second){
                        for(int k=0; k<v[depth].size()/2+1; k++){
                            sum += (v[depth][k].first + 1) / 2;
                        }
                    }
                    else{
                        for(int k=0; k<v[depth].size()/2+1; k++){
                            sum += v[depth][k].first;
                        }
                    }

                    v[depth].clear();
                    v[depth-1].emplace_back(sum, false);
                }
            }
            else{
                string t;
                t += s[j];
                while(j + 1 < m && '0' <= s[j+1] && s[j+1] <= '9'){
                    j++;
                    t += s[j];
                }

                int num = stoi(t);
                v[depth-1].emplace_back(num, true);
            }
        }

        cout << v[0][0].first << endl;
    }
}


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

using namespace std;



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

	int x, n; 
	cin >> x >> n;
	
	set<int> st;

	for(int i = 0; i < n; ++i) {
		int y; cin >> y;
		st.insert(y);
	}

	for(int i = 0; i < 1000; ++i) {
		if (!st.count(x - i)) {
			cout << x - i << '\n';
			return 0;
		}
		else if (!st.count(x + i)) {
			cout << x + i << '\n';
			return 0;
		}
	}

	assert(1 == 0);


	return 0;	
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


template <typename T>
class Lazy_Seg_Tree{
public: // 0-index
  // buketは区間変更の値  datは区間の答え
	T make_dat_from_buket(T da, T bu, T s){//dat[k] = make_dat_from_buket(dat[k],buket[k],r-l);
		return bu;
	}
	T buket_to_child(T ch, T pa){// buket[2*k+1] = buket_to_child(buket[2*k+1],buket[k]);
		return pa;
	}
	T buket_update(T bu , T x , T s){// buket[k] = buket_update(buket[k],x,r-l);
		return x;
	}
	T dat_update(T dc1, T dc2){// dat[k] = dat_update(dat[2*k+1],dat[2*k+2]);
		return min(dc1 , dc2);
	}

  vector<T> dat,buket;
  T initial_d,initial_b,M;
  int n;
  Lazy_Seg_Tree(int n0_=1,T initial_dat=1,T initial_buket=0 ,T M_=1){
    initsize(n0_,initial_dat,initial_buket,M_);
  }
  void initsize(int n0,T initial_da,T initial_bu,T M_){
    M = M_;
    initial_d = initial_da;
    initial_b = initial_bu;
    int k=1;
    while(k<n0)k*=2;
    n=k;
    dat.resize(2*n-1);
    buket.resize(2*n-1);
    for(int i=0;i<2*n-1;i++)dat[i]=initial_da;
    for(int i=0;i<2*n-1;i++)buket[i]=initial_bu;
  }
	
	void eval(int k,int l,int r){
		if(buket[k] != initial_b){
			dat[k] = make_dat_from_buket(dat[k],buket[k],r-l);
			if(r-l>1){
				buket[2*k+1] = buket_to_child(buket[2*k+1],buket[k]);
				buket[2*k+2] = buket_to_child(buket[2*k+2],buket[k]);
			}
			buket[k] = initial_b;
		}
	}

	void operate(int a,int b, T x, int k=0,int l=0, int r=-1){
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l || r<=a)return;
		if(a<=l && r<=b){
			buket[k] = buket_update(buket[k],x,r-l);
			eval(k,l,r);
		}else{
			operate(a,b,x,2*k+1,l,(l+r)/2);
			operate(a,b,x,2*k+2,(l+r)/2,r);
			dat[k] = dat_update(dat[2*k+1],dat[2*k+2]);
		}
	}
	T get(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0)r=n;
		if(b<=l || r<=a) return initial_d;
		eval(k,l,r);
		if(a<=l && r<=b) return dat[k];
		T vl = get(a,b,2*k+1,l,(l+r)/2);
		T vr = get(a,b,2*k+2,(l+r)/2,r);
		return dat_update(vl,vr);
	}
};



int main(){

	ll n,q;
	cin >> n >> q;
	Lazy_Seg_Tree<ll> sg(n,(1LL<<31)-1,(1LL<<31)-1,MOD);
	FOR(i,0,q){
		ll q_,s,t,x;
		cin >> q_;
		if(q_){
			cin >> s >> t;
			cout << sg.get(s,t+1,0,0,-1) << "\n";
		}else{
			cin >> s >> t >> x;
			sg.operate(s,t+1,x,0,0,-1);
		}
	}


}



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


using namespace std;



int main(void) {

	int n, m, c,sum=0,count=0;
	int b[100],a[100];

	cin >> n;
	cin >> m;
	cin >> c;

	for (int i = 0; i < m; i++) {
		cin>>b[i];
	}
	
	for (int j = 0; j < n; j++) {
		for (int k = 0; k < m; k++) {
			cin >> a[k];
			sum = sum + a[k] * b[k];
		}
		sum = sum + c;
		if (sum > 0) {
			count++;
		}
		sum = 0;
	}
	cout << count;

	return 0;

}

Measured memory_bytes: 256