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

char map[2100][2100];
int height[2100][2100];
using std::pair;
using pii = pair<int, int>;
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", map[i]);
		for (int j = 0; j < w; j++) {
			map[i][j] = (map[i][j] == '#');
		}
	}
	h--; w--;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int cnt = map[i][j] + map[i + 1][j] + map[i][j + 1] + map[i + 1][j + 1];
			if (cnt % 2 == 0) {
				height[i][j] = true;
			}
		}
	}
	for (int i = 1; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (height[i][j]) {
				height[i][j] += height[i - 1][j];
			}
		}
	}
	int ans = std::max(h+1,w+1);
	for (int i = 0; i < h; i++) {
		std::vector<pii> stack;
		for (int j = 0; j < w; j++) {
			int left = j;
			while (!stack.empty() && stack.back().first >= height[i][j]) {
				int W = j - stack.back().second;
				int H = stack.back().first;
				ans = std::max(ans, (W + 1)*(H + 1));
				left = stack.back().second;
				stack.pop_back();
			}
			stack.push_back({ height[i][j],left });
		}
		while (!stack.empty()) {
			int W = w - stack.back().second;
			int H = stack.back().first;
			ans = std::max(ans, (W + 1)*(H + 1));
			stack.pop_back();
		}
	}
	printf("%d", ans);
}

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

#define                      ff                                          first
#define                      ss                                          second
#define                      pai                                         acos(-1)
#define                      ll                                          long long
#define                      pb                                          push_back
#define                      mp                                          make_pair
#define                      pll                                         pair<ll,ll>
#define                      sz(a)                                       (ll)a.size()


double dis(double x,double y)
{
    return sqrt((x*x)+(y*y));
}
int  main(int argc, char const *argv[])
{
    ll i,j,k,a,b,c,d,n,m,t,h,u,v,x,y,z;
    cin>>n>>m;
    ll cnt=0;
    while(n--)
    {
        cin>>x>>y;
        if(dis(x,y)<=m)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    int ans=0;
    vector <string> str(n);
    int aowa=0, bhazime=0,ab=0;
    for(int i=0;i<n;i++){
        cin>>str[i];
        for(int j=0;j<str[i].size()-1;j++){
            if(str[i][j]=='A'&&str[i][j+1]=='B') ans++;
        }
        if(str[i][0]=='B'&&str[i][str[i].size()-1]=='A') ab++;
        else{
        if(str[i][0]=='B') bhazime++;
        if(str[i][str[i].size()-1]=='A') aowa++;}
    }
    //cout<<ans<<endl;
    int fans=ans, ans2=0,ans3=0,ans4=0,ans5=0;
    //cout<<ab<<endl;
    /*
    cout<<aowa<<endl;
    cout<<bhazime<<endl;
    */
    //全部あるとき
    if(aowa>0&&bhazime>0&&ab>0){
    int a=aowa,b=bhazime, tab=ab;
    a--; b--; 
    ans2=fans+tab+1+min(a,b);
    }
    //BAがないとき
    if(ab==0){
        int a=aowa,b=bhazime;
        ans3=fans+min(a,b);
    }
    //~Aがないとき
    if(aowa==0&&ab){
        int tab=ab, b=bhazime;
        if(b) ans4=fans+tab;
        else ans4=fans+tab-1;
    }
    //B~がないとき
    if(bhazime==0&&ab){
        int tab=ab, a=aowa;
        if(a) ans5=fans+tab;
        else ans5=fans+tab-1;
    }
    int final_answer=0;
    final_answer=max({ fans,ans2,ans3,ans4,ans5});
    //ans+=min(aowa+ab,bhazime+ab);
    //if(aowa==0&&bhazime==0) ans--;
    cout<<final_answer<<endl;
}

Measured memory_bytes: 768
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	string s;

	cin >> s;

	FOR(i, 0, 18) {
		if (s[i] == ',') {
			cout << " ";
		}
		else {
			cout << s[i];
		}
	}

	cout << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll a, b, c, d, e;cin >> a >> b >> c >> d >> e;
	ll x = a * 60 + b;
	ll y = c * 60 + d;
	cout << (y - x - e) << endl;

	return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c ;
  string ans ="No";
  if((a+b)==c)
   ans = "Yes";
  if(a ==(b+c))
    ans = "Yes";
  if((a+c)==b)
    ans = "Yes";
  cout << ans ;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	var dishes Records
	dishes = make([]Record, N)
	for i := 0; i < N; i++ {
		d := Record{}
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &d.a, &d.b)
		dishes[i] = d
	}
	sort.Sort(dishes)

	ans := 0
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			ans = ans + dishes[i].a
		} else {
			ans = ans - dishes[i].b
		}
	}
	fmt.Println(ans)
}

type Record struct {
	a, b int
}

type Records []Record

func (r Records) Len() int {
	return len(r)
}
func (r Records) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func (r Records) Less(i, j int) bool {
	return r[i].a+r[i].b > r[j].a+r[j].b
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b)
	printf("a < b\n");
	else if(a>b)
	printf("a > b\n");
	else
	printf("a == b\n");
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, x;
	vector<llong> a;

	cin >> N >> x;
	a.resize(N);
	for(int i = 0; i < N; i++)
		cin >> a[i];

	llong ans = 0;
	for(int i = 1; i < N; i++){
		llong dif = a[i] + a[i-1] - x;
		ans += max(0ll, dif);

		if(dif > 0){
			a[i] = max(0ll, a[i] - dif);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N,a,check=0;
  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> a;
    if((!(a%2))&&(a%3)&&(a%5)){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()

ans = 0
n = len(s)
for i in range(2 ** (n-1)):
    t = 0
    for j in range(n):
        t *= 10
        t += int(s[j])
        
        if ((i >> j) & 1):
            ans += t
            t = 0
    ans += t

print(ans)


Measured memory_bytes: 2940
n = int(input())
c = list(input())

r = []
for i in range(n):
    if c[i] == 'R':
        r.append(i)

count = 0
for i in range(len(r)):
    if r[i] != i:
        r.insert(i, i)
        r.pop()
        count += 1

print(count)




Measured memory_bytes: 18652
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {
	string res = "None";
	string S; cin >> S;

	for (int i = 97; i < 123; i++) if (count(S.begin(), S.end(), (char)i) == 0) { res = (char)i; break; }

	cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main()
{
    int k;
    cin >> k;
    switch (k)
    {
    case 1:
    case 2:
    case 3:
    case 5:
    case 7:
    case 11:
    case 13:
    case 15:
    case 17:
    case 19:
    case 23:
    case 29:
    case 31:
        cout << 1 << endl;
        break;
    case 4:
    case 6:
    case 9:
    case 10:
    case 14:
    case 21:
    case 22:
    case 25:
    case 26:
        cout << 2 <<endl;
        break;
    case 8:
    case 12:
    case 18:
    case 20:
    case 27:
        cout << 5 << endl;
        break;
    case 28:
    case 30:
        cout << 4 << endl;
        break;
    case 16:
        cout << 14 << endl;
        break;
    case 24:
        cout << 15 << endl;
        break;
    case 32:
        cout << 51 << endl;
        break;
    }
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int main(){

	int n;
	cin>>n;
	float x1,y1,x2,y2,x3,y3,x4,y4;
	while(n>0){
		
		float a=999999,b=999999;
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;

		if(x2!=x1){
			a=(y2-y1)/(x2-x1);
		}
		if(x3!=x4){
			b=(y4-y3)/(x4-x3);
		}
		
		if(a==b)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
		n--;
	}
	
	
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    long long N;
    cin >> N;

    if(N % 2 == 1){
        cout << 0 << endl;
    }
    else{
        long long cnt5 = 0;
        long long temp = 10;
        for(int i = 1; i <= 25; i++){
            cnt5 += N / temp;
            temp *= 5;
        }

        cout << cnt5 << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long int ll;

int main()
{
   int n,k;
   cin >> n >> k;
   vector<ll>A(n),a(n);
   for(int i = 0; i < n; i++) cin >> A[i];
   ll cost = 1e11;
   for(int bit = 0; bit < (1<<n);bit++)
   {
       a = A;
       ll sum = 0;
       for(int i = 1; i < n; i++)
       {
           if(bit & (1<<i))
           {
               ll high = 0;
               for(int j = 0; j < i; j++)
               {
                   high = max(high,a[j]);
               }
               if(high >= a[i])
               {
                   sum += high - a[i] + 1;
                   a[i] = high + 1;
               }
           }
       }
       int see = 1;
       ll high = a[0];
       for(int i = 1; i < n; i++)
       {
           if(high < a[i])
           {
               see++;
               high = a[i];
           }
       }
       if(see >= k) 
       {
           cost = min(cost,sum);
       }
   }
   cout << cost << endl;
}


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

int solve(int x, int y) {
    x = abs(x);
    y = abs(y);
    if (x + y == 0) return 0;
    if (x + y == 1) return 1;
    if (x % 2 == 0 && y % 2 == 0) {
        return x + y;
    }
    if (x % 2 == 0 || y % 2 == 0) {
        if (x == 0 || y == 0) {
            return x + y + 1;
        }
        return x + y;
    }
    return x + y - 1;
}

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

    int x, y;
    while (cin >> x >> y) {
        cout << solve(x, y) << endl;
    }
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstdio>


#define rep(X, Y) for(int (X) = 0; (X) < (Y); ++(X))
#define MAX 1001

typedef long long ll;

int n;
ll m, b[MAX], h[MAX*MAX], res = -1;

int main(){
	while(scanf("%d%lld", &n, &m), n|m){

		rep(i, n){
			scanf("%lld", b + i + 1);
		}
		++n;

		rep(i, n){
			rep(l, n){
				h[i * n + l] = b[i] + b[l];
			}
		}

		std::sort(h, h + n * n);

		res = -1;
		rep(i, n*n){
			auto it = std::upper_bound(h, h + n * n, m - h[i]);

			if( it - 1 >= h ) res = std::max(res, *(it - 1) + h[i]);
		}

		printf("%lld\n", res);
	}

	return 0;
}

Measured memory_bytes: 9024
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
ans = 'War'
for i in range(X+1, Y+1):
	flag = True
	for j in range(0, N):
		if i <= x[j]:
			flag = False
	for j in range(0, M):
		if y[j] < i:
			flag = False
	if flag:
		ans = 'No '+ans
		break
print(ans)

Measured memory_bytes: 39024
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int x[100010],n;
void read(){
	n=0;
	char ch=getchar();
	while (ch!='\n') {
		n++; if (ch=='g') x[n]=0; else x[n]=1;
		ch=getchar();
	}
}
int main()
{
	read();
	int ans=0;
	for (int i=1;i<=n;i++) {
		if (i%2) {
			if (x[i]) ans--;
		} else {
			if (!x[i]) ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(5);
  
  for(int i = 0 ; i < 5; i++){
    cin >> vec.at(i);
  }
  int k;
  cin >> k;
  
sort(vec.begin(), vec.end());

  int c = vec.at(4) - vec.at(0);
  
 if(c <= k) cout << "Yay!" << endl;
 
  else cout << ":(" << endl;
   
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[n+1], b[n+1], c[n+1];
  
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++) cin >> b[i];
  for(int i=2; i<=n; i++) cin >> c[i];

  int res = 0;
  
  for(int i=1; i<=n; i++){
      int d = a[i];
      res += b[d];

      if(i != 1 && a[i] == a[i-1] + 1) res += c[a[i]];
  }

  cout << res << endl;

}  


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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "delete" :
            list.delete( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public StringBuilder getAllElements() {
    StringBuilder buf = new StringBuilder(size*2);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf;
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    current = nil.next;

    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else if( target == nil.prev ) deleteLast();
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 190584
N = int(input())
inputs = [int(i) for i in input().split()]

set_inputs = set(inputs)
if N % 3 == 0:
    list_inputs = list(set_inputs)
    if (len(set_inputs) == 3 
    and list_inputs[0] == (list_inputs[1] ^ list_inputs[2]) 
    and (inputs.count(list_inputs[0]) == inputs.count(list_inputs[1]) == inputs.count(list_inputs[2]))):
        print('Yes')
    elif len(set_inputs) == 2:
        list_inputs = list(set_inputs)
        if inputs.count(list_inputs[0]) > inputs.count(list_inputs[1]):
            more = list_inputs[0]
            less = list_inputs[1]
        else:
            more = list_inputs[1]
            less = list_inputs[0]
        if less == 0 and inputs.count(more) == inputs.count(less) * 2:
            print('Yes')
        else:
            print('No')
    elif len(set_inputs) == 1:
        if inputs[0] == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if set_inputs == set([0]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14212
#include<stdio.h>
#include<algorithm>

using namespace std;

int N, W, w[100], v[100], vals = 0;

void input(){
  scanf("%d %d", &N, &W);
  for(int i=0; i<N; i++){
    scanf("%d %d", &w[i], &v[i]);
    vals += v[i];
  }
}

int main(){
  input();
  int DP[100001] = {0};
  for(int i=1; i<100000; i++){
    DP[i] = -1;
  }
  for(int i=0; i<N; i++){
    for(int j=vals; j>=v[i]; j--){
      if(DP[j-v[i]] == -1){
        continue;
      }
      if(DP[j-v[i]] + w[i] > W){
        continue;
      }
      if(DP[j] == -1){
        DP[j] = DP[j-v[i]] + w[i];
      }
      else{
        DP[j] = min(DP[j-v[i]] + w[i], DP[j]);
      }
    }
  }
  for(int i=vals; i>=0; i--){
    if(DP[i] != -1){
      printf("%d", i);
      break;
    }
  }
}

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

void swap(int &a, int &b) {
	int tmp = a;
	a = b;
	b = tmp;
}

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

	if(a > c) {
		swap(a, c);
	}
	if(b > c) {
		swap(b, c);
	}
	if(a > b) {
		swap(a, b);
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
vector<long long>fact(200550);
long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}
long long per(long long a, long long b){
    long long cur = (fact[b] * fact[a]) % mod;
    cur = bigmod(cur, mod - 2);
    cur = (cur * fact[a + b]) % mod;
    return cur;
}
int main(){
    long long h, w, a, b;
    cin >> h >> w >> a >> b;
    long long ans = 0;
    fact[0] = 1;
    for(long long i = 1; i <= 200010; i++){
        fact[i] = (fact[i - 1] * i) % mod;
    }
    long long p = h - a, q = b + 1;
    while(p >= 1 && q <= w){
        ans = (ans + (per(p - 1, q - 1) * per(h - p, w - q)) % mod) % mod;
        p--;
        q++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    fori(n) cin>>a[i];
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<s.size();++i)
    {
        if(s[i]=='?')
        {
            s[i]='D';
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  int n;
  cin>>n;
  vector<ll> X,Y;
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    X.push_back(x);
    Y.push_back(y);
  }
  double ans = 0;
  rep(i,n){
    rep(j,n){
      ans += 1.0 * sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j])) / n;
    }
  }
  cout<<setprecision(10)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    input()
    mod = 10**9 + 7
    arr = sorted(map(int, input().split()))
    arr.reverse()

    sm = arr[0] + arr[1]
    ans = arr[0] * arr[1] % mod

    for x in range(2, len(arr)):
        ans += sm * arr[x]
        sm += arr[x]

    print(ans % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  string s;
  cin>>s;
  int n=s.size();

  ll ans=0;
  ll now=0;
  rep(i,n){
    if(s[i]=='T')now++;
    if(s[i]=='S')now--;
    ans=max(ans,now);
  }
  


  cout << 2*ans << endl;

}


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

int n, x, y;

int gcd(int a, int b){
	while(a!=0){
		if(b>a){
			int temp = a;
			a = b;
			b = temp;
		}
		a %= b;
	}
	return b;
}

int main(void){
	cin >> n;
	cin >> x;
	for(int i=1; i<n; i++){
		cin >> y;
		x = gcd(x, y);
	}
	cout << x << endl;
}

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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int a[N];s64 s[N];	

int main()
{
	//freopen("1.in","r",stdin);
	int n;cin>>n;
	rep(i,1,n)scanf("%d",a+i);
	sort(a+1,a+n+1);
	rep(i,1,n)s[i]=s[i-1]+a[i];
	int i=n;
	while(i)
	{
		--i;
		if(s[i]*2<a[i+1])break;
	}
	printf("%d\n",n-i);
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int sum = 0,num;
	string s;
	stringstream ss;
	while(cin >> s)
	{
		rep(i,s.length())
		{
			if(s[i] < '0' || s[i] > '9')
			{
				s[i]  = ' ';
			}
		}

		ss << s;
		while(ss >> num)
		{
			sum += num;
		}

		ss.str();
		ss.clear(stringstream::goodbit);
	}

	cout << sum << endl;
	return 0;
}

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

int main() {

	ll x; cin >> x;
	int r = 1;
	int y = 0;
	ll m = 100;
	while (m < x) {
		m = m + m * r / 100;
		y++;
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  k--;
  s[k] = s[k] + 0x20;

  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int array[N];
  int n,minj;
  int i,j;
  int count=0;
  int temp;

  /* Input */
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(array[j]<array[minj]){
	minj=j;
      }
    }
    temp=array[i];
    array[i]=array[minj];
    array[minj]=temp;
    if(i!=minj) count++;
  }

  /* Output */
  for(i=0;i<n-1;i++){
    printf("%d ",array[i]);
  }
  printf("%d\n",array[n-1]);
  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef vector<int> vi;

int n,m,a[10];
int use[20][20];
vi ans;

vi check(void){
  vi res(n);
  for(int i=1;i<=n;i++){
    int now = i;
    for(int j=0;j<m;j++){
      if(use[j][now])now++;
      else if(use[j][now-1])now--;
    }
    res[now-1] = i;
  }
  return res;
}

int count(void){
  int res = 0;
  for(int i=0;i<m;i++){
    for(int j=0;j<=n;j++){
      if(use[i][j])res = max(res,i);
    }
  }
  return res+1;
}

int rec(int d){
  if(d==m){
    /*
    for(int i=0;i<m;i++){
      for(int j=0;j<=n+1;j++)cout << use[i][j] << " ";
      cout << endl;
    }
    cout << endl;
    */

    vi tmp = check();
    if(tmp==ans)return count();
    else return m;
  }
  int v = a[d];

  int res = m;
  for(int i=0;i<m;i++){
    if(use[i][v-1] || use[i][v] || use[i][v+1])continue;
    
    use[i][v] = 1;
    res = min(res,rec(d+1));
    use[i][v] = 0;
  }

  return res;
}

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

  memset(use,0,sizeof(use));
  for(int i=0;i<m;i++)use[i][a[i]] = 1;
  ans = check();

  memset(use,0,sizeof(use));
  cout << rec(0) << endl;
}

Measured memory_bytes: 1220
STDIN.to_a[1..-1].each do |value|
	value =~ /^(\d+) (\d+) (\d+)$/
	array = [$1.to_i, $2.to_i, $3.to_i]
	array.sort!
	if ((array[0]**2 + array[1]**2) == array[2]**2)
		puts "YES"
	else
		puts "NO"
	end
end

Measured memory_bytes: 6108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        if(Math.abs(a - c) <= d){
            System.out.println("Yes");
        }else if((Math.abs(a - b) <= d && Math.abs(b - c) <= d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}
 

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
char s[26];
string s1;
cin>>s1;
int i=0;
for(char c='A';c<='Z';c++){
   s[i++]=c;
}
int pos,r;
string res="";
for(int i=0;i<s1.size();i++){
    for(int j=0;j<26;j++){
      if(s1[i]==s[j]){
        pos=j;
      }
    }
    r=(pos+n)%26;
    res+=s[r];

}
for(int i=0;i<s1.size();i++){
  cout<<res[i];
}
}


Measured memory_bytes: 256
n=input()
K=int(input())
ns=len(n)
dp=[[[0]*(5) for _ in range(2)]for _ in range(ns+1)]
dp[0][0][0]=1
for i in range(ns):
    for k in range(K+1):
        dp[i+1][1][k+1]+=dp[i][1][k]*9
        dp[i+1][1][k]+=dp[i][1][k]
        if int(n[i])>0:
            dp[i+1][1][k+1]+=dp[i][0][k]*(int(n[i])-1)
            dp[i+1][1][k]+=dp[i][0][k]
            dp[i+1][0][k+1]+=dp[i][0][k]
        else:
            dp[i+1][0][k]+=dp[i][0][k]

#print(dp)
print(dp[ns][0][K]+dp[ns][1][K])

Measured memory_bytes: 62340
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,M,Q;
int a[100],b[100],c[100],d[100];
int dfs(int mx,int point,int retsu[15]){
    if(point==N){
        int ret=0;
        rep(i,Q){
            if(retsu[b[i]]-retsu[a[i]]==c[i])ret+=d[i];
        }
        /*rep(j,N){
            printf("%lld,",retsu[j]);
        }
        printf("\n%lld\n",ret);*/
        return ret;
    }
    int sans=0;
    for(int i=mx;i<=M;i++){
        retsu[point]=i;
        sans=max(sans,dfs(i,point+1,retsu));
    }
    return sans;
}
signed main(){
    scanf("%lld %lld %lld",&N,&M,&Q);
    rep(i,Q){
        scanf("%lld %lld %lld %lld",&a[i],&b[i],&c[i],&d[i]);
        a[i]--;b[i]--;
    }
    int retsu[15];
    int ans=dfs(1,0,retsu);
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 200000000000;
    for(int i = 0; i <= 200000; i+=2) {
        ll cost = c * i;
        cost += max(0, x - (i / 2)) * a;
        cost += max(0, y - (i / 2)) * b;
        ans = min(ans, cost);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashSet<String> set = new HashSet<>();
    for (int i = 0; i < n; i++) {
      String s = sc.next();
      set.add(s);
    }
    System.out.println(set.size());
  }
}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();

		int H = sc.nextInt();

		int N = sc.nextInt();

		int[] X = new int[N];

		int[] Y = new int[N];

		int ans = 0;

		for(int i=0;i<N;i++) {

			X[i] = sc.nextInt();

			Y[i] = sc.nextInt();
		}

		int x0 = X[0];

		int y0 = Y[0];

		int x1, y1;

		for(int i=1;i<N;i++) {

			x1 = X[i];

			y1 = Y[i];

			if(x0==x1) {

				ans += Math.abs(y0-y1);

				x0 = x1;

				y0 = y1;

			}else if(y0==y1) {

				ans += Math.abs(x0-x1);

				x0 = x1;

				y0 = y1;

			}else if(x0-x1 == y0-y1) {

				ans += Math.abs(x0-x1);

				x0 = x1;

				y0 = y1;

			}else {

				if((x0>x1&&y0>y1 || x0<x1&&y0<y1)) {

					ans += Math.max(Math.abs(x0-x1),Math.abs(y0-y1));

				}else {

					ans += Math.abs(x0-x1);

					ans += Math.abs(y0-y1);
				}

				x0 = x1;

				y0 = y1;

			}

		}

		System.out.println(ans);
	}

}



Measured memory_bytes: 33028
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <functional>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;
ll pow(int x, int y) {
  ll ans = 1;
  rep(i,y) {
    ans *= x;
  }
  return ans;
}

int main() {
	int n,m;
	cin >> n >> m;
  if (n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  int s, c;
  map<int,int> map;
  rep(i,m) {
    cin >> s >> c;
    auto iterator = map.find(s);
    if (iterator != map.end() && iterator->second != c) {
      cout << -1 << endl;
      return 0;
    }
    if (s == 1 && c == 0 && n != 1) {
      cout << -1 << endl;
      return 0;
    }
    map.insert(make_pair(s, c));
  }

  ll ans = 0;
  auto ite1 = map.find(1);
  if (ite1 == map.end()) ans += pow(10, (n - 1));
  for(auto it = map.begin(); it != map.end(); it++) {
    ans += pow(10, (n - it->first)) * it->second;
  }
	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
# define vll vector<ll>
# define vvll vector<vector<ll>>
# define vpll vector<pll>
# define ppll pair<pll,ll>
ll M=1000000007;
ll MAX=LONG_LONG_MAX;
template<typename T>
//using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}
ll func(int i,int j,int b,vvll &dp,vll &v)
{
   if(i==j){ 
      if(b==1)
   return v[i];
   else
   return 0;}
   if(dp[i][j]!=-1)
   return dp[i][j];
   if(b==1)
   {
      return dp[i][j]=max(func(i+1,j,2,dp,v)+v[i],func(i,j-1,2,dp,v)+v[j]);
   }
   else
   {
       return dp[i][j]=min(func(i+1,j,1,dp,v),func(i,j-1,1,dp,v));
   }
   

}
int main()
{
   int n;
   cin>>n;
   ll c=0;
   vvll dp(n,vll(n,-1));
   vll v(n);
   for(int i=0;i<n;i++){
    cin>>v[i]; c+=v[i];}
    cout<<2*func(0,n-1,1,dp,v)-c;

}

Measured memory_bytes: 70912
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if (A<B) {
			if (A<C && C<B) {
				System.out.println("Yes");
			}
			else
				System.out.println("No");
		}
		else {
			if (A>C && C>B) {
				System.out.println("Yes");
			}
			else
				System.out.println("No");
		}
		
	}
}	


Measured memory_bytes: 20948
def check():
    if N %2 == 1:
        if A.pop(0) != 0:
            return 0
        pair = 2
    else:
        pair = 1
    
    for i in range(N//2):
        if A[2*i] == pair and A[2*i+1] == pair:
            pair += 2
        else:
            return 0
    return 1

N = int(input())
A = list(map(int, input().split()))
A.sort()
mod = int(1e9 +7)
if check() == 0:
    print(0)
else:
    print(pow(2, N//2, mod))

Measured memory_bytes: 52204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

void swap(int &a, int &b)
{
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

int partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for (int j = p; j < r; j++)
	{
		if (A[j] <= x)
		{
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

int main()
{
	int n, q;
	cin >> n;
	int *A = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	q = partition(A, 0, n - 1);
	for (int i = 0; i < n; i++)
	{
		if (i == q)
		{
			cout << "[" << A[i] << "]";
		}
		else
		{
			cout << A[i];
		}
		if (i == n - 1)
		{
			cout << endl;
		}
		else
		{
			cout << " ";
		}
	}
	delete A;
	return 0;
}


Measured memory_bytes: 3128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	m := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
		m[a[i]]++
	}
	// out(m)
	ans := 1
	if N%2 == 1 {
		if m[0] != 1 {
			out(0)
			return
		}
		for i := 2; i <= N-1; i += 2 {
			if m[i] != 2 {
				out(0)
				return
			}
			ans *= 2
			ans %= mod
		}
	} else {
		for i := 1; i <= N-1; i += 2 {
			if m[i] != 2 {
				out(0)
				return
			}
			ans *= 2
			ans %= mod
		}
	}
	out(ans)
}


Measured memory_bytes: 2816
Menu = [int(input()) for _ in range(5)]
# 届く時間を1の位で切り上げたとき、届く時間の和
time_max = sum(map(lambda x: (x + 9) // 10 * 10, Menu))
# 1の位で切り上げたとき、最も元の時間との差が大きいもの
tmp = max(map(lambda x: (x + 9) // 10 * 10 - x, Menu))
print(time_max - tmp)

Measured memory_bytes: 2940
(let* ((a (read))
       (b (read))
       (c (read))
       (d (gcd a b))
       (lst nil))
  (loop :for n :from 1 :upto d :do (if (= 0 (mod a n) (mod b n))
                                       (push n lst)
                                       nil))
  (princ (nth (1- c) lst)))

Measured memory_bytes: 13284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < N; i++) {
			int tmp = Math.min(2*x[i], 2*(K-x[i]));
			ans += tmp;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 300005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

v<ll> fact(N);
v<ll> prime_check(1e6 + 2);
v<ll> primes;

long long powmod(long long x, long long y, long long m)
{
    long long res = 1LL;
    while (y)
    {
        if (y & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return res;
}

void init_fact()
{
    fact[0] = 1;
    for (ll i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll C(ll n, ll r)
{
    if (n < r)
        return 0;
    ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
    temp *= powmod(fact[n - r], mod - 2, mod);
    temp %= mod;
    return temp;
}

void Sieve()
{
    for (ll i = 2; i <= 1e6 + 1; i++)
    {
        if (prime_check[i])
            continue;
        primes.pb(i);
        for (ll j = 2 * i; j <= 1e6 + 2; j += i)
            prime_check[j] = i;
    }
}
ll phi(ll n)
{
    ll i, res = n;
    for (i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            while (n % i == 0)
                n /= i;
            res -= res / i;
        }
    if (n > 1)
        res -= res / n;
    return res;
}

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

string s, t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin >> s >> t;
    ll ans = 0;
    for (ll i = 0; i < s.size(); i++)
        if (s[i] != t[i])
            ans++;
    cout << ans << "\n";
}

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

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

  vector<string> s(n);
  for (int i = 0; i < s.size(); i++){
    cin >> s.at(i);
    sort(s.at(i).begin(), s.at(i).end());
  }
  sort(s.begin(), s.end());

  long ans = 0;
  long flag = 0;
  string temp_s = "";
  for (int i = 0; i < s.size(); i++){
    if (temp_s == s.at(i)){
      flag++;
      ans += flag;
    }else {
      temp_s = s.at(i);
      flag = 0;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int nums;
	map<string,bool> a;
	scanf("%d", &nums);
	map<string, bool> ::iterator it;
	for (int i = 0; i < nums; i++) {
		string temp;
		cin >> temp;
		it = a.find(temp);
		if (it != a.end()) a.erase(it);
		else a[temp] = 1;
	}
	cout << a.size();
	return 0;
}

Measured memory_bytes: 8064
using System;
using System.Linq;

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var list = text.Split(' ').ToList();

            var r = int.Parse(list[0]);
            var n = int.Parse(list[1]);

            text = Console.ReadLine();

            var line = text.Substring(0, n - 1) + text.Substring(n - 1, 1).ToLower();
            if (r != n){
                line = line + text.Substring(n, r - n);
            }
            
            Console.WriteLine(line);
        }
    }
}


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

int main(){
	int n,k;
	cin>>n>>k;
	set<int>s;
	while(k--){
		int d,x;
		cin>>d;
		for(int i=0;i<d;i++)
			cin>>x,s.insert(x);
	}
	cout<<n-s.size()<<endl;
	return 0;
}


Measured memory_bytes: 3616
import java.util.*;
import java.io.*;

public class Main {
    public static int[] wt;
    public static int[] val;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int C = Integer.parseInt(st.nextToken());
        wt = new int[N];
        val = new int[N];
        int maxVals = 0;
        for (int i=0; i<N; i++){
            st = new StringTokenizer(br.readLine());
            wt[i] = Integer.parseInt(st.nextToken());
            val[i] = Integer.parseInt(st.nextToken());
            maxVals+=val[i];
        }

        long[][] dp = new long[N+1][maxVals+1];
        for (int i=0; i<=maxVals; i++){
            dp[0][i] = Integer.MAX_VALUE;
        }
        dp[0][0]=0;

        for (int i=1; i<=N; i++){
            for (int j = 1; j <= maxVals; j++) {
                dp[i][j]=dp[i-1][j];
                if(j-val[i-1]>=0){
                    dp[i][j] = Math.min(dp[i][j], wt[i-1]+dp[i-1][j-val[i-1]]);
                }
            }
        }
        long ans=0;
        for (int i = 0; i<=maxVals; i++){
            if(dp[N][i]<=C)
                ans=i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 126164
#include <stdio.h>

int main()
{
	int a,b,c,x,d;
	int T = 0;

	scanf("%d %d %d",&a,&b,&c);
	for (x = a;x <= b;x++) {
		if (c%x == 0) {
			T++;
		}
	}
	printf("%d\n",T);

	return 0;
}

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

const int MAX_N = 22;

int C[MAX_N], V[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> V[i];
    for (int i = 0; i < N; i++) cin >> C[i];
    int ans = 0;
    for (int mask = 0; mask < (1 << N); mask++) {
        int sub_ans = 0;
        for (int i = 0; i < N; i++) {
            if ((mask >> i) & 1) {
                sub_ans += V[i] - C[i];
            }
        }
        ans = max(ans, sub_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n,m,x = list(map(int,input().split()))
c = []
a = []

for i in range(n):
  stdIn = list(map(int,input().split()))
  c.append(stdIn[0])
  a.append(stdIn[1:])
flag = 0
ans = sum(c)
for i in range(2**n):
  result = np.array([0]*m)
  price = 0
  for j in range(n):
    if((i>>j)&1):
      result += a[j]
      price += c[j]
  if (len(result[result<x])==0):
    ans = min(ans,price)
    flag = 1
print(ans if flag != 0 else -1)

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

int main(){
  ll n,h,w,h1,w1;
  cin>>n>>h>>w;
  int count=0;
  for(int i=0;i<n;i++){
    cin>>h1>>w1;
    if(h1>=h && w1>=w){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256