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

using namespace std;

int main(int argc, char *argv[]) {
    int A, B, C;
    cin >> A >> B >> C;

    int64_t ans = 0;
    if (C <= A) {
        ans += C;  // 無毒
        ans += B;
    } else {
        ans += A + 1;  // 毒
        C = C - (A + 1); // C の枚数を減らす
        if (C > 0) {
            ans += (B + min(C, B));
        } else {
            ans += B;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int h, m;
  cin >> h >> m;
  int now = h * 60 + m;
  cin >> h >> m;
  int next = h * 60 + m;
  int k;
  cin >> k;
  cout << next - now - k << endl;
}

Measured memory_bytes: 3616
'use strict'

function main(s) {  
  
  const input = s.replace(/\n/g, '').split(' ').map(x => Number(x));
  var result = ((input[0] * input[1]) % 2) === 0 ? 'Even' : 'Odd';  
  console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, Q;
    cin >> N >> Q;
    dsu d(N);
    rep(i, Q){
        ll t, u, v;
        cin >> t >> u >> v;
        if(t == 0){
            d.merge(u, v);
        }
        else{
            if(d.same(u, v)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }
}

Measured memory_bytes: 4032
#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(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, A;
    cin >> N >> A;
    cout << N*N - A << endl;
    return 0;
}

Measured memory_bytes: 256
# ABC139E - League
from collections import deque


def main():
    N, *A = map(int, open(0).read().split())
    B = {}
    for i in range(N):
        x = i * (N - 1)
        B[i + 1] = deque(A[x : x + N - 1])
    ans, cnt, matched = 0, 0, set()
    q = [i for i in range(1, N + 1)]
    while q:
        ans += 1
        next_q = []
        for i in q:
            if i in B and i not in matched:
                x = B[i][0]
                if x in B and x not in matched and B[x][0] == i:
                    B[i].popleft(), B[x].popleft()
                    matched |= {i, x}
                    cnt += 1
                    if not B[i]:
                        del B[i]
                    else:
                        next_q += [i]
                    if not B[x]:
                        del B[x]
                    else:
                        next_q += [x]
        q = next_q
        matched = set()
    flg = cnt == N * (N - 1) // 2
    print(ans if flg else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 104244
#include <stdio.h>
#include <math.h>

typedef struct{ 
    double x,y;
}Point;
void koch(int, Point, Point);

int main() {
    Point a,b;
    int n;
    
    scanf("%d",&n);
    
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x, b.y);
    
    return 0;
}

void koch(int n, Point a, Point b){
    Point s,t,u;
    double th;
    if(n==0) return;
    th = M_PI * 60.0/180.0;
    
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1,t,b);
}

Measured memory_bytes: 640
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getList()

money = 1000
stock = 0
for i in range(N - 1):
    if A[i + 1] >= A[i]:
        stock += money // A[i]
        money -= (money // A[i]) * A[i]
    else:
        money += stock * A[i]
        stock = 0
money += A[-1] * stock
print(money)

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

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long min = long.MaxValue ;
            long squareRoot = (long)(Math.Sqrt(N));
            for (long i = 1; i <= squareRoot; i++)
            {
                if(N % i == 0)
                {
                    //Console.WriteLine(i + " " + N / i);
                    if(i + (N /i) - 2 < min)
                    {
                        min = i + (N / i) - 2;
                    }
                }
            }

            Console.WriteLine(min);
            //Console.ReadKey();
        }

    }
}


Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;


class Main{
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();
        int[] sub = new int[N];
        int[] arr = in.nextIntArray(N-1);

        for (int i = 0; i < N - 1; i++) {
            int x = arr[i] - 1;
            sub[x] = sub[x] + 1;
        }
        for (int x : sub) {
            System.out.println(x);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int size){
            int arr[] =new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = Integer.parseInt(next());
//                sum = sum + in.nextInt();
            }
            return arr;
        }

    }
}



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

int main() {
    int N; cin >> N;
    vector<int64_t> L(N);
    for(auto &e : L) cin >> e;
    int ans = 0;
    rep(i, N) for(int j = i + 1; j < N; ++j) for(int k = j + 1; k < N; ++k) {
        if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
        int64_t c = max({L[i], L[j], L[k]});
        int64_t ab = L[i] + L[j] + L[k] - c;
        if(ab > c) ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

#define int long long
#define MOD 1000000007
#define maxlen 9223372036854775807
#define minlen -9223372036854775807
#define fin(n) for(int i=0;i<n;i++)

int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
vector<int> primeFact(int n){vector<int> ans;for(int t=2;t<=sqrt(n);t++){if(n%t==0){ans.push_back(t);while(n%t==0){n=n/t;}}}if(n>2)ans.push_back(n);return ans;}
vector<int> fact(int n){vector<int> ans;for(int i=1;i<=sqrt(n);i++){if(n%i==0){if( i*i == n ){ans.push_back(i);}else{ans.push_back(i);ans.push_back(n/i);}}}return ans;}
int powerr(int base,int exp,int mod) { if(exp==0)return 1;int t = powerr(base,exp/2,mod)%mod;if(exp%2==0){return (t%mod*t%mod)%mod;}else{return (t%mod*t%mod*base%mod)%mod;}} 
void fastio(){ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}



int32_t main(){
	fastio();

	int a,b,n;
	cin >> a >> b >> n;

	int f = min(b-1,n);

	int ans = (a*f)/b - a*(f/b);

	cout << ans << "\n";

	

	return 0;
}






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

using namespace std;
static const int MAX = 1000;

void trace(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

int main() {
    int n, a[MAX];
    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i];
    trace(a, n);
    int k;
    for (int i = 1; i < n; i++) {
        k = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > k) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = k;
        trace(a, n);
    }
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(max(a + b, a - b), a * b) << endl;
  return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
   string s,t;
   cin>>s>>t;

   int cnt=0;
   rep(i,3) if(s[i]==t[i]) cnt++;
   
   cout<<cnt<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main() {
	int n, m;
	map<string, int> ma1, ma2;
	set<string> se;
	cin >> n;
	rep(i, n) {
		string t; cin >> t;
		se.insert(t);
		ma1[t]++;
	}
	cin >> m;
	rep(i, m) {
		string t; cin >> t;
		se.insert(t);
		ma2[t]++;
	}

	int ans = 0;
	for(auto u : se) {
		chmax(ans, ma1[u] - ma2[u]);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

const int MAXN = 25;

int c[MAXN], v[MAXN], w[MAXN];

int n;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    for (int i = 1; i <= n; i++)
        cin >> c[i];
    for (int i = 1; i <= n; i++)
        w[i] = v[i] - c[i];
    int res = 0;
    sort(w + 1, w + n + 1);
    for (int i = n, sum = 0; i > 0; i--)
    {
        sum += w[i];
        if (sum > res)
            res = sum;
    }
    cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double pi = 3.1415926535;
  double rad2deg = pi / 180.0;
  
  double short_angle = (h * 60 + m) * 0.5;
  if (short_angle == 0) short_angle = 360;
  double long_angle = m * 6;
  if (long_angle == 0) long_angle = 360;

  if (short_angle == long_angle)
  {
    cout << abs(a - b) << endl;
    return 0;
  }
  
  double angle_diff = long_angle > short_angle ? long_angle - short_angle : short_angle - long_angle;
  
  cout << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(angle_diff * rad2deg) ) << endl;  
  return 0;
}

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

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		vector<unsigned long long int> Vec(N);
		for(int i = 0; i < N; ++i)
		{
			cin >> Vec[i];
		}
		sort(Vec.begin(), Vec.end());
		unsigned long long int sum = 0;
		unsigned long long int time = 0;
		for(int i = 0; i < N - 1; ++i)
		{
			time += Vec[i];
			sum += time;
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 0
cnt = 0
while True:
  a, b = map(int, input().split())
  if a + b == 0:
    break
  flag = True
  if cnt != 0:
    print()
  for i in range(a, b + 1):
    if i % 4 == 0:
      if i % 100 == 0:
        if i % 400 == 0:
          flag = False
          print(i)
      else:
        flag = False
        print(i)
  if flag == True:
    print("NA")
  cnt += 1


Measured memory_bytes: 5720
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int A, B; cin >> A >> B;
	if (A <= 9 && B <= 9) cout << A * B << endl;
	else cout << "-1" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k,t;
    vector<int> l;
    cin >> n >> k;
    
    for(ll i = 0;i<n;i++){
        cin >> t;
        l.push_back(t);
    }
    sort(all(l),greater<int>());
    
    int a;
    for(ll i=0;i<min(n,k);i++) a += l.at(i);
    cout << a << "\n";
    
    
    return 0;
}

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

int main() {
	int a,b,c;cin>>a>>b>>c;
	int ans=0;
	while(1){
		if(a%2+b%2+c%2)break;
		int min=a;
		if(a>b)min=b;
		if(min>c)min=c;
		a-=min;
		b-=min;
		c-=min;
		int sum=a+b+c;
		if(sum==0){
			ans=-1;
			break;
		}
		a=(sum-a)/2;
		b=(sum-b)/2;
		c=(sum-c)/2;
		ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n %= 1000;
        if(n==0||n==1000) {
            System.out.println(0);
        }
        else{
            System.out.println(1000-n);
        }
    }
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+5, mod = 1e9+7;

void solve() {
    int r, g, b; cin >> r >> g >> b;
    int k; cin >> k;

    while (k) {
        if (g <= r) {
            g *= 2;
            --k;
        } else if (b <= g) {
            b *= 2;
            --k;
        }
        if (g > r && b > g) {
            break;
        }
    }

    if (g > r && b > g) {
        cout << "Yes\n"; 
    } else {
        cout << "No\n";
    }
    
}

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


Measured memory_bytes: 3648
#!/usr/bin/env perl
use 5.10.0;
use utf8;
use strict;
use warnings;
use open qw( :utf8 :std );
use Data::Dumper;

chomp( my $in = do { local $/; <> } );

my %is = (
    "AAA" => 0,
    "AAB" => 1,
    "ABA" => 1,
    "ABB" => 1,
    "BAA" => 1,
    "BAB" => 1,
    "BBA" => 1,
    "BBB" => 0,
);

say $is{ $in } ? "Yes" : "No";


exit;



Measured memory_bytes: 2048
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
step = sum(B) - sum(A)
if step < 0:
    print('No')
    exit()

a_cnt = 0
b_cnt = 0

for a, b in zip(A, B):
    tmp = a - b
    if tmp > 0:
        b_cnt += tmp
    elif tmp < 0:
        tmp = abs(tmp)
        if tmp % 2 == 0:
            a_cnt += tmp // 2
        else:
            a_cnt += tmp // 2 + 1
            b_cnt += 1
if step >= a_cnt >= b_cnt:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10580
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int n = sc.nextInt();

		int ans = n;
		if (n % 2 == 1) {
			ans*= 2;
		}

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define CHAL_BC_APNE_BAAP_KO_MAT_SIKHA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fr first
#define se second
#define mod 1000000007
signed main()
{
	CHAL_BC_APNE_BAAP_KO_MAT_SIKHA;		
	int n,m;
	cin>>n>>m;
	if(m<n){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 28;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// d[u][v]は辺e = (u, v)のコスト（存在しない場合はINF、ただしd[i][i] = 0とする。）
// Vは頂点数
void warshall_floyd(vector<vector<int>> &d, int V)
{
    for (int k = 0; k < V; k++)
    {
        for (int i = 0; i < V; i++)
        {
            for (int j = 0; j < V; j++)
            {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<vector<int>> d(n,vector<int>(n,INF));
    for(int i=0;i<n;i++){
        d[i][i]=0;
    }
    vector<int> a(m),b(m),c(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }
    warshall_floyd(d,n);
    int ans=0;
    for(int i=0;i<m;i++){
        if(c[i] > d[a[i]][b[i]]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int h[n];
    for(long long int i=0;i<n;++i)
    {
        cin>>h[i];
    }
    sort(h,h+n,greater<int>());
    long long int s=0;
    for(long long int i=k;i<n;++i)
    {
        s=s+h[i];
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cctype>
using namespace std;
typedef long long ll;
inline ll read() {
	char ch = getchar(); ll x = 0; int op = 1;
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') op = -1;
	for(; isdigit(ch); ch = getchar()) x = x*10+ch-'0';
	return x*op;
}
inline void write(ll a) {
	if(a < 0) putchar('-'), a = -a;
	if(a >= 10) write(a/10); putchar('0'+a%10);
}
const int N = 110;
const double pi = acos(-1);
int n;
double x[N], y[N];
int main() {
	n = read();
	for(int i = 1; i <= n; i ++) scanf("%lf%lf", &x[i], &y[i]);
	for(int i = 1; i <= n; i ++) {
		double l0 = -pi, r0 = 0, l1 = 0, r1 = pi, a;
		for(int j = 1; j <= n; j ++) if(i != j) {
			a = atan2(x[j]-x[i], -(y[j]-y[i]));
			if(a >= 0) {
				l1 = max(l1, a); r0 = min(r0, a-pi);
			} else {
				l0 = max(l0, a); r1 = min(r1, a+pi);
			}
		}
		printf("%.10lf\n", (max(0.0, r0-l0)+max(0.0, r1-l1))/2/pi);
	}
	return 0;
}

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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	if( n == 1 ) cout << "Hello World" << endl;
	
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	
	return 0;
}


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

int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

  vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(2, vector<int>(t + 3001)));
  for (int i = 0; i < n; i++) {
    for (int f = 0; f < 2; f++) {
      for (int w = 0; w < t; w++) {
        dp[i + 1][f][w] = max(dp[i + 1][f][w], dp[i][f][w]);
        dp[i + 1][f][w + a[i]] = max(dp[i + 1][f][w + a[i]], dp[i][f][w] + b[i]);
        if (!f) dp[i + 1][1][w] = max(dp[i + 1][1][w], dp[i][0][w] + b[i]);
      }
    }
  }
  cout << *max_element(dp[n][1].begin(), dp[n][1].begin() + t) << endl;
}


Measured memory_bytes: 141312
#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() {
    int n,k,d;
    cin >> n >> k;
    vector<int> v;
    for(int i=1;i<=n;i++) v.push_back(i);
    rep(i,k){
        cin >> d;
        int a;
        rep(j,d){
            cin >> a;
            auto itr = find(v.begin(),v.end(),a);
            if(itr!=v.end()){
                v.erase(itr);
            }
        }
    }
    cout << v.size() << endl;
    return 0;
}


Measured memory_bytes: 3636
n = input()
n = int(n)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
memo = -1
ans = 0
count = -1
for ai in a:
    ans += b[ai - 1]
    if ai - 1 == memo:
        ans += c[ai - 2]
    memo = ai
    count += 1
print(ans)

Measured memory_bytes: 3064
n,m = map(int,input().split())
x = [0]*(n+1)
t = [0]*(n+1)
p=q=0
for i in range(m):
  k,l = input().split()
  y=int(k)-1
  if x[y]==0:
    if l=='WA':
      t[y]+=1
    else:
      q+=t[y]
      p+=1
      x[y]=1
print(p,q)

Measured memory_bytes: 4596
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<map>
#include<stack>
#include<string>
#include<set>
using namespace std;
int main(){
	int a, b, c;
	int k;
	cin >> a >> b >> c >> k;
	int num = 0;
	while (b <= a) { b *= 2;num++; }
	while (c <= b) { c *= 2;num++; }
	if (num <= k)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
  vector<int64_t> fib(100010);
  fib.at(0)=fib.at(1)=fib.at(2)=1;
  for(int i=3; i<100010; i++){
    fib.at(i)=fib.at(i-1)+fib.at(i-2);
    fib.at(i)%=1000000007;
  }
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> A(M);
  for(int64_t i=0; i<M; i++){
    cin >> A.at(i);
  }
  if(M==0){
    cout << fib.at(N+1)%1000000007 << endl;
    goto finish;
  }
  else{
    int64_t Ans=fib.at(A.at(0));
    for(int64_t i=1LL; i<M; i++){
      if(A.at(i)-A.at(i-1)==1){
        Ans=0;
        break;
      }
      else{
        Ans*=fib.at(A.at(i)-A.at(i-1)-1)%1000000007;
        Ans%=1000000007;
      }
    }
    if(N-A.at(M-1)==0){
      Ans=0;
    }
    else{
      Ans*=fib.at(N-A.at(M-1));
      Ans%=1000000007;
    }
    cout << Ans << endl;
  }
  finish: N=0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define FOR(i,s,n) for(int i=s;i<n;i++)
#define ROF(i,n,e) for(int i=n;i>e;i--)
#define mod 1e9+7
#define MAX 1000005    //10^5+5
#define MAXQ 200005    //2*10^5+5
#define pi pair<int,int>
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define ll long long
#define f first
#define s second
#define sz(container) container.size()
typedef pair<int,int> pii;
typedef pair<int,pii> node;

inline ll modExp(ll a,ll b,ll m=mod){
	ll res=1;
	a%=m;
	while(b>=1){
		if(b%2!=0){
			res=(res%m*a%m)%m;
		}
		a=(a%m*a%m)%m;
		b=b/2;
	}
	return res;
}
bool isPrime(int x){
	if(x<=1){
		return false;
	}
	if(x==2||x==3){
		return true;
	}
	if(x%2==0){
		return false;
	}
	for(int i=3;i<=sqrt(x);i+=2){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x;
    cin>>x;
    while(!isPrime(x)){
    	x++;
    }
    cout<<x<<"\n";
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K <= A) cout << K << endl;
  else if(K <= A + B) cout << A << endl;
  else cout << A - (K - A - B) << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
using namespace std;

/*
long long factorial(long long x) {
    if (x > 1) {
        return factorial(x - 1) * x;
    } else {
        return 1;
    }
}
*/

int main() {
    int n;
    cin >> n;
    
    int mod = pow(10, 9) + 7;
    long ret = 1;
    for (int i = 1; i <= n; i++) {
        ret = ret * i;
        ret = ret % mod;
    }
    cout << ret << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e;
    int A,B;
    cin >> a>>b>>c>>d>>e;
    
    if(b%d==0) A=d/b;
    else A=b/d+1;
    
    if(c%e==0) B=c/e;
    else B=c/e+1;
    
    if(A==B) cout <<a-A <<endl;
    else if(A>B) cout <<a-A <<endl;
    else cout << a-B  <<endl;
}


Measured memory_bytes: 3100
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define BUF_SIZE 200010
unsigned long long ans = 0;
unsigned long long count = 0;
char s[BUF_SIZE];
char *r;
int i;

int main(void){
    fgets(s, BUF_SIZE, stdin);
    for(i=0; i<BUF_SIZE; i++) {
        if( s[i] == '\n' || s[i] == '\0') {
            break;
        }
        if( s[i] == 'B') {
            count++;
        } else {
            ans += count;
        }
    }
    printf("%llu",ans);
}


Measured memory_bytes: 384
import java.util.*;
import java.lang.*;

public class Main {
    
    static int ab;
    static int bc;
    static int ca;
    
    public static void main (String args[]) {
        int ans = 0;

        Scanner sc = new Scanner(System.in);
        ab = sc.nextInt();
        bc = sc.nextInt();
        ca = sc.nextInt();
        
        ans = ab * bc / 2;

        System.out.println(ans);
    }
    

}


Measured memory_bytes: 23380
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

let N = readInt()!
var answer = 0
for C in stride(from: 3, to: N+1, by: 2) {
    var num_of_divisors = 0
    for X in 3..<C {
        if C % X == 0 {
            num_of_divisors += 1
        }
    }
    if num_of_divisors == 6 {
        answer += 1
    }
}
print(answer)

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

#define  ll  unsigned long long
#define  pii pair<int,int>
#define  pll pair<ll , ll>
#define  debug cout << "this far" << endl;
#define  For(i, n) for(int i = 0; i < (n); ++i)
#define  lsb(x) ((x) & (-x))
#define  PI acos(-1)
#define  line cout << endl;
#define  getbit(n, i) (((n) & (1LL << (i))) != 0)
#define  resetbit(n, i) ((n) & (~(1LL << (i))))
#define  setbit(n, i) ((n) | (1LL << (i)))
#define  togglebit(n, i) ((n) ^ (1LL << (i)))
//#define  ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//using namespace __gnu_pbds;
using namespace std;
const int N = 1e5 + 4;
const int mod = 1e9 + 7 ;
ll dp[N][13] ;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string  s ; cin >> s;
    dp[0][0]  =  1 ;
    int n = s.length() ;
    for(int i = 0 ; i  < n ; ++ i   ) {
        int crval = s[i] == '?' ? -1  : s[i] - '0' ;
        for(int j = 0 ; j < 10 ; ++j ) {
            if(crval != -1 && j != crval) continue;
            for(int k = 0 ; k < 13 ; ++k)
                dp[i+1][(k * 10 + j) % 13] = (dp[i+1][(k * 10 + j) % 13] % mod +  dp[i][k] % mod ) % mod  ;
        }

    }
    cout << dp[n][5] ;

}

Measured memory_bytes: 13928
#include<stdio.h>
int main(){
  int a,b,c,i,tmp;

  scanf("%d %d %d",&a,&b,&c);
  for(i=0;i<3;i++){
    if(a > b){
      tmp = a;
      a = b;
      b = tmp;
    }
    else if(b > c){
      tmp = b;
      b = c;
      c = tmp;
    }
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}



Measured memory_bytes: 2128
#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;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;

    vector<lli> v;

    while (n > 0) {
        lli rem = n % 26;
        if (rem == 0) {
            rem = 26;
        }
        v.pb(rem);
        n /= 26;
        if (rem == 26) {
            n--;
        }
    }

    reverse(all(v));

    string ans;
    for (lli i = 0; i < v.size(); i++) {
        char ch = (char)((v[i] - 1) + 'a');
        ans += ch;
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3672
import std.stdio;
import std.string;

string raw = "**=*****";
char[9][9] ch;

void main(){
	bool f = true;
	string s;
	while ((s = chomp(readln())), s) {
		if (f) f = false;
		else writeln();

		foreach (i; 0..5) set(0,i);
		for (int i = 0; i < s.length; i++) set(s[i] - '0', i+5-cast(int)s.length);
		for (int y = 0; y < 8; y++) {
			for (int x = 0; x < 5; x++) {
				write(ch[y][x]);
			}
			writeln();
		}
	}
}

void set(int n, int p){
	foreach (i; 0..8) ch[i][p] = raw[i];
	if (n < 5) {
		ch[1][p] = ' ';
	}else {
		ch[0][p] = ' ';
		n -= 5;
	}
	ch[n+3][p] = ' ';
}

Measured memory_bytes: 956
n,m = list(map(int, input().split()))
H = list(map(int, input().split()))
lst = [1 for i in range(n)]

for i in range(m):
    a,b = list(map(int, input().split()))
    if H[a-1]>H[b-1]:
        lst[b-1] = 0
    elif H[a-1]<H[b-1]:
        lst[a-1] = 0
    else:
        lst[a-1] = 0
        lst[b-1] = 0

print(sum(lst))


Measured memory_bytes: 20012
///Bismi Allahi arrahmani arraheem

///author : I_HAVE_NO_LOGIC
///6.26.2020

#include<bits/stdc++.h>
#define cy cout << "Yes" << endl;
#define cn cout << "No" << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){

 int a,b,c,d,e;
 cin >> a;
 cout << a+a*a+a*a*a << endl;





}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

#define EPS (1e-10)
#define equals (fabs((a)-(b)<EPS)
int n;

struct Point
{
    double x, y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator -(Point a)
    {
        return Point(x-a.x,y-a.y);
    }
    double norm()
    {
        return x*x+y*y;
    }
};
double cross(Point a,Point b)
{
    return a.x*b.y-b.x*a.y;
}
double dot(Point a,Point b)
{
    return a.x*b.x+a.y*b.y;
}
Point p0,p1,p2,p3;
int ccw(Point p0,Point p1,Point p2)
{
    Point a=p1-p0;
    Point b=p2-p0;
    if(cross(a,b)>EPS) return 1;
    if(cross(a,b)<-EPS) return -1;
    if(dot(a,b)<-EPS) return 2;
    if(a.norm()<b.norm()) return -2;

    return 0;
}
void solve()
{
   if(ccw(p0,p1,p2)*ccw(p0,p1,p3)<=0&&ccw(p2,p3,p0)*ccw(p2,p3,p1)<=0) printf("1\n");
   else printf("0\n");
}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p0.x,&p0.y,&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y);
        solve();
    }

    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int a,b;
  cin>>a>>b;
  while(a!=0 && b!=0){
    rep(i,a){
      rep(j,b){
        if(i%2==0){
          if(j%2==0){cout << "#";}
          else{cout << ".";}          
          }
        else{
          if(j%2==1){cout << "#";}
          else{cout << ".";}
        }
      }
      cout << endl;
    }
    cout << endl;
    cin>>a>>b;
  }
}


Measured memory_bytes: 3096
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
from operator import itemgetter
n=int(input())
lx=[]
ly=[]
XY = [[i] + [int(x) for x in input().split()] for i in range(n)]
edge = set()
for key in [itemgetter(1),itemgetter(2)]:
    XY.sort(key = key)
    for i in range(n-1):
        i1,x1,y1 = XY[i]
        i2,x2,y2 = XY[i+1]
        d = min(abs(x1-x2),abs(y1-y2))
        edge.add((i1,i2,d))

row,col,value = zip(*edge)
value = np.array(value,dtype=int)
graph = csr_matrix((value,(row,col)),shape=(n,n))

tree = minimum_spanning_tree(graph,overwrite = True).astype(int)
print(tree.sum())


Measured memory_bytes: 91088
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long


int main(){
  string s;
  cin >> s;
  int n=0;
  ll ans = 0;
  int i=0;
  while(i<s.size()){
    if(s[i] == '<'){
      n=0;
      while(s[i] == '<'){
        n++;
        ans += n;
        i++;
        if(i >= s.size()){
          break;
        }
      }
    }else{
      int N=0;
      while(s[i] == '>'){
        N++;
        ans += N;
        i++;
        if(i >= s.size()){
          break;
        }
      }
      ans -= min(n, N);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 900
import Control.Monad
import Data.Maybe (fromJust)
import Data.List
import Data.Char

solve :: Int -> Int -> Int -> String
solve a b c
    | a + b == c = "Yes"
    | a + c == b = "Yes"
    | b + c == a = "Yes"
    | otherwise = "No"

main :: IO ()
main = do
    [a,b,c] <- map (read) . words <$> getLine :: IO [Int]
    putStrLn $ solve a b c


Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a_1(int a) {//素数判定
	int x = 0;
	for (int i = 2; i < a; i++) {
		if (a % i == 0)x++;
	}
	if (x == 0) {
		return 0;//素数であるとき
	}
	if (x != 0) {
		return 1;//素数でないとき
	}
}
int gcd(int a, int b) {
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
int main() {
	int n, a = 0, b = 0, c = 0, d = 0;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC")a++;
		else if (s == "WA")b++;
		else if (s == "TLE")c++;
		else if (s == "RE")d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c<< endl;
	cout << "RE x " << d << endl;
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>

using namespace std;

int main(void) {
    int n, m, c;
    cin >> n;
    cin >> m;
    cin >> c;
    vector<int> b(m);
    for(int i = 0 ; i < m ; ++i) {
        cin >> b[i];
    }
    int ans = 0;
    for(int j = 0 ; j < n ; ++j) {
        int spec = c;
        for(int i = 0 ; i < m ; ++i) {
            int a;
            cin >> a;
            spec += a * b[i];
        }
        if (spec > 0) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections

def solve(N: int, S: str):
    counter = collections.defaultdict(int)
    for s in S:
        counter[s] += 1
    result = 1
    for k, v in counter.items():
        result *= v
    if len(counter) < 3:
        result = 0

    notcounter = 0
    for i in range(N):
        for j in range(i+1, N):
            diff = j - i
            if j + diff >= N:
                break
            if (S[i]!=S[j]) and (S[j]!=S[j+diff]) and (S[i]!=S[j+diff]):
                notcounter += 1
    print(result - notcounter)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9420
#include <iostream>
#include <vector>
using namespace std;
const int INF = (1e9);
int dx[] = {1,1,0,-1,-1,0}, dy[] = {0,1,1,0,-1,-1};

void dfs(vector< vector<int> > &S, int x, int y){
  int ret = 0, c = S[x][y], N = S.size();
  S[x][y] *= -1;
  for(int i = 0; i < 6; ++i){
    int x_ = x + dx[i], y_ = y + dy[i];
    if(x_ < 0 || x_ < y_ || y_ < 0 || x_ >= N || y_ >= N) continue;
    if(S[x_][y_] == c) dfs(S,x_,y_);
  }
}

int calc_score(vector< vector<int> > S, int c){
  int N = S.size(), ret = 0;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < i+1; ++j){
      if(!S[i][j]){
        //cout << i << " " << j << endl;
        for(int k = 0; k < 6; ++k){
          int x_ = i + dx[k], y_ = j + dy[k];
          //cout << x_ << " " << y_ << endl;
          if(x_ < 0 || y_ < 0 || x_ >= N || y_ >= N) continue;
          if(S[x_][y_] > 0){
            //cout << x_ << " " << y_ << endl;
            dfs(S,x_,y_);
          }
        }
      }
    }
  }
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < i+1; ++j){
      //cout << S[i][j] << " ";
      if(S[i][j] == c) ret -= 2;
      if(S[i][j] > 0) ++ret;
    }//cout << endl;
  }
  return ret;
}

int main(){
  int N, C;
  while(cin >> N >> C, N){
    vector< vector<int> > S(N, vector<int>(N,-10));
    for(int i = 0; i < N; ++i)
      for(int j = 0; j < i+1; ++j)
        cin >> S[i][j];
    int ans = -INF;
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < i+1; ++j){
        if(!S[i][j]){
          S[i][j] = C;
          //cout << calc_score(S,C) << endl;
          ans = max(ans, calc_score(S,C));
          S[i][j] = 0;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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

int main(void){
    char c;
    cin >> c;
    switch(c){
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
            break;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> void printv(vector<T> v){ for (T t : v) {cout << t << " " ;} cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;


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

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

    int H, W;
    cin >> H >> W;

    vector<string> v;
    REP(i,H){
        string s;
        cin >> s;
        v.emplace_back(s);
    }

    vvi x_num(H,vi(W,0));
    vvi y_num(H,vi(W,0));
    REP(y,H) {
        if (v[y][0] != '#') x_num[y][0] = 1;
        REP(x,W-1) if (v[y][x+1] != '#') x_num[y][x+1] = x_num[y][x] + 1;
    }

    REP(y,H) RREP(x,W-1) {
        if (x-1 >= 0) if (x_num[y][x] != 0 and x_num[y][x-1]) x_num[y][x-1] = x_num[y][x];
    }
    

    REP(x,W) {
        if (v[0][x] != '#') y_num[0][x] = 1;
        REP(y,H-1) if (v[y+1][x] != '#') y_num[y+1][x] = y_num[y][x] + 1;
    }

    REP(x,W) RREP(y,H-1) {
        if (y-1 >= 0) if (y_num[y][x] != 0 and x_num[y-1][x]) y_num[y-1][x] = y_num[y][x];
    }



    // REP(y,H) {
    //     REP(x,W){
    //         cout << x_num[y][x] << " " ;
    //     } 
    //     cout << endl;
    // } cout << endl;

    // REP(y,H) {
    //     REP(x,W){
    //         cout << y_num[y][x] << " " ;
    //     } 
    //     cout << endl;
    // } cout << endl;
 
    int ans = 0;
    REP(x,W) REP(y,H){
        ans = max(ans,x_num[y][x] + y_num[y][x] - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35968
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxn=2e5+10;
int n,a[maxn],stk[maxn],top,l[maxn],r[maxn];
long long ans;

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i){
		while(top&&a[stk[top-1]]>a[i])
			r[stk[--top]]=i-1;
		if(!top)
			l[i]=1;
		else
			l[i]=stk[top-1]+1;
		stk[top++]=i;
	}
	for(int i=0;i<top;++i)
		r[stk[i]]=n;
	for(int i=1;i<=n;++i)
		ans+=(long long)(r[i]-i+1)*(i-l[i]+1)*a[i];
	cout<<ans<<endl;
	return 0;
}

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

int curx = 0, cury = 0, curtime = 0;
int n;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x, y, t;
		scanf("%d%d%d", &t, &x, &y);
		int d = abs(x-curx)+abs(y-cury);
		if (d > t-curtime || ((t-curtime)-d)%2 == 1) {
			puts("No");
			return 0;
		}
		curx = x, cury = y, curtime = t;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws IOException{
               BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));	
		int N = Integer.parseInt(reader.readLine());
		int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		Arrays.sort(list);
		int cnt = 0;
		int[] Seive_mod = new int[list[N-1]+1];
		for(int i=0;i<N;i++){
			for(int j = list[i];j<Seive_mod.length;j=j+list[i]){
				Seive_mod[j]+=1;
			}	
		}
		for(int i = 0;i<N;i++){
			if(Seive_mod[list[i]]==1) cnt++;
		}
		System.out.println(cnt);		
	}
}


Measured memory_bytes: 64600
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int, input().split()))
answer = 0
mod = 10**9 + 7
LCM = lcm(*A)

for i in range(N):
    answer += LCM // A[i]

print(answer % mod)

Measured memory_bytes: 6136
#include <iostream>
#include <ctime>
using namespace std;

int N,M;
void solve()
{
    cin >> N >> M;
    int X = 1900 * M + 100 * (N-M);
    while (M > 0){
        X *= 2;
        --M;
    }
    cout << X << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3592
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

def time(m):
    c, s, f = csf[m-1]
    depart_next = s
    arrive_next = s+c
    while m < n-1:
        nc, ns, nf = csf[m]
        i = 0
        while ns + nf*i < arrive_next:
            i += 1
        depart_next = ns + nf*i
        arrive_next = depart_next + nc
        m += 1
    return arrive_next


for i in range(1, n):
    print(time(i))
print(0)


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

int main() {
    int a, b, c, d;  cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
}

Measured memory_bytes: 256