akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        double r=in.nextDouble();
        System.out.println(String.format("%.6f %.6f",r*r*Math.PI,Math.PI*r*2));
    }
}


Measured memory_bytes: 28308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    string s,t;
    cin >> s >> t;
    bool can = true;
    for (int i=0;i<t.size()-1;i++){
        if(s.at(i)!=t.at(i)) can = false;
    }
    if(s.size()+1!=t.size()) can = false;
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

auto& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
auto& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;} 
 
namespace std{
    bool operator <  (const P& a,const P& b){ return sgn(real(a-b))?real(a-b)<0:sgn(imag(a-b))<0;}
    bool operator == (const P& a,const P& b){ return sgn(real(a-b))==0 && sgn(imag(a-b))==0;}
}

bool operator <  (const C& a,const C& b){ return a.c==b.c?sgn(a.r-b.r)<0:a.c<b.c;}
bool operator == (const C& a,const C& b){ return a.c==b.c&&sgn(a.r-b.r)==0;}

// Circle // verified: AOJ 1183
enum RCC{OUT=2,ON_OUT=1,ISC=0,ON_IN=-1,IN=-2};
int rcc(C a,C b){ R d=abs(a.c-b.c);return sgn(d-a.r-b.r)+sgn(d-abs(a.r-b.r));}

VP contact(C a,C b){
	VP ret; 
	P d=b.c-a.c;
	for(int i:{-1,1})if(rcc(a,b)>=i) for(P s:{-1i,1i}){
		R r=a.r+i*b.r;
		ret.emplace_back(a.c+a.r*(r+sq(norm(d)-norm(r))*s)*d/norm(d));
	}
	uniq(ret);
	return ret;
}

int main(void){
	C c1,c2;
	cin >> c1.c >> c1.r >> c2.c >> c2.r;
	VP res=contact(c1,c2);
	cout.precision(20);
	for(auto &p:res) cout << fixed << p << endl;
	return 0;
}

Measured memory_bytes: 3284
#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() {
    char a,b;
    cin >> a >> b;
    if(a < b)cout << "<" <<endl;
    else if(a == b)cout << "=" << endl;
    else cout << ">" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
//it gives the lexicographically smallest string//

void solve()
{
	int t=1;
	//cin>>t;
	while(t--)
    {
       ll n,d,count=0;
       cin>>n>>d;
       while(n--)
       {
       	ll d1,d2;
       	cin>>d1>>d2;
       	if(sqrt(d1*d1+d2*d2)<=d) count++;
       }
       cout<<count;
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	solve();
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int k;
priority_queue<ll, vector<ll>, greater<ll>> que;

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

    cin >> k;
    if(k <= 12){
        cout << k << endl;
        return 0;
    }
    for(int i = 1; i <= 9; ++i) que.push(i);
    int cnt = 0;
    int digit = 2;
    while(cnt < k - 1){
        ll foo = que.top();
        que.pop();
        ++cnt;
        int bar = foo % 10;
        foo *= 10;
        if(bar - 1 >= 0)    que.push(foo + bar - 1);
        que.push(foo + bar);
        if(bar + 1 <= 9)    que.push(foo + bar + 1);
    }
    cout << que.top() << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

typedef struct{
  ll b,l,u;
}T;
ll N,X;

bool comp(T& l, T& r){
  return X*l.u - l.b*(l.u-l.l) > X*r.u - r.b*(r.u-r.l);
}

int main(void){
  cin >> N >> X;
  vector<T> v(N);
  ll A = 0,B = 0;

  int i;REP(i,N){
    cin >> v[i].b >> v[i].l >> v[i].u;
    B += v[i].b * v[i].l;
  }
  //X取った時にBのとるポイント(b*c)との差が大きい順にソート
  sort(v.begin(),v.end(),comp);

  //貪欲に取って行った時に初めて超えるインデックス
  int index = 0;

  REP(i,N){
    A += X*v[i].u;
    B += v[i].b*(v[i].u - v[i].l);
    if(A  >= B ){
      index = i;
      break;
    }
  }

  ll minimum = X;
  REP(i,N){
    int j = min(index,i);
    ll remain = (B - v[j].b*(v[j].u - v[j].l) ) - (A - X*v[j].u);
    ll s,e,c;
    if(v[i].b*v[i].l < remain){
      remain += v[i].b*(v[i].u - v[i].l);
      s = v[i].b;
      e = X;
      c = v[i].u;
    }else{
      s = 0;
      e = v[i].b;
      c = v[i].l;
    }
    while(e-s>=2){
      if(s>=minimum) break;
      ll mid = (s+e)/2;
      if(mid*c < remain) s = mid;
      else e = mid;
    }
    minimum = min(e,minimum);
  }
  ll ans = (ll)X * index + minimum;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np


def main():
    A = np.array([list(map(int, input().split())) for _ in range(3)])
    N = int(input())
    B = np.array([int(input()) for _ in range(N)])

    result = np.zeros((3, 3))

    for i in range(3):
        for j in range(3):
            for b in B:
                if A[i][j] == b:
                    result[i][j] = 1

    for i in range(3):
        if all(result[i, :]):
            print('Yes')
            exit(0)
    for i in range(3):
        if all(result[:, i]):
            print('Yes')
            exit(0)
    if all([result[0, 0], result[1, 1], result[2, 2]]):
        print('Yes')
        exit(0)
    if all([result[0, 2], result[1, 1], result[2, 0]]):
        print('Yes')
        exit(0)
    print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 12248
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int OFS = 2;
	int MAX = 10 + OFS * 2;
	int map[][];
	
	void run() {
		Scanner sc = new Scanner(System.in);
		map = new int[MAX][MAX];
		
		while(sc.hasNext()) {
			String[] str = sc.next().split(",");
			int[] v = new int[3];
			for(int i=0;i<3;i++) v[i] = Integer.parseInt(str[i]);
			if(v[2] == 1) s(v[0]+OFS, v[1]+OFS);
			if(v[2] == 2) m(v[0]+OFS, v[1]+OFS);
			if(v[2] == 3) l(v[0]+OFS, v[1]+OFS);
		}
		int max = 0, cnt = 0;
		for(int i=OFS;i<MAX-OFS;i++) for(int j=OFS;j<MAX-OFS;j++) {
			max = max(max, map[i][j]);
			if(map[i][j] == 0) cnt++;
		}
		System.out.println(cnt);
		System.out.println(max);
	}
	
	void s(int x, int y) {
		map[y][x]++; map[y-1][x]++; map[y][x-1]++; map[y+1][x]++; map[y][x+1]++; 
	}
	void m(int x, int y) {
		for(int i=x-1;i<=x+1;i++) for(int j=y-1;j<=y+1;j++)
			map[j][i]++;
	}
	void l(int x, int y) {
		m(x, y);
		map[y-2][x]++; map[y][x-2]++; map[y+2][x]++; map[y][x+2]++;
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main() {
    int a,b;
    cin >> a >> b ;
    if (a==1){
        a+=1234;
    }
    if (b==1){
        b+=1234;
    }
    if(a>b){
        cout << "Alice";
    }else if (a<b){
        cout << "Bob";
    }else{
        cout << "Draw";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
int main()
{
#ifdef _noname
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> a >> b;
	if (a + b > n + 1 || a * b < n) puts("-1");
	else
	{
		int x = 1, y;
		if (b != 1)
			for (; (n - x * b) >= a - x; x++)
				for (int i = b; i >= 1; i--)
					printf("%d ", (x - 1) * b + i);
		x--;
		y = x * b;
		for (int i = 1; i < a - x; i++)
		{
			y++;
			printf("%d ", y);
		}
		for (int i = n; i > y; i--) printf("%d ", i);
		puts("");
	}
	return 0;
}

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

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(NULL);
#define endl            "\n"
#define NUM             100005
typedef long long ll;

long long n,w,weight[NUM],value[NUM],dp[105][NUM];

long long solve(long long i,long long m)
{
    ll profit1,profit2;

    if(i==n+1)
        return 0;

    if(dp[i][m]!=-1)
        return dp[i][m];

    if(m+weight[i]<=w)
        profit1 = value[i]+solve(i+1,m+weight[i]);
    else
        profit1=0;

    profit2 = solve(i+1,m);

    dp[i][m] = max(profit1,profit2);

    return dp[i][m];
}


int main()
{
    FastRead

    //long long n,w;

    memset(dp,-1,sizeof(dp));

    cin>>n>>w;

    for(ll i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
    }

    cout<<solve(0,0);
}


Measured memory_bytes: 82432
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int a;
  int p;
  int katahen;
  int ans;
  scanf("%d%d",&a,&p);
  katahen=a*3+p;
  ans=katahen/2;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
char maps[2005][2005];
int row[2005][2005];
int column[2005][2005];
int main(){
  int h,w;
  cin>>h>>w;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maps[i][j];
    }
  }
  
  for(int i=0;i<h;i++){
    int cnt=0;
    for(int j=0;j<w;j++){
      if(maps[i][j]=='#'){
	cnt=0;
      }else{
	cnt++;
      }
      column[i][j]=cnt;
    }
    int target=0;
    for(int j=w-1;j>=0;j--){
      if(target==0&&maps[i][j]=='.'){
	target=column[i][j];
      }else if(maps[i][j]=='#'){
	target=0;
      }
      column[i][j]=target;
    }
  }

  for(int j=0;j<w;j++){
    int cnt=0;
    for(int i=0;i<h;i++){
      if(maps[i][j]=='#'){
	cnt=0;
      }else{
	cnt++;
      }
      row[i][j]=cnt;
    }
    int target=0;
    for(int i=h-1;i>=0;i--){
      if(target==0&&maps[i][j]=='.'){
	target=row[i][j];
      }else if(maps[i][j]=='#'){
	target=0;
      }
      row[i][j]=target;
    }
  }

  int maxim=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      maxim=max(maxim,column[i][j]+row[i][j]-1);
    }
  }
  cout<<maxim<<endl;
  return(0);
}

Measured memory_bytes: 35584
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
	int N, M;
	std::vector<int> A;
	std::cin >> N>> M;
	int At = 0;
	for (int i = 0; i < M; i++) {
		int a;
		std::cin >> a;
		A.push_back(a);
		At += a;
	}
	int day = N - At;
	if (day < 0)
		std::cout << -1;
	else
		std::cout << day;
}

Measured memory_bytes: 3744
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, K; cin >> N >> M >> K;
	M--;
	VI A(N);
	REP(i, N)cin >> A[i];
	vector<VI>dp(K + 1, VI(N + 1, 0));
	VI ma(N);

	eREP(i, N)eREP(j, K)dp[j][i] = 0;
	REP(i, N)dp[1][i] = A[i];

	deque<int>deq;
	REP(j, N) {
		while (!deq.empty() && dp[1][deq.back()] <= dp[1][j])deq.pop_back();
		deq.push_back(j);
		ma[j] = dp[1][deq.front()];
		if (deq.front() == j - M)deq.pop_front();
		//cout << ma[j] << endl;
	}

	eFOR(i, 2, K) {
		FOR(j, 1, N) {
			int tmp = ma[j - 1];
			dp[i][j] += tmp;
			if (dp[i][j] > 0)dp[i][j] += i * A[j];
		}

		deq.clear();
		REP(j, N) {
			while (!deq.empty() && dp[i][deq.back()] <= dp[i][j])deq.pop_back();
			deq.push_back(j);
			ma[j] = dp[i][deq.front()];
			if (deq.front() == j - M)deq.pop_front();
		}
	}

	int ans = -LLINF;
	eREP(i, N)chmax(ans, dp[K][i]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 240928
#include <stdio.h>
#include <string.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  char s[100005];  scanf("%s", s);
  int answ = 0, ansb = 0;

  for(int i=0; i<strlen(s); i++)
    if(i % 2){
      if(s[i] == '0')  ansb++;
      else  answ++;
    }else{
      if(s[i] == '0')  answ++;
      else  ansb++;
    }

  printf("%d\n", min(ansb, answ));
  return 0;
}
    


Measured memory_bytes: 256
class Solution:
    def solve(self, N: int, F, P) -> int:

        answer = - 10**10

        def list2int(li) -> int:

            base = 1
            ret = 0
            for b in li:
                ret += base * b
                base *= 2
            return ret

        def int2list(i: int):
            ret = []
            for _ in range(10):
                ret.append(i % 2)
                i //= 2

            return ret

        F_int = [list2int(f) for f in F]

        for j in range(1, 1024):
            s = 0
            for n, f in enumerate(F_int):
                cn = sum(int2list(j & f))
                s += P[n][cn]

            answer = max(answer, s)

        return answer


if __name__ == '__main__':

    # standard input
    N = int(input())
    F = []
    for _ in range(N):
        F.append(list(map(int, input().split())))
    P = []
    for _ in range(N):
        P.append(list(map(int, input().split())))

    # solve
    solution = Solution()
    print(solution.solve(N, F, P))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

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

int main()
{
    int a, b; cin >> a >> b;
    if(a<10 && b < 10){
        cout << a*b << endl;
    }
    else  cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()

slist=[]
for i in range(4):
    slist.append(s[i])

slistx=sorted(slist)

if slistx[0]==slistx[1]:
    if slistx[2]==slistx[3]:
        if slistx[1]!=slistx[2]:
            print("Yes")
            quit()
            
print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

struct Edge {
   ll from, to, cost;
   Edge(){}
   Edge(ll from, ll to, ll cost):from(from),to(to),cost(cost){}
};

vector<Edge> g;

bool bellman_ford(int s, int t, int V, vector<ll> &dp) {
    dp[s]=0;
    bool neg_loop = false;
    for (int i = 0; i < 2*V; ++i) {
        bool update = false;
        bool goal_updated = false;
        for (auto &&e:g) {
            if (dp[e.from]!=LINF && dp[e.to]>dp[e.from]+e.cost) {
                dp[e.to]=dp[e.from]+e.cost;
                update=true;
                if (e.to == t) goal_updated = true;
            }
        }
        if (!update) break;
        if (i>=V-1 && goal_updated) {
            neg_loop=true;
            break;
        }
    }
    return neg_loop;
}

bool find_neg_loop(int s, int t, int V, vector<ll> &dp) {
    bool update = false;
    for (int i=0; i<=V; ++i) {
        for (auto &&e: g) {
            if (dp[e.to]!=LINF && dp[e.to] > dp[e.from]+e.cost) {
                dp[e.to] = -LINF;
            }
        }
    }
    if (dp[t]==-LINF) return true;
    else return false;
}

int main(int argc, char const *argv[]) {
    int n,m,p;cin>>n>>m>>p;
    rep(i,m) {
        int a,b,c;cin>>a>>b>>c;
        --a,--b;
        c-=p;
        c*=-1;
        g.push_back(Edge(a,b,c));
    }
    vector<ll> dp(n,LINF);
    bellman_ford(0,n-1,n,dp);
    if (find_neg_loop(0,n-1,n,dp)) cout << -1 << endl;
    else cout<<max(dp[n-1]*-1,0ll)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define end(x) {cout<<#x<<endl;continue;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll gcd(ll x,ll y){return !y?x:gcd(y,x%y);}
int main()
{	int t; cin>>t;
	while(t--)
	{	ll a,b,c,d; cin>>a>>b>>c>>d;
		if(a<b) end(No); if(d<b) end(No); if(c>b) end(Yes);
		ll ans=b-gcd(b,d)+a%gcd(b,d);
		if(ans>c) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
 
public class Test
{
	public static void Main()
	{
		// my code goes here
		
		ulong  x = ulong.Parse(Console.ReadLine());
		
		int counter = 0;
		decimal a = 100;
		while(a<x){
			a = a * (decimal)1.01;
			a = Math.Floor(a);
			counter++;
		}
		Console.WriteLine(counter);
		
	}
}

Measured memory_bytes: 27620
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
# どこから来たのかを記録
come_from = [set() for _ in range(N+1)]
edges = [set() for _ in range(N+1)]
for _ in range(N-1+M):
    a, b = lr()
    come_from[b].add(a)
    edges[a].add(b)

from_num = [len(x) for x in come_from]
root = 0
for i in range(1, N+M):
    if from_num[i] == 0:
        root = i
        break

parent = [-1] * (N+1)
parent[root] = 0
stack = [root]
while stack:
    x = stack.pop()
    for y in edges[x]:
        if len(come_from[y]) > 1:
            come_from[y].remove(x)
            continue
        parent[y] = x
        stack.append(y)

for i in range(1, N+1):
    print(parent[i])
#01

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

void solve(long long N, long long K)
{
    cout << (N % K == 0 ? 0 : 1) << endl;
}

// 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)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


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

int b()
{
    long long a, b, c, k;
    std::cin >> a >> b >> c >> k;
    
    long long ans = 0;
    if(k <= a)
    {
        ans = k;
    }
    else if(k <= a + b)
    {
        ans = a;
    }
    else
    {
        ans = a - (k - (a + b));
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    b();
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >=0; --i)
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; }

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);



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

  ll a, b;
  map<pi, pi> m;
  map<pi, ll> m4;

  ll zero = 0;
  ll xconst = 0;
  ll yconst = 0;
  
  rep(i, n){
    cin >> a >> b;
    if(a==0 && b==0) {
      zero++;
      continue;
    }
    if(b<0){
      a = -a; b= -b;
    }
    if(b==0 && a<0){
      a = -a;
    }
    ll g = gcd(a, abs(b));
    a /= g; b /= g;

    bool dai1 = false;
    if(a>0) dai1 = true;
    if(dai1) {
      pi tmp = make_pair(a, b);
      m[tmp].first++;
    }
    else{
      pi tmp = make_pair(b, -a);
      m[tmp].second++;
    }

  }

  mint ans = 1;

  for(auto x : m){
    mint now = mint(2).pow(x.second.first);
    now += mint(2).pow(x.second.second) -1;
    ans *= now; 
  }
  cerr << ans.x << endl;

  cerr << xconst<< " "<<yconst << endl;
  cerr << zero << endl;

  cerr << ans.x << endl;

  ans += zero - 1;

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


Measured memory_bytes: 21912
INF = 10 ** 5
N, Ma, Mb = map(int,input().split())
dp = [[[INF for i in range(10 * N + 1)] for j in range(10 * N + 1)] for k in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    a, b, c = map(int,input().split())
    for j in range(10 * N + 1):
        for k in range(10 * N + 1):
            dp[i+1][j][k] = min(dp[i][j][k], dp[i+1][j][k])
            if j + a <= 10 * N and k + b <= 10 * N:
                dp[i+1][j+a][k+b] = min(dp[i][j][k] + c, dp[i+1][j+a][k+b])

ans = INF
i = 1
while Ma * i <= 10 * N and Mb * i <= 10 * N:
    ans = min(ans, dp[N][Ma*i][Mb*i])
    i += 1

if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 99164
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int a,b;
    cin >> a >> b;
    if(a * b % 2 == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    int a;
    cin>>a;
    string s;
    cin>>s;
    int sum=0;
    int max1=0;
     for(int i=0;i<a;i++)
     {
         if(s[i]=='I')
         {
             sum++;
         }
         else
         {
             sum--;
         }
         max1=max(sum,max1);
     }
     cout<<max1<<endl;
     return 0;
 }


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

int main(){
    int N,M;
    cin>>N>>M;
    int L=1,R=N;
    for(int i=0;i<M;i++){
        int l,r;
        cin>>l>>r;
        L=max(L,l);
        R=min(R,r);
    }
    cout<<max(0,R-L+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include  <stdio.h>

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

	if(a<=b&&b<=c)
	{
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<=c&&c<=b)
	{
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<=a&&a<=c)
	{
		printf("%d %d %d\n",b,a,c);
	}
	else if(b<=c&&c<=a)
	{
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<=a&&a<=b)
	{
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<=b&&b<=a)
	{
		printf("%d %d %d\n",c,b,a);
	}

	return 0;
}

Measured memory_bytes: 596
var
	n,i,ans,p,j,a,cnt,k:Longint;
	dp:array[0..100,1..75]of Longint;
function isp(a:Longint):Boolean;
var i:Longint;
begin
	i:=2;
	while i*i<=a do begin
		if a mod i=0 then begin
			isp:=False;
			exit;
		end;
		inc(i);
	end;
	isp:=True;
end;
begin
	read(n);
	dp[0,1]:=1;
	p:=0;
	for i:=2 to n do begin
		if not isp(i)then continue;
		cnt:=0;
		for j:=1 to n do begin
			a:=j;
			while a mod i=0 do begin
				a:=a div i;
				inc(cnt);
			end;
		end;
		for j:=0 to cnt do begin
			if not((j=0)or(j=2)or(j=4)or(j=14)or(j=24)or(j=74))then continue;
			for k:=1 to 75 div (j+1)do inc(dp[i,k*(j+1)],dp[p,k]);
		end;
		p:=i;
	end;
	writeln(dp[p,75]);
end.


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    int n;
    cin >> n;
    ll a;
    deque<ll> b;
    if (n % 2 == 0)
    {
        rep(i, n)
        {
            cin >> a;
            if (i % 2 == 0)
            {
                b.push_back(a);
            }
            else
            {
                b.push_front(a);
            }
        }
    }
    else
    {
        rep(i, n)
        {
            cin >> a;
            if (i % 2 == 0)
            {
                b.push_front(a);
            }
            else
            {
                b.push_back(a);
            }
        }
    }
    for (ll n : b)
    {
        cout << n << " ";
    }
    cout << endl;

    return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	int sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		sum+= arr[i];
	}
	cout << sum-n;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (int)(1e7)
using namespace std;

struct intersection {
  string s, t;
};

int n, m;
map<string, int> mp;
vector<vector<int>> dist;
vector<vector<bool>> memo;
vector<intersection> v;

intersection parse(string &s);

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    v.resize(n);
    mp.clear();
    for(int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      intersection in = parse(s);
      if(mp.find(in.s) == mp.end()) {
        int x = mp.size();
        mp[in.s] = x;
      }
      if(mp.find(in.t) == mp.end()) {
        int x = mp.size();
        mp[in.t] = x;
      }
      v[i] = in;
    }
    cout << mp.size() << endl;
    dist.assign(mp.size(), vector<int>(mp.size(), inf));
    memo.assign(mp.size(), vector<bool>(mp.size(), 0));
    for(int i = 0; i < n; ++i)
      dist[mp[v[i].s]][mp[v[i].t]] =
          memo[mp[v[i].s]][mp[v[i].t]] = 1;
    n = mp.size();
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        if(!memo[i][j]) {
          bool ch = 0;
          for(int k = 0; k < n; ++k)
            if((memo[i][k] && memo[j][k]) ||
               (memo[k][i] && memo[k][j]))
              ch = 1;
          for(int k = 0; k < n; ++k)
            if((memo[i][k] && memo[k][j]) ||
               (memo[j][k] && memo[k][i]))
              ch = 0;
          if(ch) dist[i][j] = 2;
        }
    for(int k = 0; k < n; ++k)
      for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
          dist[i][j] =
              min(dist[i][j], dist[i][k] + dist[k][j]);
    cin >> m;
    for(int i = 0; i < m; ++i) {
      string s;
      cin >> s;
      intersection now = parse(s);
      if(mp.find(now.s) == mp.end() ||
         mp.find(now.t) == mp.end() ||
         dist[mp[now.s]][mp[now.t]] % 2 == 0)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
  return 0;
}

intersection parse(string &s) {
  bool ch = 0;
  intersection res = {"", ""};
  int len = s.size();
  for(int i = 0; i < len; ++i) {
    if(s[i] == '-') {
      ch = 1;
      continue;
    }
    if(!ch)
      res.s += s[i];
    else
      res.t += s[i];
  }
  return res;
}


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

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

            double money = 100;
            var year = 0;
            while (money < X)
            {
                money = (long)money * 1.01;
                year++;
            }
            Console.WriteLine(year);
        }
    }
}


Measured memory_bytes: 17600
import itertools
r = 110000
s = int(r*0.5)
p = [1] * r
p[0] = 0
for i in range(1,s):
	if p[i]:
		p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
		
while 1:
	N,P = map(int,raw_input().split())
	if N == -1: break
	i = N + 1
	prime = [0]*(13 + P/10)
	j = 0
	while j < (13 + P/10):
		if p[i-1] == 1:
			prime[j] = i
			j += 1
		i += 1
	wa = sorted([sum(comb) for comb in itertools.combinations(prime,2)] + [2*a for a in prime])
	print wa[P-1]

Measured memory_bytes: 9028
#include<stdio.h>
#include<math.h>
double d[1000][1000];
int f[1000][1000];
int main(){
  int n,i,j,k,s,t,b[1000],x[1000],y[1000];
  int M=100000000;
  while(scanf("%d",&n),n){
    for(i=0;i<n;i++){
      scanf("%d %d %d",&b[i],&x[i],&y[i]);
      for(j=i;j>-1;j--){
        d[b[i]][b[j]]=d[b[j]][b[i]]=hypot(x[j]-x[i],y[j]-y[i]);
	f[b[i]][b[j]]=b[i];
	f[b[j]][b[i]]=b[j];
	if(d[b[i]][b[j]]>50)d[b[i]][b[j]]=d[b[j]][b[i]]=M;
      }
    }
    for(k=0;k<n;k++){
      for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	  if(d[b[i]][b[j]]>d[b[i]][b[k]]+d[b[k]][b[j]]){
	     d[b[i]][b[j]]=d[b[i]][b[k]]+d[b[k]][b[j]];
	     f[b[i]][b[j]]=f[b[k]][b[j]];
	  }
	}
      }
    }
    scanf("%d",&n);
    while(n--){
      scanf("%d %d",&s,&t);
      if(d[t][s]>M-1)printf("NA\n");
      else{
	for(;s-t;s=f[t][s])printf("%d ",s);
	printf("%d\n",t);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

string jj("JOI");
string ii("IOI");

int main(){
  string s;
  while(cin>>s){
    int jo=0,io=0;
    for(int i=0; i+2<(int)s.size(); i++){
      bool joi=true,ioi=true;
      for(int j=i; j<i+3; j++){
        int k=j-i;
        if(jj[k]!=s[j]) joi=false;
        if(ii[k]!=s[j]) ioi=false;
      }
      if(joi) jo++;
      if(ioi) io++;
    }
    
    cout<<jo<<endl<<io<<en
  }
  
}



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

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

#define mp make_pair
#define pb(x) push_back(x)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
// template <typename... Args>
// void dbg(Args... args) {
//     ((cout << args << " "), ...);
//     cout << endl;
// }

//--------------------------------------------------//
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({a, b, c}) - min({a, b, c}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
 
 
int main(){
    int k; string s; cin >> k >> s;
    int sl=s.length();
    if(k>=sl){
        cout << s << endl;
        return 0;
    }
    else{
        string ans=s.substr(0,k);
        cout << ans << "..." << endl;
    }
return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    ll sum=0;
    map<char,int> dic;
    rep(i,s.size()){
        sum+=i-dic[s[i]];
        dic[s[i]]++;
    }
    cout1(sum+1);
}

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

using namespace std;
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define all(x) (x).begin(),(x).end()

using int64 = long long;




int main() {
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}


Measured memory_bytes: 888
n = int(input())
a = sorted([int(input()) for _ in range(n)])
ans = 0
count = 0
pre = a[0]

for i in range(n):
    if a[i] == pre:
        count+=1
    else:
        pre = a[i]
        if count%2 == 1:
            ans += 1
        count = 1
if count%2 == 1:
    ans += 1
print(ans)


Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b <= a) {
    cout << "delicious";
  } else if (b > a && b <= a+x) {
    cout << "safe";
  } else {
    cout << "dangerous";
  }
  return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根をrxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for(int i = 0; i < N; i++){
        cin >> P[i];
    }
    
    UnionFind tree(N); //
    
    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1); // 要素x-1の木とy-1の木を併合する
    }
    
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if (tree.same(i, P[i]-1)) { //iとP[i]-1が同じ木に属するなら，カウンタに1追加
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

tot1=[]
tot2=[]


for _ in range(m):
    a,b = map(int,input().split())
    tot1.append(a)
    tot2.append(b)

for i in range(1,n+1):
    cnt=(tot1+tot2).count(i)
    print(cnt)

Measured memory_bytes: 3060
function Main(s){
	s|=0;
	var arr=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049];
	var a=1<<29;
	
	fu(0,s,11);
	
	function fu(k,n,i){
		if(n<=0){
			if(k<a){a=k;}
		}
		else if(k<a){
			while(arr[i]>n){i--;}
			fu(k+1,n-arr[i],i);
			if(i>1){fu(k+1,n-arr[i-1],i-1);}
		}
	}
	
	console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int ans=max(max(10*a+b+c,a+10*b+c),a+b+10*c);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, h;
  cin >> a >> b >> h;
  int ans = (a + b) * h / 2;
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B;
  int a, b;
  cin >> A >> B;
  for (int i = 1; i < 1100; i++)
  {
      a = i * 0.08;
      b = i * 0.1;
      a = floor(a);
      b = floor(b);
    if (a == A && b == B)
    {
      cout << i << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            
            int blue_n = Integer.parseInt(br.readLine());
            ArrayList<String> blue_card = new ArrayList<String>();
            
            for(int i=0;i<blue_n;i++){
                blue_card.add(br.readLine());
                
            }
            
            
            
            int red_n = Integer.parseInt(br.readLine());
            ArrayList<String> red_card = new ArrayList<String>();
            
            for(int i=0;i<red_n;i++){
                red_card.add(br.readLine());
                
            }
            
            
            
            String str ="";
            int max=0;
            
            for(int i=0;i<blue_n;i++){
                
                int count_b=0;
                int count_r=0;
                
                str = blue_card.get(i);

                    
                for(int j=0;j<blue_n;j++){
                    if(blue_card.get(j).equals(str)){
                        count_b++;
                    }
                }
                
                
                for(int k=0;k<red_n;k++){
                    if(red_card.get(k).equals(str)){
                        count_r++;
                    }
                }
                
                
                if(count_b-count_r>max){
                max =count_b-count_r;
                }
            
            }
            
            
           System.out.println(max);
            
            

        }
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

struct Mono {
	int num, order;
	bool check = 0;
};

void merge(Mono*, int, int, int);
void mergesort(Mono*, int, int);

int main()
{
	int n, tmp, cnt = 0, sum = 0;
	Mono *w;
	vector<Mono> vvm[500];

	scanf("%d", &n);
	w = new Mono[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &w[i].num);
		w[i].order = i;
	}

	mergesort(w, 0, n);
	
	for (int i = 0; i < n; i++)
		if (!w[i].check)
		{
			tmp = i;
			while (!w[tmp].check)
			{
				w[tmp].check = true;
				if (w[tmp].order == tmp)
					break;
				vvm[cnt].push_back(w[tmp]);
				tmp = w[tmp].order;
			}
			if (vvm[cnt].size())
				cnt++;
		}

	for (int i = 0; i < cnt; i++)
	{
		for (int j = 1; j < vvm[i].size(); j++)
			sum += vvm[i][j].num;
		if (w[0].num * (vvm[i].size() + 1) + vvm[i][0].num * 2 > vvm[i][0].num * (vvm[i].size() - 1))
			sum += vvm[i][0].num * (vvm[i].size() - 1);
		else
			sum += w[0].num * (vvm[i].size() + 1) + vvm[i][0].num * 2;
	}
	printf("%d\n", sum);
	delete[] w;

	return 0;
}

void merge(Mono *a, int left, int mid, int right)
{
	int n1, n2, i = 0, j = 0;
	Mono *l, *r;
	n1 = mid - left;
	n2 = right - mid;
	l = new Mono[n1 + 1];
	r = new Mono[n2 + 1];

	for (int i = 0; i < n1; i++)
		l[i] = a[left + i];
	for (int i = 0; i < n2; i++)
		r[i] = a[mid + i];
	l[n1].num = r[n2].num = 20000000;

	for (int k = left; k < right; k++)
	{
		if (l[i].num <= r[j].num)
		{
			a[k] = l[i];
			i++;
		}
		else
		{
			a[k] = r[j];
			j++;
		}
	}
	delete[] l;
	delete[] r;
	return;
}

void mergesort(Mono *a, int left, int right)
{
	if (left + 1 < right)
	{
		int mid;
		mid = (left + right) / 2;
		mergesort(a, left, mid);
		mergesort(a, mid, right);
		merge(a, left, mid, right);
	}
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<string> s(n),ans;
  rep(i,n) cin >> s[i];
  map<string,int> cnt;
  rep(i,n){
    cnt[s[i]]++;
  }
  int tmp=-1;
  rep(i,n){
    int rec=cnt[s[i]];
    chmax(tmp,rec);
  }

  rep(i,n){
    if(cnt[s[i]]==tmp){
      ans.pb(s[i]);
    }
  }


  sort(all(ans));
  ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
  rep(i,sz(ans)) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 28404