akhauriyash/Code-Regression huggingface dataset:
program canh_toan;
uses math;
const minn=0;
      maxn=trunc(1e5)+5;
      module=trunc(1e9)+7;
var n:longint;
    a,b:array[minn..maxn] of longint;
procedure sorta(l,r:longint);
var i,j,k,tg:longint;
begin
i:=l;j:=r;tg:=a[random(r-l+1)+l];
repeat
while (a[i]<tg) do inc(i);
while (tg<a[j]) do dec(j);
if not(i>j) then
   begin
     k:=a[i];
     a[i]:=a[j];
     a[j]:=k;
     inc(i);
     dec(j);
   end;
until i>j;
if (l<j) then sorta(l,j);
if (i<r) then sorta(i,r);
end;
procedure sortb(l,r:longint);
var i,j,k,tg:longint;
begin
i:=l;j:=r;tg:=b[random(r-l+1)+l];
repeat
while (b[i]<tg) do inc(i);
while (tg<b[j]) do dec(j);
if not(i>j) then
   begin
     k:=b[i];
     b[i]:=b[j];
     b[j]:=k;
     inc(i);
     dec(j);
   end;
until i>j;
if (l<j) then sortb(l,j);
if (i<r) then sortb(i,r);
end;
function nhannp(x,y:int64):int64;
var tg:int64;
begin
if y=0 then exit(0)
else if y=1 then exit(x mod module)
else
  begin
    tg:=nhannp(x,y div 2) mod module;
    tg:=(2*tg) mod module;
    if y mod 2=1 then tg:=(tg+x) mod module;
    exit(tg mod module);
  end;
end;
procedure main();
var i,j,x,y:longint;
    kq:int64;
begin
readln(n);
for i:=1 to n do read(a[i]);
readln;
for j:=1 to n do read(b[j]);
sorta(1,n);sortb(1,n);
i:=1;j:=1;x:=0;y:=0;kq:=1;
while (i<=n) and (j<=n) do
  begin
    if (a[i]<b[j]) then
       begin
         y:=x+1;
         inc(i);
       end
    else
       begin
         y:=x-1;
         inc(j);
       end;
    if (abs(x)>abs(y)) then kq:=nhannp(kq,abs(x)) mod module;
    x:=y;
  end;
while (i<=n) do
  begin
    kq:=nhannp(kq,abs(x)) mod module;
    inc(x);
    inc(i);
  end;
while (j<=n) do
  begin
    kq:=nhannp(kq,abs(x)) mod module;
    dec(x);
    inc(j);
  end;
write(kq);
end;
BEGIN
  main();
END.

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

int main(void){
	int i,j,x,s[2]={0,0};

	for(i=0;i<2;i++){
		for(j=0;j<4;j++){
			cin>>x;
			s[i]+=x;
		}
	}
	if(s[0]>s[1]) cout<<s[0]<<endl;
	else cout<<s[1]<<endl;

	return 0;
}

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

using namespace std;

int n, f[101][10], p[101][11];
long long ans=-99999999999999, a;
bool flag[10];

void dfs(int dep, bool F)
{
    if (dep==10)
    {
        int cnt; a=0;
        bool c=false;
        flag[dep-1]=F;
        for (int i=0; i<10; i++) if (flag[i]) c=true;
        if (!c) return;
        for (int i=0; i<n; i++)
        {
            cnt=0;
            for (int j=0; j<10; j++) if (flag[j] && f[i][j]) cnt++;
            a+=p[i][cnt];
        }
        ans=max(ans, a);
    }
    else
    {
        flag[dep-1]=F;
        dfs(dep+1, 0);
        dfs(dep+1, 1);
        return;
    }
}

int main()
{
    cin>>n;
    for (int i=0; i<n; i++) for (int j=0; j<10; j++) cin>>f[i][j];
    for (int i=0; i<n; i++) for (int j=0; j<=10; j++) cin>>p[i][j];
    dfs(1, 0);
    dfs(1, 1);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  string s; cin >> s;
  int sz = s.length();
  REP(i, sz) {
    if (i == a) {
      if (s[i] != '-') {
        cout << "No\n";
        return 0;
      }
    } else if (s[i] == '-') {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


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

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

    ll sum = 0;
    map<ll, ll> mp; mp[0] = 1;
    for (int i = 0; i < n; i++) {
        ll a; cin >> a;
        sum += a;
        mp[sum % m]++;
    }

    ll ans = 0;
    for (auto& e : mp) {
        ll num = e.second;
        ans += (num * (num - 1)) / 2;
    }

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

Measured memory_bytes: 4224
// AOJ 2150
#include<algorithm>
#include<iostream>
#include<vector>

const int MAX_PRIME = 150000;

bool used[MAX_PRIME];
std::vector<int> primes;

int n, p;

void sieve( int n )
{
	used[0] = used[1] = true;
	for( int i = 2; i <= n; ++i )
	{
		if( !used[i] )
		{
			primes.push_back( i );
			for( int j = i; j <= n; j += i )
				used[j] = true;
		}
	}

	return;
}

int main()
{
	sieve( MAX_PRIME );

	while( std::cin >> n >> p, ~( n & p ) )
	{
		int idx = std::upper_bound( primes.begin(), primes.end(), n ) - primes.begin();

		std::vector<int> sum;
		for( int i = idx; i < idx + p && i < primes.size(); ++i )
			for( int j = i; j < idx + p && j < primes.size(); ++j )
				sum.push_back( primes[i] + primes[j] );

		std::sort( sum.begin(), sum.end() );
		
		std::cout << sum[p-1] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1484
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1) a=14;
  if(b==1) b=14;

  if(a>b) puts("Alice");
  else if(a<b) puts("Bob");
  else if(a==b) puts("Draw");
}

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

int selectionsort(int a[],int n){
  int count = 0;
  for(int i = 0; i < n; i++){
    int minj = i;
    for(int j = i; j < n; j++){
      if(a[j] < a[minj]){
        minj = j;
      }
    }
    int v = a[i];
    a[i] = a[minj];
    a[minj] = v;
    if(minj != i) count++;
  }
  return count;
}

int main(void){
  int n; cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int count = selectionsort(a,n);
  selectionsort(a,n);
  for(int i = 0; i < n; i++){
    if(i != n-1){
      cout << a[i] << " ";
    }
    else cout << a[i] << endl;
  }
  cout << count << endl;
  return 0;
}



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

#define INF (INT64_MAX)
#define MAX 100000

int N, M;

typedef vector<int> vi;

long long MOD;
vi g[MAX + 1];
vi pref[MAX + 1];
vi suf[MAX + 1];
long long down[MAX + 1];
long long up[MAX + 1];

int add( int x, int y ) { return ((long long)x + y) % MOD; }
int mul( int x, int y ){ return (long long)x * y % MOD; }

void fix( int x )
{
	for( int i = 0; i < g[x].size(); i++ ) {
		int y = g[x][i];
		g[y].erase( find( g[y].begin(), g[y].end(), x ) );
        fix( y );
    }
}

void dfs( int x )
{
    down[x] = 1;
    for( auto &y : g[x] ) {
        dfs( y );
        down[x] = mul( down[x], add(down[y], 1) );
    }
    int sz = g[x].size();
    pref[x].resize( sz + 1 );
    suf[x].resize( sz + 1 );
    pref[x][0] = suf[x][sz] = 1;
    for( int i = 0; i < sz; i++ ) {
        pref[x][i + 1] = mul( pref[x][i], add(1, down[ g[x][i] ] ) );
    }
    for( int i = sz-1; i >= 0; i-- ) {
        suf[x][i] = mul( suf[x][i + 1], add(1, down[ g[x][i] ] ) );
    }
}

void dfs1( int x )
{
    for( int i = 0; i < g[x].size(); i++ ) {
        int y = g[x][i];
        up[y] = mul(up[x], mul( pref[x][i], suf[x][i+1] ) );
        up[y] = add(up[y], 1 );
        dfs1( y );
    }
}

int main() {
	cin >> N >> M;
	for( int i = 0; i < N - 1; i++ ) {
		int x, y;
		cin >> x >> y;
		g[ x ].push_back( y );
		g[ y ].push_back( x );
	}
	MOD = M;
	fix( 1 );
	dfs( 1 );
	up[1] = 1;
	dfs1( 1 );

	for( int i = 1; i <= N; i++ ) {
		cout << mul( up[i], down[i] ) << endl;
	}
	return 0;
}


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

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

  int n;
  cin >> n;

  map<int,int> mp;
  for (int i = 0; i < n-1; ++i) {
    int a;
    cin >> a;

    ++mp[a];
  }

  for (int i = 1; i <= n; ++i) cout << mp[i] << '\n';

  return (0);
}

Measured memory_bytes: 13004
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> da(m);
	vector<bool> ju(n+1,true);
	for (int i = 0;i < m;i++) {
		cin >> da[i];
		ju[da[i]] = false;
	}
	vector<int> dp(n+1,0);
	dp[0] = 1;
	if (ju[1])
		dp[1] = 1;
	for (int i = 2;i < n + 1;i++) {
		if (ju[i]) {
			dp[i] = (long long)(dp[i - 1] + dp[i - 2]) % 1000000007;
		}
	}
	cout << dp[n] << endl;
	/*for (int i = 0;i < n + 1;i++) {
		cout << dp[i] << endl;
	}*/
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static int gcd(int a, int b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int array[] = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        System.out.println(array[n - 1] - array[0]);
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 27312
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    cout << (n==m ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int InputNum[7];
    int a=1,b=2,c=3;
    int tmp;
    int i;
    char Input;
    
    for(i=0;i<6;i++){
        scanf("%d",&InputNum[i]);
    }
    while ((Input = getchar())!=EOF) {
        switch (Input) {
            case 'S':
                tmp=7-b;
                b=a;
                a=tmp;
                break;
            case 'W':
                tmp=7-a;
                a=c;
                c=tmp;
                break;
            case 'N':
                tmp=7-a;
                a=b;
                b=tmp;
                break;
            case 'E':
                tmp=7-c;
                c=a;
                a=tmp;
                break;
            default:
                break;
        }
    }
    printf("%d\n",InputNum[a-1]);
}


Measured memory_bytes: 2144
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

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

const int max_N = 110;

int main() {
    int a[max_N];

    int n, x;
    cin >> n >> x;

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

    sort(a, a + n);

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] > x) {
            break;
        } else {
            x -= a[i];
            ++ans;
        }
    }

    if (ans == n && x != 0) {
        cout << ans - 1 << endl;
    } else {
        cout << ans << endl;
    }
}


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

using namespace std;

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

    long long count = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= B[i]) {
            count += B[i];
            continue;
        } else {
            count += A[i];
            B[i] -= A[i];
        }

        if (A[i + 1] >= B[i]) {
            count += B[i];
            A[i + 1] -= B[i];
        } else {
            count += A[i + 1];
            A[i + 1] = 0;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
//21:04
#include<bits/stdc++.h>
using namespace std;
int a[758768];
main(){
    int n;
    cin >> n;
    int x = 0, y = 0, z = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]%4 == 0) x ++;
        else if(a[i] % 2 == 0) y ++;
        else z++;
    }
    if(z <= x || (y == 0  && z <= x+1)){
        cout<<"Yes"<<endl;
    }
    else cout << "No"<<endl;
}


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

int main(){
  
  string S;
  cin >> S;
  
  if (S == "MON") cout << 6 << endl;
  
  else if (S == "TUE") cout << 5 << endl;
  
  else if (S == "WED") cout << 4 << endl;
  
  else if (S == "THU") cout << 3 << endl;
  
  else if (S == "FRI") cout << 2 << endl;
  
  else if (S == "SAT") cout << 1 << endl;
  
  else cout << 7 << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
string s;int k;
cin >>s>>k;
vector <string> v;
for(int i=0;i<s.size();i++){
  for(int j=1;j<6;j++) v.push_back(s.substr(i,j));
}
sort(v.begin(),v.end());
v.erase(unique(v.begin(),v.end()),v.end());
cout <<v[k-1]<<endl;
}


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

int main()
{
    int num1, num2;
    cin>>num1>>num2;
    if((num1>=1 && num1<=9) && (num2<=9 && num2>=1)) {
        cout<<num1*num2<<endl;
    } else {
        cout<<"-1"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<pair<int, int>>v(N);
	rep(i, N)cin >> v[i].second >> v[i].first;
	sort(v.begin(), v.end());
	int sum = 0;
	rep(i, N)
	{
		sum += v[i].second;
		if (sum > v[i].first)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3328
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.List
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Vector.Unboxed as V ((!),fromList,Vector)
import Control.Monad
import Control.Monad.ST
import Debug.Trace

type DP s = STUArray s (Int,Int) Int

dp_i :: DP s-> Int -> Int -> Int -> Int -> Int -> ST s ()
dp_i dparr ai k i j prevsum
  | j < 0 = return ()
  | j >= k-ai = do
    hand0 <- readArray dparr (i-1,j)
    let nowsum = mod0 $ hand0 + prevsum
    writeArray dparr (i,j) nowsum
    dp_i dparr ai k i (j-1) nowsum
  | otherwise = do
    hand0  <- readArray dparr (i-1,j)
    handai <- readArray dparr (i-1,j+ai+1)
    let nowsum = mod0 $ hand0 + prevsum - handai
    writeArray dparr (i,j) nowsum
    dp_i dparr ai k i (j-1) nowsum

solve :: Int -> Int -> Vector Int -> ST s Int
solve n k as = do
  dparr <- newArray ((0,0),(n,k)) 0
  writeArray dparr (0,k) 1
  forM_ [1..(n-1)] $ \i ->
    dp_i dparr (as V.! (i-1)) k i k 0
  ans0 <- forM [0..(as V.! (n-1))] $ \j -> readArray dparr (n-1,j)
  return $ sum ans0

main :: IO ()
main = do
  [n,k]  <- map read.words <$> getLine
  as <- map read.words <$> getLine
  print $ mod0 $ runST $ solve n k (V.fromList as)

-------------------------
mod0 :: Int -> Int
mod0 n = mod n 1000000007


Measured memory_bytes: 87164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

using ld = long double;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    vector<ld> x(n + 2), y(n + 2), r(n + 2);
    x[0] = xs, y[0] = ys;
    x[n + 1] = xt, y[n + 1] = yt;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }
    vector<vector<ld>> g(n + 2, vector<ld>(n + 2));
    for (int i = 0; i < n + 2; i++) {
        for (int j = i + 1; j < n + 2; j++) {
            g[i][j] = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            g[i][j] = sqrtl(g[i][j]);
            g[i][j] -= r[i] + r[j];
            g[i][j] = max(0.0L, g[i][j]);
            g[j][i] = g[i][j];
        }
    }
    // debug(g);
    priority_queue<pair<ld, int>, vector<pair<ld, int>>, greater<pair<ld, int>>> pq;
    vector<ld> d(n + 2, 1e100);
    d[0] = 0;
    pq.push({0, 0});
    ld eps = 1e-12;
    while (!pq.empty()) {
        ld cd = pq.top().first;
        int v = pq.top().second;
        pq.pop();
        if (cd > d[v]) continue;
        for (int i = 0; i < n + 2; i++) {
            if (d[v] + g[v][i] < d[i]) {
                d[i] = d[v] + g[v][i];
                pq.push({d[i], i});
            }
        }
    }
    cout << fixed << setprecision(10);
    cout << d[n + 1] << '\n';
    return 0;
}


Measured memory_bytes: 25324
S = input()
T = input()

answer = len(T)

for i in range(0, len(S) - len(T) + 1):

    diff = 0

    for j in range(0, len(T)):
        if T[j] != S[i + j]:
            diff += 1

    answer = min(answer, diff)

print(answer)


Measured memory_bytes: 73192
def main():
    n = int(input())
    xy = []
    for i in range(n):
        a = int(input())
        xy.append([tuple(map(int, input().split())) for _ in range(a)])

    c = 0
    for i in range(1 << n):
        popcnt = bin(i).count('1')
        if popcnt <= c:
            continue
        all_honest = True
        for j in range(n):
            if (1 << j) & i != 0:
                for x, y in xy[j]:
                    x -= 1  # 人の番号をひとつずらす
                    if ((1 << x) & i) >> x != y:
                        all_honest = False
                        break
            if not all_honest:
                break
        if all_honest:
            c = popcnt

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import std.stdio;
void main() {
	int h, w;
	for (;;) {
		"%d %d\n".readf(&h, &w);
		if (h == 0 && w == 0) break;
		foreach (j; 0..h) {
			foreach (i; 0..w) {
				if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1)
					"#".write;
				else
					".".write;
				if (i == w - 1) "".writeln;
			}
		}
		"".writeln;
	}
}

Measured memory_bytes: 2472
#include<bits/stdc++.h>
using namespace std;
int main(){
	int arr[5];
	
	for(int i=0;i<5;i++)
		cin>>arr[i];
	
	for(int i=0;i<5;i++)	
		if(arr[i]==0)
		 	cout<<i+1;
	
}

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

int main () {
  int a,b,ans=0;cin>>a>>b;
  if(a>=13){
    ans=b;
    }else if(a>=6 && a<=12) {
    ans = b/2;
    }
  cout<<ans<<endl;
  
  return 0;
  }

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    bool qq[82];
    for (int i = 0; i <= 81; ++i) {
        qq[i] = false;
    }
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            qq[i*j] = true;
        }
    }
    if (qq[N]) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int s,w;
	std::cin >> s >> w;
	if(w>=s) print("unsafe");
	else print("safe");
	return 0;
}


Measured memory_bytes: 3632
N = int(input())

List = list(map(int,input().split()))

H = 0
ck = 0

for i in range(N):
  a = List[i]
  if a >= H:
    if a-1 >= H:
      H = a -1
    else:
      H = a
  else:
    ck = 1

print("Yes" if ck == 0 else "No")


Measured memory_bytes: 15020
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<(x)<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q,ans;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
bool flag,dame;

ll solve(ll a){
	if(a == -1){
		return 0;
	}else if(a % 4 == 1){
		return 1;
	}else if(a % 4 == 2){
		return a + 1;
	}else if(a % 4 == 3){
		return 0;
	}else{
		return a;
	}
}

int main(){
    cin >> a >> b;
	n = solve(a-1);
	m = solve(b);
	n = n ^ m;
	p(n);

	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long

long int nCr(long int n, long int r){
    long int product = 1;
    for(long int i = r; i <= n; i++)
        product *= i;
    
    for(long int i = 1; i <= n-r; i++)
        product /= i;
    
    return product;
}

int main(){
    IOS;

    long int n;
    cin>>n;

    vector<long int> v(n);
    for(long int i = 0; i < n; i++)
        cin>>v[i];
    
    vector<long int> dp(n,LONG_MAX);
    dp[0] = 0;

    for(long int i = 1; i < n; i++){
        if(i > 0)
            dp[i] = min(dp[i],abs(v[i]-v[i-1]) + dp[i-1]);
        
        if(i > 1)
            dp[i] = min(dp[i],abs(v[i] - v[i-2]) + dp[i-2]);
    }

    cout<<dp.back();
    return 0;
}

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

int main(){
    string s, p;
    cin >> s >> p;
    string s2 = s + s;
    bool exist = false;
    for (int i = 0; i < s.size(); i++){
        for (int j = 1; j <= 2 * s.size() - i; j++){
            if (p == s2.substr(i, j)) exist = true;
        }
    }
    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
long long a[100010];
int main(){
	long long n,A,B,ans=0;
	cin>>n>>A>>B;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
	}
	for(long long i=2;i<=n;i++){
		long long len=a[i]-a[i-1];
		long long tmp=len*A;
		if(tmp<B){
			ans+=tmp;
		}else ans+=B;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = a - b * 2;
    if(ans <= 0){
        cout << 0 << endl;
    }else {
        cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int N, L;
  cin >> N >> L;
  int b = L;
  int d = abs(L);
  int c = 0;
  for(int x=L; x<L+N; x++){
    if(abs(x)<d){
      b = x;
      d = abs(x);
    }
    c += x;
  }
  cout << c-b << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_S 3010

string S, T;

// 文字列 s と t の最長共通部分列(LCS)を求める
// O(2|s||t|)
string lcs(string s, string t) {
    // まず DP で長さを求める
    // s の [0, i] と、 t の [0, j] を使った時の LCS の長さ
    vector< vector<ll> > dp(s.length()+1, vector<ll>(t.length()+1, 0));
    for(int i = 1; i <= s.length(); ++i) {
        for(int j = 1; j <= t.length(); ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1] == t[j-1]) { dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1); }
        }
    }
    // この時点で dp[s.length()][t.length()] に LCS の長さが入る
    // ここから経路復元
    string ret = "";
    int s_ind = s.length(), t_ind = t.length();
    while(ret.length() < dp[s.length()][t.length()]) {
        if(dp[s_ind][t_ind] == dp[s_ind-1][t_ind]) { s_ind--; }     // 同じならこの s_ind は使われていない
        else if(dp[s_ind][t_ind] == dp[s_ind][t_ind-1]) { t_ind--; }
        else {
            s_ind--;
            t_ind--;
            ret += s[s_ind];
        }
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

// vector 版
// 配列 s と t の最長共通部分列(LCS)を求める
// O(|s||t|)
vector<ll> lcs(const vector<ll> s, const vector<ll> t) {
    vector< vector<ll> > dp(s.size()+1, vector<ll>(t.size()+1, 0));
    for(int i = 1; i <= s.size(); ++i) {
        for(int j = 1; j <= t.size(); ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1] == t[j-1]) { dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1); }
        }
    }
    vector<ll> ret;
    int s_ind = s.size(), t_ind = t.size();
    while(ret.size() < dp[s.size()][t.size()]) {
        if(dp[s_ind][t_ind] == dp[s_ind-1][t_ind]) { s_ind--; }
        else if(dp[s_ind][t_ind] == dp[s_ind][t_ind-1]) { t_ind--; }
        else {
            s_ind--;
            t_ind--;
            ret.push_back(s[s_ind]);
        }
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

signed main()
{
    cin >> S >> T;
    //printf("%s\n", lcs(S, T).c_str());
    vector<ll> sv, tv;
    REP(i, S.length()) { sv.push_back(S[i]); }
    REP(i, T.length()) { tv.push_back(T[i]); }
    vector<ll> ans = lcs(sv, tv);
    for(auto& c : ans) {
        printf("%c", static_cast<char>(c));
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll N,M; cin>>N>>M;
    map<ll,ll> data;
    rep0(i,N){
        ll K; cin>>K;
        rep0(j,K){
            ll a; cin>>a;
            data[a]++;
        }
    }
    ll ans=0;
    rep1(i,M){
        if(data.count(i)&&data[i]==N){ans++;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int m = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int count = 0;
		for(int i=22; i<=d; i++){
			if(i % 10 > 1 && (i / 10) * (i % 10) <= m){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//ユークリッドの互除法
ll gcd(ll x,ll y){
    if(x > y) swap(x,y);
    if(x == 0) return y;
    return gcd(x,y%x);
};

//最小公倍数
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
};

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll tmp = a-1;
    tmp -= (a-1)/c+(a-1)/d-(a-1)/lcm(c,d);
    ll ans = b;
    ans -= (b)/c+(b)/d-(b/lcm(c,d));
    ans -= tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;

int main() {
	int a, b, ans = 0;
	char ca[100], cb[100];

	cin >> a;

	if (a < 1000) { cout << "ABC" << endl; }
	else { cout << "ABD" << endl; }
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int n;
  cin>>n;
  if(n<1200)
  {
      cout<<"ABC"<<endl;
  }
  else
  {
      cout<<"ARC"<<endl;
  }


return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    string input;
    
    cin >> input;
    
    char* num = new char[input.length() + 1];
    strcpy(num, input.c_str());
    
    unsigned long size = input.size();
    int temp;
    
    temp = num[0] - '0';
    int result = 0;
    result += temp;
    
    for(int i = 1; i < size; i++){
        temp = num[i] - '0';
        
        if(temp == 9) {
            result += temp;
            continue;
        } else {
            result--;
            result += 9 * (size - i);
            break;
        }
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define AC 0
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int h,w;
	cin>>h>>w;
	map<int,int> val;
	multiset<int> ans;
	for(int i=0;i<w;i++) {
		val.insert(pair<int,int>(i,0));
		ans.insert(0);
	}
	for(int i=0,a,b;i<h;i++) {
		cin>>a>>b;
		a--;
		int mn=2e9;
		while(true) {
			map<int,int>::iterator mapit=val.lower_bound(a);
			if(mapit==val.end()||mapit->first>=b) break;
			ans.erase(ans.lower_bound(mapit->second));
			mn=min(mn,mapit->second+b-mapit->first);
			val.erase(mapit);
		}
		if(mn<2e9&&b<w) {
			if(val.count(b)) {
				ans.erase(ans.lower_bound(val[b]));
				val[b]=min(val[b],mn);
			}
			else val[b]=mn;
			ans.insert(val[b]);
		}
		if(ans.size()) cout<<*ans.begin()+i+1<<'\n';
		else cout<<"-1\n";
	}
	return AC;
}

Measured memory_bytes: 22364
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm>
#define MAX_V 2000
#define INF 1e5
using namespace std;
int n,m,S,T;
int V;
struct edge{
	int to,cap,rev,id;
	edge(int tt=0,int cc=0,int rr=0,int ii=0){
		to=tt;
		cap=cc;
		rev=rr;
		id=ii;
	}
};

vector<edge> G[MAX_V];
bool used[MAX_V];
void add_edge(int from,int to,int cap,int id){
	G[from].push_back(edge(to,cap,G[to].size(),id));
	G[to].push_back(edge(from,cap,G[from].size()-1,-id));
}

int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
	}
}

int main(void){
	scanf("%d %d",&n,&m);
	int S=n,T=S+1;
	for(int i=0;i<m;i++){
		int f,t;
		scanf("%d %d",&f,&t);
		f--;
		t--;
		add_edge(f,t,1,i+1);
	}
	int s,t;
	scanf("%d %d",&s,&t);
	s--;
	t--;
	add_edge(S,s,INF,0);
	add_edge(t,T,INF,0);
	int res=max_flow(S,T);
	vector<int> res_edge;
	for(int i=0;i<n;i++){
		for(int j=0;j<G[i].size();j++){
			if(G[i][j].id>0 && G[i][j].cap==2){
				res_edge.push_back(G[i][j].id);
			}
		}
	}
	printf("%d\n",res);
	printf("%d\n",res_edge.size());
	for(int i=0;i<res_edge.size();i++){
		printf("%d\n",res_edge[i]);
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=0;
  for(int i=1;i<n-1;i++){
    if((a[i-1]-a[i])*(a[i]-a[i+1])>=0)ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    long long k, n;
    cin >> k >> n;
    vector <long long> a;
    long long sum = 0;
    for(long long i=  0; i < n; i++)
    {
        long long x;
        cin >> x;
        a.push_back(x);
        if(i > 0)
            sum += a[i] - a[i - 1];
    }
    long long ans = 1e9;
    for(long long i = 1; i < n; i++)
    {
        ans = min(ans, k - a[n - 1] + a[0] + sum - (a[i] - a[i - 1]));
    }
    cout << min(ans, sum);
    return 0;
}


Measured memory_bytes: 2420
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5+5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int n;
  cin >> n;

  map<int,int>mp;
  f(i,0,n){
    int x;  cin >> x;
    mp[x]++;
  }
  if(mp.size() == 1){
    if(mp.begin()->first == 0){
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  } else if(mp.size() == 2){
    if(n%3 || mp.begin()->second * 3 != n || mp.begin()->first != 0){
      cout << "No\n";
    } else
      cout << "Yes\n";
  }  else if(mp.size() == 3){
    vector<int> v;
    for(auto it : mp){
      if(it.second * 3 != n){
        cout << "No\n";
        return 0;
      }
      v.push_back(it.first);
    }
    if((v[0] ^ v[1]) == v[2])
      cout << "Yes\n";
    else
      cout << "No\n";
  } else cout << "No\n";

  return 0;
}


Measured memory_bytes: 3840
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(u,a,b) for(int u=(a);u<(b);u++)
#define rrep(u,a,b) for(int u=(b)-1;u>=(a);u--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct HopcroftKarp {
	int n;
	vector<vector<int>> g;
	vector<int> match, dist;
	vector<bool> used, alive;
	HopcroftKarp(int n) : n(n), g(n), match(n), dist(n), used(n), alive(n, true) {}
	void addEdge(int u, int v) {
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	int maximumMatching() {
		int cnt = 0;
		fill(match.begin(), match.end(), -1);
		while (true) {
			buildAlternatingLevelGraph();
			fill(used.begin(), used.end(), false);
			int flow = 0;
			for (int u = 0; u < n; u++)
				if (match[u] == -1 && augment(u))
					flow++;
			if (flow == 0)break;
			cnt += flow;
		}
		return cnt;
	}
	void buildAlternatingLevelGraph() {
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int u = 0; u < n; u++)
			if (match[u] == -1) {
				q.emplace(u);
				dist[u] = 0;
			}
		while (q.size()) {
			int u = q.front(); q.pop();
			for (int v : g[u]) {
				int w = match[v];
				if (w != -1 && dist[w] == -1) {
					dist[w] = dist[u] + 1;
					q.emplace(w);
				}
			}
		}
	};
	bool augment(int u) {
		used[u] = true;
		for (int v : g[u]) {
			if (!alive[v])continue;
			int w = match[v];
			if (w == -1 || (!used[w] && dist[w] == dist[u] + 1 && augment(w))) {
				match[u] = v;
				match[v] = u;
				used[v] = true;
				return true;
			}
		}
		return false;
	}
};

template<class T, class ...Tail>
void tiedSort(vector<T> &a, vector<Tail>&... tail) {
	int n = a.size();
	using S = tuple<T, Tail...>;
	vector<S> s(n);
	for (int i = 0; i < n; i++)
		s[i] = make_tuple(a[i], tail[i]...);
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++)
		tie(a[i], tail[i]...) = s[i];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N, M, L; cin >> N >> M >> L&&N;) {
		static int g[110][110];
		memset(g, 0x3f, sizeof(g));
		rep(i, 0, M) {
			int u, v, d; cin >> u >> v >> d;
			g[u][v] = g[v][u] = d;
		}
		rep(i, 0, N)
			g[i][i] = 0;
		rep(k, 0, N)rep(i, 0, N)rep(j, 0, N) {
			if (g[i][k] != INF&&g[k][j] != INF)
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
		}

		vector<int> p(L), t(L); rep(i, 0, L) {
			cin >> p[i] >> t[i];
		}
		tiedSort(t, p);
		HopcroftKarp hk(L + L);
		int source = hk.n - 2, sink = source + 1;
		rep(i, 0, L) {
			rep(j, i + 1, L) {
				if (g[p[i]][p[j]] <= t[j] - t[i]) {
					hk.addEdge(i, L + j);
				}
			}
		}
		auto ans = L - hk.maximumMatching();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8284
k=int(input())
A=[1,2,3,4,5,6,7,8,9]
head=0
tail=len(A)
for z in range(10):
    for i in range(head,tail):
        now=A[i]%10
        ad=A[i]*10
        if now!=0:
            A.append(ad+now-1)
        if now!=9:
            A.append(ad+now+1)
        A.append(ad+now)
    head=tail
    tail=len(A)
A.sort()
print(A[k-1])

Measured memory_bytes: 28916
// Chrollo_Lucifer (nlather)
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  map<vector<int>, int> m;
  while(n--) {
    vector<int> v(26, 0);
    for(char i = 0, c; i < 10; i++)
      cin >> c, v[c-'a']++;
    m[v]++;
  }
  long ans = 0;
  for(auto &p : m) ans += (long)p.second*(p.second-1)/2;
  cout << ans;
}


Measured memory_bytes: 18944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min({a,b,c,d,e});
    ll ans = 4;
    if(n%m == 0){
        ans += (n/m);
    }else{
        ans += ((n/m) + 1);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    for (int i = b; i > 0; i /= 10) {
        a *= 10;
    }

    bool flag = false;
    for (int i = 1; i * i <= a + b; i++) {
        if (i * i == a + b) {
            flag = true;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
}


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

using namespace std;

int main()
{
	int A, B, C, D;
	int ans;

	cin >> A >> B >> C >> D;
	ans = min(B, D) - max(A, C);
	if (ans < 0)
		ans = 0;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
like =[]
for i in range(n):
    ka = list(map(int,input().split()))
    ka.pop(0)
    for j in range(m):
        if (j+1 in ka) and i == 0:
            like += [j+1]
        elif j+1 not in ka and j+1 in like and i != 0:
            like.remove(j+1)
print(len(like))


Measured memory_bytes: 3060
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var takahashi = tmp[0] - 0;
	var aoki = tmp[1] - 0;
  	var K = tmp[2] - 0;
  	
	//出力
	console.log(Math.max(takahashi - K,0) + " "
                + Math.min(aoki,Math.max(aoki-K+takahashi,0)));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll a;
  scanf("%lld", &a);
  cout << (a * 2 * 3.1415926535) << endl;
}


Measured memory_bytes: 3828
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

ll gcd(ll a, ll b)
{
    if (a > b)
        std::swap(a, b);

    while (true)
    {
        auto m = b % a;
        if (m == 0)
            return a;
        b = a;
        a = m;
    }
}

int main()
{
    using namespace std;

    string s;
    cin >> s;

    int l, r;
    l = stoi(s.substr(0, 2));
    r = stoi(s.substr(2, 2));

    auto lm = l > 0 && l <= 12;
    auto rm = r > 0 && r <= 12;

    if (lm || rm)
    {
        if (lm && rm)
        {
            cout << "AMBIGUOUS" << endl;
        }
        else if (lm && !rm)
        {
            cout << "MMYY" << endl;
        }
        else
        {
            cout << "YYMM" << endl;
        }
        
    }
    else
    {
        cout << "NA" << endl;
    }
    


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argA, argB, argC;
	cin >> argA >> argB >> argC;

	for (ll i = 0; i < argA * argB; ++i) {
		if (i % argA != 0) {
			continue;
		}
		if (i % argB == argC) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,k,a[55],sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){ 
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]<a[j]){ 
                swap(a[i],a[j]); 
            }
        }
    }
    for(int i=0;i<k;i++){
        sum+=a[i];
    }
    cout<<sum<<endl; 
    return 0; 
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 0
cnt = 0
prev = 0
for i in h:
  if i <= prev:
    cnt += 1
  else:
    if ans < cnt:
      ans = cnt
    cnt = 0
#  print(i, ans, cnt, prev)
  prev = i
if ans < cnt:
  ans = cnt
print(ans)

Measured memory_bytes: 14252
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let c = read char
    let a = int c + 1
    char a |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 11092