akhauriyash/Code-Regression huggingface dataset:
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math
import math
import time
from queue import Queue
# PradeepGhosh_2017076

def seive(n):
	l=[True]
	l=l*(n+1)
	for i in range(2,int(sqrt(n))+1):
		if(l[i]==True):
			val=i*i
			while(val<len(l)):
				l[val]=False
				val+=i
	prime=[]
	for i in range(2,len(l)):
		if(l[i]==True):
			prime.append(i)
	return prime

def dp(l,i,n,val,ans):
	if(i>=n or val<0):
		return 1000000
	elif(val==0):
		return 0
	else:
		if(ans[i]==1000000):
			ans[i]=min(min(1+dp(l,i+1,n,val-l[i],ans),1+dp(l,i,n,val-l[i],ans)),dp(l,i+1,n,val,ans))
		return ans[i]
from queue import Queue
def factors(n):
	l=[]
	for i in range(1,int(sqrt(n))+1):
		if(n%i==0):
			if(n//i==i):
				l.append(i)
			else:
				l.append(i)
				l.append(n//i)
	return l
def check1(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v-=1
def check2(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v+=1

def up(n):
	j=n-1
	while(j>0):
		if(n%j==0):
			break
		j-=1
	return j		
def fac(n):
	c=1
	i=1
	while(i<=n):
		c*=i
		i+=1
	return c
def check_happy(n):
	ss=set()
	print(n)
	while(n!=1):
		val=n
		s=0
		print(val)
		while(val!=0):
			s+=(val%10)**2
			val=val//10
		print(val)
		print("hi")
		if(val in ss):
			return False
		else:
			n=val
			ss.add(n)
	return True
def update(a,b):
	c=1
	val=a
	while(a<b):
		print(c,a)
		c+=c
		a+=a
	print(1)
	while(a>b):
		print()
		a-=val
		c-=1
	return c
import random as rand
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
# nakdna
from itertools import permutations
def insertion_sort(arr):
	for i in range(len(arr)):
		j=i
		while(j>0):
			if(arr[j]<arr[j-1]):
				temp=arr[j]
				arr[j]=arr[j-1]
				arr[j-1]=temp
			j-=1
	return arr
def quick_sort(arr,low,high):
	i=low
	j=high
	
	while(i<j):
		if(arr[i]>arr[low] and arr[j]<arr[low]):
			temp=arr[i]
			arr[i]=arr[j]
			arr[j]=arr[i]
			i+=1
			j-=1
		elif(arr[i]<=arr[low]):
			i+=1
		elif(arr[j]>=arr[low]):
			j-=1
	print(i,j)
	toto=arr[j]
	arr[j]=arr[low]
	arr[low]=toto
	return j
def dodo(arr,low,high):
	if(low<high):
		val=quick_sort(arr,low,high)
		dodo(arr,low,val-1)
		dodo(arr,val+1,high)
def dp(arr,c,n,k,z,ans):
	if(k==0):
		return ans
	else:
		if(c==0):
			return dp(arr,c+1,n,k-1,z,ans+arr[c+1])
		elif(c==n-1):
			if(z==0):
				return 0
			else:
				return dp(arr,c-1,n,k-1,z-1,ans+arr[c-1])
		else:
			if(z==0):
				return dp(arr,c+1,n,k-1,z,ans+arr[c+1])
			else:
				return max(dp(arr,c+1,n,k-1,z,ans+arr[c+1]),dp(arr,c-1,n,k-1,z-1,ans+arr[c-1]))
if __name__ == '__main__':
	n=int(input())
	if(n>=30):
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 10648
//??????r?????¢?????¨?????¨????±???????

#include<stdio.h>
#include<math.h>

int  main(void){
    double r;
    double area;
    double Circumference;
    
    scanf("%lf", &r);
    
    area = r * r * M_PI;
    Circumference = 2 * M_PI * r;
    printf("%lf %lf\n", area, Circumference);
    
    return 0;
    
}

Measured memory_bytes: 648
#include<iostream>
#include<vector>
#include<limits>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 105;
int N, K;

int main()
{
	cin >> N >> K;
	ll x[maxn], y[maxn], a[maxn], b[maxn];
	for (int i = 0; i<N; i++) {
		cin >> a[i] >> b[i];
		x[i] = a[i], y[i] = b[i];
	}
	sort(x, x + N);
	sort(y, y + N);
	ll ans = 1ll << 62;
	for (int i = 0; i < N; i++) {
		for(int j=i+1;j<N;j++)
			for (int k = 0; k < N; k++) {
				for (int l = k + 1; l < N; l++) {
					ll sx = x[i];
					ll gx = x[j];
					ll sy = y[k];
					ll gy = y[l];
					int cnt = 0;
					for (int m = 0; m < N; m++) {
						if (a[m] >= sx&&a[m] <= gx&&b[m] >= sy&&b[m] <= gy)
							cnt++;
					}
					if (cnt >= K)
						ans = min(ans, (gx - sx)*(gy - sy));
				}
			}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

static const int LEN = 110;      // 頂点数のMAX値+α
static const int UNVISITED = 0;  // 頂点の訪問状態:未訪問
static const int VISITED = 1;    // 頂点の訪問状態:訪問済み

// 頂点uに隣接する頂点vを番号順に取得
int next(int u, vector<int>& M_u, int& nt_u) {
    if (nt_u < M_u.size()) {
        return M_u[nt_u++];
    }
    return -1;
}

// スタックを用いた深さ優先探索
void dfs_visit(int r, int n, vector<vector<int>>& M, vector<int>& status,
               vector<int>& d, vector<int>& f, int& tt) {
    vector<int> nt(LEN);  // nt:隣接する頂点のうち,確認済みのものを保持

    for (int i = 0; i < n; ++i) {
        nt[i] = 0;
    }

    stack<int> S;  // 訪問途中の頂点を退避しておくスタック
    status[r] = VISITED;
    S.push(r);
    d[r] = ++tt;

    while (!S.empty()) {
        // スタックtopの頂点uを訪問し,
        // uに隣接している頂点で次に探索する頂点をvとして受け取る
        int u = S.top();
        int v = next(u, M[u], nt[u]);

        if (v == -1) {
            S.pop();
            f[u] = ++tt;
            continue;
        }

        if (status[v] == UNVISITED) {
            status[v] = VISITED;
            S.push(v);
            d[v] = ++tt;
        }
    }
}

void dfs(int n, vector<vector<int>>& M) {
    vector<int> status(LEN);  // status:頂点の訪問状態
    vector<int> d(LEN);       // d:頂点の発見時刻
    vector<int> f(LEN);       // f:頂点の完了時刻

    // 初期化 (頂点uの訪問状態を「未訪問」に,また時刻を0に)
    for (int i = 0; i < n; ++i) {
        status[i] = UNVISITED;
    }
    int tt = 0;  // tt:経過時刻

    // 未訪問の頂点rを始点として深さ優先探索開始
    for (int r = 0; r < n; ++r) {
        if (status[r] == UNVISITED) dfs_visit(r, n, M, status, d, f, tt);
    }

    // 結果を出力
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int n, u, k, v;  // n:頂点数, u:頂点番号, k:出次数,
                     // v:隣接する頂点番号（入力受け取り用）
    vector<vector<int>> M(LEN,
                          vector<int>());  //  M:頂点同士の隣接を表す隣接リスト

    // 隣接リストを作成
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            --v;
            M[u].push_back(v);
        }
    }

    dfs(n, M);

    return 0;
}


Measured memory_bytes: 3172
#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 c,d,e,f,p,t,ans=0;


ll n;
vl v(200000);
set<ll> k;
ll kyori(ll x){
    auto i1=k.upper_bound(x),i2=k.upper_bound(x);
    i2--;
    ll a1=x-*i2,a2=*i1-x;
    if(*i2!=0){
        c=*i2;
        i2--;
        d=c-*i2;
    }
    else d=0;
    if(*i1!=n+1){
        e=*i1;
        i1++;
        f=*i1-e;
    }
    else f=0;
    //cout<<a1<<" "<<a2<<" "<<d<<" "<<f<<endl;
    return a1*f+a2*d;
}
void input(void){
    ll a;
    cin>>n;
    rep(i,n){
       cin>>a;
       v[a]=i+1;
    }
}

void solve(void){
    k.insert(0);
    k.insert(n+1);
    for(ll i=n;i>0;i--){
        t=v[i];
       // cout<<kyori(t)<<endl;
        ans+=i*kyori(t);
        k.insert(t);
    }
    cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D;
  str S1,S2,S3;
  str N;
  cin>>A>>B>>C;
  if(A+B<C)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_io;
    int n;
    cin >> n;
    int a,cnt=0;
    while( n != 0)
    {
        a = n % 10;
        n = n / 10;
        if(a == 7)
        {
            cnt++;
            break;
        }
    }
    if(cnt > 0)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    int n,sum;
    cin>>n;
    sum=(n/500)*1000;
    n%=500;
    sum+=(n/5)*5;
    cout<<sum;
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
//system("pause");
return 0;

}


Measured memory_bytes: 256
from collections import deque
import sys
def input():
    return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].append([b, c])
        G[b].append([a, c])
    q, k = list(map(int, input().split()))
    k -= 1
    stack = deque([k, ])
    ans = [-1] * n
    ans[k] = 0
    while stack:
        x = stack.popleft()
        for (dx, l) in G[x]:
            if ans[dx] == -1:
                ans[dx] = ans[x] + l
                stack.appendleft(dx)
    for _ in range(q):
        x, y = list(map(lambda x: int(x) - 1, input().split()))
        print(ans[x] + ans[y])

if __name__ == '__main__':
    main()


Measured memory_bytes: 51596
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=5000+5,mod=1e9+7;
int n,k,p[N],c[N];
ll arr[N];
ll solve(int no){

   int str=no;
   int rem=k,cnt=0;
   ll ret=0,mx=-1e16;
   arr[cnt]=0;
   while(rem>0){
    str=p[str];
    rem--;
    ret+= c[str];
    mx=max(mx,ret);
    cnt++;
    arr[cnt]=mx;
    if(str==no){
        break;
    }
   }
   ll mx2=mx;
   if(rem>0){
    int F= rem/cnt;
    int mo= rem%cnt;
    mx=max(mx,ret*(F+1)+arr[mo]);
    mx=max(mx,(F)*ret+mx2);
   }
  return mx;
}
int main(){

    GO();
    int T;
    T=1;
    while(T--){

        cin>>n>>k;
        for(int i=1;i<=n;i++) cin>>p[i];
        for(int i=1;i<=n;i++) cin>>c[i];
        ll ans=-1e16;
        for(int i=1;i<=n;i++){
            ans=max(ans,solve(i));
        }
        cout<<ans<<"\n";
    }
}















































































































































































































































Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int test[345678];
signed main() {
	int n, mi = 0, ma = 0, ans = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	reverse(test, test + n);
	for (int h = 0; h < n; h++) {
		if (h == 0) {
			if (test[h] != 2) { cout << -1 << endl; return 0; }
			mi = test[h]; ma = test[h] * 2 - 1;
		}
		else {
			mi += test[h] - 1;
			mi = mi / test[h] * test[h];
			ma = ma / test[h] * test[h] + test[h] - 1;
		}
		if (mi > ma) { cout << -1 << endl; return 0; }
	}
	cout << mi << ' ' << ma << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define mod ((ll)1e9+7)
#define N ((ll)2e6+10)
#define pb push_back
#define in insert
#define F first
#define S second
#define MAX_CHARS 256
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x, ll y, ll p) { ll res = 1; while (y) {if (y % 2) res = (res * x % p) % p; x = (x * x) % p; y /= 2; } return res;}
int sv[1000000] = {0};
ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];
void InverseofNumber(ll p) {naturalNumInverse[0] = naturalNumInverse[1] = 1; for (ll i = 2; i <= N; i++)naturalNumInverse[i] = naturalNumInverse[p % i] * (mod - mod / i) % mod;}
void InverseofFactorial(ll p) {factorialNumInverse[0] = factorialNumInverse[1] = 1; for (ll i = 2; i <= N; i++)factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;}
void factorial(ll p) {fact[0] = 1; for (ll i = 1; i <= N; i++) {fact[i] = (fact[i - 1] * i) % mod;}}
ll Binomial(ll n, ll R) {ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod; return ans;}
/*TOIENT FUNCTION*/ll phi(ll n) {ll ans = n; for (ll i = 2; i * i <= n; i++) {if (n % i == 0) {while (n % i == 0) n /= i; ans -= ans / i;}} if (n > 1) ans -= ans / n; return ans;}


void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {

//    InverseofNumber(mod);
//    InverseofFactorial(mod);
//    factorial(mod);
    speed
    // fileIO();
    ll a, b, h, m; cin >> a >> b >> h >> m;
    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;
    double pi = 2 * acos(0.0);
    double angle = abs(hour_angle - minute_angle);
    angle = min(360.00 - angle, angle);
    angle /= 180.00;
    double k = a * a + b * b - 2 * a * b * cos(pi * angle);
    cout << fixed << setprecision(10) << sqrt(k);


    return 0;
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
#include <iostream>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;

using qul = queue<ll>;

int main() {
    char S;
    cin >> S;
    if(isupper(S)) {
        cout << 'A'<< endl;
    } else {
        cout << 'a' << endl;

    }
}

Measured memory_bytes: 3628
fun main( args : Array<String> ) {
  val n = readLine()
  readLine()!!.split(" ")
  .map {
    val x = it.toInt()
    listOf(x-1, x, x+1)
  }.flatten()
  .groupBy {
    it
  }.toList()
  .map {
    it.second.size
  }.max()
  .let {
    println(it)
  }
}

Measured memory_bytes: 85812
#include <stdio.h>

int main(void)
{
	int mon,n;
	int i;
	
	mon = 100000;
	
	scanf("%d",&n);
	
	for(i = 1;i <= n;i++){
		mon *= 1.05;
			if(mon % 1000 != 0){
		    mon = mon - (mon % 1000) + 1000;
		}
	}

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

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			int N = scn.nextInt();
			long[] a = new long[N];

			for(int i = 0; i < N; i++) {
				a[i] = scn.nextLong();
				if(a[i] == 0) {
					System.out.println(0);
					System.exit(0);
				}
			}

			long max = (long) Math.pow(10, 18);
			max++;

			long tmp = a[0];
			for(int i = 1; i < N; i++){
				if(tmp * a[i] / max >= 1 || tmp * a[i] < tmp) {
					System.out.println(-1);
					System.exit(0);
				}
				tmp *= a[i];
			}
			System.out.println(tmp);
		}
	}
}

Measured memory_bytes: 61520
#include<stdio.h>
int main()
{
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    while(op!='?')
    {
        switch(op)
        {
            case '+':printf("%d\n",a+b);break;
            case '-':printf("%d\n",a-b);break;
            case '*':printf("%d\n",a*b);break;
            case '/':printf("%d\n",a/b);break;
        }
        scanf("%d %c %d",&a,&op,&b);
    }
    return 0;
}



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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   ll n,x;
   cin >> n >> x;
   vector<ll> v(n);
   for(int i=0;i<n;i++)cin >> v[i];

   ll ans=0;
   if(v[0] > x)ans+=(v[0]-x),v[0]-=(v[0]-x);
   for(int i=0;i<n-1;i++){
      ll k = max(0LL,v[i]+v[i+1]-x);
      ans += k;
      v[i+1]-=k;
   }
   cout << ans;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// calculating after processing


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			long n = cin.Long();

			if (n % 2 == 1) {
				Console.WriteLine(0);
				return;
			}

			long ans = 0;
			long bo = 10;
			while (n >= bo) {
				ans += n / bo;
				bo *= 5;
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll max(ll a, ll b){
    return a > b? a : b;
}
int main()
{
    ll r, d, x;
    cin >> r >> d >> x;
    ll t = x;
    for(int i = 1; i <= 10; i++)
    {
        t = r * x - d;
        cout << t << endl;
        x = t;
    }
    return 0;
}

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

int W, H;
char board[30][30];
bool is[30][30];

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

void dfs(int x, int y) {
   for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (board[nx][ny] == '#') continue;
      if (is[nx][ny]) continue;
      is[nx][ny] = true;
      dfs(nx, ny); // 次の一から再び4近傍を探索
   }
}

int main() {
   while (cin >> W >> H, W && H) {
      memset(is, false, sizeof(is));
      int x, y;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            cin >> board[i][j];
            if (board[i][j] == '@') {
               x = i, y = j;
            }
         }
      }

      is[x][y] = true;
      dfs(x, y);
      int cnt = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            if (is[i][j]) cnt++;
         }
      }
      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 2992
#include <stdio.h>
long long gcd(long long p,long long q){
    if(p%q==0) return q;
    else return gcd(q,p%q);
}
int main(void){
    long long a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",a*b/gcd(a,b));
    return 0;
}


Measured memory_bytes: 128
select::Int->[Int]->[Int]
select n xs=(take n xs) ++ (drop (n+1) xs)

f::Int->[Int]->Int
f ans []=ans
f ans xs=minimum [f (g ans (xs!!e)) (select e xs)|e<-[0..((length xs)-1)]]
         where g x y=((div x 10))*10+y + if (mod x 10)>0 then 10 else 0

main = do
       xs<-getContents
       let ys=map read (lines xs)::[Int]
       print $ f 0 ys

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> A(N+1,0);
    for(auto& x:A) cin >> x;
    if(N==0){
        cout << (A[0]!=1? -1:1) << "\n";
        return 0;
    }
    if(A[0]!=0){
        cout << -1 << "\n";
        return 0;
    }
    ll inf = 1e18;
    vec<ll> L(N+1,inf),R(N+1,-1);
    L[0] = 1,R[0] = 1;
    for(int i=1;i<=N;i++){
        L[i] = max(L[i-1]-A[i],0LL);
        R[i] = min(inf,2*R[i-1]-A[i]);
//        cerr << i << " " << L[i] << " " << R[i] << "\n";
    }
    ll now = A[N];
    ll ans = A[N];
    for(int i=N-1;i>=0;i--){
        ll low = (now+1)/2;
        ll upp = now;
        if(max(low,L[i]) > min(upp,R[i])){
            cout << -1 << "\n";
            return 0;
        }
        ans += min(upp,R[i])+A[i];
        now = min(upp,R[i])+A[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = reader.readLine();
        String[] vals = line.split(" ");
        Integer[] nums = { Integer.parseInt(vals[0]),
                Integer.parseInt(vals[1]), Integer.parseInt(vals[2]),
                Integer.parseInt(vals[3]), Integer.parseInt(vals[4]) };
        Arrays.sort(nums);
        out.println(String.format("%d %d %d %d %d", nums[4], nums[3], nums[2], nums[1], nums[0]));
    }
}

Measured memory_bytes: 11000
#include<stdio.h>

typedef struct{
  double t;
  int num;
} hight;

int main()
{
  int n, i;
  scanf("%d\n", &n);
  hight h[n];
  double t, a, tempar;
  scanf("%lf%lf", &t, &a);
  for(i = 0; i < n; ++i){
    h[i].num = i+1;
    scanf("%lf", &h[i].t);
    tempar = t - h[i].t * 0.006;
    h[i].t = a - tempar;
    if(h[i].t < 0) h[i].t = -h[i].t;
  }
  int j;
  for(j = 0; j < n-1; ++j){
      for(i = 0; i < n - 1 -j; ++i){
	hight temp;
	if(h[i].t > h[i+1].t){
	  temp = h[i];
	  h[i] = h[i+1];
	  h[i+1] = temp;
	}
      }
  }
  printf("%d\n", h[0].num);
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

bool X[1100][1100];
ll memo[1100][1100];

ll func(ll y, ll x){
    if(memo[y][x] >= 0){
        return memo[y][x];
    }

    ll ret = 0;
    if(y-1 >= 0 && X[y-1][x]){
        ret += func(y-1, x);
        ret %= MOD;
    }

    if(x-1 >= 0 && X[y][x-1]){
        ret += func(y, x-1);
        ret %= MOD;
    }

    ret %= MOD;
    return memo[y][x] = ret;
}

int main(){
    ll H, W;
    cin >> H >> W;
    REP(i,H){
        REP(j,W){
            char c;
            cin >> c;
            X[i][j] = c == '.';
        }
    }

    REP(i,H){
        REP(j,W){
            memo[i][j] = -1;
        }
    }
    memo[0][0] = 1;

    ll ans = func(H-1, W-1);

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


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

int main() {
  int X;
  cin >> X;
  if(X < 1200){
    cout << "ABC" << endl;
    return 0;
  }
  else if(X < 2800){
    cout << "ARC" << endl;
    return 0;
  }
  cout << "AGC" << endl;
}


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

using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;

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


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

using namespace std;

int main(){

   int s[13] = {0}, h[13] = {0}, c[13] = {0}, d[13] = {0};
   int n, num;
   string cc;

   cin >> n;

   for(int i = 0; i < n; i++){
      cin >> cc >> num;
      if(cc == "S"){
         s[num - 1]++;
      }
      else if(cc == "H"){
         h[num - 1]++;
      }
      else if(cc == "C"){
         c[num - 1]++;
      }
      else{
         d[num - 1]++;
      }
   }

   for(int i = 0; i < 13; i++){
      if(s[i] == 0){
         cout << "S " << i + 1 << endl;
      }
   }

   for(int i = 0; i < 13; i++){
      if(h[i] == 0){
         cout << "H " << i + 1 << endl;
      }
   }

   for(int i = 0; i < 13; i++){
      if(c[i] == 0){
         cout << "C " << i + 1 << endl;
      }
   }

   for(int i = 0; i < 13; i++){
      if(d[i] == 0){
         cout << "D " << i + 1 << endl;
      }
   }

   return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const string password[] = {"BD", "ACE", "BF", "AEG", "BDFH", "CEI", "DH", "EGI", "FH"};

int main(){
  string s;
  while(cin >> s){
    bool flag = true;
    for(int i = 0 ; i < s.size()-1 ; i++){
      if( password[s[i+1]-'A'].find(s[i]) == string::npos ){ flag = false; break; }      
    }
    if(flag) cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>

#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


int D, N;


signed main()
{
	cin >> D >> N;

	if (D == 0)
	{
		if (N == 100)
		{
			cout << 101 << endl;
		}
		else
		{
			cout << N << endl;
		}
	}
	if (D == 1)
	{
		if (N == 100)
		{
			cout << 10100 << endl;
		}
		else
		{
			cout << N * 100 << endl;
		}
	}
	if (D == 2)
	{
		if (N == 100)
		{
			cout << 1010000 << endl;
		}
		else
		{
			cout << N * 10000 << endl;
		}
	}
}



Measured memory_bytes: 3160
# import math
# import statistics
# import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# N,S,T= map(int,input().split())
# f = list(map(int,input().split()))
# g = [int(input()) for _ in range(N)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen

print((a/3)**3)

Measured memory_bytes: 9400
#include <iostream>

using namespace std;

int main(){
    int t,p=2000,j=2000;
    for(int i=0;i<3;++i){
        cin>>t;p=p<t?p:t;
    }
    for(int i=0;i<2;++i){
        cin>>t;j=j<t?j:t;
    }
    cout<<p+j-50<<endl;
    return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
int main()
{
  char input[6];
  int i;
  int flag = 0;
  scanf("%s", &input);
  
  for(i = 0; input[i + 1] != '\0'; ++i){
    if((input[i] == 'A') && (input[i + 1] == 'C'))
      flag = 1;
  }
  if(flag == 1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 128
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

ll col[mx], cnt[mx], dist[mx];
vector< pair < int,int> > adj[mx];
bool vis[mx];

void dfs(int u)
{
    vis[u]=true;
    for(auto x:adj[u])
    {
        if(vis[x.ff]==false)
        {
            dist[x.ff]=dist[u]+x.ss;

            if(dist[x.ff]%2)
                col[x.ff]=1;
            else
                col[x.ff]=0;

            dfs(x.ff);
        }
    }
}

int main()
{
    fastio;
    int n,u,v,w;
    cin>>n;

    forn(i, n-1)
    {
        cin >> u>>v>>w;
        adj[u].pb({v,w});
        adj[v].pb({u,w});

        cnt[u]++;
        cnt[v]++;
    }

    int root;
    forn(i,n+1)
    {
        if(cnt[i]==1)
            root=i;
    }

    dfs(root);
    for(int i=1; i<=n; i++)
    {
        cout << col[i] << "\n";
    }

    return 0;
}



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

using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  vector<int> score;
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    score.push_back(x);
  }

  for (int i = K; i < N; i++) {
    if (score[i - K] < score[i]){
       cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3840
<?php
// Your code here!
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

$a = str_split($a);
$b = str_split($b);
$sum=0;

for($i=0; $i<count($a); $i++)
{
    if($a[$i] != $b[$i]){
        $sum++;
    }
}

echo $sum;


?>


Measured memory_bytes: 41252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n,k;
  cin>>n>>k;
  vector<ll> h(n);
  rep(i,n) cin>>h[i];
  /////
  ll dp[100010];
  rep(i,100010) dp[i]=inf;
  dp[0]=0;
  
  for(int i=1;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i-j>=0)
   		chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
              cout<<dp[n-1]<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	int ret=700;
	FORR(c,S) if(c=='o') ret+=100;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<tuple>
#include<algorithm>

using namespace std;

int main(){
  int W,H,N;
  cin>>W>>H>>N;
  int xy[100000][2];
  for(int i=0;i<N;i++){
    cin>>xy[i][0]>>xy[i][1];
  }
  vector<tuple<int,int,long long> > res[2];
  for(int i=0;i<2;i++){
    vector<pair<int,int> > v;
    for(int j=0;j<N;j++){
      v.emplace_back(xy[j][i],j);
    }
    sort(begin(v),end(v));
    long long nd=0;
    int lx=0,x=N-1;
    int l=N-1,r=0;
    for(int j=0;j<N-1;j++){
      nd+=2LL*(v[N-1].first-v[j].first);
    }
    long long pd=nd-(v[N-1].first-v[0].first);
    for(;;){
      while(x){
	long long nnd=nd+(v[x].first-v[x-1].first)*2LL*(r+1-l);
	long long npd=nnd-abs(v[lx].first-v[x-1].first);
	if(npd>pd)break;
	nd=nnd;
	pd=npd;
	l--;
	r++;
	x--;
      }
      res[i].emplace_back(v[lx].second,v[x].first,pd);
      lx++;
      if(lx==N)break;
      pd+=abs(v[lx-1].first-v[x].first)-abs(v[lx].first-v[x].first);
    }
    sort(begin(res[i]),end(res[i]));
  }
  int rx,ry;
  long long d=1LL<<62;
  for(int i=0;i<N;i++){
    long long sd=get<2>(res[0][i])+get<2>(res[1][i]);
    bool f;
    if(sd!=d){
      f=sd<d;
    }else if(rx!=get<1>(res[0][i])){
      f=get<1>(res[0][i])<rx;
    }else{
      f=get<1>(res[1][i])<ry;
    }
    if(f){
      rx=get<1>(res[0][i]);
      ry=get<1>(res[1][i]);
      d=sd;
    }
  }
  cout<<d<<endl;
  cout<<rx<<' '<<ry<<endl;
}

Measured memory_bytes: 7828
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
l=[[0]*26]
t=[[]]
v=[0]
for d in range(D):
    x=[]
    for b in range(len(l)):
        x.extend([(S[d][i]-sum([(d+1-l[b][j])*C[j] for j in range(26) if i!=j]),i,b) for i in range(26)])
    x=sorted(x,key=lambda a:v[a[2]]+a[0])[::-1]
    l2=[]
    t2=[]
    v2=[]
    for _,i,b in x[:9]:
        l2.append(l[b].copy())
        l2[-1][i]=d+1
        t2.append(t[b].copy())
        t2[-1].append(i+1)
        v2.append(v[b]+_)
    l=l2
    t=t2
    v=v2
print(*t[0],sep='\n')

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

using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    
    vector<int> temp(5, 0);
    int ans = 0;
    
    for(int i = 1; i <= N; i++){
        int cnt = 0;
        int m = i;
        
        while(m > 0){
            temp[cnt++] = m % 10;
            m /= 10;
        }
        
        int sum = 0;
        for(int j = 0; j < cnt; j++){
            sum += temp[j];
        }
        
        if(sum >= A && sum <= B){
            ans += i;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> II;

int main() {
	int n, c[26]; cin >> n;
	for (int i = 0; i < 26; ++i) c[i] = 1e9;
	while (n--) {
		string S; cin >> S;
		int d[26] = {0};
		for (int i = 0; i < (int) S.size(); ++i) d[S[i] - 'a']++;
		for (int i = 0; i < 26; ++i) c[i] = min(c[i], d[i]);
	}
	for (int i = 0; i < 26; ++i)
		while (c[i]--) putchar(i + 'a');
	return 0;
}

Measured memory_bytes: 256
S = int(input())

_set = set()
_set.add(S)

_ = 10**7
cnt = 1
before_num = S

for n in range(_):
  cnt += 1
  _ = before_num
  
  if _%2==0:
    this_num = _/2
  else:
    this_num = 3*_+1
  _set.add(this_num)
  
  if len(_set) < cnt:
    ans = cnt
    break
  
  before_num = this_num
    
print(ans)

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

using namespace std;
int main()
{   
    // 整数の入力
//    int a,b,c;
    string str;
    int count = 0;
    cin >> str;
    int ll = str.length();
//    vector<int> vect;

    for(int n=0; n<ll/2;n++){
        if(str[n]==str[ll-1-n]){
        }else{
            count++;
        }
    }
        cout << count;
        return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();

      if(b%a==0){
        System.out.println(a+b);
      }else{
        System.out.println(b-a);
      }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 500010;
const int INF = LLONG_MAX/4;

int n;
int32_t main() {
	cin >> n;
	
	string ans = ""; 
	while (n > 0) {
		n -= 1;
		ans += ('a' + (n % 26));
		n /= 26;
	}
	reverse(ans.begin(),ans.end());
	cout << ans;
	
	
}









Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000000

// 辺の（行先，容量，逆辺が保存されているG[to]での番地）．
struct edge {int to, cap, rev;};

vector<vector<edge>> G; //有向グラフとその残余グラフ．
vector<int> level; // sからの距離
vector<int> iter; // どこまで調べ終わったか．

void add_edge(int from, int to , int cap){
    G[from].push_back(edge{to, cap, (int)G[to].size()});
    G[to].push_back(edge{from, 0, (int)G[from].size() - 1});
}

//sからの最短距離をbfsで計算．
void bfs(int s){
    fill(ALL(level), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()){
        int v = que.front(); que.pop();
        for (edge &e:G[v])
            if (e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
    }
}

//v から t へのパスを DFS で探し，そのパスで流せる最大流量を返す．
// mincap = 通った辺の中の最少容量
int flow_dfs(int v, int t, int mincap){
    if (v == t) return mincap;
    for (int &i = iter[v]; i <  G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = flow_dfs(e.to, t, min(mincap, e.cap));
            if (d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流
int max_flow(int s, int t){
    int flow = 0;
    while (true){
        bfs(s);
        if (level[t] < 0) return flow;
        fill(ALL(iter), 0);
        int f;
        while((f = flow_dfs(s, t, INF)) > 0)
            flow += f;
    }
}

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

// s から t へ流せる最大流量
// Dinic ．O(EV²). 
int V, E; cin >> V >> E;
G.assign(V, vector<edge>());
level.assign(V, 0);
iter.assign(V, 0);
rep(i, 0, E){
    int u, v, c; cin >> u >> v >> c;
    add_edge(u, v, c); 
    //もし無効グラフなら add_edge(v, u, c) もする．
}

cout << max_flow(0, V-1) << endl;

}




Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

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

  vector<int> g(n+1, 0);
  for(int i = 0; i < m; i++){
    int p; cin >> p;
    g[p] = 1;
  }
  int left = 0;
  for(int i = 0; i <= x; i++){
    left += g[i];
  }
  int right = 0;
  for(int i = x; i <= n; i++){
    right += g[i];
  }
  int ans = min(left, right);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
const int N=3e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int cnt=0;
        while(i+1<n&&a[i]>=a[i+1])
        {
            cnt++;
            i++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
    char s[10];
    int l,c=0;
    if(scanf("%s",s)==1) l=strlen(s);
    if(s[0]=='A'&&islower(s[1])&&islower(s[l-1])){
        for(int i=2;i<l;i++){
            if(isupper(s[i])&&s[i]!='C'){printf("WA\n");return 0;}
            else if(s[i]=='C')c++;if(c>1){printf("WA\n");return 0;}
        }   
        if(c==0){printf("WA\n");return 0;}
        else{printf("AC\n");return 0;}
    }else{ printf("WA\n"); return 0;}
}   

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> p(m);
    rep(i,m){
        int b,a;
        cin >> a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    /*
    cout<<"------"<<endl;
    rep(i,m){
        cout << p[i].second<<" "<<p[i].first<<endl;
    }
    */
   //secondが左、firstが右  
    int ans=0;
    int i=0;
    bool eli=false;
    while(i<m){
        int j=1;
        if(i==m-1){
            ans++;
            break;
        }
        if(p[i].first>p[i+1].second){
            /*if(!eli){//まだ取り除いてない
                ans++;
            }
            */
            while(p[i].first>p[i+j].second){
                if(i+j>=m){
                break;
            }
                j++;
            }
        }
        ans++;
        //cout <<"i="<<i<<",i+j="<<i+j<<endl;
        i += j;
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    ll len = N.length();
    vector<vector<ll>> dp(len, vector<ll>(2, 1e18));
    int val = N[len - 1] - '0';
    dp[len - 1][0] = val;
    dp[len - 1][1] = 10 - val;
    for (int i = len - 2; i >= 0; i--) {
        val = N[i] - '0';
        dp[i][0] = min(dp[i][0], dp[i + 1][0] + val);
        if (val != 9) {
            dp[i][0] = min(dp[i][0], dp[i + 1][1] + val + 1);
        }
        dp[i][1] = min(dp[i][1], dp[i + 1][0] + 10 - val);
        dp[i][1] = min(dp[i][1], dp[i + 1][1] + 10 - val - 1);
    }
    cout << min(dp[0][0], dp[0][1] + 1) << endl;
    return 0;
}


Measured memory_bytes: 55964
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int A, B, C, D;
  string s; cin >> s;
  A = s[0]-'0';
  B = s[1]-'0';
  C = s[2]-'0';
  D = s[3]-'0';

  for (char a: {'+', '-'}) {
    int AA = a == '+' ? A + B : A - B;
    for (char b: {'+', '-'}) {
      int BB = b == '+' ? AA + C : AA - C;
      for (char c: {'+', '-'}) {
        int CC = c == '+' ? BB + D : BB - D;
        if (CC == 7) {
          printf("%d%c%d%c%d%c%d=7\n", A, a, B, b, C, c, D);
          return;
        }
      }
    }
  }
}

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


Measured memory_bytes: 3252
a=int(input())
lis=sorted(list(map(int , input().split())))
ans=float('inf')
ans2=0
for i in range(lis[-1]):
  for j in lis:
    ans2+=(j-(i+1))**2
  if ans>ans2:
    ans=ans2
  ans2=0
print(ans)

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

int main()
{
    int t;
    string s;
    cin >> t;
    cin >> s;
    if(t>=3200){
        cout << s << endl;
    }
    else{
        cout << "red\n";
    }
    return 0;
}


Measured memory_bytes: 256
console.log((args=>{
  const [n,...s] = args.trim().split`\n`;
  const N = n|0;
  const m = new Map();
  for ( let i = 0; i < N; i++ ) {
    const p = s[i].split``.sort().join``;
    m.set( p, (m.get(p)|0) + 1 );
  }
  let a = 0;
  for ( const [,v] of m ) a += v*(v-1)/2;
  return `${a}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 65076
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    for (char c: "abcdefghijklmnopqrstuvwxyz"s) {
        if (S.find(c) == -1) {
            cout << c << endl;
            exit(0);
        }
    }
    cout << "None"s << endl;
    return 0;
}

Measured memory_bytes: 512