akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <map>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int N = 3e5 + 10;
vector<int> row[N], col[N];
bool cmp1(int &l, int &r)
{
    return row[l].size() > row[r].size();
}
bool cmp2(int &l, int &r)
{
    return col[l].size() > col[r].size();
}
typedef struct boom
{
    int x, y;
} boom;
boom b[N];
map<pair<int, int>, int> mp;
int rs[N], cs[N];
int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    int maxrow, maxcol;
    maxrow = maxcol = 0;
    for (int i = 1; i <= k; i++)
    {
        scanf("%d%d", &b[i].x, &b[i].y);
        mp.insert(make_pair(make_pair(b[i].x, b[i].y), 1));
        row[b[i].x].push_back(i);
        col[b[i].y].push_back(i);
        rs[b[i].x] = b[i].x;
        cs[b[i].y] = b[i].y;
    }
    sort(rs + 1, rs + n + 1, cmp1);
    sort(cs + 1, cs + m + 1, cmp2);
    int ans = row[rs[1]].size() + col[cs[1]].size();
    int flag = 0;
    for (int i = 1; i <= n;)
    {
        for (int j = 1; j <= m;)
        {
            pair<int, int> tmp = make_pair(rs[i], cs[j]);
            if (!mp.count(tmp))
            {
                flag = 1;
                break;
            }
            j++;
            if (col[cs[j]].size() < col[cs[j - 1]].size())
                break;
        }
        if (flag)
            break;
        i++;
        if (row[rs[i]].size() < row[rs[i - 1]].size())
            break;
    }

    printf("%d\n", flag == 1 ? ans : ans - 1);
    return 0;
}

Measured memory_bytes: 54768
#include<cstdio>
using namespace std;

int main() {
	int a,b;
	int i=1;
	while (true)
	{		
		scanf("%d %d",&a,&b);
		if (a == 0 && b==0) {
			break;
		}
		else
		{
			if(a<=b)
				printf("%d %d\n",a,b );
			else
				printf("%d %d\n", b, a);
		}
		
	}

	return 0;
}


Measured memory_bytes: 2544
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var score = 0;
var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  const d = next();//365
  const n = 26;
  const c = nexts(n);
  var a = xArray(-1,n);
  var ans = [];
  for(var i = 0; i < d; i++){
    var s = nexts(n);
    var t = -1e9, id = 0;
    for(var j = 0; j < n; j++){
      var u = (i-a[j])*c[j] + s[j];
      if(t < u)t = u, id = j;
    }
    ans[i] = id+1;
    a[id] = i;
    score += s[id];
    for(var j = 0; j < n; j++)score -= (i-a[j]) * c[j];
  }
  return ans.join("\n");
}

Measured memory_bytes: 33724
from collections import deque

h, w = map(int, input().split())
a = ['#' + input() + '#' for _ in range(h)]
b = ['#' * (w + 1)] * 2
r = 0
for i in range(1, h + 1):
  for j in range(1, w + 1):
    if a[i - 1][j] == '.':
      b[1: -1] = map(list, a)
      q = deque()
      b[i][j] = 0
      q.append((i, j))
      while(q):
        i, j = q.popleft()
        r = max(r, b[i][j])
        d = 0
        for i1 in range(i - 1, i + 2):
          for j1 in range(j - d, j + 2, 2):                
            if b[i1][j1] == '.':
              b[i1][j1] = b[i][j] + 1
              q.append((i1, j1))
          d ^= 1
print(r)


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

int main(){
	string S;
	cin>>S;
	
	string T;
	cin>>T;
	
	int num=0;
	for(int i=0;i<3;i++){
		if(S[i]==T[i])
			num++;
	}
	
	cout<<num<<endl;
	
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		int plus = A+B;
		int minus = A-B;
		int times = A*B;
		int ans = Math.max(plus,Math.max(minus, times));

		System.out.println(ans);

	}
}

Measured memory_bytes: 21844
A = parse(readline())
B = parse(readline())
C = parse(readline())
X = parse(readline())
counter = 0
for i in 0:A
    for j in 0:B
        for k in 0:C
            counter += 500i + 100j + 50k == X ? 1:0
        end
    end
end
print(counter)

Measured memory_bytes: 118420
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
struct query {
  int i;
  int v;
  int d;
  int c;
};
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vi a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  int q; cin >> q;
  vector<query> qlist(q);
  for (int i = 0; i < q; i++) {
    qlist[i].i = i;
    cin >> qlist[i].v >> qlist[i].d >> qlist[i].c;
    qlist[i].v--;
  }
  vvi adj(n, vi());
  for (int i = 0; i < m; i++) {
    adj[a[i]].push_back(b[i]);
    adj[b[i]].push_back(a[i]);    
  }
  vvi dp(11, vi(n, -1));
  for (int i = 0; i < q; i++) dp[10 - qlist[i].d][qlist[i].v] = qlist[i].i;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < n; j++) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (dp[i][j] != -1) {
        for(int k : adj[j]) {
          dp[i + 1][k] = max(dp[i + 1][k], dp[i][j]);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) printf("%d\n", qlist[dp[10][i]].c);
  return 0;
}


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

#define MAX 100000
#define NIL -1

void dfs(int start_point, int id, vector<int> *graph, int *color, int n){
    
    stack<int> S;
    S.push(start_point);
    color[start_point] = id;

    while(!S.empty()){
        int node = S.top(); S.pop();
        rep(i, graph[node].size()){
            int v = graph[node][i];
            if(color[v] == NIL){
                color[v] = id;
                S.push(v);
            }
        }
    }
}

void assignColor(vector<int> *graph, int *color, int n){
    int id = 1;
    rep(i, n){
        if(color[i] == NIL){
            dfs(i, id++, graph, color, n);
        }
    }
}

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> graph[MAX];
    int color[MAX];
    rep(i, n){
        color[i] = NIL;
    }

    rep(i, m){
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }

    assignColor(graph, color, n);

    int q;
    cin >> q;
    rep(i, q){
        int x, y;
        cin >> x >> y;
        if(color[x] == color[y]){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8976
s = input()
a = b = c = 0

for i in range(3):
    if s[i] == "a":
        a += 1

    elif s[i] == "b":
        b += 1

    elif s[i] == "c":
        c += 1

print("Yes" if a == b == c == 1 else "No")


Measured memory_bytes: 2940
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

dis = abs(max(A,B) - min(A,B))
velo = V - W
if velo <= 0:
    print('NO')
    exit()

if (dis/velo) <= T:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

vector<vector<int>> G(101010);
int deg[101010];

const int MAX_V=101010;

int par[MAX_V];
int rnk[MAX_V];
int num[MAX_V];

void init(){
  for(int i=0;i<MAX_V;i++){
    par[i]=i;
    rnk[i]=0;
    num[i]=1;
  }
}

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

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

  if (rnk[x] < rnk[y]){
    par[x] = y;
    num[y] += num[x];
  }else{
    par[y] = x;
    num[x] += num[y];
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

bool dfs(int v,int p){
  for(int u:G[v]){
    if(u==p) continue;
    if(dfs(u,v)){
      cout<<v<<" "<<u<<endl;
      deg[v]++;
    }
  }
  if(p!=-1){
    if(deg[v]%2){
      cout<<v<<" "<<p<<endl;
      return 0;
    }else{
      return 1;
    }
  }
  return 0;
}

int main(){
  int N,M; cin>>N>>M;
  if(M%2){
    cout<<-1<<endl;
    return 0;
  }
  init();
  rep(i,M){
    int A,B; cin>>A>>B;
    if(same(A,B)){
      cout<<A<<" "<<B<<endl;
      deg[A]++;
    }else{
      G[A].push_back(B);
      G[B].push_back(A);
      unite(A,B);
    }
  }
  dfs(1,-1);
  return 0;
}


Measured memory_bytes: 15104
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int main ()
{
	int n;
	char s[10];
	scanf("%s",&s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		if (s[i] == 'A')
		if (s[i+1] =='C') 
		{
			printf("Yes\n");
			return 0;
			}
		}
		printf("No\n");
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

ll digitsum(ll n, ll b)
{
	ll ans = 0;
	while(n)
	{
		ans += n%b;
		n /= b;
	}
	return ans;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, s;
	cin>>n>>s;
	if(s>n)
	{
		cout<<-1<<endl;
		return 0;
	}
	ll ans = -1;
	for(int i = 2; i<=sqrt(n); i++)
	{
		ll y = digitsum(n,i);
		if(y==s)
		{
			cout<<i<<endl;
			return  0;
		}
	}
	n-=s;
	ll ans2 = 1e18;
	if(n==0)
		ans2 = s+1;
	for(ll i = 1; i<=sqrt(n); i++)
	{
		if(n%i==0)
		{
			ll y = digitsum(n+s,n/i+1);
			if(y==s)
				ans2 = min(ans2,n/i+1);
		}
	}
	if(ans2<(ll)(1e18))
		cout<<ans2<<endl;
	else
		cout<<ans<<endl;
	return 0;
}


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

int main(){
  int a,b,n,t=0;
  cin >> a >> b >> n;
  int c[n*2];
  for(int i=0; i<n*2; i=i+2){
    int num,num2;
    cin >> num >> num2;
    if(num<a&&num2>a){
      t=1;
    }
    if(num<b&&num2>b){
      t=1;
    }
    if(num==a&&num2==b)t=1;
    if(a<num&&b>num2)t=1;
  }
  cout << t << endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }



int main() {
    int n;
    cin >> n;
    ll i = 0;
    while(i*(i+1)/2 < n)i++;
    if(n != i*(i+1)/2){
        puts("No");
        return 0;
    }else {
        puts("Yes");
        cout << i+1 << "\n";
    }
    auto v = make_v(i+1, i, 0);
    int p = 1, q = 1;
    for (int j = 0; j < i; ++j) {
        for (int k = 0; k < i-j; ++k) {
            v[j][k+j] = p;
            v[k+j+1][j] = p;
            p++;
        }
    }
    for (int j = 0; j < i+1; ++j) {
        printf("%d", i);
        for (int k = 0; k < i; ++k) {
            printf(" ");
            printf("%d", v[j][k]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2176
n=int(input());*a,=map(int,input().split())
if n!=2:
	b=[abs(a[0])]+[abs(i-j)for i,j in zip(a,a[1:])]+[abs(a[-1])]
	c=[abs(a[1])]+[abs(i-j)for i,j in zip(a,a[2:])]+[abs(a[-2])]
	s=sum(b)
	for i,j,k in zip(b,b[1:],c):
		print(s-i-j+k)
else:
	print(2*abs(a[1]),2*abs(a[0]))

Measured memory_bytes: 17528
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=[A,B,C,D,E]
mod=0
mx=0
for i in range(5):
    if mod<10-a[i]%10 and a[i]%10!=0:
        mx=i
        mod=10-a[i]%10
ans=0
for i in range(5):
    if i!=mx and a[i]%10!=0:
        ans+=a[i]+10-a[i]%10
    else:
        ans+=a[i]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int n, num[100005]; 

inline int fpow(int a, int b){
	long long ret = 1, tmp = a;
	while(b){
		if(b & 1) ret = ret * tmp % mod;
		b >>= 1; tmp = tmp * tmp % mod;
	}
	return (int)ret;
}

int main()
{
	int x; scanf("%d", &n);
	for(int i = 1; i <= n; ++i){scanf("%d", &x); num[x]++;}	
	if(n & 1){
		if(num[0] != 1){printf("0"); return 0;}
		for(int i = 2; i < n; i += 2)
			if(num[i] != 2){printf("0"); return 0;}
		printf("%d", fpow(2, n / 2)); return 0;
	}
	else{
		for(int i = 1; i < n; i += 2)
			if(num[i] != 2){printf("0"); return 0;}
		printf("%d", fpow(2, n / 2)); return 0;
	}
	return 0;
}

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

using namespace std;

int main() 
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long int n;
	long long int res = 1;
	set <long long int> S;
	cin >> n;
	
	long long int m = n - 1;
	
	for(long long int i=2;i<=sqrt(m);i++)
	{
		if(m%i==0)
		{
			if(i*i==m)
			{
				S.insert(i);
			}
			else
			{
				S.insert(m/i);
				S.insert(i);
			}
		}
	}
	if(m!=1)
	{
		S.insert(m);
	}
	for(long long int i=2;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			long long int a = i;
			long long int b = n/i;
			if(a==b)
			{
				long long int temp = n;
				while(1)
				{
					if(temp%a!=0)
					{
						break;
					}
					temp/=a;
				}
				temp%=a;
				if(temp==1)
				{
					S.insert(a);
				}
				temp = n;
				while(1)
				{
					if(temp%b!=0)
					{
						break;
					}
					temp/=b;
				}
				temp%=b;
				if(temp==1)
				{
					S.insert(b);
				}				
			}
			else
			{
				long long int temp = n;
				while(1)
				{
					if(temp%a!=0)
					{
						break;
					}
					temp/=a;
				}
				temp%=a;
				if(temp==1)
				{
					S.insert(a);
				}				
			}
		}
	}
	
	if(n!=1)
	{
		S.insert(n);
	}
	
	cout << S.size() << '\n';
	
	return 0;
}

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

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main() {

  int r;
  cin >> r;

  cout << 3*r*r << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def binom_tables(n, q):
	fact = [1 for _ in range(n + 1)]
	inv = [1 for _ in range(n + 1)]
	for i in range(1, n+1):
		fact[i] = (fact[i-1] * i) % q
		inv[i] = pow(fact[i], q-2, q)
	return fact, inv

def main():
	MOD = 998244353
	n, m, k = rli()
	F, I = binom_tables(n, MOD)
	
	def binom(n, k, q):
		return (F[n]*((I[k]*I[n-k])%q))%q

	ans = 0
	for i in range(n-k, n+1):
		ans += (binom(n-1, i-1, MOD)*m*pow(m-1, i-1, MOD))%MOD
	print(ans % MOD)

if __name__ == "__main__":
	main()

Measured memory_bytes: 75776
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ a + b, b + c, c + a }) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	long N,A,B;cin>>N>>A>>B;
	if((A-B)%2==0) cout<<abs(A-B)/2<<endl;
	else{
		if(A>B) swap(A,B);
		cout<<(B-A-1)/2+min(A,N+1-B)<<endl;
	}
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut map: Vec<Vec<char>> = vec![];
    let mut temp: Vec<Vec<char>> = vec![];

    for _ in 0..n {
        let row: String = read();
        let rowc: Vec<char> = row.chars().collect();
        map.push(rowc);
    }
    for _ in 0..m {
        let row: String = read();
        let rowc: Vec<char> = row.chars().collect();
        temp.push(rowc)
    }
    let mut ans = "No";

    'outermost: for i in 0..n - m + 1 {
        for j in 0..n - m + 1 {
            let mut flag = false;
            'outer: for ii in i..i + m {
                for jj in j..j + m {
                    // println!("ii{}, jj{}", ii, jj);
                    if map[ii][jj] != temp[ii - i][jj - j] {
                        flag = true;
                        break 'outer;
                    }
                }
            }

            if flag == false {
                ans = "Yes";
                break 'outermost;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// atcoder/abc159/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  str s;
  while (cin >> s) {
    const int N = s.size();
    bool f = true;

    str t = s;
    reverse(t.begin(), t.end());
    f = f && (s == t);

    str a;
    for (int i = 0; i < (N - 1) / 2; ++i) {
      a = s[i];
    }
    str b = a;
    reverse(b.begin(), b.end());
    f = f && (a == b);

    str p;
    for (int i = (N + 3) / 2 - 1; i < N; ++i) {
      p += s[i];
    }
    str q = p;
    reverse(q.begin(), q.end());
    f = f && (p == q);

    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long int
#define pb push_back
int main(){
    int a;
    cin>>a;
    pair <int, int> arr[a];
    for (int i=0; i<a; i++){
        cin>>arr[i].fi>>arr[i].se;
    }
    int cnt=0;
    for (int i=0; i<a; i++){
        if (arr[i].fi==arr[i].se){
            cnt++;
        }
        else cnt=0;
        if (cnt==3){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
public class Main {
	static String[][] boards = {
			null,
			null,
			null,
			{"aab",
			"d.b",
			"dcc"},

			{"aacd",
			"bbcd",
			"cdaa",
			"cdbb"},

			{"aaccd",
			"ijj.d",
			"i..le",
			"h..le",
			"hggff"},

			{"aabee.",
			"d.b..f",
			"dcc..f",
			"f..aab",
			"f..d.b",
			".hhdcc"},

			{"aabb..a",
			".cc..ca",
			"...ddcb",
			"a.d...b",
			"acd....",
			"bc..cc.",
			"b..aabb"}
	};
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PrintWriter pw = new PrintWriter(System.out);
		if(n < 3) {
			pw.println("-1");
			pw.flush();
		}
		else if(n == 3) {
			for(String s: boards[3]) {
				pw.println(s);
			}
			pw.flush();
		}
		else {
			char[][] res = new char[n][n];
			for(char[] s: res) Arrays.fill(s, '.');
			int k = 0;
			while(k + 7 < n) {
				for(int i = 0; i < 4; i++) {
					char[] s = boards[4][i].toCharArray();
					for(int j = 0; j < 4; j++) {
						res[k+i][k+j] = s[j];
					}
				}
				k += 4;
			}
			for(int i = 0; i < n-k; i++) {
				char[] s = boards[n-k][i].toCharArray();
				for(int j = 0; j < n-k; j++) {
					res[k+i][k+j] = s[j];
				}
			}
			for(char[] s: res) pw.println(s);
			pw.flush();
		}
	}
	

}


Measured memory_bytes: 26800
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    bool ans = false;
    rep (i, 0, 100) {
        rep (j, 0, 100) {
            if (4*i + j*7 == N)  {
                ans = true;
                break;
            }
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  pair<int, int> point(0, 0);
  int time = 0;

  bool yes = true;

  for(int i=0;i<N;i++) {
    int t, x, y;
    cin >> t >> x >> y;

    int diff = t - time;
    int dis = abs(x-point.first)+abs(y-point.second);
    if(dis > diff) {
      yes = false;
      break;
    } else if((diff-dis)%2!=0) {
      yes = false;
      break;
    }

    time = t;
    point.first = x;
    point.second = y;
  }

  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define INF 1000000007;

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

    std::map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int val;
        std::cin >> val;

        auto itr = mp.find(val);
        if(mp.end() == itr){
            mp.insert(std::make_pair(val, 1));
        }else{
            ++itr->second;
        }
    }

    bool flg = true;
    auto itr = mp.begin();
    int ref = 1 - n % 2;
    while(flg && mp.end() != itr){
        if(mp.begin() == itr){
            flg = ref == itr->first && ref + 1 == itr->second;
        }else{
            flg = ref == itr->first && 2 == itr->second;
        }
        ref += 2;
        ++itr;
    }


    long long ans = 1;
    if(flg){
        for(int i = 0; i < n / 2; ++i){
            ans *= 2;
            ans %= INF;
        }
    }else{
        ans = 0;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3200
# 誰か奇数になったら終了
# A==B==C になったら-1

A,B,C=map(int,input().split())
cnt=0
ans=0
while A%2==0 and B%2==0 and C%2==0:
    if A==B==C:
        ans=-1
        break
    else:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        cnt+=1
        ans=cnt
print(ans)

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int(a.size())
#define rep(i, s, n)  for(int i = s; i <= n; ++i)
#define rev(i, n, s)  for(int i = n; i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;


int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll a, b, c;
  cin >> a >> b >> c;
  int res = 0;
  while((!(a & 1LL)) && (!(b & 1LL)) && (!(c & 1LL))) {
    res++;
    if(res > 1e6) {
      break;
    }
    ll t1 = a, t2 = b, t3 = c;
    a = (t2 + t3) / 2 ;
    b = (t1 + t3) / 2;
    c = (t1 + t2) / 2;
  }
  if(res > 1e6) {
    res = -1;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

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

	int A, B, C; cin >> A >> B >> C;
	int rem = A - B;
	print(max((ll)0, C - rem));
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        for (int i = 0; i * 4 <= n; i++)
        {
            for (int j = 0; i * 4 + j * 7 <= n; j++)
            {
                if (i * 4 + j * 7 == n)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   ll a,b,c;
   cin>>a>>b>>c;
   if(a==(b+c))
   {
       cout<<"Yes"<<endl;
   }
   else if(b==(a+c))
   {
       cout<<"Yes"<<endl;
   }
   else if(c==(a+b))
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
N = [int(s) for s in raw_input().split(" ")][0]
H = [int(s) for s in raw_input().split(" ")]
res = 0
idx = 0
while idx < N:
    j = idx
    while j + 1 < N and H[j+1] <= H[j]:
        j += 1
    res = max(res, j-idx)
    idx = j+1
print(res)


Measured memory_bytes: 11936
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int n, s;
	static long dp[][][];

	public static long f(int cnt, int k, int sum) {
		if (0 <= dp[cnt][k][sum]) {
			return dp[cnt][k][sum];
		}
		if (cnt == n - 1) {
			if (sum + k == s) {
				return dp[cnt][k][sum] = 1;
			} else {
				return dp[cnt][k][sum] = 0;
			}
		} else {
			if (s < sum + k) {
				return dp[cnt][k][sum] = 0;
			}
			long x = 0;
			for (int i = k + 1; i <= 100; i++) {
				x += f(cnt + 1, i, sum + k);
			}
			return dp[cnt][k][sum] = x;
		}
	}

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

		while (true) {
			n = sc.nextInt();
			s = sc.nextInt();
			if ((n | s) == 0) {
				break;
			}
			dp = new long[n][110][1100];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 110; j++) {
					Arrays.fill(dp[i][j], -1);
				}
			}

			long sum = 0;
			for (int i = 0; i <= 100; i++) {
				sum += f(0, i, 0);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 117172
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int main(){
  int k, x;
  cin >> k >> x;
  for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++)
    cout << i <<' ' ;
  return 0;
}


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

int main(){
    int n, k;
    while(true){
        if(cin >> n >> k){
            if(n == 0){
                break;
            }
            int a[n], b[n];
            for(int i = 0; i < n; i++){
                cin >> a[i];
                if(i == 0){
                    b[i] = a[i];
                }else{
                    b[i] = b[i - 1] + a[i];
                }
            }
            int ans = -1073741820;
            for(int i = 0; i < n - k; i++){
                if(ans <= b[i + k] - b[i]){
                    ans = b[i + k] - b[i];
                }
            }
            cout << ans << endl;
        }else{
            break;
        }
    }
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int N;
vector<int> P;

PII dp[100][50000];
bool cmp (const PII &l, const PII &r)
{
    if (l.first == r.first) return l.second > r.second;
    return l.first < r.first;
}


PII solve(int n, int x, int sum, int num)
{
    if (n == N) return PII(0, 0);
    if (dp[n][x].first != -1) return dp[n][x];

    PII res = PII(0, INF);

    // ????????????
    res = max(res, solve(n+1, x, sum, num), cmp);

    // ?°????????????£?????????
    {
        int kozeni = (P[n] + 500) % 1000;
        if (kozeni <= x) {
            PII tmp = solve(n+1, x-kozeni, sum+P[n], num+1);
            tmp.first++;
            tmp.second += P[n];
            res = max(res, tmp, cmp);
        }
    }
    
    // ?????????????????£?????????
    {
        int kozeni = (1000 - P[n]%1000)%1000;
        int get = 0;
        if (kozeni >= 500) {
            get = 1;
            kozeni -= 500;
        }

        PII tmp = solve(n+1, x+kozeni, sum+P[n], num+get);
        tmp.first += get;
        tmp.second += P[n];
        res = max(res, tmp, cmp);
    }

    return dp[n][x] = res;
}


int main()
{
    while (cin >> N, N) {
        fill(dp[0], dp[0]+100*50000, PII(-1, -1));
        P.resize(N);
        rep(i, N) cin >> P[i];

        PII ans = solve(0, 0, 0, 0);
        cout << ans.first << " " << ans.second << endl;
    }
}

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

void solve()
{
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    ll ans = 0, ss = v.front(), mod = 1e9+7;
    for (int i = 1; i < n; ++i) {
        ans = (ans + (v[i] * ss % mod)) % mod;
        ss = (ss + v[i]) % mod;
    }
    cout << ans << '\n';
}

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

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

signed main() {
    IO;
    int ans = 0, l, r, d;
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> l;
        if((i & 1) && (l & 1)) ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  int n;
  cin >> n;
  VL a(n);
  map<ll, int> freq;
  REP(i, 0, n) {
    cin >> a[i];
    freq[a[i]] += 1;
  }
  VL pool;
  for (auto t: freq) {
    REP(i, 0, t.second / 2) {
      pool.push_back(t.first);
    }
  }
  sort(pool.rbegin(), pool.rend());
  if (pool.size() < 2) {
    cout << 0 << endl;
  } else {
    cout << pool[0] * pool[1] << endl;
  }
}


Measured memory_bytes: 7296
import numpy as np
N, T = map(int, input().split())

cost_list = np.array(list(map(int, input().split())))

max_num = 0
max_profit = 0
max_list = []
max_value = 0
for x in reversed(cost_list[1:]):
    max_value = max(max_value, x)
    max_list.append(max_value)
max_list = list(reversed(max_list))
max_list = np.array(max_list)
res = max_list - cost_list[:-1]

res_max = max(res)

max_num_list = [y for y in res if y == res_max]

print(len(max_num_list))




Measured memory_bytes: 23424
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    string s;
    cin >> s;

    if (s[s.size() - 1] == 's') {
        put(s + "es");
    }
    else {
        put(s + "s");
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3636
P = int(input())
A = []
for i in range(1, 10):
    A.append(str(i))

keta = 1
for i in range(9):
    ap = []
    for j in range(len(A)):
        a = A[j]
        if len(a)<keta:
            continue
        l = int(a[-1])
        for k in range(max(0, l-1), min(10, l+2)):
            ap.append(a+str(k))
    keta += 1
    for j in ap:
        A.append(j)
for i in range(len(A)):
    A[i] = int(A[i])
A.sort()
print(A[P-1])

Measured memory_bytes: 77476
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

ll MOD = 1000000007;



int main()
{
	int A;
	cin >> A;
	cout << A*A*A << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string N;
    cin >> N;
    N[0] += 1;
    cout << N << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
    ll a,b,c,x;
    cin>>a>>b>>c>>x;
    ll ans=0;
    for(ll i=0;i<=a;++i){
        for(ll j=0;j<=b;++j){
            for(ll k=0;k<=c;++k){
                if(500*i + 100*j + 50*k == x){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200010;
struct edge{
	int u,v,w;
}E[maxn*2];
int eid = 0;
int n,m;
namespace ufs{
	int fa[maxn],size[maxn];
	inline void init(){
		for(register int i=0;i<=n;++i) fa[i] = i,size[i] = 1;
	}
	inline int get(int x){
		if(fa[x] == x) return x;
		return fa[x] = get(fa[x]);
	}
	inline void merge(int x,int y){
		int fx = get(x),fy = get(y);
		if(fx == fy) return;
		fa[fy] = fx;
	}
}
ll dis[maxn];
inline bool cmp(const edge &a,const edge &b){
	return a.w < b.w;
}
int main(){
	scanf("%d%d",&n,&m);
	ufs::init();
	memset(dis,0x3f,sizeof dis);
	for(int i=1;i<=m;++i){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		E[++eid].u = a;
		E[eid].v = b;
		E[eid].w = c;
		dis[a] = min(dis[a],c+1ll);
		dis[b] = min(dis[b],c+2ll);
	}
	for(int i=0;i<n;i++){
		dis[i] = min(dis[i],dis[(i-1+n)%n]+2);
	}
	for(int i=0;i<n;i++){
		dis[i] = min(dis[i],dis[(i-1+n)%n]+2);
		E[++eid].u = i;
		E[eid].v = (i + 1) % n;
		E[eid].w = dis[i]; 
	}
	sort(E+1,E+eid+1,cmp);
	int tcnt = 0;
	ll ans = 0;
	for(int i=1;i<=eid;i++){
		if(tcnt == n-1) break;
		if(ufs::get(E[i].u) != ufs::get(E[i].v)){
			ans += E[i].w;
			ufs::merge(E[i].u,E[i].v);
			tcnt++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  string k="keyence",s;
  int i,j,ans=0;
  cin >> s; j=s.size()-1;
  for(i=0; i<7; i++){
    if(s[i]!=k[i]) break;
  }
  ans+=i;
  for(i=0; i<7; i++){
    if(s[j-i]!=k[6-i]) break;
  }
  ans+=i;
  if(ans>=7){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

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

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

const int MAXN = 1e5 + 10;

typedef long long i64;

i64 tmp = 0x7F7F7F7F7F7F7F7F;
i64 N, M, T;
i64 a[MAXN];
i64 dp[MAXN];

int main()
{
	//REDIRECT("computer");

	i64 t = 0;
	scanf("%lld%lld%lld", &N, &M, &T);
	for (int i = 1; i <= N; i++)
		scanf("%lld", &a[i]);

	for (int i = 1; i <= N; i++)
	{
		while (T <= (a[i] - a[t + 1]) * 2)
			tmp = std::min(tmp, dp[t] - 2 * a[t + 1]), t++;
		dp[i] = std::min(dp[t] + T, tmp + 2 * a[i]);
	}

	printf("%lld\n", dp[N] + M);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 1664
N = int(input())
Hs = list(map(int, input().split()))

"""
SEA H_1 H_2 H_3 H_4 ... H_N
"""

# 0 ~ i番目の旅館のうち最も高いもの
# max(Hs[0:i+1])

ret = 0
for i in range(N):
    if Hs[i] == max(Hs[0:i+1]):
        ret += 1

print(ret)

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

const int mod1 = 1e9 + 7;
const int mod2 = 998244353;

struct Combination
{
	using ll = int_fast64_t;

	int mod;
	vector<ll> mfact, rfact;

	Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod)
	{
		mfact[0] = 1LL;
		for (int i = 1; i < sz + 1; i++)
		{
			mfact[i] = mfact[i - 1] * i % mod;
		}

		rfact[sz] = inv(mfact[sz]);

		for (int i = sz - 1; i >= 0; i--)
		{
			rfact[i] = rfact[i + 1] * (i + 1) % mod;
		}
	}

	ll fact(int k) const
	{
		return mfact[k];
	}

	ll pow(ll x, ll n) const
	{
		ll ret = 1LL;
		while (n > 0)
		{
			if (n & 1)
				(ret *= x) %= mod;
			(x *= x) %= mod, n >>= 1;
		}
		return ret;
	}

	ll inv(ll x) const
	{
		return pow(x, mod - 2);
	}

	ll Perm(int n, int r) const
	{
		if (r < 0 || n < r)
			return 0LL;
		return mfact[n] * rfact[n - r] % mod;
	}

	ll Binom(int p, int q) const
	{
		if (q < 0 || p < q)
			return 0LL;
		return mfact[p] * rfact[q] % mod * rfact[p - q] % mod;
	}
};

int main()
{
	int K;
	string s;
	cin >> K >> s;
	ll ans = 0;
	int N = s.size();

	Combination Comb(N + K, mod1);

	for (int i = 0; i <= K; i++)
	{
		(ans += (Comb.pow(26, i) * Comb.pow(25, K - i) % mod1) * Comb.Binom(K - i + N - 1, N - 1)) %= mod1;
	}

	cout << ans << "\n";
}


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

int main(){
    string s; cin >> s;
    ll n=s.size();
    rep(i,n){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3748
def merge(A,left,mid,right):

    global cnt

    n1=mid-left
    n2=right-mid

    inf = 100000000001
    L, R = A[left:left+n1]+[inf], A[mid:mid+n2]+[inf]##今回知った書き方
    
    i=j=0
    

    for k in range(left,right):
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
        cnt+=1
        



def mergeSort(A,left,right):
    if left+1<right:
        mid =(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)


cnt=0
n=int(input())
A=[int(x) for x in input().split()]



mergeSort(A,0,n)

print(*A)
print(cnt)


Measured memory_bytes: 63428
#include<stdio.h>

#define N 100




int main(void){
	
	int n,A[N],min,temp,count;

	
	scanf("%d",&n);

	for(int i=0;i<n;i++){

		scanf("%d",&A[i]);

		}
	count = 0;
	
	for(int i=0;i<n;i++){
		
		min = i;
		
		for(int j=i;j<n;j++){
			
			if(A[j]<A[min]){
				
				min = j;
			}
		}
			if(i != min){
		
				temp =A[i];
				A[i] =A[min];
				A[min]=temp;
				
			
				count++;
			}
			
		
		}
	
			for(int i=0;i<n-1;i++){

			printf("%d ",A[i]);
			
		
		}
	
	printf("%d\n",A[n-1]);
	printf("%d\n",count);
	
	return 0;
}



	
	


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    int cnt = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            for(int k = j+1; k < N; k++){
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]){
                    continue;
                }
                int d = abs(L[i]-L[j]);
                int D = L[i]+L[j];
                if(d < L[k] && L[k] < D){
                    
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Collection;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
            Scanner sc = new Scanner(System.in);
            
            int n =sc.nextInt();
            int l =  sc.nextInt();
            String [] str = new String[n];
            
           

            int i=0;
            while (i<n)
            {
                str[i] = sc.next();
                i++;
            }
            Arrays.sort(str);
          for(i=0;i<str.length;i++)
          {
              //System.out.println(str[i]);
          }
          String str2="";
          for(i=0;i<str.length;i++)
          {
              str2 = str2 + str[i];
          }
         
          System.out.println(str2);
    }

}


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

const int MOD = 1000000007;
int N;
vector<int> adjlist[100000];
int dp[100000][2];

int dfs(int parent, int child, bool black) {
  if(dp[child][(int)black] != -1) return dp[child][(int)black];
  int d = 1;
  for(auto v : adjlist[child]) {
    if(v == parent) continue;
    d *= dfs(child, v, false) + (black ? 0 : dfs(child, v, true));
    d %= MOD;
  }
  return dp[child][(int)black] = d;
}

signed main() {
  cin >> N;
  for(int i=0; i<N-1; i++) {
    int x,y; cin >> x >> y;
    x--; y--;
    adjlist[x].push_back(y);
    adjlist[y].push_back(x);
  }
  fill(dp[0], dp[100000], -1);
  cout << (dfs(-1, 0, false) + dfs(-1, 0, true)) % MOD << endl;
}


Measured memory_bytes: 15616
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        int[] arr = new int[N];
        int max = -1;
        for (int i=0; i<N; i++){
            arr[i] = Integer.parseInt(st.nextToken());
            max = Math.max(max, arr[i]);
        }

        Arrays.sort(arr);

        boolean[] dp = new boolean[max+1];
        int[] count = new int[max+1];
        //dups
        for (int i=0; i<N; i++){
            count[arr[i]]++;
        }
        //sieve
        for (int i=0; i<N; i++){
            if (!dp[arr[i]]){
                for (int j=2; j*arr[i]<=max; j++){
                    dp[j*arr[i]]=true;
                }
            }
        }

        int ans=0;
        for (int i=0; i<N; i++){
            if (!dp[arr[i]]&&count[arr[i]]==1)
                ans++;
        }

        System.out.println(ans);


    }




}



Measured memory_bytes: 55044