akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

//エラトステネス使う必要あるか？ルートまででもよくね？
int main() {
	int x;
	cin>>x;
	while(1){
		bool flag=true;
		for(int i=2;i*i<=x;i++){
			if(x%i==0){
				flag=false;
				break;//割れたら素数ちゃう
				
			}
		}
		if(flag)break;
		
		
		x++;
	}
	
	cout<<x<<endl;
}
//prime判定関数を作った方がスマート
//半分WA

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
int t[200005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&t[i]);
    sort(t+1,t+n+1);
    int i;
    for(i=1;i<n;i++)
        if(t[i]==t[i+1])
        break;
    if(i==n)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MOD = 1000000007;

template <typename T>
struct matrix {
  vector<vector<T>> v;
  int n;
  matrix(int n) : v(n, vector<T>(n)), n{n} {}
  matrix operator * (const matrix& o) const {
    auto& a = *this;
    auto& b = o;
    matrix res(n);
    rep(i, 0, n) {
      rep(k, 0, n) {
	rep(j, 0, n) {
	  res.v[i][j] = (res.v[i][j] + (a.v[i][k] * b.v[k][j] % MOD)) % MOD;
	}
      }
    }
    return res;
  }
  matrix operator ^ (ll p) {
    auto pwr = *this;
    matrix res(n);
    rep(i, 0, n) res.v[i][i] = 1;
    while (p) {
      if (p & 1) res = res * pwr;
      pwr = pwr * pwr;
      p /= 2;
    }
    return res;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; ll k;
  cin >> n >> k;
  matrix<ll> mat(n);
  rep(i, 0, n) rep(j, 0, n)
    cin >> mat.v[i][j];
  mat = mat ^ k;
  auto res = 0LL;
  rep(i, 0, n) rep(j, 0, n)
    res = (res + mat.v[i][j]) % MOD;
  cout << res << '\n';
}


Measured memory_bytes: 384
N, K, Q = map(int, input().split())
A_list = []
for i in range(Q):
    A = int(input())
    A_list.append(A)
dic_A = {}
for i in A_list:
    if i in dic_A:
        dic_A[i] += 1
    else:
        dic_A[i] = 1
for i in range(1, N+1):
    if i in dic_A:
        if K-(Q-dic_A[i]) > 0:
            print("Yes")
        else:
            print("No")
    else:
        if K-Q > 0:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 11544
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int getBitNum(int num) {
    int count = 0;
    while (num > 0) {
        count += 0x1 & num;
        num >>= 1;
    }
    return count;
}

int main(void) {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> testimony(N);

    for (auto& t : testimony) {
        int A;
        cin >> A;
        REP (i, A) {
            int x, y;
            cin >> x >> y;
            t.emplace_back(x, y);
        }
    }

    int ans = 0;
    REP (bit, 0x1 << N) {
        bool success = true;
        REP (i, N) {
            if (((bit >> i) & 0x1) == 0) {
                continue;
            }
            for (auto t : testimony[i]) {
                if (((bit >> (t.first - 1)) & 0x1) ^ t.second) {
                    success = false;
                }
            }
        }
        if (success) {
            ans = max(ans, getBitNum(bit));
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

A=list(map(int,input().split()))
B=[]
C=[]

for i in range(N):
    if(N%2==0):
        if(i%2==0):
            B.append(A[i])
        else:
            C.append(A[i])
    else:
        if(i%2==0):
            C.append(A[i])
        else:
            B.append(A[i])

C.reverse()
for i in range(len(B)):
    C.append(B[i])

for i in range(N):
    print(C[i] if i==0 else " "+str(C[i]),end="")
print()


Measured memory_bytes: 100948
X, Y = map(int, input().split())
n = (2 * X - Y) / 3
m = (2 * Y - X) / 3

if n < 0 or m < 0 or not n.is_integer() or not m.is_integer():
    print(0)
    exit()

n, m = map(int, [n, m])
mod = 10**9 + 7
fact = [1]
inv = [1]
for i in range(1, X + Y + 1):
    fact.append((fact[i-1] * i) % mod)
    inv.append(pow(fact[-1], mod-2, mod))

def cmb(n, r):
    return fact[n] * inv[n-r] * inv[r]

print(cmb(n+m, min(n, m)) % mod)


Measured memory_bytes: 135920
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = a * b * c;
    if (x & 1) {
        ll n = x - (a - 1) * b * c;
        n = min(n, x - (b - 1) * c * a);
        n = min(n, x - (c - 1) * a * b);
        cout << n << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int h,m;
    int H,M;
    while(1){
        scanf("%d %d",&h, &m);
        if((h==0)&&(m==0))break;
        for(H=h;H>0;H--){
            for(M=m;M>0;M--){
                if( ((H==h)||(H==1)) || ((m==M)||(M==1)) )printf("#");
                else{printf(".");}
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2028
#N人の人がそれぞれXiに住んでいる。Pで集会開く時、(Xi-P)^2の和の最小値

N = int(input())
X = input().split()
X = [int(n) for n in X]

Xpwr = list()

for i in range (1, 101):
    Xpsum = list()

    for j in range(N):
        Xpsum.append((X[j] - i) ** 2)

    Xpwr.append(sum(Xpsum))

ans = min(Xpwr)
print(ans)

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

long long GCD(long long a,long long b){
    if(b==0)return a;
    else return GCD(b,a%b);
}

int main(){
    int N; long long X;
    cin>>N>>X;
    vector<long long> x(N);for(int i=0;i<N;i++) cin>>x[i],x[i]-=X;
    long long g=abs(x[0]);
    for (int i=0;i<N;i++)g=GCD(g,abs(x[i]));
    cout<<g<<endl;
}

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

int main(){
  int N;
  cin >> N;
  
  int ans;
  int count = 0;
  for(int i=1; i<=N; i++){
    ans = to_string(i).length();
    if(ans%2==1){
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

#define ll long long

using namespace std;

//memset(dp, 0, sizeof(dp));
const ll M = 1e9 + 7;
const int N = 2e6 + 10;
int F[N], G[N];

ll comb(int n, int m) {
	if (n < m || m < 0) {
		return 0;
	}
  	return (ll)F[n] * G[m] % M * G[n - m] % M;
}

void init(int n) {
	static int inv[N];
	inv[1] = 1;
	for(int i = 2; i < n; i++) {
		inv[i] = (M - M / i) * (ll)inv[M % i] % M;
	}
	F[0] = G[0] = 1;
	for(int i = 1; i < n; ++i) {
		F[i] = (ll)F[i - 1] * i % M;
		G[i] = (ll)G[i - 1] * inv[i] % M;
	}
}

ll power_mod(ll a, ll n, ll p = M) {
	ll res = 1;
	for(; n; n >>= 1) {
		if(n & 1) {
	    	res = res * a % p;
	    }
	    a = a * a % p;
	}
	return res;
}
void work(int T) {
	
	int k;
	cin >> k;
	string s;
	cin >> s;
	
	int m = s.size(), n = m + k;
	ll res = 0, mul = 1;	
	init(n);
	for(int i = m - 1; i < n; i++) {
		res = (res + (ll)comb(i, m - 1) % M * mul % M * power_mod(26, n - i - 1) % M) % M;
		mul = mul * 25ll % M;
	}
	cout << res << endl;
	
	return;

}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	// int t;
	// for(cin >> t; t > 0; t--) {
		// work(t);
	// }
	work(0);
	return 0;
};


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

using namespace std;

class Graph{
	int V;
	int E;
	vector<vector<int>> adj_list;
public:
	Graph(int V, int E, vector<pair<int, int>> edges){
		this->V = V;
		this->E = E;
		this->adj_list = vector<vector<int>>(this->V, vector<int>());
		for(auto p: edges){
			this->adj_list[p.first].push_back(p.second);
		}
	}

	int dfs(){
		bool visited[V];
		for(auto src = 0; src < V; ++src){
			for(auto i = 0; i < V; ++i) visited[i] = false;
			int count_duplicated = dfs_util(src, src, visited);
			if(count_duplicated > 1){
				return 1;
			}
		}
		return 0;
	}

	int dfs_util(int ref, int src, bool visited[]){
		int count = 0;
		if(ref == src) ++count;
		for(auto adj_node: adj_list[src]){
			if(!visited[adj_node]){
				visited[adj_node] = true;
				count += dfs_util(ref, adj_node, visited);
			}
		}
		return count;
	}
};

int main(){
	int V, E;
	cin >> V >> E;
	vector<pair<int, int>> edges;
	for(auto i = 0; i < E; ++i){
		int src, dest;
		cin >> src >> dest;
		edges.push_back({src, dest});
	}
	Graph g(V, E, edges);
	cout << g.dfs() << endl;
}	


Measured memory_bytes: 3176
#include<iostream>
#include<numeric>

using namespace std;

int Y[12],X[12],S[12];
int g[10][10];
const int W=13*12+1;
bool dp[13][W]={true};


bool dfs(int y,int x,int s,int n){
  int sum=accumulate(g[0],g[10],0);
  if(!dp[n][sum])return false;
  if(n==0) return true;
  for(int i=s;i>=0;i--){
    for(int j=y;j<10;j++){
      y=0;
      for(int k=x;k<10;k++){
	x=0;
	static int dy[][4]={
	  {-1,0,0,1},
	  {-1,-1,1,1},
	  {-2,0,0,2}
	};
	static int dx[][4]={
	  {0,-1,1,0},
	  {-1,1,-1,1},
	  {0,-2,2,0}
	};
	bool f=!g[j][k];
	for(int l=0;l<=i;l++){
	  for(int m=0;m<4;m++){
	    int ny=j+dy[l][m];
	    int nx=k+dx[l][m];
	    f|=ny<0||10<=ny||nx<0||10<=nx||g[ny][nx]==0;
	  }
	}
	if(!f){
	  g[j][k]--;
	  S[n-1]=i;
	  Y[n-1]=j;
	  X[n-1]=k;
	  for(int l=0;l<=i;l++){
	    for(int m=0;m<4;m++){
	      int ny=j+dy[l][m];
	      int nx=k+dx[l][m];
	      g[ny][nx]--;
	    }
	  }
	  if(dfs(j,k,i,n-1))return true;
	  g[j][k]++;
	  for(int l=0;l<=i;l++){
	    for(int m=0;m<4;m++){
	      int ny=j+dy[l][m];
	      int nx=k+dx[l][m];
	      g[ny][nx]++;
	    }
	  }
	  if(i==0)return false;
	}
      }
    }
  }
  return false;
}

int main(){
  for(int i=0;i<12;i++){
    for(int j=0;j<W;j++){
      if(dp[i][j]){
	int d[]={5,9,13};
	for(int k=0;k<3;k++){
	  if(j+d[k]<W){
	    dp[i+1][j+d[k]]=true;
	  }
	}
      }
    }
  }
  int n;
  cin>>n;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>g[i][j];
    }
  }
  dfs(0,0,2,n);
  while(n--){
    cout<<X[n]<<' '<<Y[n]<<' '<<S[n]+1<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N;
int A[100010];


int solve(){
	SI s;
	rep(i, 0, N)
		if(s.find(A[i]) == s.end()) s.insert(A[i]);
		else s.erase(A[i]);
	return SIZE(s);
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	cout << solve() << endl;

	return 0;
}

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

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

#define int ll


main(){
	int n;
	vector<P> v;

	cin >> n;
	for(int i=0;i<n;i++){
		int x,y;
		cin >> x >> y;
		v.push_back({x,y});
	}

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

	int ans = n-1;
	map<pair<int, int>, int> cnt;
	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++){
			if(i==k) continue;
			int p = v[k].first - v[i].first;
			int q = v[k].second - v[i].second;	
			cnt[{p,q}]++;
		}
	}

	int max_cnt = 0;
	for (auto itr : cnt) {
		max_cnt = max(max_cnt, itr.second);
	}
 
	ans = n - max_cnt;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    queue<pair<string,ll>> q;
    q.push(make_pair("a",0));
    while(true){
        if(q.front().first.size() == N){
            break;
        }
        queue<pair<string,ll>> tmp;
        while(!q.empty()){
            auto str = q.front();
            q.pop();
            for (int i = 0; i <= str.second; ++i) {
                auto p = make_pair(str.first + (char)('a' + i),str.second);
                tmp.push(p);
            }
            tmp.push(make_pair(str.first + (char)('a' + str.second + 1),str.second + 1));
        }
        q = tmp;

    }
    while(!q.empty()){
        auto s = q.front();q.pop();
        cout << s.first << endl;
    }

}


Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
#define rep(i,n) for(int i=0;i<(n);i++)
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

vector<ll> divisor(ll n){
    vector<ll> ret;
    for (ll i = 1; i * i <= n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main()
{
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i += 2){
        vector<ll> hoge = divisor(i);
        if(hoge.size() == 8)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s1,s2;
    cin>>s1>>s2;
    int t = 0;
    for(int i = 0; i < 3; i++){
        if(s1[i] == s2[i])t++;
    }
    cout<<t;
	return 0;
}


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

int main() {
string s,t;
cin >> s;
t=s;
if(s=="keyence"){
    cout << "YES";
    return 0;
}
else {
    for(long long i=0;i<s.size();i++){
        
        for(long long j=i+1;j<s.size();j++){
            
            s.erase(i,j-i);
        if(s=="keyence"){
            cout << "YES";
            return 0;}
          s=t;
        }
        
    }
}
cout << "NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll (i) = (s); (i) < (x); (i) ++)
#define MREP(i, s, x) for(ll (i) = (s); (i) >= (x); (i) --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = INF;
    REP(i, max(x, y) + 1){
        ll sum = 2 * c * i;
        if(x - i > 0){
            sum += a * (x - i);
        }
        if(y - i > 0){
            sum += b * (y - i);
        }
        chmin(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	long long N, M, ANS = 0;
	vector<vector<long long> > V;
	cin >> N >> M;
	V.resize(M);
	for (int i = 0; i < N; i++) {
		long long X;
		cin >> X;
		V[X % M].push_back(X);
	}
	for (int i = 1; i * 2 < M; i++) {
		sort(V[i].begin(), V[i].end()), sort(V[M - i].begin(), V[M - i].end());
		if (V[i].size() < V[M - i].size()) swap(V[i], V[M - i]);
		long long COUNT = V[M - i].size();
		long long D = V[i].size() - V[M - i].size();
		long long Even = V[i].size();
		map<long long, long long> mp = {};
		for (long long j : V[i]) mp[j] = (mp[j] + 1) % 2;
		for (auto it = mp.begin(); it != mp.end(); it++) {
			Even -= it->second;
		}
		Even /= 2;
		COUNT += min(Even, (long long)((V[i].size() - V[M - i].size()) / 2));
		ANS += COUNT;
	}
	ANS += V[0].size() / 2;
	if (M % 2 == 0) ANS += V[M / 2].size() / 2;
	cout << ANS << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long int ll;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	map<string,int>m;
	ll N;
	cin>>N;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<"\n";
	cout<<"WA x "<<m["WA"]<<"\n";
	cout<<"TLE x "<<m["TLE"]<<"\n";
	cout<<"RE x "<<m["RE"]<<"\n";
}

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

typedef long long int llint;

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

  for(int i = a; i <= b; i++) {
    if(i < a + k || i > b - k) cout<< i <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C;
    cin >> A >> B >> C;

    int m[3][3] = {}, S;
    m[0][0] = A;
    m[0][1] = B;
    m[1][1] = C;
 
    m[2][0] = A + B - C;
    m[2][1] = 2*C - B;
    S = m[0][1] + m[1][1] + m[2][1];
    m[0][2] = S - A - B;
    m[1][0] = S - m[0][0] - m[2][0];
    m[1][2] = S - m[1][0] - m[1][1];
    m[2][2] = S - m[2][0] - m[2][1];
 
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(j != 0)
                cout << ' ';
            cout << m[i][j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int count = 0;
		for (int i = 0; i < S.length()/2; i++) {
		    if (S.charAt(i) == S.charAt(S.length() - (i + 1))) {
		    	continue;
		    } else {
		    	count++;
		    }
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23380
#include <stdio.h>
#include <stdlib.h>
#define MAX 500001
#define NIL NULL

struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};
typedef struct node * Node;

Node root;

Node treeSearch(Node x, int k){
  if(x==NIL||k==x->key)
    return x;
  if(k<x->key) return treeSearch(x->left,k);
  else return treeSearch(x->right,k);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}

void preorder(Node x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int INF = INT_MAX/3;
const double EPS = 1e-14;

template<typename U, typename T>
void chmin(U &x, T y) { x = min(x, y); }

template<typename U, typename T>
void chmax(U &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;

const int NMAX = 10;
string coststr[NMAX][NMAX];
pair<int,string> dp[1<<NMAX][NMAX];
int N;

string strcost(string src, string dst) {
  int upb = min(src.length(), dst.length());
  int i = upb;
  while (i >= 0 and src.substr(src.length()-i) != dst.substr(0, i)) { --i; }
  return dst.substr(i);
}

pair<int,string> solve(int S, int i) {
  if ((S | (1<<i)) == (1<<N)-1) return make_pair(0, "");
  if (dp[S][i].first < INF) return dp[S][i];
  pair<int,string> ans = make_pair(INF,"~");
  REP(j, N) {
    if ((S>>j)&1 or i == j) continue;
    chmin(ans, [i, j](pair<int,string> p){
        p.first += coststr[i][j].length();
        p.second = coststr[i][j] + p.second;
        return p;
      }(solve(S|(1<<i), j)));
  }
  dp[S][i] = ans;
  return dp[S][i];
}

int includeder(string query, vector<string> ss) {
  int i = 0;
  for (string s:ss) {
    if (s.find(query) != string::npos) { ++i; }
  }
  return i;
}

int main() {
  string s, d;
  while (cin >> N and N) {
    REP(i,1<<NMAX) REP(j,NMAX) { dp[i][j] = make_pair(INF,""); }
    vector<string> queries, s_;
    REP(i, N) {
      string s;
      cin >> s;
      if (find(ALL(queries), s) == queries.end()) { queries.push_back(s); }
    }
    for (string q:queries) {
      if (includeder(q,queries) == 1) { s_.push_back(q); }
    }
    N = s_.size();
    REP(i, N) REP(j, N) { 
      coststr[i][j] = strcost(s_[i], s_[j]);
    }
    pair<int,string> ans = make_pair(INF, "");
    REP(i, N) {
      chmin(ans, [](pair<int,string> c, string s){
          c.first += s.length();
          c.second = s + c.second;
          return c;
        }(solve(0, i), s_[i]));
    }
    cout << ans.second << endl;
  } 
  return 0;
}

Measured memory_bytes: 1776
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,l,r) for(int i=l; i<(int)(r); i++)
#define max(l,r) (l>r?l:r)
#define min(l,r) (l<r?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;

int main(){
    int n, p; scanf("%d%d",&n,&p);
    int a[101010], cnt[2] = {0};
    rep(i,n) scanf("%d",a+i);
    ll ans = 0;

    rep(i,n) cnt[(a[i])%2]++;
    if(cnt[1] > 0)
        ans = (1LL << (cnt[1]-1)) * (1LL << cnt[0]);
    else
        ans = (p == 1 ? 0 : (1LL << cnt[0]));
    printf("%lld",ans);
}

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

vector<Int> factors(Int n) {
    vector<Int> v;
    for (Int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i*i != n) v.push_back(n/i);
        }
    }
    return v;
}

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

    
    vector<Int> d1, d2;
    d1 = factors(N);
    d2 = factors(N-1);

    Int cnt1 = 0;

    for (int i = 0; i < d1.size(); ++i) {
        if(d1[i] == 1) continue;

        Int M = N;
        Int now = d1[i];
        while (M % now == 0) {
            M /= now;
        }
        if (M % now == 1) cnt1++;
    }

    Int cnt2 = d2.size()-1;


    cout << cnt1 + cnt2 << endl;
}




Measured memory_bytes: 3524
#include <iostream>
using namespace std;
int main() {
    int X,Y; cin>>X>>Y;
    int turu, kame, flg;

    for (turu = 0; turu <= X; turu++) {
        kame = X - turu;
        flg = (X == kame + turu) && (Y == 2 * turu + 4 * kame);
        if (flg) {
            break;
        }
    }
    if (flg) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3632
def main():
    A, B = map(int, input().split())
    S = list(input().split('-'))
    if len(S) == 2:
        if len(S[0]) == A and len(S[1]) == B:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, p[100], P[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		P[i] = p[i];
	}
	sort(P, P + N);
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != P[i]) {
			count++;
		}
	}
	if (count > 2) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
	vector <ll> a;
	int n, r, l;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		ll temp;
		cin >> temp;
		a.push_back(temp);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n-1; ++i) {
		if (a[i] == a[i + 1]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#define ll long long
using namespace std;
int main() {
 ll A, B; 
 ll tapnum = 0;
 ll ans = 1;
 cin >> A >> B;
 if (B==1) cout << 0 << endl;
 else {
   tapnum += A;
   while (tapnum < B) {
     tapnum += A - 1;
     ans++;
   }
   cout << ans << endl;
 }
}


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

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 100005;
const int INF = 1001001001;
const int MOD = 1000000007;

int hight(int n) {
    int res = 0;
    while(n > 0) res++, n /= 2;
    return res;
}

int dp[515][MAX];

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

    vector<int> V(N+1), W(N+1);
    rep(i, N) cin >> V[i+1] >> W[i+1];

    // 二分木の高さ
    int k = hight(N);

    int m = 1 << (k / 2);
    rep(i, MAX) dp[1][i] = W[1] <= i? V[1] : 0;

    auto init = [&](){
        for (int i = 2; i < m; ++i) {
            for (int j = 0; j < MAX; ++j) {
                chmax(dp[i][j], dp[i/2][j]);
                if (W[i] <= j) chmax(dp[i][j], dp[i/2][j-W[i]] + V[i]);
            }
        }
    };

    init();

    int Q;
    cin >> Q;
    rep(q, Q) {
        int v, l;
        cin >> v >> l;

        if (v < m) {
            cout << dp[v][l] << endl;
            continue;
        }

        vector<P> vec;
        vec.emplace_back(0, 0);
        while (m <= v) {
            vector<P> old;
            swap(old, vec);
            for (auto &p : old) {
                vec.emplace_back(p);
                vec.emplace_back(p.first + V[v], p.second + W[v]);
            }
            v /= 2;
        }

        int ans = 0;
        for (auto &p : vec) {
            if (p.second > l) continue;
            chmax(ans, p.first + dp[v][l - p.second]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 204900
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
#define N 100000
#define inf 1000000000
typedef long long ll;






int main(){
    int i,k,a,b,la,lb;
    cin>>k>>a>>b;
    la=a/k;lb=ceil(b*1.0/k);
    for(i=la;i<=lb;i++){
        if(i*k>=a&&i*k<=b){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

//ACGT
//AGC GAC ACG AXGC AGXC
//021 201 012 0X21 02X1
int f[maxn][4][4][4];
int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  f[0][3][3][3] = 1;
  for(int i=0;i<n;i++)
    for(int j=0;j<4;j++)
      for(int k=0;k<4;k++)
        for(int p=0;p<4;p++){
          if(f[i][j][k][p]==0)continue;
          for(int q=0;q<4;q++){
            if(k==0&&p==2&&q==1)continue;
            if(k==2&&p==0&&q==1)continue;
            if(k==0&&p==1&&q==2)continue;
            if(j==0&&p==2&&q==1)continue;
            if(j==0&&k==2&&q==1)continue;
            f[i+1][k][p][q]+=f[i][j][k][p];
            f[i+1][k][p][q]%=mod;
          }
        }
  int ret = 0;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      for(int k=0;k<4;k++){
        ret=(ret+f[n][i][j][k])%mod;
      }
  cout<<ret<<endl;
  return 0;
}

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

const int inf = (1<<29);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    vector<vector<ll>> dp(n+1,vector<ll>(2));
    dp.at(0).at(1) = -inf;
    rep(i,n) {
        dp.at(i+1).at(0) = max(dp.at(i).at(0) + a.at(i), dp.at(i).at(1) - a.at(i));
        dp.at(i+1).at(1) = max(dp.at(i).at(0) -  a.at(i), dp.at(i).at(1) + a.at(i));
    }
    cout << dp.at(n).at(0) << endl;
    return 0;
}

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

class Dice{
	int top, n, s, e, w;
public:
	Dice();
	void roll(char dir);
	int getTop();
};

Dice::Dice(){
	top = 1;
	n = 5;
	s = 2;
	e = 3;
	w = 4;
}

void Dice::roll(char dir){
	switch (dir){
	case 'N':
		n = top;
		top = s;
		s = 7 - n;
		break;
	case 'S':
		s = top;
		top = n;
		n = 7 - s;
		break;
	case 'E':
		e = top;
		top = w;
		w = 7 - e;
		break;
	case 'W':
		w = top;
		top = e;
		e = 7 - w;
		break;
	}
}

int Dice::getTop(){
	return top;
}

int main(void){
	int num[6];
	string str;
	Dice dice;

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

	cin >> str;

	for (int i = 0; i < str.size(); i++){
		dice.roll(str[i]);
	}
	
	cout << num[dice.getTop()-1] << "\n";

	return 0;
}

Measured memory_bytes: 1208
def main():
    n = int(input())
    towns = list(map(int,input().split()))
    braves = list(map(int,input().split()))

    count = 0
    for b in range(n-1, -1, -1):
        if towns[b+1] > braves[b]:
            count = count + braves[b]
            towns[b+1] = towns[b+1] - braves[b]
            braves[b] = 0
            
        else:
            count = count + towns[b+1]
            braves[b] = braves[b] - towns[b+1]
            towns[b+1] = 0

        if braves[b]:
            if towns[b] > braves[b]:
                count = count + braves[b]
                towns[b] = towns[b] - braves[b]
                braves[b] = 0
                
            else:
                count = count + towns[b]
                braves[b] = braves[b] - towns[b]
                towns[b] = 0

    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 81892
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

const int N = 1e5 + 100, T = 2e3 + 100, OO = 1e12 + 10, M = 1e9 + 7, P = 49157, sq = 360, lg = 20;
typedef pair <int, int> pii;
int a[N], n, x;

int sum() {
	int cnt = 0;
	for(int i = 0; i < n; i++)
		cnt += a[i];
	return cnt;
}

int32_t main() {
	use_fast;
	cin >> n >> x;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int ans = sum();
	for(int i = 1; i <= n; i++) {
		int fs = a[0];
		for(int j = 0; j < n - 1; j++) 
			a[j] = min(a[j], a[j + 1]);
		a[n - 1] = min(a[n - 1], fs);
		ans = min(ans, x * i + sum());
	}
	cout << ans << endl;
	return 0;
} 	
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;
const ll INF = 2e18;

ll N, K, A[MAX];

vi pos, neg;

ll negIndexOf(ll x) {
    ll ret = 0;
    ll i_p = 0;
    REPR (i_n, neg.size()) {
        while (i_p < pos.size() && x < neg[i_n] * pos[i_p]) i_p++;
        ret += pos.size() - i_p;
    }
    return ret;
}

ll countZero() {
    ll z = N - (int)pos.size() - (int)neg.size();
    return z * (N-z) + (z-1)*z / 2;
}

ll posIndexOf(ll x) {
    auto f = [&x](vi vec) -> ll {
        ll ret = 0;
        ll n = vec.size();
        ll r = n-1;
        REP (l, n) {
            while (l < r && x < vec[l] * vec[r]) r--;
            ret += max(0ll, r-l);
        }
        return ret;
    };

    return f(pos) + f(neg);
}

ll indexOf(ll x) {
    ll ret = negIndexOf(min(x, -1ll));
    if (x >= 0) ret += countZero();
    if (x > 0) ret += posIndexOf(x);
    return ret;
}

ll solve() {
    REP (i, N) {
        if (A[i] > 0) pos.push_back(A[i]);
        if (A[i] < 0) neg.push_back(A[i]);
    }
    sort(ALL(pos));
    sort(ALLR(neg));

    ll ng = -INF, ok = INF;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        if (indexOf(mid) >= K) ok = mid;
        else ng = mid;
    }

    return ok;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define PB push_back
#define ub upper_bound
#define lb lower_bound
#define ins insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
int main()
{
    ll n,sum=0;
    cin>>n;
    F(i,1,n+1,1)
    {
        if(i%15==0)
            continue;
        else if(i%3==0)
            continue;
        else if(i%5==0)
            continue;
        else
            sum+=i;

    }
        cout<<sum;

    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n,m,k;
int d[16],v[100][100];

const int INF=123456789;
const int N=1<<16;
int dp[N];

int main()
{
    scanf(" %d %d %d", &n, &m, &k);
    rep(i,m)
    {
        scanf(" %d", &d[i]);
        --d[i];
    }
    rep(i,n)rep(j,k)
    {
        scanf(" %d", &v[i][j]);
        --v[i][j];
    }

    fill(dp,dp+N,INF);
    int start = (1<<m)-1;
    dp[start] = 0;

    queue<int> que;
    que.push(start);
    while(!que.empty())
    {
        int mask = que.front();
        que.pop();

        // printf("mask = %d\n", mask);

        rep(i,k)
        {
            int nx=0;
            rep(j,m)if(mask>>j&1)
            {
                int next_room = v[d[j]][i];
                // printf(" next_room = %d\n", next_room);
                rep(d_idx,m)
                {
                    if(d[d_idx] == next_room)
                    {
                        nx |= (1<<d_idx);
                        break;
                    }
                }
            }

            // printf("i = %d, nx = %d\n", i,nx);
            if(dp[nx] > dp[mask]+1)
            {
                dp[nx] = dp[mask]+1;
                que.push(nx);
            }
        }
    }

    printf("%d\n", dp[0]);
    return 0;
}

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

int main() {
  int N; cin >> N;
  string s; cin >> s;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (s.at(i) == 'R') cnt++;
  }
  if (cnt > (N - cnt)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    while (true) {
		    String line = br.readLine();
		    int H = Integer.parseInt(line.split(" ")[0]);
		    int W = Integer.parseInt(line.split(" ")[1]);

		    if (H == 0 && W == 0) break;

		    display(H, W);
	    }
	}

	public static void display(int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h - 1) {
					System.out.print("#");
				} else {
					if (j == 0 || j == w - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
			}
			System.out.println("");
		}
		System.out.println("");
	}
}

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

const int N = 5050;

int n;
string s;
map<deque<char>, vector<int>> vec;

bool check(int len) {
	vec.clear();
	deque<char> now;
	for (int i = 0; i < len; i++)
		now.push_back(s[n - len + i]);
	vec[now].push_back(n - len);
	for (int i = n - len - 1; i >= 0; i--) {
		now.pop_back();
		now.push_front(s[i]);
		vec[now].push_back(i);
	}


	for (auto p: vec)
		if(p.second[0] - p.second.back() >= len)
			return true;
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> s;
	int l = 0, r = n + 1;
	while(r - l > 1) {
		int c = (l + r) >> 1;
		if(check(c))
			l = c;
		else
			r = c;
	}
	cout << l;
	return 0;
}


Measured memory_bytes: 9344
import java.util.*;

public class Main {
        public static void main(String[] args){
            Scanner sc =new Scanner(System.in);
            int n = sc.nextInt();
            int[] h = new int[n];
            for(int i=0;i<n;i++){
                h[i] = sc.nextInt();
            }
            int max = h[0];
            int sum = 1;
            for(int j=1;j<n;j++){
                if(h[j]>=max){
                    sum++;
                    max=h[j];
                }
            }
            System.out.println(sum);
            for(long k = 0;k<1000000;k++){
                sum=sum*1/1^1;
            }
        }

        }


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => BigInteger.Parse(x)).ToArray();
            var K = vals[3];
            var result = new BigInteger(0);
            if(K%2==0)
            {
                result = vals[0] - vals[1];
            }
            else
            {
                result = vals[1] - vals[0];
            }

            if(BigInteger.Abs(result) >= BigInteger.Pow(10, 18))
            {
                Console.WriteLine("Unfair");
            }
            else
            {
                Console.WriteLine(result.ToString());
            }
        }
    }
}


Measured memory_bytes: 13652
#include <bits/stdc++.h>
using namespace std;
template <class c> struct rge { c b, e; };
template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; }
template <class c> auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c> char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
template <class c> typename enable_if<sizeof dud<c>(0)!=1, debug&>::type operator<<(c i) {cerr << boolalpha << i; return * this; }
template <class c> typename enable_if<sizeof dud<c>(0)==1, debug&>::type operator<<(c i) {return * this << range(begin(i), end(i)); }
template <class c, class b> debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template <class c> debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template <class c> debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


typedef long long ll;
typedef long double ld;

#define ar array

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound 

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int main() {
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double x = h*1.0/12.0+(m%60)*1.0/60.0/12.0;
	double y = m*1.0/60.0;
	debug() << imie(x) imie(y);
	double diff = x-y;
	if (diff<0.0) diff += 1.0;
	diff = min(diff,1.0-diff);
	double d = a*a+b*b-2.0*a*b*cos(diff*2*M_PI);
	cout << setprecision(10) <<sqrt(d) << endl;
    return 0;    
}


Measured memory_bytes: 4136
#include <iostream>
using namespace std;
int main(void){
    int a, b ;
    cin>>a>>b ;
    if(a<b){
        cout<< "a < b";
    }else if(a>b){
        cout<< "a > b";
    }else{
        cout<< "a == b";
    }
    cout<<endl;
}


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

int main() {
	long long n;
	cin >> n;
	cout << 50 << endl;
	for(int i = 0; i < 50; ++i) {
		if(i) cout << ' ';
		cout << 49 - i + (n + 49 - i) / 50;
	}
	cout << endl;
}

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

struct restaurant {
    string name;
    int score;
    int id;
};

bool operator < (const restaurant &a, const restaurant &b) {
    if (a.name != b.name) {
        return a.name < b.name;
    } else if (a.score != b.score) {
        return a.score > b.score;
    } else {
        return a.id < b.id;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    while (cin >> n) {
        vector<restaurant> restaurants;
        for (int i = 0; i < n; i++) {
            restaurant r; cin >> r.name >> r.score; r.id = i;
            restaurants.push_back(r);
        }
        sort(restaurants.begin(), restaurants.end());
        for (auto r : restaurants) {
            cout << r.id+1 << '\n';
        }
    }
    return 0;
}


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

struct disjoint_set{
  size_t n;
  vector<int> par;
  disjoint_set(){}
  disjoint_set(size_t _n):n(_n){
    par.resize(n,-1);
  }
  void reset(size_t _n){
    n = _n;
    par.clear();
    par.resize(n,-1);
  }
  int root(int k){
    while(par[k]>=0){
      if(par[par[k]]>=0)par[k]=par[par[k]];
      k = par[k];
    }
    return k;
  }
  int size(int k){
    k = root(k);
    return -par[k];
  }
  auto operator[](int k){
    return size(k);
  }
  bool connect(int a,int b){
    a = root(a);
    b = root(b);
    if(a==b)return false;
    if(size(a)<size(b))swap(a,b);
    par[a] += par[b];
    par[b] = a;
    return true;
  }
  auto operator()(int a,int b){
    return connect(a,b);
  }
  bool same(int a,int b){
    return root(a) == root(b);
  }
};

signed main(){

  int n,m,k;
  cin>>n>>m>>k;
  disjoint_set st(n);
  vector<int> deg(n);
  for(int _{0};_<m;++_){
    int a,b;
    cin>>a>>b;
    a--;b--;
    st(a,b);
    deg[a]++;
    deg[b]++;
  }
  for(int _{0};_<k;++_){
    int c,d;
    cin>>c>>d;
    c--;d--;
    if(st.same(c,d)){
      deg[c]++;
      deg[d]++;
    }
  }
  for(int v{0};v<n;++v){
    cout<<(st[v]-deg[v]-1)<<" ";
  }
  cout<<endl;

}

Measured memory_bytes: 1664
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I]*(N*2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 81340