akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  ARC85_C Nov_14
//
//  Created by Shuangyi Zhang on 11/14/17.
//  Copyright © 2017 Shuangyi Zhang. All rights reserved.
//

#include <iostream>
#include <cmath>
using namespace std;
int n,m;
int main() {
    cin>>n>>m;
   // double p=1-1/pow(2,m);
    //cout<<p;
    double t=100*(n-m)+1900*m;
    cout<<t*pow(2,m);
    return 0;
}


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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);

	int a, b;
	cin >> a >> b;
	int c = a * b;
	cout << c << endl;
}

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

int main(){
  int N;
  cin >> N;
  switch(N){
    case 1:
      cout << "Hello World"<<endl;
      break;
    case 2:
      int A,B;
      cin >> A >> B;
      cout << A+B <<endl;
      break;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

count = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    count[p-1] += x

stack = [0]
visited = [0]*n
while stack:
    v = stack.pop()
    visited[v] = 1
    for v2 in edges[v]:
        if visited[v2] == 1:
            continue
        count[v2] += count[v]
        stack.append(v2)

print(*count)


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

int gcd(int a, int b){
    
    if ((0 == a)||(0 == b))
        return 0;
        
    while(a!=b){
        if(a>b)  a=a-b;
        else     b=b-a;
        }
        return a;
}


int main(void){
    long a,b;
     
    while(cin >> a >> b) {
        int lcm = a*b/gcd(a,b);
        
        cout << gcd(a,b) << " "<< lcm << endl;
    }
    
}



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

#define LONG_LONG_MAX 9223372036854775807

int main(){
	long i,n;
	long long min=LONG_LONG_MAX,marginmax=-LONG_LONG_MAX,R;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> R;
		if(R - min > marginmax) marginmax = R-min;
		if(R<min) min=R;
	}
	cout << marginmax << endl;
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,C;
ll A,B,W;
ll T,a,b;
double v[55],D[55];
ll ans=0;
bool h,o;
//bool D[100005];
ll S[50][50]={};
char str1[55][55],str2[55][55];
map<string,int> m;

int main(){
	cin>>N>>M;
	for(int i=0;i<N;++i){
		for(int j=0;j<N;++j){
			cin>>str1[i][j];
		}
	}
	for(int i=0;i<M;++i){
		for(int j=0;j<M;++j){
			cin>>str2[i][j];
		}
	}
	o=0;
	for(int i=0;i<N-M+1;++i){
		for(int j=0;j<N-M+1;++j){
			h=0;
			for(int k=0;k<M;++k){
				for(int l=0;l<M;++l){
					if(str1[i+k][j+l]!=str2[k][l]){
						h=true;
						break;
					}
				}
			}
			if(!h){
				cout<<"Yes"<<endl;
				o=true;
				break;
			}
		}
		if(o)break;
	}
	if(!o)cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<tuple<string,int>> vt;
  int ans = 0;
  for(auto&& i:irange(0,n)) {
    string s;
    int t;
    cin>>s>>t;
    vt.emplace_back(s,t);
    ans += t;
  }
  string x;
  cin>>x;
  int i = 0;
  string s;
  do {
    int t;
    tie(s,t) = vt[i];
    ans -= t;
    i++;
  } while (s != x);
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	int a,b,keta;
	while(cin>>a>>b){
		keta = 1;
		a = a+b;
		while(a /= 10){
			keta++;
		}

		cout<<keta<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int get(int x) {
	int sum = 0;
	while (x) {
		sum += x%10;
		x /= 10;
	}
	return sum;
}
int main() {
	int n = 0;
	scanf("%d", &n);
	int res = 1000000;
	for(int i=1;i<n;i++) {
		int a = i;
		int b = n - i;
		res = min(res, get(a) + get(b));
	}
	cout<<res;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
use=[0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(N+1)
dp[0]=0
for i in range(N+1):
    for k in A:
        if i+use[k]<=N:
            dp[i+use[k]]=max(dp[i]+1,dp[i+use[k]])
ans=""
now=N
for i in range(dp[N]):
    for k in A:
        if now-use[k]>=0:
            if dp[now-use[k]]==dp[now]-1:
                ans+=str(k)
                now-=use[k]
                break
print(ans)

Measured memory_bytes: 3416
/*************************************************************************
    > File Name: C.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-12-15 20:35:08
 ************************************************************************/

#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN];
int cur[25];
bool check(int x)
{
    memset(cur,0,sizeof(cur));
    for(int k=1;k<=20;k++) cur[k]=1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>20) continue;
        if(i!=1&&a[i]<=a[i-1]) 
        {
            cur[a[i]]++;
            for(int j=a[i]+1;j<=20;j++) cur[j]=1;
            int now=a[i];
            while(now>=1&&cur[now]>x)
            {
                cur[now]=1;
                now--;
                cur[now]++;
            }
        }
    }
    if(cur[0]>0) return false; else return true;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    bool f=true;
    for(int i=2;i<=n;i++)
    {
        if(a[i]<=a[i-1]) f=false;
    }
    if(f)
    {
        puts("1");
        return 0;
    }
    int l=1,r=n;
    while(r-l>1)
    {
        int mid=(l+r)/2;
        if(!check(mid)) l=mid; else r=mid;
    }
    printf("%d\n",r);
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int a, b, c, k, i, j, min, ans=0, leng=0, po=0;
    scanf("%lld %lld", &a, &b);
    if(a<10&&b<10) printf("%lld", a*b);
    else printf("-1");
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n,x;
	cin>>n>>x;
	int a[n+1];
	a[0]=0;
	for(int i=1;i<n+1;i++)
	{
	    cin>>a[i];
	}
	for(int i=1;i<n+1;i++)
	{
	    a[i]=a[i]+a[i-1];
	}
	int cnt=0;
	for(int i=0;i<n+1;i++)
	{
	    if(a[i]<=x)
	    {
	        cnt++;
	    }
	}
	cout<<cnt<<endl;
}

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

int main(){
	int n;
	cin >> n;
	for(int i=0; i < n; i++) {
		char s;
		cin >> s;
		if(s != 'Y')
			continue;
		cout << "Four" << endl;
		return 0;
	}
	cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.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 Long() {
        return long.Parse(next());
    }

    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;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main(string[] args) {
        int N = cin.Int();
        var h = new int[N + 2];
        int[] input = cin.ArrayInt(N);
        for (int i = 1; i <= N; i++) {
            h[i] = input[i - 1];
        }

        int cnt = 0;
        while(!h.All(x => x == 0)) {
            for (int i = 1; i <= N + 1; i++) {
                if (h[i - 1] > 0 && h[i] == 0) cnt++;
            }
            for (int i = 1; i <= N; i++) {
                if (h[i] > 0) h[i]--;
            }
        }
        Console.WriteLine(cnt);
        Console.ReadLine();
    }
}

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

//素数判定
bool judge_prime(int x) {
  if (x == 2) {
    return true;
  }
  else if (x % 2 == 0) {
    return false;
  }
  
  double sqrtx = sqrt(x);
  for (int i = 3; i <= sqrtx; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int X;
  cin >> X;
  while (true) {
    if (judge_prime(X)) {
      cout << X << endl;
      break;
    }
    else {
      X++;
    }
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
    	String[] sai = br.readLine().split(" ");
    	String order = br.readLine();
    	int[] newsai = new int[6];
    	int a =  0;
    	for (int i = 0; i < 6; i++)
    	{
    		newsai[i] = Integer.parseInt(sai[i]);
    	}
    	
    	for (int i = 0; i < order.length(); i++)
    	{
    		char houkou = order.charAt(i);
    		if (houkou == 'N')
    		{
    			a = newsai[0];
    			newsai[0] = newsai[1];
    			newsai[1] = newsai[5];
    			newsai[5] = newsai[4];
    			newsai[4] = a;
    		}
    		else if (houkou == 'S')
    		{
    			a = newsai[0];
    			newsai[0] = newsai[4];
    			newsai[4] = newsai[5];
    			newsai[5] = newsai[1];
    			newsai[1] = a;
    		}
    		else if (houkou == 'E')
    		{
    			a = newsai[0];
    			newsai[0] = newsai[3];
    			newsai[3] = newsai[5];
    			newsai[5] = newsai[2];
    			newsai[2] = a;
    		}
    		else if (houkou == 'W')
    		{
    			a = newsai[0];
    			newsai[0] = newsai[2];
    			newsai[2] = newsai[5];
    			newsai[5] = newsai[3];
    			newsai[3] = a;
    		}
    	}
    	System.out.println(newsai[0]);
	}
}

Measured memory_bytes: 24492
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型の利用*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))

//date 03/07
//abc158

int main(void)
{
  char s[3];
  char *a= "AAA";
  char *b="BBB";
  bool flag = true;
    scanf("%s", &s);
  if (strcmp(s,a) == 0 || strcmp(s,b) == 0) {
    printf("No\n" );
  }else printf("Yes\n" );
  return 0;
}


Measured memory_bytes: 128
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n, k, a, b, ans = 0;
    cin >> n >> k;
    vector<int> A(n);
    for(auto &x : A) cin >> x;

    REP(i, n){
        a = A[i] * 2;
        b = abs(k - A[i]) * 2;
        ans += min(a, b);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    string S; is >> S;
    if(!is) return;
    string pre;
    string now;
    ll K = 0;
    for (auto &&s : S) {
        now += s;
        if(pre != now){
            K++;
            pre = now;
            now = "";
        }
    } // end s
    cout << K << endl;


}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

bool mas[4][4][4];
string s = "LURD";
const int dy[] = { 0, -1, 0, 1}, dx[] = { -1, 0, 1, 0};

void dfs( int y, int x, int pos){
  cout << s[pos];
  if(!y && !x){
    cout << endl;
    return;
  }
  for(int i = 0 ; i < 4 ; i++ ){
    int dd = ( pos + 3 + i ) % 4;
    int ny = y + dy[ dd], nx = x + dx[ dd];
    if(mas[y][x][dd]){
      dfs( y + dy[ dd], x + dx[ dd], dd);
      return;
    }
  }
}
int main(){
  char c;
  for(int i = 0 ; i < 9 ; i++ ){
    if(i & 1) for(int j = 0 ; j < 5 ; j++ ){
      cin >> c;
      if(c == '1') mas[i / 2][j][3] = mas[i / 2 + 1][j][1] = true;
    } else for(int j = 0 ; j < 4 ; j++ ){
      cin >> c;
      if(c == '1') mas[i / 2][j][2] = mas[i / 2][j + 1][0] = true;
    }
  }
  dfs( 0, 1, 2);
}

Measured memory_bytes: 1180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String base;
		String comparison;
		
		try {
			base = br.readLine();
			comparison = br.readLine();
			
			Inversions(base, comparison, br);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	public static void Inversions(String base, String comparison,  BufferedReader br){ 
		StringBuilder sb = new StringBuilder();
		int length = base.length() - comparison.length();
		String 	container;
		int ans_num = 0;
		int[] ans = new int[1000000];
		
		for(int i = 0; i <= length ; i ++ ) {
			container = base.substring( i, i + comparison.length() );
			if( container.equals(comparison) ) {
				ans[ans_num] = i;
				ans_num ++;
			}
		}
		
		for(int i = 0; i <ans_num; i++){;
			sb.append(ans[i] + "\n");
		}
		 
		System.out.print(sb);
	}
}


Measured memory_bytes: 28452
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)] #各ノードの親番号
        self.rank = [0] * (n) #各ノードのランク（木の高さ）
        self.root = [-1]*(n+1) # -（各ノードの属するグループの要素数）

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            node = [x]
            cur = node[0]
            while self.par[cur] != cur:
                cur = self.par[cur]
                node.append(self.par[cur])
            
            for n in node:
                self.par[n] = cur
            
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.root[x] += self.root[y]
            self.root[y] = self.root[x]
        else:
            self.par[y] = x
            self.root[x] += self.root[y]
            self.root[y] = self.root[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
                
    # グループ数
    def groupsize(self):
        cnt = 0
        for i,x in enumerate(self.par):
            if x == i:
                cnt += 1
        return cnt

    # xの属すグループの要素数
    def size(self, x):
        return -self.root[self.find(x)]
    
    # xの属すグループの要素リスト
    def members(self, x):
        ret = []
        rootNode = self.find(x)
        for i in range(len(self.par)):
            if self.find(i) == rootNode:
                ret.append(i)
        return ret
    
    # ルートノードのリストを取得
    def get_roots(self):
        ret = []
        for i,x in enumerate(self.par):
            if x==i:
                ret.append(i)
        return ret
    
    # 各グループ毎の要素リストを取得
    def all_members(self):
        L = len(self.par)
        roots = self.get_roots()
        namedict = [0]*L
        for i,r in enumerate(roots):
            namedict[r] = i
        
        
        ret = [[] for _ in range(len(roots))]
        for i in range(len(self.par)):
            p = namedict[self.find(i)]
            ret[p].append(i)
        return ret
            
    

N,M,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
CD = [list(map(int,input().split())) for _ in range(K)]
    
uf = UnionFind(N)
for a,b in AB:
    uf.union(a-1,b-1)
    
ans = [0]*N
 
for group in uf.all_members():
    L = len(group)-1
    for a in group:
        ans[a] = L
        
# friends = [0]*N
# brock = [0]*N
for a,b in AB:
    ans[a-1] -= 1
    ans[b-1] -= 1
 
for c,d in CD:
    if uf.same_check(c-1,d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
 
print(*ans)
        
    
    
    
    
    
    
    

Measured memory_bytes: 109784
n=gets.to_i
s=gets.chomp
max=0
0.step(n-2) do |i,sum=0|
  a=s[0..i].split("").uniq
  b=s[i+1..n-1].split("").uniq
  a.each{|an| sum+=1 if b.include?(an)}
  max=sum if max<sum
end
puts max


Measured memory_bytes: 3836
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long t[] = new long[n+1];
		long x[] = new long[n+1];
		long y[] = new long[n+1];
		t[0]=0;
		x[0]=0;
		y[0]=0;
		n++;
		for(int i=1; i<n; i++) {
			t[i]=sc.nextLong();
			x[i]=sc.nextLong();
			y[i]=sc.nextLong();
		}
		for(int i=1; i<n; i++) {
			long tt= t[i]-t[i-1];
			long xx = Math.abs(x[i]-x[i-1]);
			long yy = Math.abs(y[i]-y[i-1]);

			if(tt<xx+yy || (tt-(xx+yy))%2!=0) {
				System.out.println("No");
				sc.close();
				return;
			}
		}
		System.out.println("Yes");
		sc.close();
	}
}


Measured memory_bytes: 60208
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    int a,b;
    a=0;b=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            a++;
        }else{
            b++;
        }
    }
    if(a>b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll A, B;
    cin >> A >> B;
    cout << max(0LL, A - B - B) << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
  let mut input = String::new();

  io::stdin().read_line(&mut input)
    .expect("Failed to read line");

  let mut output = String::new();
  let input = input.trim_right();

  if input == "A" {
    output = "T".to_string();
  }
  else if input == "T" {
    output = "A".to_string();
  }
  else if input == "G" {
    output = "C".to_string();
  }
  else {
    output = "G".to_string();
  }


  println!("{}", output);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int n, q;
ll S[100000], T[50000];

int cond(ll x, ll qq){
    // fprintf(stderr, "%lld %lld\n", x, qq);

	if(S[x] < qq) return 0;
	return 1;
}

ll binarySearch(ll MX, ll qq){
	ll left = 0;
	ll right = MX;

	if(cond(0, qq) == 1) return 0;
	if(cond(MX-1, qq) == 0) return MX;

	while (left + 1 < right){
		ll mid = (left + right) / 2;
		if(cond(mid, qq) == 0) {
			left = mid;
		}
		else{
			right = mid;
		}
	}
	return right;
}

bool exist(ll qq){
    // fprintf(stderr, "----- \n");
	ll bs = binarySearch(n, qq);
    // fprintf(stderr, "----- %lld %lld\n", qq, bs);

    if (bs == n) return false;
	return S[bs] == qq;
}

int main() {
	cin >> n;
	rep(i, n) { cin >> S[i]; }
	cin >> q;
	rep(i, q) { cin >> T[i]; }

	int ret = 0;
	rep(i, q) {
		if(exist(T[i])) ret++;
	}
	cout << ret << endl;
}

Measured memory_bytes: 4260
#include<bits/stdc++.h>
 
using namespace std;
 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_A&lang=jp
 
struct Edge {
  int dst,weight;
};
 
int TravelingSalesmanProblem(int V,int E,vector<int> s,vector<int> t,vector<int> d) {
  vector<vector<Edge> > G(V);
  vector<int> cost(V,INT_MAX);
  cost[0] = 0;
  for(int i=0;i<E;++i) {
    G[s[i]].push_back((Edge){t[i],d[i]});
    if( t[i] == 0 ) {
      cost[s[i]] = min(cost[s[i]],d[i]);
    }
  }
  vector<vector<int> > dp((1<<V),vector<int>(V,INT_MAX));
  dp[1][0] = 0;
  for(int state=0;state<(1<<V);++state) {
    for(int cur=0;cur<V;++cur) if( dp[state][cur] != INT_MAX ) {
        for(int i=0;i<(int)G[cur].size();++i) {
          Edge &e = G[cur][i];
          if( (state>>e.dst) & 1 ) continue;
          dp[state|(1<<e.dst)][e.dst] = min(dp[state|(1<<e.dst)][e.dst],
                                            dp[state][cur]+e.weight);
        }
      }
  }
 
  int mini = INT_MAX;
  for(int i=0;i<V;++i) if( dp[(1<<V)-1][i] != INT_MAX && cost[i] != INT_MAX ) {
    mini = min(mini,dp[(1<<V)-1][i]+cost[i]);
  }
  return (mini!=INT_MAX)?mini:-1;
}
 
int main() {
  int V,E;
  cin >> V >> E;
  vector<int> s(E), t(E), d(E);
  for(int i=0;i<E;++i) cin >> s[i] >> t[i] >> d[i];
  cout << TravelingSalesmanProblem(V,E,s,t,d) << endl;
  return 0;
}

Measured memory_bytes: 6292
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 256
#include<stdio.h>
struct Card
{
  char mark;
  char value;
};

main(){
  struct Card C1[100],C2[100],c;
  int n,i,j,mini;
  char ch;
  scanf("%d%c",&n,&ch);
  for(i=0;i<n;i++)
    {
      scanf("%c%c%c",&C1[i].mark,&C1[i].value,&ch);
      C2[i]=C1[i];
    }

  for(i=0;i<=n-1;i++)
    {
      for(j=n-1;j>=i+1;j--)
	{
	  if(C1[j].value<C1[j-1].value)
	  {
	    c=C1[j];
	    C1[j]=C1[j-1];
	    C1[j-1]=c;
	  }
	}
    }

  for(i=0;i<=n-1;i++)
    {
      mini=i;
      for(j=i;j<=n-1;j++)
	{
	  if(C2[j].value<C2[mini].value)
	    {
	      mini=j;
	    }
	}
      c=C2[i];
      C2[i]=C2[mini];
      C2[mini]=c;
    }
  for(i=0;i<n;i++)
    {
      printf("%c%c",C1[i].mark,C1[i].value);
      if(i<n-1) printf(" ");
    }
  printf("\nStable\n");
  for(i=0;i<n;i++)
    {
      printf("%c%c",C2[i].mark,C2[i].value);
      if(i<n-1) printf(" ");
    }
  for(i=0;i<n;i++)
    {
    if(C1[i].mark!=C2[i].mark)
      {
	printf("\nNot stable\n"); break;
      }
    }
  if(i==n) printf("\nStable\n");

  return 0;
}

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

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

int N;
char s[MAXN];
int cnt[30];

int main() {
	scanf("%d%s", &N, s);
	for (int i = 0; i < N; i++)
		cnt[s[i] - 'a']++;
	
	int ans = 1;
	for (int i = 0; i < 26; i++)
		ans = (long long)ans * (cnt[i] + 1) % MOD;
	
	printf("%d\n", (ans + MOD - 1) % MOD);
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N;

//解法
void solve() {

	int ans = 1111;
	for (int i = 1; i <= 9; i++) {
		int a = i * 111;
		if (a >= N && a < ans) ans = a;
	}
	cout << ans;
	return;
}

int main() {
	//入力
	cin >> N;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long L,R,ans;
  cin >> L >> R;
  if(R-L>2019-1)ans=0;
  else{
    ans=2019;
    for(long long i=L;i<R;i++){
    for(long long k=i+1;k<=R;k++){
      if((i*k)%2019<ans)ans=(i*k)%2019;
     }
    }
  }
  cout << ans << flush;
  return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> demand;
    
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        demand.emplace_back(a,b);
    }

    sort(demand.begin(),demand.end());
    ll ans =0;
    ll place =0;
    set<int> endPoint;
    for(int i=0;i<N;i++){
        if(endPoint.find(i) != endPoint.end()){
            // cerr <<"i=" << i <<"found" << endl;
            ans++;
            endPoint.clear();
        }
        while(demand[place].first ==i){
            //  cerr <<"place found at" <<demand[place].first << endl; 
            endPoint.insert(demand[place].second);
            place++;
        }
        
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
vector<int> a(3, 0);
int main() {
    for(int i = 0; i < 3; ++i) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());

    if(a.at(0) + a.at(1) == a.at(2)) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007 
#define MOD1 998244353
#define ll long long int
#define db double
#define endl "\n"
#define INF 1000000000000000000
#define INF1 1000000000
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define debx cout<<" X "<<endl;
#define deby cout<<" Y "<<endl;
#define debz cout<<" Z "<<endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;
using namespace std;
 
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2)
        return (a*temp)%MOD;
    return temp;
}
ll mod_in(ll n){
    return mpow(n,MOD-2);
}
ll cl(ll a, ll b){
    if(a%b)
        return 1+a/b;
    return a/b;
}
ll dig(ll n){
    if(!n)
        return 0;
    return 1 + dig(n/10);
}
int main(){
    // fastio
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>

int main() {
	char s[51], t[51];
	std::cin >> s >> t;
	if (strlen(s) < strlen(t)) {
		printf("UNRESTORABLE");
		return 0;
	}

	for (int i = strlen(s) - strlen(t); i >= 0; i--) {
		bool flag = true;
		for (int j = i; j < strlen(t)+i; j++) {
			if (s[j] != '?'&&s[j] != t[j-i]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			for (int j = i; j < strlen(t)+i; j++) {
				s[j] = t[j - i];
			}
			for (int j = 0; j < strlen(s); j++) {
				if (s[j] == '?')s[j] = 'a';
			}
			printf("%s", s);
			return 0;
		}
	}
	printf("UNRESTORABLE");
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Possible"  # type: str
NO = "Impossible"  # type: str


def solve(A: int, B: int):
    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        print(YES)
    else:
        print(NO)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int a,b,c ;
	cin >> a >> b >> c ;
	int d = a+b+c ;
	if((max(a,max(b,c))*3-d)%2==0) cout << (max(a,max(b,c))*3-d)/2 << endl ;
	else cout << (max(a,max(b,c))*3-d+3)/2 << endl ;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 'APPROVED'
for i in range(n):
	if a[i] % 2 == 0:
		if a[i] % 3 != 0 and a[i] % 5 != 0:
			ans = 'DENIED'
			break

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, K, ts[MAX_N], ds[MAX_N];
  scanf("%ld %ld", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%ld %ld", &ts[i], &ds[i]);
    ts[i]--;  // note modified input
  }

  // zip ts and ds and sort
  vector<pair<long, long>> ps;
  for (int i = 0; i < N; i++) {
    ps.push_back(make_pair(ds[i], ts[i]));
  }
  sort(ps.begin(), ps.end(), greater<pair<long, long>>());

  // take k from ts
  vector<long> nums(N, 0);
  long num_types = 0, sum_d = 0;
  for (int i = 0; i < K; i++) {
    const long d = ps[i].first, t = ps[i].second;
    if (nums[t] == 0) {
      num_types++;
    }
    sum_d += d;
    nums[t]++;
  }

  // try other candidates by replacing
  int add_i = K, remove_i = K - 1;
  long ans = sum_d + num_types * num_types;
  while (1) {
    // look for next element to remove
    while (remove_i >= 0 && nums[ps[remove_i].second] <= 1) {
      remove_i--;
    }
    if (remove_i < 0) {
      break;
    }

    // look for next element to add
    while (add_i < N && nums[ps[add_i].second] > 0) {
      add_i++;
    }
    if (add_i >= N) {
      break;
    }

    // replace
    nums[ps[remove_i].second]--;
    nums[ps[add_i].second]++;
    num_types++;
    sum_d += ps[add_i].first - ps[remove_i].first;
    ans = max(ans, sum_d + num_types * num_types);
    remove_i--;
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 4208
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-08-02 19:55:50
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    n = int(input())
    s = input()

    a = ''.join(list(sorted(list(s))))

    cnt = 0
    for i in range(n):
        if a[i] != s[i]: cnt += 1
    print(cnt>>1)
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 80916
import java.util.Scanner;

public class Main{
  public static void main (String[] args){
    Scanner scan = new Scanner(System.in);
    int W = scan.nextInt();
    int H = scan.nextInt();
    int x = scan.nextInt();
    int y = scan.nextInt();
    int r = scan.nextInt();

    if(x+r>W|| x-r<0|| y+r>H|| y-r<0){
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 26320
N=int(input())
A=list(map(int,input().split()))
c=[0]*9
for i in A:
    c[min(i//400,8)]+=1
for i in range(8):
    if c[i]>0:
        c[i]=1
if c[:8]==[0]*8:
    print(1,c[-1])
else:
    print(sum(c[:8]),sum(c[:8])+c[-1])


Measured memory_bytes: 38256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int main() {
	string MARCH = "MARCH";
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A,B,C,X,Y;
	cin >> A >> B >> C >> X >> Y;
	int ans = C * 100000 * 2;
	REP(k, 100001) {
		ans = min(ans, 2*C*k + max(X-k,0) * A + +max(Y - k,0) * B);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right
N, M, K = map(int, input().split())
A = [0]+list(map(int, input().split()))
B = [0]+list(map(int, input().split()))
for i in range(N):
    A[i+1] += A[i]
for i in range(M):
    B[i+1] += B[i]
ans = 0
for i in range(N+1):
    if A[i] > K:
        break
    ans = max(i+bisect_right(B, K-A[i])-1, ans)
print(ans)

Measured memory_bytes: 112832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] strs = br.readLine().split(" ");
		int[] inputData = new int[n];
		for (int i = 0; i < n; i++) {
			inputData[i] = Integer.parseInt(strs[i]);
		}
		printArray(inputData, selectionSort(inputData));
	}

	public static int selectionSort(int[] A) {
		int swapCnt = 0;
		for (int i = 0; i < A.length; i++) {
			int minIdx = i;
			for (int j = i; j < A.length; j++) {
				if (A[minIdx] > A[j]) {
					minIdx = j;
				}
			}
			if (i == minIdx) continue;
			int temp = A[i];
			A[i] = A[minIdx];
			A[minIdx] = temp;
			swapCnt++;
		}
		return swapCnt;
	}

	public static void printArray(int[] target, int swapCnt) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < target.length; i++) {
			sb.append(target[i]);
			if (i < target.length - 1) {
				sb.append(" ");
			}
		}
		sb.append("\n");
		sb.append(swapCnt);
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24464
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			double[] x = new double[3];
			double[] y = new double[3];
			for(int i=0; i<3; i++)
			{
				x[i] = scanner.nextDouble();
				y[i] = scanner.nextDouble();
			}
			double px = scanner.nextDouble();
			double py = scanner.nextDouble();
			
			double pa_x = px - x[0];
			double pa_y = py - y[0];
			double pb_x = px - x[1];
			double pb_y = py - y[1];
			double pc_x = px - x[2];
			double pc_y = py - y[2];
			
			double axb = pa_x*pb_y - pa_y*pb_x;
			double bxc = pb_x*pc_y - pb_y*pc_x;
			double cxa = pc_x*pa_y - pc_y*pa_x;
			
			String str = "NO";
			if((axb>0 && bxc>0 && cxa>0) || (axb<0 && bxc<0 && cxa<0) )
			{
				str = "YES";
			}
			
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 32632
//##MohK
//08/03/2020.... 6,35.
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll counter=0,counterr=0;
    string s;
    cin>>s;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='A')counter++;
        else counterr++;
    }
    if(counter==3||counterr==3)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        Map<Integer, Long> map = IntStream.range(0, n).mapToObj(m -> sc.nextInt()).collect(Collectors.groupingBy(v -> v, Collectors.counting()));
        long sum = map.keySet().stream().mapToLong(v -> v * map.get(v)).sum();
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int before = sc.nextInt();
            int after = sc.nextInt();
            if (map.containsKey(before)) {
                long count = map.get(before);
                sum += (after - before) * count;
                System.out.println(sum);
                map.remove(before);
                if (map.containsKey(after)) {
                    map.replace(after, map.get(after) + count);
                } else {
                    map.put(after, count);
                }
            } else {
                System.out.println(sum);
            }
        }
    }
}


Measured memory_bytes: 67476
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());
            long saving = 100;
            int ans = 0;

            while (saving < X)
            {
                saving += (saving/100);
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27540
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;
char a[101][101];
int d[101][101];
int dx[] = { 0,1 };
int dy[] = { 1,0 };
int n, m;
queue<pair<int, int>> q;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	if (a[1][1] == '#')d[1][1] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (i == 1 && j == 1)continue;
			d[i][j] = 1e9;
			if (a[i][j] == '.') {
				if (i - 1 >= 1) {
					d[i][j] = min(d[i - 1][j], d[i][j]);
				}
				if (j - 1 >= 1) {
					d[i][j] = min(d[i][j - 1], d[i][j]);
				}
			}
			else {
				if (i - 1 >= 1) {
					if (a[i - 1][j] == '#') {
						d[i][j] = d[i - 1][j];
					}
					else d[i][j] = d[i - 1][j] + 1;
				}
				if (j - 1 >= 1) {
					if (a[i][j - 1] == '#') {
						d[i][j] = min(d[i][j], d[i][j - 1]);
					}
					else {
						d[i][j] = min(d[i][j - 1] + 1, d[i][j]);
					}
				}
			}
		}
	}

	cout << d[n][m] << '\n';




}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int p=998244353;
int n,m,mx,i,j,k,l,val,ans,f[302][302][302],a[302],b[302],sum,sz;
char s[10010];
int main(){
	scanf("%s",s+1);
	scanf("%d",&mx);
	n=strlen(s+1);
	for(i=1;i<=n;i++){
		if(s[i]=='1')sz++,sum++;
		 else{
		 	a[++m]=sz;sz=0;
		 }
	}
	f[0][0][0]=1;
	for(i=1;i<=m;i++){
		b[i]=a[i];
		a[i]+=a[i-1];
		for(j=a[i-1];j<=sum;j++)
		 for(k=0;k<=min(j,mx);k++)if(f[i-1][j][k])
		  for(l=max(0,a[i]-j);l<=sum-j;l++){
		  	val=max(0,l-b[i]);
		  	if(k+val<=mx)(f[i][j+l][k+val]+=f[i-1][j][k])%=p;
		  }
	}
	for(j=a[m];j<=sum;j++)
	for(k=0;k<=min(mx,sum);k++)ans=(ans+f[m][j][k])%p;
	printf("%d",ans);
}

Measured memory_bytes: 17756
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
H.insert(0,0)
L = []
C = 0
for i in range(N+1):
    L.append(list())
for i in range(M):
    A, B = list(map(int, input().split()))
    L[A].append(B)
    L[B].append(A)
for i, l in enumerate(L):
    if i == 0:
        continue
    if len(l) == 0:
        C += 1
        continue
    for n in l:
        f = True
        if H[i] <= H[n]:
            f = False
            break
    if f:
        C += 1
print(C)

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

using I = long long;
const I M = 998244353;

I power(I m, I n) {
  if(!n) return 1;
  return (n & 1) ? (power(m, n - 1) * m % M) : power(m * m % M, n >> 1);
}
I factorial(I n) {
  static std::vector<I> memo = {1};
  while(I(memo.size()) <= n) memo.emplace_back(memo.back() * I(memo.size()) % M);
  return memo.at(n);
}

I inverse(I n) {
  return power(n, M - 2);
}
I combination(I n, I r) {
  if(!n) return 1;
  if(n < r) return 0;
  return (factorial(n) * inverse(factorial(n - r)) % M) * inverse(factorial(r)) % M;
}

int main() {
  I N, A, B, K;
  cin >> N >> A >> B >> K;

  I ans = 0;
  for(I a=0; a<=N; ++a) {
    auto k = a * A;
    if(K < k) continue;
    auto b = (K - k) / B;
    if(N < b) continue;
    if(a * A + b * B != K) continue;
    (ans += combination(N, a) * combination(N, b) % M) %= M;
  }
  cout << ans << endl;
}

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

using namespace std;

unsigned long long dic[524288];
unsigned char k[128];

unsigned long long hash(const char *str) {
	unsigned long long hash=1;
	do{
		hash=(hash<<2)+k[(unsigned)*str];
	}while(*++str);
	return hash;
}

void set(unsigned long long hash) {
	dic[hash>>6]|=(1ULL<<(hash&63));
}

bool get(unsigned long long hash) {
	return true&&(dic[hash>>6]&(1ULL<<(hash&63)));
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string com;
	k['C']=1;
	k['G']=2;
	k['T']=3;

	int n;
	cin>>n;
	cin.ignore();
	for(int i=0; i<n; i++) {
		getline(cin, com);
		if(com[0]=='i') {
			set(::hash(com.c_str()+7));
		} else {
			if(get(::hash(com.c_str()+5))) cout<<"yes\n";
			else cout<<"no\n";
		}
	}
	return 0;
}



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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = ReadLine();
			var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			long answer = 1;

			if(line.Any(value => value == 0))
			{
				WriteLine(0);
				return;
			}

			foreach(var value in line)
			{
				if(answer > 1000000000000000000 / value)
				{
					WriteLine(-1);
					return;
				}
				answer *= value;
			}

			WriteLine(answer);
		}
	}
}


Measured memory_bytes: 37276
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
ch -= 1
cw -= 1
dh, dw = map(int, input().split())
dh -= 1
dw -= 1
s = [input() for _ in range(h)]

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
dxw = [-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2]
dyw = [-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]

q = deque()
q.append((ch, cw, 0))
ans = [[10 ** 9] * w for _ in range(h)]
while len(q) > 0:
    x, y, c = q.popleft()
    for i in range(4):
        nx, ny = x + dx[i], y + dy[i]
        if (
            nx >= 0
            and nx < h
            and ny >= 0
            and ny < w
            and c < ans[nx][ny]
            and s[nx][ny] == "."
        ):
            q.appendleft((nx, ny, c))
            ans[nx][ny] = c
    for i in range(24):
        nx, ny = x + dxw[i], y + dyw[i]
        if (
            nx >= 0
            and nx < h
            and ny >= 0
            and ny < w
            and c + 1 < ans[nx][ny]
            and s[nx][ny] == "."
        ):
            q.append((nx, ny, c + 1))
            ans[nx][ny] = c + 1
v = ans[dh][dw]
print(-1 if v == 10 ** 9 else v)


Measured memory_bytes: 95524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,s=0;
	cin>>a;

	
	for(int i=1;i<=a;i+=2)
	{   int k=0;
	
		for(int j=1;j<=sqrt(i);j++)
		{
			if(i%j==0)
			k+=2;
		}
		if(int(sqrt(i))==sqrt(i))
		k--;
		
		if(k==8)
		s++;
		
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256