akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, m int
	var ans int64

	fmt.Sscan(getNextLine(scanner), &n, &m)

	aaa := getIntList(scanner)
	sums := make([]int, n+1)
	for i := 0; i < n; i++ {
		sums[i+1] = (sums[i] + aaa[i]) % m
	}
	sort.Sort(sort.IntSlice(sums))
	same := 0
	for i := 1; i <= n; i++ {
		if sums[i] != sums[i-1] {
			same = 0
			continue
		}
		same++
		ans += int64(same)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 9856
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s, t;
  cin >> s >> t;
  reverse(all(t));
  if (s == t) cout << "YES" << '\n';
  else cout << "NO" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++) std::cin >> v[i];
  ll ans = 0;
  for(int i=0;i<=min(K, N);i++){
    for(int j=0;j<=i;j++){
      std::vector<int> data;
      ll su=0;
      for(int k=0;k<j;k++){
        data.push_back(v[k]);
      }
      for(int k=0;k<(i-j);k++){
        data.push_back(v[N-k-1]);
      }
      sort(data.begin(), data.end());
      for(int k=0;k<K-i;k++){
        if(k<data.size()) if(data[k]<0) data[k]=0;
      }
      for(int k=0;k<data.size();k++) su+=data[k];
      //for(int l=0;l<data.size();l++) std::cout << data[l];
      //std::cout << '\n';
      ans = max(su, ans);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  
  int N, a, count = 0, ans = 9999;
  cin >> N;

  for(int i = 0; i < N; i++) {
  
    cin >> a;
    count = 0;
    
    for(int j = 0; j <= count + 1; j++) {
//      cout << "j:" << j << endl;
      
      if(a % 2 == 0) {
        count += 1;
//        cout << "count:" << count << endl;
        a /= 2;
//        cout << "a:" << a << endl;
      }
      
      else {
        break;
      }
      
    }
    
//    cout << "count" <<  "(" << i + 1 << ")" << count << endl;
//    cout << "max" <<  "(" << i + 1 << ")" << max << endl;
    
    if(count < ans) {
      ans = count;
    }
    
      
  }
 
  cout << ans << endl;
  
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    string s;
    int count = 0;
    cin >> s;
    for(int i = 0; i < s.length() ; i++){
        if(s[i] == '2') count++;
    }
    print(count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> L(N + 1, 0);
  for (int i = 0; i < N; i++){
    if (S[i] == '#'){
      L[i + 1] = L[i] + 1;
    } else {
      L[i + 1] = L[i];
    }
  }
  vector<int> R(N + 1, 0);
  for (int i = N - 1; i >= 0; i--){
    if (S[i] == '.'){
      R[i] = R[i + 1] + 1;
    } else {
      R[i] = R[i + 1];
    }
  }
  int ans = INF;
  for (int i = 0; i <= N; i++){
    ans = min(ans, L[i] + R[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ar=array<ull,26>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s1,s2;
	ar ht; ht[0]=1;
	rep(i,25) ht[i+1]=ht[i]*10007;
	
	while(cin>>s1>>s2){
		if(s1.size()>s2.size()) swap(s1,s2);
		int n1=s1.size(), n2=s2.size();
		unordered_set<ull> lst;
		vector<ull> p1(1,0),p2(1,0),p3(n1+1),p4(n2+1);
		for(auto c:s1)p1.push_back(ht[c-'a']);
		for(auto c:s2)p2.push_back(ht[c-'a']);
		partial_sum(p1.begin(), p1.end(), p3.begin());
		partial_sum(p2.begin(), p2.end(), p4.begin());
		
		for(int l=n1;l>=1;l--){
			lst.clear();
			ull tmp=p3[l-1];
			range(i,l,n1+1) {
				tmp+=p1[i];
				tmp-=p1[i-l];
				lst.insert(tmp);
			}
			tmp=p4[l-1];
			range(i,l,n2+1){
				tmp+=p2[i];
				tmp-=p2[i-l];
				if(lst.find(tmp) != lst.end()){
					cout<<l<<'\n';
					goto end;
				}
			}
		}
		cout<<0<<'\n';
		end: ;
	}
	return 0;
}



Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long int li;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef pair<double, double> dd;
typedef unsigned int ui;
typedef vector<ii> vii;
typedef vector<ff> vff;
typedef set<int> si;
typedef set<lli> slli;
typedef vector<lli> vlli;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long int ulli;
#define MOD 1000000007
#define INF (unsigned)(~0)>>1
typedef pair<int, ii> iii;
void arr_int(int* given_arr, int n){
  for(int i=0;i<n;i++)
    scanf("%d", &given_arr[i]);
  return;
}
void solve();
int main(int argc, char const *argv[]){
  solve();
  return 0;
}
void solve(){
  int N;
  scanf("%d", &N);
  int ans = (N/2) + (N%2);
  printf("%d\n",ans);
}


Measured memory_bytes: 256
def  main():
  A = list(map(int, input().split()))
  A = sorted(A)
  if A[0] %2 == A[1] % 2:
    print(A[2]-max(A[0], A[1])+abs(A[0]-A[1])//2)
  else:
    print(1+A[2]-max(A[0], A[1])+(abs(A[0]-A[1])+1)//2)
if __name__ == "__main__":
  main()
  

Measured memory_bytes: 3060
w,h,n = map(int,input().split())
x=[]
y=[]
a=[]
for i in range(n):
    x1,y1,a1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    a.append(a1)
x_max=w
x_min=0
y_max=h
y_min=0
for i in range(n):
    if a[i]==1:
        x_min = max(x_min,x[i])
    elif a[i]==2:
        x_max = min(x_max,x[i])
    elif a[i]==3:
        y_min = max(y_min,y[i])
    elif a[i]==4:
        y_max = min(y_max,y[i])
ans = (x_max-x_min)*(y_max-y_min)
if x_max < x_min or y_max < y_min:
    print(0)
else:
    print((x_max-x_min)*(y_max-y_min))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
        long long x,y,s=0,i,ii=1;
        scanf("%lld%lld",&x,&y);
        i=x;
        while(i<=y)
        {
                s++;
                i*=2;
        }
        printf("%lld",s);
        return 0;
}

Measured memory_bytes: 256
eval'a=2
b=1,1,2,3,5,8,13,21
%d.times{a=0,*(1..w=%d).map{|i|t=0;3.times{|j|t+=a[j+=i-1]*b[[i,j].min-1]*b[w-[i,j].max]};t},0}
p a[%d].%%10**9+7'%gets.split

Measured memory_bytes: 1916
#include<stdio.h>

int main()
{
	int i,h,m,s;
	scanf("%d",&i);
	
	h = i/(60*60);
	m = (i-(h*60*60))/60;
	s = i-(h*60*60)-(m*60);
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int main() {
  int a,b;cin>>a>>b;
  for(int i=1;i<2000;i++){
    if(i*8/100==a&&i*10/100==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * (m - 1) + [n * (n - 1) // 2]

root = [0] * (n + 1)
count = [1] * (n + 1)

def uf(a): return a if root[a] == 0 else uf(root[a])

for i in range(m - 1, 0, -1):
    ha = uf(ab[i][0])
    hb = uf(ab[i][1])
    if ha == hb:
        ans[i - 1] = ans[i]
        continue
    ans[i - 1] = max(0, ans[i] - count[ha] * count[hb])
    if count[ha] > count[hb]:
        root[hb] = ha
        count[ha] += count[hb]
    else:
        root[ha] = hb
        count[hb] += count[ha]
for i in ans:
    print(i)

Measured memory_bytes: 34268
#include "stdio.h"

int main(){
	int H, W, i, j;
	for(;;){
		scanf("%d %d", &H, &W);	
		if(H==0 && W==0){
			break;
		}
		else{
			for(i=0;i<H;i++){
				for(j=0;j<W;j++){
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
		}	
	}
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#define max(a,b) ((a) > (b) ? (a): (b))
#define abs(a)   ((a) > (0) ? (a):-(a))
#define NMAX 100
int N;
int x[NMAX], y[NMAX], h[NMAX];
int hc;

int check(int px, int py)
{
    int k;
    for(k = 0; k < N && h[k] == 0; k++);
    hc = h[k] + abs(x[k] - px) + abs(y[k] - py);
    for(k = 0 ; k < N; k++){
        if(max(hc - abs(x[k] - px) - abs(y[k] - py), 0) != h[k]) break;
    }
    if(k == N) return 1;
    return 0;
}

int main()
{
    int i, j;
    
    scanf("%d", &N);
    for(i = 0; i < N; i++) {
        scanf("%d %d %d", &x[i], &y[i], &h[i]);
    }
    
    for(i = 0; i <= NMAX; i++) {
        for(j = 0; j <= NMAX; j++) {
            if(check(i, j)) {
                printf("%d %d %d\n", i, j, hc);
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

def median(arr):
    arr.sort()
    n = len(arr)
    if n % 2 == 1:
        return arr[(n + 1) // 2 - 1]
    else:
        return (arr[n//2 - 1] + arr[n//2]) / 2

med_a = median(A)
med_b = median(B)
if N % 2 == 1:
    ans = int(med_b) - int(med_a) + 1
else:
    ans = med_b * 2 - med_a * 2 + 1
    ans = int(ans)

print(ans)

Measured memory_bytes: 99096
def solve(mid,g):
    for t,d in zip(x,y):
        if s[mid]==t:
            mid-=(d<'R')or-1
    return mid==g
n,q,s,*z=open(0).read().split()
x,y=z[::2],z[1::2]
n,q=int(n),int(q)
s=' %s '%s
ok=0
ng=n+1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if solve(mid,0):
        ok=mid
    else:
        ng=mid
a=ok
ok=n+1
ng=0
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if solve(mid,n+1):
        ok=mid
    else:
        ng=mid
print(max(0,ok-a-1))

Measured memory_bytes: 11572
from decimal import Decimal
from fractions import Fraction
n, k = map(int, input().split())

prob = []

for base in range(1, n+1):
  p = 0
  while (base < k):
    p += 1
    base = base * 2
  prob.append(Fraction(1, n * (2 ** p)))
print(Decimal(sum(prob).numerator / sum(prob).denominator))


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

signed main() {
    int a, b;
    cin >> a >> b;
    
    if ( a < 6 ) {
        cout << 0 << endl;
    } else if ( a > 12 ) {
        cout << b << endl;
    } else {
        cout << b / 2 << endl;
    }
    return (0);
}

Measured memory_bytes: 3620
N = int(input())
taka = list(map(int,input().split()))
exam = list(map(int,input().split()))

sa = list()
#　高橋くんがマイナスになっている部分を変更することでうまくいくかどうかを検索する
for t,e in zip(taka,exam):
  sa.append(t-e)
sa = sorted(sa)

minus = list(filter(lambda x:x<0,sa))
plus = list(filter(lambda x:x>0,sa))

sum_plus = 0
sum_minus = sum(minus)
if sum_minus == 0:
  print(0)
else:
  for idx,p in enumerate(plus[::-1]):
    sum_plus += p
    if sum_plus>=-sum_minus:
      print(idx+1+len(minus))
      break
  else:
    print(-1)


Measured memory_bytes: 18524
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long A,B,N,X,Y,number,L;
    cin>>A>>B>>N;
    number=0;
    if(N<B){
        X=A*N/B;
        Y=N/B;
        number=X-A*Y;
    }
    if(N>=B){
        X=A*(B-1)/B;
        Y=0;
        number=X-A*Y;
    }
    cout<<number<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>

#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;


int main() {
    int n;
    cin >> n;
    vl a(n);
    rep(i,n)cin >> a[i];
    if(a[0] != 0){
        cout<<-1<<endl;
        return 0;
    }
    ll ans = 0;
    ll mx = 0;
    srep(i,1,n){
      maxs(mx,a[i]);
      if(a[i]-a[i-1] >=2){
        cout<<-1<<endl;
        return 0;
      }
      if(a[i-1]+1 != a[i]  && a[i]>max(mx,2LL)){
          cout<<-1<<endl;
          return 0;
      }else{
        if(a[i]>0){
          if(a[i] == a[i-1]+1 || a[i]== 1)
          ans++;
          else ans+=a[i];
        }
      }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<math.h>
#include<queue>
int a[105],b[105],c[105];
int main()
{
    int n,x,y,k=1,Min=100;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    while(k<n)
    {
        for(int i=0;i<k;i++)
        {
            b[k]+=a[i];
        }
        for(int i=n-1;i>k-1;i--)
        {
            c[k]+=a[i];
        }
        x=fabs(b[k]-c[k]);
        k++;
        if(Min>x)Min=x;
    }
    printf("%d\n",Min);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    for (a = -1000; a < 1001; a++) {
        for (b = -1000; b < 1001; b++) {
            long long x = 0;
            x += a*a*a*a*a;
            x -= b*b*b*b*b;
            if (x == m) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int h[3][1000], n, i, temp;
	scanf("%d", &i);
	for (n = 0; n < i; n++){
		scanf("%d %d %d", &h[0][n], &h[1][n], &h[2][n]);
		if (h[0][n]<=h[1][n]){
			temp=h[0][n];
			h[0][n]=h[1][n];
			h[1][n]=temp;
		}
		if(h[0][n]<=h[2][n]){
			temp=h[0][n];
			h[0][n]=h[2][n];
			h[2][n]=temp;
		}
/*	}
	for (n = 0; n < i; n++){
*/		if ((h[0][n]*h[0][n])==(h[1][n]*h[1][n]+h[2][n]*h[2][n])){
			printf("YES\n");
		} else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1016
a=int(input())
sum=0
s=''
'''if a<0:
    b = abs(a)
    if b%2==1:
        b=b+1
        print(str(bin(b))[2:-1]+'1')
    else:
        print(str(bin(b))[2:-1])'''
if a!=0:
    while(a!=1):
        if a%(-2)==-1:
            s=s+'1'
            a=a-1
            a=a/-2
        else:
            s = s + '0'
            a=a/-2
    s=s+'1'
    for i in range(len(s)):
        print(s[len(s)-1-i],end='')
    print()
else:
    print(0)


Measured memory_bytes: 38384
#include "stdio.h"
int main()
{
  int a,b,c,t;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b)
  {
    if(b!=c)
      printf("Yes\n");
    else
      printf("No\n");
  }
  else
  {
    if(a==c||b==c)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n;
	char s[300001];
	int mw[300001], me[300001];
	int cw = 0, ce = 0;

	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 0; i < n; i++) {
		mw[i] = 0;
		me[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			cw++;
		}
		mw[i] = cw;
	}

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'E') {
			ce++;
		}
		me[i] = ce;
	}
	int ans=99999999999;
	int sum;
	for (int i = 0; i < n; i++) {
		sum = 0;
		if (s[i] == 'W') {
			mw[i]--;
		}
		else {
			me[i]--;
		}
		sum += mw[i] + me[i];
		if (ans > sum) {
			ans = sum;
		}
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2816
n = int(input())
moto =[]
a = []
for _ in range(n):
  b = int(input())
  moto.append(b)
  if b%2 == 1:
    a.append(1)
  elif b:
    a.append(2)
  else:
    a.append(0)
for i in range(n-1):
  if a[i]%2 == 1:
    if a[i+1]:
      a[i+1] += 1
      a[i+1] %=2
      a[i]-=1
for i in range(n):
  a[i] %=2
print((sum(moto)-sum(a))//2)

Measured memory_bytes: 56664
n = int(input())
ab_list = [list(map(int, input().split())) for i in range(n)]

ab_list.sort(key=lambda x:x[1])

now = 0
comp = True
for a,b in ab_list:
    now += a
    if now > b:
        comp = False
        break

print('Yes' if comp else 'No')

Measured memory_bytes: 90072
N = gets.chomp

just = true
prev = N.chars.first.to_i
sum = prev
N.chars[1..-1].each do |c|
  d = c.to_i

  # p "d: #{d} prev: #{prev} sum: #{sum}"

  if just
    if prev + d < prev - 1 + 9
      sum -= 1
      prev = 9
      sum += 9
      just = false
    else
      prev = d
      sum += d
    end
  else
    sum += 9
  end
end

puts sum


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 

int main(){
    int n; cin >> n;
    vector<int> w(n);
    int lsum=0, rsum=0;
    rep(i,n) {
        cin >> w[i];
        rsum += w[i];
    }
    int ans = INF;
    rep(i,n-1){
        lsum += w[i];
        rsum -= w[i];
      ans =min(ans, abs(lsum - rsum));
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
struct UnionFind{
    vector<int> parent;
    vector<int> rank; // tree's depth
 
    UnionFind(int n){
        parent.resize(n);
        rank.resize(n);
        init(n);
    }
 
    // initialize
    void init(int n){
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    // find root
    int find(int x){
        if(parent[x] == x){
            return x;
        }else{
            return parent[x] = find(parent[x]);
        }
    }
 
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
 
        if(rank[x] < rank[y]){
            parent[x] = y;
        }else{
            parent[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
 
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int n, m; cin >> n >> m;
    UnionFind UF(n);

    int x, y, z;
    rep(i, m){
        cin >> x >> y >> z;
        x--, y--;
        UF.unite(x, y);
    }
    set<int> count;
    rep(i, n) count.insert(UF.find(i));
    cout << count.size() << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[21], n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int mins = a[0], sum = 1;
	for (int i = 1; i < n; i++)
	{
		if (a[i] >= mins)
		{
			sum++;
			mins = a[i];
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = 1e9 + 7;

void add(int & a, int b) {
  if ((a += b) >= mod) {
    a -= mod;
  }
}

int mult(int a, int b) {
  return (ll) a * b % mod;
}

void precalc() {
}

int n, m, k;

bool read() {
  if (scanf("%d%d%d", &n, &m, &k) < 3) {
    return false;
  }
  return true;
}

const int maxn = 2100;

int dp[maxn], ndp[maxn];

void solve() {
  for (int i = 0; i < k; i++) {
    dp[i] = 1;
  }
  int res = 0;
  for (int i = 1; ; i++) {
    int all = i * (k - 1) + 1;
    if (all > n + m) {
      break;
    }
    for (int j = 1; j <= m; j++) {
      if ((m - j) % (k - 1) == 0 && (all - j) <= n) {
        add(res, dp[j]);
      }
    }
    memset(ndp, 0, sizeof(ndp));
    for (int j = 1; j <= m; j++) {
      for (int r = j; r < j + k && r <= m; r++) {
        add(ndp[r], dp[j]);
      }
    }
    swap(ndp, dp);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
MOD = 998244353
N, M, K = map(int, input().split())

fact = [0] * 220000
invfact = [0] * 220000
fact[0] = 1
for i in range(1, 220000):
    fact[i] = (fact[i - 1] * i) % MOD

invfact[220000 - 1] = pow(fact[220000 - 1], MOD - 2, MOD)

for i in range(220000 - 2, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % MOD


# D = list(map(int,input().split()))
# S = input()
# X1_list = [int(input()) for i in range(N)]
# X2_list = [list(map(int,input().split())) for i in range(N)]
def nCk(n, k):
    if k < 0 or n < k :
        return 0
    return fact[n] * invfact[k] * invfact[n-k] % MOD


ans = 0
for i in range(0, K + 1):
    #print(ans)
    ans += M * pow(M - 1, N - i - 1, MOD) * nCk(N - 1, i) % MOD
print(int(ans % MOD))


Measured memory_bytes: 26216
let n = read_int ()
let s = read_line ()
let m = 1_000_000_007
let cs = Array.make 128 0
let _ =
  String.iter (fun c -> cs.(Char.code c) <- cs.(Char.code c) + 1) s;
  (Array.fold_left (fun ans c -> ans * (c + 1) mod m) 1 cs + m - 1) mod m |> Printf.printf "%d\n"

Measured memory_bytes: 640
N, M = map(int, input().split())
sc = [[int(i) for i in input().split()] for j in range(M)]

num_min = 10**(N-1)
num_max = 10**N
if N > 1:
    i = num_min
else:
    i = 0
ans = -1
while i < num_max:
    num_list = []
    rem = i
    for j in range(N, 0, -1):
        num_list.append(rem // 10**(j-1))
        rem = i % 10**(j-1)
    
    found = True
    for k in range(M):
        s, c = sc[k]
        if num_list[s-1] != c:
            found = False
    
    if found:
        ans = i
        break
    else:
        i += 1

print(ans)

Measured memory_bytes: 3064
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def rzucanie_zaklenc(zycie, lista_zaklenc):
    koszt_zaklenc = [10**9] * (zycie+1)
    koszt_zaklenc[0] = 0
    for damage, cost in lista_zaklenc:
        for i in range(zycie+1):
            if i - damage >= 0:
                if cost+koszt_zaklenc[i-damage]< koszt_zaklenc[i]:
                    koszt_zaklenc[i] = cost+koszt_zaklenc[i-damage]
            else:
                if cost < koszt_zaklenc[i]:
                    koszt_zaklenc[i] = cost
    return koszt_zaklenc[zycie]

def E():
    H, N = wczytaj_liste()
    zaklencia = []
    for i in range(N):
        damage, cost = wczytaj_liste()
        zaklencia.append((damage, cost))
    print(rzucanie_zaklenc(H, zaklencia))

E()



Measured memory_bytes: 40432
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans[101010];
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
ll outnum[101010];
ll innum[101010];


int main() {
	cin>>N>>M;
	graph=AdjList(N+1);
	rep(i,0,N-1+M){
		ll a,b;
		cin>>a>>b;
		graph[a].push_back(Edge(b,1));
		outnum[a]++;
		innum[b]++;
	}
	ll tmp;
	rep(i,1,N+1){
		if(innum[i]==0){
			ans[i]=0;
			tmp=i;
			break;
		}
	}
	queue<ll> q;
	q.push(tmp);
	while(!q.empty()){
		ll tmp =q.front();

		q.pop();
		rep(i,0,graph[tmp].size()){
			innum[graph[tmp][i].to]--;
			if(innum[graph[tmp][i].to]==0){
				ans[graph[tmp][i].to]=tmp;
				q.push(graph[tmp][i].to);
			}
		}
	}
	rep(i,1,N+1){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 10368
n, d = map(int, input().split())
li = [list(map(int, input().split())) for i in range(n)]

cnt = 0

for i in range(len(li) - 1):
  for j in range(i+1, len(li)):
    total = 0
    for k in range(d):
      total += (li[i][k] - li[j][k])**2
    
    f = (total**0.5)
    if f.is_integer():
      cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>
#include <math.h>

using namespace std;

int main()
{
    int N,D;
    cin >> N>>D;

    cout << ((N+D*2)/(D*2+1)) << endl;
}

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

int main(void) {
	int a,b,c;
	int *count;
	
	scanf("%d %d %d",&a,&b,&c);
	
	count = (int *)calloc(sizeof(int),10);
	
	count[a-1]++;
	count[b-1]++;
	count[c-1]++;
	
	if(count[4] == 2 && count[6] == 1) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，DP
// 存在判定：構成方法，入力の特徴
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N, M; cin >> N >> M;
VI k(M), p(M);
VI s(M, 0);
rep(i, 0, M){
    cin >> k[i];
    rep(j, 0, k[i]){
        int S; cin >> S;
        s[i] |= (1<<(S-1));
    }
}
rep(i, 0, M) cin >> p[i];

int cnt = 0;
rep(bit, 0, (1<<N)){
    bool on = true;
    rep(i, 0, M){
        if (bitset<10>(bit & s[i]).count() % 2 != p[i]) on = false;
    }
    if (on) ++cnt;
}

cout <<  cnt << "\n";  

}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;

if(a==5&&b==5&&c==7)
cout<<"YES"<<endl;

else if(a==5&&b==7&&c==5)
cout<<"YES"<<endl;

else if(a==7&&b==5&&c==5)
cout<<"YES"<<endl;

else 
cout<<"NO"<<endl;
}

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

int main()
{
    std::string S;
    std::cin>>S;
    transform(S.begin(),S.end(), S.begin(), toupper);
    std::string str;
    int ans=0;
    while(std::cin>>str){
        if(str=="END_OF_TEXT")break;
        transform(str.begin(), str.end(), str.begin(), toupper);
        if(str==S)ans++;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 3172
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
	int d,m,dd,mm;
	scanf("%d%d",&m,&d);
	scanf("%d%d",&mm,&dd);
	if(m+1==mm)printf("1\n");
	else printf("0\n");
}

Measured memory_bytes: 128
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 998244353
#define INIT -1

int main()
{
   int n;
   string s;
   cin >> n >> s;
   set<int> idx[26];
   for (int i = 0; i < n; i++)
   {
      idx[s[i] - 'a'].insert(i);
   }
   int q;
   cin >> q;
   for (int i = 0; i < q; i++)
   {
      int com;
      cin >> com;
      if (com == 1)
      {
         int iq;
         char cq;
         cin >> iq >> cq;
         iq--;
         idx[s[iq] - 'a'].erase(iq);
         idx[cq - 'a'].insert(iq);
         s[iq] = cq;
      }
      else
      {
         int lq, rq;
         cin >> lq >> rq;
         lq--;
         rq--;
         int ans = 0;
         for (int j = 0; j < 26; j++)
         {
            auto l = idx[j].lower_bound(lq);
            auto r = idx[j].lower_bound(rq + 1);
            if (l != r)
               ans++;
         }
         cout << ans << endl;
      }
   }
}

Measured memory_bytes: 27236
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
int main()
{
    std::cout << std::setprecision(16);
    while (true)
    {
        size_t n;
        std::cin >> n;
        if (n == 0)
            break;
        std::vector<double> vs(n);
        double sd = 0;
        double m = 0;
        for (size_t i = 0; i < n; i++)
        {
            std::cin >> vs[i];
            m += vs[i];
            sd += vs[i] * vs[i];
        }
        m /= n;
        sd /= n;
        sd -= m * m;

        std::cout << std::sqrt(sd) << "\n";
    }
    return 0;
}


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

using namespace std;

int main()
{
    vector<int> a(3); 

    for (auto &i : a)
        cin >> i;

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

    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;

    //cout << endl;

    return 0;
}



Measured memory_bytes: 3160
// Problem : C - Walking Takahashi
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    int req = (x+d-1)/d;
    if(k < req){
        cout<<x-k*d;
    } else {
        int ans1 = abs(x-req*d);
        int ans2 = abs(x-(req-1)*d);
        int rem = k-req;
        cout<<(rem % 2 ? ans2 : ans1);
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main (void)
{
  int x,y,z;
  in("%d %d %d\n",&x,&y,&z);
  rep(i,100010)
  {
    if(z+i*(y+z)>x)
    {
      printf("%d \n",i-1);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
   double x1,x2,y1,y2;
   double d;
   cin >> x1 >> y1 >> x2 >> y2;

   d = (double)sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
   printf("%.6lf\n",d);

   return 0;
}

Measured memory_bytes: 1236
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<u32>().unwrap();
    let k = stdin.lock().gets().parse::<u32>().unwrap();
    let x = stdin.lock().gets().parse::<u32>().unwrap();
    let y = stdin.lock().gets().parse::<u32>().unwrap();
    if n <= k {
        println!("{}", n * x);
    } else {
        println!("{}", k * x + (n - k) * y);
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

bool isPalindromic(string s)
{
    int left = 0, right = s.length()-1;
    while(left < right)
    {
        if(s[left++] != s[right--]) return false;
    }
    return true;
}

void solve()
{
    int A, B; cin >> A >> B;
    int ans = 0;
    for(int i = A; i <= B; i++)
    {
        string s = to_string(i); 
        if(isPalindromic(s)) ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

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

#define ll long long
#define ull unsigned long long
//#define double long double
//#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n, m;
int a[SZ];
vector<int> g[SZ];

inline void read() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

inline void solve() {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int mx = 0;
        for (int v : g[i]) {
            mx = max(mx, a[v]);
        }

        if (mx < a[i]) ++ans;
    }
    cout << ans << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
    read();
    solve();
//    }

    return 0;
}

Measured memory_bytes: 9164
a=input()
ans=[]
for i in range(len(a)):
    if 68<=ord(a[i])<=90:
        A=chr(ord(a[i])-3)
        ans.append(A)
    else:
        if a[i]=="A":
            ans.append("X")
        if a[i]=="B":
            ans.append("Y")
        if a[i]=="C":
            ans.append("Z")
print(*ans,sep="")


Measured memory_bytes: 5720
#include<bits/stdc++.h>
using namespace std;
string s[55];
int cnt[55][55];
int main(){
    int n;
    cin>>n;
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=n;i++){
        cin>>s[i];
        for(int j=0;j<s[i].size();j++){
            cnt[i][s[i][j]-'a']++;
        }
    }
    int cur=55;
    string ans;
    for(int i=0;i<26;i++){
        cur=55;
        for(int j=1;j<=n;j++){
            cur=min(cur,cnt[j][i]);
        }
        for(int j=1;j<=cur;j++){
            ans+=(char)(i+'a');
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
using namespace std;


int main(void)
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = A * X + B * Y;

    for(int i = 1; i <= max(X, Y); i++)
    {
        int x = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i);
        ans = min(ans, x);
    }

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

Measured memory_bytes: 256
N,T=map(int,input().split())
CL = []
for i in range(N):
  c, ti = map(int,input().split())
  if ti <= T:
    CL.append(c)
if len(CL) == 0:
  print("TLE")
else:
  CL.sort()
  print(CL[0])


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef pair<int,pair<int,PII>> State;

int di[] = {-1,0,1,0};
int dj[] = {0,1,0,-1};
int w,h;
int c[4];
VVI board(31,VI(31));
const int INF = 1e9;
int dijkstra(){
  int dist[h][w][4];
  rep(i,h)rep(j,w)rep(dir,4) dist[i][j][dir] = INF;
  dist[0][0][1] = 0;
  priority_queue< State, vector<State>, greater<State>> que;
  que.push(State(0,{1,{0,0}}));

  while(que.empty() == false){
    State p = que.top();
    que.pop();
    int cdist = p.first;
    int cdir = p.second.first;
    int ci  = p.second.second.first;
    int cj = p.second.second.second;
    //cout << ci << " " << cj << " " << cdir << endl;
    if(dist[ci][cj][cdir] < cdist) continue;
    // 0: 直進
    int ni = ci + di[cdir];
    int nj = cj + dj[cdir];
    int cost = c[0];
    if(board[ci][cj] == 0) cost = 0;
    if(ni >= 0 && nj >= 0 && ni < h && nj < w && dist[ni][nj][cdir] > (cdist + cost) ){
      dist[ni][nj][cdir] = (cdist + cost);
      que.push(State(dist[ni][nj][cdir],{cdir,{ni,nj}}));
    }

    //1「右折」命令
    cost = c[1];
    if(board[ci][cj] == 1) cost = 0;
    int ndir =(cdir+1)%4;
    ni = ci + di[ndir];
    nj = cj + dj[ndir];
    if(ni >= 0 && nj >= 0 && ni < h && nj < w && dist[ni][nj][ndir] > (cdist + cost) ){
      dist[ni][nj][ndir] = (cdist + cost);
      que.push(State(dist[ni][nj][ndir],{ndir,{ni,nj}}));
    }

    //2「反転」命令
    cost = c[2];
    if(board[ci][cj] == 2) cost = 0;
    ndir =(cdir+2)%4;
    ni = ci + di[ndir];
    nj = cj + dj[ndir];
    if(ni >= 0 && nj >= 0 && ni < h && nj < w && dist[ni][nj][ndir] > (cdist + cost) ){
      dist[ni][nj][ndir] = (cdist + cost);
      que.push(State(dist[ni][nj][ndir],{ndir,{ni,nj}}));
    }

   //「左折」命令
   cost = c[3];
   if(board[ci][cj] == 3) cost = 0;
   ndir =(cdir+3)%4;
   ni = ci + di[ndir];
   nj = cj + dj[ndir];
   if(ni >= 0 && nj >= 0 && ni < h && nj < w && dist[ni][nj][ndir] > (cdist + cost) ){
     dist[ni][nj][ndir] = (cdist + cost);
     que.push(State(dist[ni][nj][ndir],{ndir,{ni,nj}}));
   }

  }
  int ans = INF;
  // rep(i,h){
  //   rep(j,w){
  //     int tmp = INF;
  //     rep(dir,4) tmp = min(dist[i][j][dir],tmp);
  //     cout << tmp << " ";
  //   }
  //   cout << endl;
  // }

  rep(dir,4) ans = min(dist[h-1][w-1][dir],ans);
  return ans;
}



int main(){
  while(true){
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    rep(i,h)rep(j,w) cin >> board[i][j];
    rep(i,4) cin >> c[i];
    cout << dijkstra() << endl;
  }

}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll K; cin >> K;
    queue<ll> q;
    rep(i, 9){
        q.push(i+1);
    }

    ll cnt = 1;
    ll x;
    while(cnt<=K){
        x = q.front(); q.pop();
        if(x%10!=0) q.push(10*x+x%10-1);
        q.push(10*x+x%10);
        if(x%10!=9) q.push(10*x+x%10+1);
        cnt++;
    }
    cout << x << endl;
}

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

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

    vector<string> s(n);
    int cnt = 0;
    int judge = 0;

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

      if(i > 0){
        if((s[i][0] != s[i-1][0]) && (s[i][1] == s[i-1][1])) cnt++;
      }
    }

    cout << cnt << endl;

  }

  return 0;

}



Measured memory_bytes: 3156
n,k,*a = map(int,open(0).read().split())
mod = 10**9+7
t1 = 0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      t1+=1
t2 = 0
c = 0
for i in sorted(list(set(a))):
  dc = a.count(i)
  t2 += c*dc
  c += dc
print((t1*k+t2*k*(k-1)//2)%mod)

Measured memory_bytes: 9348
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{
	int n;
	cin >> n;
	
	vector<int> x(n);
	for (auto& i : x)cin >> i;

	int ans = INT_MAX;
	for (int i = 1; i <= 100; i++) {
		int wk = 0;
		for (int j = 0; j < x.size(); j++) {
			wk += (x[j] - i) * (x[j] - i);
		}

		ans = min(ans, wk);


	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
char S;
int N,R=0,i;
cin >> N;
for(i=0;i<N;i++) {
cin >> S;
if(S == 'R')R++;
}
if(R*2 > N)cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
board = 3.times.map { gets.split.map(&:to_i) }
horizontal_diff_list = [
  board[0][0] - board[0][1],
  board[0][1] - board[0][2]
]
vertical_diff_list = [
  board[0][0] - board[1][0],
  board[1][0] - board[2][0]
]
horizontal_ok = (1..2).all? do |i|
  [
    board[i][0] - board[i][1],
    board[i][1] - board[i][2]
  ] == horizontal_diff_list
end
vertical_ok = (1..2).all? do |j|
  [
    board[0][j] - board[1][j],
    board[1][j] - board[2][j]
  ] == vertical_diff_list
end
ans = horizontal_ok && vertical_ok ? 'Yes' : 'No'
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int32_t main()
{
	IOS
	int n,k;cin>>n>>k;
	vector<int>h(n+1);
	vector<int>dp(n+1);
	for(int i=1;i<=n;i++)
	cin>>h[i];
	
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=1e15;
		for(int j=i-1;j>=i-k && j > 0 ;j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	
	cout << dp[n] << endl;
	
}


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


int main() {
int A,B,T;
  cin >>A>>B>>T;//秒枚秒
  
  int ans=0;
  int t=0;
  while(t+A<T+0.5){
    t+=A;
    ans+=B;
    
   // cout<<t<<B<<endl;
  }
  
  cout<<ans<<endl;
  

}


Measured memory_bytes: 256