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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  while(cin >> n >> k && n && k){
    vary(ll,s,k,0);
    rep(i,k){
      cin >> s[i];
    }
    ll b;
    bool f = true;
    rep(i,n){
      rep(j,k){
        cin >> b;
        s[j] -= b;
        if(s[j] < 0) f = false;
      }
    }
    if(f) cout << "Yes"<<endl;
    else cout << "No"<<endl;
  }
  return 0;
}

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

int main(){
  	int N;
  	int a[210];
  	int res=0;
  	cin>>N;
  		for(int l=0; l<N;l++){
  			cin>>a[l];
        	}
  		while(true){
          	bool flag = false; 
      			for(int i=0; i<N;i++){
  					if (a[i]%2 != 0){
            			flag=true;
                      	}
            		}
          		if (flag){
                      	break;
                    	}
          		for(int j=0; j<N;j++){
  					a[j]/=2;
            		}
          	++res;
        	}
  	cout<<res<<endl;
	}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import bisect

h, n = map(int, list(input().split()))

ab = []
max_a = 0
for _ in range(n):
    ab.append(list(map(int, list(input().split()))))
    max_a = max(max_a, ab[-1][0])

dp = [int(1e9)] * int(1e6)
checked = [False] * int(1e6)
dp[0] = 0

sorted_list = [0]
while len(sorted_list) > 0:
    v = sorted_list.pop(0)
    
    if v > h:
        break
    
    for i in range(n):
        if checked[v + ab[i][0]] == False:
            bisect.insort_right(sorted_list, v + ab[i][0])
            checked[v + ab[i][0]] = True
        dp[v + ab[i][0]] = min(dp[v + ab[i][0]], dp[v] + ab[i][1])
    
print(min(dp[v-1:]))


Measured memory_bytes: 66780
/*
 *  *s.rbegin()=*(--s.end())
 *   sort(v.rbegin(),v.rend()) = negative of v[i] , sort(v.begin(),v.end())
 *   sort(v.begin()+l_index,v.begin()+r_index+1);
 * 
 *   for(auto &it:v)cin>>it; 
 *   n + n/2 + n/3 + n/4 + n/5 + ........n/n =>n*log(n)
 *   n + n/3 + n/5 + n/7 + n/11+.............=>n*log(log(n))
 *   1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 .......=>gcd( a[i] , a[i+1] , a[i+2] )=1;
 *   2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 ......=>upto 1e6 max diff a[i], a[i+1] ~ 150
 *   Every even integer greater than 2 can be expressed as the sum of two primes.[1]  : https://en.wikipedia.org/wiki/Goldbach%27s_conjecture
 *   printf("%03d\n",k);
 *   scanf("%d/%d/%d",&d,&m,&y);   
 */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
vector<int>dx={0,1,0,-1},dy={1,0,-1,0};
long long  gcd(long long  a,long long b)
{
     while (a&&b)a>b?a%=b:b%=a;
     return a+b;
}
const int N=1e6;
int n,m,ans=1e18+100,k;
int d_sum(int num)
{
	int s=0;
	while(num)
	{
		s+=num%10;num/=10;
	}
	return s;
}
int is_possible(int mid)
{ 
	int d=d_sum(mid);
	if( mid*mid + d*mid == n )return 0;
	else if( mid*mid + d*mid > n)return 1;
	else return -1;
}
void b_search(int l,int r)
{
	if(l<=r)
	{
		int mid=(l+r)/2;
		int s=is_possible(mid);
		if(s==0)
		{
			ans=min(ans,mid);r=mid-1;
		}
		else if(s>0)r=mid-1;
		else if(s<0)l=mid+1;
		b_search(l,r);
	}
}
int32_t main()
{
	IOS
	string S;cin>>S;
	string s1=S.substr(0,2);
	string s2=S.substr(2,2);
	stringstream ss1(s1),ss2(s2);
	int f,s;ss1>>f;ss2>>s;
	string ans;
	if( f>=1 && s>=1 && f<=12 && s<=12)
	{
		ans="AMBIGUOUS";
	}
	else if(f<=12 && f>=1)
	{
		ans="MMYY";
		
	}
	else if( s<=12 && s>=1)
	{ ans="YYMM";
	}
	else ans="NA";
	cout<<ans<<endl;
}
		


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <tuple>
#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

ll N, Ans;

int main() {
	scanf("%lld", &N);
	Ans = N/11; N -= Ans * 11; Ans *= 2;
	if(N <= 0) { printf("%lld\n", Ans); return 0; }
	N -= 6; Ans++;
	if(N <= 0) { printf("%lld\n", Ans); return 0; }
	N -= 5; Ans++;
	printf("%lld\n", Ans);
	return 0;
}

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

string s;

bool solve();

int main() {
  while(1) {
    cin >> s;
    if(s == "#") break;
    if(solve())
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

bool solve() {
  long long ssize = s.size();
  for(int i = 0; i < ssize; ++i) {
    vector<bool> large[2], small[2];
    for(int i = 0; i < 2; ++i) {
      large[i].assign(26, 0);
      small[i].assign(26, 0);
    }
    assert(s[i] == '(');
    ++i;
    for(int j = 0; j < 3; ++j) {
      bool ch = 0;
      if(s[i] == '~') ch = 1, ++i;
      if(s[i] >= 'a' && s[i] <= 'z')
        small[ch][s[i++] - 'a'] = 1;
      else
        large[ch][s[i++] - 'A'] = 1;
      if(j != 2)
        assert(s[i] == '&');
      else
        assert(s[i] == ')');
      ++i;
    }
    bool isok = 1;
    for(int j = 0; j < 26; ++j) {
      if(small[0][j] && small[1][j]) isok = 0;
      if(large[0][j] && large[1][j]) isok = 0;
    }
    if(isok) return 1;
  }
  return 0;
}


Measured memory_bytes: 3172
#define DEBUG 0

/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-25 21:03:10
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int L[100010];
int R[100010];
int imos[100010];

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    cin >> L[i] >> R[i];
  }
  fill(imos, imos + N + 1, 0);
  for (auto i = 0; i < M; i++)
  {
    imos[L[i]]++;
    imos[R[i] + 1]--;
  }
  for (auto i = 1; i <= N; i++)
  {
    imos[i] += imos[i - 1];
  }
  int ans = 0;
  for (auto i = 1; i <= N; i++)
  {
    if (imos[i] == M)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	if (N == M)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
    char c[6];
    int cnt = 0;
    gets(c);
    for(int i=0; c[i]!='\0'; i++)
    {
        if(c[2]==c[3] && c[4]==c[5])
        {
            cnt++;
        }
    }
    if(cnt!=0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#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>;

int main(){
  int n;
  cin >> n;
  map<int,int> ans;
  int a;
  rep(i,n)
    ans[i] = 0;
  rep(i,n-1){
    cin >> a;
    ans[a-1]++;
  }
  rep(i,n){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 13008
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        if(!(cin >> n))
            return 0;

        cout << (n*(n+1)/2+1) << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef long long ll;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	ll ns[3];
	rep(3, i) cin >> ns[i];
	sort(ns, ns+3);
	int f = 0;
	rep(3, i) {
		if (ns[i] & 1) {
			continue;
		}
		f = 1;
	}
	cout << (f?0:ns[0]*ns[1]) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
X, Y = [], []
for n in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

l_s = 0

for i in range(N):
    for j in range(N):
        l_s += (((X[i]-X[j])**2) + ((Y[i]-Y[j])**2)) **(0.5)
ans = l_s / N
print(ans)

Measured memory_bytes: 3064
/********************************
	Author: xsl
	Date: 2019/10/15
	Language: C++
	Description: permutation
********************************/
#include <bits/stdc++.h>
#define FILE(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int maxn = 500003;

int n, m, k, a[maxn], p[maxn], q[maxn];
int tot, head[maxn], ver[maxn * 2], nxt[maxn * 2];
int in[maxn], tr[maxn * 4];

inline void add(int u, int v)
{
	ver[++tot] = v, nxt[tot] = head[u], head[u] = tot, ++in[v];
}

inline int ls(int p) {return p << 1;}
inline int rs(int p) {return p << 1 | 1;} 

int getans(int ql, int qr, int l, int r, int p)
{
	if (ql == l && r == qr) return tr[p];
	int mid = (ql + qr) >> 1;
//	cout << l << ' ' << r << ' ' << ql << ' ' << qr << ' ' << p << endl;
	if (r <= mid) return getans(ql, mid, l, r, ls(p));
	else if (l > mid) return getans(mid + 1, qr, l, r, rs(p));
	else return min(getans(ql, mid, l, mid, ls(p)), getans(mid + 1, qr, mid + 1, r, rs(p)));
}

void modify(int x, int z, int l, int r, int p)
{
	if (l == r) {tr[p] = z; return;}
	int mid = (l + r) >> 1;
//	cout << l << ' ' << r << ' ' << p << endl;
	if (mid >= x) modify(x, z, l, mid, ls(p));
	else modify(x, z, mid + 1, r, rs(p));
	tr[p] = min(tr[ls(p)], tr[rs(p)]);
}

void build(int l, int r, int p)
{
	tr[p] = n + 1;
	if (l == r) return;
	int mid = (l + r) >> 1;
	build(l, mid, ls(p));
	build(mid + 1, r, rs(p));
}

inline void solve()
{
	build(1, n, 1);
//	puts(":::");
	for (int i = n; i >= 1; i-=1)
	{
		int x;
		x = getans(1, n, max(1, q[i] - k + 1), q[i], 1);
		if (x <= n) add(q[i], q[x]);
		x = getans(1, n, q[i], min(n, q[i] + k - 1), 1);
		if (x <= n) add(q[i], q[x]);
		modify(q[i], i, 1, n, 1);
	}
	set <int> qq;
	for (int i = 1; i <= n; i+=1) 
	{
		if (!in[i]) qq.insert(i);
	}
	for (int i = 1; i <= n; i+=1) 
	{
		int x = q[i] = *qq.begin(); qq.erase(qq.begin());
//		cout << x << endl;
		for (int j = head[x]; j; j = nxt[j])
		{
			int v = ver[j];
			if (!(--in[v])) qq.insert(v);
		}
	}
//	puts("");
	for (int i = 1; i <= n; i+=1) p[q[i]] = i;
	for (int i = 1; i <= n; i+=1) printf("%d\n", p[i]);
}

int main()
{
	n = gi(), k = gi();
	for (int i = 1; i <= n; i+=1)
	{
		p[i] = gi();
		q[p[i]] = i;
	}
	solve();
	return 0;
}

Measured memory_bytes: 39296
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {+0,+1,+1,+1,+0,-1,-1};
static const int ty[] = {-1,+1,+0,-1,+1,-1,+0};

class Point {
public:
  double x;
  double y;
  Point() : x(0), y(0) {}
  Point(double _x,double _y) : x(_x), y(_y) {}
};


class UnionFindTree {
private:
  int* par;
  int* rank;
  int* weight;
public:
  UnionFindTree(int n){
    par = new int[n]();
    rank = new int[n]();
    weight = new int[n]();
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 0;
      weight[i] = 1;
    }
  }

  ~UnionFindTree(){
    delete[] rank;
    delete[] par;
    delete[] weight;
  }

  int find(int x){
    if(par[x] == x){
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      weight[y] += weight[x];
    } else {
      par[y] = x;
      weight[x] += weight[y];
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  int count(int x){
    return weight[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int main(){
  int total_homes;
  double R;
  vector<Point> homes;

  while(~scanf("%d %lf",&total_homes,&R)){
    map<P,int> cell;
    map<P,int> cell_idx;
    int idx = 0;

    for(int home_idx = 0; home_idx < total_homes; home_idx++){
      double x,y;
      scanf("%lf %lf",&x,&y);
      homes.push_back(Point(x,y));
      int cell_x = (int)(x / R);
      int cell_y = (int)(y / R);
      cell[P(cell_x,cell_y)]++;
      if(cell_idx.find(P(cell_x,cell_y)) == cell_idx.end()){
	cell_idx[P(cell_x,cell_y)] = idx++;
      }
    }

    int total_cells = idx;
    UnionFindTree uft(total_cells);
    
    for(map<P,int>::iterator it = cell.begin();
	it != cell.end();
	it++){
      for(int i=0;i<8;i++){
	int sx = it->first.first;
	int sy = it->first.second;

	int dx = sx + tx[i];
	int dy = sy + ty[i];
	if(cell.find(P(dx,dy)) != cell.end()){
	  int from = cell_idx[P(sx,sy)];
	  int to = cell_idx[P(dx,dy)];
	  uft.unite(from,to);
	}
      }
    }

    bool visited[200001];
    memset(visited,false,sizeof(visited));
    int res = 0;
    for(int i=0;i<total_cells;i++){
      if(!visited[uft.find(i)]){
	visited[uft.find(i)] = true;
	res++;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 29388
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	long long int N, K;
	cin >> N >> K;
	int kmax = (N-2)*(N-1)/2;
	if(kmax < K) {
		cout << -1;
		return 0;
	}

	// 最大で引く本数（K=0）
	long long int mMax = (N-1)*N/2;
	// 実際に引く本数
	long long int m = mMax - K;
	cout << m << endl;
	int i = 1;
	int j = 2;
	while(0 < m) {
		cout << i << " " << j << endl;
		j++;
		if(N < j) {
			i++;
			j = i+1;
		}
		m--;
	}

	return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	int cnt = 0;
	int min;
	cin >> N;

	rep(i, N)
	{
		int n;
		cin >> n;

		if (i == 0)
		{
			min = n;
		}

		if (n <= min)
		{
			min = n;
			cnt++;
		}
	}

	cout << cnt;
	return 0;
}

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

ll gcd(ll a, ll b) {
  if (a%b == 0) {
    return(b);
  } else {
    return(gcd(b, a%b));
  }
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll div_ceil(ll a, ll b) {
  if (a % b == 0) return a/b;
  return a/b + 1;
}

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll k = lcm(c,d);
  ll n = 0;
  n += b/c - div_ceil(a,c);
  n += b/d - div_ceil(a,d);
  n -= b/k - div_ceil(a,k);
  ll ans = b - a - n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        HashSet<String> set = new HashSet<>();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1; i < n; i++) {
            String x = s.substring(0, i);
            String y = s.substring(i);
            set.clear();
            for (int j = 0; j < x.length(); j++) {
                String tmp = x.substring(j, j + 1);
                if(y.contains(tmp)) {
                    set.add(tmp);
                }
            }
            list.add(set.size());
        }
        System.out.println(Collections.max(list));
    }
}

Measured memory_bytes: 36932
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<vector<int>> G(n, vector<int>(n));
   rep(i, 0, n) {
      int u, k;
      cin >> u >> k;
      u--;
      rep(j, 0, k) {
         int v;
         cin >> v;
         v--;
         G[u][v] = 1;
      }
   }
   rep(i, 0, n) rep(j, 0, n) printf("%d%c", G[i][j], j == n - 1 ? '\n' : ' ');
   return 0;
}


Measured memory_bytes: 3296
INF = 1001001001

N, M, L = map(int, input().split())

fuel = [[INF] * N for _ in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    fuel[A][B] = C
    fuel[B][A] = C
for i in range(N):
    fuel[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            fuel[i][j] = min(fuel[i][j], fuel[i][k] + fuel[k][j])

dist = [[INF] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            dist[i][j] = 0
        elif fuel[i][j] <= L:
            dist[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    if dist[s][t] == INF:
        print(-1)
    else:
        print(dist[s][t] - 1)


Measured memory_bytes: 60120
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;cin>>n;
    vector<int>p(n);
    for(int &i:p)cin>>i;
    sort(p.begin(),p.end());
    int res=0;
    for(int i=0;i<n-1;i++)res+=p.at(i);
    cout<<p.at(n-1)/2+res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	int a, b, c, d, e = 0;
	cin >> a >> b >> c;
	
		for (int d = a; d <= b; d = d + 1) {
			if (c % d == 0) {
				e = e + 1;
			} 
		} cout << e << endl;
	
	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {

    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();

        // first way

        long ans = 0;

        if(x >= 0) {
            if(x <= y) {
                ans = y - x;
            } else if(x <= Math.abs(y)) {
                ans = 1 + Math.abs(y) - x;
            } else {
                if(y > 0) {
                    ans = 2 + x - y;
                }else {
                    ans = 1 + x + y;
                }
            }
        }
        else {
            if(x == y) {
                ans = 0;
            }
            else if(x < y) {
                if(Math.abs(x) <= y) {
                    ans = 1 + y - Math.abs(x);
                } else {
                    if(y > 0) {
                        ans = Math.abs(x) - y + 1;
                    } else {
                        ans = y - x;
                    }
                }
            } else {
                ans = 2 + x - y;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 10188
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
class Main {
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = stdin.readLine()) != null) {
            Integer value = Integer.valueOf(line);
            if (value>=30) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }

    } catch(Exception e) {
    }
   
  }
}

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

int main(){
    int n;

    cin>>n;
  int x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        y[i] = x[i];
    }

    sort(y, y+n);

    int median_left = y[n/2-1];
    int median_right = y[n/2];
    
    for(int i=0;i<n;i++){
        if(x[i]<=median_left){
            cout << median_right << endl;
        }
        else{
            cout << median_left << endl;
        }
    }
}


Measured memory_bytes: 3712
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=SENTINEL;
	R[n2]=SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}
		else{
			A[k]=R[j++];
		}
	}
}

void mergeSort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(void){
	int A[MAX],n,i;
	cnt=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	mergeSort(A,n,0,n);
	
	for(i=0;i<n;i++){
		if(i){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",cnt);
	
	return 0;
}


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

int main() {
int arr[5], k;

for (int i=0; i<5; i++) {
  cin >> arr[i];
}
cin >> k;

sort(arr, arr+5);

if (arr[4]-arr[0]>k) cout << ":(";
else cout << "Yay!";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
int dp[3002][3002] = {0};
string ans = "";
string s, t;
void func(int len1, int len2) {
    if(!len1 || !len2) {
        return;
    }
    if(s[len1 - 1] == t[len2 - 1]) {
        ans += s[len1 - 1];
        func(len1 - 1, len2 - 1);
    }
    else {
        if(dp[len1][len2 - 1] > dp[len1 - 1][len2]) {
            func(len1, len2 - 1);
        }
        else {
            func(len1 - 1, len2);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n, i, j, len1, len2;
    cin >> s >> t;
    len1 = s.size();
    len2 = t.size();
    for(i = 0; i <= 3000; i++) {
        dp[i][0] = 0;
        dp[0][i] = 0;
    }
    for(i = 1; i <= len1; i++) {
        for(j = 1; j <= len2; j++) {
            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    func(len1, len2);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    bool h1=false;
    rep(i,n){
      if(h1)cout<<' ';
      h1=true;
      cout<<in[i];
      bool h=false;
      if(i+1<n)while(in[i]+1==in[i+1]){i++;h=true;if(i==n-1)break;}
      if(h)cout<<'-'<<in[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=998244353;

int N;
int K;
LL pw2[4145];
LL ans[4145];
LL memo[4145][4145];

LL Comb(LL n, LL k) {
  if (n == k || k == 0) return 1;
  if (n <= 0) return 0;
  if (k < 0 || n < k) return 0;
  if (memo[n][k] >= 0) return memo[n][k];
  
  memo[n][k] = Comb(n-1, k) + Comb(n-1, k-1);
  if (memo[n][k] >= MOD) memo[n][k] -= MOD;
  return memo[n][k];
}

int main() {
  fill(memo[0], memo[4145], -1);
  scanf("%d%d", &K, &N);

  pw2[0] = 1;
  reps(i, 1, 2*K+10) {
    pw2[i] = pw2[i-1]*2 % MOD;
  }

  for (int d=3; d<=K+1; d+=2) {
    int lim = d/2;
    rep(t, lim+1) {
      ans[d] += Comb(lim, t) * pw2[t] % MOD * Comb(N+K-lim-lim-1, K-lim-lim+t-1);
      ans[d] %= MOD;
    }
    ans[2*K+2-d] = ans[d];
  }

  for (int d=2; d<=K+1; d+=2) {
    int lim = d/2-1;
    rep(t, lim+1) {
      ans[d] += Comb(lim, t) * pw2[t] % MOD * Comb(N+K-lim-lim-2, K-lim-lim-2+t);
      ans[d] += Comb(lim, t) * pw2[t] % MOD * Comb(N+K-lim-lim-3, K-lim-lim-2+t);
      ans[d] %= MOD;
    }
    ans[2*K+2-d] = ans[d];
  }

  reps(d, 2, K*2+1) {
    printf("%lld\n", ans[d]);
  }
}



Measured memory_bytes: 134784
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<P> red, blue;
    for(int i = 0; i < n; i++)
    {
        int a, b; cin >> a >> b;
        red.push_back(P(a, b));
    }
    for(int i = 0; i < n; i++)
    {
        int a, b; cin >> a >> b;
        blue.push_back(P(a, b));
    }
    sort(blue.begin(), blue.end());
    bool used[n + 1] = {};
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int pos = -1, tmp = -INF;
        for(int j = 0; j < n; j++)
        {
            if(used[j]) continue;
            if(red[j].first < blue[i].first && red[j].second < blue[i].second && red[j].second > tmp)
            {
                tmp = red[j].second;
                pos = j;
            }
        }
        if(pos != -1)
        {
            used[pos] = true;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long

signed main()
{
    rootdada;

// fac[0] = 1;
// inv[0] = 1;
// for (int i = 1; i < N; i++)
// {
//     fac[i] = fac[i - 1] * i;
//     fac[i] %= M;
//     inv[i] = power(fac[i], M - 2);
// }

    int n, a, b;
    cin >> n >> a >> b;
    int l = a + b;
    // if (a == 0)
    //     cout << 0 << endl;
    // else
    {
        cout << ((n / l) * a) + min(n % l, a) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    private static Scanner sc=new Scanner(System.in);
    private static int n=sc.nextInt();
    private static int[] a=new int[n+1];
    public static void main(String[] args){
        int[] count=new int[n];
        for(int i=1;i<=n;i++){
            a[i]=sc.nextInt();
            count[a[i]]++;   
        }
        boolean possible=true;
        int ans=0;
if(n%2==1){
            if(count[0]!=1) possible=false;
            for(int i=1;i<=(n-1)/2;i++){
                if(count[2*i]!=2) possible=false;
            }
            if(possible){
                ans=1;
                for(int i=0;i<(n-1)/2;i++){
                    ans=(ans*2)%1000000007;
                }
            }
        }else{
           for(int i=0;i<n/2;i++){
               if(count[2*i+1]!=2) possible=false;
           }
           if(possible){
               ans=1;
               for(int i=0;i<n/2;i++){
                   ans=(ans*2)%1000000007;
               }
           }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 51148
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ll t,t1,c,i,j,k,l,a,n,d;
		cin>>n>>t;
		k=0;
		for(i=0;i<n;i++)
		{
			cin>>c>>t1;
			if(t1<=t)
			{
				if(k==0)
					k=c;
				else
				{
					if(c<k)
						k=c;
				}
			}
		}
		if(k!=0)
			cout<<k<<"\n";
		else
			cout<<"TLE";
		return 0;
}
	

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {0, 0, 1, -1};
    int dx[] = {1, -1, 0, 0};

    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<vector<bool> > grid(h+2, vector<bool>(w+2, false));
        int sy, sx, gy, gx, cy, cx;
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                int a;
                cin >> a;
                if(a != 1)
                    grid[i][j] = true;
                if(a == 2){
                    cy = i;
                    cx = j;
                }else if(a == 3){
                    gy = i;
                    gx = j;
                }else if(a == 4){
                    sy = i;
                    sx = j;
                }
            }
        }

        int ret = -1;
        vector<vector<vector<vector<bool> > > > check(h+2, vector<vector<vector<bool> > >(w+2, vector<vector<bool> >(h+2, vector<bool>(w+2, false))));
        multimap<int, pair<pair<int, int>, pair<int, int> > > mm;
        check[sy][sx][cy][cx] = true;
        mm.insert(make_pair(0, make_pair(make_pair(sy, sx), make_pair(cy, cx))));
        while(!mm.empty()){
            int cost1 = mm.begin()->first;
            int y1 = mm.begin()->second.first.first;
            int x1 = mm.begin()->second.first.second;
            int y2 = mm.begin()->second.second.first;
            int x2 = mm.begin()->second.second.second;
            mm.erase(mm.begin());
            if(y2 == gy && x2 == gx){
                ret = cost1;
                break;
            }

            for(int i=0; i<4; ++i){
                int y3 = y1 + dy[i];
                int x3 = x1 + dx[i];
                int y4 = y2;
                int x4 = x2;
                int cost2 = cost1;
                if(y3 == y4 && x3 == x4){
                    y4 += dy[i];
                    x4 += dx[i];
                    ++ cost2;
                }
                if(!grid[y3][x3] || !grid[y4][x4])
                    continue;
                if(check[y3][x3][y4][x4])
                    continue;
                check[y3][x3][y4][x4] = true;
                mm.insert(make_pair(cost2, make_pair(make_pair(y3, x3), make_pair(y4, x4))));
            }
        }

        cout << ret << endl;
    }
}

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

int main() {
    auto Solve = [&](int n, int k) {
        while (n % k != 0) {
            int pv = n / k * k;
            int g = max(1, (n - pv) / (n / k + 1));
            n -= g * (n / k + 1);
        }
        return n / k;
    };

    int n; scanf("%d", &n);
    int sg = 0;
    for (int i = 0; i < n; ++i) {
        int a, k; scanf("%d%d", &a, &k);
        sg ^= Solve(a, k);
    }
    if (sg == 0) puts("Aoki");
    else puts("Takahashi");
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab = [[int(i) for i in input().split()]for j in range(m)]

graph = [[] for i in range(n+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

ans = 0

for i in ab:
    start = i[0]
    last = i[1]
    
    que = [start]
    visit = [False]*(n+1)
    visit[start]=True
    while que:
        q = que.pop()
        for j in graph[q]:
            if q == start and j== last:
                continue
            if j==last:
                break
            if  not visit[j]:
                que.append(j)
                visit[j] = True
        else:
            continue
        break
    else:
        ans+=1
print(ans)

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

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	if(str.charAt(2) == str.charAt(3))
		if(str.charAt(4) == str.charAt(5)) {
			System.out.println("Yes");
          return;
		}
   
    System.out.println("No");
       }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    char A;
    cin >> A;
    if ( 65 <= A && A <=90){
        cout << "A" << endl;
    }else {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
#include <string.h>
int main(void){
char str[1000];
int i,l;
 
fgets(str,1000,stdin);
l=strlen(str);
for(i=0;i<l;i++){
if(str[i]=='p' && str[i+1]=='e'&&str[i+2]=='a'&&str[i+3]=='c'&&str[i+4]=='h'){
str[i]='a';
str[i+1]='p';
str[i+2]='p';
str[i+3]='l';
str[i+4]='e';
i=i+4;
}else if(str[i]=='a' && str[i+1]=='p'&&str[i+2]=='p'&&str[i+3]=='l'&&str[i+4]=='e'){
str[i]='p';
str[i+1]='e';
str[i+2]='a';
str[i+3]='c';
str[i+4]='h';
i=i+4;
}
     
}
printf("%s",str);
return 0;
}

Measured memory_bytes: 2652
#include <stdio.h>

int h, w; char g[2001][2001]; int mem[4][2001][2001] = {};

int tu(int i, int j){
  if(mem[0][i][j] != 0) return mem[0][i][j];
  else{
  if(i == 0) return 0;
  else if(g[i - 1][j] == '#') return 0;
  else return (mem[0][i][j] = tu(i - 1, j) + 1);
  }
}

int td(int i, int j){
  if(mem[1][i][j] != 0) return mem[1][i][j];
  else{
  if(i == h - 1) return 0;
  else if(g[i + 1][j] == '#') return 0;
  else return (mem[1][i][j] = td(i + 1, j) + 1);
  }
}

int yr(int i, int j){
  if(mem[2][i][j] != 0) return mem[2][i][j];
  else{
  if(j == w - 1 || g[i][j + 1] == '#') return 0;
  else return (mem[2][i][j] = yr(i, j + 1) + 1);
  }
}

int yl(int i, int j){
  if(mem[3][i][j] != 0) return mem[3][i][j];
  else{
  if(j == 0 || g[i][j - 1] == '#') return 0;
  else return (mem[3][i][j] = yl(i, j - 1) + 1);
  }
}



int
main(int argc, char *argv[])
{
  scanf("%d %d", &h, &w);
  for(int i = 0; i < h; i++){
    scanf("%s", g[i]);
  }



 int max = 0; int q;

 for(int i = 0; i < h; i++){
   for(int j = 0; j < w; j++){
     if(g[i][j] != '#'){
       q = yl(i, j) + yr(i, j) + tu(i, j) + td(i, j) + 1;
       max = max > q ? max : q;
     }
   }
 }

 printf("%d\n", max);
  
 

  return 0;
}

				   
    


Measured memory_bytes: 66688
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
    int r, c;
    cin >> r >> c;
    int a[r+1][c+1];
    for(int i=0; i<r; ++i) a[i][c]=0;    
    for(int i=0; i<=c; ++i) a[r][i]=0;    
    for(int i=0; i<r; ++i) {
        for(int j=0; j<c; ++j) {
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
    }
    for(int i=0; i<r+1; ++i) {
        for(int j=0; j<c; ++j) {
            cout << a[i][j] << " ";
        }
        cout << a[i][c] << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>

int main(void)
{
	int i,j=0;

	while(1){
		scanf("%d" , &i);
		if(i == 0){
			break;
		}		
		j++;
		printf("Case %d: %d\r\n", j, i );
	}

	 return 0;	 
}

Measured memory_bytes: 600
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut v = std::collections::VecDeque::new();

    for i in 0..n {
        if (i & 1) == 0 {
            v.push_back(a[i]);
        } else {
            v.push_front(a[i]);
        }
    }
    if (n & 1) == 0 {
        for i in 0..n {
            print!("{} ", v[i]);
        }
    } else {
        for i in 0..n {
            print!("{} ", v[n - i - 1]);
        }
    }
}


Measured memory_bytes: 10364
N, Q = map(int, input().split())
S = input()
ls = list()
rs = list()
for _ in range(Q):
    l, r = map(int, input().split())
    ls.append(l)
    rs.append(r)

cumsum = [0]

for i in range(1,N):
    if S[i-1:i+1] == "AC":
        cumsum.append(cumsum[i-1] + 1)
    else:
        cumsum.append(cumsum[i-1])

for l, r in zip(ls, rs):
    print(cumsum[r-1] - cumsum[l-1])



Measured memory_bytes: 14212
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] c = S.toCharArray();
        for(int i = 0; i < S.length(); i++){
            int x = c[i] - 'A';
            x = (x + N) % 26;
            System.out.print((char)('A' + x));
        }
 }
}

Measured memory_bytes: 24912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args)
    {
        CP sc =new CP();
        int D = sc.nextInt(), T = sc.nextInt(), S = sc.nextInt();
        if(S==0)
            System.out.println("No");
        else if(T>=(1.0*D/S))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
    /*****************************************************************************/
    static class CP
    {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;
        public CP() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }
        int nextInt() {
            return Integer.parseInt(NNNN());
        }
        long nextLong() {
            return Long.parseLong(NNNN());
        }
        double nextDouble() {
            return Double.parseDouble(NNNN());
        }
        String NNNN() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }
        String nextLine() {
            String spl = "";
            try {
                spl = bufferedReader.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return spl;
        }
    }
    /*****************************************************************************/
}

Measured memory_bytes: 32716
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_135
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Pi = Slist();
            var Pis = new int[N];
            Pi.CopyTo(Pis, 0);
            Array.Sort(Pis);
            var cnt = 0;
            for (var i = 0; i < N; ++i)
            {
                if (Pi[i] != Pis[i])
                    ++cnt;
            }
            if (cnt == 2 || cnt == 0)
            { WriteLine("YES"); }
            else
            { WriteLine("NO"); }
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>

int main()
{
  int A[100], N, i, sw;

  scanf("%d",&N);
  for(i = 0 ; i < N ; i++)
    {
      scanf("%d",&A[i]);
    }
  
  sw = selectionSort(A,N);

  for(i = 0 ; i < N ; i++)
    {
      if(i > 0)
	{
	  printf(" ");
	}
      printf("%d",A[i]);
    }

  printf("\n");
  printf("%d\n",sw);

  return 0;
}

int selectionSort(int A[], int N)
{
  int i, j, temp, sw = 0, minj;

  for(i = 0 ; i < N - 1 ; i++)
    {
      minj = i;
      
      for(j = i ; j < N ; j++)
	{
	  if(A[j] < A[minj])
	    {
	      minj = j;
	    }
	}
      
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;

      if(i != minj)
	{
	  sw++;
	}
    }
  return sw;
}

Measured memory_bytes: 604