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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int ans = 0;
  vector<int> A(N);
  int x_array[N][N];
  REP(i, N){
    REP(j, N){
      x_array[i][j] = 2;
    }
  }
  int y_array[N][N];
  REP(i, N){
    REP(j, N){
      y_array[i][j] = 2;
    }
  }

  REP(i, N){
    int a_val;
    cin >> a_val;
    A[i] = a_val;
    REP(j, a_val){
      cin >> x_array[i][j];
      cin >> y_array[i][j];
      x_array[i][j]--;
    }
  }
  REP(bit, 1<<N){
    bool exist = true;
    REP(i, N){
      if (bit & (1<<i)){
        REP(j, A[i]){
          int someone = x_array[i][j];
          int flag = y_array[i][j];
          if (flag == 0 and bit & (1<<someone)){exist = false;}
          else if(flag == 1 and !(bit & (1<<someone))){exist = false;}
        }
      }

    }
    if(exist) ans = max(ans, __builtin_popcount(bit));
  }


  cout << ans << endl;


 return 0;
}



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

using namespace std;
#define pb push_back
#define ld long double
#define ll unsigned long long
string s, t;
vector<ll>v[150];
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s >> t;
    ll lp = 0, rest = 0, pa = -1;
    for(int i = 0 ; i < s.size(); ++i)
        v[s[i] - 'a'].pb(i);

    for(auto ch : t)
    {
        if(v[ch - 'a'].empty())
        {
            cout << -1;
            return 0;
        }

        auto k = lower_bound(v[ch - 'a'].begin(), v[ch - 'a'].end(), pa + 1);

        if(k == v[ch - 'a'].end())
        {
            rest++;
            pa = v[ch - 'a'][0];
        }
        else pa = *k;

    }
    cout << 1LL * rest * s.size() + pa + 1;
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

    
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll x,y;
    cin >> x >> y;
    if(x % y != 0) print(x);
    else print(-1);

}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
int n,len;
int cnt[30];
char s[100010];
int solve(int l,int r)
{
	if(l==r)
		return s[l]-'a'+1;
	if(r-l+1==5)
	{
		int x=s[l+1]-'a'+1,y=s[r-1]-'a'+1;
		if(!cnt[x]&&!cnt[y])
			return -1;
		if(cnt[x]&&cnt[y])
			return -1;
		if(cnt[x])
		{
			cnt[x]--;
			return x;
		}
		cnt[y]--;
		return y;
	}
	int pos=l+1,id=0;
	if(s[pos]=='[')
		id++;
	while(id)
	{
		pos++;
		if(s[pos]=='[')
			id++;
		if(s[pos]==']')
			id--;
	}
	int x=solve(l+1,pos),y=solve(pos+2,r-1);
	if(x==-1||y==-1)
		return -1;
	if(!cnt[x]&&!cnt[y])
			return -1;
	if(cnt[x]&&cnt[y])
			return -1;
	if(cnt[x])
	{
			cnt[x]--;
			return x;
	}
	cnt[y]--;
	return y;
}
int main()
{
	scanf("%s",&s[1]);
	len=strlen(&s[1]);
	for(int i=1; i<=len; i++)
		if(s[i]>='a'&&s[i]<='z')
			n++;
	for(int i=1; i<=n; i++)
	{
		char ch=getchar();
		while(ch<'a'||ch>'z')
			ch=getchar();
		int num=0;
		scanf("%d",&num);
		cnt[ch-'a'+1]=num;
	}
	if(solve(1,len)==-1)
		puts("No");
	else
	{
		for(int i=1; i<=26; i++)
			if(cnt[i])
			{
				puts("No");
				return 0;		
			}
		puts("Yes");
	}
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int CountHangOut (vector<int> Array, int Days) {
    int ans=Days;
    for (int i=0;i<Array.size();i++) {
        ans -= Array[i];
    }
    if (ans < -1) ans = -1;
    return ans;
}
int main () {
    int N, M, A_item;
    vector<int> A;
    cin >> N>> M;
    for (int i=0;i<M;i++) {
        cin >> A_item;
        A.push_back(A_item);
    }
    cout << CountHangOut(A, N)<< endl;
    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 50;
int N;
string S[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> S[i];

	vector<int> cnt_min(26, 1e5);
	for(int i=0; i<N; i++){
		vector<int> cnt(26, 0);
		for(int j=0; j<S[i].size(); j++){
			cnt[S[i][j]-'a']++;
		}
		for(int k=0; k<26; k++){
			cnt_min[k] = min(cnt_min[k], cnt[k]);
		}
	}

	for(int k=0; k<26; k++){
		for(int i=0; i<cnt_min[k]; i++){
			cout << (char)('a'+k);
		}
	}
	cout << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
 int N; cin >> N;
  vector<pair<ll,ll>> vec;
  for(int i = 0; i < N; i++){
    ll x,y; cin >> x >> y;
    vec.push_back(make_pair(x,y));}
  
  map<pair<ll,ll>,ll> mp;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if( i == j){ continue;}
      else{
        ll dx = vec[j].first - vec[i].first;
        ll dy = vec[j].second - vec[i].second;
        mp[make_pair(dx,dy)]++;}
    }
  }
  ll res = 0;
  for(auto ne: mp){
    res = max( res, ne.second);}
  
  cout << N - res << endl; return 0;}
    
        
        
      

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

int main(){
	vi s; int n;
	read(n),n*=2; s.resize(n);
	REP(i,n) read(s[i]);
	sort(s.begin(),s.end());
	ll ans=0;
	for(int i=0;i<s.size();i+=2) ans+=s[i];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const double EPS = 1e-8;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(p.y, -p.x); } // 時計回りに90度回転 
bool equals(const Point& a, const Point& b) { return abs(a.x - b.x) < EPS && abs(a.y - b.y) < EPS; }
Point unit(const Point& p) { return p / norm(p); }
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }

int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;
    if (cross(b, c) > EPS) return +1;      // a,b,cの順に反時計周り
    if (cross(b, c) < -EPS) return -1;     // a,b,cの順に時計周り
    if (dot(b, c) < 0) return +2;          // c--a--b 直線
    if (norm(b) < norm(c)) return -2;      // a--b--c 直線
    return 0;                              // a--c--b 直線
}

struct Line {
    Point a, b;
    Line() {}
    Line(const Point& a, const Point& b) : a(a), b(b) {}
};
bool contains(const Line& l, const Point& p) { return ccw(l.a, l.b, p) % 2 == 0; }
bool parallel(const Line& s, const Line& t) { return abs(cross(s.b - s.a, t.b - t.a)) < EPS; }
bool equals(const Line& s, const Line& t) { return parallel(s, t) && contains(s, t.a); }
bool orthogonal(const Line& s, const Line& t) { return abs(dot(s.b - s.a, t.b - t.a)) < EPS; }

istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }
istream& operator>>(istream& is, Line& l) { return is >> l.a >> l.b; }

int main() {
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        Line s, t;
        cin >> s >> t;
        if (parallel(s, t)) {
            cout << 2 << endl;
        } else if (orthogonal(s, t)) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
s = input()
a = s[:2]
b = s[2:]
if 0< int(a) <13:
  if 0<int(b)<13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0<int(b)<13:
    print("YYMM")
  else:
    print("NA")

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

int main(){
  ll n;
  int i,sat,d,e;
  cin >> n;
  e=-2;
  ll a[n],b[n],c[n];
  sat =0;
  for(i=1;i<=n;i++)cin >>a[i];
  for(i=1;i<=n;i++)cin >>b[i];
  for(i=1;i<n;i++)cin >>c[i];
  for(i=1;i<=n;i++){
    d=a[i];
    sat=sat+b[d];
    if(d-e==1){
      sat=sat+c[d-1];
    }
    e=d;
  }
  cout << sat;
}

Measured memory_bytes: 256
#
# 1129: Hanafuda Shuffle
#

### constants 

### main

loop do
    n, r = gets.split.map(&:to_i)
    break if (n | r) == 0
    
    cards = (1..n).to_a.reverse
    
    r.times do
        pn, cn = gets.split.map(&:to_i)
        pn -= 1
        cards0 = cards[pn, cn] + cards[0, pn] + cards[(pn + cn)...n]
        cards = cards0
    end
    
    puts cards.first
end

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

int main(){
    int N;
    cin >> N;
    if(N%111 == 0){
        cout << N <<endl;
    }
    else if(N/100*111 > N) {
        cout << N/100*111 <<endl;
    }
    else {
        cout << N/100*111+111 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  int f[n][10];
  for(int i=0; i<n; ++i) for(int j=0; j<10; ++j){
    cin >> f[i][j];
  }
  int p[n][11];
  for(int i=0; i<n; ++i) for(int j=0; j<11; ++j){
    cin >> p[i][j];
  }
  int ans = -INF;
  for(int i=1; i<(1<<10); ++i){
    int score = 0;
    for(int j=0; j<n; ++j){
      int cnt = 0;
      for(int k=0; k<10; ++k){
        if((i>>k & 1) && f[j][k]) ++cnt;
      }
      score += p[j][cnt];
    }
    ans = max(score, ans);
  }
  cout << ans << endl;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, m, i, ans = 0;
	cin >> n >> m;
	priority_queue<ll>pq;
	rep(i,0,n){
		cin >> ans;
		pq.push(ans);
	}
	rep(i,0,m){
		ll k = pq.top();
		pq.pop();
		k /= 2;
		pq.push(k);
	}
	ans = 0;
	while(!pq.empty()){
		ans += pq.top();
		pq.pop();
	}
	cout << ans << nl;
}
int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 4268
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int maxA = a[n-1];
        int totalB = 0;
        int ans = h/maxA;
        ans += h%maxA != 0 ? 1 : 0;
        int cntB = 0;
        for(int i = n-1; i >= 0; i--){
            totalB += b[i];
            cntB++;
            int tmp = Math.max(0,(h-totalB)/maxA);
            tmp += (h-totalB)%maxA != 0 && (h-totalB) > 0 ? 1+cntB : cntB;
            ans = Math.min(ans,tmp);
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 55624
#include <stdio.h>

int main(void){
	int n ,i;
	char s[100], t[100];

	scanf("%d", &n);

	scanf("%s", s);
	scanf("%s", t);
	
	for (i = 0; i < n; i++) {
		printf("%c", s[i]);
		printf("%c", t[i]);
	}

	return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  map<i64, i64> cnt;
  vector<i64> a(N);
  rep(i, N) {
    cin >> a[i];
    cnt[a[i]]++;
  }

  sort(all(a));
  a.erase(unique(all(a)), a.end());

  i64 res = 0;
  for (auto e : a) {
    if (cnt[e] < e) res += cnt[e];
    else if (cnt[e] > e) res += (cnt[e] - e);
  }

  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  cout << n*n*n;
 return 0;
}

Measured memory_bytes: 256
#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;
}
bool kaibun(string S) {
  int n = S.length();
  REP(i, 0, S.length()/2+1) {
    if (S[i] != S[n - i - 1]) {
      return false;
    }
  }
  return true;
}

int main() {
  string S;
  cin>>S;
  int n = S.length();
  string s2 = S.substr(0, n/2);
  string s3 = S.substr(n/2+1, n/2);
  DUMP(S,s2,s3);
  Yes(kaibun(S)&&kaibun(s2)&&kaibun(s3));

  return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [list(input()) for i in range(N)]
B = []
wa = set(A[0])
for a in A:
    a.sort()
    # B.append(a)
    wa = set(a) & wa
# print(wa)
dic = defaultdict(int)
for k in wa:
    dic[k] = INF
for k in wa:
    for a in A:
        a.count(k)
        dic[k] = min(dic[k], a.count(k))

dic = sorted(dic.items(), key=lambda x: x[0])
ans = ""
for d in dic:
    ans += d[0] * d[1]
print(ans)




Measured memory_bytes: 5192
#include <bits/stdc++.h>
//v.erase(unique(v.begin(),v.end()),v.end());
 
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
 
typedef double ld;
typedef long long ll;
const ll N = 100500;
const ll mod = 1100000007;
const ll INF = 1e+9;
using namespace std;
//using namespace __gnu_pbds;
 
//typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif

int xd[N];

void solve(){
	int n, k; cin >> n >> k;

	for(int i = 0; i < n; i++) cin >> xd[i];
	int ans = 1e+9;
	for(int i = 0; i <= n - k; i++){
		if(xd[i] <= 0 and xd[i + k - 1] >= 0) ans = min(ans, abs(xd[i + k - 1]) + abs(xd[i]) + min(abs(xd[i]), abs(xd[i + k - 1])));
		else{
			ans = min(ans, max(abs(xd[i]), abs(xd[i + k - 1])));
		}
	}

	
	cout << ans << endl;

}
 
int main(){
	fastio;
	ll tc = 1;
	//cin >> tc;

	while(tc--) solve();

	return 0;
}

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

int main() {
  int n,y;
  cin >> n >> y;
  int k;
  y /= 1000;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n-i; j++) {
      k=n-i-j;
      if (10*i+5*j+k == y) {
	printf("%d %d %d\n",i,j,k);
	return 0;
      }
    }
  }

  printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    if(M<2*N) cout<<M/2<<endl;
    else cout<<N+(M-2*N)/4<<endl;
}


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

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2020
#endif

using ll=long long;
ll dp[55][1<<20];
void solve() {
    int n; cin >> n;
    vector<vector<pair<int,int>>> g(n);
    for (int i = 0; i < n-1; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].emplace_back(y,i);
        g[y].emplace_back(x,i);
    }
    vector<int> restricted(n-1);
    vector<int> pth;
    int T;
    function<bool(int,int)> dfs = [&](int u, int p){
        for (auto& e: g[u]) {
            int v,i;
            tie(v,i) = e;
            if (v==p) continue;
            pth.push_back(i);
            if (v == T) return true;
            if (!dfs(v, u)) pth.pop_back();
            else return true;
        }
        return false;
    };
    int m; cin >> m;
    for (int j = 0; j < m; j++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        T = y;
        pth.clear();
        dfs(x, -1);
dbg(pth);
        for (int i: pth) {
            restricted[i] |= 1<<j;
        }
    }
dbg(restricted);
    const int MSK = 1<<m; 
    dp[0][0] = 1;
    for (int i = 0; i < n-1; i++) {
        int r = restricted[i];
        for (int msk = 0; msk < MSK; msk++) {
            dp[i+1][msk] += dp[i][msk];
            dp[i+1][msk|r] += dp[i][msk];
        }
    }
    cout << dp[n-1][MSK-1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 403712
/************************************/
/* NoobM							*/
/* File Name : at.cpp				*/
/* Date : 21.06.2020 18:00:49 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n;
	cin >> n;
	
	ll sum = 0;
	
	map <int, int> mp;
	
	rr(i, n) {
		int x;
		cin >> x;
		
		mp[x]++;
		sum += x;
	}
	
	//sort(a.begin(), a.end());
	
	int q;
	cin >> q;
	
	rr(i, q) {
		int b, c;
		cin >> b >> c;
		
		if(mp[b] == 0) cout << sum << endl;
		else {
			int temp = mp[b];
			ll minussum = (long long)temp * (ll)b;
			sum -= minussum;
			
			mp[b] = 0;
			mp[c] += temp;
			
			ll plussum = (long long)temp * (ll)c;
			sum += plussum;
			
			cout << sum << endl;
		}
	}
	
	
	
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


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

int main(){
	int n, m, l;
	int i, j ,k;

	cin >> n >> m >> l;

	int a[n][m];
	int b[m][l];

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
			cin >> b[i][j];
		}
	}

	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			long long sum = 0;
			for(k=0; k<m; k++){
				sum += a[i][k] * b[k][j];
			}
			if(j) cout << " ";
			cout << sum;
		}
		cout << endl;
	}

}

Measured memory_bytes: 1232
AOPB = input().split()
a = int(AOPB[0])
b = int(AOPB[2])
op = AOPB[1]
while op != "?":
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    AOPB = input().split()
    a = int(AOPB[0])
    b = int(AOPB[2])
    op = AOPB[1]

Measured memory_bytes: 7676
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++){
    for(Int j=0;j<i;j++){
      if(abs(a[i]-a[j])%(n-1)==0){
	cout<<a[i]<<" "<<a[j]<<endl;
	return 0;
      }
    }
  }
  return 0;
}



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

int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  if (N%2 == 0) {
    for (int i = 0; i < N; i++) {
      if(A.at(i) != i/2*2+1) {
        cout << 0 << endl;
        return 0;
      }
    }
    long ans = 1;
    for (int i = 0; i < N/2; i++) {
      ans *= 2;
      ans %= 1000000007;
    }
    cout << ans << endl;
  }
  else {
    for (int i = 0; i < N; i++) {
      if(A.at(i) != (i+1)/2*2) {
        cout << 0 << endl;
        return 0;
      }
    }
    long ans = 1;
    for (int i = 0; i < N/2; i++) {
      ans *= 2;
      ans %= 1000000007;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<P> ans;
	if(n%2 == 0){
		bool ok = false;
		int l = 1, r = n-1;
		while(l < r){
			if(!ok && r-l <= n/2){
				--r;
				ok = true;
			}
			ans.emplace_back(l, r);
			++l;
			--r;
		}
	}
	else{
		int l = 1, r = n-1;
		while(l < r){
			ans.emplace_back(l, r);
			++l;
			--r;
		}
	}
	rep(i,m){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 4216
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
	char symbol[5] = {'.', ',', '!', '?', ' '};
	char ans[80];
	int stringSize = 0;
	char input[2000];
	int count;
	
	cin >> count;
	for(int q=0; q < count; q++){
		stringSize = 0;
		cin >> input;
		int num = 0;
		int numCount = 0;
		for(int i=0; i < (int)strlen(input); i++){
			char tmp = input[i];
			int n = atoi(&tmp);
			if(n == num) numCount++;
			else if(n != num){
				switch(num){
					case 1:
						ans[stringSize++] = symbol[numCount % 5];
						break;
					case 2:
						ans[stringSize++] = 'a' + numCount % 3;
						break;
					case 3:
						ans[stringSize++] = 'd' + numCount % 3;
						break;
					case 4:
						ans[stringSize++] = 'g' + numCount % 3;
						break;
					case 5:
						ans[stringSize++] = 'j' + numCount % 3;
						break;
					case 6:
						ans[stringSize++] = 'm' + numCount % 3;
						break;
					case 7:
						ans[stringSize++] = 'p' + numCount % 4;
						break;
					case 8:
						ans[stringSize++] = 't' + numCount % 3;
						break;
					case 9:
						ans[stringSize++] = 'w' + numCount % 4;
						break;
					case 0:
						break;
				}
				num = n;
				numCount = 0;
			}
		}
		ans[stringSize] = '\0';
		cout << ans << endl;
	}
}

Measured memory_bytes: 1164
/*
 * ID: ITP1_7_B
 * Problem: Number of combination
 */

#include <stdio.h>

int main(void)
{
    int n, sum;

    while (1) {
        scanf("%d %d", &n, &sum);
        if (n == 0 && sum == 0)
            return 0;
        int i, j, k, count = 0;
        for (i = 1; i <= n; i++) {
            for (j = i + 1; j <= n; j++) {
                k = sum - i - j;
                if (k > 0 && k <= n && k != i && k != j && i < j && j < k) {
                    count++;
                    //printf("%d %d %d %d\n", i, j, k, count);
                }
            }
        }
        printf("%d\n", count);
    }

    return 0;
}



Measured memory_bytes: 2104
import Control.Monad
f [a,b] [c,d] = abs (a-c) + abs (b-d)
main = do
  [n,m] <- map read . words <$> getLine
  abs <- replicateM n $ map read . words <$> getLine
  cds <- replicateM m $ map read . words <$> getLine
  mapM (\ab -> print $ snd $ minimum $ zip (map (f ab) cds) [1..]) abs

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long n = sc.nextLong();
		System.out.println(n*(n-1)/2);
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    ll L,R; cin >> L >> R;
    int MOD = 2019;
    ll ans = 2020;
    if(R - L < 2019){
        for(ll i = L; i < R; i++){
            for(ll j = i+1; j <= R; j++){
                ans = min(ans,((i % MOD)*(j % MOD))%MOD);
            }
        }
    }else{
        ans = 0;
    }

    cout << ans << endl;
}

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

int main(){
	long n,k,r,s,p;
	string ss;
	cin >> n >> k >> r >> s >> p >> ss;
	vector<char> v(n);
	long ans=0;
	rep(i,n){
		if(ss[i]=='r' && (i<k || v[i-k]!='p')){
			ans+=p;
			v[i]='p';	
		}
		if(ss[i]=='s' && (i<k || v[i-k]!='r')){
			ans+=r;
			v[i]='r';
		}
		if(ss[i]=='p' && (i<k || v[i-k]!='s')){
			ans+=s;
			v[i]='s';
		}
	}
	cout << ans;
	
	return 0;
}


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

using namespace std;

int main(void){
    
    vector<int> n, x;
    
    int count = 0;
    while(1){
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        n.push_back(a);
        x.push_back(b);
        count++;
    }
    
    for(int o = 0;o < count;o++){
        int ans = 0;
        for(int i = 1;i <= n[o]-2;i++){
            for(int j = i+1;j <= n[o]-1;j++){
                for(int k = j+1;k <= n[o];k++){
                    if(i+j+k == x[o]) ans++;
                }
            }
        }
        
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3160
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 5010;
const LL Mod = 1e9+7;
const LL inv2 = 500000004;
LL f[Maxn][Maxn], g[Maxn], h[Maxn];
struct node {
	LL y, next;
}a[Maxn<<1]; LL first[Maxn], len;
void ins(LL x, LL y) {
	len++;
	a[len].y = y;
	a[len].next = first[x]; first[x] = len;
}
LL siz[Maxn];
LL n;
LL jc[Maxn], inv[Maxn], two[Maxn];
void up(LL &x, LL y) { x = (x + y) % Mod; }
void dfs(LL x, LL fa) {
	LL i, j;
	siz[x] = 1; f[x][1] = 1;
	for(LL k = first[x]; k; k = a[k].next){
		LL y = a[k].y;
		if(y == fa) continue;
		dfs(y, x);
		for(i = 2-((siz[x]+siz[y])&1); i <= siz[x]+siz[y]; i += 2) h[i] = 0;
		for(i = 2-(siz[x]&1); i <= siz[x]; i += 2){
			for(j = 2-(siz[y]&1); j <= siz[y]; j += 2){
				up(h[i+j], f[x][i]*f[y][j]);
				if(!(siz[y]&1)) up(h[i], (Mod-1)*f[x][i]%Mod*f[y][j]%Mod*g[j]);
			}
		}
		siz[x] += siz[y];
		for(i = 2-(siz[x]&1); i <= siz[x]; i += 2) f[x][i] = h[i];
	}
}
int main() {
	LL i, j, k;
	scanf("%lld", &n);
	for(i = 1; i < n; i++){
		LL x, y;
		scanf("%lld%lld", &x, &y);
		ins(x, y); ins(y, x);
	}
	jc[0] = 1;
	for(i = 1; i <= n; i++) jc[i] = jc[i-1]*i%Mod;
	inv[0] = inv[1] = 1;
	for(i = 2; i <= n; i++) inv[i] = inv[Mod%i]*(Mod-Mod/i)%Mod;
	for(i = 2; i <= n; i++) inv[i] = inv[i-1]*inv[i]%Mod;
	two[0] = 1;
	for(i = 1; i <= n; i++) two[i] = two[i-1]*inv2%Mod;
	for(i = 2; i <= n; i += 2) g[i] = jc[i]*inv[i/2]%Mod*two[i/2]%Mod;
	dfs(1, 0);
	LL ans = 0;
	for(i = 2; i <= n; i += 2) up(ans, f[1][i]*g[i]);
	printf("%lld\n", ans);
	return 0;
}

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

template<class Monoid> struct SegmentTree {
    using Function = function< Monoid(Monoid, Monoid) >;

    int N; vector<Monoid> segment;
    const Function func;
    const Monoid id;

    SegmentTree(int n, const Function func, const Monoid id) : func(func), id(id) {
        N = 1;
        while (N < n) N <<= 1;
        segment.assign(2 * N, id);
    }

    void set(int num, Monoid x) {
        segment[N + num] = x;
    }
    void build() {
        for (int k = N - 1; k > 0; k--) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }
    void update(int k, Monoid x) {
        k = k + N; segment[k] = x;
        while(k >>= 1) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }

    // query:[a, b)
    Monoid query(int a, int b) {
        Monoid L = id; Monoid R = id; a += N; b += N;
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = func(L, segment[a++]);
            if (b & 1) R = func(segment[--b], R);
        }
        return func(L, R);
    }
    // 0-based numbering;
    Monoid operator[](const int k) const {
        return segment[N+k];
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<pair<pair<int, int>, long long>> e;
    for (int i = 0; i < m; i++) {
        int a, b; long long c; cin >> a >> b >> c;
        e.push_back({{b, a}, c});
    }
    sort(e.begin(), e.end());
    SegmentTree<long long> dp(n+1, [](long long a, long long b){return min(a, b);}, (long long) 1e16);
    dp.update(0, 0);
    for (int i = 0; i < m; i++) {
        auto a = e[i].first.second;
        auto b = e[i].first.first;
        auto c = e[i].second;
        auto d = dp.query(a-1, b-1);
        dp.update(b-1, min(d+c, dp[b-1]));
    }
    if (dp[n-1] == 1e16) cout << -1 << endl;
    else cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3952
import java.util.Scanner;

/**
 * @author ??\???
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		scanner.close();
		
		System.out.println((a * b) + " " + ((a + b) * 2));
	}

}

Measured memory_bytes: 26384
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b) {
  return (a > b ? a : b);
}

int main(void) {
  int N;
  int R;

  scanf("%d %d", &N, &R);

  printf("%d\n", R + max(0, 100 * (10 - N)));

  return (0);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[][] str = new String[n][n];

    for (int i=0; i < n; i++) {
      String tmpStr = sc.next();

      for (int j=0; j < n; j++) {
        str[i][j] = String.valueOf(tmpStr.charAt(j));
      }
    }

    int count = 0;
    String[][] secondStr = new String[n][n];

    for (int A=0; A < n; A++) {
      for (int i=0; i < n; i++) {
        for (int j=0; j < n; j++) {
          secondStr[i][j] = str[(i+A)%n][j];
        }
      }

      boolean ans = true;

      for (int i=0; i < n; i++) {
        for (int j=0; j < n; j++) {
          if (!(secondStr[i][j].equals(secondStr[j][i]))) {
            ans = false;
          }
        }
      }

      if (ans == true) count += n;
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 32796
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<double> v(n);
	for (int i = 0; i < n; i++) cin >> v.at(i);
	sort(v.begin(), v.end());

	for (int i = 1; i < n; i++) v.at(i) = (v.at(i - 1) + v.at(i)) / 2;
	cout << v.at(n - 1) << endl;
}

Measured memory_bytes: 3796
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
ll root(ll X,ll par[]){
    if(X==par[X]){
        return X;
    }else{
        par[X]=root(par[X],par);
        return par[X];
    }
}
void merge(ll X,ll Y,ll par[]){
    if(root(X,par)!=root(Y,par))par[root(Y,par)]=root(X,par);
    return;
}

int main(){
    ll N,M;
    cin >> N >> M;
    ll par[N];
    ll i;
    for(i=0;i<N;i++){
        par[i]=i;
    }
    ll X,Y,Z,ans=N;
    for(i=0;i<M;i++){
        cin >> X >> Y>>Z;
        X--;
        Y--;
        if(root(X,par)!=root(Y,par)){
            merge(X,Y,par);
            ans--;
            }
        }
    cout << ans;
    return 0;
}


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

typedef long long LL;
const int MX = 1e5+7, N = 105;
const LL INF = 1e18;
LL dp[N][MX];


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

    for (int i=0; i<=n; i++)
        for (int j=0; j<=w; j++)
            dp[i][j] = -INF;

    dp[0][0] = 0;

    LL ans = 0;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<=w; j++)    dp[i][j] = dp[i-1][j];
        int x, v;
        cin>>x>>v;
        for (int j=x; j<=w; j++) {
            dp[i][j] = max(dp[i][j], dp[i-1][j-x] + v);
            ans = max(ans, dp[i][j]);
//            cout<<"--->"<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<int,int>mp;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,y,a[100005],i,j,b[100005],d;
    cin>>n>>y;
    for(i=0; i<n; i++)
    {
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    ll sum=0,c=0;
    for(int i=n-1; i>=0; i--)
    {
        if(a[n-1]<b[i])
        {
            c++;
            sum+=b[i];
            if(sum>=y)
                break;
        }
        else
            break;
    }
    if(sum>=y)
        cout<<c<<endl;
    else if((y-sum)%a[n-1]==0)
    {
        cout<<c+(y-sum)/a[n-1]<<endl;
    }
    else
        cout<<c+(y-sum)/a[n-1]+1<<endl;
    return 0;
}


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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            long K = long.Parse(Console.ReadLine());
            int output = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == '1')
                {
                    K--;
                }
                else
                {
                    output = int.Parse(S[i].ToString());
                    break;
                }
                if (K == 0)
                {
                    output = int.Parse(S[i].ToString());
                    break;
                }
            }
            Console.WriteLine(output);
            ;
        }
    }
}


Measured memory_bytes: 13140
/*
 © 2020-09-19 07:00:13 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n; cin >> n;
  lli last = 0;
  fore(i, 0, n){
    lli x, y; cin >> x >> y;
    if(x == y){
      last++;
    }else last = 0;
    if(last >= 3){
      cout << "Yes" << ENDL;
      return 0;
    }
  }
  cout << "No" << ENDL;
  return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

vector<string> s357 = {"3", "5", "7"};
lint ans = 0;

string dfs(string s,lint n){
    string ret;
    //cout << s << "\n";
    if(s!=""&&stoull(s)>n){
        return "";
    }
    //cout << s<< "\n";
    vector<lint> exist(10);
    REP(i,SZ(s)){
        exist[s[i] - '0'] = 1;
    }
    if (exist[3] + exist[5] + exist[7]==3){
        ans++;
    }
        REP(i, 3)
        {
            ret += dfs(s + (string)s357[i], n);
        }
    return ret;
}

int main()
{
    lint n;cin >> n;
    //int ans=0;
    string s = to_string(n);
    int d = SZ(s);

    dfs("0", n);

    cout <<ans <<"\n";

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  rep(i,N){
    cin >> A.at(i);
  }
  rep(i,N){
    cin >> B.at(i);
  }
  rep(i,N){
    cin >> C.at(i);
  }
  
  sort(A.begin(),A.end());
  sort(C.begin(),C.end());
  
  ll cnt = 0;
  rep(i,N){
    int a = upper_bound(A.begin(), A.end(), B.at(i)-1) - A.begin();
    int c = lower_bound(C.begin(), C.end(), B.at(i)+1) - C.begin();
    cnt += 1LL * (N-c) * (a);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

 int n,a,b,x[200000];
 cin>>n>>a>>b;
 for(int i=0;i<n;++i) cin>>x[i];
 sort(x,x+n);

 int A=0,B=0,C=0;
 int p=0;
 while(1){
   if(p>=n) break;
   if(x[p]>a) break;
   p++;
   A++;
 }
  while(1){
   if(p>=n) break;
   if(x[p]>b) break;
   p++;
   B++;
 }
  while(1){
   if(p>=n) break;
   p++;
   C++;
 }

 cout<<min(A,min(B,C))<<endl;
 

 return 0;
}


Measured memory_bytes: 256