akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	string S, T;

	cin >> S >> T;

	int hit = 0;

	for (long long iS = 0; iS < 3; iS++)
	{
		if (S[iS] == T[iS])
		{
			hit++;
		}
	}

	cout << hit << endl;
}


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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= k) {
      ans += x;
    } else {
      ans += y;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int x = 0, y = 0, z = 0;  // x = 1万, y = 5千, z = 千
  int N, Y;     // 合計N枚, 合計Y円

  cin >> N >> Y;

  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N; j++){
      int k = (Y - 10000*i - 5000*j)/1000;

      if(i + j + k == N && k >= 0){
        x = i;  y = j;  z = k;
      }
    }
  }

  if(x == 0 && y == 0 && z == 0){
    cout << "-1 -1 -1" << endl;
  }
  else{
    cout << x << " " << y << " " << z << endl;
  }

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	)

func main(){
	var N int
	var CMAX, DMAX int
	var Hantei bool
	fmt.Scanf("%d",&N)
	CMAX = 100 / 4
	DMAX = 100 / 7
	//fmt.Printf("CMAX:%d DMAX:%d\n",CMAX,DMAX)
	for i := 0; i < CMAX; i++ {
		for j := 0; j < DMAX; j++ {
			if i*4+j*7 == N {Hantei = true}
		}
	}
	if Hantei == false {
		fmt.Printf("%s\n","No")
	} else { 
	fmt.Printf("%s\n","Yes") 
	}
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class AParking {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(Math.min(in.nextInt() * in.nextInt(), in.nextInt()));
        }

    }
}



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

int main() {
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    int ans=0;
    for (int i=0;i<k;i++) {
        char pr=0;
        for (int j=i;j<n;j+=k) {
            if (t[j]=='r'&&pr!='p')
                ans+=p,pr='p';
            else if (t[j]=='p'&&pr!='s')
                ans+=s,pr='s';
            else if (t[j]=='s'&&pr!='r')
                ans+=r,pr='r';
            else
                pr=0;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int n;
  cin >> n;
 vector<int> a(n); 
 for(int i=0;i<n;i++){
   cin >> a.at(i);
 }
  sort(a.begin(),a.end());
  for(int i=1;i<n;i++){
  if(a.at(i-1)==a.at(i)){cout << " NO" << endl;
                        return 0;}
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int num;
  cin>>num;
  rep(i,num){
    int x,y,w,h;
    cin>>x>>y>>w>>h;
    int n;
    cin>>n;
    int ans=0;
    rep(j,n){
      int a,b;
      cin>>a>>b;
      if(0<=b-y && b-y<=h && 0<=a-x && a-x<=w)ans++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s, t;
    cin >> s >> t;
    map<char, int> ms;
    map<char, int> mt;
    int n = s.size();
    rep(i, n) {
        ms[s[i]]++;
        mt[t[i]]++;
    }
    string ans = "Yes";
    vector<int> ns;
    vector<int> nt;
    for (auto m: ms) ns.push_back(m.second);
    for (auto m: mt) nt.push_back(m.second);
    sort(whole(ns));
    sort(whole(nt));
    if (ns.size()!=nt.size()) ans = "No";
    else {
        rep(i, ns.size()) {
            if (ns[i]!=nt[i]) ans = "No";
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 776
n, m, l = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(m)]
q = int(input())
query = [list(map(int, input().split())) for _ in range(q)]

INF = 1001001001
dist = [[INF for _ in range(n)] for _ in range(n)]
for i in range(n):
    dist[i][i] = 0

for road in ls:
    dist[road[0]-1][road[1]-1] = dist[road[1]-1][road[0]-1] = road[2]

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

dist2 = [[INF for _ in range(n)] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if dist[i][j] <= l:
            dist2[i][j] = 1

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j])

for el in query:
    ans = dist2[el[0]-1][el[1]-1]-1
    if dist2[el[0]-1][el[1]-1] == INF:
        ans = -1
    print(ans)

Measured memory_bytes: 83288
#include <bits/stdc++.h>
#define MOD 1000000007
#define last last2

using namespace std;

char str[100005];
int f[100005],last[100005][3];

int main() {
  memset(last,255,sizeof(last));
  scanf("%s",str+1);
  int n=strlen(str+1);
  int nr=0;
  while (nr<n&&str[nr+1]!=str[nr]) nr++;
  int l=0,s=0;
  last[0][0]=0;
  for(int i=1;i<=n;i++) {
  	s=(s+str[i]-'a'+1)%3;
  	memcpy(last[i],last[i-1],sizeof(last[i]));
  	last[i][s]=i;
  	if (str[i]==str[i-1]) l=i-2;
  	int u=last[l][(s+2)%3],v=last[l][(s+1)%3];
  	if (str[i]=='a') u=i-1; else v=i-1;
  	if (u!=-1) {
	  f[i]=(f[i]+f[u])%MOD;
	  if (u&&nr>=u&&nr<i) f[i]=(f[i]+((u-1)>>1))%MOD;
    }
    if (v!=-1) {
	  f[i]=(f[i]+f[v])%MOD;
	  if (v&&nr>=v&&nr<i) f[i]=(f[i]+((v-1)>>1))%MOD;
	}
  	if (s&&(i==1||nr<i)) f[i]=(f[i]+1)%MOD;
  }
  printf("%d\n",f[n]);
  return 0;
}

Measured memory_bytes: 1920
n,k=map(int,input().split())
nums=[]
for i in range(n):
  nums.append(list(map(int,input().split())))
nums.sort(key=lambda x:x[0])
cnt=0
i=0
while cnt<k:
  cnt+=nums[i][1]
  if cnt>=k:
    print(nums[i][0])
    break
  i+=1

Measured memory_bytes: 29144
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    int a,b;
    cin >> a >> b;
    string out = "Even";
    if(a % 2 == 1 && b % 2 == 1) out = "Odd";
    cout << out << endl;
    return 0;
}


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

int a[100010],n,k,pos,ans=0x3f3f3f3f;

int gg(int a,int b)
{
	int xx=a%b==0?a/b:a/b+1;
	return xx;
}

int main()
{
	scanf("%d%d",&n,&k);
	if(n==1&&k==1)
	{
		puts("0");
		return 0;
	}
	if(n==k)
	{
		puts("1");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==1)
		{
			pos=i;
		}
	}
	for(int i=1;i<=k-1;i++)
	{
		int l=pos-k+i+1;
		int r=pos+i;
		if(l>=1&&r<=n) 
		    if(ans>gg(l-1,k-1)+gg(n-r,k-1)+1)
		    {
		    	ans=gg(l-1,k-1)+gg(n-r,k-1)+1;
			}
	}
	for(int i=0;i<=k-2;i++)
	{
		int l=pos-k+i+1;
		int r=pos+i;
		if(l>=1&&r<=n) 
		    if(ans>gg(l-1,k-1)+gg(n-r,k-1)+1)
		    {
		    	ans=gg(l-1,k-1)+gg(n-r,k-1)+1;
			}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool judge(char letter)
{
	if(letter == 'A' || letter == 'C' || letter == 'G' || letter == 'T')
		return true;
	else
		return false;
}
int max(int x, int y)
{
	return(x > y ? x:y);
}
int main()
{
	string s;
	cin >> s;
	int maxs = 0;
	int count = 0;
	for(int i = 0; s[i]!= '\0'; i ++)
	{
		if(judge(s[ i ]))
		{
			count += 1;
			if(!judge(s[ i + 1 ]))
			{
				maxs = max(maxs,count);
				count = 0;
			}
		}
	}
	cout << maxs << endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100005];
int x=0,y=0,ans=0;
int main()
{
    cin>>a;
    for (int i=0;i<sizeof(a);i++)
        if (x==y) {
            x++; 
            if(a[i]=='p') ans--;
        }
    else {
        y++; 
        if(a[i]=='g') ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct skill{
  int c,t;
  skill(){}
  skill(int c,int t):c(c),t(t){}
};
vector<vector<int> > G;
bool used[111],tmp[111];
bool dfs(int v,int d){
  if(d>111) return 0;
  tmp[v]=1;
  bool f=1;
  for(int i=0;f&&(i<(int)G[v].size());i++)
    if(!used[G[v][i]]) f&=dfs(G[v][i],d+1);
  return f;
}
bool solve(int m){
  bool f=1;
  for(int i=0;f&&(i<m);i++) {
    memset(tmp,0,sizeof(tmp));
    if(!used[i]) f&=dfs(i,0);
    for(int j=0;j<m;j++) used[j]|=tmp[j];
    //cout<<i<<endl;
  }
  return f;
}
int main(){
  int m,n;
  cin>>m>>n;
  vector<skill> ss[m][n];
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s,t;
      string c;
      cin>>s>>c>>t;
      ss[i][s-1].push_back(skill(c=="<=",t));
    }
  }
  bool ff=0;
  G.resize(m);
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      bool f=0;
      for(int k=0;k<n;k++){
	for(int x=0;x<(int)ss[i][k].size();x++){
	  for(int y=0;y<(int)ss[j][k].size();y++){
	    if(ss[i][k][x].t<=ss[j][k][y].t){
	      f|=(ss[i][k][x].c==1&&ss[j][k][y].c==0);
	    }
	  }
	}
      }
      if(f) G[j].push_back(i);
      ff|=((i==j)&&f);
      //if(f) cout<<i<<":"<<j<<endl;
    }
  }
  cout<<(!ff&&solve(m)?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	vector<int> vec (3);
	int K;
	cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
	cin >> K;
	sort(vec.begin(),vec.end());
	for(int i = 0;i < K;i++){
		vec.at(2) *= 2;
	}
	cout << vec.at(0) + vec.at(1) + vec.at (2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

/////////////         modの計算
const ll mod = 1000000007LL;

class modlong {
public:
	modlong() { x = 0; }
	modlong(ll num) { x = num; }
	inline operator ll() const { return x; }
	inline void operator = (ll num) { x = num; }
	inline void operator += (ll num) { x = adjust(x + num); }
	inline void operator *= (ll num) { x = adjust(x * num); }
	inline modlong operator * (ll num) { modlong m(adjust(this->x * num)); return m; }
private:
	inline ll adjust(ll a) {
		if (a >= mod) { return a % mod; }
		return a;
	}
	ll x;
};

constexpr int K = 16;

constexpr ll v_e[] = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
constexpr ll v_o[] = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

int main() {
	int T; scanf("%d", &T);
	for (int _t = 0; _t < T; _t++) {
		ll N; scanf("%ld", &N);
		modlong ans = 0;
		modlong x = 1;

		if (N & 1) {// odd
			for (int i = 0; i < K; i++) {
				ans += x * v_o[i];
				x *= N;
			}
		}
		else {// even
			for (int i = 0; i < K; i++) {
				ans += x * v_e[i];
				x *= N;
			}
		}
		printf("%ld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 1736
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    restaurants = []
    for i, s in enumerate(inputs):
        s = s.split()
        restaurants.append((i+1, s[0], int(s[1])))
    restaurants.sort(key=lambda x: x[2], reverse=True)
    restaurants.sort(key=lambda x: x[1])

    ret = list(map(lambda r: r[0], restaurants))

    return ret


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N] = string_to_int(input())
    ret = solve(inputs(N))
    # print(ret)

    for r in ret:
        print(r)


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	while(!s.empty()){
		int len=s.size();
		if(len&1){
			s.pop_back();
			continue;
		}
		string a=s.substr(0,len/2);
		string b=s.substr(len/2,len/2);
		if(a==b&&len!=n){
			cout<<len<<'\n';
			return 0;
		}
		s.pop_back();
	}
}




Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int P[10];
int main(){
  int i, res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(P[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = P[0];
      for(KL2GvlyY=1;KL2GvlyY<N;KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, P[KL2GvlyY]);
      }
    }
    i =Q5VJL1cS;
  }
  {
    int cTE1_r3A, e98WHCEY;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = P[0];
      for(e98WHCEY=1;e98WHCEY<N;e98WHCEY++){
        cTE1_r3A += P[e98WHCEY];
      }
    }
    res =cTE1_r3A- i/2;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, P[10];
// {
//   int i, res;
//   rd(N,P(N));
//   i = max(P(N));
//   res = sum(P(N)) - i/2;
//   wt(res);
// }


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<pair<string,P>>a(n);
    REP(i,n){
        string s;
        int p;
        cin>>s>>p;
        a[i]={s,{-p,i+1}};
    }
    sort(ALL(a));
    REP(i,n){
        OUT(a[i].second.second);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n == 1){
        return 0*printf("1\n");
    }else {
        int x = 1;
        while(x <= n) x<<=1;
        printf("%d\n",x>>1);
    }
    return 0;
}


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

const int MAX_N = 1e5 + 3;
struct edge{int to; int cost; };
vector<edge> tree[MAX_N];
ll d[MAX_N];
bool visited[MAX_N];
int N, Q, K;

void dfs(int a) {
    for(int i = 0; i < tree[a].size(); ++i) {
        int t = tree[a][i].to, c = tree[a][i].cost;
        if(visited[t]) continue;
        d[t] = (ll)c + d[a]; visited[t] = true; dfs(t);
    }
    return ;
}

void init() { visited[K] = true; dfs(K); }

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N-1; ++i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        --a, --b;
        tree[a].push_back((edge){b, c});
        tree[b].push_back((edge){a, c});
    }
    scanf("%d %d", &Q, &K);
    --K;
    init();
    ll res[Q];
    for(int i = 0; i < Q; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        --x, --y;
        res[i] = d[x] + d[y];
    }
    for(int i = 0; i < Q; ++i) printf("%lld\n", res[i]);
    return 0;
}

Measured memory_bytes: 12800
n, m = map(int, input().split())
edges = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a-1 in edges:
    edges[a-1].append(b-1)
  else:
    edges[a-1] = [b-1]
  if b-1 in edges:
    edges[b-1].append(a-1)
  else:
    edges[b-1] = [a-1]

end1, end2 = a-1, b-1

visited = [False for _ in range(n)]
visited[end1] = True
visited[end2] = True

seti = set([end1, end2])
path = [end1, end2]
while True:
  reme = None
  for _a in edges[end1]:
    if _a not in seti:
      reme = _a
      break
  if reme is not None:
    end1 = _a
    seti.add(_a)
    path = [_a] + path
  else:
    for _a in edges[end2]:
      if _a not in seti:
        reme = _a
        break
    if reme is not None:
      end2 = _a
      seti.add(_a)
      path += [_a]
  if reme is None:
    break

print(len(path))
print(*map(lambda x: x+1, path))


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

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

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

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

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

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

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  string s;cin>>s;
  int n = s.size();
  int ans = -1;
  char pre = 'x';
  rep(i,n) {
    if (pre == s[i]) continue;
    ans++;
    pre = s[i];
  } 
  cout << ans << endl;
}

Measured memory_bytes: 512
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>
 
 
using namespace std;
 
// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }

 
const ll MAX_N = 100;
const ll MAX_W = 1e5;
ll N, W;
ll v[MAX_N], w[MAX_N];
ll dp[MAX_N+1][MAX_W+1]; // メモ化テーブル
 
// i番目以降の品物から重さの総和がj以下になるように選ぶ
ll rec(ll i, ll j){
	if (dp[i][j]>=0){
		// 既に調べたことがあるならばその結果を再利用
		return dp[i][j];
	}
	ll res;
	if (i==N){
		//もう品物は残っていない
		res = 0;
	} else if (j<w[i]) {
		// もう品物は入らない
		res = rec(i+1, j);
	}else {
		//入れない場合と入れる場合を両方試す
		res = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
	}
	// 結果をテーブルに記憶する
	return dp[i][j] =res;
}
 
int main() {
	// 入力
	cin >> N >> W;
	for (ll i = 0; i < N; ++i) cin >> w[i] >> v[i];
 
	// 解法
	// まだ調べていないことを表す-1でメモ化テーブルを初期化
	memset(dp, -1, sizeof(dp));
	printf("%lld\n", rec(0, W));
}
 

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

main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k=0,l,m,n,p,t;
   while(cin>>m>>n){
      int x[1000]={0};
      for(i=0;i<n;i++){
        cin>>j;
        x[j]++;
      }
      k=100000;l=0;
      i=m-1;j=m+1;
      if(x[m]==0) cout<<m<<endl;
      else{
      while(1){
        if(x[i]==0){
            cout<<i<<endl; break;
        }
        if(x[j]==0){
            cout<<j<<endl;break;
        }
        i--;j++;
      }


   }}
    return 0;

}


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

int main() {
    
    char x;
    cin >> x;
    
    if (x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}

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

void findNext(vector<int>& nums) {
  nums[0]++;
  
  int d(0);
  for (int i = 0; i + 1 < nums.size(); ++i) {
    if (nums[i] == 10 || abs(nums[i] - nums[i+1]) == 2) {
      nums[i+1]++;
      d = max(d, i+1);
    }
  }
  
  if (nums.back() == 10) {
    nums.back() = 0;
    nums.push_back(1);
  }
  for (int i = d; i >= 1; --i)
    nums[i-1] = max(nums[i] - 1, 0);
}

int main() {
  vector<int> nums(1);
  int n;
  cin >> n;
  while (n--) findNext(nums);
  for (int i = nums.size() - 1; i >= 0; --i)
    cout << nums[i];
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (mut i, o, _t, mut j, mut l, _, _) = get!(u64, u64, u64, u64, u64, u64, u64);

    let mut ans = 0;

    let mut c = 0;
    c += i % 2;
    c += l % 2;
    c += j % 2;
    if c == 2 && i > 0 && l > 0 && j > 0 {
        ans += 6;
        i -= 1;
        j -= 1;
        l -= 1;
    }


    ans += i / 2 * 4;
    ans += 2 * o;
    ans += j / 2 * 4;
    ans += l / 2 * 4;

    if i % 2 == 1 && j % 2 == 1 && l % 2 == 1 {
        ans += 6;
    }

    println!("{}", ans / 2);
}


Measured memory_bytes: 4352
n,m = map(int,input().split())
num = list(map(int,input().split()))
sum_num = sum(num)

cnt = 0
for i in range(n):
    tmp = num.pop(num.index(max(num)))
    if tmp >= sum_num*1/(4*m):
        cnt += 1

if cnt >= m:
    print("Yes")
else:
    print("No")

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

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

  ll cnt;
  if (h > w) {
    cnt = n / h;
    if (n % h != 0) cnt++;
  } else {
    cnt = n / w;
    if (n % w != 0) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
//abc090_b.cpp
//Sun Mar 11 20:54:58 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	int x;
	int y;
	cin >> x;
	cin >> y;
	int ans=0;
	for (int i=x;i<=y;i++){
		int a = i/1000;
		int b = i%10;
		int c = (i%100-b)/10;
		int d = b*10+c;
		if (a==d){
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
a, b, c, d =0, 0, 0 , 0
for i in range(int(input())):
    x = input()
    if x == 'AC':
        a += 1
    if x == 'TLE':
        b += 1
    if x == 'RE':
        c += 1
    if x == 'WA':
        d += 1
print('AC x', a)
print('WA x', d)
print('TLE x', b)
print('RE x', c)


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

int n,m,a[40],ans;

int main()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		for(int j = 1; j <= k; j++){
			int x;
			cin >> x;
			a[x]++;
		}
	}
	for(int i = 1; i <= 30; i++)
		if(a[i]==n) ans++;
	cout << ans << endl;
	return 0;
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;


void autoinput()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}

#define ll long long
#define scan(x) scanf("%lld ",&x)
#define pb push_back
#define mp make_pair
#define make_edge(xx,yy) v[xx].pb(yy);v[yy].pb(xx)
#define debug(a) cout << #a << ": " << a << endl
#define pp(a,b) push_back(make_pair(a,b))
#define ff first
#define ss second
#define tff get<0>
#define tss get<1>
#define ttt get<2>
#define mt make_tuple
#define eps 0.0000001
#define sz size()
const ll mod = 998244353;
long double gammay = 0.5772156649015328606065120;




//PBDS
/*
tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> Data[40];
*/



/*
ordered_set X;
    X.insert(1);
    X.insert(2);
    X.insert(4);
    X.insert(8);
    X.insert(16);

    cout<<*X.find_by_order(1)<<endl; // 2
    cout<<*X.find_by_order(2)<<endl; // 4
    cout<<*X.find_by_order(4)<<endl; // 16
    cout<<(end(X)==X.find_by_order(6))<<endl; // true

    cout<<X.order_of_key(-5)<<endl;  // 0
    cout<<X.order_of_key(1)<<endl;   // 0
    cout<<X.order_of_key(3)<<endl;   // 2
    cout<<X.order_of_key(4)<<endl;   // 2
    cout<<X.order_of_key(400)<<endl; // 5
*/

 //priority_queue<int, vector<int>, std::greater<int> > first;

ll gcd(ll a, ll b)
{
    if(a<b)
        swap(a,b);
    if(b==0)
        return a;
    if(a%b==0)
        return b;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){

  return (a*b)/__gcd(a,b);
}

ll bigmod(ll N,ll P)
{
    if(P==0) return 1;
    if(P%2==0)
    {
        ll ret=bigmod(N,P/2);
        return ((ret%mod)*(ret%mod))%mod;
    }
    else return ((N%mod)*(bigmod(N,P-1)%mod))%mod;

}
bool isPrime(ll x)
{
    if(x<=1)
        return 0;
    if(x<=3)
        return 1;
    if(x%2==0)
        return 0;
    for(ll i = 3; i*i<=x;i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}

ll modInverse(ll a, ll m)
{
    return bigmod(a, m-2);
}

string s[500];
ll n,m;
ll dp[101][101][2];

bool ok(ll x, ll y){
    if(x>=n || y >=m)
        return 0;
    return 1;
}


ll func(ll x, ll y, ll fl){
    if(x==n-1 && y == m-1)
        return 0;
    if(x>=n || y>=m){
        return 1e8;
    }
    ll way1=1e8,way2=1e8;
    if(dp[x][y][fl]!=-1)
        return dp[x][y][fl];

    if(ok(x,y+1)){
        if(s[x][y+1]=='#'){

            way1=  func(x,y+1,1) + (ll)(fl^1);
           
        }
        else
        {
            way1 =  func(x,y+1,0);
        }
    }
    if(ok(x+1,y)){
        if(s[x+1][y]=='#'){
            way2=  func(x+1,y,1) + (ll)(fl^1) ;
        }
        else
        {
            way2 =  func(x+1,y,0);
        }
    }

    return dp[x][y][fl]=min(way1,way2);

}


int main()
{
    // ios_base::sync_with_stdio(false); 
    // cin.tie(NULL);
    #ifdef LOCAL
        autoinput();
    #endif
    ll i,j,k,l;
    memset(dp,-1,sizeof dp);
    cin >> n >> m;

    for(i=0;i<n;i++){
        cin >> s[i];

    }

    if(s[0][0]=='#')
        cout << 1+func(0,0,1) << endl;
    else
        cout << func(0,0,0) << endl;
}


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

int main()
{
    long long n;
    cin>>n;
    vector<long long>arr(n);
    for(int i=0;i<n;i++)
      cin>>arr[i];
      
    map<long long,long long>mp;
    for(int i=0;i<n;i++)
      mp[arr[i]]++;
      
    long long sum=0;
    for(int i=0;i<n;i++)
      sum+=arr[i];
      
    long long q,prev,second,got;
    cin>>q;
    long long x,y;
    while(q--)
    {
        cin>>x>>y;
         prev=mp[x]*x;
         second=mp[x];
         got=second*y;
        mp.erase(x);
        mp[y]+=second;
        sum+=got-prev;
        cout<<sum<<endl;
    }
}

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

const int MAX = 100;
const long long INF = (1LL << 32);

long long d[MAX][MAX];

void floyd(int n) {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (d[i][k] == INF) continue;
			for (int j = 0; j < n; j++) {
				if (d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
	int v, e;
	scanf("%d %d", &v, &e);
	for (int i = 0; i < v; i++) {
		for (int j = 0; j < v; j++) {
			d[i][j] = (i == j) ? 0 : INF;
		}
	}

	int s, t, c;
	for (int i = 0; i < e; i++) {
		scanf("%d %d %d", &s, &t, &c);
		d[s][t] = c;
	}

	floyd(v);

	bool isNega = false;
	for (int i = 0; i < v; i++) {
		if (d[i][i] < 0) isNega = true;	
	}
	if (isNega) {
		cout << "NEGATIVE CYCLE" << endl; return 0;
	}

	for (int i = 0; i < v; i++) {
		for (int j = 0; j < v; j++) {
			if (j != 0) cout << " ";
			if (d[i][j] == INF) cout << "INF";
			else cout << d[i][j];	
		}
		cout << endl;
	}

	return 0;
}



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

int main()
{
    int n,flg;

    cin >> n;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    flg = 0;
    for (int i=n-1;i>0;--i) {
        if (h[i - 1] > h[i]) {
            if (--h[i-1] > h[i]) {
                ++flg;
                break;
            }
        }
    }
    if (flg==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3792
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int x,b,p;
    cin>>x;
    int mx=1;
    b=1;
    p=2;
    int SM;
    for (;;)
    {
         SM=b;
         for (int i=1;i<p;i++)
             SM*=b;
         if (SM<=x && b!=1) {mx=max(SM,mx);p=p+1;}
         else if (p==2 && b!=1) break;
              else {b=b+1;p=2;}
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int n = b - a - 1;
    cout << n * (n + 1) / 2 - a << endl;

    return 0;
}

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

int main()
{
	int n, a[200];
	cin >> n;
	int c = 0;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	bool ok = true;
	while (1)
	{
		for (int i = 0; i < n; i++)
		{
			if (a[i] % 2)
			{
				ok = false;
				break;
			}
			else
			{
				a[i] /= 2;
			}
		}
		if (!ok)
			break;
		else
			c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  string s,h="";
  bool ans=0;
  cin >> s;
  rep(i,0,5){
    h+="hi";
    if(h==s){
      ans=1;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfLong().toLongArray()
    val dp = Array(N) { LongArray(2) }
    dp[1][1] = A[1]
    dp[1][0] = A[0]
    for (n in 2 until N) {
        if (n and 1 == 0) {
            if (n < 3) {
                dp[n][1] = A[n] + listOf(dp[n - 2][1], dp[n - 2][0]).max()!!
                dp[n][0] = listOf(dp[n - 1][1], dp[n - 1][0]).max()!!
            } else {
                dp[n][1] = A[n] + listOf(dp[n - 3][1], dp[n - 3][0], dp[n - 2][1], dp[n - 2][0]).max()!!
                dp[n][0] = listOf(dp[n - 1][1], dp[n - 1][0], A[n - 2] + dp[n - 3][0]).max()!!
            }
        } else {
            dp[n][1] = A[n] + listOf(dp[n - 2][1], dp[n - 2][0], dp[n - 1][0]).max()!!
            dp[n][0] = A[n - 1] + dp[n - 2][0]
        }
    }
    val ans = Math.max(dp[N - 1][0], dp[N - 1][1])
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(offset: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + offset }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }



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

int main()
{
  int n,k,ans=0;
  cin>>n>>k;
  int x[n];
  for(int &i:x) cin>>i;
  for(auto i:x)
  {
    ans += min(i+i,abs(k-i+k-i));
  }
  cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    int n,h,w;
    cin >>n>>h>>w;
    cout << (n-h+1)*(n-w+1)<<endl;
    return 0;
}


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


int main() {

	int N, X;
	cin >> N >> X;

	vector<int> donut(N);

	for (int i = 0;i < N;i++)
		cin >> donut.at(i);

	int a = X;
	for (int i = 0;i < N;i++)
		a -= donut.at(i);

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

	int count = N;
	while (a >= donut.at(0)) {
		a -= donut.at(0);
		count++;
	}
	cout << count;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
	int n;
	ll a[200001] = { 0 };
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", a + i);
		a[i] += a[i - 1];
	}
	ll min_dif = 1000000000ll * 250000ll;
	for (int i = 1; i <= (n - 1); i++)
		min_dif = min(min_dif, abs(a[i] - (a[n] - a[i])));
	printf("%lld\n", min_dif);
}

Measured memory_bytes: 1792
from functools import lru_cache


def PrimeFactorization(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf


@lru_cache(maxsize=100000)
def f(x):
    return int((-1 + (1 + 8 * x) ** 0.5) // 2 + 0.001)


def resolve():
    n = int(input())
    d = PrimeFactorization(n)
    ans = 0
    for v in d.values():
        ans += f(v)
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9820
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[100];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n - 2; i++)
	{
		if (a[i] < a[i + 1] && a[i + 1] < a[i + 2])
		{
			ans++;
		}
		else if (a[i] > a[i + 1] && a[i + 1] > a[i + 2])
		{
			ans++;
		}
		else
		{
			
		}
	}
	cout << ans << endl;



}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  long long s=0;
  int i,j,c=0;
  float n=0;
  while((scanf("%d,%d",&i,&j)) != EOF){
    s += i*j;
    n += j;
    c++;
  }
  printf("%lld\n%d\n",s,(int)(n/c+0.5));
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	
	void update(int i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	llint query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n, l;
llint a[100005], b[100005];
llint c[100005], sumc[100005];

vector<P> vec;
BIT bit(100005);
SegTree seg(17);
llint pnum;

llint get(llint x)
{
	llint ub = pnum+1, lb = -1, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(bit.query(mid) >= x) ub = mid;
		else lb = mid;
	}
	return ub;
}

int main(void)
{
	cin >> n >> l;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	for(int i = 1; i <= n; i++) cin >> c[i];
	for(int i = 1; i <= n; i++) sumc[i] = sumc[i-1] + c[i];
	
	for(int i = 1; i <= n; i++) vec.push_back(make_pair(a[i]-b[i], i));
	sort(vec.rbegin(), vec.rend());
	
	for(int i = 0; i < vec.size(); i++){
		if(vec[i].first < 0) break;
		bit.add(i+1, vec[i].first);
		pnum++;
	}
	llint tpos = n+1;
	for(int i = 1; i <= pnum; i++){
		if(bit.query(i) - sumc[i] <= 0){
			tpos = i;
			break;
		}
	}
	
	seg.init();
	for(int i = 1; i <= pnum; i++) seg.update(i, bit.query(i) - sumc[i-1]);
	
	llint ans = inf;
	for(int i = 0; i < vec.size(); i++){
		llint id = vec[i].second;
		if(i < pnum){
			bit.add(i+1, -vec[i].first);
			llint p = get(l - a[id]);
			bit.add(i+1, vec[i].first);
			if(p > pnum || p >= tpos) continue;
			if(p < i+2) ans = min(ans, p+1);
			else if(seg.query(i+2, p) > vec[i].first) ans = min(ans, p);
		}
		else{
			llint p = get(l - a[id]);
			if(p > pnum) continue;
			if(p < tpos) ans = min(ans, p+1);
		}
	}
	if(ans >= inf) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 10884
n = int(input())
# for i in range(n):
items = input()
li = list(map(int, items.split()))
# print(type(li))

# li = [7,43,45,32,3,5,11,22]
#
# li2 = sorted(li)
# print(li2)
#

li = sorted(li)
print(sum([val for i, val in enumerate(li) if i % 2 == 0]))


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	int tmp,lst;
	cin>>lst;
	for(int i=2;i<=n;i++)
	{
		cin>>tmp;
		if(tmp+lst>=l)
		{
			cout<<"Possible"<<endl;
			for(int j=1;j<i-1;j++)
				cout<<j<<endl;
			for(int j=n-1;j>=i;j--)
				cout<<j<<endl;
			cout<<i-1<<endl;
			return 0;
		}
		lst=tmp;
	}
	cout<<"Impossible"<<endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool is_g = true;
  for (int i=S.size()-2; i>0; i-=2) {
    is_g = true;
    for (int j=0; j<i/2; j++) {
      if (S.at(j) != S.at(i/2+j)) {
        is_g = false;
        break;
      }
    }
    if (is_g) {
      cout << i << endl;
      break;
    }
  }
}

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

int main(){
    int n;
    int t[100010], x[100010], y[100010];
    cin >> n;
    t[0] = x[0] = y[0] = 0;
    for (int i = 0; i < n; i++) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

    bool ans = true;
    for (int i= 0; i < n; i++) {
        int diffT = t[i + 1] - t[i];
        int diffD = abs(x[i + 1] - x[i]) + abs (y[i + 1] - y[i]);
        if (diffD > diffT) ans = false;
        if (diffD % 2 != diffT % 2) ans = false;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib> 
#include <algorithm>
#include <cmath>
#include <stack>

#define Bigger(a,b) (a <= b)?b:a                   //大きい方を返す
#define Rep(i, n) for(int i = 0; i < n; i++)    //i=0 → i=nまでループ
#define Repr(i,n) for(int i = n; i <=0; i--)    //i=n → i=0までループ　
#define For(i, m, n) for(int i = m;i < n;i++)   //i=m → i=nまでループ
#define All(x) (x).begin(),().end()             //xの最初と最後のイテレータを返す 
#define Out(n) cout << n << endl


using namespace std;



int main(){
    int n,k;
    string s;

    cin >> n >> s >> k;

    string ans = s;

    char c = s[k - 1];
    Rep(i,n){
        if(s[i] != c){
            ans[i] = '*';
        }
    }

    Out(ans);





    return 0;
}

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

#define REP(i,n) for(int i=0;i<n;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 pb(x) push_back(x)
#define mp(x, y) make_pair(x, y) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
    
using namespace std;

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

int32_t main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i, n){
        cin >> v[i];
    }

    int ans=INF;
    REP(i, n){
        if(i+k-1>=n) break;
        int t1=v[i];
        int t2=v[i+k-1];
        ans = min(ans, min(abs(t1)+abs(t1-t2), abs(t2)+abs(t2-t1)));
    }

    cout << ans << endl;
}

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

int main(){
  int a[26]={},b[26]={};
  string e = "Yes";
  string c,d;
  cin >> c >> d;
  for(int i=0;i<c.size();i++){
    a[c.at(i)-97]++;
    b[d.at(i)-97]++;
  }
  sort(a,a+26);
  sort(b,b+26);
  for(int i=0;i<26;i++){
    if(a[i]!=b[i])
      e = "No";
  }
  cout << e << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    string ope = "No";
    if (a < b && b < c) {
        ope = "Yes";
    }
    cout << ope << endl;
    return 0;
}


Measured memory_bytes: 3164