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


using namespace std;

int main() {

	int x, y;
	scanf("%d %d", &x, &y);
	int bonus = 400000;
    long long int sum = 0;
    int first = 300000, second = 200000, third = 100000;

	if(x == 3 and y >= 4)
    {
        sum = third;
    }
    else if(x == 2 and y >= 4)
    {
        sum = second;
    }
    else if(x == 1 and y >= 4)
    {
        sum = first;
    }
    else if(x >= 4 and y == 3)
    {
        sum = third;
    }
    else if(x >= 4 and y == 2)
    {
        sum = second;
    }
    else if(x >= 4 and y == 1)
    {
        sum = first;
    }
    else if(x == 1 and y == 1)
    {
        sum = first + first + bonus;
    }
    else if((x == 2 and y ==1) or (x == 1 and y == 2))
    {
        sum = second + first;
    }
    else if((x == 3 and y ==1) or (x == 3 and y == 1))
    {
        sum = third + first;
    }
    else if((x == 2 and y ==3) or (x == 3 and y == 2))
    {
        sum = third + second;
    }
    else if((x == 1 and y ==3) or (x == 3 and y == 1))
    {
        sum = third + first;
    }
    else if(x == 2 and y == 2)
    {
        sum = second + second;
    }
    else if(x == 3 and y == 3)
    {
        sum = third + third;
    }


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define is(s) freopen((const char*)(s),"r",stdin)
#define os(s) freopen((const char*)(s),"w",stdout)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define x first
#define y second

using namespace std;
int n;
string k;
map<string,int>pos;
vector<pair<int,string> >ans;
int main()
{
	//is("input.txt");os("output.txt");
	cin>>n;
	rep(i,n)
	{
		cin>>k;
		if(pos.count(k)) ans[pos[k]].x--;
		else pos[k]=ans.size(),ans.pb(mp(-1,k));
	}
	sort(all(ans));
	cout<<ans[0].y<<endl;
	rep2(i,1,ans.size())
	if(ans[i].x==ans[i-1].x)
	cout<<ans[i].y<<endl;
	else break;
	return 0;}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
namespace __gnu_pbds {
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}






int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("digits.in" , "r" , stdin);
//freopen("digits.out" , "w" , stdout);


     string s1,s2;
     cin>>s1>>s2;
     s2.erase(s2.size()-1,1);
     if(s1==s2){
        cout<<"Yes";
        return 0;
     }
     cout<<"No";






     return 0;

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 ll dp[2000][2000];



int main(){
   ll a,b,c,k,ans=0;;
   cin>>a>>b>>c>>k;
   ans+=min(a,k);
   k-=a+b;
   if(k>0)ans-=k;

   cout<<ans<<endl;
   

}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

lint N, K;
lint A[1010101], F[1010101];

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

  cin >> N >> K;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];

  sort(A, A + N);
  sort(F, F + N);
  reverse(F, F + N);

  lint left = -1, right = 1e18, tmp;
  while (left + 1 < right) {
    lint mid = (left + right) / 2;
    tmp = K;
    bool ok = true;
    rep(i, N) {
      if (A[i] * F[i] <= mid) continue;
      lint cnt = mid / F[i];
      cnt = A[i] - cnt;

      if (cnt <= tmp) {
        tmp -= cnt;
      } else {
        ok = false;
      }
    }
    if (ok) {
      right = mid;
    } else {
      left = mid;
    }
  }

  cout << right << endl;

  return 0;
}

Measured memory_bytes: 5888
fun main(arg: Array<String>) {
    val INF = 1000000007
    val (N, M) = listOfInt()
    val G = Array(N) { IntArray(N) { INF } }
    val E = Array(N) { IntArray(N) }
    repeat(N) { n -> G[n][n] = 0 }
    repeat(M) {
        val (a, b, c) = listOfInt(-1, -1, 0)
        G[a][b] = c; G[b][a] = c
        E[a][b] = c; E[b][a] = c
    }
    repeat(N, N, N) { k, n, m ->
        G[n][m] = Math.min(G[n][m], G[n][k] + G[k][m])
    }
    val A = Array(N) { BooleanArray(N) }
    repeat(N, N, N, N) { s, t, n, m ->
        if (s != t && n != m)
            if (G[s][t] == G[s][n] + E[n][m] + G[m][t]) A[n][m] = true
    }
    var ans = 0
    repeat(N, N) { n, m ->
        if (n < m && !A[n][m] && E[n][m] != 0) ans += 1
    }
    println(ans)
}
inline fun repeat(times1: Int, times2: Int, action: (Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2) {
            action(index1, index2)
        }
}
inline fun repeat(times1: Int, times2: Int, times3: Int, action: (Int, Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2)
            for (index3 in 0 until times3) {
                action(index1, index2, index3)
            }
}
inline fun repeat(times1: Int, times2: Int, times3: Int, times4: Int, action: (Int, Int, Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2)
            for (index3 in 0 until times3)
                for (index4 in 0 until times4) {
                    action(index1, index2, index3, index4)
                }
}


fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map(String::toLong)
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }


Measured memory_bytes: 47432
using System;

namespace ITP1_8_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            for(int i = 0; i<input.Length;i++)
            {
                if (char.IsUpper(input[i]))
                    Console.Write(char.ToLower(input[i]));
                else if (char.IsLower(input[i]))
                    Console.Write(char.ToUpper(input[i]));
                else
                    Console.Write(input[i]);
            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 5552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  vector<vector<int>> dp(n + 1, vector<int>(3));
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= 2; j++) {
      if (i - j == 0) dp[i][j] = 1;
      string t;
      for (int u = i - j; u < i; u++) {
        t += s[u];
      }
      for (int k = 1; i + k <= n && k <= 2; k++) {
         string r;
         for (int u = 0; u < k; u++) {
           r += s[u + i];
         }
         if (t != r) dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
         //cerr << i << " " << j << " " << k << " " << t << " " << r << endl;
      }
    }
  }
  cout << max(dp[n][1], dp[n][2]) << endl;
  return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main()
{
    int n, ans=0;
    string s;
    cin >>n>>s;
    
    for(int i = 0; i < n; i++)
    {
        bool x[26],y[26];
        
        for(int iii = 0; iii < 26; iii++)
        {
            x[iii]=false;
            y[iii]=false;
        }
        
        for(int xx = 0; xx < i; xx++)
        {
            x[s[xx]-'a']=true;
        }
        
        for(int yy = i; yy < n; yy++)
        {
            y[s[yy]-'a']=true;
        }
        
        int tmp =0;
        
        for(int j = 0; j < 26; j++)
        {
            if(x[j]&&y[j]) tmp++;
        }
        
        ans=max(ans,tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
  int N;
  cin >> N;

  long double sum = 0;
  for (int i = 0; i < N; ++i)
  {
    int A;
    cin >> A;
    sum += 1 / (long double)A;
  }
  cout << setprecision(14) << 1 / sum << endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    ans += bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i]))
print(ans)


Measured memory_bytes: 23092
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

N,mod=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]

if N==1:
    print(1)
    sys.exit()

EDGELIST=[[] for i in range(N+1)]
for x,y in EDGE:
    EDGELIST[x].append(y)
    EDGELIST[y].append(x)

SCORELIST=[[-1]*len(EDGELIST[i]) for i in range(N+1)]
PRODLIST=[[-1]*len(EDGELIST[i]) for i in range(N+1)]
PRODLIST_rev=[[-1]*len(EDGELIST[i]) for i in range(N+1)]
EDICT=dict()

for i in range(1,N+1):
    for j in range(len(EDGELIST[i])):
        EDICT[(i,EDGELIST[i][j])]=j

def dp(x,y):
    if SCORELIST[y][EDICT[(y,x)]]!=-1:
        return SCORELIST[y][EDICT[(y,x)]]

    ANS=1
    for to in EDGELIST[x]:
        if to==y:
            continue
        ANS=ANS*dp(to,x)%mod

    SCORELIST[y][EDICT[(y,x)]]=ANS+1   
    return ANS+1

def dp2(x,y):
    if PRODLIST[x][0]==-1:
        PRODLIST[x][0]=(SCORELIST[x][0])%mod
        for i in range(1,len(EDGELIST[x])):
            PRODLIST[x][i]=PRODLIST[x][i-1]*SCORELIST[x][i]%mod

        PRODLIST_rev[x][-1]=SCORELIST[x][-1]
        for i in range(len(EDGELIST[x])-2,-1,-1):
            PRODLIST_rev[x][i]=PRODLIST_rev[x][i+1]*SCORELIST[x][i]%mod

    if len(EDGELIST[x])==1:
        ANS=1
    elif EDICT[(x,y)]==0:
        ANS=PRODLIST_rev[x][1]
    elif EDICT[(x,y)]==len(EDGELIST[x])-1:
        ANS=PRODLIST[x][EDICT[(x,y)]-1]
    else:
        ANS=PRODLIST[x][EDICT[(x,y)]-1]*PRODLIST_rev[x][EDICT[(x,y)]+1]%mod

    SCORELIST[y][EDICT[(y,x)]]=ANS+1

for to in EDGELIST[1]:
    dp(to,1)

QUE=deque([1])
check=[0]*(N+1)

while QUE:
    x=QUE.pop()
    if check[x]==1:
        continue
    for to in EDGELIST[x]:
        if check[x]==0 or check[to]==0:
            dp2(x,to)
            QUE.append(to)
    check[x]=1

for i in range(1,N+1):
    print(PRODLIST[i][-1])

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

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

   int H,W;
   cin>>H>>W;
   int black=0,white=0;
   vector<vector<char> >s(W,vector<char>(H));
   for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
         cin>>s[x][y];
         char a=s[x][y];
         if(a=='.')white++;
         else black++;
      }
   }
   //cout<<white<<" "<<black<<endl;

   queue<pii>q;
   q.push(make_pair(0,0));
   vector<vector<int> >d(W,vector<int>(H));
   d[0][0] = 0;
   bool flg = false;
   while(q.size()){
      int x = q.front().first;
      int y = q.front().second;
      q.pop();
      if(x==W-1&&y==H-1){
         flg=true;
         break;
      }
      for(int i=0;i<4;i++){
         int nx=x+dx[i];
         int ny=y+dy[i];
         if(0<=nx && nx<W && 0<=ny && ny<H && s[nx][ny]=='.'){
            s[nx][ny]='#';
            d[nx][ny] = d[x][y]+1;
            q.push(make_pair(nx,ny));
         }
      }
   }

   //cout<<d[W-1][H-1]<<endl;
   if(flg)cout<<(H*W-black-d[W-1][H-1]-1)<<endl;
   else cout<<-1<<endl;
   return 0;
}


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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='C'){
      for(int j=i+1;j<s.size();j++){
        if(s[j]=='F'){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3604
private fun readInts() = readLine()!!.split(" ").map { it.toInt()!! }

fun main(args: Array<String>) {
    val (N, M, X) = readInts()
    val A = readInts()

    val toZero = (1..X).filter { A.contains(it) }.size
    val toX = (X..N).filter { A.contains(it) }.size

    println(Math.min(toZero, toX))
}

Measured memory_bytes: 35972
#include<stdio.h>

int main(void)
{
	int i,x,y;
	
	for(i=1;i<=3000;i++){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
		if(x<y){
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",y,x);
		}
		
	}
	return 0;
}


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

int n;
vector<vector<int>> g;
vector<int> c, v;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	g.resize(n);
	for(int i=0; i<n-1; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	c.resize(n);
	for(auto &i:c) cin >> i;
	sort(c.rbegin(), c.rend());
	v.resize(n, -1);
	queue<int> q;
	int dm = 0, dmv = -1;
	for(int i=0; i<n; ++i)
		if(g[i].size() > dm){
			dm = g[i].size();
			dmv = i;
		}
	q.push(dmv);
	int cnt = 0;
	while(!q.empty()){
		int t = q.front(); q.pop();
		if(v[t] != -1) continue;
		v[t] = c[cnt];
		++cnt;
		for(size_t i=0; i<g[t].size(); ++i)
			if(v[g[t][i]] == -1)
				q.push(g[t][i]);
	}
	int ans = 0;
	for(int i=0; i<n; ++i)
		for(size_t j=0; j<g[i].size(); ++j)
			if(i < g[i][j])
				ans += min(v[i], v[g[i][j]]);
	cout << ans << "\n";
	if(n == 1) v[0] = c[0];
	for(int i=0; i<n; ++i)
		cout << v[i] << " \n"[i==n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(x < y) {
        ans++;
        x *= 2;
    }
    cout << ans + (x == y) << endl;
}


Measured memory_bytes: 256
from collections import deque
queue=deque()

n = int(input())
A = [int(i) for i in input().split()]

for i in range(n):
  if i % 2 == 0:
  	queue.append(A[i])
  else:
    queue.appendleft(A[i])

answer = []
if n % 2 == 1:
  for i in range(n):
    answer.append(queue.pop())
else:
  for i in range(n):
    answer.append(queue.popleft())
    
print(*answer)

Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
vl v;

void input(void){
   cin>>n;
}

void solve(void){
    cout<<n*(n-1)/2<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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 n,k,a[200005];
int par[200005],ran[200005];
void init(){ for(int i=0;i<200005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
struct RMQ{
	#define s (1<<19)
	int seg[s];
	void update(int k,int a){
		k+=s/2-1; seg[k]=a;
		while(k>0){
			k=(k-1)/2;
			seg[k]=max(seg[k*2+1],seg[k*2+2]);
		}
	}
	int query(int a,int b,int k,int l,int r){
		if(r<a || b<l) return -INF;
		if(a<=l && r<=b) return seg[k];
		else{
			int vl=query(a,b,k*2+1,l,(l+r)/2);
			int vr=query(a,b,k*2+2,(l+r)/2+1,r);
			return max(vl,vr);
		}
	}
}mx,mn,rin;
int main(){
	cin >> n >> k; rep(i,n) cin >> a[i]; init();
	rep(i,n){
		mx.update(i,a[i]);
		mn.update(i,-a[i]);
	}
	rep(i,n-1) rin.update(i,(a[i]<a[i+1]?0:1));
	rep(i,n){
		if(i+k >= n) break;
		int x = mx.query(i,i+k,0,0,s/2-1);
		int y = mn.query(i,i+k,0,0,s/2-1);
		if(y == -a[i] && x == a[i+k]) {unite(i,i+1);}
	}
	int ans = 0, nch = 0;
	rep(i,n){
		if(i+k-1 >= n) break;
		if(rin.query(i,i+k-2,0,0,s/2-1) == 0) {nch=1; continue;}
		if(find(i) == i) ans ++;
	}
	cout << ans+nch << endl;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

const string inf = "-";

void chmax(string& a, string b){
    if(a == inf) a = b;
    else if(a.length() < b.length()) a = b;
    else if(a.length() == b.length()){
        if(a < b) a = b;
    }
}

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

    int n, m; cin >> n >> m;
    int match[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    vector<int> a(m);
    for(int i=0; i<m; ++i) cin >> a[i];

    vector<string> dp(15000, inf);
    dp[0] = "";

    for(int i=0; i<=n; ++i){
        if(dp[i] == inf) continue;
        for(int j=0; j<m; ++j){
            chmax(dp[i+match[a[j]]], dp[i]+(char)(a[j]+'0'));
        }
    }

    cout << dp[n] << endl;


    return 0;
}

Measured memory_bytes: 43776
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }
};

int main()
{
    int n, m; cin >> n >> m;

    UnionFind UF(n);

    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        UF.unite(a, b);
    }

    int ans = 0;
    rep(i,n) {
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4036
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    input = stdin.buffer.readline
    n = int(input())
    g = [int(input()) - 1 for _ in range(n)]
    q = deque([0])
    seen = [-1] * n
    seen[0] = 0

    while q:
        u = q.popleft()
        v = g[u]
        if seen[v] == -1 or seen[v] > seen[u] + 1:
            seen[v] = seen[u] + 1
            q.append(v)

    print(seen[1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 43896
#include <stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void heap(int);

int main()
{
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)
    heap(i);
  for(i=1;i<=H;i++)
    printf(" %d",A[i]);
  printf("\n");
}

void heap(int u)
{
  int l = 2 * u,r = 2 * u + 1,max,k;

  if(l <= H && A[l] > A[u])
    max = l;
  else
    max = u;
   if(r <= H && A[r] > A[max])
     max = r;


  if(max != u)
    {
      k=A[u];
      A[u] = A[max];
      A[max] = k;
      heap(max);
    }
}



Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionA
	{
		public static void Main(string[] args)
		{
			var x = long.Parse(Console.ReadLine());

			Console.WriteLine(x >= 30 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 27376
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL MOD = 1000000007LL;
LL Max[300000];
LL Min[300000];
LL A[300000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < 3 * N; i++) cin >> A[i];
	priority_queue<LL, vector<LL>, greater<LL>> Q1;
	LL sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
		Q1.push(A[i]);
	}
	Max[N - 1] = sum;
	for (int i = N; i < 2 * N; i++) {
		sum += A[i];
		Q1.push(A[i]);
		sum -= Q1.top();
		Q1.pop();
		Max[i] = sum;
	}
	priority_queue<LL> Q2;
	sum = 0;
	for (int i = 3 * N - 1; i >= 2 * N; i--) {
		sum += A[i];
		Q2.push(A[i]);
	}
	Min[2 * N] = sum;
	for (int i = 2 * N - 1; i >= N; i--) {
		sum += A[i];
		Q2.push(A[i]);
		sum -= Q2.top();
		Q2.pop();
		Min[i] = sum;
	}
	LL ans = -(1LL << 60);
	for (int i = N - 1; i < 2 * N; i++) {
		ans = max(ans, Max[i] - Min[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8820
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = n % 10;
        int b = n / 10 % 10;
        int c = n / 100 % 10;
        if(n <= c*100+c*10+c) System.out.println( c*100+c*10+c);
        else System.out.println((c+1)*100+(c+1)*10+(c+1));
        
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
    public static int max(int a, int b) {
        if(a <= b) return b;
        else return a;
    }
}

Measured memory_bytes: 23124
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	#define ll long long
	ll xx;
	cin>>xx;
	vector<ll> good;
	ll x=0;
	while(1){
		ll y=1;
		y*=x;
		if(y>=1e9)
			break;
		y*=x;
		if(y>=1e9)
			break;
		y*=x;
		if(y>=1e9)
			break;
		y*=x;
		if(y>=1e9)
			break;
		y*=x;
		good.push_back(y);
		x++;
	}
	for(int i=0;i<(int)good.size();i++)
		for(int j=0;j<(int)good.size();j++){
			ll a=good[i], b=good[j];
			if(a-b==xx)
				return cout<<i<<" "<<j, 0;
			if(a+b==xx)
				return cout<<i<<" "<<-j, 0;
		}
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int n; cin >> n;
	vector<int>l;
	REP(i, n) {
		int x; cin >> x;
		l.push_back(x);
	}
	sort(l.begin(), l.end());
	ll ans = 0;
	for (int i = n - 1; i >= 2; --i) {
		for (int j = 0; j < i-1; ++j) {
			int x = l[i] - l[j];
			int dis = upper_bound(l.begin(), l.end(), x) - l.begin();
			if (dis <= j) {
				ans += i - j-1;
				continue;
			}
			ans += (i - dis);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-03-30 17:08:06
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int sum = h[0];
    for (int i = 0; i < n-1; i++) {
        sum += max(0, h[i+1]-h[i]);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n, u, v;
vector<int> a[100010];
int anc[100010][20];
int h[100010];
int in[100010];
int out[100010];
bool vis[100010];
int nowh, nowtime;
void dfs(int x, int y)
{
    nowtime++;
    in[x] = nowtime;
    vis[x] = 1;
    h[x] = nowh;
    if(x == 1) forn(i, 18) anc[1][i] = 1;
    else
    {
        anc[x][0] = y;
        int cur = y;
        Forn(i, 17)
        {
            anc[x][i] = anc[cur][i-1];
            cur = anc[cur][i-1];
        }
    }
    forn(i, a[x].size())
    {
        if(!vis[a[x][i]])
        {
            nowh++;
            dfs(a[x][i], x);
            nowh--;
        }
    }
    nowtime++;
    out[x] = nowtime;
}
bool isanc(int x, int y)
{
    if(in[x]<=in[y] && out[y]<=out[x]) return 1;
    return 0;
}
int lca(int x, int y)
{
    if(isanc(x, y)) return x;
    int cur = x;
    for(int i=17; i>=0; i--)
    {
        if(!isanc(anc[cur][i], y)) cur = anc[cur][i];
    }
    return anc[cur][0];
}
int dis(int x, int y)
{
    int mid = lca(x, y);
    return (h[x] - h[mid]) + (h[y] - h[mid]);
}

int tou[100010];
int tov[100010];

int op;
void dfs2(int x)
{
    //cout << "dfs2 " << x << " " << tou[x] << " " << tov[x] << endl;
    vis[x] = 1;
    op = max(op, tov[x] - 1);
    forn(i, a[x].size())
    {
        if(!vis[a[x][i]] && tou[a[x][i]] < tov[a[x][i]]) dfs2(a[x][i]);
    }
}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> u >> v;
    forn(i, n-1)
    {
        int x, y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    dfs(1, 1);
    //cout << lca(4, 1) << endl;
    Forn(i, n)
    {
        tou[i] = dis(i, u);
        tov[i] = dis(i, v);
        //cout << i << " " << tou[i] << " " << tov[i] << endl;
    }
    Forn(i, n) vis[i] = 0;
    dfs2(u);
    cout << op << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<vector<int64_t>> C(10, vector<int64_t>(10));

    for (int i = 1; i <= n; i++){
        string S = to_string(i);
        int a = S[0] - '0';
        int b = S[S.size() - 1] - '0';
        C[a][b]++;
    }

    int64_t ans = 0;
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++)
            ans += C[i][j] * C[j][i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ld a, b, c;
    cin >> a >> b >> c;

    if(a + b + 2 * sqrt(a * b) < c){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
} 

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    REP(i, N)
    {
        ll h;
        cin >> h;
        if (h >= K)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H + 2);

    REP(i, W) {
        s[0] += ".";
        s[H + 1] += ".";
    }
    REP(i, H) {
        string input;
        cin >> input;
        s[i + 1] = "." + input + ".";
    }

    REP(i, H) {
        REP(j, W) {
            if (s[i + 1][j + 1] == '#') {
                continue;
            }
            debug(s[i + 1][j + 1]);
            char count = '0';
            REP(k, 3) {
                REP(m, 3) {
                    if (s[i + 1 - 1 + k][j + 1 - 1 + m] == '#') {
                        count++;
                    }
                }
            }
            s[i + 1][j + 1] = count;
        }
    }

    REP(i, H) {
        REP(j, W) {
            cout << s[i + 1][j + 1];
        }
        cout << "\n";
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/
int cnt[30];
vector<char>v;
signed main() {
	string s;
	cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		goto end;
	}
	if (s.size() != 26) {
		for (int i = 0; i < s.size(); i++)cnt[s[i] - 'a']++;
		for (int i = 0; i < 26; i++) {
			if (cnt[i] == 0) {
				cout << s << (char)(i + 'a') << endl;
				goto end;
			}
		}
	}
	v.push_back(s[25]);
	for (int i = 24; i >= 0; i--) {
		sort(v.begin(), v.end());
		if (s[i] < s[i + 1]) {
			if (i == 0) {
				cout << (char)(s[0] + 1) << endl;
				goto end;
			}
			cout << s.substr(0, i);
			for (int j = 0; j < v.size(); j++) {
				if (s[i] < v[j]) {
					cout << v[j] << endl;
					goto end;
				}
			}
		}
		v.push_back(s[i]);
	}
end:;
	system("PAUSE");
	return 0;
}



Measured memory_bytes: 504
houkou={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
moji="SSSSEEEENEEEENEEEENEEEENWSSSSWSSSSWSSSSWNWSSSSEEEEWSSSSEEEEWSSSSEEEEWNWSSSSEEEEWSSSSEEEEWSSSSEEEEWNWSSSSEEEEWSSSSEEEEWSSSSEEEEWN:"
answer=0

n=int(input())
S=[0]*n
for i in range(n):
  S[i]=list(map(int,input().split()))
  
for i in range(n):
  for j in range(i+1,n):
    for k in range(len(moji)):
      if moji[k]==":":
        answer+=0
        break
      if S[j]==S[i]:
        answer+=1
        break
      S[j]=[S[j][l]for l in houkou[moji[k]]]
if answer==0:
    print("Yes")
else:
    print("No")


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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
const int mx = 1000005 ;
bool mark[mx] ;


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k, node, x=1 ;
	cin >> k ;
	node = (7%k) ;
	mark[node] =1 ;
	if(node == 0){
		cout << x ;
		return 0 ;
	}
	while(1){
		x++ ;
		int nodex = (node*10+7)%k ;
//		cout << node << ' ' << nodex << ' ' << mark[nodex] <<'\n' ;
		if(mark[nodex]){
			break ;
		}
		if(nodex == 0){
			mark[nodex] = 1 ;
			break ;
		}
		mark[nodex] = 1 ;
		node = nodex ;
	}
	if(mark[0] == 1){
		cout << x ;
	}
	else{
		cout << -1 << '\n' ;
	}
	
	return 0 ;
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int weight[107];
int value[107];

const long long INF = 1e18L + 5;  

void min_self ( int& a, int b  ) {
	a = min (a, b);
}

void max_self ( int& a, int b  ) {
	a = max (a, b);
}

signed
main () {
	
	int n, w;
	std::cin >> n >> w;
	int sum = 0; 
 	for ( int i = 0; i < n; ++i  ) {
		std::cin >> weight[i] >> value[i];
		sum = sum + value[i]; 
	}
	// minimum weight for value i 
	std::vector< int  > dp( sum + 1, INF );
	dp[0] = 0;
	for ( int item = 0; item < n; ++item ) {
		for ( int val = sum; val >= 0; --val ) {
			if ( val + value[item] <= sum  ) {
				min_self( 
					dp[val + value[item]], 
					dp[val] + weight[item] 
				);
			}
		}
	}
	int answer = 0;
	for ( int i = sum; i >= 0; --i ) {
		if ( dp[i] <= w ) {
			answer = i;
			break;
		}
	}
	std::cout << answer << '\n'; 
	return 0;
}


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

#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 1000;

string a[MAXN];

int main() {

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

    {
        bool flag = false;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (a[i][j] != '.') {
                    flag = true;
                    break;
                }
        if (!flag) {
            cout << -1;
            return 0;
        }
    }

    int id = -1;
    int minw = 1e9;
    for (int i = 0; i < n; i++) {
        int white = 0;
        bool flag = false;
        for (int j = 0; j < n; j++)
            if (a[i][j] == '.')
                white++;

        for (int j = 0; j < n; j++)
            if (a[j][i] == '#') {
                flag = true;
                break;
            }

        if (!flag)
            white++;
        minw = min(white, minw);
        id = i;
    }

    for (int i = 0; i < n; i++) {
        bool flag = false;
        for (int j = 0; j < n; j++)
            if (a[j][i] == '.') {
                flag = true;
                break;
            }
        if (!flag)
            minw--;
    }
    if (id == -1)
        cout << -1;
    else
        cout << minw + n;

    return 0;
}

Measured memory_bytes: 512
require 'set'
S = gets.chomp.chars
K = gets.to_i

if Set.new(S).size == 1
  puts S.size * K / 2
  exit 0
end

count = 0
prev = '*'
S.each.with_index do |ch, i|
  if prev == ch
    prev = '*'
    count += 1
  else
    prev = ch
  end
end
prefix_count = S.take_while { |ch| ch == S[0] }.count
suffix_count = S.reverse.take_while { |ch| ch == S[0] }.count
if prefix_count.odd? && suffix_count.odd?
  ans = count * K + (K - 1)
  puts ans
else
  ans = count * K
  puts ans
end


Measured memory_bytes: 2172
/********************************************//**
 ****** Author: Shivam Kejriwal *****************
 ****** Handle: techno_phyle    *****************
 ***********************************************/

#include<bits/stdc++.h>
using namespace std;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;

#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
typedef pair<double, long> key;

struct comp {
    bool operator()(pair<int,int> p1, pair<int,int> p2) {
        if (p1.first < p2.first) return false;
        if (p2.first < p1.first) return true;
        return p1.second < p2.second;
    };
};
//greater<pair<int,int> , greater<int>>
const ll INF = 1e18L + 5;
//int dp[N][3];
int main(){
	fastIO;
    //#ifndef ONLINE_JUDGE
    //    freopen("../input.txt", "r", stdin);
    //    freopen("../output.txt","w",stdout);
    //#endif	
    int n;
    cin >> n;
    double p[n+1];
    for(int i=1;i<=n;i++) cin >> p[i];
    double dp[n+1][n+1];
    memset(dp , 0 ,sizeof(dp));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++) dp[i][0] = dp[i-1][0]*(1 - p[i]);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1 - p[i]);
        }
    }
    double ans = 0;
    std::cout << std::fixed << std::setprecision(10);
    for(int j=0;j<=n;j++){
        if(j>n/2){
            ans += dp[n][j];
        }
    }
    std::cout << ans << endl;
	return 0;

}



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

using namespace std;

int main()
{
	string s;
	
	cin >> s;
	
	bool A = false;
	bool C = false;
	
	A = (s[0] == 'A');
	
	for(int i = 1; i < s.size(); i++)
	{
		if(s[i] == 'C')
		{
			if(i == 1 || i == s.size() - 1)
			{
				cout << "WA" << endl;
				return 0;
			}
			if(!C) C = true;
			else
			{
				cout << "WA" << endl;
				return 0;
			}
		}
		else
		{
			if(s[i] < 'a')
				A = false;
		}
	}
	
	if(A && C) cout << "AC" << endl;
	else cout << "WA" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Long A = sc.nextLong();
    Double B = sc.nextDouble();
    BigDecimal ad = new BigDecimal(String.valueOf(A));
    BigDecimal bd = new BigDecimal(String.valueOf(B));
    BigDecimal bd3 = bd.setScale(2, RoundingMode.DOWN);
    BigDecimal bd4 = ad.multiply(bd3);
    System.out.println(bd4.setScale(0, RoundingMode.DOWN));

  }

  
}

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

const int N = 210;
const int M = 8;
const int inf = 0x3f3f3f3f;

int n, m, r, a[M], d[N][N], dp[1<<M][M];

int main(){
	scanf("%d %d %d", &n, &m, &r);
	for(int i=0; i<r; i++)	scanf("%d", a+i);
	int x, y, z;
	memset(d, 0x3f, sizeof(d));
	memset(dp, 0x3f, sizeof(dp));
	for(int i=1; i<=n; i++)	d[i][i] = 0;
	while(m--){
		scanf("%d %d %d", &x, &y, &z);
		d[x][y] = d[y][x] = min(d[x][y], z);
	}
	for(int k=1; k<=n; k++){
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	for(int i=0; i<r; i++){
		dp[1<<i][i] = 0;
	}
	for(int i=1; i<(1<<r); i++){
        for(int j=0; j<r; j++){
			if(!(i >> j & 1))	continue;
			for(int k=0; k<r; k++){
				if(i >> k & 1)	continue;
				dp[i | (1<<k)][k] = min(dp[i | (1<<k)][k], dp[i][j] + d[a[j]][a[k]]);
			}
        }
	}
	int ans = inf;
	for(int i=0; i<r; i++){
		ans = min(ans, dp[(1<<r) - 1][i]);
	}
	printf("%d\n", ans);
	return 0;
}


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

template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

int n,a[110];
using P = pair<int,int>;
P dp[110][50010];

P operator+(const P &p1,const P &p2){
	return P(p1.first + p2.first,p1.second + p2.second);
}

void solve(){
	const int INF = 1e+9;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= n * 500;j++) dp[i][j] = P(-INF,-INF);
	}
	dp[0][0] = P(0,0);
	for(int i = 0;i < n;i++){
		int b = (a[i] % 1000 ? a[i] % 1000 : 1000);
		for(int j = 0;j <= n * 500;j++){
			chmax(dp[i + 1][j],dp[i][j]);
			if(j + 500 - b >= 0 && j + 500 - b <= n * 500) chmax(dp[i + 1][j + 500 - b],dp[i][j] + P(1,-a[i]));
			if(b > 500 && j + 1000 - b <= n * 500) chmax(dp[i + 1][j + 1000 - b],dp[i][j] + P(0,-a[i]));
		}
	}
	P ans(-INF,-INF);
	for(int i = 0;i <= n * 500;i++){
		chmax(ans,dp[n][i]);
	}
	cout << ans.first << " " << -ans.second << endl;
}

signed main(){
	while(cin >> n,n) solve();
}



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

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            for(int i = 1; i <= x; i++)
            {
                if (100 * i <= x && x <= 105 * i)
                {
                    Console.WriteLine(1);
                    return;
                }
            }
            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 11092