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

using namespace std;

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


int main() 
{
  int x=in();
  x<1200?print("ABC"):print("ARC");

  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
int a[100005],b[100005];
vector<int> g[100005];
int used[100005];
int ans[100005];
map<int,int> color[100005];
set<int> st;
void dfs(int v,int p){
    used[v]=1;
    int k=1;
    for(auto to:g[v]){
        if(!used[to]){
            if(k==color[p][v])
                k++;
                color[v][to]=k;
            st.insert(k++);
                dfs(to,v);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++){
        cin>>a[i]>>b[i];
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    dfs(1,0);
    cout<<st.size()<<'\n';
    for(int i=1;i<=n-1;i++){
        if(color[a[i]][b[i]])
        cout<<color[a[i]][b[i]]<<'\n';
        else{
            cout<<color[b[i]][a[i]]<<'\n';
        }
    }
    return 0;
}



Measured memory_bytes: 19712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
signed main(){
  int x,y;
  cin >> x >> y;
  
  int a = abs( abs(x) - abs(y) );
  
  int ans = 1001001001001001001;
  
  if(  x + a == y ) ans = min(ans,a+0);
  if( -x + a == y ) ans = min(ans,a+1);
  if( -x - a == y ) ans = min(ans,a+1);
  if(  x - a == y ) ans = min(ans,a+2);
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

//#define int ll

const ll INF =1LL<<50;
signed main(){
    int n,m;
    cin>>n>>m;
    
    const int nmax=1000;
    const int mmax=2000;
    int a[mmax],b[mmax];
    ll c[mmax];
    
    rep(i,0,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
        c[i]=-c[i];
    }
    
    ll dist[nmax];
    
    rep(i,0,n)dist[i]=INF;
    dist[0]=0;
    
    rep(loop,0,n-1){
        rep(i,0,m){
            if(dist[a[i]]==INF)continue;
            if(dist[b[i]]>dist[a[i]]+c[i]){
                dist[b[i]]=dist[a[i]]+c[i];
            }
        }
    }
    
    ll ans=dist[n-1];
    
    bool negative[nmax];
    
    rep(i,0,n)negative[i]=false;
    
    rep(loop,0,n){
        rep(i,0,n){
            if(dist[a[i]]==INF)continue;
            if(dist[b[i]]>dist[a[i]]+c[i]){
                dist[b[i]]=dist[a[i]]+c[i];
                negative[b[i]]=true;
            }
            if(negative[a[i]]==true){
                negative[b[i]]==true;
            }
        }
    }
    
    if(negative[n-1])cout<<"inf"<<endl;
    else cout<<-ans<<endl;
    
}

Measured memory_bytes: 256
n = int(input())
B = list(map(int, input().split()))
sumA = 0

for i in range(n):
    if i==0:
        sumA+=B[i]
    elif i==n-1:
        sumA+=B[i-1]
    else:
        sumA+=min(B[i-1],B[i])

print(sumA)


Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 1000000

typedef struct
{         
  int p; //parent
  int l; //left
  int r; //right
}Tree;
Tree A[MAX];   

int depth(int i);

int main(){
  int i,j; 
  int N,id,k,c,l;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    A[i].p=A[i].l=A[i].r=-1;
  }

  for(i=0;i<N;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      A[c].p=id;
      if(j==0) A[id].l=c;
      else A[l].r=c;
      l=c;
    }
  }

  for(i=0;i<N;i++){
    printf("node %d: parent = %d, depth = %d,",i,A[i].p,depth(i));
    if(depth(i)==0) printf(" root, [");
    else if(A[i].l==-1) printf(" leaf, [");
    else printf(" internal node, [");
    j=A[i].l;
    while(j!=-1){
      printf("%d",j);
      j=A[j].r;
      if(j!=-1) printf(", ");
    }
    printf("]\n");
  } 
      
  return 0;
}

int depth(int i){
  int j=0;
  while(A[i].p!=-1){
    i=A[i].p;
    j++;
  }
  
  return  j;
}



Measured memory_bytes: 2864
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace  std;

int main(void) {
  double r;
  cout << fixed;
  cin >> r;
  cout << setprecision(7) << M_PI * pow(r, 2) << " " << 2 * r * M_PI << endl;
}


Measured memory_bytes: 3288
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int q = in.nextInt();

            int[][] sum = new int[n + 1][n + 1];
            for (int i = 0; i < m; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                sum[l][r]++;
            }

            for (int i = 0; i <= n; i++) {
                for (int j = 0; j < n; j++) {
                    sum[i][j + 1] += sum[i][j];
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j <= n; j++) {
                    sum[i + 1][j] += sum[i][j];
                }
            }

            for (int i = 0; i < q; i++) {
                int p = in.nextInt();
                int r = in.nextInt();

                out.println(sum[r][r] - sum[r][p - 1] - sum[p - 1][r] + sum[p - 1][p - 1]);
            }
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 60880
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  deque<char> dq;
  rep(i,0,s.sz){
    dq.push_back(s[i]);
  }
  ll q;
  cin>>q;
  ll p = 0;
  rep(i,0,q){
    ll a;
    cin>>a;
    if(a==1){
      p = 1-p;
    }
    else{
      ll b;
      char c;
      cin>>b>>c;
      if(p==0){
        if(b==1){
          dq.push_front(c);
        }
        else{
          dq.push_back(c);
        }
      }
      else{
        if(b==1){
          dq.push_back(c);
        }
        else{
          dq.push_front(c);
        }
      }
    }
  }
  string ans;
  while(!dq.empty()){
    char c = dq.front();
    dq.pop_front();
    string s = ctos(c);
    ans += s;
  }
  if(p==1)reverse(all(ans));
  cout << ans << endl;
  return 0;
}

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

using pii = pair<int, int>;

int main() {
    int w, h, n; cin >> w >> h >> n;
    vector<pii> es(n);
    multiset<int, greater<>> s;
    for(int i = 0; i < n; ++i) {
        cin >> es[i].first >> es[i].second;
        s.insert(es[i].second);
    }
    sort(begin(es), end(es));
    int ans = 1e9;
    {
        int maxi_y = 0;
        for(int i = 0; i < n; ++i) {
            maxi_y = max(maxi_y, es[i].second);
        }
        ans = min(es.back().first, maxi_y);
    }
    for(int i = 0; i < n; ++i) {
        s.erase(s.lower_bound(es[i].second));
        ans = min(ans, es[i].first + *begin(s));
    }
    cout << ans << endl;
}



Measured memory_bytes: 8364
#include <bits/stdc++.h>
#define int long long
using namespace std;

int d, w, e[10][10];

signed main(){
  
  while(1){
  
    cin>>d>>w;
    if( d == 0 && w == 0 ) break;
    
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
	cin>>e[i][j];
      }
    }
  
    int ans = 0;
  
    for(int i=0;i<d;i++){
    
      for(int j=0;j<w;j++){
      
	for(int k=i+2;k<d;k++){
	
	  for(int l=j+2;l<w;l++){
	  
	    int minv = 1000;
	    int maxv = 0;
	    int sum = 0;
	    int cnt = 0;
	  
	    for(int y=i;y<=k;y++){
	    
	      for(int x=j;x<=l;x++){
	      
		if( y == i || y == k || x == j || x == l ) minv = min( minv, e[y][x] );
		else{
		  maxv = max( maxv, e[y][x] );
		  sum += e[y][x];
		  cnt++;
		}
	      
	      }
	    
	    }
	  
	    if( minv > maxv ) ans = max( ans, minv * cnt - sum );
	  
	  }
	
	}
      
      }
    
    }
  
    cout<<ans<<endl;

  }
  
  return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if(a + b == 15) {
    cout << "+" << endl;
  }else if(a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,ans=0;
	cin>>n;
	int a[n];
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i+=2)
	{
		if(a[i]%2==1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int N; cin >> N;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A+N);
  int maxNum = 1, num1 = 1, num2 = 1, num3 = 1;
  for (int i = 1; i < N; i++) {
    int dif = A[i] - A[i - 1];
    if (dif == 1) {
      num1 = num2; num2 = num3; num3 = 0;
    } else if (dif == 2) {
      num1 = num3; num2 = 0; num3 = 0;
    } else if (dif >= 3) {
      num1 = 0; num2 = 0; num3 = 0;
    }
    num1++; num2++; num3++;
    maxNum = max(maxNum, max(num1, max(num2, num3)));
  }
  cout << maxNum << endl;
}

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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)

const int N = 3e5 + 2;

int n, m, cnt_x[N], cnt_y[N];
set<pair<int,int>> given;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    cin >> n >> m;
    int t;
    cin >> t;
    while(t--) {
        int x, y;
        cin >> x >> y;
        given.insert({x, y});
        cnt_x[x]++;
        cnt_y[y]++;
    }
    int maxx = 0, maxy = 0;
    set<int> whichx, whichy;

    FOR(i,1,N-1) {
        maxx = max(maxx, cnt_x[i]);
        maxy = max(maxy, cnt_y[i]);
    }
    FOR(i,1,N-1) {
        if(cnt_x[i] == maxx) {
            whichx.insert(i);
        }
        if(cnt_y[i] == maxy) {
            whichy.insert(i);
        }
    }

    int cnt_pairs = 0;
    for(auto& p : given) {
        int x = p.first;
        int y = p.second;
        if(whichx.count(x) && whichy.count(y))
            cnt_pairs++;
    }

    if(cnt_pairs == sz(whichx) * sz(whichy)) 
        cout << maxx + maxy - 1;
    else cout << maxx + maxy;
}


Measured memory_bytes: 48184
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 2000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li],c[li];
int cev;
string s;
vector<int> v;

main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		scanf("%lld %lld",&a[i],&b[i]);
	}
	FOR{
		for(int j=k-a[i];j>=0;j--){
			dp[j+a[i]]=max(dp[j]+b[i],dp[j+a[i]]);
		}
	}
	for(int i=0;i<=k;i++)cev=max(cev,dp[i]);
	printf("%lld\n",cev);
	return 0;
}



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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<bitset<10> > F;
	vector<vector<long long> > P;
	for(int i = 0; i < N; ++i) {
		string line;
		for(int j = 0; j < 10; ++j) {
			string ch;
			cin >> ch;
			line += ch;
		}
		F.push_back(bitset<10>(line));
	}
	for(int i = 0; i < N; ++i) {
		vector<long long> v;
		for(int j = 0; j <= 10; ++j) {
			long long t;
			cin >> t;
			v.push_back(t);
		}
		P.push_back(v);
	}
	long long result = -100000000000;
	for(unsigned int subset = 0x001; subset < 0x400; ++subset) {
		bitset<10> bs(subset);
		long long profit = 0;
		for(int i = 0; i < N; ++i) {
			profit += P[i][(bs & F[i]).count()];
		}
		if(result < profit) {
			result = profit;
		}
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int h, w;
vector<pair<int, int>> ps;
vector<int> ts1, ts2;

int main(void) {
  scanf("%d%d", &h, &w);
  int mi1 = 114514, mi2 = 114514;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c; scanf(" %c", &c);
      if (c == 'B') {
	ps.push_back({j, i});
	ts1.push_back(j + i);
	ts2.push_back(j - i);
	mi1 = min(mi1, j + i);
	mi2 = min(mi2, j - i);
      }
    }
  }

  int res = 0;
  for (int i = 0; i < int(ts1.size()); i++) {
    res = max(res, ts1[i] - mi1);
  }
  for (int i = 0; i < int(ts2.size()); i++) {
    res = max(res, ts2[i] - mi2);
  }
  printf("%d\n", res);
  return 0;
}

/*
|x1-x2|+|y1-y2|

x1+y1
x1-y1

max(x1+y1-(x2+y2)(x1-x2)+(y1-y2),
(x1-y1)-(x2-y2)(x1-x2)+(y2-y1),
(y1-x1)+(x2-y2)(x2-x1)+(y1-y2),
(x2+y2)-(x1+y2)(x2-x1)+(y2-y1))
 */



Measured memory_bytes: 17540
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10;
int A[N],R[N],C[N],n; // r -> r   c -> c+H
struct item {
	int u;
	item(int u=0): u(u) {}
	friend bool operator <(item a,item b) { return A[a.u]==A[b.u]?a.u<b.u:A[a.u]>A[b.u]; }
};
set<item> s[N];
multiset<item> que;
int bel[N];
void un(int x,int y) {
	if(s[bel[x]].size()>s[bel[y]].size()) swap(x,y);
	if(!s[bel[x]].size()) {
		if(s[bel[y]].size()) que.insert(*s[bel[y]].begin());
		bel[x]=y;
		return;
	}
	for(set<item>::iterator it=s[bel[x]].begin();it!=s[bel[x]].end();++it)
		s[bel[y]].insert(*it);
	bel[x]=y;
	que.insert(*s[bel[y]].begin());
}
int find(int x) { return bel[x]==x?x:bel[x]=find(bel[x]); }
int H,W;
inline void Erase(int u) {
	int x=find(R[u]),y=find(C[u]+H);
	if(s[x].size()&&s[y].size()&&x!=y) {
		if((s[x].begin()->u)==u) que.erase(que.find(item(u)));
		if((s[y].begin()->u)==u) que.erase(que.find(item(u)));
		s[x].erase(item(u));
		s[y].erase(item(u));
		un(x,y);
		return;
	}
	que.erase(que.find(item(u)));
	s[x].clear(),s[y].clear();
}
void Debug() {
	for(int i=1;i<=H;++i) {
		printf("r%d : ",i);
		int x=find(i);
		for(set<item>::iterator it=s[x].begin();it!=s[x].end();++it) printf("%d ",it->u); puts("");
	}
	for(int i=1;i<=W;++i) {
		printf("c%d : ",i);
		int x=find(i+H);
		for(set<item>::iterator it=s[x].begin();it!=s[x].end();++it) printf("%d ",it->u); puts("");
	}
	cout<<"que : ";
	for(multiset<item>::iterator it=que.begin();it!=que.end();++it) printf("%d ",it->u); puts("");
}
	
int main() {
	rd(n),rd(H),rd(W);
	for(int i=1;i<=W+H;++i) bel[i]=i;
	for(int i=1;i<=n;++i) {
		rd(R[i]),rd(C[i]),rd(A[i]);
		s[R[i]].insert(item(i));
		s[C[i]+H].insert(item(i));
	}
	for(int i=1;i<=W+H;++i)
		if(s[i].size()) que.insert(*s[i].begin());
	ll ans=0;
	while(!que.empty()) {
		int u=que.begin()->u;
//		cout<<u<<endl;
		ans+=A[u]; Erase(u);
//		Debug();
	}
	printf("%lld",ans);
	return 0;
}

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

int main(void){
    string S;
    cin >> S;
    bool flag=1;
    for(int i = 0; i<(S.size()/2); i++){
        if(S.at(i) != S.at(S.size()/2+1+i)){
            flag = 0;
            break;
        }
    }
    if(flag){
        cout << "Yes";
    } else {
        cout << "No";
    }
    
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int[] data = new int[3];
        for (int a = 0; a < 3; a++) {
            data[a] = sc.nextInt();
        }
        Arrays.sort(data);
        System.out.println(data[0] + " " + data[1] + " " + data[2]);
    }
}


Measured memory_bytes: 26208
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vp a;
vi b,c;

int main(){
	cin>>n;
	a=vp(n);
	b=c=vi(n);
	for(int i=0;i<n;i++) cin>>a[i].first>>a[i].second;
	sort(a.begin(),a.end());
	int res=0,mn=inf;
	b[0]=a[0].second;c[n-1]=a[n-1].second;
	for(int i=1;i<n;i++) b[i]=min(b[i-1],a[i].second);
	for(int i=n-2;i>=0;i--) c[i]=min(c[i+1],a[i].second);
	for(int i=0;i<n-1;i++){
		res=max(res,a[i].second-a[i].first+1+max(0,min((i?b[i-1]:inf),c[i+1])-a[n-1].first+1));
		res=max(res,max(0,b[i]-a[i].first+1)+max(0,c[i+1]-a[n-1].first+1));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,d;
	cin >> n >> d;
	int x[n][d];
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> x[i][j];
		}
	}
	int cnt=0;
	/*
	for(int i=0 ;i<n; i++){
		for(int j=0; j<d; j++){
			cout << x[i][j] <<" "; 
		}
		cout << endl;
	}
	*/
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			long double ans = 0.0;
			for(int l=0; l<d; l++){
				ans += pow(abs(x[i][l]-x[j][l]),2);
				//cout << ans << " ";
			}
			//cout << endl;
			ans = sqrt(ans);
			ll ians = ans;
			if(!(ans-ians)){
				cnt++;
			}
			//cout << ans << endl;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define INF 0x3f3f3f3f
using namespace std;
 
template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
 
/*============ Header Template ============*/

const int N = 50 + 5;
const int M = 2500 + 5;

int n, A;
int a[N];
LL f[M][N];

int main() {
	read(n), read(A);
	for (int i = 1; i <= n; i++) read(a[i]);
	f[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 2500; j >= a[i]; j--)
			for (int k = 1; k <= i; k++) f[j][k] += f[j - a[i]][k - 1];
	}
	LL ans = 0;
	for (int i = 1; i <= n; i++) 
		if (i * A <= 2500) ans += f[i * A][i];
	printf("%lld\n", ans);
	return 0;
}

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

ll gcd(ll a, ll b)
{

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

int main(){
	ll n;
	cin >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	ll answer = gcd(arr[0],arr[1]);
	for (int z=2;z<n;z++){
		answer = gcd(arr[z],answer);
	}
	cout << answer << endl;
	cin >> n;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace aziz
{
    class Program
    {
        static void Main(string[] args)
        {
            var KN = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
            var P = Console.ReadLine( ).Split( ).Select( int.Parse ).ToList( );
            var selected = P.OrderBy( x => x ).Take( KN[ 1 ] ).ToList( );
            Console.WriteLine(selected.Sum());
        }
    }
}

Measured memory_bytes: 28736
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    cnt = [0] * (M + 1)

    for _ in range(N):
        K, *A = list(map(int, readline().split()))
        for x in A:
            cnt[x] += 1

    print(cnt.count(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62472
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()

ans = "Good"
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        ans = "Bad"

print(ans)

Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
  char c;
  scanf("%c",&c);
  if(c=='a'){
    printf("b\n");
  }
  if(c=='b'){
    printf("c\n");
  }
  if(c=='c'){
    printf("d\n");
  }
  if(c=='d'){
    printf("e\n");
  }
  if(c=='e'){
    printf("f\n");
  }
  if(c=='f'){
    printf("g\n");
  }
  if(c=='g'){
    printf("h\n");
  }
  if(c=='h'){
    printf("i\n");
  }
  if(c=='i'){
    printf("j\n");
  }
  if(c=='j'){
    printf("k\n");
  }
  if(c=='k'){
    printf("l\n");
  }
  if(c=='l'){
    printf("m\n");
  }
  if(c=='m'){
    printf("n\n");
  }
  if(c=='n'){
    printf("o\n");
  }
  if(c=='o'){
    printf("p\n");
  }
  if(c=='p'){
    printf("q\n");
  }
  if(c=='q'){
    printf("r\n");
  }
  if(c=='r'){
    printf("s\n");
  }
  if(c=='s'){
    printf("t\n");
  }
  if(c=='t'){
    printf("u\n");
  }
  if(c=='u'){
    printf("v\n");
  }
  if(c=='v'){
    printf("w\n");
  }
  if(c=='w'){
    printf("x\n");
  }
  if(c=='x'){
    printf("y\n");
  }
  if(c=='y'){
    printf("z\n");
  }

  /* s[1]='b';
  s[2]='c';
  s[3]='d';
  s[4]='e';
  s[5]='f';
  s[6]='g';
  s[7]='h';
  s[8]='i';
  s[9]='j';
  s[10]='k';
  s[11]='l';
  s[12]='m';
  s[13]='n';
  s[14]='o';
  s[15]='p';
  s[16]='q';
  s[17]='r';
  s[18]='s';
  s[19]='t';
  s[20]='u';
  s[21]='v';
  s[22]='w';
  s[23]='x';
  s[24]='y';
  s[25]='z';
    for(i=0;i<25;i++){
      if(c==s[i]){
	printf("%c\n",s[i+1]);
	break;
      }
      }*/
  return 0;
}


Measured memory_bytes: 128
s = list(input())
t = list(input())
s.reverse()
t.reverse()
l = len(t)
ld = len(s)-len(t)+1
for i in range(ld):
    cnt = 0
    for j in range(l):
        if s[j+i] == "?" or s[j+i] == t[j]:
            cnt += 1
    if cnt == l:
        ans = []
        for p in range(i):
            if s[p] == "?":
                ans.append("a")
            else:
               ans.append(s[p])
        for p in t:
            ans.append(p)
        for p in range(ld-i-1):
            if s[l+p+i] == "?":
                ans.append("a")
            else:
                ans.append(s[l+i+p])
        ans.reverse()
        for p in ans:
            print(p,end = "")
        break
            
else:
    print("UNRESTORABLE")

Measured memory_bytes: 9104
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 998244353
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
} 
int main()
{
    fast;
        ll n,k,v,t,w,x=0,a,b,c,d,e,f;
        std::cin >> a>>b>>c>>d>>e;
        if(a==0)
        cout<<1<<"\n";
        else if(b==0)
        cout<<"2\n";
        else if(c==0)
        cout<<"3\n";
        else if(d==0)
        cout<<"4\n";
        else
        cout<<"5\n";
        
}

Measured memory_bytes: 3656
n = int(input())
ans = 0
a, b, ab = 0, 0, 0
for _ in range(n):
    s = list(input())
    l = len(s)
    for i in range(l - 1):
        if s[i] == "A" and s[i + 1] == "B":
            ans += 1
    if s[0] == "B":
        b += 1
    if s[l - 1] == "A":
        a += 1
    if s[0] == "B" and s[l - 1] == "A":
        ab += 1
if a == b == ab:
    a -= 1
ans += min(n - 1, max(0, min(a, b)))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N;
    cin >> N;
    
    vec<mint> A(N);
    mint sm = 0;
    rep(i, N) {
        int a;
        cin >> a;
        A[i] = a;
        sm+=a;
    }

    mint sb = 0;
    rep(i,N) {
        mint a = 0;
        a=A[i];
        a*=a;
        sb+=a;
    }
    
    cout << (sm*sm-sb)/2 << '\n';
}


Measured memory_bytes: 4808
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int n;
	int a[100000];
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mp[a[i]]++;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > 100000) {
			ans++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (mp[i] >= i) {
			ans += mp[i] - i;
		}
		else {
			ans += mp[i];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
char c[2005][2005];
int nextr[2005][2005],lastr[2005][2005],nextc[2005][2005],lastc[2005][2005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int H,W;
	cin>>H>>W;
	for(int i=0;i<=H+1;i++){
		for(int j=0;j<=W+1;j++){
			c[i][j]='#';
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>c[i][j];
			nextr[i][j]=H+1;
			nextc[i][j]=W+1;
			lastr[i][j]=lastc[i][j]=0;
		}
	}
	for(int i=1;i<=H;i++){
		int last=0;
		for(int j=1;j<=W+1;j++){
			if(c[i][j]=='#'){
				for(int k=last+1;k<j;k++){
					nextc[i][k]=j;
				}
				last=j;
			}
		}
		for(int j=W;j>=0;j--){
			if(c[i][j]=='#'){
				for(int k=last-1;k>j;k--){
					lastc[i][k]=j;
				}
				last=j;
			}
		}
	}
	for(int i=1;i<=W;i++){
		int last=0;
		for(int j=1;j<=H+1;j++){
			if(c[j][i]=='#'){
				for(int k=last+1;k<j;k++){
					nextr[k][i]=j;
				}
				last=j;
			}
		}
		for(int j=H;j>=0;j--){
			if(c[j][i]=='#'){
				for(int k=last-1;k>j;k--){
					lastr[k][i]=j;
				}
				last=j;
			}
		}
	}
	int ans=0;
	/*for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cout<<lastr[i][j]<<" ";
		}
		cout<<endl;
	}*/
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(c[i][j]=='.') ans=max(ans,nextr[i][j]-lastr[i][j]+nextc[i][j]-lastc[i][j]-3);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}

Measured memory_bytes: 3548
N, T = map(int, input().split())
c_t = [list(map(int, input().split())) for i in range(N)]
c_t = [[c, t] for c, t in c_t if t <= T]
C = sorted(c_t, key=lambda x:x[0])
print(C[0][0] if C else "TLE")

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};

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

    string A,B;
    cin >> A >> B;
    if(A.length() > B.length()){
        cout << "GREATER" << endl;
    }else if(A.length() < B.length()){
        cout << "LESS" << endl;
    }else{
        if(A > B){
            cout << "GREATER" << endl;
        }else if(A < B){
            cout << "LESS" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n;
int main(){
    cin >> n;
    vector<int> x(n),y(n);
    rep(i,n) cin >> x[i], y[i] = x[i];
    sort(ALL(y));
    int m1 = y[n/2 - 1], m2 = y[n/2];
    rep(i,n){
        if(x[i] <= m1) cout << m2 << endl;
        else cout << m1 << endl;
    }
}

Measured memory_bytes: 3840
#!/usr/bin/env python

def bubbleSort(A, N):
    swap_count = 0

    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                swap_count += 1
                flag = True
    ans = " ".join(map(str, A))
    print(ans)
    print(swap_count)

def main():
    size = int(input())
    line = list(map(int, input().split()))
    bubbleSort(line, size)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7732
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(int argc, char **argv)
{
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> l[i];
	}

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

	int res = 0;
	for (int i = 0; i < k; ++i)
	{
		res += l[n - 1 - i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll MX=200000;
vvl G(MX,vl());
vl ans(MX);

void dfs(ll i,ll p=-1){
  for(auto v:G[i]){
    if(v==p){
      continue;
    }
    ans[v] +=ans[i];
    dfs(v,i);
  }
}

int main() {
  ll n,q;
  cin >> n >> q;
  rep(i,n-1){
    ll a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,q){
    ll p,x;
    cin >> p >> x;
    p--;
    ans[p]+=x;
  }
  dfs(0);
  rep(i,n){
    cout << ans[i] << endl;
  }
}

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

using namespace std;

int main() {
    int k, s;
    cin >> k >> s;
    int count = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n, cc;
int d[35][100005];
int res[100005];
int sum[35][100005];

int main(){
	scanf("%d %d ", &n, &cc);
	int s, t, c;
	int end = -1;
	FORI(0,n) {
		scanf("%d %d %d ", &s, &t, &c);
		d[c - 1][s - 1]++;
		d[c - 1][t]--;
	}
	FORI(0, cc) {
		FORJ(1, 100001) {
			d[i][j] += d[i][j - 1];
			if (d[i][j] > 0)
				sum[i][j] = 1;
		}
	}
	FORI(0, cc) {
		FORJ(0, 100001) {
			if(d[i][j]>0)
				sum[i][j] = 1;
		}
	}
	FORI(0, cc) {
		FORJ(0, 100001) {
			res[j] += sum[i][j];
		}
	}

	int ans = -1;
	FORI(0, 100001) {
		ans = max(ans, res[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 26880
#include <stdio.h>
typedef struct{
  char mark[2];
  int value;
  int moji;
} Card;

int partition(Card*, int, int);
void quickSort(Card*,int ,int);


int main(){
  Card A[100001];
   int n,i,stb = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s %d",A[i].mark, &A[i].value);
    A[i].moji = i + 1;
  }
 
 quickSort(A, 0, n - 1);

  for(i = 0; i < n; i++){
     if(A[i].moji > A[i + 1].moji && A[i].value == A[i + 1].value){
      stb++;
      break;
    }
   }
   if(stb == 0) {
     printf("Stable\n");
   }
   else { 
     printf("Not stable\n");
   }  
   for(i = 0; i < n; i++) {
     printf("%s %d\n",A[i].mark, A[i].value);
   }  
   return 0;
  
  
}
void quickSort(Card *A,int p,int r){
  
  int q;
  if (p < r){
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
  
  

  
}

int partition(Card *A,int p,int r){
  int i, j, a;
  Card x;
  
  a = A[r].value;
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j].value <= a){
      i++;
      x = A[i];
      A[i] = A[j];
      A[j] = x;
    }
  }
  x = A[i + 1];
  A[i + 1] = A[r];
  A[r] = x;
  
  return i + 1;
}

Measured memory_bytes: 1780
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int p[200010];
double e[200010];
double sum[200010];
int main() 
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		e[i] += ((double)p[i] * (p[i] + 1) / 2) / p[i];
		//cout << e[i] << endl;
	}
	for (int i = 1; i <= N; i++) {
		sum[i] = sum[i - 1] + e[i - 1];
		//cout << sum[i] << endl;
	}
	double ans = 0;
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, sum[i + K] - sum[i]);
	}
	printf("%.7f\n", ans);
}

Measured memory_bytes: 4096
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e11;
const long double PI = (acos(-1));


signed main() {
	int K, A, B;
	cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;


int main() {

    int n;
    cin >> n;

    map<int, int> odd;
    map<int, int> even;

    rep(i, n) {
        int v;
        cin >> v;
        if (i % 2 == 0) {
            even[v]++;
        } else {
            odd[v]++;
        }
    }

    vector<P> odd_sort;
    vector<P> even_sort;

    for (auto p : odd) {
        P np(p.second, p.first);
        odd_sort.push_back(np);
    }
    odd_sort.push_back(P(0, 0));
    sort(odd_sort.rbegin(), odd_sort.rend());

    for (auto p : even) {
        P np(p.second, p.first);
        even_sort.push_back(np);
    }
    even_sort.push_back(P(0, 0));
    sort(even_sort.rbegin(), even_sort.rend());

    if (even_sort[0] == odd_sort[0]) {

        int ans;
        {
            // oddの一番とevenの二番を使う場合
            int odd_change = (n / 2) - odd_sort[0].first;
            int even_change = (n / 2) - even_sort[1].first;
            ans = odd_change + even_change;
        }
        {
            // oddの二番とevenの一番を使う場合
            int odd_change = (n / 2) - odd_sort[1].first;
            int even_change = (n / 2) - even_sort[0].first;
            ans = min(ans, odd_change + even_change);
        }

        cout << ans << endl;
    } else {
        int odd_change = (n / 2) - odd_sort[0].first;
        int even_change = (n / 2) - even_sort[0].first;
        int ans = odd_change + even_change;
        cout << ans << endl;
    }

}


Measured memory_bytes: 6136
#!/usr/bin/env python3
import sys
from itertools import product, permutations

MOD = 1000000007  # type: int

def solve(N: int):
    f = lambda : {c:{cc:{ccc:0 for ccc in 'ACGT'} for cc in 'ACGT'} for c in 'ACGT'}
    dp = [f() for _ in range(N+2)]
    ng = set(map(tuple, ('AGC', 'ACG', 'GAC', #.XXX, XXX.
                         'AAGC', 'AGGC', 'ACGC', 'ATGC', #A.GC
                         'AGAC', 'AGCC', 'AGGC', 'AGTC', #AG.C
                     )))
    for a, b, c in product('ACGT', repeat=3):
        if (a, b, c) in ng:
                continue
        dp[2][a][b][c] = (dp[2][a][b][c] + 1) % MOD
    for i in range(2, N):
        for a, b, c, d in product('ACGT', repeat=4):
            if (a, b, c, d) in ng or (a, b, c) in ng or (b, c, d) in ng:
                continue
            dp[i][b][c][d] = (dp[i][b][c][d] + dp[i-1][a][b][c]) % MOD
    return sum(sum(sum(dd.values()) for dd in d.values()) for d in dp[N-1].values()) % MOD

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::vector<int>G[100010];
int SG[100010];
void dfs(int x,int fa=-1){for(int i:G[x])if(i!=fa)dfs(i,x),SG[x]^=SG[i]+1;}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),x,y;
	for(int i=1;i<n;++i)x=gi(),y=gi(),G[x].push_back(y),G[y].push_back(x);
	dfs(1);
	if(SG[1])puts("Alice");
	else puts("Bob");
	return 0;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    // fastio
    ll t,n,m,i,j,k,l,x,y,z,a,b,c,d,e,p,nl,np,q,r,s;
    string str,str1;
    t=1;
    while(t--)
    {
          cin>>n;
          s=0;
          for(int i=1;i<=n;i++)
          {
              if(i%3!=0 && i%5!=0)
              {
              	s+=i;
              }
          }

          cout<<s<<endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//https://atcoder.jp/contests/tenka1-2019/tasks/tenka1_2019_c
int N;
string S;

long long solve() {
    N = S.size();
    vector<int> whsum(N+1, 0);
    vector<int> blsum(N+1, 0);
    for (int i = 0; i < N; ++i) {
        whsum[i+1] = whsum[i] + (S[i] == '.' ? 1 : 0);
        blsum[i+1] = blsum[i] + (S[i] == '#' ? 1 : 0);
    }
    
    long long res = 1LL<<60;
    for (int left = 0; left <= N; ++left) {
        long long tmp = 0;
        // left を全部白に
        tmp += blsum[left] - blsum[0];
        
        // right を全部黒に
        tmp += whsum[N] - whsum[left];
        
        chmin(res, tmp);
    }
    return res;
}


int main() {
    cin >> N >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 2180
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    string s,t;
    cin >> s >> t;

    int l = t.size();
    string ss = t.erase(l-1);

    if(s==ss){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3572