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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;

    cin >> s;

    vector<int> v('z' - 'a' + 1);

    int i, len = s.size();

    for (i = 0; i < len; i++) v[s[i] - 'a']++;

    len = 'z' - 'a' + 1;
    for (i = 0; i < len; i++) {
        if (v[i] == 0) {
            cout << (char)(i + 'a') << endl;

            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
long long n, x, r;
long long Do(long long a, long long b){
    if(a%b==0)return (a/b)*2*b-b;
    if(b%a==0)return (b/a)*2*a-a;
    if(a>b)return (a/b)*2*b+Do(a%b,b);
    return (b/a)*2*a+Do(b%a,a);
}
int main(){
    scanf("%lld%lld",&n,&x);
    printf("%lld\n",n + Do(x,n-x));
}

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

  int main () {
      int x, y;
      
      cin >> x >> y;
      
     int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};   int b[] = {4, 6, 9, 11};
      
      
      cout << (a[x] == a[y] ? "Yes": "No" ) << endl;
      
      
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    //       6
    //     2 6 5
    //   2 2 6 6 5
    // 3 2 1 7 6 5 4

    //       6
    //     6 6 2
    //   5 6 6 2 2
    // 3 5 6 7 1 2 4

    //       2
    //     6 2 2
    //   6 6 2 2 3
    // 5 6 7 1 2 3 4

    //     2
    //   2 2 4
    // 3 2 1 4 5

    //         8
    //       8 8 3
    //     6 8 8 2 2
    //   6 6 8 8 2 2 3
    // 7 4 6 9 8 1 2 5 3

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt() * 2 - 1, x = sc.nextInt();
        if (x == 1 || x == n) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
        int[] ans = new int[n];
        ans[n / 2] = x;
        ans[n / 2 - 1] = x + 1;
        ans[n / 2 + 1] = x - 1;

        int idx = 1;
        for (int i = 0; i < n; i++) {
            if (idx == x - 1) {
                idx += 3;
            }
            if (i == n / 2 - 1) {
                i += 2;
                continue;
            }
            ans[i] = idx++;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(ans[i]);
        }
    }

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


Measured memory_bytes: 54336
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
  ll n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    string s;
    cin >> n >> s;
    // 右を　+1, 左を-1としたときの最大地になるのでは？
    int64_t maxnum = 0, sum = 0, maxi = 0;
    rep(i,n){
        if(s.at(i) == 'E') sum += 1;
        if(s.at(i) == 'W') sum -= 1;
        if(maxnum <= sum){
            maxnum = sum;
            maxi = i;
        }
    }
    int64_t res = 0;
    rep(i,n){
        if(i<maxi && s.at(i) == 'W') res += 1;
        if(i>maxi && s.at(i) == 'E') res += 1;
    }
    cout << res << endl;
}


Measured memory_bytes: 720
N = int(input())
S = [input() for _ in range(N)]
abc = 'abcdefghijklmnopqrstuvwxyz'
count = [50]*26
for s in S:
    count_this = [0]*26
    for char in s:
        count_this[abc.index(char)] += 1
    for i in range(26):
        count[i] = min(count[i], count_this[i])
ans = ''
for i in range(26):
    ans += abc[i]*count[i]
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#define ll long long
using namespace std;

struct store {
    int price=1000000001;
    int limit=0;
};
int compare_store(const void* a, const void* b)
{
    return (*(store*)a).price - (*(store*)b).price;
}

int main ()
{
    int n;
    int m;
    cin >> n >> m;
    store s[100000];
    for(int i = 0; i < n; ++i) {
        cin >> s[i].price >> s[i].limit;
    }
    qsort(s,n,sizeof(store),compare_store);
    ll cost = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i].limit<m) {
            m-=s[i].limit;
            cost += ((ll)s[i].price*(ll)s[i].limit);
            continue;
        }
        cost += ((ll)s[i].price*(ll)m);
        break;
    }
    cout << cost;
}

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int room[4][3][10]={{{0}}};
  
  for(int i=0;i<n;i++)
  {
    int b,f,r,v;
    cin>>b>>f>>r>>v;
    room[b-1][f-1][r-1]+=v;
  }
  
  for(int B=0;B<4;B++)
  {
    for(int F=0;F<3;F++)
    {
      for(int R=0;R<10;R++)
      {
        cout<<" "<<room[B][F][R];
      }
      cout<<endl;
    }
    if(B<=2)cout<<"####################"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3096
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Int
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

readInt :: BS.ByteString -> Int
readInt s = case BS.readInt s of
              Just (x, _) -> x

main = do
  n <- readInt <$> BS.getLine
  xs :: U.Vector Int64 <- U.fromListN n . map (fromIntegral . readInt) . BS.words <$> BS.getLine
  let negatives = U.filter (<= 0) xs
      abss = U.map abs xs
  if even (U.length negatives)
    then print $ U.sum $ U.map abs xs
    else print $ (U.sum abss) - 2 * U.minimum abss


Measured memory_bytes: 5756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
    int n; cin >> n;
    vector<ll> a(n), s(n);
    for(int i=0; i<n; ++i){cin >> a[i];}
    s[0] = 0;
    for(int i=0; i<n-1; ++i){
        s[i+1] = (s[i] + a[n-1-i])%mod;
    }
    ll res = 0;
    for(int i=0; i<n; ++i){
        res += (a[n-1-i] * s[i])%mod;
    }
    res %= mod;
    cout << res << endl;
    return 0;
}

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

int main()
{
    int n, ai, max = 0, min = 1 << 30;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> ai;
        if(ai > max) max = ai;
        if(ai < min) min = ai;
    }
    cout << max - min << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 300000 + 1000;
const int INF = 0x3f3f3f3f;

struct Node
{
	int l, r, s, p;
	Node *lc, *rc;
	Node(int _l, int _r) : l(_l), r(_r), s(0), p(0), lc(NULL), rc(NULL)
	{}
}
*root;

void build(Node* &now, int l, int r)
{
	now = new Node(l, r);
	if(l == r)
		return ;
	int mid = (l + r) / 2;
	build(now->lc, l, mid);
	build(now->rc, mid + 1, r);
}

void update(Node *now)
{
	now->s = max(now->lc->s, now->rc->s);
}

void add(Node *now, int v)
{
	now->s += v;
	now->p += v;
}

void down(Node *now)
{
	if(now->p)
	{
		add(now->lc, now->p);
		add(now->rc, now->p);
		now->p = 0;
	}
}

void modify(Node *now, int l, int r, int v)
{
	if(now->r < l || r < now->l)
		return ;
	if(l <= now->l && now->r <= r)
		return add(now, v);
	down(now);
	modify(now->lc, l, r, v);
	modify(now->rc, l, r, v);
	update(now);
}

int query(Node *now, int l, int r)
{
	if(now->r < l || r < now->l)
		return -INF;
	if(l <= now->l && now->r <= r)
		return now->s;
	down(now);
	return max(query(now->lc, l, r), query(now->rc, l, r));
}

typedef pair<int, int> pii;

int n, W, H, ans = 0;
pii p[MAXN];

void solve()
{
	stack<pii> sta1, sta2;
	int mid = H / 2;

	sort(p + 1, p + n + 1);
	build(root, 1, n);
	for(int i = 1; i <= n; i++)
	{
		ans = max(ans, query(root, 1, i - 1) + p[i].first);
		// cerr << i << ' ' << query(root, 1, i - 1) << endl;

		if(p[i].second <= mid)
		{
			int t = i - 1;
			while(!sta1.empty() && sta1.top().first < p[i].second)
			{
				modify(root, sta1.top().second, t, sta1.top().first - p[i].second);
				t = sta1.top().second - 1;
				sta1.pop();
			}
			if(t != i - 1)
				sta1.push(make_pair(p[i].second, t + 1));
		}
		else
		{
			int t = i - 1;
			while(!sta2.empty() && sta2.top().first > p[i].second)
			{
				modify(root, sta2.top().second, t, p[i].second - sta2.top().first);
				t = sta2.top().second - 1;
				sta2.pop();
			}
			if(t != i - 1)
				sta2.push(make_pair(p[i].second, t + 1));
		}

		sta1.push(make_pair(0, i));
		sta2.push(make_pair(H, i));
		modify(root, i, i, H - p[i].first);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> W >> H >> n;
	for(int i = 1; i <= n; i++)
		cin >> p[i].first >> p[i].second;
	p[++n] = make_pair(0, 0);
	p[++n] = make_pair(0, H);
	p[++n] = make_pair(W, 0);
	p[++n] = make_pair(W, H);
	solve();
	for(int i = 1; i <= n; i++)
		swap(p[i].first, p[i].second);
	swap(W, H);
	solve();
	cout << ans * 2 << endl;

	return 0;
}


Measured memory_bytes: 60120
#include<bits/stdc++.h>
using namespace std;
#define N 1000100
int dp[N], odd[N];
#define reps(i,n,m) for(int i=int(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
int func(int x) {
	return x*(x+1)*(x+2)/6;
}
int main() {
	int num = 1;
	int a;
	rep(i,N) {
		dp[i]=N;
		odd[i]=N;
	}
	while((a=func(num)) < N){
		dp[a] = 1;
		if(a%2==1) odd[a]=1;
		reps(i,1,N-a) {
			if(dp[i]!=N) {
				dp[i+a] = min(dp[i+a], dp[i]+1);
			}
			if(a%2==1 && odd[i]!=N) {
				odd[i+a]=min(odd[i+a], odd[i]+1);
			}
		}
		num++;
	}
	int x;
	while(cin>>x&&x!=0) {
		cout<<dp[x]<<" "<<odd[x]<<endl;
	}
	return 0;
}

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

bool correct(string s){
  if (s.find("AGC") != std::string::npos) return false;
  for (int i = 1; i < s.size(); ++i) {
    swap(s[i],s[i - 1]);
    if (s.find("AGC") != std::string::npos) return false;
    swap(s[i],s[i - 1]);
  }
  return true;
}

int main() {
  int n;
  map<string, long long> counts;
  cin>>n;
  counts["A"] = 1;
  counts["C"] = 1;
  counts["G"] = 1;
  counts["T"] = 1;
  int maxn = 1000000007;
  for (int i = 1; i < n; ++i) {
    map<string, long long> newmap;
    for (auto pair : counts) {
      string key = pair.first;
      if (key.size() > 3) key = key.substr(key.size() - 3);
      key += "A";
      if (correct(key)) newmap[key] += pair.second % maxn;
      key[key.size() - 1] = 'C';
      if (correct(key)) newmap[key] += pair.second % maxn;
      key[key.size() - 1] = 'G';
      if (correct(key)) newmap[key] += pair.second % maxn;
      key[key.size() - 1] = 'T';
      if (correct(key)) newmap[key] += pair.second % maxn;
    }
    counts = newmap;
  }
  long long res = 0;
  for (auto pair : counts) {
    res += pair.second;
  }
  res %= maxn;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

#pragma warning(disable:4996)

int main()
{
	string a, b;
	cin >> a >> b;
	
	for (int i = 0; i < a.size(); i++)
	{
		if (a == b) {
			cout << "Yes";
			return 0;
		}
		rotate(a.begin(), a.begin() + 1, a.end());
	}
	cout << "No";
	return 0;
	
	
}

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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(lli i=1;i<=n;i++)

int main(){
	map<char,char> m;
	m['A'] = 'T';
	m['C'] = 'G';
	m['T'] = 'A';
	m['G'] = 'C';

	char tmp;
	cin>>tmp;
	cout<<m[tmp]<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#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;
int n;
int a[21],b[21],c[21];
int main()
{
  cin >> n;
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  vector<int> x;

  int res = 0;
  rep(i,n) res += b[i];

  rep(i,n-1){
    if(a[i]+1==a[i+1]) x.push_back(a[i]);
  }
  rep(i,x.size()){
    res += c[x[i]];
  }

  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC166A()
{
	string S;
	cin >> S;
	if (S == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}
}

int main()
{
	ABC166A();
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#define N 1000

void cm(char a[] , char b[]);
int max(int a , int b);
int c[N+1][N+1];

int main()
{
	char a[N];
	char b[N];
	int i , n;
	scanf("%d",&n);
	for(i = 1; i <= n; i++)
	{
		scanf("%s%s",a+1,b+1);
		a[0]=b[0]= ' ';
		cm(a,b);
	}
}

int max(int a , int b)
{
	if(a < b)return b;
	else return a;
}

void cm(char  a[]  , char b[])
{
	int i , j;
	int m1,m2;
	m1 = strlen(a)-1;
	m2 = strlen(b)-1;
	int ma = 0;
	for(i=0;i<m1;i++)
	{
		c[0][i]=0;
	}
	for(j=0;j<m2;j++)
	{
		c[0][j]=0;
	}
	for(int i = 1; i <=m1; i++)
	{
		for(int j = 1; j<=m2; j++)
		{
			if(a[i]==b[j])
			{
				c[i][j]=c[i-1][j-1]+1;
			}
			else{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			ma = max(ma,c[i][j]);
				
		}
	}
	printf("%d\n",ma);
}




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

int main() {
  int N, X, T;
  cin >> N >> X >> T;

  if(N%X!=0){
    cout << (N/X)*T+T << endl;
  }
  else{
    cout << (N/X)*T << endl;
  }

return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>
int main() {
	double a[2], b[2], c[2], d[2], t[2], s[2];

	while (scanf(" %lf %lf %lf %lf %lf %lf %lf %lf ",
				a, a+1, b, b+1, c, c+1, d, d+1) != EOF) {
		t[0] = a[0] - b[0];
		t[1] = a[1] - b[1];
		s[0] = c[0] - d[0];
		s[1] = c[1] - d[1];

		if (round((t[0] * s[1] - t[1] * s[0]) * 100000.0) == 0.0) {
			puts("NO");
		}
		else if (round((t[0] * s[0] + t[1] * s[1]) * 100000.0) == 0.0) {
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  double x[10], y[10];
  rep(i,N) cin >> x[i+1] >> y[i+1];
  vector<int> p;
  rep(i,N) p.emplace_back(i+1);
  double l=0;
  do {
    rep(i,N-1){
      int s=p[i], g=p[i+1];
      double X=x[s]-x[g], Y=y[s]-y[g];
      l+=sqrt(X*X+Y*Y);
    }
  } while(next_permutation(p.begin(),p.end()));
  int n=1;
  rep(i,N) n*=i+1;
  cout << setprecision(15) << l/n << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  ll a,b,k;
  cin >> a >> b >> k;
  bool taka = true;
  rep(i,k){
    if(taka){
      if(a % 2 != 0)a--;
      b += a / 2;
      a /= 2;
      taka = false;
    }
    else{
      if(b % 2 != 0)b--;
      a += b / 2;
      b /= 2;
      taka = true;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int a,b;
	bool have=false;
	while(N!=0)
	{
		a=N%10;
		N=N/10;
		if(a==7)
		{
			have=true;
		}
	}
	if(have==true)
	{
		cout << "Yes\n" << endl;
	}
	else{
		cout << "No\n" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
#define NIL -1
Tree tree[10000];
void Preorder(int);
void Inorder(int);
void Postorder(int);
int main()
{
  int i,id,j,n,k,depth=0,num,l,r,degree=0,height=0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    tree[i].parent=NIL;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    tree[id].left=l;
    tree[id].right=r;
    if(l!=NIL && r!=NIL){
      tree[l].parent=id;
      tree[r].parent=id;
    }
    else if(l!=NIL && r==NIL){
      tree[l].parent=id;
    }
    else if(l==NIL && r!=NIL){
      tree[r].parent=id;
    }
  }
  for(j=tree[0].parent;tree[j].parent!=NIL;j=tree[j].parent);
  printf("Preorder\n");
  Preorder(j);
  printf("\nInorder\n");
  Inorder(j);
  printf("\nPostorder\n");
  Postorder(j);
  printf("\n");

  return 0;
}

void Preorder(int i)
{
  printf(" %d",i);
  if(tree[i].left!=NIL){
    Preorder(tree[i].left);
  }
  if(tree[i].right!=NIL){
    Preorder(tree[i].right);
  }
  
}
void Inorder(int i)
{
  if(tree[i].left!=NIL && tree[i].right!=NIL){
    Inorder(tree[i].left);
    printf(" %d",i);
    Inorder(tree[i].right);
 
  }
  if(tree[i].left!=NIL && tree[i].right==NIL){
    //printf(" %d",i);   
   Inorder(tree[i].left);
     printf(" %d",i);   
  } 
 
  if(tree[i].right!=NIL && tree[i].left==NIL){ 
  printf(" %d",i);
 Inorder(tree[i].right);  
 
  } 
  if(tree[i].left==NIL && tree[i].right==NIL)printf(" %d",i);

}
void Postorder(int i)
{
  if(tree[i].left==NIL && tree[i].right==NIL){
    printf(" %d",i);
  }
  else if(tree[i].left!=NIL && tree[i].right==NIL){
    Postorder(tree[i].left);
     printf(" %d",i);
  }
  else if(tree[i].right!=NIL && tree[i].left==NIL){
    Postorder(tree[i].right); 
     printf(" %d",i);
  } 
  else{
    Postorder(tree[i].left);
    Postorder(tree[i].right); 
     printf(" %d",i);
  }
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e+9+7;
int main(){
    string s;
    cin >> s;
    int pt = 1, n = s.size();
    int dp[100001][13] = {};
    dp[n][0] = 1;
    for(int i = n-1; i >= 0; i--){
        if(s[i] == '?'){
            for(int k = 0; k < 10; k++){
                for(int j = 0; j < 13; j++){
                    int rem = (k * pt + j) % 13;
                    dp[i][rem] = (dp[i][rem] + dp[i+1][j]) % MOD;
                }
            }
        }else{
            for(int j = 0; j < 13; j++){
                int rem = ((pt * (s[i] - '0')) + j) % 13;
                dp[i][rem] = (dp[i][rem] + dp[i+1][j]) % MOD;
            }
        }
        pt = (pt * 10) % 13;
    }
    cout << dp[0][5] << endl;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
void show(VEC<VEC<int>> &d) {
  REP(i, 0, d.size()) {
    REP(j, 0, d[i].size()) { printf("%10d ", d[i][j]); }
    puts("");
  }
  cerr << endl;
}

int main() {
  int H, N;
  cin >> H >> N;
  VEC<int> A(N), B(N);
  REP(i, 0, N) { cin >> A[i] >> B[i]; }
  //   DUMP(A);
  //   DUMP(B);
  auto dp = VEC<VEC<int>>(N + 1, VEC<int>(H + 1, INT32_MAX >> 1));
  REP(i, 0, N + 1) { dp[i][0] = 0; }
  REP(i, 0, N) {
    REP(h, 0, H + 1) {
      //   int nh = min((int)h + A[i], H);
      //   int nc = B[i];
      //   DUMP("nh", nh);
      //   DUMP("d(nh, i), d(h, i)+B(i)", dp[nh][i], dp[h][i] + B[i]);

      if (h < A[i]) {
        dp[i + 1][h] = dp[i][h];
      } else {
        dp[i + 1][h] = min(dp[i][h], dp[i + 1][h - A[i]] + B[i]);
      }
    }
    // DUMP("N", i);
    // show(dp);
  }
  LL ans = INT32_MAX;
  REP(h, 0, H + 1) {
    REP(i, 0, N) {
      LL nh = h + A[i];
      LL nc = dp[N][h] + B[i];
      if (nh >= H) {
        ans = min(ans, nc);
      }
    }
  }

  std::cout << ans << endl;

  return 0;
}


Measured memory_bytes: 39424
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int d[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>d[i];
  }
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      ans=ans+d[i]*d[j];
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void swap(int *a, int *b){
    int tmp = *a;
    *a = *b;
    *b = tmp;
}
void sort(int num[3]){
    if(num[1] > num[0]){
        swap(num, num+1);
    }
    if(num[2] > num[0]){
        swap(num, num+2);
    }
}
int main(){
    int num[3];
    scanf("%d %d %d", num, num+1, num+2);
    sort(num);
    printf("%d\n", num[0] * 10 + num[1] + num[2]);
    return 0;
}

Measured memory_bytes: 128
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int a = input[0];
            int b = input[1];
            Console.WriteLine(b >= a ? a : a - 1);
        }
    }
}

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

int main(){
    string s; cin >> s;
    if(s.back()=='F') s.push_back('T');
    int x,y; cin >> x >> y;
    set<int> dpx,dpy;
    vector<int> h,v;
    int cnt_f=0;
    int cnt_t=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='F'){
            cnt_f++;
        }else{
            cnt_t++;
            if(cnt_t%2==1) h.push_back(cnt_f);
            else v.push_back(cnt_f);
            cnt_f=0;
        }
    }
    /*
    for(int i=0;i<h.size();i++) cout << h[i] << endl;
    cout << endl;
    for(int i=0;i<v.size();i++) cout << v[i] << endl;
    */
    dpx.insert(h[0]);
    for(int i=1;i<h.size();i++){
        set<int> next;
        for(auto it:dpx){
            next.insert(it+h[i]);
            next.insert(it-h[i]);
        }
        swap(next,dpx);
    }
    dpy.insert(0);
    for(int i=0;i<v.size();i++){
        set<int> next;
        for(auto it:dpy){
            next.insert(it+v[i]);
            next.insert(it-v[i]);
        }
        swap(dpy,next);
    }
    auto it1=dpx.find(x);
    auto it2=dpy.find(y);
    if(it1!=dpx.end()&&it2!=dpy.end()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 768
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		in.nextLine();
		while(N-->0)
		{
			char ch[]=in.nextLine().toCharArray();
			char re[]=new char[ch.length];
			boolean judge=false;
			String res="";
			for(int a=0;a<26;a++)
			{
				for(int b=0;b<26;b++)
				{
					for(int i=0;i<ch.length;i++)
					{
						if(ch[i]==' ')
						{
							re[i]=' ';
							continue;
						}
						int m=(a*((int)ch[i]-97)+b)%26;
						re[i]=(char)(m+97);
					}
					res="";
					for(int i=0;i<re.length;i++)
						res+=re[i];
					if(res.indexOf("this")!=-1||res.indexOf("that")!=-1)
						judge=true;
					if(judge)
						break;
				}
				if(judge)
					break;
			}
			for(int i=0;i<re.length-1;i++)
				System.out.print(re[i]);
			System.out.println(re[re.length-1]);
		}
	}
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 88952
#include <iostream>
#define REP(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) REP(i,0,a)
using namespace std;

const int INF = 1 << 28;
int N, M, L, K, A, H, x, y, t;
int d[101][101], dd[101][101], c[101];

int main(void){
    while (cin >> N >> M >> L >> K >> A >> H, N) {
        rep(i, 101) rep(j, 101) d[i][j] = dd[i][j] = INF;
        rep(i, L) cin >> c[i];
        rep(i, K) {
            cin >> x >> y >> t;
            d[x][y] = d[y][x] = t;
        }
        
        rep(k, N) rep(i, N) rep(j, N) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        
        rep(i, L) {
            dd[  0][i+1] = dd[i+1][  0] = (d[A][c[i]] <= M ? d[A][c[i]]:INF);
            dd[L+1][i+1] = dd[i+1][L+1] = (d[H][c[i]] <= M ? d[H][c[i]]:INF);
        }
        
        rep(i, L) rep(j, L) dd[i+1][j+1] = (d[c[i]][c[j]] <= M ? d[c[i]][c[j]]:INF);
        
        dd[0][L+1] = dd[L+1][0] = (d[A][H] <= M ? d[A][H]:INF);
        rep(k, L+2) rep(i, L+2) rep(j, L+2) dd[i][j] = min(dd[i][j], dd[i][k]+dd[k][j]);
        
        int time = dd[0][L+1];
        if (time < INF) cout << time + max(0, time-M) << endl;
        else cout << "Help!" << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
import math
import collections
def main():

    N = int(input())
    d = dict()
    for i in range(1, N+1):
        d[i] = 0

    ans = 0
    for i in range(1, N+1):
        p = N//i
        ans += p * (p+1)//2 * i
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 568340
program main
    implicit none

    integer(4) :: n
    integer(4) :: m, i, num, c

    read(*, *) n

    do c=1, n-1
        m = n-c
        i = 1
        do while (i*i<=m)
            if (mod(m, i) == 0) then
                num = num + 1
                if (m/i /= i) then
                    num = num + 1
                end if
            end if 
            i = i + 1
        end do
        
    end do

    write(*, *) num

end program main 

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

string s;

void back(int d, int n){
    rep(i, d){
        if(s[n-1] == 'z') s[n-1] = 'a';
        else s[n-1]++;
    }
}

int main(){
    int n;
    while(cin >> n, n){
        cin >> s;
        vector<pair<int, int> > v;
        rep(i, n){
            int a, b;
            cin >> a >> b;
            v.push_back(make_pair(a, b));
        }
        reverse(v.begin(), v.end());
        rep(i, v.size()){
            int a = v[i].first, b = v[i].second;
            int d = abs(a-b);
            back(d, a);
            back(d, b);
            swap(s[a-1], s[b-1]);
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1204
def f(res,i)
  return res ^ i
end


A,B = readline.chomp.split.map(&:to_i)
res = nil


if(A == B)
  p A
elsif( A % 2 == 0)
  # 2,3 => 2 ^ 3
  if((B-A)%4== 1)
    p 1
  # 2,3,4 => 1 ^ 4
  elsif((B-A)%4 == 2)
    p 1 ^ B
  # 2,3,4,5 => 1 ^ 1 => 0
  elsif((B-A)%4 == 3)
    p 0
  # 2,3,4,5,6 => 1 ^ 1 ^ 6 => 0 ^ 6 => 6
  elsif((B-A)%4 == 0)
    p B
  # 2,3,4,5,6,7 = 1 ^ 1 ^ 1 => 0 ^ 1 => 1
  # elsif()
  #   p 1
  # # 2,3,4,5,6,7,8 = 1 ^ 1 ^ 1 ^ 8 => 1 ^ 8
  # elsif()

  # # 2,3,4,5,6,7,8,9 = 1 ^ 1 ^ 1 ^ 1 => 1 ^ 1 => 0
  # elsif()

  end
else
  # 3,4 => 3 ^ 4
  if((B-A)%4== 1)
    p A ^ B
  # 3,4,5 => 3 ^ 1
  elsif((B-A)%4== 2)
    p A ^ 1
  # 3,4,5,6 => 3 ^ 1 ^ 6
  elsif((B-A)%4== 3)
    p A ^ 1 ^ B
  # 3,4,5,6,7 = 3 ^ 1 ^ 1 => 3 ^ 0 => 3
  elsif((B-A)%4== 0)
    p A
  # 3,4,5,6,7,8 = 3 ^ 1 ^ 1 ^ 8 => 3 ^ 0 ^ 8 => 3 ^ 8
  # elsif()
  #   p A ^ B
  # # 3,4,5,6,7,8,9 = 3 ^ 1 ^ 1 ^ 1 => 3 ^ 1
  # elsif()
  
  end
end

# if ((A - B) % 2 + 1 == 0)
#   if (A % 2 == 0) && (B % 2 == 1)
#     res = 0
#   elsif (A % 2 == 0) && (B % 2 == 0)
#     res = f(0,B)
#   elsif (A % 2 == 1) && (B % 2 == 0)
#     res = f(A,B)
#   else
#     res = f(A,0)
#   end
# else ((A - B) % 2 + 1 == 1)
#   if (A % 2 == 0) && (B % 2 == 1)
#     res = 1
#   elsif (A % 2 == 0) && (B % 2 == 0)
#     res = f(1,B)
#   elsif (A % 2 == 1) && (B % 2 == 0)
#     res = f(A,B)
#   else
#     res = f(A,1)
#   end
# end


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

int main(void)
{
    int n; cin >> n;
    if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
        cout << "hon";
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
        cout << "pon";
    else
        cout << "bon";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll mod = 1e9+7;
const ll inf = 1e6;




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>a(n),d(inf+1);
    vector<ll>gcds(inf);
    for(int i = 2;i <= inf;++i){
        if(d[i])continue;
        d[i] = i;
        ll k = i*2;
        while(k <= inf){
            d[k] = i;
            k += i;
        }
    }
    rep(i,n){
        cin >> a[i];
        ll k = a[i];
        while(k != 1){
            ++gcds[d[k]-1];
            ll tmp = d[k];
            while(tmp == d[k]){
                k /= d[k];
            }
        }
    }
    ll l = 0,s = 1e18;
    rep(i,inf){
        if(i == 0)continue;
        l = max(gcds[i],l);
    }
    


    if(l == n){
        cout << "not coprime" << endl;
    }else if(l <= 1){
        cout << "pairwise coprime" << endl;
    }else{
        cout << "setwise coprime" << endl;
    }
    
    



    return 0;
}


Measured memory_bytes: 26672
N = gets.to_i
XY = []

N.times do 
  XY.push(gets.split().map(&:to_i))
end

sum = 0
count = 0

XY.permutation(N) do |array|
  array.each_cons(2) do |(x1, y1), (x2, y2)|
    sum += ((x1 - x2)**2 + (y1 - y2)**2) ** 0.5
  end
  count += 1
end

puts sum/count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int N;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    vector<ll> h(N);
    rep(i, 0, N) { cin >> h[i]; }
    bool flg = true;

    int pre = -100;
    for(int i = 0; i < N; i++) {
        if(pre <= h[i] - 1) {
            pre = h[i] - 1;
        } else if(pre <= h[i]) {
            pre = h[i];
        } else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 3928
n = int(input())
l = list(map(int, input().split()))
c = [False] * 8
red = 0
for i in range(n):
    if l[i] <= 399:
        c[0] = True
    elif l[i] <= 799:
        c[1] = True
    elif l[i] <= 1199:
        c[2] = True
    elif l[i] <= 1599:
        c[3] = True
    elif l[i] <= 1999:
        c[4] = True
    elif l[i] <= 2399:
        c[5] = True
    elif l[i] <= 2799:
        c[6] = True
    elif l[i] <= 3199:
        c[7] = True
    else:
        red += 1
ans_min = max(1, c.count(True))
ans_max = c.count(True) + red
print(ans_min, ans_max)

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

static const int WHITE = 0;
static const int ABLE  = 1;
static const int N = 20;

char a[N][N];
int judge[N][N];

void search(int x, int y, int w, int h) {
	queue<int> qx, qy;
	qx.push(x);
	qy.push(y);
	judge[y][x] = ABLE;
	
	int tx, ty;
	while (!qx.empty() && !qy.empty()) {
		tx = qx.front();
		qx.pop();
		ty = qy.front();
		qy.pop();
		
		if (ty + 1 < h && a[ty+1][tx] != '#' && judge[ty+1][tx] == WHITE) {
			judge[ty+1][tx] = ABLE;
			qx.push(tx);
			qy.push(ty+1);
		}
		if (ty - 1 >= 0 && a[ty-1][tx] != '#' && judge[ty-1][tx] == WHITE) {
			judge[ty-1][tx] = ABLE;
			qx.push(tx);
			qy.push(ty-1);
		}
		if (tx + 1 < w && a[ty][tx+1] != '#' && judge[ty][tx+1] == WHITE) {
			judge[ty][tx+1] = ABLE;
			qx.push(tx+1);
			qy.push(ty);
		}
		if (tx - 1 >= 0 && a[ty][tx-1] != '#' && judge[ty][tx-1] == WHITE) {
			judge[ty][tx-1] = ABLE;
			qx.push(tx-1);
			qy.push(ty);
		}
	}
}

int main() {
	while (1) {
		int w, h;
		cin >> w >> h;
		if (h == 0) break;
		
		int startx, starty;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> a[i][j];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] == '.' || a[i][j] == '#') judge[i][j] = WHITE;
				else {
					startx = j;
					starty = i;
					judge[i][j] = WHITE;
				}
			}
		}
		
		search(startx, starty, w, h);
		
		int count = 0;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (judge[i][j] == ABLE) count++;
			
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	string str, cmd;
	int a, b, q;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> cmd >> a >> b;
		if (cmd == "print") {
			for (int j = a; j <= b; j++)
				cout << str[j]; cout << endl;
		}
		else if (cmd == "reverse") {
			int fend = (b - a + 1) / 2;
			for (int j = 0; j < fend; j++)
				swap(str[a++], str[b--]);
		}
		else if (cmd == "replace") {
			string p; int n = 0;
			cin >> p;
			for (int k = a; k <= b; k++) {
				str[k] = p[n++];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3216
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] as = new int[n];
		int count = 0;
		
		for(int i=0; i<as.length; i++) {
			as[i] = sc.nextInt();
		}
		sc.close();
		
		Arrays.sort(as);
		
		for(int i=0; i<as.length; i++) {
			boolean bool = true;
			while(i!=as.length-1 && as[i]==as[i+1]) {
				bool = !bool;
				i++;
			}
			
			if(bool) {
				count++;
			}
				
		}
		
		System.out.println(count);

	}

}

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

int main()
{
    int a,b;
    string s;
    bool flag = true;

    cin >> a >> b;

    cin >> s;
    
    for(int i = 0;i < s.size();i++){
        if(i == a) continue;
        
        if(s[i] == '-') flag = false;
    }
    if(flag && s[a] == '-') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    
    int value=0;
    for(int i=0;i<k;i++){
        if((a+i)%k==0){
            value=(a+i);
        }
    }
    if(value<=b){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3564
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int s=x*a+y*b;
    int l=0;
    int h=0;
    int g=0;
    int m=min(x,y);
    int n=max(x,y);
    if(x>y)
    {
        l=2*m*c+(x-y)*a;
        h=2*n*c;
        g=min(l,h);
    }
    else
    {
        l=2*m*c+(y-x)*b;
        h=2*n*c;
        g=min(l,h);
    }
    int kqy=min(s,g);
    cout<<kqy;

    return 0;
}

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

int main(){
    int n;
    std::string str;
    std::string fr = "Hoshino";
    std::string to = "Hoshina";
    std::string::size_type pos;
    std::cin >> n;
    std::cin.get();
    
  
        //文字列の読み込み
        while(n > 0 && std::getline(std::cin, str)){
            //"Hoshino"を"Hoshina"に変換
            pos = str.find(fr);
            while(pos != std::string::npos){
                str.replace(pos, fr.size(), to);
                pos = str.find(fr, pos+to.size());
            }
             std::cout << str << std::endl;
            str = "";
            std::cin.clear();
            --n;
        }
}


Measured memory_bytes: 3132
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n):
    c = input().split()
    if c[1] == "JPY": s+= int(c[0])
    else :s += 380000.0 * float(c[0])
print(s)

Measured memory_bytes: 13900
#include<stdio.h>
int main()
{
	int a,b,i,j;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		char s[a+2][b+2];
		
		for(i=0;i<a+2;i++)
		{
			for(j=0;j<b+2;j++)
			{
				s[i][j]='#';
			}
		}
		for(i=1;i<=a;i++)
		{
			for(j=1;j<=b;j++)
			{
				scanf("\n%c",&s[i][j]);
			}
		}
		for(i=0;i<a+2;i++)
		{
			for(j=0;j<b+2;j++)
			{
				printf("%c",s[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;
class Solver2 {
 public:
  int h, w;
  vector<string> s;
  vector<vector<int>> dp;
  Solver2(LL h, LL w) : h(h), w(w), s(h), dp(h, vector<int>(w, INF)){};

  void solve() {
    for (int i = 0; i < h; ++i) {
      cin >> s[i];
    }
    dp[h - 1][w - 1] = (s[h - 1][w - 1] == '#');
    for (int j = w - 1; j >= 0; --j) {
      for (int i = h - 1; i >= 0; --i) {
        if (i == h - 1 && j == w - 1) continue;
        calc(i, j);
      }
    }
    DBG(dp)
    cout << dp[0][0] << endl;
  }

  void calc(int x, int y) {
    queue<pair<int, int>> Q;
    vector<vector<int>> vis(h, vector<int>(w));
    Q.emplace(x, y);
    while (!Q.empty()) {
      auto now = Q.front();
      Q.pop();
      if (now.first + 1 < h && now.second < w) {
        auto nxt = now;
        nxt.first++;
        if (s[nxt.first][nxt.second] == s[x][y] && vis[nxt.first][nxt.second] == 0) {
          vis[nxt.first][nxt.second] = 1;
          Q.push(nxt);
        }
        if (s[nxt.first][nxt.second] == s[x][y] && nxt.first == h - 1 && nxt.second == w - 1) {
          dp[x][y] = min(dp[x][y], dp[nxt.first][nxt.second]);
        } else {
          dp[x][y] = min(dp[x][y], dp[nxt.first][nxt.second] + (s[x][y] == '#'));
        }
      }
      if (now.first < h && now.second + 1 < w) {
        auto nxt = now;
        nxt.second++;
        if (s[nxt.first][nxt.second] == s[x][y] && vis[nxt.first][nxt.second] == 0) {
          vis[nxt.first][nxt.second] = 1;
          Q.push(nxt);
        }
        if (s[nxt.first][nxt.second] == s[x][y] && nxt.first == h - 1 && nxt.second == w - 1) {
          dp[x][y] = min(dp[x][y], dp[nxt.first][nxt.second]);
        } else {
          dp[x][y] = min(dp[x][y], dp[nxt.first][nxt.second] + (s[x][y] == '#'));
        }
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


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

typedef long long LL;

using namespace std;

vector<vector<int>> g;

vector<bool> marked;
vector<int> component;

void dfs(int v) {
	marked[v] = true;
	component.push_back(v);

	for (int u: g[v])
		if (!marked[u])
			dfs(u);
}

int main() {
	int n;
	cin >> n;
	vector<array<int, 3>> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i][0] >> p[i][1];
		p[i][2] = i;
	}

	sort(p.begin(), p.end());
	
	g.assign(n, {});

	set<pair<int,int>> pre;
	for (int i = 0; i < n; i++) {
		auto x = pre.lower_bound({p[i][1], -1});
		if (pre.empty() || pre.begin()->first > p[i][1]) {
			pre.insert({p[i][1], p[i][2]});
			continue;
		}

		auto first = *pre.begin();
		while (!pre.empty() && pre.begin()->first < p[i][1]) {
			int id = pre.begin()->second;
			pre.erase(pre.begin());

			g[id].push_back(p[i][2]);
			g[p[i][2]].push_back(id);
		}

		pre.insert(first);
	}

	vector<int> answer(n);

	marked.assign(n, false);
	for (int i = 0; i < n; i++)
		if (!marked[i]) {
			component.clear();
			dfs(i);
			int sz = (int)component.size();
			for (int v: component)
				answer[v] = sz;
		}

	for (int x: answer) cout << x << '\n';

	return 0;
}


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

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

        int D[4][3][10];
        for (int i = 0; i < 4; ++i) {
                for (int j = 0; j < 3; ++j) {
                        for (int k = 0; k < 10; ++k) {

                                D[i][j][k] = 0;
                        }
                }
        }

        for (int i = 0; i < n; ++i) {
                int b, f, r, v;
                cin >> b >> f >> r >> v;
                D[b-1][f-1][r-1] += v;
        }
        for (int i = 0; i < 4; ++i) {

                for (int j = 0; j < 3; ++j) {

                        for (int k = 0; k < 10; ++k) {
                                cout << " ";
                                cout << D[i][j][k];
                        }
                        cout << endl;
                }
                if (i != 3) {
                        cout << "####################" << endl;
                }
        }



}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807


void solve()
{
  
  string S;
  cin>>S;
  int count = 0;
  int max_v = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if((S[i] == 'A')||(S[i] == 'G')||(S[i] == 'C')||(S[i] == 'T'))count++;
    else
    {
      max_v = max(max_v,count);
      count = 0;
    }
  }

  max_v = max(max_v,count);
  cout<<max_v<<endl;
  
  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    long long A[N];
    long long count = 0;
    long long sum=0;
    long long ans ;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] < 0)count++;
        sum += abs(A[i]);
    }
    
    if(count % 2 == 0){
        ans = sum;
    }
    else{
        ans = 0;
        for(int i=0;i<N;i++){
            ans = max(ans,sum-abs(A[i])*2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3944
#include<stdio.h>
#include<math.h>
#define PI 3.14159265359
#define CONVERT(x) (x*180/PI)
int main()
{
	double a,b,x;
	scanf("%lf%lf%lf",&a,&b,&x);
	if(x>a*b*a/2.0)
	{
	  	x=a*b*a-x;
		double h=2.0*x/pow(a,2);	
		double y = atan(a/h);
		printf("%.10lf\n",90.0-CONVERT(y));
		return 0;
	}
	if(x==a*a*b/2.0)
	{
		printf("45.0000000000"); return 0;
	}
	if(x<a*a*b/2.0)
	{
		double h=2.0*x/(a*b);
		double y = atan(h/b);
		printf("%.10lf\n",90.0-CONVERT(y));
		return 0;
	}
	 
 } 

Measured memory_bytes: 128
def SelectionSort(A):
    n = len(A)
    ans = 0
    for i in range(n-1):
        mini = i
        for j in range(i+1, n):
            if A[j] < A[mini]:
                mini = j
        if i != mini:
            A[i], A[mini] = A[mini], A[i]
            ans += 1
    print(' '.join([str(i) for i in A]))
    print(ans)

_ = input()
SelectionSort([int(i) for i in input().split()])


Measured memory_bytes: 5608
#include <iostream>
#include <array>
#include <algorithm>

int main(int argc, char const* argv[])
{
    int a, b, c;
    auto ary = std::array<int, 3>();
    for(auto &v: ary)
    {
        std::cin >> v;
    }
    std::sort(ary.begin(), ary.end());

    int l = ary[2];
    int m = ary[1];
    int s = ary[0];

    int d1 = l - m;
    int d2 = s + d1;
    int result = d1;
    if((l - d2) % 2 == 0)
    {
        result += (l - d2) / 2;
    }
    else
    {
        result += ((l + 1 - d2) / 2) + 1;
    }
    std::cout << result << std::endl;
}

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



Measured memory_bytes: 1932
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int Y = sc.nextInt();

		if(Y % 2 != 0) {
			System.out.println("No");
			return;
		}

		int t = 2*X - Y/2;
		int k = -X + Y/2;

		if(t >= 0 && k >= 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35756
import sys
input = sys.stdin.readline
from collections import *

MOD = 10**9+7

class Comb:
    def __init__(self, N):
        self.fac = [1] * (N+1)
        for i in range(2, N+1): self.fac[i] = self.fac[i-1] * i % MOD

    def pow(self, a, b):
        res = 1
        while b:
            if b & 1: res = res * a % MOD
            a = a**2 % MOD
            b >>= 1
        return res

    def comb(self, n, r):
        if r < 0 or r > n: return 0
        return (self.fac[n] * self.pow(self.fac[r], MOD-2)) % MOD * self.pow(self.fac[n-r], MOD-2) % MOD

    def permutation(self, n, r):
        return self.fac[n] * self.pow(self.fac[n-r], MOD-2) % MOD
      
def main():
    N, K = list(map(int, input().split()))
    g = [0] * (N+1)
    
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        g[a] += 1
        g[b] += 1
    
    comb = Comb(K)

    ans = K * comb.permutation(K-1, g[1]) % MOD
    K -= 2
    for i in range(2, N+1):
        if K < g[i]-1: ans = 0; break

        ans = ans * comb.permutation(K, g[i]-1) % MOD

    print(ans%MOD)
if __name__ == '__main__':
    main()



Measured memory_bytes: 8172