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

int main()
{
  vector<int> V(3);
  cin >> V.at(0) >> V.at(1) >> V.at(2);
  
  sort(V.begin(), V.end(), greater<int>());
  int ans = V.at(0) * 10 + V.at(1) + V.at(2);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int a, b, c;
  char x[10000];
  while(1){
    scanf("%d %c %d", &a, x, &b);
    if(!strcmp(x, "?")){
      break;
    }
    if(!strcmp(x, "+")){
      c = a + b;
    }
    if(!strcmp(x, "-")){
      c = a - b;
    }
    if(!strcmp(x, "/")){
      c = a / b;
    }
    if(!strcmp(x, "*")){
      c = a * b;
    }
    printf("%d\n", c);
  }
  return 0;
}


Measured memory_bytes: 1972
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 5100
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll q,h,s,d; cin >> q >> h >> s >> d;
    ll n; cin >> n;
    ll ans = 0;
    ll min2 = min({q*8,h*4,s*2,d});
    ans += n / 2 * min2;
    ll min1 = min({q*4,h*2,s});
    ans += (n % 2) * min1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[200005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    int i;

    int ans=0;
    int cnt=0;
    for(i=0; i<n; i++) {
        if(str[i]=='S') {
            cnt++;
        }
        else {
            if(cnt) {
                ans++;
                cnt--;
            }
        }
    }
    printf("%d\n", n-ans*2);
   



    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
  long long int n,q,sum=0,cnt=0;
  cin>>n;
  long long int arr[n],i,b,c;
  long long int h[100005]={0};
  for(i=0;i<n;i++)
  {
  	cin>>arr[i];
  	sum+=arr[i];
  	h[arr[i]]++;
  }
  cin>>q;
  while(q--)
  {
  	cin>>b>>c;
  	cnt=h[b];
  	sum-=cnt*b;
  	sum+=cnt*c;
  	cout<<sum<<endl;
  	h[c]+=h[b];
  	h[b]=0;
  }
}

Measured memory_bytes: 5096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<LL> v1;

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	LL x,y,z;
	for(i=0;i<m;i++){
		cin>>x>>y>>z;
		a=0,b=0,x--,y%=z;
		for(j=0;j<n;j++){
			c=v1[j]%z;
			if(c==0)c=z;
			a+=c;
			if(j<x%n)b+=c;
		}
		a=y+(x/n)*a+b;
		a/=z;
		cout<<x-a<<endl;
	}
}

Measured memory_bytes: 384
N = int(input())
a = []
for i in range(N):
  a.append(int(input()))

sort = sorted(a)
m1 = sort[-1]
m2 = sort[-2]
if m1 == m2:
  for i in range(N):
    print(m1)
else:
  j = a.index(m1)
  for i in range(N):
    if i == j:
      print(m2)
    else:
      print(m1)

Measured memory_bytes: 14240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string coror;
  cin >> N;
  
  for (int i=0; i < N; i++) {
    cin >> coror;
    if (coror == "Y")
      break;
  }
  if (coror == "Y")
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

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

void msort(long *array, int n_elem) {
	if(n_elem == 1) return;
	if(n_elem == 2) {
		if(array[0] > array[1]) {
			long temp = array[0];
			array[0] = array[1];
			array[1] = temp;
		}
		return;
	}
	long *p_array;
	int p_length = n_elem / 2;
	p_array = (long *)malloc(sizeof(long) * p_length);
	long *s_array;
	int s_length = n_elem - n_elem / 2;
	s_array = (long *)malloc(sizeof(long) * s_length);

	memcpy(p_array, array, sizeof(long) * p_length);
	memcpy(s_array, array + p_length, sizeof(long) * s_length);
	msort(p_array, p_length);
	msort(s_array, s_length);

	int i;
	int p_idx = 0;
	int s_idx = 0;
	for(i=0;i<n_elem;i++) {
		if(p_idx > p_length - 1) {
			array[i] = s_array[s_idx];
			s_idx++;
			continue;
		}
		if(s_idx > s_length - 1) {
			array[i] = p_array[p_idx];
			p_idx++;
			continue;
		}
		if(p_array[p_idx] > s_array[s_idx]) {
			array[i] = s_array[s_idx];
			s_idx++;
		} else {
			array[i] = p_array[p_idx];
			p_idx++;
		}
	}
	free(p_array);
	free(s_array);
}

int main() {
	int n;
	scanf("%d", &n);
	long *d;
	d = (long *)malloc(sizeof(long) * n);
	int i;
	for(i=0;i<n;i++) {
		scanf("%ld", &d[i]);
	}
	int m;
	scanf("%d", &m);
	long *t;
	t = (long *)malloc(sizeof(long) * m);
	for(i=0;i<m;i++) {
		scanf("%ld", &t[i]);
	}
	msort(d, n);
	msort(t, m);

	/*for(i=0;i<n;i++) {
		printf("%ld, ", d[i]);
	}
	printf("\n");

	for(i=0;i<m;i++) {
		printf("%ld, ", t[i]);
	}
	printf("\n");*/
	
	int flag = 0;
	int d_idx = 0;
	for(i=0;i<m;i++) {
		//printf("%ld vs %ld\n", t[i], d[d_idx]);
		if(t[i] > d[d_idx]) {
			d_idx++;
			i--;
			continue;
		}
		if(t[i] < d[d_idx]) {
			//printf("I'm ... out of problems\n");
			flag = 1;
			break;
		}
		d_idx++;
	}
	if(flag) {
		printf("NO");
	} else {
		printf("YES");
	}

	free(d);
	free(t);
	return 0;
}


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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  bool flag = true;
  int cnt1=0;
  while(flag){
    if(b>a){
      break;
    }
    b=b*2;
    cnt1++;
  }
  while(flag){
    if(c>b){
      break;
    }
    c=c*2;
    cnt1++;
  }
  if(cnt1<=k){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
s = list(input())
t = list(input())

ans = len(t)
if len(s) == len(t):
    icchi = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            icchi += 1
    ans = len(t)-icchi
else:
    for i in range(len(s)-len(t)):
        a = s[i:i + len(t)]
        icchi = 0
        for j in range(len(t)):
            if a[j] == t[j]:
                icchi += 1
        ans = min(ans, len(t)-icchi)


print(ans)


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  ll s;
  cin >> s;
  set<ll> st;

  ll cnt = 1;
  ll a = s;
  do {
    st.insert(a);
    if(a % 2 == 0) {
      a = a / 2;
    } else {
      a = 3 * a + 1;
    }
    cnt++;
    //    cout << a << " " << endl;
  } while(st.find(a) == st.end());
  //  cout << endl;
  cout << cnt << endl;
}


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

int main(){
    int n,ans=0;
    long long d,x,y,sum;
    cin >> n >> d;
    for (int i=0;i<n;i++){
        cin >> x >> y;
        if (x*x+y*y<=d*d){
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int p=1000000007;
ll fast (ll d,ll z,ll m) {//快速幂
	ll ans=1;
	for (d%=m;z;ans=ans*(z&1?d:1)%m,z>>=1,d=d*d%m);
	return ans;
}
ll ni (int num) {
	return fast(num,p-2,p);
} 
int main () {
	ll a,b,x,y;
	cin>>a>>b;
	x=(2*a-b)/3;
	y=(2*b-a)/3;
	if (x<0||y<0||(a+b)%3!=0) {
		cout<<0;
	} else {
		ll ans=1,t=1,n=x+y,r=min(x,y);
		for (int i=0;i<r;i++) {
			ans=ans*(n-i)%p;
			t=t*(i+1)%p;
		}
		cout<<ans*ni(t)%p;
	}
}

Measured memory_bytes: 384
#include<cstdio>
#include<cctype>
#include<cstring>

int main(void){
	
	char ch, seq[1200];
	int count[26] = {};
	
	int l = 0;
	while( scanf("%c", &ch) != EOF){
		seq[l] = ch;
		l++;
	}
	
	for(int i= 0;i < strlen(seq); i++){
		if (isalpha(seq[i])){
			seq[i] = tolower(seq[i]);
			int num = seq[i] - 'a';
			count[num] += 1;
		}
	}
	
	for(int j =0; j<26; j++){
		int a = 'a';
		printf("%c : %d\n", a + j , count[ j]);
	}
	
	
	return 0;
}

Measured memory_bytes: 980
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

typedef struct{
	int tarou;
	int hanako;
}two_point;

int main(){

	while(true){
		int t_p,h_p;
		int t_sum=0,h_sum=0;
		int t_a,h_a;

		cin >> t_p >> h_p;

		if(t_p==0&&h_p==0) break;

		int t[t_p],h[h_p];

		for(int i=0;i<t_p;i++){
			cin >> t[i];
			t_sum+=t[i];
		}
		for(int i=0;i<h_p;i++){
			cin >> h[i];
			h_sum+=h[i];
		}

		int answer = 10000;

		for(int i=0;i<t_p;i++){
			for(int j=0;j<h_p;j++){
				int ans = h[j]-t[i];	
				if(h_sum-ans == t_sum+ans){
					if(t[i]+h[j]<answer){
						
						t_a=t[i];
						h_a=h[j];
						answer=t_a+h_a;
					}
				}
			}
		}
		if(answer==10000){
			cout << -1 << endl;
		}else{
			cout << t_a << " " << h_a << endl;
		}

	}
	
}

Measured memory_bytes: 1160
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
	int A,B,x,y;
	char grid[100][100];
	cin>>A>>B;
	
	for(int y=0;y<50;y++){
		for(int x=0;x<100;x++){
			grid[y][x]='.';
			grid[y+50][x]='#';
		}
	}
	
	A--;
	B--;
	 
	x=1;
	y=0;
	while(B>0){
		grid[y][x]='#';
		x+=2;
		if(x>99){
			y+=2;
			x=1;
		}
		B--;
	}

	x=1;
	y=51;
	while(A>0){
		grid[y][x]='.';
		x+=2;
		if(x>99){
			y+=2;
			x=1;
		}
		A--;
	}	

	cout<<100<<" "<<100;	
	for(y=0;y<100;y++){
		cout<<endl;
		for(x=0;x<100;x++) cout<<grid[y][x];
	}
	
    rt0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
 struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l==NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
printf("%d",c);
  }
printf("]\n");
}

void rec(int u,int p){
  D[u]=p;
  if(T[u].r != NIL)rec(T[u].r,p);
  if(T[u].l !=NIL)rec(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
     scanf("%d",&c);
     if(j==0)T[v].l=c;
     else T[l].r=c;
     l=c;
     T[c].p=v;
    }
  }
for(i=0;i<n;i++){
  if(T[i].p==NIL)r=i;
}
rec(r,0);
for(i=0;i<n;i++)print(i);
return 0;
}



Measured memory_bytes: 6380
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void swim(int A[], int begin, int end, int key) {
    int i = 0;
    for(i = end; i >= begin ; i--) {
        if(A[i] <= key) break;
        else A[i+1] = A[i];
    }
    A[i+1] = key;
}

int main(){
  int n;
  int A[N+1];
  scanf("%d", &n);

  for(int i = 0; i < n; i++ ) scanf("%d", &A[i]);

  trace(A, n);
  for(int i = 1; i < n; i++) {
    int key = A[i];
    swim(A, 0, i-1, key);
    trace(A, n);
  }
  return 0;
}

Measured memory_bytes: 2688
import sys


def input():
    return sys.stdin.readline().strip()


x, y, a, b, c = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)[:x]
Q = sorted(list(map(int, input().split())), reverse=True)[:y]
R = list(map(int, input().split()))

print(sum(sorted(P + Q + R, reverse=True)[:x + y]))


Measured memory_bytes: 22616
#include <cstdio>

using namespace std;

int main()
{
    long A, B;
    char op;

    scanf("%ld %c %ld", &A, &op, &B);

    if (op == '+') {
        printf("%ld\n", A + B);
    } else {
        printf("%ld\n", A - B);
    }

    return 0;
}


Measured memory_bytes: 128
n, k, q = list(map(int, input().split()))
ans = [0]*n
for i in range(q):
  a = int(input())
  a -= 1
  ans[a] += 1
for i in range(n):
  ans[i] = k - q + ans[i]
  if ans[i]>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 7752
/* Read input from STDIN. Print your output to STDOUT*/

import java.io.*;
import java.util.*;
public class Main {
    static int[][] a;
    static int[][] dp;
    static int n;
    public static void main(String args[] ) throws Exception {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        a=new int[n][3];
        dp=new int[n][3];
        for(int[] i:dp)Arrays.fill(i,-1);
        for(int i=0;i<n;i++){
            a[i][0]=sc.nextInt();
            a[i][1]=sc.nextInt();
            a[i][2]=sc.nextInt();
        }
        int ans=0;
        ans=a[0][0]+solve(1,0);
        ans=Math.max(ans,a[0][1]+solve(1,1));
        ans=Math.max(ans,a[0][2]+solve(1,2));
        System.out.println(ans);
    }
    static int solve(int day,int flag){
        if(day==n)return 0;
        if(dp[day][flag]!=-1)return dp[day][flag];
        int ans=0;
        if(flag==0){
            ans=Math.max(ans,a[day][1]+solve(day+1,1));
            ans=Math.max(ans,a[day][2]+solve(day+1,2));
        }
        else if(flag==1){
            ans=Math.max(ans,a[day][0]+solve(day+1,0));
            ans=Math.max(ans,a[day][2]+solve(day+1,2));
        }
        else{
            ans=Math.max(ans,a[day][0]+solve(day+1,0));
            ans=Math.max(ans,a[day][1]+solve(day+1,1));
        }
        dp[day][flag]=ans;
        return dp[day][flag];
    }
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=1e5+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
//#define int ll

int a, b, c;

main()
{
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

LL n,m,k;
LL a[500005];
LL tmp = 1;

LL gcd(LL x,LL y){
	if(!y) return x;
	return gcd(y,x % y);
}

LL calc(LL x){
	LL ret = 0;
	while(x % 2 == 0){
		x >>= 1;
		ret ++;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	LL N = 10000;
	N = N * N * 30;
//	cout << N << endl;
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i];
		tmp = tmp * a[i] / gcd(tmp,a[i]);
		if(tmp > N){
			cout << 0 << endl;
			return 0;
		}
	}
	
	for(LL i = 2;i <= n;i ++){
		if(calc(a[i]) != calc(a[1])){
			cout << 0 << endl;
			return 0;
		}
	}
	
	cout << (m + tmp / 2) / tmp << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

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

int main() {
    bool flag = false;
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        char s;
        cin >> s;
        if (s == 'Y') {
            flag = true;
        }
    }
    if (flag) {
        cout << "Four\n";
    } else {
        cout << "Three\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
s = input()
r = 0
p = 0
score = 0
for x in s:
    if x == "g":
        if p < r:
            p += 1
            score += 1
        else:
            r += 1
    else:
        if p < r:
            p += 1
        else:
            score -= 1
            r += 1
print(score)

Measured memory_bytes: 3316
n,k,q = map(int,input().split())
a = [0] * q
b = [0] * (n + 1)
for i in range(q):
  a = int(input())
  b[a] += 1

m = q - k + 1
for i in range(1,n +1):
  if b[i] >= m:
    print('Yes')
  else:
    print('No')

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

int main() {
 int a,b;cin>>a>>b;
string S;
  cin>>S;
  if(S.size()==(a+b+1)){
    if(S.at(a)=='-'){
  for(int i=0; i<S.size(); i++){
    if(S.at(i)=='-'&&i!=a){cout<<"No"<<endl;break;}
    if(i==S.size()-1){cout<<"Yes"<<endl;}
  }
    }
      else{cout<<"No"<<endl;}
  }
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define aint(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revrep(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define ii pair<int,int>
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   int a,b,c;
   cin>>a>>b>>c;
   map<int,int> mp;
   mp[a]++,mp[b]++,mp[c]++;
   if(mp[5] == 2 and mp[7] ==1)
    cout<<"YES";
   else
    cout<<"NO";
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n,a,b; cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int main(){
  int n,m; cin >>n >>m;
  atcoder::scc_graph g(n);
  rep(i,m){
    int u,v; cin >>u >>v;
    g.add_edge(u,v);
  }
  vector<vector<int>> adj=g.scc();
  print(adj.size());
  for(auto x:adj) print(x.size(),x);
}


Measured memory_bytes: 40092
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if (A == B & B == C & C == A) yes;
    else no;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>

using namespace std;

#define ll long long

int main(){
  string s;
  cin >> s;
  ll n = s.length();
  vector< pair<ll,ll> > v;
  stack<ll> st;
  for(ll i = 0; i < n; i++){
    if(s[i] == '/'){
      if(st.size()){
	v.push_back(make_pair(st.top(),i));
	st.pop();
      }
    }else if(s[i] == '_'){

    }else{
      st.push(i);
    }
  }

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

  list<ll> ans;
  ll sum = 0;
  {
    vector< pair<ll,ll> > :: iterator it = v.begin();

    while(it != v.end()){
      ll ps = 0;
      ll e = (*it).second;
      while(it != v.end() && (*it).first < e){
	ps += (*it).second - (*it).first;
	it++;
      }
      sum += ps;
      ans.push_back(ps);
    }

  }
  cout << sum << '\n';
  cout << ans.size();
  for(list<ll>::iterator it = ans.begin(); it != ans.end(); it++){
    cout << ' ' << *it;
  }
  cout << '\n';
}

Measured memory_bytes: 3352
/*Lower_Rating*/
/*AGC036 F Square Constraints*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;

#define LL long long
#define MAXN 500
#define Pr pair<int,int>
#define X first
#define Y second
#define INF (1LL<<60)
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
LL MOD;
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

int n,tot,ans;
Pr p[MAXN+5];
int dp[MAXN+5][MAXN+5];
int main()
{
    //freopen("square.in","r",stdin);
    //freopen("square.out","w",stdout);
    n=read(),MOD=read();
    for(int i=0,vf=2*n,vg=2*n;i<2*n;i++){
        while(i*i+(vf-1)*(vf-1)>4*n*n&&vf>0)vf--;
        while(i*i+(vg-1)*(vg-1)>=n*n&&vg>0)vg--;
        if(i<n)p[++tot]=Pr(vg,vf);
        else p[++tot]=Pr(vf,0);
    }
    sort(p+1,p+tot+1);
    for(int k=0;k<=n;k++){
        memset(dp,0,sizeof(dp));
        dp[1][0]=1;
        int cntf=0,cntg=0;
        for(int i=1;i<=tot;i++){
            for(int j=0;j<=k;j++)
            if(p[i].Y==0)dp[i+1][j]=add(dp[i+1][j],mul(dp[i][j],(p[i].X-j-cntf)));
            else{
                if(j<k)dp[i+1][j+1]=add(dp[i+1][j+1],mul(dp[i][j],(p[i].X-j-cntf)));
                dp[i+1][j]=add(dp[i+1][j],mul(dp[i][j],(p[i].Y-n-k-(cntg-j))));
            }
            if(p[i].Y==0)cntf++;
            else cntg++;
        }
        if(k%2)ans=dec(ans,dp[tot+1][k]);
        else ans=add(ans,dp[tot+1][k]);
    }
    printf("%d",ans);
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    int n,k; cin >> n >> k;

    double ans = 0.0;

    for(int init=1; init<n+1; init++){

        //cout << init << " " << k << endl;

        if(init >= k){ans+=1.0/(n+0.0); continue;}

        int temp = init;
        int cnt = 0;
        double x = 1.0/(n+0.0);

        while(temp<k){
            cnt++;
            temp*=2;
            x*=0.5;
        }

        //cout << x << endl;

        ans+=x;

    }

    cout << std::setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int k;
    int s;
    cin >> k;
    cin >> s;
    int sum = 0;
    int count = 0;
    for (int i = 0;i <= k;++i) {
        for (int j = 0;j <= k;++j) {
            int sum = i + j;
            if ((s-sum) <= k && (s-sum) >= 0)
                ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463; int < 2*10^9

int main(void){
  ll n; cin >> n;

  double r = sqrt(n);
  ll q = (ll) r;
  for(ll i = q; i > 0; i--){
    if(n%i == 0){
      cout << (i-1) + (n/i-1) << endl;
      return 0;
    }
  }

  return 0;
}

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

int main(){

    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> s(n);
        int sum = 0;
        for(int i = 0; i < n; ++i){
            cin >> s[i];
            sum += s[i];
        }
        
        double average = (double) sum / (double) n;
        double ans = 0;
        for(int i = 0; i < n; ++i){
            ans += pow((double)s[i] - average, 2);
        }
        cout << fixed << setprecision(10) << sqrt(ans / (double) n) << endl;
    }

    return 0;
}


Measured memory_bytes: 3268
#52 1日かかった
N = int(input())
b = list(map(int,input().split()))
a = [0 for i in range(N)]

a[0] = b[0]
for i in range(N-2):
    a[i+1] = min(b[i],b[i+1])

a[-1] = b[-1]
            
        
    

print(sum(a))

Measured memory_bytes: 9184
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

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

	ll n;
	string s;
	cin >> n >> s;
	ll white_num=0, black_num=0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == '.')
			white_num++;
	}

	ll ret = white_num;
	for (ll i = 0; i < n; i++) {
		if (s[i] == '.') {
			white_num--;
		}
		if (s[i] == '#') {
			black_num++;
		}
		ret = min(ret, white_num + black_num);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 832
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn main(){
    let line = read_as_vec::<i64>();
    let (n, a, b) = (line[0], line[1], line[2]);
    let (a, b) = (cmp::min(a, b), cmp::max(a, b));
    if (a-b).abs()%2 == 0{
        println!("{}", (a-b).abs()/2);
        return;
    }

    println!("{}", cmp::min(
        ((b-a)-1)/2+a,
        (n-(a+(n-b+1)))  /2+(n-b+1)
    ));
}


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

int main(){
  int n,cou=0,count=0,time;
  int len,oldlen;
  char com[33],tmp[33];
  char old[111];
  string strtmp,strcom;
  cin >> n;
  cin >> com;
  strcom = com;
  len = strlen(com);
  while(cou!=n){
    cou++;
    cin >> old;
    oldlen = strlen(old);
    for(int i=0;i<oldlen;i++){
      time = 1;
      if(com[0] == old[i]){
	while(i+time*(len-1) < oldlen){
	  strtmp = old[i];
	  for(int j=1;j<len;j++){
	    strtmp += old[i+time*j];
	  }
	  if(strcom == strtmp){
	    count++;
	    i = oldlen;
	  }
	  else time++;
	}
      }
    }
  }
  cout << count << endl;
}

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

R = [input().split()+[i] for i in range(1, N+1)]

R = [[r[0], int(r[1]), r[2]] for r in R]

city = ''
stars = []
for r in sorted(R):
  if city != r[0]:
    for star in reversed(stars):
      print(star)
    city = r[0]
    stars = [r[2]]
  else:
    stars.append(r[2])
for star in reversed(stars):
  print(star)

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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    cout << (a <= x && a+b >= x ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
// // #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<int>v[4];
	ll n, w;
	cin >> n >> w;
	vector<ll>weight(n), value(n);
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> value[i];
	}
	for (int i = 0; i < n; i++) {
		v[weight[i] - weight[0]].pb(value[i]);
	}
	for (int i = 0; i < 4; i++) {
		sort(v[i].begin(), v[i].end(), greater<int>());
	}
	ll k = weight[0];
	ll ans = 0;
	for (int one = 0; one <= v[0].size(); one++) {
		for (int two = 0; two <= v[1].size(); two++) {
			for (int three = 0; three <= v[2].size(); three++) {
				for (int four = 0; four <= v[3].size(); four++) {
					ll total_w = k * one + (k + 1) * two + (k + 2) * three + (k + 3) * four;
					if (total_w > w)continue;
					ll temp = 0;
					for (int i = 0; i < one; i++)temp += v[0][i];
					for (int i = 0; i < two; i++)temp += v[1][i];
					for (int i = 0; i < three; i++)temp += v[2][i];
					for (int i = 0; i < four; i++)temp += v[3][i];
					ans = max(ans, temp);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_macros, unused_imports, dead_code, non_snake_case)]

use std::io;

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

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

macro_rules! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; input_inner ! {iter , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let mut s = {use std :: io :: Read ; let mut s = String :: new () ; std :: io :: stdin () . read_to_string (& mut s ) . unwrap () ; s } ; let mut iter = s . split_whitespace () ; input_inner ! {iter , $ ($ r ) * } } ; }
macro_rules! input_inner {($ iter : expr ) => {} ; ($ iter : expr , ) => {} ; ($ iter : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ iter , $ t ) ; input_inner ! {$ iter $ ($ r ) * } } ; ($ iter : expr , mut $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let mut $ var = read_value ! ($ iter , $ t ) ; input_inner ! {$ iter $ ($ r ) * } } ; }
macro_rules! read_value {($ iter : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ iter , $ t ) ) ,* ) } ; ($ iter : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ iter , $ t ) ) . collect ::< Vec < _ >> () } ; ($ iter : expr , chars ) => {read_value ! ($ iter , String ) . chars () . collect ::< Vec < char >> () } ; ($ iter : expr , usize1 ) => {read_value ! ($ iter , usize ) - 1 } ; ($ iter : expr , $ t : ty ) => {$ iter . next () . unwrap () . parse ::<$ t > () . expect ("Parse error" ) } ; }

fn main() {
    loop {
        from_line!(n:usize, r:usize);
        if n == 0 { break }
        let mut g = vec![0; n];
        for i in 0..n {
            g[i] = n - i;
        }
        for _ in 0..r {
            from_line!(p:usize, c:usize);
            let mut f = Vec::new();
            for i in 0..c {
                f.push(g[p-1+i]);
                g[p-1+i] = 0;
            }
            for &x in &g {
                if x > 0 {
                    f.push(x);
                }
            }
            g = f;
            // println!("{:?}", g);
        }
        println!("{}", g[0]);
    }
}



Measured memory_bytes: 5048
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    long[] l = new long[n+1];
    foreach (i; 0 .. n)
    {
        l[i+1] = gcd(l[i], a[i]);
    }

    long[] r = new long[n+1];
    foreach_reverse (i; 0 .. n)
    {
        r[i] = gcd(r[i+1], a[i]);
    }

    long result;
    foreach (i; 0 .. n)
    {
        result = max(result, gcd(l[i], r[i+1]));
    }

    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 7208
n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 1e10
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)


Measured memory_bytes: 2940
import java.util.List;
import java.util.Scanner;
import java.util.function.LongSupplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	};
	public static void main(String[] __) throws Exception{
		int n,m;
		solve:
		while((n=s.nextInt())+(m=s.nextInt())!=0){
			List<Integer>
			t=REPS(n).mapToObj(i->s.nextInt()).collect(Collectors.toList()),
			h=REPS(m).mapToObj(i->s.nextInt()).collect(Collectors.toList());
			int
			sumt=t.parallelStream().mapToInt(v->v).sum(),
			sumh=h.parallelStream().mapToInt(v->v).sum();
			if((sumt+sumh)%2==1) {
				System.out.println(-1);
				continue solve;
			}
			for(int i:t) {
				if(h.contains(i+(sumh-sumt)/2)) {
					System.out.printf("%d %d\n",i,i+(sumh-sumt)/2);
					continue solve;
				}
			}
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 35944
use std::collections::BTreeMap;
use std::collections::btree_map::Entry::{Vacant, Occupied};

fn main() {
    let n = read::<usize>();
    let mut ma = 0;
    let mut map: BTreeMap<String, usize> = BTreeMap::new();
    for _ in 0..n {
        let s = read::<String>();
        match map.entry(s.clone()) {
            Vacant(entry) => { entry.insert(1); },
            Occupied(mut entry) => { *entry.get_mut() += 1; }
        }

        let tmp = map.get(&s).unwrap();
        if ma < *tmp {
            ma = *tmp;
        }
    }

    for (k, v) in map.iter() {
        if *v == ma {
            println!("{}", k);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


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

table = [[0] * 10 for _ in range(10)]

for i in range(1, n+1):
    i = str(i)
    head = int(i[0])
    tail = int(i[-1])
    table[head][tail] += 1

ans = 0
for i in range(10):
    for j in range(10):
        if(i == j):
            ans += table[i][i]**2
        else:
            ans += table[i][j]*table[j][i]
print(ans)

Measured memory_bytes: 40428
from collections import deque
n, q = map(int, input().split())
queue = deque()
for _ in range(n):
    name, time = input().split()
    queue.append((name, int(time)))

comp = []
t = 0
while queue:
    name, time = queue.popleft()
    if time <= q:
        t += time
        comp.append((name, t))
    else:
        t += q
        queue.append((name, time - q))
for s in comp:
    print(*s)


Measured memory_bytes: 14296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  string s, t, r;
  cin >> s >> t >> r;

  cout << s[0] << t[1] << r[2] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<tuple<string,int,int>>a;
  for(int i=1;i<=N;++i){
    string s;    int p;
    cin>>s>>p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  rep(i,N){
    cout<<get<2>(a[i])<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
const int mod = 1e9+7;

vector<ll> fac(3000);
vector<ll> ifac(3000);

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

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main(){
    int n,k;
    cin >> n >> k;
    
    fac[0] = 1;
    ifac[0] = 1;
    rep(i,3000){
        fac[i+1] = fac[i] * (i+1) % mod;
        ifac[i+1] = ifac[i]*mpow(i+1,mod-2) % mod;
    }
    ll tmp = 0;
    reps(i,1,k+1){
        tmp = comb(n-k+1,i) * comb(k-1,i-1) % mod;
        cout << tmp << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int sum,pascal[10]={1,9,36,84,126,126,84,36,9,1};
	double t;
	char input[11];
	while (cin>>input) {
		sum=0;
		for (int i=0; i<10; i++) sum+=(input[i]-'0')*pascal[i];
		cout<<sum%10<<endl;
	}
}

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


int tree[26][1000010]={0};// tree e lazy 2*tam_arr
int n;//size Seg
void build(int id){
	for(int i=n-1;i>0;i--) tree[id][i] = tree[id][i<<1] | tree[id][i<<1|1];
}
void update(int id,int p,int val){
	for(tree[id][p+=n]=val;p>1;p>>=1) tree[id][p>>1] = tree[id][p]|tree[id][p^1];
}
int query(int l,int r){ // [l,r)
	int resp=0;
	for(int id=0;id<26;id++){
		int aux =0;
		for(int posl=n+l,posr=n+r;posl<posr;posl>>=1,posr>>=1){
			if(posl&1) aux|=tree[id][posl++];
			if(posr&1) aux|=tree[id][--posr];
		}
		resp+=aux;
	}
	return resp;
}

int main(){
	scanf("%d",&n);
	string str;
	cin >> str;
	for(int i=0;i<n;i++)
		tree[str[i]-'a'][i+n]++;
	for(int i=0;i<26;i++)
		build(i);
	int q,t,l,r;
	char c;
	
	scanf("%d",&q);
	while(q--){
		scanf("%d",&t);
		if(t==1){
			scanf(" %d %c ",&l,&c);
			l--;
			update(str[l]-'a',l,0);
			update(c-'a',l,1);
			str[l] = c;
		}else{
			scanf("%d %d",&l,&r);
			l--;
			printf("%d\n",query(l,r));
		}
	}
}

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

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

const int N = 1e5 + 5;
int n, m, t;
auto cmp = [](ii a, ii b) {
  return a.first / pow(2, a.second) < b.first / pow(2, b.second);
};
priority_queue<ii, vector<ii>, decltype(cmp)> pq(cmp);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    pq.push({t, 0});
  }
  while (m) {
    auto a = pq.top();
    pq.pop();
    ++a.second;
    m--;
    pq.push(a);
  }
  ll res = 0;
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    res += p.first / (int)pow(2, p.second);
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside.
//AVX is better slightly
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

int l;

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    cin >> l;
    double len = 1.0 * l / 3;
    cout << fixed << setprecision(6) << len*len*len;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = input()
    a = input().split()

    a = list(map(int,a))

    ans = 0

    for i in a:
        while True:
            if i%2==0:
#                print(i)
                i = i/2
                ans+=1
                continue
            else:
                break

    print(ans)


if __name__ == "__main__":
        main()


Measured memory_bytes: 4148
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
    while(true){
        int ans = 0;
        string num;
        cin >> num;
        if(num[0] == '0') exit(EXIT_SUCCESS);
        for(int i = 0; i < 1000; i++) if(num[i] >= '0' && num[i] <= '9') ans += num[i] - '0'; else if(num[i] == '\0') break;
        cout << ans << endl;
    }
}



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

int main() {
    ll n, k;
    cin >> n >> k;
    ll h[n + 1], dp[n + 1];
    For(i, n) {
        cin >> h[i];
        dp[i] = 0;
    }
    dp[2] = abs(h[2] - h[1]);
    if(k <= n) {
        For(i, k - 2) {
            dp[i + 2] = dp[1] + abs(h[1] - h[i + 2]);
            For(j, i + 2) if(dp[j] + abs(h[j] - h[i + 2]) < dp[i + 2])
                dp[i + 2] = dp[j] + abs(h[j] - h[i + 2]);
        }
        For(i, n - k) {
            dp[i + k] = dp[i] + abs(h[i] - h[i + k]);
            for(int j = i; j <= i + k; ++j) if(dp[j] + abs(h[j] - h[i + k]) < dp[i + k])
                dp[i + k] = dp[j] + abs(h[j] - h[i + k]);
        }
    }
    else {
        For(i, n - 2) {
            dp[i + 2] = dp[1] + abs(h[1] - h[i + 2]);
            For(j, i + 2) if(dp[j] + abs(h[j] - h[i + 2]) < dp[i + 2])
                dp[i + 2] = dp[j] + abs(h[j] - h[i + 2]);
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        final int A = Integer.parseInt(sc.next());
        final int B = Integer.parseInt(sc.next());
        int sockets = 1;
        int ans = 0;
        while (sockets < B) {
            sockets += A-1;
            ans++;
        }
        out.println(ans);

        out.flush();
    }
}

Measured memory_bytes: 21716
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[i for i in a if i.count("#")>0]
for i in range(w-1,-1,-1):
    if sum([b[j][i]=="#" for j in range(len(b))])==0:
        for k in range(len(b)):
            b[k]=b[k][:i]+b[k][i+1:]
print(*b,sep="\n")

Measured memory_bytes: 3064