akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int N;
    R(N);
    VI A(N+1);
    FOR(i,1,N)R(A[i]);
    LL base=1000;
    for(int i=1,j;i<=N;i=j){
        for(j=i+1;j<=N&&A[j]>=A[j-1];j++);
        base+=base/A[i]*(A[j-1]-A[i]);
    }
    W(base);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>
int main(void)
{
 long int A,B,K;
 long int ans1,ans2;
 scanf("%ld %ld %ld",&A,&B,&K);
 ans1 = A-K;
 ans2 = A+B-K;

 if(ans1>=0) printf("%ld %ld\n",ans1,B);
 else if(ans1<0&&ans2>=0) printf("0 %ld\n",ans2);
 else printf("0 0\n");

 return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  int ans = 0;
  map<pair<int,int>, int> mp;
  for(int i=1; i<=N; i++){
    int a = i;
    string sa = to_string(a);
    int head = (int)(sa[0]-'0');
    int tail = (int)(sa.back()-'0');
    mp[{head, tail}]++;
  }
  for(int i=1; i<=N; i++){
    int a = i;
    string sa = to_string(a);
    int head = (int)(sa[0]-'0');
    int tail = (int)(sa.back()-'0');
    ans += mp[{tail, head}];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int x,a,b;
    cin >> x >> a >> b;
    x-=a;
    cout << x%b <<endl;
    return 0;
}


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

int main(){
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 1; i <= s.size() / 2; i++) {
        if (s.at(i - 1) != s.at(s.size() - i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        if (s[i] == 'A') {
            if (s[i+1] == 'B') {
                if (s[i+2] == 'C') {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int a,b,c,d;
int yes=0;
scanf("%d %d %d %d",&a,&b,&c,&d);

for(int i=0;i<105;i++){
    if((a<=i&&i<=b)&&(c<=i&&i<=d)){yes++;}
}
if(yes>0){yes=yes-1;}
printf("%d\n",yes);
}

Measured memory_bytes: 128
x1,y1,x2,y2=map(int,input().split())
x3=x2-(y2-y1)
y3=y2+(x2-x1)
x4=x1+(y1-y2)
y4=y1-(x1-x2)
lst=[x3,y3,x4,y4]
print(*lst)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	string ans = "UNRESTORABLE";
	for (int i = 0; i < s.size() - t.size() + 1; i++) {
		string sc = s;
		for (int j = 0; j < t.size(); j++) {
			if (sc[i + j] == '?' || sc[i + j] == t[j])sc[i + j] = t[j];
			else goto hell;
		}
		for (int i = 0; i < sc.size(); i++)if (sc[i] == '?')sc[i] = 'a';
		if (ans == "UNRESTORABLE")ans = sc;
		else if (ans > sc)ans = sc;
	hell:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 504
import math

def main():
    A, B, H, M = map(int, input().split())

    ans = (A**2 + B ** 2 - 2 * A * B * math.cos(abs(math.radians(360*H/12) + math.radians(30 * M / 60) - math.radians(360*M/60)))) ** 0.5

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 503
#define MXC 33

int N,C,
	D[MXC][MXC],
	a[MXN][MXN],
	colorsum[3*MXN][MXC];//cs[i][j]:对角线i,变成颜色j的总花费！！！！！
long long
	ans=1000000000000000000;

inline void Judge(int a1, int a2, int a3){
	long long cnt=0;
	int color[3];
	color[1]=a1;
	color[2]=a2;
	color[0]=a3;
	for(int i=2,lim=2*N+1;i<lim;i++)
		cnt+=colorsum[i][color[i%3]];



	//printf("%d,%d,%d,%lld\n",color[2],color[0],color[1],cnt);
	ans=std::min(ans,cnt);
}

inline int Girl(){
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch) ch=getchar();
	while('0'<=ch && ch<='9') x=10*x+ch-'0',ch=getchar();
	return x;
}

int main(){

	scanf("%d%d",&N,&C);
	for(int i=1;i<=C;i++)
		for(int j=1;j<=C;j++)
			scanf("%d",&D[i][j]);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			scanf("%d",&a[i][j]);

	for(int k=1;k<=C;k++)
		for(int i=1;i<=N;i++)
			for(int j=1;j<=N;j++)
				colorsum[i+j][k]+=D[a[i][j]][k];

	for(int i=1;i<=C;i++){
		for(int j=1;j<=C;j++){
			if(i==j)continue;
			for(int k=1;k<=C;k++){
				if(i==k || j==k)continue;
				Judge(i,j,k);
			}
		}
	}

	printf("%lld\n",ans);
	//system("pause");
	return 0;
}


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

int main(){
	int n[101];
	int i,a;
	cin>>a;
	for (i = 1 ; i <= a ; i++){
		cin>>n[i];
	}
	for (i = a ; i >= 1 ; i--){
		if (i == 1){
			cout<<n[i];
		}else{
		cout<<n[i]<<" ";
		}
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  vector<double> a(n); REP(i,n) cin >> a[i];

  double ans=0;
  REP(i,n) ans+= 1/a[i];

  cout << fixed << setprecision(10) << 1/ans << endl;
  return 0;
}


Measured memory_bytes: 256
open Scanf
open Printf

let () = scanf "%d %d" (fun x y->
  if   ((x = 1 || x = 3 || x = 5 || x = 7 || x = 8 || x = 10 || x = 12)  &&
       (y = 1 || y = 3 || y = 5 || y = 7 || y = 8 || y = 10 || y = 12))
    || ((x = 4 || x = 6 || x = 9 || x = 11) &&
        ( y = 4 || y = 6 || y = 9 || y = 11))
    || (x = 2 && y = 2)
    then "Yes" else "No"
  ) |> printf "%s\n"

Measured memory_bytes: 3656
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val (n, a, b) = longList()
    val x = longList()
    var t = 0L
    0.until(n.toInt() - 1).forEach {
        val from = x[it]
        val to = x[it + 1]
        val diff = to - from
        val ad = diff * a
        if (ad > b) {
            t += b
        } else {
            t += ad
        }
    }
    println(t.toString())
}


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


using namespace std;

int main()
{
    int n,d,i,j,sum,count1=0,c;
    cin>>n>>d;
    int a[n][d];
    float k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            cin>>a[i][j];
        }
    }
    c=0;
    while(c<n)
    {
     for(i=c+1;i<n;i++)
      {
        sum=0;
        for(j=0;j<d;j++)
        {
            sum=sum+((a[c][j]-a[i][j])*(a[c][j]-a[i][j]));
        }
       k=sqrt(sum);
       if(floor(k)==ceil(k))
           count1=count1+1;
     }
     c++;
    }
    cout<<count1<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;

    cout << (b / k == (a - 1) / k ? "NG" : "OK") << endl;

    return 0;
}


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

typedef long long ll;
const int mod=1145411919;
const int p=810;

string s,t;
int ans;
ll pw[16000005];
ll h[16000005];
ll ht[16000005];
int suf[16000005];

inline ll gh(int x){
    if(x+t.size()>s.size())return -1;
    return (h[x+t.size()-1]-h[x-1]*pw[t.size()]%mod+mod)%mod;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>s>>t;
    while(s.size()<t.size()*2)s=s+s;
    s=s+s;
    s=s+s;
    s=s+s;
    pw[0]=1;
    for(int i=1;i<=16000000;i++){
        pw[i]=pw[i-1]*p%mod;
    }
    h[0]=s[0]-'a'+1;
    for(int i=1;i<s.size();i++){
        h[i]=(h[i-1]*p+s[i]-'a'+1)%mod;
    }
    ht[0]=t[0]-'a'+1;
    for(int i=1;i<t.size();i++){
        ht[i]=(ht[i-1]*p+t[i]-'a'+1)%mod;
    }
    for(int i=0;i<s.size();i++){
        suf[i]=ht[t.size()-1]==gh(i);
    }
    for(int i=s.size()-t.size();i>=0;i--){
        if(suf[i])suf[i]+=suf[i+t.size()];
        ans=max(ans,suf[i]);
    }
    if(ans+1>=s.size()/t.size()){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 337624
import { readFileSync } from 'fs'

function main(input: string) {
  const [n, ...hotels] = input.trim().split(/\s/).map(Number)

  const { count } = hotels.reduce(
    (acc, hotel) => hotel < acc.max ? acc : { max: hotel, count: acc.count + 1 },
    { max: 0, count: 0 }
  )

  console.log(count)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7500
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<set>
#include<cmath>
#define mod 1000000007
#define inf 1000000000000000
#define int long long int
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int n;
     cin>>n;
     int arr[n+1];
     int j;
     for(j=1;j<=n;j++)
     {
		 cin>>arr[j];
	 }
	 int value[n+1]={0};
	 for(j=n;j>=1;j--)
	 {
		 int sum=0;
		 for(int i=2;i*j<=n;i++)
		 {
			 sum+=value[i*j];
			 sum%=2;
		 }
		 if(sum==arr[j])
		    value[j]=0;
		 else
		   value[j]=1;
	 }
	 vector<int> vec;
	 for(j=1;j<=n;j++)
     {
		 if(value[j])
		 {
			 vec.push_back(j);
		 }
	 }
	 cout<<vec.size()<<endl;
	 for(int x:vec)
	   cout<<x<<" ";
	 cout<<endl;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, k; cin >> n >> k;

    vector<int> cnt(n, 0);

    for (int i = 0; i < k; ++i) {
        int d; cin >> d;

        for (int j = 0; j < d; ++j) {
            int a; cin >> a;
            --a;

            cnt[a]++;
        }
    }

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        if (cnt[i] == 0) ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (h = 0; h < H; h++) {
            for (w = 0; w < W; w++) {
                putchar(((h & 1) ^ (w & 1)) == 0 ? '#' : '.');      }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2120
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

string s;
set<char> t;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	for (char c = 'a'; c <= 'z'; c++)
		t.insert(c);
	for (char c : s)
		t.erase(c);
	if (t.size())
		cout << s + *t.begin() << endl;
	else {
		int ind;
		for (ind = s.size() - 2; ind >= 0; ind--)
			if (s[ind] < s[ind + 1])
				break;
		if (ind == -1)
			return cout << -1 << endl, 0;
		char c = 'z';
		for (int i = ind + 1; i < s.size(); i++)
			if (s[ind] < s[i] && s[i] < c)
				c = s[i];
		for (int i = 0; i < ind; i++)
			cout << s[i];
		cout << c << endl;
	}
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_char {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (s, w) = get!(usize, usize);
    println!("{}", if s <= w {"unsafe"} else {"safe"});
}


Measured memory_bytes: 2072
import sys
bbn=1000000007
	
#+++++

		
def main():
	s = input()
	alp='abcdefghijklmnopqrstuvwxyz'
	ii=alp.index(s)
	ret=alp[ii+1]
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
f=lambda:map(int,input().split())
n,m=map(int,input().split())
g=[[0]*n for _ in range(n)]
for i in range(m):
  a,b=f()
  g[a-1][b-1]=1
  g[b-1][a-1]=1
import itertools as it
c=0
for t in it.permutations(range(1,n)):
  p=0
  for q in t:
    if g[p][q]<1: break
    p=q
  else: c+=1
print(c)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include  <string>
#include <cmath>

using namespace std;

int main(){
  unsigned long long x;
  cin >> x;
  unsigned long long money = 100;
  long long count = 0;
  while (money < x){
    money *= 1.01;
    count++;
  }
  cout << count << "\n";
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
int main(){
    double A,B,H,M;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    printf("%.10f",sqrt(A*A+B*B-2*A*B*cos((60*H+M)*2*3.141592653590/60*11/12)));
    return 0;
}

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

int main(){
    int N,K;
    string S;
    cin >> N >> S >> K;
    char Judge = S[K-1];
    for(int i = 0; i < N; i++)
    {
        if(S[i] != Judge) S[i] = '*';
    }
    cout << S << endl;
}

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

enum boolean { true, false };
struct node {
  enum boolean is_connected_to[101];
  int distance;
};
struct node graph[101];
int queue[101], head = 1, tail = 1;

void enqueue(int node) {
  queue[tail++] = node;
}

int dequeue() {
  return head != tail ? queue[head++] : -1;
}

void breadthSearch(int current_node) {
  if(current_node == -1) return;

  int i, d = graph[current_node].distance + 1;

  for(i = 1;i < 101;i++) {
    if(graph[current_node].is_connected_to[i] == true && graph[i].distance == -1) {
      enqueue(i);
      graph[i].distance = d;
    }
  }

  breadthSearch(dequeue());
}

int main() {
  int n, i, j, k, node, direction;

  for(i = 1;i < 101;i++) {
    graph[i].distance = -1;

    for(j = 1;j < 101;j++)
      graph[i].is_connected_to[j] = false;
  }

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%d %d", &node, &k);
    for(j = 0;j < k;j++) {
      scanf("%d", &direction);
      graph[node].is_connected_to[direction] = true;
    }
  }

  graph[1].distance = 0;
  breadthSearch(1);

  for(i = 1;i < n + 1;i++) {
    printf("%d %d\n", i, graph[i].distance);
  }
}



Measured memory_bytes: 2040
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dpa[15], dpb[15];
pii solve(vector<int> perm) {
    memset(dpa, 0, sizeof(dpa));
    memset(dpb, 0, sizeof(dpb));

    int N = perm.size();
    for(int i=0; i<N; i++) {
        int maa = 0, mab = 0;
        for(int j=0; j<i; j++) {
            if(perm[j] < perm[i]) chmax(maa, dpa[j]);
            if(perm[j] > perm[i]) chmax(mab, dpb[j]);
        }
        dpa[i] = maa + 1;
        dpb[i] = mab + 1;
    }
    int ra = *max_element(dpa, dpa+N);
    int rb = *max_element(dpb, dpb+N);
    return make_pair(ra, rb);
}
 
signed main() {
    int N, A, B; cin >> N >> A >> B;
    if(A+B-1 <= N && N <= A*B) {
        vector<int> buckets;
        buckets.push_back(A);
        if(B > 1) {
            int div = (N - A) / (B - 1);
            int mo = (N - A) % (B - 1);
            for(int i=0; i<N-1; i++) {
                if(i < mo) buckets.push_back(div + 1);
                else buckets.push_back(div);
            }
        }

        vector<int> ans;
        int sum = 0;
        for(int i=0; i<B; i++) {
            int base = N - sum - (buckets[i] - 1);
            for(int k=0; k<buckets[i]; k++) {
                ans.push_back(base + k);
            }
            sum += buckets[i];
        }
        for(int i=0; i<N; i++) {
            printf("%lld%c", ans[i], (i+1 == N ? '\n' : ' '));
        }
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 12012
n = int(input())
manzoku = []
for i in range(3):
  manzoku.append(list(map(int,input().split(' '))))
#print(manzoku)  
mae_i = -1  
man = 0
for i in manzoku[0]:
  man += manzoku[1][i-1]
#  print(man,i,manzoku[1][i-1])
  if i == mae_i +1:
#    print(manzoku[2][i-2])
    #print('hit')
    man += manzoku[2][i-2]
  mae_i = i

  
print(man)  

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s;
  cin >> s;

  int N = s.size();

  bool flag = true;
  FOR(i, 1, N){
    if(s[i] != '9') flag = false;
  }

  if(flag){
    cout << (s[0]-'0')+9*(N-1) << endl;
  }else{
    cout << (s[0]-'0')+9*(N-1)-1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int kazu,i,j,cnt=0,hz,smi;
		Scanner sca = new Scanner(System.in);
		kazu=sca.nextInt();
		int hai[]=new int[kazu];
		for(i=0;i<kazu;i++){
			hai[i]=sca.nextInt();
		}  
		for(i=0;i<kazu;i++){
			smi=i;
			for(j=i+1;j<kazu;j++){
				if(hai[smi]>hai[j]){
					smi=j;
				}
				}
			if(smi!=i){
				hz=hai[smi];
				hai[smi]=hai[i];
				hai[i]=hz;
				cnt++;
			}
		}
	     for(i=0;i<kazu;i++){
	    	    if(i!=kazu-1){	 
	    	     System.out.print(hai[i]+" ");
	    	     }else{
	    	    	 System.out.println(hai[i]);
	    	     }
	    }
	    	     System.out.println(cnt);

	}
		
	}



Measured memory_bytes: 26340
#include<iostream>
#include "algorithm"
#include "bits/stdc++.h"
#define ll long long
using namespace std ;
int ans=0;
int main(){
    int a,b,p;
    cin>>a>>b>>p;
    for(int i=a;i<=b;i++){
        if(i%p==0)
            ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3628
from collections import deque
import copy
h,w = map(int,input().split())
origin = []
dx = [1,-1,0,0]
dy = [0,0,1,-1]
ans = 0
for i in range(h):
    origin.append(list(input()))
for i in range(h):
    if "#" in origin[i]:
        break
else:
    print(h+w-2)
    exit()
for i in range(h):
    for j in range(w):
        if origin[i][j] == ".":
            d = [[0 for j in range(w)] for i in range(h)]
            maze = copy.deepcopy(origin)
            dq = deque([(j,i)])
            while dq:
                x,y = dq.popleft()
                for k in range(4):
                    nx = x + dx[k]
                    ny = y + dy[k]
                    if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[ny][nx] != "#":
                        dq.append((nx,ny))
                        d[ny][nx] = d[y][x]+1
                        ans = max(ans,d[ny][nx])
                maze[y][x] = "#"
            #print(maze)
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<long long MOD = 1000000007>
struct Mint {
private:
  long long val;

public:
  constexpr Mint(const long long x = 0) noexcept : val(x < 0 ? x % MOD + MOD : x >= MOD ? x % MOD : x) {}
  constexpr Mint &operator+=(const Mint rhs) noexcept {
    if ((val += rhs.val) >= MOD) val -= MOD;
    return *this;
  }
  constexpr Mint &operator-=(const Mint rhs) noexcept {
    if ((val -= rhs.val) < 0) val += MOD;
    return *this;
  }
  constexpr Mint &operator*=(const Mint rhs) noexcept {
    val = val * rhs.val % MOD;
    return *this;
  }
  constexpr Mint &operator/=(Mint rhs) noexcept {
    val = val * rhs.inv().val % MOD;
    return *this;
  }
  constexpr Mint operator+(const Mint& rhs) const noexcept { return Mint(*this) += rhs; }
  constexpr Mint operator-(const Mint& rhs) const noexcept { return Mint(*this) -= rhs; }
  constexpr Mint operator*(const Mint& rhs) const noexcept { return Mint(*this) *= rhs; }
  constexpr Mint operator/(const Mint& rhs) const noexcept { return Mint(*this) /= rhs; }
  constexpr Mint inv() const noexcept { return pow(MOD-2); }
  constexpr Mint pow(long long n) const noexcept {
    Mint ret(1), mul(val);
    while (n) {
      if (n % 2) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  constexpr bool operator==(const Mint& rhs) const noexcept { return val == rhs.val; }
  constexpr bool operator!=(const Mint& rhs) const noexcept { return val != rhs.val; }
  friend ostream &operator<<(ostream &os, const Mint<MOD> &x) { return os << x.val; }
  friend istream &operator>>(istream &is, Mint<MOD> &x) {
    long long t;
    is >> t;
    x.val = t % MOD;
    return is;
  }
};

int h, w, k;

bool check(int x) {
  bool ret = true;
  rep(i, w-2) {
    if (x & (1<<i) && x & (1<<(i+1))) ret = false;
  }
  return ret;
}

int main() {
  cin>>h>>w>>k;
  if (w==1) {
    print(1);
    return 0;
  }
  Mint<> dp[110][10] = {};
  dp[0][0] = 1;
  rep(i, h) {
    rep(j, 1<<(w-1)) {
      if (!check(j)) continue;
      rep(k, w-1) {
        if (j & 1<<k) {
          dp[i+1][k] += dp[i][k+1];
          dp[i+1][k+1] += dp[i][k];
        }
      }
      if (!(j & 1<<0)) dp[i+1][0] += dp[i][0];
      if (!(j & 1<<(w-2))) dp[i+1][w-1] += dp[i][w-1];
      rep(k, w-2) {
        if (!(j & (1<<k)) && !(j & (1<<(k+1)))) {
          dp[i+1][k+1] += dp[i][k+1];
        }
      }
    }
  }
  print(dp[h][k-1]);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double flt;
typedef pair<int, int> PII;
const flt eps = 1e-8;

struct Point {
  flt x, y;
  Point() {}
  Point(flt x, flt y): x(x), y(y) {}
  Point(const Point &a): x(a.x), y(a.y) {}
  Point operator + (const Point &rhs) const {
    return Point(x + rhs.x, y + rhs.y);
  }
  Point operator - (const Point &rhs) const {
    return Point(x - rhs.x, y - rhs.y);
  }
  Point operator * (const flt k) const {
    return Point(x * k, y * k);
  }
  Point operator / (const flt k) const {
    return Point(x / k, y / k);
  }
  flt det(const Point &rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  flt dot(const Point &rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  flt sqr() const {
    return x * x + y * y;
  }
  flt abs() const {
    return hypot(x, y);
  }
};

int sgn(flt x) {
  if (x < -eps) return -1;
  else return x > eps;
}

Point sym(const Point &O, const Point &A, const Point &B) {
  if (sgn((A - O).det(B - O)) == 0) return O;
  Point AB = B - A;
  Point AP = AB * ((O - A).dot(AB) / AB.sqr());
  return O + (A - O + AP) * 2.0;
}

Point inter(const Point &A, const Point &B, const Point &C, const Point &D) {
  Point AB = B - A, CD = D - C;
  return A + AB * (CD.det(C - A) / CD.det(AB));
}

struct Factor {
  Point A, B;
  int type;// 0 point, 1 line
  Factor() {}
  Factor(const Point &a) : A(a), type(0) {}
  Factor(const Point &a, const Point &b): A(a), B(b), type(1) {}
  Factor operator + (const Factor &rhs) const {
    if (type == 0) {
      if (rhs.type == 0) return Factor(A, rhs.A);
      else return Factor(sym(A, rhs.A, rhs.B));
    }
    else if (type == 1) {
      if (rhs.type == 0) return Factor(sym(rhs.A, A, B));
      else return Factor(inter(A, B, rhs.A, rhs.B));
    }
    else assert(false);
  }
  void print() {
    printf("%.10f %.10f\n", A.x, A.y);
  }
};

char s[200], *p;

bool check(char c) {
  return c == '-' || isdigit(c);
}

int getInt() {
  int sgn = 1, ret = 0;
  if (*p == '-') ++ p, sgn = -1;
  while (isdigit(*p)) ret = ret * 10 + (*p - '0'), ++ p;
  return sgn * ret;
}

Point getP() {
  int x = getInt(); ++ p;
  int y = getInt();
  return Point(x, y);
}

int main() {
  while (scanf("%s", s) == 1 && s[0] != '#') {
    stack<char> op;
    stack<Factor> num;
    for (p = s; *p; ) {
      if (*p == '(') {
        if (check(*(p + 1))) {
          ++ p;
          Factor now(getP());
          ++ p;
          while (!op.empty() && op.top() == '@') {
            Factor pre = num.top(); num.pop(); op.pop();
            now = now + pre;
          }
          num.push(now);
        }
        else op.push('('), ++ p;
      }
      else if (*p == ')') {
        assert(op.top() == '('); 
        op.pop(); ++ p;
        Factor now = num.top(); num.pop();
        while (!op.empty() && op.top() == '@') {
          Factor pre = num.top(); num.pop(); op.pop();
          now = now + pre;
        }
        num.push(now);
      }
      else if (*p == '@') {
        op.push('@'); ++ p;
      }
    }
    num.top().print();
  }
  return 0;
}

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

int n;
vector<string> v;

#define MAX 100002
char buf[MAX];
string t;

string conv(string f,char tt){
	for (int i = 0; i < f.size(); i++){
		if (f[i] == '?'){
			f[i] = tt;
		}
	}
	return f;
}
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%s", buf);
		v.push_back(buf);
	}
	cin >> t;
	int LES = 0;
	int B = 0;
	for (int i = 0; i < n; i++){
		bool can_less = (conv(v[i], 'a')  <= t);
		bool can_great = (conv(v[i], 'z') >= t);
		if (can_less == false || can_great == false){
			if (can_less == true){
				LES++;
			}
		}
		else{
			B++;
		}
	}
	for (int i = 0; i <= B; i++){
		if (i){
			printf(" ");
		}
		printf("%d", LES + i + 1);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
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 mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

signed main() {
	int n;
	cin >> n;
	int a[100005];
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, n - 1) {
		if (a[i + 1] <= a[i]) {
			ans++;
		}
	}
	cout << ans + 1 << endl;
	cout << n << endl;

	return 0;
}



Measured memory_bytes: 3880
open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f

let print_array a = Array.to_list a |> List.map string_of_int |> String.concat " " |> print_endline
                                                                                        
let selection_sort a n =
  let rec iter i j minj c =
    if i = n then c
    else if j = n then begin
        if i = minj then iter (i+1) (i+1) (i+1) c
        else begin
            let t = a.(i) in
            a.(i) <- a.(minj);
            a.(minj) <- t;
            iter (i+1) (i+1) (i+1) (c+1)
          end
      end
    else
      if a.(j) < a.(minj) then iter i (j+1) j c
      else iter i (j+1) minj c
  in iter 0 0 0 0

let () =
  let n = read_int () in
  let ar = Array.of_list (read_list int_of_string) in
  let c = selection_sort ar n in
  print_array ar ; print_endline (string_of_int c)

Measured memory_bytes: 2188
s = list(range(1, 14))
h = list(range(1, 14))
c = list(range(1, 14))
d = list(range(1, 14))

n = int(input())

for i in range(n):
    cards = input().split()

    if cards[0] == 'S':
        s.remove(int(cards[1]))
    elif cards[0] == 'H':
        h.remove(int(cards[1]))
    elif cards[0] == 'C':
        c.remove(int(cards[1]))
    elif cards[0] == 'D':
        d.remove(int(cards[1]))

for j in s:
    print('S ' + str(j))

for j in h:
    print('H ' + str(j))

for j in c:
    print('C ' + str(j))

for j in d:
    print('D ' + str(j))


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

long long f[20001];
int n,h;

int main()
{
	int x,y;
	cin>>h>>n;
	for(int i=1;i<=20000;i++)
		f[i]=1e18;
	f[0]=0;
	
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		for(int j=0;j<h;j++) 
		   f[j+x]=min(f[j+x],f[j]+y);
	}
	
	long long minn=1e18;
	for(int i=h;i<=20000;i++) 
	   minn=min(minn,f[i]);
	
	cout<<minn<<endl;
	return 0;
} 

Measured memory_bytes: 512
import re  # 正規表現, findall('正規表現', 文字列), search('正規表現', 文字列)
import sys # プログラム終了：sys.exit()
# sys.setrecursionlimit(10**6) # 再帰呼び出しの上限を上げる

def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
# 文字列のまま受け取りたいときはinput()

def main():
    N, Y = s_input()

    for a in range(N + 1):
        for b in range(N + 1 - a):
            c = N - a - b
            abc_sum = 10000 * a + 5000 * b + 1000 * c
            if abc_sum == Y:
                print('{} {} {}'.format(a, b, c))
                sys.exit()
            # diff = Y - 10000 * a + 5000 * b
            # c = diff // 1000
            # if a + b + c == N:
            #     print('{} {} {}'.format(a, b, c))
            #     sys.exit()

    print('-1 -1 -1')


# def check(N, Y, a, b):
#     c_max = N - a - b
#     diff = Y - 10000 * a + 5000 * b
#     if diff >= 0 and diff % 1000 == 0 and diff // 1000 <= c_max:
#         return True
#     else:
#         return False

if __name__ == "__main__":
    main()

Measured memory_bytes: 38896
A,B,C,D,E,F = map(int,input().split())
ans = []
def my_max(x,y):
    if x[0] < y[0]:
        return y
    else:
        return x
maxi = [0,0,0]
for a in range(F // (A*100) + 1):
    for b in range(F // (B*100) + 1):
        water =  100*a*A + 100*b*B 
        if water <= F:
            for c in range(E*water//100//C+1):
                for d in range(E*water//100//D+1):
                    suger = C*c + D*d
                    if suger+water <= F and E*water//100 >= suger \
                    and water + suger > 0:
                        t = (suger/(suger+water),suger+water,suger)
                        maxi = my_max(t,maxi)
ans.sort()
print(maxi[1],maxi[2])

Measured memory_bytes: 42732
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b){cout << c << endl;}
    else if(a == c){cout << b << endl;}
    else{cout << a << endl;}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
cout<<a[n/2]-a[n/2-1];
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <vector>

using namespace std;

inline int abs_needed (int y, int x) {
  // 0, 0 = 0 ok
  // 1, 0 = 1 ok
  // 1, 1 = 1 ok
  // 2, 0 = 2 ok
  // 2, 1 = 0 ok
  // 2, 2 = 2 ok
  // 3, 0 = 3 ok
  // 3, 1 = 1 ok
  // 3, 2 = 1
  // 3, 3 = 3
  // 4, 0 = 4
  // 4, 1 = 2
  // 4, 2 = 0
  // 4, 3 = 2
  // 4, 4 = 4
  // 5, 0 = 5
  // 5, 1 = 3
  // 5, 2 = 1
  // 5, 3 = 1
  // 5, 4 = 3
  // 5, 5 = 5
  x = (x > y/2) ? y - x : x;
  return y - x * 2;
}

inline int answer(int N, vector<int> *vectors) {
  int ways = 1;
  for (int n = 0; n < N; n++) {
    vector<int> v = vectors[abs_needed(N-1, n)];
    // cout << "size[" << n << "]=" << v.size() << " z=" << abs_needed(N-1, n) << endl;
    if (v.size() == 0) {
      ways = 0;
      break;
    }

    ways = (ways * v.size()) % ((int)pow(10, 9) + 7);
    vectors[abs_needed(N-1, n)].pop_back();
  }

  return ways;
}

int main() {
  int N;
  vector<int> *A;

  cin >> N;
  A = new vector<int>[N];
  for (int n = 0; n < N; n++) {
    int a;
    cin >> a;
    A[a].push_back(n);
  }

  int ways = answer(N, A);
  cout << ways << endl;
  return 0;
}


Measured memory_bytes: 4608
# coding: utf-8
# Your code here!

N,A,B = map(int,input().split())

def sum(a):
    b = 0
    while a != 0:
        b = b + a % 10
        a = a // 10
        
    return b
    
a = 1
c = 0

while a <= N:
    if A <= sum(a) <= B:
        c = c + a
        
    else:
        pass
    
    a += 1
    
print(c)

Measured memory_bytes: 3064
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
c, result = 0, 0
for d in D:
  if d[0]==d[1]:
    c += 1
  else:
    c = 0
  if c>=3:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 9172
#include <stdio.h>
#include <limits.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#define swap(type, x, y) do{type temp = x; x = y; y = temp;}while(0);
using namespace std;
int main(void) {
    int num;
    
    while(1) {
        int i, j, value;
        long long int ans = INT_MIN;
        scanf("%d", &num);
        if(num == 0) break;
        long long int sum[num + 1];
        
        for(i = 0; i < num + 1; i++) {
            sum[i] = 0;
        }
        
        for(i = 0; i < num; i++) {
            scanf("%d", &value);
            sum[i + 1] += sum[i] + value;
        }
        for(i = 0; i < num + 1; i++) {
            for(j = i + 1; j < num + 1; j++) {
                long long int psum = sum[j] - sum[i];
                if(psum > ans) ans = psum;
            }
        }
        cout << ans << endl;
    }
    
    return(0);
}

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

string t, l, ad, ar, d, r;
int ct, cl;
char cc;

void push_right() {
  r += cc;
  cc = l[cl++];
}

void push_down() {
  d += cc;
  cc = t[ct++];
}

bool rec(int s) {
  char tmpc;
  if(s == t.length()+l.length() - 1) {
    int f;
    if(d.length() != t.length()) {
      d += cc;
      f = 0;
    } else {
      r += cc;
      f = 1;
    }
    if(d == ad) {
      ar = r;
      return true;
    }
    if(f == 0) d = d.substr(0, d.length()-1);
    else       r = r.substr(0, r.length()-1);
    return false;
  }
  if(d.length() != 0 && d[d.length()-1] != ad[d.length()-1]) return false;
  if(cl < l.length()) {
    tmpc = cc;
    push_right();
    if(rec(s+1)) return true;
    r = r.substr(0, r.length()-1);
    cl--;
    cc = tmpc;
  }
  if(ct < t.length()) {
    tmpc = cc;
    push_down();
    if(rec(s+1)) return true;
    d = d.substr(0, d.length()-1);
    ct--;
    cc = tmpc;
  }
  return false;
}

string solve() {
  cc = l[0];
  r = d = "";
  ct = 0;
  cl = 1;
  if(rec(0)) {
    return ar;
  } else {
    return "NA";
  }
}

int main() {
  while(1) {
    cin >> t;
    if(t == "-") break;
    cin >> l;
    cin >> ad;
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long n,l,ans;
int main()
{
	string a[200010];
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=a[i+1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9864
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;

    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int a[3];
  int maxa=0;
  int sum=0;

  cin >> a[0] >> a[1] >> a[2];
  for(int i=0; i<3; i++){
    maxa=max(maxa, a[i]);
  }

  int b[3]={};

  for(int i=0; i<3; i++){
    b[i]=maxa-a[i];
    sum+=maxa-a[i];
  }
  int ans=0;

  if(sum%2==0){
    bool flag=false;
    for(int i=0; i<3; i++){
      if(b[i]%2==1){
        if(flag)ans++;
        flag=!flag;
      }
      ans+=b[i]/2;
    }
  }else{
    for(int i=0; i<3; i++){
      b[i]++;
    }
    bool flag=false;
    for(int i=0; i<3; i++){
      if(b[i]%2==1){
        if(flag)ans++;
        flag=!flag;
      }
      ans+=b[i]/2;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "Yes"
#define __FALSE "No"
using namespace std;

int main() {
  string s;
  cin >> s;
  int max=700;
  for(int i=0;i<s.size();i++) {
    if(s[i] == 'o') {
      max += 100;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#Problem C

X, K, D = list(map(int,input().split()))

T_min = abs(X)//D
ans = 0

if abs(X) > K*D:
    print(abs(X) - K*D)
    exit()
elif T_min > K:
    print(abs(X) - K*D)
    exit()


if (T_min-K)%2 ==0:
    ans = abs(abs(X) - (T_min*D))
else:
    ans1 = abs(abs(X) - (T_min*D) + D)
    ans2 = abs(abs(X) - (T_min*D) - D)
    ans = min(ans1,ans2)
    
print(ans)

Measured memory_bytes: 61632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(ReadLine());

            double ans = 0;
            for (int i = 0; i < N; i++)
            {
                var raw = ReadLine().Split();
                if (raw[1] == "JPY") ans += double.Parse(raw[0]);
                else ans += 380000 * double.Parse(raw[0]);
            }

            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>

using namespace std;

bool ok(int N, const vector<int>& A)
{
	for (auto x : A) {
		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) {
		cin >> x;
	}

	if (ok(N, A)) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}
}


Measured memory_bytes: 256
n,s=map(int,input().split())
a=list(map(int,input().split()))
mod=998244353
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
  for j in range(s+1):
    dp[i+1][j]+=dp[i][j]*2%mod
    if j-a[i]>=0:
      dp[i+1][j]+=dp[i][j-a[i]]
    dp[i+1][j]%=mod
print(dp[-1][-1])

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

template<typename TWeight>
class Dijkstra {
public:
  std::vector< std::tuple<int, TWeight> > *edges;
  int v;
  TWeight inf;
};

template<typename TWeight>
Dijkstra<TWeight> initDijkstra(int v, TWeight inf) {
  Dijkstra<TWeight> res;
  res.edges = new std::vector< std::tuple<int, TWeight> > [v + 3];
  res.v     = v + 3;
  res.inf   = inf;
  return res;
}

template<typename TWeight>
void addEdge(Dijkstra<TWeight>& x, int from, int to, TWeight w) {
  x.edges[from].push_back(std::make_tuple(to, w));
}

template<typename TWeight>
std::vector<TWeight> eval(Dijkstra<TWeight> x, int source) {
  std::vector<TWeight> res(x.v, x.inf);
  res[source] = 0;
  std::priority_queue< std::tuple<TWeight, int> > q;
  q.push(std::make_tuple(0, source));
  while( not q.empty() ) {
    TWeight base; int id;
    std::tie(base, id) = q.top(); q.pop();
    base = -base;
    for(std::tuple<int, TWeight> edge : x.edges[id]) {
      int next; TWeight dist;
      std::tie(next, dist) = edge;
      auto newdist = base + dist;
      if( newdist >= res[next] ) continue;
      res[next] = newdist;
      q.push(std::make_tuple(-newdist, next));
    }
  }
  return res;
}

int main() {
  int v, e, r;
  scanf("%d %d %d", &v, &e, &r);
  auto graph = initDijkstra<long>(v, (1LL << 55));
  for(int i = 0; i < e; ++i) {
    int s, t; long d;
    scanf("%d %d %ld", &s, &t, &d);
    addEdge(graph, s, t, d);
  }
  auto dists = eval(graph, r);
  for(int i = 0; i < v; ++i) {
    if( dists[i] != graph.inf ) {
      printf("%ld\n", dists[i]);
    }
    else {
      puts("INF");
    }
  }
}

Measured memory_bytes: 19440
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
   int N,K;
   cin >> N >> K;
   vector<int> h;
   for(int i=0; i<N; i++)
   {
   	  int x;
   	  cin >> x;
   	  h.push_back(x);
   }
   sort(h.begin(),h.end());
   int ans = h[K-1]-h[0];
   for(int i=1; i<=N-K; i++)
   {
       ans = min(ans, h[K+i-1]-h[i]);
   }
   cout << ans << endl;

}


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

int main() {
	ll N, A, B; 
	cin >> N >> A >> B;
	vector<ll> x(N);
	for (int i = 0; i < N; ++i) { cin >> x[i]; }

	ll res = 0;
	for (int i = 1; i < N; ++i) {
		ll a = (x[i] - x[i - 1]) * A;
		res += min(a, B);
	}

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


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    
    int n;
    cin >> n;
    int ans = 0;
    while(n >= 500){
        n -= 500;
        ans += 1000;
    }
    while(n >= 5){
        n -= 5;
        ans += 5;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3600