akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
//typedef long long ll;
//typedef long double ld;
//typedef unsigned long long ull;
//typedef unsigned long double uld;
typedef pair<int,int> P;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int n;
    cin >> n;
    int sum = 0;
    int t[n];
    rep(i,n){
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    int ans = 3e5 * -1;
    int num;
    rep(i,m){
        int p, x;
        cin >> p >> x;
        cout << sum - t[p-1] + x << endl;
    }
}
/*

a2 = b2 + c2 - 2bccosA

*/

Measured memory_bytes: 3616
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = Counter(a)
res = 0
for v in cnt.values():
    if v - 1 > 0:
        res += v - 1
if res % 2:
    print(len(cnt)-1)
else:
    print(len(cnt))

Measured memory_bytes: 65256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;



int main(){
    long long h, w, m;
    cin >> h >> w >> m;

    vector<long long> v1(h ,0);
    vector<long long> v2(w, 0);
    set<pair<long long, long long> > T;

    for(long long i = 0; i < m; i++){
        long long hm, wm;
        cin >> hm >> wm;
        hm--;
        wm--;
        T.insert(make_pair(hm, wm));
        v1[hm]++;
        v2[wm]++;
    }

    vector<long long> index_h;
    vector<long long> index_w;
    long long maxw = 0, maxh = 0;

    for(long long i = 0; i < h; i++) maxh = max(maxh, v1[i]);
    for(long long i = 0; i < w; i++) maxw = max(maxw, v2[i]);

    for(long long i = 0; i < h; i++){
        if(maxh == v1[i]) index_h.push_back(i);
    }
    for(long long i = 0; i < w; i++){
        if(maxw == v2[i]) index_w.push_back(i);
    }

    long long ans = maxh + maxw;

    if(index_h.size() * index_w.size() > m){
        cout << ans << endl;
        return 0;
    }

    bool find = true;
    for(long long y = 0; y < index_h.size(); y++){
        for(long long x = 0; x < index_w.size(); x++){
            if(T.find(make_pair(index_h[y], index_w[x])) == T.end()){
                find = false;
                break;
            }
        }
    }

    if(find == true) ans--;

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

Measured memory_bytes: 34980
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#define RE(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define SZ(x) ((int)(x.size()))
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using C = complex<double>;
const double PI = 3.14159265;
const double eps = 1e-8;
const int N = 1e6 +10;
const int M = 1e9 + 7;
const int inf = 1e9+7;
const ll INF = 1e18;
ll pw(ll a, ll b){ll t=1;a%=M;for(;b;b>>=1){if(b&1){t=t*a%M;}a=a*a%M;}return t;}
ll gcd(ll a, ll b){return b?gcd(b, a%b): a;}

ll a[N];
ll b[100][2];
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
    cin>>n;
    ll x;
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>x;
        for(int j=60;~j;j--){
            if(x>>j&1){
                ans=ans+b[j][0];
                ans%=M;
                b[j][1]+=1LL<<j;
                b[j][1]%=M;
            }
            else{
                ans=ans+b[j][1];
                ans%=M;
                b[j][0]+=1LL<<j;
                b[j][0]%=M;

//                ans=ans+b[j];
//                ans%=M;
            }
        }
//        for(int j=0;j<60;j++)
//            printf("%lld ", b[j]);
//        puts("");
    }
    cout<<ans<<"\n";
}

/*
#ifdef DEBUG
	cout<<"I Love Co shu Nie [ https://coshunie.com/ ]"
#endif
*/


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

int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;

  for (int i = 0; i < N; i++){
    if (x*2 < x+K){
      x = x*2;
    }
    else{
      x = x+K;
    }
    }
    cout << x << endl;
}
      
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define SZ(v) ((int)(v).size())
typedef long long ll;
string S,T,B="~";
bool isOK(string A1,string A2){
	for(int i=0;i<A1.size();i++){
		if(A1[i]!='?'&&A1[i]!=A2[i])return false;
	}
	return true;
}
int main(){
    ios::sync_with_stdio(false);
	cin>>S>>T;
	for(int i=0;i<=SZ(S)-SZ(T);i++){
		string U=S.substr(i,SZ(T));
		if(isOK(U,T)==true){
			string V=S;
			for(int j=i;j<i+SZ(T);j++)V[j]=T[j-i];
			for(int j=0;j<i;j++){
				if(V[j]=='?'){
					V[j]='a';
				}
			}
			for(int j=i+SZ(T);j<SZ(V);j++){
				if(V[j]=='?'){
					V[j]='a';
				}
			}
			B=min(B,V);
		}
	}
	if(B=="~")cout<<"UNRESTORABLE"<<endl;
	else cout<<B<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<string> G(10);
  G[1] = ".,!? ";
  G[2] = "abc";
  G[3] = "def";
  G[4] = "ghi";
  G[5] = "jkl";
  G[6] = "mno";
  G[7] = "pqrs";
  G[8] = "tuv";
  G[9] = "wxyz";
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    vector<pair<char,int>> vec;
    vec.emplace_back('0',1);
    for(int j=0; j<S.size(); j++){
      if(S[j] == '0'){
        vec.emplace_back('0',1);
      }else{
        if(vec.back().first == S[j]){
          vec.back().second++;
        }else{
          vec.emplace_back(S[j],1);
        }
      }
    }
    string ans = "";
    string temp = "";
    for(int j=0; j<vec.size(); j++){
      if(vec[j].first == '0'){
        ans += temp;
        temp = "";
      }else{
        temp += G[vec[j].first-'0'][(vec[j].second-1)%G[vec[j].first-'0'].size()];
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
/*******************************
Author:Morning_Glory
LANG:C++
Created Time:2019年07月20日 星期六 21时28分01秒
*******************************/
#include <cstdio>
#include <fstream>
#define ll long long
using namespace std;
//{{{cin
struct IO{
	template<typename T>
	IO & operator>>(T&res){
		res=0;
		bool flag=false;
		char ch;
		while((ch=getchar())>'9'||ch<'0')	 flag|=ch=='-';
		while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^'0'),ch=getchar();
		if (flag)	 res=~res+1;
		return *this;
	}
}cin;
//}}}
int main()
{
	int n;
	cin>>n;
	printf("%d\n",3*n*n);
	return 0;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    cout << 'A' << endl;
  } else {
    cout << 'B' << endl;
  }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e17)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

struct P {
    int x, y, z;
    P(int x, int y, int z) : x(x), y(y), z(z) {}
    bool operator<(const P& a) const {
        return x < a.x;
    }
};

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vll a(x+1);
    rep(i, x) cin >> a[i];
    a[x] = -INF;
    vll b(y+1);
    rep(i, y) cin >> b[i];
    b[y] = -INF;
    vll c(z+1);
    rep(i, z) cin >> c[i];
    c[z] = -INF;
    RSORT(a); RSORT(b); RSORT(c);
    priority_queue<pair<ll, P>> q;
    //map<ll, bool> used;
    auto push = [&] (ll v, P p) {
        if (p.x>x||p.y>y||p.z>z) return;
        //if (used[p.x*p.y*p.z]) return;
        q.emplace(v, p);
        //used[p.x*p.y*p.z] = true;
    };
    P s(0, 0, 0);
    push(a[0]+b[0]+c[0], P(0, 0, 0));
    rep(i, k) {
        auto p = q.top(); q.pop();
        cout << p.first << endl;
        if (p.second.x==s.x) {
            ++(s.x);
            rep(j, s.y+1) {
                rep(h, s.z+1) {
                    ll v = a[s.x] + b[j] + c[h];
                    push(v, P(s.x, j, h));
                }
            }
        }
        if (p.second.y==s.y) {
            ++(s.y);
            rep(j, s.x+1) {
                rep(h, s.z+1) {
                    ll v = a[j] + b[s.y] + c[h];
                    push(v, P(j, s.y, h));
                }
            }
        }
        if (p.second.z==s.z) {
            ++(s.z);
            rep(j, s.x+1) {
                rep(h, s.y+1) {
                    ll v = a[j] + b[h] + c[s.z];
                    push(v, P(j, h, s.z));
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 197084
n, k = gets.split.map &:to_i 
h = gets.split.map &:to_i 

dp = [0]

1.upto(n - 1) do |i|
  min = Float::INFINITY 
  [0, i - k].max.upto(i - 1) do |j|
    d = (h[i] - h[j]).abs + dp[j]
    min = d if min > d
  end
  dp[i] = min
end

puts dp[- 1]

Measured memory_bytes: 13340
n = int(input())
a = [0] + list(map(int,input().split()))
b = [0] + list(map(int,input().split()))
c = [0] + list(map(int,input().split()))
ans = 0
tmp = 0
for i in range(1,n+1):
    ans += b[a[i]]
    if tmp==a[i]-1:
        ans += c[tmp]
    tmp = a[i]
print(ans)


Measured memory_bytes: 9196
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int A, B;


int main() {
	cin >> A >> B;

	for (int i = 1; i <= 1250; i++) {
		int a = i * (0.08), b = i * (0.1);
		if (a == A && b == B) {
			cout << i << "\n";
			return 0;
		}
	}


	cout << "-1\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int g(int a){
  switch(a){
    case 1:
      return 1;
    case 3:
      return 1;
    case 5:
      return 1;
    case 7:
      return 1;
    case 8:
      return 1;
    case 10:
      return 1;
    case 12:
      return 1;
    case 4:
      return 2;
    case 6:
      return 2;
    case 9:
      return 2;
    case 11:
      return 2;
    case 2:
      return 3;
  }
}

int main(){
  int x,y;
  cin >> x >> y;
  map<int,int> mp;
  mp[g(x)]++;
  mp[g(y)]++;
  if(mp.size() == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int gcm(int, int,int);
int main() {
	int k;

	cin >> k;
	int sum=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int m=1;m<=k;m++){
				sum+=gcm(i,j,m);
			}
		}
	}
	cout << sum << endl;
	return 0;
}

int gcm(int x, int y, int z){
	int r;
	if (x<y) swap(x,y);

	while(y>0){
		r =x%y;
		x=y;
		y=r;
	}
	if(x<z) swap(x,z);
	while(z>0){
		r = x%z;
		x=z;
		z=r;
	}
	return x;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
ll n, m, k, y,a, q, d, w = 0, sum = 0, ans = 0; string s;
const int MOD = 1000000007;
int main(void) {
	cin >> n >> m>>q; vector<vector<char>> v(n, vector<char>(m));
	rep(i, n) rep(j, m) {
		cin >> v[i][j];
		if (v[i][j] == '#')sum++;
	}
	rep(i, 1 << n) {
		rep(j, 1 << m) {
			w = 0;
			rep(l, n) {
				if (i & (1 << l)) continue;
				rep(k, m) {
					if (j & (1 << k))continue;
					if (v[l][k] == '#')w++;
				}
			}
			if (w == q)ans++;
		}
	}cout << ans << endl;
}

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

int main(){
    int N;
    int t[100010],x[100010],y[100010];
    cin >> N;
    t[0] = x[0] = y[0] = 0; //初期位置
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1]; //初期位置を除くためi+1 

    bool can = true;
    for (int i = 0; i < N; ++i){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
        if (dt < dist) can = false;  // 総ステップが距離を超えることはない
        if (dist % 2 != dt % 2) can = false;  // 偶奇一致
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> l;
const int INF = 1e9;

int dfs(int num, int a, int b, int c){
  if(num==N){
    if(min(a,min(b,c))==0) return INF;
    else return abs(a-A) + abs(b-B) + abs(c-C) - 30;
  }

  int MP1 = dfs(num+1, a, b, c);
  int MP2 = dfs(num+1, a+l[num], b, c) + 10;
  int MP3 = dfs(num+1, a, b+l[num], c) + 10;
  int MP4 = dfs(num+1, a, b, c+l[num]) + 10;

  return min(min(MP1,MP2),min(MP3,MP4));
}

int main(){
  cin >>N >>A >>B >>C;
  l.resize(N);
  for(int i=0;i<N;i++){
    int x; cin >>x;
    l[i] = x;
  }

  cout << dfs(0,0,0,0) << endl;
  return 0;
}

Measured memory_bytes: 764
function main()
  
  N = parse(Int,readline())
  A = map(x -> parse(Int,x), split(readline()))
  
  cnt2 = 0
  cnt4 = 0
  others = 0
  
  for i in A
    if i % 4 == 0
      cnt4 += 1
    elseif i % 2 == 0
      cnt2 += 1
    end
  end
  
  others = length(A)-cnt4-cnt2
  
  if cnt4+1 >= others + ( cnt2 % 2 )
    println("Yes")
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 124988
import java.util.*;

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 = sc.nextInt();    
    int Y = sc.nextInt(); 
    //出力
    if (N > K) {
      System.out.println(K*X + (N-K)*Y);
    } else {
      System.out.println(N*X);
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(void){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int M = max(max(a, b), c);
	rep(i, k)M *= 2;
	int ans = a + b + c + M - max(max(a, b), c);
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	k, n := readInt(), readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	l := 0
	a = append(a, a[0]+k)
	for i := 0; i < n; i++ {
		l = max(l, a[i+1]-a[i])
	}
	fmt.Println(k - l)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int n;
    cin >> n;
    int ans = 0;

    for(int i = 1;i <=n;i+=2){
        int num = 0;
        for(int j = 1;j <= i;++j){
            if(i%j == 0){
                num += 1;
            }
        }
        if(num == 8){
            ans += 1;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n;
    string s;
    cin >> n >> s;
/*     for (int i = 0; i < n; i++) {
        if (i % 3 == 0)
            s.push_back('R');
        if (i % 3 == 1)
            s.push_back('G');
        if (i % 3 == 2)
            s.push_back('B');
    } */
    ll nr = 0, ng = 0, nb = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            nr++;
        if (s[i] == 'G')
            ng++;
        if (s[i] == 'B')
            nb++;
    }
    ll total = nr * ng * nb;
    for (int d = 1; d <= n/2; d++) {
        for (int m = 0; m + d * 2 < n; m++) {
            if (s[m] != s[m+d] && s[m+d] != s[m+d*2] && s[m] != s[m+d*2])
                total--;
        }

    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,ans=0;
int main() 
{
    cin>>a>>b>>c>>d;
    if(c>=a&&c<=b)
	{
		ans=min(b,d)-c;
	} 
    if(a>=c&&a<=d) 
	{
		ans=min(b,d)-a;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

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();
        String S = sc.next();
        
        //郵便番号の形式と合っているかを確認し、結果を出力
        Pattern pattern = Pattern.compile("^[0-9]{"+ A +"}-[0-9]{"+ B +"}$");
        Matcher matcher = pattern.matcher(S);
        
        if(matcher.find()) {   
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
    
    //郵便番号の形式チェックを行うメソッド
    //public static boolean isPostalCode(int A, int B, int S) {
    //    boolean result = S.equals("^[0-9]{"  +A+ "}-[0-9]{" +B+ "}$"); //〒A(桁) -(ハイフン) B(桁)
    //    return result;
    //}
    
}

Measured memory_bytes: 39196
N,K=map(int,input().split())

ans=0
n=20
p=[1]*n
for i in range(n-1):
    p[i+1]=p[i]*2

for i in range(1,N+1):
    temp=0
    for j in range(n):
        if i*p[j]>=K:
            temp=j
            break
    ans+=1/N/p[temp]
    
print(ans)

Measured memory_bytes: 38896
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

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

	cout << "ABC" << N << endl;

	return 0;
}

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

int main(){
  int a,b,c;
  //一文字目取得
  cin >> a; 
  //二文字目取得
  cin >> b;
  //積を計算
  c = a*b;
  //積の値で文字列表示
  if(c%2 == 0)
  cout << "Even" << endl; //偶数
  else
  cout << "Odd" << endl; //奇数
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 10000000007; //10^9+7

int main(){
  int n,m;
  cin>>n>>m;
  int time=m*1900+(n-m)*100;
  int p=pow(2,m);
  int ans=time*p;
  print(ans);
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,ans=0; cin>>n; 
    vi mon(n+3),hero(n+3); 
    for (int i=1;i<=n+1;i++) cin >> mon[i] ; 
    for (int i=1;i<=n;i++) cin >> hero[i] ; 
    for (int i=1;i<=n;i++){ 
        if ( mon[i]<=hero[i] ) { ans += mon[i], hero[i]-=mon[i]; } 
        else if ( mon[i]>=hero[i] ) { ans += hero[i],hero[i]=0; } 
        if ( mon[i+1]<=hero[i] ) { ans += mon[i+1], mon[i+1]=0; } 
        else if ( mon[i+1] >= hero[i] ) { ans += hero[i],mon[i+1]-=hero[i]; } 
    } 
    cout << ans << endl; 
} 
 
signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    string s;
    cin>>s;
    vector<char> st;
    rep(i, s.length()){
        if(s[i]=='0')
            st.push_back('0');
        else if(s[i]=='1')
            st.push_back('1');
        else{
            if(st.size()!=0)
                st.pop_back();
        }
    }
    for (int i = 0; i < st.size();i++)
        cout << st[i];
    cout << endl;
}

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

using ll = long long;

const int N = 200005;
const ll M = ll(1e9) + 7;

int n, d[N], c[N];

int main(){
	scanf("%d", &n);
	d[0] = 1;
	for(int i = 1, x, pv = -1; i <= n; i++){
		scanf("%d", &x);
		d[i] = d[i - 1];
		if(x == pv) continue;
		pv = x;
		(d[i] += c[x]) %= M;
		(c[x] += d[i - 1]) %= M;
	}
	printf("%lld\n", d[n]);
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      for(int i=0;i<s.length();i++){
      	if(i%2==0){
          if(!(s.charAt(i)=='R' || s.charAt(i)=='U' || s.charAt(i)=='D')){
          System.out.println("No");
          return;
          }
        }else{
            if(!(s.charAt(i)=='L' || s.charAt(i)=='U' || s.charAt(i)=='D')){
            System.out.println("No");
            return;
            }
        }
      }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 26940
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Prime Caves
// 2013/08/14
public class Main{
	Scanner sc=new Scanner(System.in);

	int m, start;

	void run(){
		for(;;){
			m=sc.nextInt();
			start=sc.nextInt();
			if((m|start)==0){
				break;
			}
			solve();
		}
	}

	byte[] isPrime;

	void solve(){
		int M=(int)1e6+100;
		if(isPrime==null){
			isPrime=new byte[M];
			fill(isPrime, (byte)1);
			isPrime[0]=isPrime[1]=0;
			for(int j=0; j<M; j++){
				if(isPrime[j]==0){
					continue;
				}
				for(int i=j*2; i<M; i+=j){
					isPrime[i]=0;
				}
			}
		}
		int n=2000;
		int[][] dp=new int[n][n], index=new int[n][n];
		for(int i=0; i<n; i++){
			fill(dp[i], -1);
		}
		int[] _=spiralN2XY(start);
		int x0=_[0]-n/2, y0=_[1];
		dp[0][n/2]=isPrime[start];
		index[0][n/2]=start*isPrime[start];
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				if(dp[j][i]<0){
					continue;
				}
				for(int k=-1; k<=1; k++){
					if(j+1>=n||i+k<0||i+k>=n){
						continue;
					}
					int val=spiralXY2N(x0+i+k, y0+j+1);
					if(val>m){
						continue;
					}
					if(dp[j][i]+isPrime[val]>dp[j+1][i+k]){
						dp[j+1][i+k]=dp[j][i]+isPrime[val];
						index[j+1][i+k]=isPrime[val]==1?val:index[j][i];
					}
				}
			}
		}
		int maxVal=0, maxIndex=0;
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				if(dp[j][i]>maxVal||(dp[j][i]==maxVal&&index[j][i]>maxIndex)){
					maxVal=dp[j][i];
					maxIndex=index[j][i];
				}
			}
		}
		println(maxVal+" "+maxIndex);
	}

	int[] spiralN2XY(int n){
		int m=(int)sqrt(n-1)+1;
		int x=m/2-min(m*m-n, m-1), y=m/2-max(m*m-m+1-n, 0);
		if(m%2==0){
			x=-x+1;
			y=-y;
		}
		return new int[]{x, y};
	}

	int spiralXY2N(int x, int y){
		int d=max(abs(x), abs(y));
		if(y>=x)
			return (2*d+1)*(2*d+1)-abs(d-x)-abs(d-y);
		else
			return (2*d)*(2*d)-abs(-d+1-x)-abs(-d-y);
	}

	void println(String s){
		System.out.println(s);
	}

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

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

ll H,W,N;

int main(){
    cin >> H >> W >> N;
    map<pii,bool> mp;
    rep(i,N){
        int aa,bb;cin>>aa>>bb;
        aa--,bb--;
        pii p = pii(aa,bb);
        mp[p] = true;
    }

    vector<ll> ans(10,0);

    set<pii> st;
    for(auto pp : mp){
        pii p = pp.first;
        int x = p.first , y = p.second;

        for(int s=-1;s<=1;s++) for(int t=-1;t<=1;t++){
            // x + s , y + t が真ん中
            int cx = x + s , cy = y + t;
            if(st.count(pii(cx,cy))) continue;
            bool f=true;
            int cnt=0;
            for(int i=-1;i<=1;i++) for(int j=-1;j<=1;j++){
                int nx=cx+i , ny=cy+j;
                if(nx<0 or ny<0 or nx>=H or ny>=W){
                    f=false;
                }
                pii np = MP(nx,ny);
                if(mp.count(np)) cnt++;
            }

            if(!f){
                continue;
            }
            st.insert(pii(cx,cy));
            ans[cnt]++;
        }
    }
    ans[0] = (H-2) * (W-2);
    for(int i=1;i<10;i++) ans[0]-=ans[i];
    for(int i=0;i<10;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 48640
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		if(c.equals("A"))System.out.println("T");
		if(c.equals("T"))System.out.println("A");
		if(c.equals("C"))System.out.println("G");
		if(c.equals("G"))System.out.println("C");
		
		
		
		sc.close();
	}

	
}


Measured memory_bytes: 22356
fn main() {
    let a = read::<i32>().unwrap();
    let s = read::<String>().unwrap();

    if a >= 3200 {
        println!("{}", s);
    }
    else {
        println!("{}", "red");
    }

}

// 標準入力より、FromStrを実装した型の値を読み取る
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> Option<T>  {
    let mut value = String::new();
    std::io::stdin().read_line(&mut value).unwrap();
    value.trim().parse::<T>().ok()
}

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

int main(){
  int a,b;
  cin >> a >> b;
  
  if( (a % 2 != 0 )&&(b % 2 != 0 ) ){
    cout << "Odd" << endl;
  }
  
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $number1, $number2, $number3);
fscanf(STDIN, "%d", $doubleTimes);
$maxNumber = max($number1, $number2, $number3);

$maxNumberCalc = $maxNumber;
for($i=0; $i<$doubleTimes; $i++){
    $maxNumberCalc = $maxNumberCalc * 2;
}

echo $number1 + $number2 + $number3 - $maxNumber + $maxNumberCalc;

Measured memory_bytes: 4728
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a + b >= c){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=0;
    long h=sc.nextLong(),w=sc.nextLong();
    for(int i=0;i<n;i++) {
    	long buffh=sc.nextLong(),buffw=sc.nextLong();
    	if(buffh>=h&&buffw>=w)count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 25320
#include<iostream>
using namespace std;
#define max 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[max];
int n, D[max];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL)cout << "root, ";
	else if (T[u].l == NIL)cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";
	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i)cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

void rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL)rec(T[u].r, p);
	if (T[u].l != NIL)rec(T[u].l, p + 1);
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++)T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL)r = i;
	}

	rec(r, 0);

	for (i = 0; i < n; i++)print(i);

	return 0;
}




Measured memory_bytes: 7768
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var nums = chunk.split(" ");
    for(var i = 0; i < nums.length; i ++){
        nums[i] = Number(nums[i]);
    }
    console.log(nums[0]*nums[1], (nums[0]+nums[1])*2);
});

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

using namespace std;

int main(){
    int count=0,mx=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='S'){
            mx=max(mx,count);
            count=0;
        } else {
            count++;
        }
    }
    mx=max(mx,count);
    cout<<mx;
    return 0;
}

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

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-8;
const double PI = acos(-1);

double dot(Point a, Point b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
    return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
    b -= a;  c -= a;
    if (cross(b,c) >  EPS) return +1;  // counter clockwise
    if (cross(b,c) < -EPS) return -1;  // clockwise
    if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
    if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
    return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSP(Point a1, Point a2, Point b) {
    return !ccw(a1, a2, b);
}

bool isecSS(Point a1, Point a2, Point b1, Point b2) {
    return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
           ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

Point proj(Point a1, Point a2, Point p) {
    return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

double distSP(Point a1, Point a2, Point p) {
    Point r = proj(a1, a2, p);
    if (isecSP(a1, a2, r)) return abs(r-p);
    return min(abs(a1-p), abs(a2-p));
}

double distSS(Point a1, Point a2, Point b1, Point b2) {
    if (isecSS(a1, a2, b1, b2)) return 0;
    return min({
        distSP(a1, a2, b1),
        distSP(a1, a2, b2),
        distSP(b1, b2, a1),
        distSP(b1, b2, a2)});
}

bool inPolygon(Point p,VP& ps){
    int n = ps.size();
    double sumAngle=0;
    rep(i,n){
        double t = arg(ps[(i+1)%n]-p)-arg(ps[i]-p);
        while(t > +PI) t-=2*PI;
        while(t < -PI) t+=2*PI;
        sumAngle += t;
    }
    return (abs(sumAngle) > 0.1);
}

int main(void){
    int n;
    while(cin>>n, n){
        double sx,sy,ex,ey;
        cin>>sx>>sy>>ex>>ey;
        Point s(sx,sy);
        Point e(ex,ey);
        vector<double> d(n,INF), h(n);
        bool ng = false;
        rep(i,n){
            double x1,y1,x2,y2;
            cin>>x1>>y1>>x2>>y2>>h[i];
            VP p = {{x1,y1},{x2,y1},{x2,y2},{x1,y2}};
            if(inPolygon(s,p) || inPolygon(e,p)){
                ng = true;
            }
            rep(j,4){
                d[i] = min(d[i],distSS(s,e,p[j],p[(j+1)%4]));
            }
        }
        if(ng){
            cout<<"0.0000"<<endl;
            continue;
        }

        double l = 0, r = 1000;
        rep(loop,100){
            double R = (l+r)/2;
            bool ok = true;
            rep(i,n){
                if(sqrt(pow(max(R-h[i],0.0),2) + pow(d[i],2)) < R){
                    ok = false;
                }
            }
            if(ok) l = R;
            else   r = R;
        }
        printf("%.4f\n",l);
    }
    return 0;
}



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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int w=0, r=0;
  rep(i,N){
    if(S[i]=='W')w++;
    if(S[i]=='R')r++;
  }
  string T = "";
  rep(i,r) T += 'R';
  rep(i,w) T += 'W';
  int cnt = 0;
  rep(i,N){
    if(S[i]!=T[i]) cnt++;
  }
  cout << (cnt+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<int> G[101010];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    vector<int> ans(n + 1, -1);
    ans[1] = 0;
    queue<int> que;
    que.push(1);
    while(que.size()) {
        int v = que.front();
        que.pop();
        for(auto u : G[v]) {
            if (ans[u] == -1) {
                ans[u] = v;
                que.push(u);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 2; i <= n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 10248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  double A, B; cin >> A >> B;
  cout << (A>B?"GREATER":A<B?"LESS":"EQUAL") << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
using namespace std;
int a,b,c;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		char a='-',b='1';
		putchar(a);
		putchar(b);
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}

int main()
{
    a=read(),b=read(),c=read();
	if(a+b+c>=22)
		puts("bust");
	else
		puts("win");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>

int main(){

	double
		a,men,sh;

	scanf("%lf", &a);

	men = a*a*M_PI;
	sh = 2 * a*M_PI;

	printf("%lf %lf\n", men, sh);


	return 0;
}

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

int main(){
	int w,h,n;
	cin>>w>>h>>n;
	int x1=0,x2=w,y3=0,y4=h;
	for(int i=0,x,y,a;i<n;++i){
		cin>>x>>y>>a;
		if(a==1)x1=max(x1,x);
		else if(a==2)x2=min(x2,x);
		else if(a==3)y3=max(y3,y);
		else if(a==4)y4=min(y4,y);
	}
	int ans;
	if(x2-x1>0&&y4-y3>0)ans=(x2-x1)*(y4-y3);
	else ans=0;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val MOD = 1000000007L
    val N = nextLong()
    val A = listOfLong()
    val C = Array<Long>(61) { 0L }
    for (a in A) {
        for (b in 0 until 61) {
            C[b] += (a shr b) % 2
        }
    }
    var ans = 0L
    fun shiftLeft(v: Long, shift: Int): Long {
        var ret = v % MOD
        for (s in 0 until shift) {
            ret *= 2
            ret %= MOD
        }
        return ret
    }
    for (b in 0 until 61) {
        ans += shiftLeft(C[b] * (N - C[b]), b)
        ans %= MOD
    }
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }

Measured memory_bytes: 150460
K, N = map(int,input().split())
A = list(map(int,input().split()))

length=[]
for i in range(N-1):
    length.append(A[i+1]-A[i])

max = max(length)
sum1 = sum(length) #内側の合計

length.append(K-A[N-1]+A[0])

sum2 = sum(length)-max #外側を通るときの合計

if sum1 >= sum2:
    print(sum2)
else:
    print(sum1)


Measured memory_bytes: 26420
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    vector<pair<int, int>> queue;
    queue.reserve(H * W * 2);

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

    vector<vector<int>> dist(H, vector<int>(W, -1));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                queue.push_back({i, j});
                dist[i][j] = 0;
            }
        }
    }

    for (int b = 0; b < queue.size(); b++) {
        for (int i = -1; i <= 1; i += 2) {
            for (int j = 0; j <= 1; j += 1) {
                auto p = make_pair(queue[b].first + i * j,
                                   queue[b].second + i * (1 - j));
                if (0 <= p.first && p.first < H && 0 <= p.second &&
                    p.second < W) {
                    if (dist[p.first][p.second] == -1) {
                        queue.push_back(p);
                        dist[p.first][p.second] =
                            dist[queue[b].first][queue[b].second] + 1;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15616
#include <cstdio>

typedef long long ll;

const int MAXN = 1E3 + 10;
const int MOD = 1E9 + 7;

int cnt[MAXN];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i){
		int t = i;
		for (int j = 2; j * j <= t; ++j)
			for (; t % j == 0; ++cnt[j], t /= j);
		if (t)
			++cnt[t];
	}
	ll ans = 1;
	for (int i = 2; i <= n; ++i)
		ans = ans * (cnt[i] + 1) % MOD;
	printf("%d\n", int(ans));
	return 0;
}


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

n = len(S)
m = len(T)


for i in reversed(range(n - m + 1)):
  t_kamo = S[i: i + m]
  for j in range(m + 1):
    if j == m:
      print((S[:i] + T +  S[i + m:]).replace("?", "a"))
      exit()
    if t_kamo[j] == "?":
      continue
    elif t_kamo[j] != T[j]:
      break

print("UNRESTORABLE")


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    for(int i = N; i > 0; i--) {
        if(s.substr(N - i, i) == t.substr(0, i)) {
            cout << N * 2 - i << endl;
            return 0;
        }
    }
    cout << 2 * N << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int count = 0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) == 'o'){
            count++;
        }
    }
    cout << 700 + count * 100 << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  vector<long long> L(100);
  L.at(0)=2;
  L.at(1)=1;
  for(long long i=2;i<99;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n = read::<usize>();
    let l = read::<i32>();

    let mut v = vec![];
    let mut e = i32::max_value();
    let mut ev = -1;
    for i in 0..n {
        let i = i as i32;
        if e > (l+i).abs() {
            e = (l+i).abs();
            ev = l+i;
        }
    }
    for i in 0..n {
        let i = i as i32;
        if l+i != ev {v.push(l+i)}
    }

    println!("{}", v.iter().sum::<i32>());

}


Measured memory_bytes: 4352
import sys

# import os
# path = os.getcwd()
# path = os.path.join(path,"input.txt")
# sys.stdin = open(path)

input = sys.stdin.readline
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [float('inf')]*(K)
dp.append(0)
dp = dp[::-1]
for i in range(N-1):
    dp_ = dp.pop(0)
    if i >= N-K-1:
        dp = [min(dp_+abs(H[i+j+1]-H[i]),dp[j]) for j in range(N-i-1)]
        continue
    dp = [min(dp_+abs(H[i+j+1]-H[i]),dp[j])  for j in range(K)]
    dp.append(float("inf"))

print(dp[0])
        

Measured memory_bytes: 52828
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;

int main()
{
	int h, w;
	char b[500][500], r[500][500], a[500][500];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			if (((i % 2 == 0) && (j != (w - 1)))||((i % 2 == 1) && (j == 0))) {
				b[i][j] = '#';
				r[i][j] = a[i][j];
			}
			else {
				r[i][j] = '#';
				b[i][j] = a[i][j];
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << b[i][j];
		}
		cout << endl;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << r[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1536