akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    vector<int> wmemo;
    vector<int> hmemo;
    for(int i=0;i<h;i++){
        bool flag=true;
        for(int j=0;j<w;j++){
            if('#'==a[i][j]){
                flag=false;
                break;
            }
        }
        if(flag){
            hmemo.push_back(i);
        }
    }
    for(int i=0;i<w;i++){
        bool flag=true;
        for(int j=0;j<h;j++){
            if('#'==a[j][i]){
                flag=false;
                break;
            }
        }
        if(flag){
            wmemo.push_back(i);
        }
    }
    for(int i=0;i<h;i++){
        if(hmemo.end()!=find(hmemo.begin(),hmemo.end(),i)){
            continue;
        }
        for(int j=0;j<w;j++){
            if(wmemo.end()!=find(wmemo.begin(),wmemo.end(),j)){
                continue;
            }
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; ++i)
#define REP(i, n)  for(int i=0; i<(int)(n); ++i)
#define REPS(i, n)  for(int i=1; i<=(int)(n); ++i)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); ++i)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); ++i)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ull MOD = 998244353;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int n;  cin >> n;
  vector<int> A(n);
  map<int, int> dict;

  bool dp[1000007];
  REP(i, 1000007){
    dp[i]=true;
  }
  REP(i, n){
    cin >> A[i];
    if(false == dp[A[i]]){
      continue;
    }
    dict[A[i]]++;
    if(dict[A[i]]>1){
      dp[A[i]] = false;
      continue;
    }
    for(int j=2; A[i]*j<1000007; ++j){
      dp[A[i]*j]=false;
    }
  }
  int ans = 0;
  REP(i, n){
    if(dp[A[i]]){
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 14112
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int h, w;
char grid[10][10];
bool vis[10][10];

int main() {
    memset(grid, 0, sizeof(grid));
    memset(vis, 0, sizeof(vis));
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) {
        scanf("%s", &grid[i][1]);
    }
    int x = 1, y = 1;
    vis[1][1] = true;
    bool possible = true;
    while (x != h || y != w) {
        //printf("%d %d\n", x, y);
        bool right = false, down = false;
        if (y < w) {
            if (grid[x][y + 1] == '#') right = true;
        }
        if (x < h) {
            if (grid[x + 1][y] == '#') down = true;
        }
        if (right && down) {
            possible = false;
            break;
        } else if (right) {
            y++;
        } else if (down) {
            x++;
        } else {
            possible = false;
            break;
        }
        vis[x][y] = true;
    }
    if (!possible) {
        printf("Impossible\n");
        return 0;
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (grid[i][j] == '#') {
                if (!vis[i][j]) {
                    printf("Impossible\n");
                    return 0;
                }
            }
        }
    }
    printf("Possible\n");
}

Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
for i in range(n):
    d = {}
    for j in s[:i]:
        if d.get(j, 0) == 0:
            d[j] = 1
    for j in s[i:]:
        if d.get(j, 0) == 1:
            d[j] = 2
    t = 0
    for j in d:
        if d[j] == 2:
            t += 1
    ans = max(ans, t)

print (ans)

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0;bool b=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')b=1;c=getchar();}
	while(c>='0'&&c<='9')n=(n<<3)+(n<<1)+(c^48),c=getchar();
	return b?-n:n;
}
int k,n;
main()
{
	k=read();n=read();
	if(500*k>=n)puts("Yes");
	else		puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k ;
    cin >>n>>k ;
   long long  int l =n/k;
    long long int m =(2*n/k )-l ;
    long long int x= l*l*l;
    long long int y= m*m*m ;
  if(k%2==0)
  cout << x+y << endl;
  else
  cout <<  x<< endl;
}

Measured memory_bytes: 256
S=list(input())
n=len(S)
ans=0
ansl=[0]
for i in range(n):
    if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
        ans+=1
    else:
        ans=0
    ansl.append(ans)
ansl.sort(key=int)
print(ansl[n])

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m;
bool x[200010], y[200010];

int main() {
    cin >> n >> m;
    rep(i, m) {
        int a, b; cin >> a >> b;
        if (a == 1) x[b] = true;
        if (b == n) y[a] = true;
    }

    bool flg = false;
    for (int i = 2; i <= n; i++) {
        if (x[i] && y[i]) flg = true;
    }
    if (flg) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


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

using namespace std;
using ll = long long;

vector<ll> P(51), A(51);

ll solve(ll N, ll X) {
  if (N == 0)
    return (X <= 0 ? 0 : 1);
  else if (X <= A[N - 1] + 1)
    return solve(N - 1, X - 1);
  else
    return P[N - 1] + solve(N - 1, X - (A[N - 1] + 2)) + 1;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, X;
  cin >> N >> X;
  P[0] = 1;
  A[0] = 1;
  for (int i = 1; i <= 50; i++) {
    P[i] = 2 * P[i - 1] + 1;
    A[i] = 2 * A[i - 1] + 3;
  }
  cout << solve(N, X) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i;
	scanf("%d",&i);
	if(i==1)
		printf("Hello World");
	else if(i==2){
		int sum;
		scanf("%d",&i);
		scanf("%d",&sum);
		printf("%d",sum+=i);	
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	char num[100];
	scanf("%s", num);
	if (num[0] == 'A'){
		for (int i = 3; i < 6; ++i)
			printf("%c", num[i]);
		printf("\n");
	}
else
{
	printf("ABC");
	printf("%s\n", num);
}
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool check(int tx, int ty, int th, int x, int y, int h){
	int ph = max(th - abs(tx-x) - abs(ty-y), 0);
	if(ph == h)return true;
	else return false;
}

int main(){
	int n;
	cin>>n;
	vector<pair<pair<int,int>,int>> data(n);
	rep(i,n){
		cin>>data[i].first.first>>data[i].first.second>>data[i].second;
	}
	int x,y,h;
	rep(i,n){
		if(data[i].second>0){
			x = data[i].first.first;
			y = data[i].first.second;
			h = data[i].second;
			break;
		}
	}
	rep(tx,101){
		rep(ty,101){
			int th = h + abs(x-tx) + abs(y-ty);
			bool ok = true;
			rep(i,n){
				if(!check(tx, ty, th, data[i].first.first, data[i].first.second, data[i].second)){
					ok = false;
					break;
				}
			}
			if(ok){cout<<tx<<' '<<ty<<' '<<th<<endl; return 0;}
		}
	}
	return 0;
}


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

using namespace std;

static long long gcd(long long a,long long b){
	int amari = a % b;
	int c = b;
	if(amari == 0){
		return b;
	}else{
		return gcd(b,amari);
	}
}
static long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}
int main() {
    int n,d;
    cin >> n >> d;
    int x[n][d] = {0};
    for (int i=0;i<n;i++){
        for (int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    int tmp = 0;
    double root = 0;
    for (int i=0;i<n-1;i++){
        for (int j=1;j<n;j++){
            tmp = 0;
            if(i < j){
                for (int k=0;k<d;k++){
                    tmp += pow(abs(x[i][k] - x[j][k]),2);
                }
                root = pow(tmp,0.5);
                if (ceil(root) == floor(root)){
                    ans += 1;
                }
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 512
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	const int BIG_NUM = 1000000;
	vector<bool> f(BIG_NUM, false);
	int s;
	int cnt_idx = 1;

	cin >> s;
	f[s - 1] = true;

	while(1) {
		cnt_idx++;
		if (s % 2 == 0) {
			s /= 2;
		}
		else {
			s = 3 * s + 1;
		}
		if (f[s - 1] == true) {
			cout << cnt_idx << endl;
			break;
		}
		else {
			f[s - 1] = true;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int k;
	string s;
	cin >> k;
	cin >> s;
	if (s.length() <= k) {
		cout << s; return 0;
	}
	s = s.substr(0, k);
	cout << s << "...";
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> Ws(N), table(N);
    for(int i = 0; i < N; ++i){
        cin >> Ws[i];
    }
    table[0] = Ws[0];
    for(int i = 1; i < N; ++i){
        table[i] = table[i-1] + Ws[i];
    }
    int minVal = 10e6;
    for(int i = 0; i < N; ++i){
        minVal = min(minVal, abs(table[i]*2-table[N-1]));
    }
    cout << minVal << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1)
#define EPS 1e-12
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bitCount __builtin_popcount
#define forn(i, n) for(i = 0; i < (ll)n; i++)
#define for1(i, n) for(i = 1; i <= (ll)n; i++)
#define forv(i, v) for(i = 0; i < v.size(); i++)
#define forab(i, a, b) for(i = a; i <= (ll)b; i++)
#define Sort(v) sort(v.begin(), v.end())
#define bend(v) v.begin(), v.end()
#define sz(v) v.size()
#define trace(x) cout<<"x = "<<x<<"\n"
#define trace2(x, y) cout<<"x = "<<x<<" y = "<<y<<"\n"
#define trace3(x, y, z) cout<<"x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define trace4(w, x, y, z) cout<<"w = "<<w<<" x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define ln "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int>::iterator sit;
typedef set<ll>::iterator sllt;
typedef set<char>::iterator sct;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
typedef multiset<int>::iterator msit;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
const int alphabet = 26;
const int inf = INT_MAX;
const ll linf = 1e18+9;
namespace util{
	inline ll cnm(char ch){ return (ch-'0'); }
	inline ll cap(char ch){ return (ch-'a'); }
	inline void instr(string& s, ll& n){ cin>>s;    n = s.length(); }
	inline void instr(string& s){ cin>>s; }
	template<typename T> T gcd(T a, T b){ if(a==0) return b; return gcd(b%a, a); }
	template<typename T> bool min(T a, T b, T c){
		return  std::min(a, std::min(b, c));
	}
}
using namespace util;


void solve(int tc)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll i, j, k, m, n;
	set<int> hon, bon, pon;
	hon.insert(2); hon.insert(4); hon.insert(5); hon.insert(7); hon.insert(9);
	pon.insert(0); pon.insert(1); pon.insert(6); pon.insert(8);
	bon.insert(3);

	cin>>n;
	ll val = n%10;
	if(hon.count(val)) cout<<"hon";
	else if(pon.count(val)) cout<<"pon";
	else cout<<"bon";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	int i = 1;
	// cin>>t;
	while(i <= t){
		solve(i);
		i++;
	}

	return 0;
}



Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
int main(){
    set<int> st;
    int n,x;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&x);
        if(st.count(x)==0)
            st.insert(x);
        else st.erase(x);
    }
    printf("%d\n",st.size());
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	long long int n = s.length(); 
	long long int ans = 0;
	rep(i,n){
		if(s[i] != t[i]){
			ans++;
		}
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3916
t = input()
s = list(map(int,list(t)))

if s[0] + s[1] + s[2] + s[3] == 7:
    print(t[0]+"+"+t[1]+"+"+t[2]+"+"+t[3]+"=7")
elif s[0] + s[1] + s[2] - s[3] == 7:
    print(t[0]+"+"+t[1]+"+"+t[2]+"-"+t[3]+"=7")
elif s[0] + s[1] - s[2] + s[3] == 7:
    print(t[0]+"+"+t[1]+"-"+t[2]+"+"+t[3]+"=7")
elif s[0] + s[1] - s[2] - s[3] == 7:
    print(t[0]+"+"+t[1]+"-"+t[2]+"-"+t[3]+"=7")
elif s[0] - s[1] + s[2] + s[3] == 7:
    print(t[0]+"-"+t[1]+"+"+t[2]+"+"+t[3]+"=7")
elif s[0] - s[1] + s[2] - s[3] == 7:
    print(t[0]+"-"+t[1]+"+"+t[2]+"-"+t[3]+"=7")
elif s[0] - s[1] - s[2] + s[3] == 7:
    print(t[0]+"-"+t[1]+"-"+t[2]+"+"+t[3]+"=7")
elif s[0] - s[1] - s[2] - s[3] == 7: 
    print(t[0]+"-"+t[1]+"-"+t[2]+"-"+t[3]+"=7")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(max(a*c,a*d),b*c),b*d);
  return(0);
}

Measured memory_bytes: 3632
antennas = [
    int(input()),
    int(input()),
    int(input()),
    int(input()),
    int(input())
]
k = int(input())

message = 'Yay!'
for i in range(0, 5 - 1):
    if message == ':(':
        break
    for j in range(i + 1, 5):
        if (antennas[j] - antennas[i]) > k:
            message = ':('
            break
print(message)

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int L,R,l,r,ans;
	cin>>L>>R;
	l=L%2019;r=R%2019;
	if(R-L>=2018||l>r)ans=0;
	else{
		ans=2019;
		for(int i=l;i<=r-1;i++){
			for(int j=i+1;j<=r;j++){
				ans=min(ans,(i*j)%2019);
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="Sunny")cout<<"Cloudy"<<endl;
	if(s=="Cloudy")cout<<"Rainy"<<endl;
	if(s=="Rainy")cout<<"Sunny"<<endl;
}


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

const int maxn=1e6+10;
const int mo=1e9+7;

int n,f[maxn],pre[maxn],Ans;

int main()
{
#ifdef h10
	freopen("neutral.in","r",stdin);
	freopen("neutral.out","w",stdout);
#endif
	int i;
	scanf("%d",&n);
	f[0]=pre[0]=1; f[1]=1; pre[1]=2;
	for (i=2;i<=n;i++)
	{
		f[i]=(pre[i-1]+mo-f[i-2])%mo;
		pre[i]=(pre[i-1]+f[i])%mo;
	}
	Ans=f[n];
	for (i=0;i<n-1;i++)
		(Ans+=(LL)f[i]*(i+1)%mo)%=mo;
	(Ans+=(LL)pre[n-2]*(n-1)%mo*(n-1)%mo)%=mo;
	(Ans+=(LL)f[n-1]*(n-1)%mo)%=mo;
	printf("%d\n",Ans);
}


Measured memory_bytes: 8064
import java.util.*;

public class Main {

	public static int N,M;
	public static void main(String[] args) {
		Scanner scanner =new Scanner(System.in);
		N = scanner.nextInt();
		M = scanner.nextInt();
		
		int[] points = new int[M];
		int[] dis = new int[M-1];
		

		for (int i = 0; i < M; i++) {
			points[i] = scanner.nextInt();
		}

		Arrays.sort(points);

		int sum = 0;

		for (int i = 1; i < M; i++) {
			dis[i-1] = points[i] - points[i-1];
			sum += dis[i-1];
		}

		Arrays.sort(dis);
		
		int ans = 0;
		for (int i = 0; i < N - 1; i++) {
			if (i == M - 1) {
				break;
			}
			ans +=  dis[M - 2 - i];
		}

		System.out.println(sum-ans);

		scanner.close();
	}

}


Measured memory_bytes: 49868
import copy
from itertools import combinations

N, M, X = map(int, input().split())

books = []

for i in range(N):
    books.append(list(map(int, input().split())))

combi = []

for i in range(1, len(books) + 1):
    for conb in combinations(books, i):
        combi.append(list(conb))

min_result = None
for i in combi:
    result = copy.deepcopy(i[0])

    for j in i[1:]:
        for k in range(len(j)):
            result[k] += j[k]

    flag = True

    for j in result[1:]:
        if j < X:
            flag = False
            break

    if flag and (min_result is None or min_result > result[0]):
        min_result = result[0]

if min_result is None:
    print(-1)
else:
    print(min_result)

        
        
    

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

int main(){
int a;int b;
int i = 1;
int s;int d;int j;int k;
cin >> s >> d >> j >> k;
a = s+d+j+k;
int w;int ww;int www;int wwww;
cin >>w >> ww >> www >> wwww;
b = w + ww + www + wwww;
if(a >= b){
cout << a << endl;
}
else{
cout << b << endl;
}
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.io.IOException;
	public class Main {
		
	    public static void main(String[] args) throws IOException {
	    	Scanner teclado = new Scanner(System.in);
	    	int a = teclado.nextInt();
	    	int b = teclado.nextInt();
	    	int c = teclado.nextInt();
	    	if(a*b<c) {
	    		System.out.println(a*b);
	    	}else {
	    		System.out.println(c);
	    	}
	    }
	
	}

Measured memory_bytes: 22996
#include <stdio.h>

int main(){
  char *r[]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy"};
  int i;
  float w,s[]={48.0,51.0,54.0,57.0,60.0,64.0,69.0,75.0,81.0,91.0};
  
  while(scanf("%f",&w)!=EOF){
    for(i=0;i<10;i++){
      if(w<=s[i]) {printf("%s\n",r[i]); break;}
    }
    if(i==10) printf("heavy\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

bool check(int *vec, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (*vec % 2 != 0)
        {

            return false;
        }
        vec++;
    }
    return true;
}

int main()
{
    int N;
    int count = 0;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    while (check(A, N) == true)

    {
        count++;
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 == 0)
            {
                A[i] = A[i] / 2;
            }
        }
    }

    cout << count << endl;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI p(n), c(n);
	rep(i, n){ cin >>p[i]; p[i]--;}
	rep(i, n) cin >>c[i];
	
	UF ufa(n);
	rep(i, n) ufa.unite(i, p[i]);
	
	VL sm(n);
	rep(i, n) sm[ufa.find(i)] += c[i];


	ll ans = -1e17;
	rep(i, n){
		int z =i, cnt =0;
		ll cnd = 0;
		while(1){
			z = p[z];
			if(++cnt > k ) break;
			cnd += c[z];
			ll s = (k-cnt)/ ufa.size(i);
			ll w = max(0LL,sm[ufa.find(i)]) * max(s, 0LL);
			ans = max(ans, cnd + w);
			//dbg(z, cnt,cnd,w, cnd+w);
			if(z == i ) break;
		}
	}
	cout <<ans <<"\n";
	return 0;
}



Measured memory_bytes: 3756
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d;
    multiset<int> s;
    cin>>n>>m;
    rep(i,n){
        ll k;
        cin>>k;
        rep(j,k){
            cin>>d;
            s.insert(d);
        }
    }
    ll i=1;
    for(;i<=m;i++){
        if(s.count(i)==n) sum++;
    }
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


int main_C() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vvi A(2, vi(N));
    REP(i, 2)
        REP(j, N) cin >> A[i][j];

    vi sum0(N), sum1(N);
    sum0[0] = A[0][0];
    sum1[0] = A[1][0];
    FOR(i,1,N) {
        sum0[i] = sum0[i - 1] + A[0][i];
        sum1[i] = sum1[i - 1] + A[1][i];
    }

    vi dp(N);    
    dp[0] = sum0[0] + sum1[N - 1];
    for(int i=1; i<N; i++) {
        dp[i] = sum0[i] + (sum1[N-1] - sum1[i-1]);
    }

    int ans = 0;
    REP(i, N) ans = max(ans, dp[i]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

	int a, b, c, d, e,f,g,h,i;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);



	if (d >= b) {

		f = d - b;
		g = c - a;
		h = g * 60 + f;
		i = h - e;
		printf("%d", i );

	}

	else if (d < b) {

		f = d + 60 - b;
		g = c - a - 1;
		h = g * 60 + f;
		i = h - e;



		printf("%d", i);
	}
		




	return 0;
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fastio
    ll t, i, j;
    ll h, w, m, mxx=0, mxy=0;

    cin>>h>>w>>m;    
    ll x[m+9], y[m+9];
    map <ll, ll> mpx, mpy;
    map <pair<ll, ll>, bool> mpxy;
    for(i=0; i<m; i++)
    {
        cin>>x[i]>>y[i];
        mpx[x[i]]++;
        mpy[y[i]]++;
        mpxy[{x[i], y[i]}]=true;
        mxx=max(mxx, mpx[x[i]]);
        mxy=max(mxy, mpy[y[i]]);
    }

    vector<ll> vx, vy;
    for(auto p:mpx)
    {
        if(p.second==mxx)
        {
            vx.push_back(p.first);
        }
    }
    for(auto p:mpy)
    {
        if(p.second==mxy)
        {
            vy.push_back(p.first);
        }
    }
    ll ans, flag=0;

    for(i=0; i<vx.size(); i++)
    {
        for(j=0; j<vy.size(); j++)
        {
            if(mpxy[{vx[i], vy[j]}]==false)
            {
                flag=1;
                break;
            }
        }
    }
    ans=mxx+mxy;
    if(flag==0)
    {
        ans--;
    }
    cout<<ans;
}

Measured memory_bytes: 87560
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int h, w, m;
	cin >> h >> w >> m;

	vector<pair<int, int>>row(h), col(w);
	int ans = 0;
	map <pair<int, int>, int>target;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;

		target[ {a, b}]++;

		row[a - 1].first++;

		col[b - 1].first++;

	}

	for (int i = 0; i < h; i++) {
		row[i].second = i + 1;
	}
	for (int i = 0; i < w; i++) {
		col[i].second = i + 1;
	}

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

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


	pair<int, int>best_row = row[0];

	pair<int, int>best_col = col[0];



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

		if (target[ {best_row.second, col[i].second}]) {
			ans = max(ans, best_row.first + col[i].first - 1);
		}
		else {
			ans = max(ans, best_row.first + col[i].first);
		}

	}

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

		if (target[ {row[i].second, best_col.second}]) {
			ans = max(ans, row[i].first + best_col.first - 1);
		}
		else {
			ans = max(ans, best_col.first + row[i].first);
		}

	}

	cout << ans << endl;





}


Measured memory_bytes: 64168
import numpy as np
words = lambda t : list(map(t, input().split()))
n,m = words(int)

ss = [True] * (n+1)
dp = [0] * (n+1)
MOD = 1000000007


for i in range(m):
    k = int(input())
    ss[k] = False

dp[0] = 1
if ss[1]:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2,n+1):
    if ss[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
    else:
        dp[i] = 0

#print(dp)
print(dp[n])


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

int main() {
	long long int n,d; cin>>n>>d;
	long long int count=0;
	while(n--)
	{
	   long long int x,y;cin>>x>>y;
	    if(sqrt(x*x+y*y)<=d) count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3672
import math
n,k = map(int, input().split())
lst = list(input())
hap = 0
for i in range(n-1):
    if lst[i]==lst[i+1]:
        hap+=1
unh = len(lst)-hap-1
print(len(lst)-1 if math.ceil(unh/2)<=k else hap+k*2)


Measured memory_bytes: 4084
#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a, const void* b){
  return *(int*)a - *(int*)b;
}

int main(){
  int n,i,sum=0,c=0;
  scanf("%d", &n);
  int job[n][2];
  for(i=0;i<n;i++){
    scanf("%d %d", &job[i][1], &job[i][0]);
  }
  qsort(job, n, sizeof(job[0]), cmp);
  for(i=0;i<n;i++){
    sum+=job[i][1];
    if(sum>job[i][0]){
      c=1;
      break;
    }
  }
  if(c==0) puts("Yes");
  else puts("No");
}

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

using namespace std;

int main(){

	int N;
	cin >> N;
	
	int a[N+1];
	
	for(int i=1;i<=N;i++){
		cin >> a[i];
	}
	
	//最初a[0]を押す
	
	set<int> c;
	
	int temp = a[1];
	int index =1;
	int count = 1;
	c.insert(1);
	
	while(1){
	
		index = temp;
		if(!c.insert(index).second){break;}
		temp = a[index];
		
		if(index==2){
			cout << count << endl;
			return 0;
		
		}
		count++;
		
		
	
	
	}
	
	cout << "-1" << endl;
	
	return 0;

}

Measured memory_bytes: 5376
X = int(input())
nums = set()
nums.add(1)
for b in range(2, 40):
    p = 2
    while True:
        if b**p <= 1000:
            nums.add(b**p)
            p += 1
        else:
            break
ans = -1
for num in nums:
    if num <= X:
        ans = max(ans, num)
print(ans)


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

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

  int total = 0;
  for(int i=0;i<s.size();i++){
    if(s.at(i) == 'o'){
      total++;
    }
  }
  cout << 700 + 100 * total << endl;
}


Measured memory_bytes: 256
K,N = map(int, input().split())
src = map(int, input().split())
src = list(src)
if src[-1] - src[0] <= K/2:
  print(src[-1] - src[0])
else:
  a = K - (src[-1] - src[0])
  for i in range(N-1):
    if a < src[i+1] - src[i]:
      a = src[i+1] - src[i]
  print(K-a)

Measured memory_bytes: 26436
n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)
b = gets.strip.split.map(&:to_i)

count = 0
 
(0..n-1).each do |i|
  x = [b[i],a[i]].min
  b[i] = b[i] - x
  y = [a[i+1], b[i]].min
  a[i+1] = a[i+1] - y
  count += x + y
end

puts count.to_s

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

int n, a[100005], b[100005], c[100005], dp[100005][5];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i] >> b[i] >> c[i];

    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    for(int i=2; i<=n; i++) {
        dp[i][1] = max(dp[i-1][2]+a[i], dp[i-1][3]+a[i]);
        dp[i][2] = max(dp[i-1][1]+b[i], dp[i-1][3]+b[i]);
        dp[i][3] = max(dp[i-1][1]+c[i], dp[i-1][2]+c[i]);
    }
    int ans = max(dp[n][1], max(dp[n][2], dp[n][3]));
    cout << ans << endl;

    return 0;
}


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

int main()
{
    ll N; cin >> N;
    map<ll, ll> mpp, mpm, mpt;
    ll A;
    for(int i=0;i<N;i++)
    {
        cin >> A;
        mpp[i + A]++; mpm[i - A]++;
        mpt[i + A] = mpp[i + A] * mpm[i + A];
        mpt[i - A] = mpp[i - A] * mpm[i - A];
    }

    ll ans = 0;

    for(auto [key, value] : mpt) ans += value;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 71756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  const double pi=3.14159265358979323846264338327950288;
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double deg2=abs(60*(double)(h)-11*(double)(m));
  double rad=deg2*pi/360.0000000000;
  rad=min(rad,2*pi-rad);
  double ans=sqrt(a*a+b*b-2*a*b*cos(rad));
  cout << fixed << setprecision(30) << ans << endl;
}

Measured memory_bytes: 4268
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *B = map(int, read().split())

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

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include<stdio.h>

int main() {
    int a,b,sum,counter,i;
    while(scanf("%d %d",&a,&b)!=-1) {
        sum = a + b;
        for(i=0;sum!=0;i++)
            sum = sum / 10;
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%MMM)if(y&1)z=1ll*z*x%MMM;return z;}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int main()
{
	faltu;
	int n,ans=0,x,mx=0;
	cin>>n;
	map<int,int>m;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		m[x]++;
		mx=max(mx,x);
	}
	for(int i=1;i<=mx;i++)
	{
		m[i]+=m[i-1];
	}
	for(int i=1;i<=mx;i++)
	{
		if(m[mx]-(2*m[i-1])==0)ans++;
	}
cout<<ans<<endl;
}








Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for(int &i:L)
    cin>>i;
  sort(L.begin(),L.end());
  int l=0;
  for(int i=0;i<N-2;i++)
    for(int j=i+1;j<N-1;j++)
      for(int k=j+1;k<N;k++){
        if(L[i]+L[j]<=L[k])
          break;
        l++;
      }
  cout<<l<<endl;
}

Measured memory_bytes: 3616
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
ans = [-1] * N

# 葉からの検索を行う
@lru_cache(maxsize=None)
def search(now):
    if now == root:
        ans[now] = 0
        return 0
    ret = -1
    for pr in parent[now]:
        depth = search(pr)
        if depth > ret:
            ans[now] = pr + 1
            ret = depth
    return ret + 1

for i in range(N):
    search(i)

print(*ans, sep='\n')

Measured memory_bytes: 203464
fun main(args:Array<String>) {
  val a1 = readLine()!!.toList().reversed()
  val a2 = readLine()!!.toList()
  a1.zip(a2).map { 
    val (c1, c2) = it
    c1 == c2 
  }.all { it }.let { 
    when (it)  {
      true -> "YES" 
      else -> "NO"
    }
  }.run(::println)
}

Measured memory_bytes: 32124
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    int n, tmp;
    long ans;
    ans = 0;
    std::cin >> n;
    for (int i=0; i<n; i++){
        std::cin >> tmp;
        ans += tmp - 1;
    }
    std::cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
N, M, Q = map(int,input().split())
P = [list(map(int,input().split())) for i in range(Q)]
 
comb = list(itertools.combinations_with_replacement(range(1, M+1), N))
 
max_score = 0
for c in comb:
    score = 0
    #print(c)
    for p in P:
        if c[p[1]-1] - c[p[0]-1] == p[2]:
            score += p[3]
    if score > max_score:
        max_score = score
 
print(max_score)


Measured memory_bytes: 21468
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(c>=a&&c<=b)puts("Yes");
	else if (c>=b&&c<=a)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    vector<char> al(26);
    for(char c='A';c<='Z';c++)al[c-'A']=c;
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        cout<<al[(s[i]-'A'+n)%26];
    }
    cout<<endl;
}


Measured memory_bytes: 256
def main():
    W, H, x, y = map(int, input().split())
    ans = (H*W)/2
    mid_x, mid_y = W/2, H/2
    if x == mid_x and y == mid_y:
        div = 1
    else:
        div = 0
    print(ans, div)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
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)*}
    };
}

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() {
    input! {
        n: i32,
        k: i8,
        d: [i8; k],
    }

    let mut pay = n;
    loop {
        let mut contains = false;
        for num in d.iter() {
            if pay.to_string().contains(num.to_string().as_str()) {
                contains = true;
            }
        }
        if contains {
            pay += 1;
        } else {
            println!("{}", pay);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

#define FOR(x)	for(int i=0;i<x;i++)

int main(void)
{

	int x;
	cin >> x;

	int i = 1;
	while (1)
	{
		if ((360 * i) % x == 0)
		{
			cout << (360 * i) / x;
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
const int N=100+10;
char a[N][15];
int main()
{
	int n;
	bool pd=true;
	cin>>n;
	memset(a,0,sizeof(a));
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		int l=strlen(a[i]);
		if(a[i][l-1]!=a[i+1][0])
		{
			cout<<"No";
			pd=false; 
			break;
		}	
		for(int j=i+1;j<n;j++)
		{
			if(strcmp(a[i],a[j])==0)
			{
				cout<<"No";
				pd=false;
				break;
			}
		} 
	}
	if(pd)
	cout<<"Yes";			
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    map<string, int> ma;
    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        ma[s]++;
    }
    int maxv = -1;
    for (auto p:ma) {
        maxv = max(maxv, p.second);
    }
    for (auto p:ma) {
        if (p.second == maxv) {
            cout << p.first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25216
#include<stdio.h>

int main(void){
  
  int A,B,C;
  
  scanf("%d %d %d",&A,&B,&C);
  
  if(B / A >= C){
   printf("%d",C); 
  }else{
   printf("%d",B/A);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int h,w,d,q;
int a[400][400];


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> h >> w >> d;
  UnionFind<ll>tree(h*w+1);
  map<int,P>mp;
  rep(i,h)rep(j,w){
    cin >> a[i][j];   
    mp[a[i][j]]=P(i+1,j+1);
  }
  exrep(i,1,h*w-d){
      int y=mp[i].first,x=mp[i].second;
      int ny=mp[i+d].first,nx=mp[i+d].second;
      tree.merge(i,i+d,abs(y-ny)+abs(x-nx));
    
  }
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << tree.diff(l,r) << endl;
  }
  
}


Measured memory_bytes: 8704
fn main() {
    let nk = read_vec::<usize>();
    let n = nk[0];
    let k = nk[1];

    let mut p = 0.0;
    for i in 1..n+1 {
        let mut point = i;
        let mut cnt = 0;
        while point < k {
            point *= 2;
            cnt += 1;
        }
        let half: f64 = 0.5;
        p += (1.0 / n as f64) * half.powi(cnt);
    }

    println!("{}", p);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
while(true)
  a, op, b = gets.split.map(&:to_s)

  if op == "?"
    break
  end
  
  a = a.to_i
  b = b.to_i



  ans = 0;

  if op == "+"
    ans = a + b
  elsif op == "-"
    ans = a - b
  elsif op == "*"
    ans = a * b
  else
    ans = a / b
  end

  puts ans
end


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

int main() {
	string s,t;
	cin >> s >>t;
	int ls=s.length(), lt=t.length();
	
	int s_az[26]={0}, t_az[26]={0};
	for(int i=0; i<ls; i++){
		s_az[s[i]-'a']++;
	}
	for(int i=0; i<lt; i++){
		t_az[t[i]-'a']++;
	}
	
	int ans=0;
	int min_s=26;
	int max_t=-1;
	int s_cnt=0;
	int t_cnt=0;
	for(int i=0; i<26; i++){
		if(s_az[i]>0 && min_s>i){min_s=i;}
		if(t_az[i]>0 && max_t<i){max_t=i;}
		
		if(s_az[i]>0){s_cnt++;}
		if(t_az[i]>0){t_cnt++;}
	}
	
	if(min_s>max_t){cout << "No" << endl;}
	else if(min_s<max_t){cout << "Yes" << endl;}
	else if(min_s==max_t){
		if((s_az[min_s]<t_az[max_t]&&s_cnt==1)||(s_az[min_s]==t_az[max_t]&&s_cnt==1&&t_cnt>1)){
			cout << "Yes" << endl;
		}else{cout<<"No"<<endl;}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
int a,b,i,sum=0;

scanf("%d",&a);
scanf("%d",&b);

for(i=0;i<2;i++)
{
  if(a<b)
  {
  sum += b;
  b -= 1;
  }
  else
  {
    sum += a;
    a -= 1;
  }
}

printf("%d",sum);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int n, s[200] = {}, result = 0,lamp=1,in,ax;
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		s[str[i]-'a']++;
	}
	for (int i = 0; i < 30; i++) {
		if (s[i] > 1) { cout << "no"; return 0; }
	}
	
	cout <<"yes";
}


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

int main(){
 int n; cin >>n;
 vector<int>a(n);
 for(int i=0; i<n; i++) cin >>a[i];
 sort(a.begin(),a.end());
 double sum=(a[0]+a[1])/2.0;
 for(int i=2; i<n; i++) sum=(sum+a[i])/2;
 cout <<sum;
return 0;}

Measured memory_bytes: 256