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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;
using edge = struct { int to; double cost;}; // edge x = {to, cost}

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1<<29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  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 >> 1);
    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;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
  for(int len = 1; len <= n; ++len) {
    for(int l = 0; l < n-len+1; ++l) {
      int r= l+len;
      if((n-len)%2==0) dp[l][r] = max(dp[l+1][r]+a[l], dp[l][r-1]+a[r-1]);
      else dp[l][r] = min(dp[l+1][r]-a[l], dp[l][r-1]-a[r-1]);
    }
  }
  cout << dp[0][n] << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int k;
  cin>>k;
  string s;
  cin>>s;
  int n=s.size();
  if(n>k){
    cout<<s.substr(0,k)<<"..."<<endl;
  }
  else
    cout<<s<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N;
  cin>>N;
  string S;
  cin>>S;
  vector<ll> Cou(200010, 0);
  for(ll i=1; i<=N; i++){
    ll j=i;
    ll cou=0;
    while(j>0){
      if(j%2)cou++;
      j/=2;
    }
    ll k=i%cou;
    Cou[i]=Cou[k]+1;
  }
  ll Cnt=0;
  rep(i, N){
    if(S.at(i)=='1')Cnt++;
  }
  if(Cnt==0){
    rep(i, N)cout<<1<<endl;
    return 0;
  }
  if(Cnt==1){
    if(S.at(N-1)=='1'){
      rep(i, N-1)cout<<2<<endl;
      cout<<0<<endl;
      return 0;
    }
    else{
      rep(i,N-1){
        if(S.at(i)=='1'){
          cout<<0<<endl;
        }
        else{
          cout<<1<<endl;
        }
      }
      cout<<2<<endl;
      return 0;        
      }
  }
  ll Inc=0;
  ll Dec=0;
  ll In=1;
  ll Dn=1;
  vector<ll> InV(N+10, 0);
  vector<ll> DcV(N+10, 0);
  rep(i, N){
    if(S.at(N-1-i)=='1'){
      Inc+=In;
      Dec+=Dn;
    }
    InV[N-1-i]=In;
    DcV[N-1-i]=Dn;
    In*=2;
    In%=(Cnt+1);
    Dn*=2;
    Dn%=(Cnt-1);
    Inc%=(Cnt+1);
    Dec%=(Cnt-1);
  }
  
  //cout<<Cnt<<endl;
  //rep(i, N){
    //cout<<InV[i]<<" "<<DcV[i]<<endl;
  //}
  //cout<<Inc<<endl;
  //cout<<Dec<<endl;
  //cout<<endl;
  rep(i, N){
    if(S.at(i)=='1'){
      ll Num=Dec-DcV[i]+(Cnt-1);
      Num%=(Cnt-1);
      cout<<Cou[Num]+1<<endl;
    }
    else{
      ll Num=Inc+InV[i];
      Num%=(Cnt+1);
      cout<<Cou[Num]+1<<endl;
    }
  }

} 

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

int main(){
  int k;
  cin >> k;
  if(k == 1) cout << 1 << endl;
  if(k == 2) cout << 1 << endl;
  if(k == 3) cout << 1 << endl;
  if(k == 4) cout << 2 << endl;
  if(k == 5) cout << 1 << endl;
  if(k == 6) cout << 2 << endl;
  if(k == 7) cout << 1 << endl;
  if(k == 8) cout << 5 << endl;
  if(k == 9) cout << 2 << endl;
  if(k == 10) cout << 2 << endl;
  if(k == 11) cout << 1 << endl;
  if(k == 12) cout << 5 << endl;
  if(k == 13) cout << 1 << endl;
  if(k == 14) cout << 2 << endl;
  if(k == 15) cout << 1 << endl;
  if(k == 16) cout << 14 << endl;
  if(k == 17) cout << 1 << endl;
  if(k == 18) cout << 5 << endl;
  if(k == 19) cout << 1 << endl;
  if(k == 20) cout << 5 << endl;
  if(k == 21) cout << 2 << endl;
  if(k == 22) cout << 2 << endl;
  if(k == 23) cout << 1 << endl;
  if(k == 24) cout << 15 << endl;
  if(k == 25) cout << 2 << endl;
  if(k == 26) cout << 2 << endl;
  if(k == 27) cout << 5 << endl;
  if(k == 28) cout << 4 << endl;
  if(k == 29) cout << 1 << endl;
  if(k == 30) cout << 4 << endl;
  if(k == 31) cout << 1 << endl;
  if(k == 32) cout << 51 << endl;
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    map<int,bool> paper;
    for(int i=0;i<n;i++){
        int num;
        cin >> num;
        if(paper.count(num)) paper.erase(num);
        else paper[num] = true;
    }

    int count = 0;
    for(auto p: paper) count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4864
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

#[derive(Clone)]
struct Edge<T: Clone> {
    to: usize,
    cap: T,
    rev: usize,
}

pub struct Graph<T: Clone> {
    edges: Vec<Vec<Edge<T>>>,
}

impl<T: Clone> Graph<T> {
    pub fn new(n: usize) -> Self {
        Graph {
            edges: vec![Vec::new(); n],
        }
    }
}

impl Graph<i64> {

    pub fn add_edge(&mut self, from: usize, to: usize, cap: i64) {
        let flen = self.edges[from].len();
        let tlen = self.edges[to].len();
        self.edges[from].push(Edge { to, cap, rev: tlen });
        self.edges[to].push(Edge { to: from, cap: 0, rev: flen });
    }

    fn dfs(&mut self, v: usize, t: usize, f: i64, used: &mut Vec<bool>) -> i64 {
        if v == t {
            return f;
        }
        used[v] = true;
        for i in 0..self.edges[v].len() {
            let eto = self.edges[v][i].to;
            let ecap = self.edges[v][i].cap;
            let erev = self.edges[v][i].rev;
            if !used[eto] && ecap > 0 {
                let d = self.dfs(eto, t, std::cmp::min(f, ecap), used);
                if d > 0 {
                    self.edges[v][i].cap -= d;
                    self.edges[eto][erev].cap += d;
                    return d;
                }
            }
        }
        0
    }

    pub fn max_flow(&mut self, s: usize, t: usize, inf: i64) -> i64 {
        let mut flow = 0;
        let mut used = vec![false; self.edges.len()];
        loop {
            used.iter_mut().for_each(|x| *x = false);
            let f = self.dfs(s, t, inf, &mut used);
            if f == 0 {
                return flow;
            }
            flow += f;
        }
    }
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let mut red = Vec::with_capacity(n);
    let mut blue = Vec::with_capacity(n);
    for i in 0..n {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let a = line[0];
        let b = line[1];
        red.push((a, b));
    }
    for i in 0..n {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let c = line[0];
        let d = line[1];
        blue.push((c, d));
    }
    let mut graph = Graph::new(2*n + 2);
    for i in 0..n {
        for j in 0..n {
            if red[i].0 < blue[j].0 && red[i].1 < blue[j].1 {
                graph.add_edge(i, j+n, 1);
            }
        }
    }
    for i in 0..n {
        graph.add_edge(2*n, i, 1);
        graph.add_edge(n + i, 2*n + 1, 1);
    }

    println!("{}", graph.max_flow(2*n, 2*n+1, 1_000_000));
}


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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define int long long
const int inf = 2e9;


void solve(int ci)
{
    string s;
    cin >> s;
    int n = s.size();
    string ans;
    int am = 0, pr = 0;
    char c[2];
    c[0] = 'D', c[1] = 'P';
    f(n)
    {
        if(s[i] == '?') ans += 'D';
        else ans += s[i];
    }
    cout << ans;

}

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    //cin >> t;
    f(t) solve(i + 1);
}


Measured memory_bytes: 3856
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int n,a[310][310];
ll ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int mi=2147483647;
			for(int k=1;k<=n;k++)
				if(k!=i&&k!=j) mi=min(mi,a[i][k]+a[j][k]);
			if(mi>a[i][j]) ans+=a[i][j];
			if(mi<a[i][j]) {printf("-1"); return 0;}			
		}			
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

void heapnew(int a[],int l){
    int k;
    if(l<=1){return;}
    if(a[l-1]>a[l/2-1]){
        k=a[l-1];a[l-1]=a[l/2-1];a[l/2-1]=k;
        heapnew(a,l/2);
    }
}

void insert(int a[],int n,int k){
    a[n]=k;n++;
    heapnew(a,n);
}

void heap(int a[],int i,int n){
    int max,k,l;
    if(i*2>n){
        return;
    }
    max = a[i-1];k=i;
    if(max<a[i*2-1]){
        max=a[i*2-1];k=i*2;
    }
    if(i*2+1<=n&&max<a[i*2]){
        max=a[i*2];k=i*2+1;
    }
    if(k!=i){
        l=a[i-1];a[i-1]=a[k-1];a[k-1]=l;
        heap(a,k,n);
    }
}

int main(void){
    int n,x;
    int a[2000000];
    char str[8];
    n=0;
    while(1){
         scanf("%s",str);
        if(str[0]=='e'&&str[1]=='n'){
            break;
        }else if(str[0]=='e'&&str[1]=='x'){
            printf("%d\n",a[0]);
            a[0]=a[n-1];n--;
            heap(a,1,n);
        }else{
            scanf("%d",&x);
            insert(a,n,x);
            n++;
        }
    }
}


Measured memory_bytes: 5700
var a,b:int64;

procedure hoge(var x:int64;p:int64);
begin
  case p of
  1: x:=1;
  2: x:=x+1;
  3: x:=0;
  end
end;

begin
  readln(a,b);
  hoge(b,b mod 4);
  if a = 0 then writeln(b) else begin
    a:=a-1;
    hoge(a,a mod 4);
    writeln(a xor b)
  end
end.

Measured memory_bytes: 128
using System;
using System.Linq;

public class Hello{
    public static void Main(){
        int kosu=int.Parse(Console.ReadLine());
        int [] str=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(string.Join(" ", str));
        
        for(int i=1;i<kosu;i++)
        {
            for(int j=i-1;j>=0;j--)
            {
                if(str[j+1]<str[j])
                {
                    int a=str[j];
                    str[j]=str[j+1];
                    str[j+1]=a;
                }
            }
            Console.WriteLine(string.Join(" ", str));
        }
    }
}



Measured memory_bytes: 16292
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll d[n];
    for(ll i=0;i<n;i++){
        cin>>d[i];
    }
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
    while(u != NIL && k != u->key){
        if(k < u->key){
            u = u->left;
        }else{
            u = u-> right;
        }
    }
    return u;

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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

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

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

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

void preorder(Node u){
    if(u == NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

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

  return 0;
}


Measured memory_bytes: 21308
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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



int main(){

	int h, w;
	cin >> h >> w;
    char s[110][110];

    for(int i=0; i<=h+1; i++){
    	for(int j=0; j<=w+1; j++){
            if(i==0 || j==0) s[i][j] = '#';
            else if(i == h+1 || j== w+1) s[i][j] = '#';
            else{
                cin >> s[i][j];
            }
        }
	}

	for(int i=0; i<=h+1; i++){
    	for(int j=0; j<=w+1; j++){
			cout << s[i][j];
		}
		cout << endl;
	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long int
#define pb push_back
#define fs first
#define se second

void solve()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    
    ll arr[n][3];
    
    for(ll i=0;i<n;i++)cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    
    ll dp[n][3];
    
    memset(dp,0,sizeof(dp));
    
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    
    for(ll i=1;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
                        if(dp[i-1][(j+1)%3] > dp[i-1][(j+2)%3])
                        {
                               dp[i][j]+= dp[i-1][(j+1)%3]+arr[i][j];
                        }
                        else{
                                dp[i][j]+=dp[i-1][(j+2)%3]+arr[i][j];
                        }

        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;    
}

int main()
{
    int t = 1;
    for(int i=0;i<t;i++)solve();
}
    



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi l(n);
	rep(i,n)cin>>l[i];
	int ans=0;
	sort(all(l));
	rep(i,n)FOR(j,i+1,n-1)FOR(k,j+1,n-1){
		if(l[i]==l[j]||l[j]==l[k]||l[k]==l[i]) continue;
		if(abs(l[i]-l[j])<l[k]&&l[k]<l[i]+l[j]) ans++;

	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
int main(){
  int N; cin>>N;
  vvi F(N,vi(10)),P(N,vi(11));
  rep(i,N) rep(j,10) cin>>F[i][j];
  rep(i,N) rep(j,11) cin>>P[i][j];
  ll ans = -1e9;
  for(int i=1;i<(1<<10);i++){
    ll bene = 0;
    rep(j,N){
      int cnt = 0;
      rep(k,10) if(i & (1<<k) && F[j][k]) cnt++;
      bene += P[j][cnt];
    }
    ans = max(ans,bene);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int block = 1;
    REP(i, 0, n - 1) {
        if (s[i] != s[i + 1]) {
            block++;
        }
    }
    REP(i, 0, k) {
        block = max(1, block - 2);
    }
    cout << n - block << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,counter;
ll res,temp;
map < ll , ll > m;
priority_queue < ll > heap;

int main(){
	cin >> n;
	for(int i =0;i<n;i++){
		cin >> temp;	
		m[temp]++;
	}
	res = 0;
	for(auto& i : m){
		if(i.second < 2)
			continue;
		heap.push(i.first);
		if(i.second >= 4){
			res = max(res , i.first * i.first);
		}
	}
	if(heap.size() > 1){
		ll a = heap.top();
		heap.pop();
		ll b = heap.top();
		res = max(res , a*b);
		
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> M;
	vector<int>A(M);
	vector<int>match = { 0,2,5,5,4,5,6,3,7,6 };
	for (int i = 0; i < M; i++)cin >> A[i];
	vector<string>dp(N + 1,"0");
	dp[0] = "";
	for (int i = 1; i <= N; i++) {
		for (int j : A) {
			if (i - match[j] >= 0) {
				if (dp[i - match[j]] == "0") continue;
				string tmp = dp[i - match[j]];
				tmp.push_back('0' + j);
				if (dp[i].size() < tmp.size())dp[i] = tmp;
				else if (dp[i].size() == tmp.size())dp[i] = max(dp[i], tmp);
			}
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 41472
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef long long ll;

int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int now=abs(b-a);
    now--;
    if(now%2)
        printf("Alice\n");
    else
        printf("Borys\n");

    //main();

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	in := nextString()
	a := make([]int, len(in))
	last := "1"
	ind := 0
	for i := 0; i < len(in); i++ {
		c := string(in[i])
		if last != c {
			ind++
			last = c
		}
		a[ind]++
	}
	sum := 0
	max := 0
	for i := 0; i < n; i++ {
		sum += a[i]
		if i > k*2 {
			sum -= a[i-k*2-1]
		}
		if i%2 == 0 && max < sum {
			max = sum
		}
	}
	_, _ = fmt.Fprintf(writer, "%d\n", max)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 2176
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r] % self.mod
        return ret


N = int(input())
F = FactMod(N+1, 10**9+7)
print(F.fact(N))


Measured memory_bytes: 11052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    ll N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N){
        cin >> A[i];
        A[i]--;
    }
    map<ll, vector<ll> > mp;
    ll sum[N+1], ans = 0;
    sum[0] = 0;
    rep(i, N){
        sum[i+1] = (sum[i]+A[i])%K;
    }
    rep(i, N+1){
        if(!mp.count(sum[i])){
            vector<ll> v;
            v.push_back(i);
            mp[sum[i]] = v;
        }
        else mp[sum[i]].push_back(i); 
    }
    map<ll, vector<ll> >::iterator ite;;
    ite = mp.begin();
    rep(i, mp.size()){
        vector<ll>  vec = ite->second;
        ll n = vec.size();
        ll pos = 0;
        rep(j, n){
            while(pos+1 < n && vec[pos+1] < vec[j]+K) pos++;
            ans += pos-j;
        }
        ite++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 25216
// F

#include <bits/stdc++.h>

using namespace std;

#define ge getchar()
#define Re read()

inline int read() {
	int x = 0, ch;
	while(!isdigit(ch = ge)) ;
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = ge;
	return x;
}

template<typename T>
inline void chkmax(T&a, T b) { a = a > b ? a : b; }
template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

int res[3001];
int A[3001];
int B[3001];
int C[3001];
int len;
int p;

inline int ksm(int x, int k) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % p;
		x = 1LL * x * x % p; k >>= 1;
	} return s;
}

inline void Add(int a[], int b[], int m) {
	for(int i = 0; i < p; i++)
		a[i] = (a[i] + b[i] * m) % p;
}

inline void Div(int a[], int b[], int v) {
	int rt = 0;
	for(int i = len - 1; i; i--) {
		int ml = rt + a[i]; b[i - 1] = ml;
		a[i - 1] = (a[i - 1] + v * ml) % p;
	}
}

int main() {
	p = Re; A[1] = 1, len = 2;
	for(int i = 1; i < p; i++) {
		for(int j = len; j >= 1; j--) {
			A[j] = (-A[j] * i % p + p + A[j - 1]) % p;
		} ++len;
	}
	for(int i = 0; i < p; i++) {
		int a = Re, mul = 1;
		if(!a) continue;
		for(int j = 0; j < p; j++)
			if(i != j) mul = mul * (i - j + p) % p;
		mul = ksm(mul, p - 2);
		memcpy(C, A, sizeof(A));
		// for(int j = 0; j <= p; j++) cout << C[j] << ' '; cout << endl;
		Div(C, B, i);
		// for(int j = 0; j < p; j++) cout << B[j] << ' '; cout << endl;
		Add(res, B, mul);
	}
	for(int i = 0; i < p; i++) printf("%d ", res[i]); puts("");
	return 0;
}

Measured memory_bytes: 384
n = int(input())

data = list(map(int,input().split()))

ans = 1

for i in range(0,n):
    if data[i] == 0:
        ans = 0

for i in range(0,n):

    ans *= data[i]

    if ans > 10**18:
        
        ans = -1
        break
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<ll> A(n+1),B(n);
  for(int i=0;i<n+1;i++) cin >> A.at(i);
  for(int i=0;i<n;i++) cin >> B.at(i);

  ll ans=0ll;
  for(int i=0;i<n;i++){
    if(A.at(i)<=B.at(i)) {
      ans += A.at(i);B.at(i) -= A.at(i);A.at(i)=0ll;
      if(A.at(i+1)<=B.at(i)){
        ans += A.at(i+1);B.at(i) -= A.at(i+1);A.at(i+1)=0ll;
      }
      else{
        ans += B.at(i);A.at(i+1) -= B.at(i);B.at(i) = 0ll;
      }
    }
    else{
      ans += B.at(i);A.at(i) -= B.at(i);B.at(i) = 0ll;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
N, M = [int(i) for i in input().split()]
r = []
for i in range(M):
    a, b = [int(i) for i in input().split()]
    r.append([a, b])

r.sort()
i_l = r[0][0]
i_r = r[0][1]
cnt = 1
for i in range(1, M):
    if r[i][0] < i_r:
        i_r = min(i_r, r[i][1])
    else:
        cnt += 1
        i_l = r[i][0]
        i_r = r[i][1]
print(cnt)

Measured memory_bytes: 20172
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n==1) System.out.println(0);
        else if (n==0) System.out.println(1);
        sc.close();
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

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

L = list(map(int, input().split()))
ans = 0
a = 0
b = 0
c = 0
for i in range(N):
  a = L[i]
  for j in range(i,N):
    b = L[j]
    for k in range(j,N):
      c = L[k]
      if a != b and a != c and b != c:
        if max(a,b,c) < a + b + c - max(a,b,c):
          ans += 1
print(ans)
    

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

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			string s = cin.Next();
			string ans = "";
            for (int i = 0; i < s.Length; i++)
            {
				if (s[i] == 'B')
				{
					if (ans.Length > 0) ans = ans.Substring(0, ans.Length - 1);
				}
				else ans = ans + s[i];
            }
            Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;
int main()
{
   
    int n;
    cin >> n ;

    vector<int>p(n);

    for (int i = 0; i < n; i++)cin >> p[i];
    int ans = 0;

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

    
    cout << ans << endl;
    
    

    return 0;

}


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

int main()
{
   int r , g ,b;
   cin >> r >> g >> b;
   int total = r * 100 + g * 10 + b;
   if( total % 4 == 0){
       cout << "YES" << endl;
   }else{
       cout << "NO" << endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;

int n, A, B, C;
vector<int> l;
int dfs(int depth,int a,int b,int c){
  if(depth == n){
    if(a==0||b==0||c==0) return INF;
    else return  abs(a-A)+abs(b-B)+abs(c-C)-30;
  }
  int r0,r1,r2,r3;
      r0=dfs(depth+1,a,b,c);
      r1=dfs(depth+1,a+l[depth],b,c)+10;
      r2=dfs(depth+1,a,b+l[depth],c)+10;
      r3=dfs(depth+1,a,b,c+l[depth])+10;
      return min({r0,r1,r2,r3});
}
int main() {
  cin >> n >> A >> B >> C;
  l.resize(n);
  rep(i,n) cin >> l[i];
  cout << dfs(0,0,0,0) << endl;
  return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  int x[N + 1][N + 1];
  REP(i, N + 1) REP(j, N + 1) x[i][j] = 0;
  REP(i, M) {
    int L, R;
    cin >> L >> R;
    x[L][R]++;
  }
  int c[N + 1][N + 1];  // c[i][j] := x[i][1] + x[i][2] + ... + x[i][j]
  REP(i, N + 1) REP(j, N + 1) c[i][j] = 0;
  REP1(i, N) REP1(j, N) c[i][j] = c[i][j - 1] + x[i][j];
  REP(i, Q) {
    int p, q;
    cin >> p >> q;
    int ans = 0;
    for (int j = p; j <= q; ++j) ans += c[j][q] - c[j][p - 1];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<string> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  a.erase(unique(all(a)), a.end());
  cout << a.size() << endl;
  return 0;
}

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); (i)++)

int N;
int M;

vector<i64> X[3];

int main() {
  cin >> N;
  cin >> M;
  X[0].resize(N);
  X[1].resize(N);
  X[2].resize(N);

  rep(i, 0, N - 1) cin >> X[0][i] >> X[1][i] >> X[2][i];

  vector<int> p = {0,1,2};
  int a[] = {1,-1};
  using P2 = pair<int,pair<int,int>>;
  i64 ans = 0;
  {

    rep(x,0,1)rep(y,0,1)rep(z,0,1){
      vector<i64> v;
      rep(i, 0, N - 1) { v.push_back(a[x] * X[p[0]][i] + a[y] * X[p[1]][i] + a[z] * X[p[2]][i]); }

      sort(v.rbegin(), v.rend());

      i64 A = 0;
      i64 B = 0;
      i64 C = 0;
      rep(i,0,M - 1){
        A += v[i];
      }
      ans = max(ans , abs(A));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int N, *a;
int ave=0;
void input(){
    scanf("%d",&N);
    a=(int*)malloc(N);
    int i;
    for(i=0;i<N;i++){
        scanf("%d", &a[i]);
        ave+=a[i];
    }
    ave=ave/N;
}
int main(){
    int i, cost1=0, cost2=0;
    input();
    for(i=0; i<N;i++) cost1+=(a[i]-ave)*(a[i]-ave);
    for(i=0; i<N;i++) cost2+=(a[i]-ave-1)*(a[i]-ave-1);
    if(cost1<cost2) printf("%d\n",cost1);
    else printf("%d\n",cost2);
    
    return 0;
}

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

int main() {
  int n, m, x;
  std::cin >> n >> m >> x;
  std::vector <int> c(n);
  std::vector <std::vector <int> > a(n, std::vector<int>(m));
  for (int i = 0; i < n; ++i) {
    std::cin >> c[i];
    for (int j = 0; j < m; ++j) {
      std::cin >> a[i][j];
    }
  }
  int best = -1;
  for (int p = 0; p < (1 << n); ++p) {
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      int s = 0;
      for (int i = 0; i < n; ++i) {
        if ((p >> i) & 1) {
          s += a[i][j];
        }
      }
      if (s < x) {
        ok = false;
      }
    }
    if (!ok) {
      continue;
    }
    int cur = 0;
    for (int i = 0; i < n; ++i) {
      if ((p >> i) & 1) {
        cur += c[i];
      }
    }
    if (best == -1 || cur < best) {
      best = cur;
    }
  }
  std::cout << best << std::endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();


		if(a<=x && x <= a+b) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}


	}

	public static int res(int n) {
		if(n==1) {
			return 1;
		}

		return n+res(n-1);
	}
}




Measured memory_bytes: 21972
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int score=0;
		int runner=0;
		for(int j=0;j<3;){
			string s;
			cin>>s;
			if(s=="HIT"){
				if(runner==3)
					score++;
				else
					runner++;
			}
			else if(s=="HOMERUN"){
				score+=runner+1;
				runner=0;
			}
			else
				j++;
		}
		cout<<score<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    
    string s;cin>>s;
    string t="ATCG";
    string ans="TAGC";
    rep(i,0,3){
        if(t[i]==s[0]){
            cout<<ans[i]<<endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,y;
	cin>>x>>y;
	int f=0;
	for(ll i=0;i<=x;i++){
		if(i*2+4*(x-i)==y)
			f=1;
		if((x-i)*2+i*4==y)
			f=1;
	}
	if(f==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ABC = sc.nextLine().split(" ");
        String A = ABC[0];
        String B = ABC[1];
        String C = ABC[2];

        boolean isAB = A.charAt(A.length() - 1) == B.charAt(0);
        boolean isBC = B.charAt(B.length() - 1) == C.charAt(0);
        if (isAB && isBC) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

int main(void){
  int n,m; cin >> n >> m;
  int h[n],a[m],b[m];
  rep(i,n) cin >> h[i];
  rep(i,m) cin >> a[i] >> b[i];
  int good[n]; //いい展望台の数
  rep(i,n) good[i] = 1;
  rep(i,m){
    if(h[a[i]-1] > h[b[i]-1]){
      good[b[i]-1] = 0;
    }
    else if(h[a[i]-1] < h[b[i]-1]){
      good[a[i]-1] = 0;
    }
    else{
      good[a[i]-1] = 0;
      good[b[i]-1] = 0;
    }
  }
  int ans = 0;
  rep(i,n){
    if(good[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    lli n;
    cin>>n;
    vector<lli>a(n);
    frr(i,n)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    vector<pair<lli,pair<lli,lli>>>s;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(i!=j)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(j!=k)
                    {
                        lli v[3];
                        v[0]=a[i];
                        v[1]=a[j];
                        v[2]=a[k];
                        //sort(v,v+3);
                        if(v[0]+v[1]>v[2] and v[0]!=v[1] and v[1]!=v[2] and v[2]!=v[0])
                        s.pb({v[0],{v[1],v[2]}});
                    }
                }
            }

        }
    }
    cout<<s.size()<<endl;
}


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

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	long double x, total1 = 0, total2 = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> x;
		total1 += ((long double)1.0/x);
	}
	total2 = (long double)1.0/total1;
	cout << setprecision(10) << fixed << total2 << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n);
    makev(a, n);
    VVI dp(n, VI(4, LLONG_MIN / 2));
    dp[0][0] = a[0];
    dp[1][0] = a[1];
    if (n % 2 == 1){
        dp[2][1] = a[2];
    }
    for(int i = 2; i < n; ++i){
        for(int j = 0; j < dp[i].size(); ++j){
            dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
        }
        if (i >= 3) {
            dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
            dp[i][2] = max(dp[i][2], dp[i - 3][1] + a[i]);
        }
        if (n % 2 == 1 && i >= 4){
            dp[i][3] = max(dp[i][3], dp[i - 4][0] + a[i]);
        }
    }
    if (n % 2 == 0){
        cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 2][0]});
    } else {
        cout << max({dp[n - 1][1], dp[n - 1][2], dp[n - 1][3], dp[n - 2][1], dp[n - 2][0], dp[n - 3][0]});
    }


    return 0;
}

Measured memory_bytes: 18788
import sys
import collections
import copy
def input(): return sys.stdin.readline().strip()
N = int(input())
sc = [[int(i) for i in input().split()] for i in range(N)]
count = [0] * N
done = [0] * N
fin = [N-1] * N
ans = 0
chk = 0
for j in range(N*(N-1)//2):
    if j >= 4000:
        chk = 1
        break
    done = [0] * N
    for i in range(N-1):
        if N-1 > count[i]:
            if done[sc[i][count[i]]-1] == 0 and done[i] == 0:
                if sc[sc[i][count[i]]-1][count[sc[i][count[i]]-1]] == i+1:
                    done[sc[i][count[i]]-1] = 1
                    done[i] = 1
                    count[sc[i][count[i]]-1] += 1
                    count[i] += 1
    if done == [0] * N:
        if count == fin:
            break
        else:
            ans = -1
            break
    ans += 1
if chk == 0:
    print(ans)
else:
    print(N*(N-1)//2)

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

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

    if(n%2 == 1){
        cout << "No" << "\n";
        return 0;
    }
    else{
        bool flag = true;
        for(int i=0; i<(n/2); ++i){
            if(s[i] != s[(n/2)+i]){
                flag = false;
            }
        }
        if(flag){
            cout << "Yes" << "\n";
        }
        else{
            cout << "No" << "\n";
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <map>
#include <list>
#include <stack>
#define lar(a, b) ((a>b) ? (a):(b))
#define sml(a, b) ((a<b) ? (a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> p;

int main(void) {
    ll n, a, i, cnt[3]={0};
    cin >> n;
    for(i=0; i<n; i++) {
        cin >> a;
        if(a%4==0)
            cnt[0]++;
        else if(a%2==0)
            cnt[1]++;
        else
            cnt[2]++;
    }
    
    if(cnt[0]>=cnt[2]) {
        cout << "Yes" << endl;
        return 0;
    }else if(cnt[0]+1==cnt[2] && cnt[1]==0) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int a_weight, b_weight, c_weight, d_weight;
  std::cin >> a_weight >> b_weight >> c_weight >> d_weight;

  int left_weight = a_weight + b_weight;
  int right_weight = c_weight + d_weight;
  std::string balance;
  if (left_weight > right_weight) {
    balance = "Left";
  } else if (left_weight < right_weight) {
    balance = "Right";
  } else {
    balance = "Balanced";
  }
  std::cout << balance << std::endl;
}


Measured memory_bytes: 256