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

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<complex>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


//4-side
//int xx[] = {0,0,-1,1};
//int yy[] = {-1,1,0,0};
//6-side hexagonal
//int xx[] = {2,-2,1,1,-1,-1};
//int yy[] = {0,0,1,-1,1,-1};

#define popc(a) (__builtin_popcount(a))
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

#define MX 100005
#define inf 100000000

const double pi = acos(-1.0);
const ll mod = 1000000000ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll x, y;
    scanf("%lld %lld", &x, &y);
    if(x%y == 0)
    {
        puts("-1");
        return 0;
    }
    ll res = x+x;
    while(res%y == 0 && res<=(mod*mod))
    {
        res += x;
    }
    if(res>(mod*mod))
    {
        puts("-1");
    }else{
        printf("%lld\n", res);
    }
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] number = line.split(" ");
        int a = Integer.parseInt(number[0]);
        int b = Integer.parseInt(number[1]);
        int c = Integer.parseInt(number[2]);
        int f = a % b;
        int n = 0;
        while(true) {
            if((n + a) % b == c) {
                System.out.println("YES");
                break;
            } else if((n + (2 * a)) % b == f) {
                System.out.println("NO");
                break;
            }
            n = n + a;
        }
    }
}

Measured memory_bytes: 21332
N,K = map(int,raw_input().split())

A = map(int,raw_input().split())

A.sort()

i = 0
counter = -1
pnum = -1
data = []

while i < N:
    if pnum != A[i]:
        data.append(1)
        pnum = A[i]
        counter += 1
    else:
        data[counter] += 1
    i += 1

data.sort()

print sum(data[:counter-K+1])

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

int main(){
  long long a, b, c;
  long long sum;
  long long result;
  scanf("%lld %lld %lld", &a, &b, &c);
  sum = a * b * c;
  if(sum%2 == 0){
    printf("%d\n", 0);
  }else{
    result = min(min(a*b, b*c), c*a);
    //result = sum%(a*b*2);
    printf("%lld\n", result);
  }

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import heapq

def dijkstra(G, s):
    dist = [float('inf')] * len(G.keys())
    dist[s] = 0
    q = [(dist[v], v) for v in G.keys()]
    heapq.heapify(q)
    while True:
        try:
            _, u = heapq.heappop(q)
        except IndexError:
            break
        for v, d in G[u]:
            tmp = dist[u] + d
            if dist[v] > tmp:
                dist[v] = tmp
                heapq.heappush(q, (tmp, v))
    return dist

n, m, s, t = map(int, input().split())
G1 = defaultdict(list)
G2 = defaultdict(list)

for i in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    G1[u].append((v, a))
    G1[v].append((u, a))
    G2[u].append((v, b))
    G2[v].append((u, b))

dist1 = dijkstra(G1, s-1)
dist2 = dijkstra(G2, t-1)

mv = 0
ans = []
for i in range(n-1, -1, -1):
    mv = max(mv, 10**15 - dist1[i] - dist2[i])
    ans.append(mv)

ans.reverse()
for a in ans:
    print(a)

Measured memory_bytes: 125528
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
const double pi = acos(-1);
int a, b, h, m;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> a >> b >> h >> m;
    double minuti = 6 * m;
    double sat = h * 30 + (double) m / 60.0 * 30;
    double alfa = sat - minuti;
    alfa = min(alfa, 360 - alfa);
    double kos = cos((alfa * pi) / 180.0);
//    cout << kos << endl;
    double c = a * a + b * b - 2 * a * b * kos;
    c = sqrt(c);
    cout << setprecision(15) << c << endl;
    return 0;
}



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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        int n;
        cin >> n;
        int tapi = n / 2;
        int tapu = n - tapi;
        int ans = tapi * tapu;
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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 (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

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

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


long long com[51][51];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }

    int N, A, B; cin >> N >> A >> B;
    vector<long long> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());

    // 最大値
    long long sum = 0;
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    // 小さいやつの個数
    long long res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += com[num][j];
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue <int> que;
  for (int i = 0; i < N; i++) {
	  int A;
	  cin >> A;
	  que.push(A);
	}
  for (int i = 0; i < M; i++) {
	  int d = que.top();
	  que.pop();
	  que.push(d / 2);
	}
  long long ans = 0;
  for (int i = 0; i < N; i++) {
	  ans += que.top();
	  que.pop();
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct edge{
	int next;
	int to;
	int w;
}e[4000020];
int head[2000020];
bool dijia(int s);
int dis[2000020];
bool book[2000020],vis[2000020];
int main(){
	scanf("%d %d",&n,&m);
	int u,v,w;
	for(int x=1;x<=m;x++){
		scanf("%d %d %d",&u,&v,&w);
		e[x].to=v;
		e[x].w=w;
		e[x].next=head[u];
		head[u]=x;
		e[x+m].next=head[v];
		e[x+m].to=u;
		e[x+m].w=-w;
		head[v]=x+m;
	}
	for(int x=1;x<=n;x++){
		if(vis[x]){
			continue;
		}
		if(!dijia(x)){
			printf("No");
			return 0;
		}
		else{
			continue;
		}
	}
	printf("Yes");
	return 0;
}
bool dijia(int s){
	dis[s]=0;
	queue<int> q;
	q.push(s);
	book[s]=1;
	while(q.size()){
		int k=q.front();
		q.pop();
		book[k]=0;
		for(int x=head[k];x;x=e[x].next){
			if(!vis[e[x].to]){
				dis[e[x].to]=dis[k]+e[x].w;
				q.push(e[x].to);
				book[e[x].to]=1;
				vis[e[x].to]=1;
			}
			else{
				if(dis[e[x].to]!=dis[k]+e[x].w){
					return false;
				}
			}
		}
	}
	return true;
}

Measured memory_bytes: 13184
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
int m,k;
typedef pair<int,int> P;
struct edge{
	int to,cost;
};
int V;
vector<edge>G[3005];
int d[3005][3005];
int cou=0;
int mi[3005];
#define INF 1000000000
void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> >que;
	d[cou][s]=0;
	que.push(make_pair(0,s));
	while(!que.empty()){
		P p=que.top(); que.pop();
		int v=p.second;
		if(d[cou][v]<p.first) continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[cou][e.to]>d[cou][v]+e.cost){
				d[cou][e.to]=d[cou][v]+e.cost;
				que.push(P(d[cou][e.to],e.to));
			}
		}
	}
}
int main(){
	scanf("%d %d %d",&V,&m,&k);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		a--; b--;
		edge r,t;
		r.to=b; t.to=a;
		r.cost=c; t.cost=c;
		G[a].push_back(r);
		G[b].push_back(t);
	}
	for(int i=0;i<3005;i++){
		for(int j=0;j<3005;j++){
			d[i][j]=INF;
		}
		mi[i]=INF;
	}
	for(int i=0;i<k;i++){
		int sta;
		scanf("%d",&sta);
		dijkstra(sta-1);
		cou++;
	}
	int ans=0,ep=0;
	for(int i=0;i<cou;i++){
		for(int j=0;j<V;j++){
				mi[j]=min(mi[j],d[i][j]);
		}
	}
	int res=0;
	for(int j=0;j<V;j++){
		for(int k=0;k<G[j].size();k++){
			int c=G[j][k].to;
			int w=G[j][k].cost;
			res=max((mi[j]+mi[c]+w+1)/2,res);
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 39316
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    bool ok = false;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == n)
                ok = true;
        }
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long n,k;cin>>n>>k;
  long long ans = (n/k)*(n/k)*(n/k);
  if(!(k%2)){
    ans += (n/(k/2)-n/k)*(n/(k/2)-n/k)*(n/(k/2)-n/k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import combinations
N = int(input())
d = defaultdict(int)
strlist = ["M","A","R","C","H"]
for i in range(N):
    S = input()
    for s in strlist:
        if S[0] == s:
            d[s] += 1
combs = list(combinations(strlist,3))
ans = 0
for s1,s2,s3 in combs:
    ans += d[s1] * d[s2] * d[s3]
print(ans)

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

int main() {
  int N, K, a=1;
  cin >> N >> K;

  for (int i = 0; i < N; i++){
    if(a<K){
      a += a;
    }else{
      a += K;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
	string str;
	long long total=0;
void bf(int i,int cnt,int t,long long temp,long long value)
{
	if(i==str.length())
	{
		if(cnt==t)
		{
			total+=temp+value;
		}
	}
	else
	{
		if(cnt<t&&i<str.length()-1)
		{
			bf(i+1,cnt+1,t,0,value+temp*10+str[i]-'0');
		}
		bf(i+1,cnt,t,temp*10+str[i]-'0',value);
	}
}
int main()
{
	cin>>str;
	for(int i=1;i<=str.length();i++)
	{
		bf(0,1,i,0,0);
	}
	cout<<total<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
ll ceil1(ll a,ll b)
{
	if(a%b==0)
		return a/b;
	else
		return a/b+1;
}

void solve()
{
	ll n,a,b;
	cin>>n;
	a=1,b=1;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		ll temp=max(ceil1(a,x),ceil1(b,y));
		a=temp*x;
		b=temp*y;
	}
	cout<<a+b;
	
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

const int N = 300005;
int n, p[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", p + i);
		if (i + p[i] & 1) return puts("No"), 0;
	}
	for (int i = 3; i < n - 1; ++i)
		if (i - 1 != p[i - 1] && i != p[i] && i + 1 != p[i + 1])
			return puts("No"), 0;
	if (p[1] != 1 && p[2] != 2) return puts("No"), 0;
	if (p[n - 1] != n - 1 && p[n] != n) return puts("No"), 0;
	for (int i = 1, j; i <= n; i = j) {
		if (p[i] == i) { j = i + 1; continue; }
		for (j = i + 1; j <= n && (p[j] == j) != (p[j - 1] == j - 1); ++j);
		int l = i, r = j - 1;
		if (p[r] == r) --r;
		for (int t = l; t <= r; t += 2)
			if (p[t] < l || p[t] > r) return puts("No"), 0;
		int lst = 0;
		for (int t = l; t <= r; t += 2)
			if (p[t] > t) {
				if (p[t] < lst) return puts("No"), 0;
				lst = p[t];
			}
		lst = n + 1;
		for (int t = r; t >= l; t -= 2)
			if (p[t] < t) {
				if (p[t] > lst) return puts("No"), 0;
				lst = p[t];
			}
	}
	puts("Yes");
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

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

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int s;
    cin>>s;
    int d=1e9;
    int x=(d-s%d)%d;
    int y=(s+x)/d;
    cout<<"0 0 "<<d<<sp<<1<<sp<<x<<sp<<y<<endl;
}

Measured memory_bytes: 256
/* D - Sum of Divisors */
// 正の整数jに対し、jの倍数であってN以下であるものの総和をg(j)とすると\sum_{j=1}^N g(j)を求める問題

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

int main(){
  long long N, ans = 0;
  cin >> N;
  for(long long j = 1; j <= N; j++){
    // Y = floor(N / X)とすると、g(X) = Y * (Y + 1) * X / 2
    ans += (N / j) * (N / j + 1) * j / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3684
n, m, c = map(int, input().split())
b_list = list(map(int, input().split()))
count = 0

for _ in range(n):
    a_list = list(map(int, input().split()))
    sum = c

    for i in range(m):
        sum += a_list[i] * b_list[i]

    if sum > 0:
        count += 1

print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  vector<int> count(n,0);
  bool flag=false;
  for(int i=0;i<n;i++)
  {
    if(flag and s[i]=='C')
      count[i]++;
    if(s[i]=='A')
      flag=true;
    else
      flag=false;
  }
  for(int i=1;i<n;i++)
    count[i]+=count[i-1];
  for(int i=0;i<q;i++)
  {
    int l,r;
    cin>>l>>r;
    cout<<count[r-1]-count[l-1]<<endl;
  }
}
  

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define all(i) i.begin(),i.end()
#define fix(i) fixed<<setprecision((i))
#define Max( i , j ) (i)=max((i),(j))
#define Min( i , j ) (i)=min((i),(j))
#define pii pair<int,int>
using namespace std;

const long long maxn = 1e5+100;
const long long INF = 3e18+1191;
const long long mod = 1e9+7;

int32_t main()
{
  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

  int a , b;
  cin >> a >> b;
  int ans = 0;
  for(int i = 1; i < a; i++)
	  for(int j = 1 ;j <=31 ;j++)
		  if(i == j)
			  ans ++;
  for(int i = 1; i <= b ; i++)
	  if( i == a) ans ++; 
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll R;
    cin >> R;
    if (R < 1200) cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int N; // 3<=N<=100
int num[110];
ll dp[110][25]; // dpの中身はi番目までの組み合わせでyが何個できるか、dp[N][計算結果0<=y<=20]

int main(void){
    cin >> N;
    REP(i, N) cin >> num[i];
    
    dp[0][num[0]] = 1; // 初期条件

    for(int i = 1; i < N - 1; i++){
        for(int cul = 0; cul <= 20; cul++){
            if(dp[i - 1][cul] >= 1 and cul - num[i] >= 0) dp[i][cul - num[i]] += dp[i - 1][cul];
            if(dp[i - 1][cul] >= 1 and cul + num[i] <= 20) dp[i][cul + num[i]] += dp[i - 1][cul]; 
        }
    }

    cout << dp[N - 2][num[N - 1]] << endl;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	
	string s;
	cin >> s;
	if(s=="ABC"){
		cout << "ARC\n";
	}else{
		cout << "ABC\n";
	}
	
	
	
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (n % 2 != 0) {
    puts("No");
    return 0;
  }
  bool is_valid = true;
  for (int i = 0; i < n - 1; i += 2) {
    if (s[i] != 'h' || s[i + 1] != 'i') is_valid = false;
  }
  if (is_valid) puts("Yes");
  else puts("No");
  return 0;
}



Measured memory_bytes: 256
import math

N = int(input())
sl = []

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans_d = {}
ans = 0
for _ in range(N):
    sl.append(input())


for s in sl:
    key = "".join(sorted(s))
    if(key not in ans_d.keys()):
        ans_d[key] = 1
    else:
        ans_d[key] += 1


print(sum([combinations_count(ans,2) for ans in ans_d.values() if ans>1]))



Measured memory_bytes: 24968
#include <iostream>

using namespace std;

int main(){
    int S, r, h, m, s;
    cin >> S;
    h = S / 3600;
    r = S % 3600;
    m = r / 60;
    s = r % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n), p(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        p[--a[i]] = i;
    }

    set<int> st;
    st.insert(-1), st.insert(n);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        auto itr = st.lower_bound(p[i]);
        int r = *itr - p[i];
        itr--;
        int l = p[i] - *itr;
        ans += (ll)(i + 1) * r * l;
        st.insert(p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13956
#include<iostream>
#include<string>
using namespace std;
struct Dice{
    int s[6];
    void roll(char c){
        int b;
        if(c=='E'){
            b=s[0];
            s[0]=s[3];
            s[3]=s[5];
            s[5]=s[2];
            s[2]=b;
        }
        if(c=='W'){
            b=s[0];
            s[0]=s[2];
            s[2]=s[5];
            s[5]=s[3];
            s[3]=b;
        }
        if(c=='N'){
            b=s[0];
            s[0]=s[1];
            s[1]=s[5];
            s[5]=s[4];
            s[4]=b;
        }
        if(c=='S'){
            b=s[0];
            s[0]=s[4];
            s[4]=s[5];
            s[5]=s[1];
            s[1]=b;
        }
        if(c=='R'){
            b=s[1];
            s[1]=s[2];
            s[2]=s[4];
            s[4]=s[3];
            s[3]=b;
        }
    }
    int top() {
        return s[0];
    }
    int right(){
        return s[2];
    }
    int left(){
        return s[3];
    }
    int front(){
        return s[1];
    }
};
int main(){
    Dice d;
    for(int i=0;i<6;i++) cin >> d.s[i];
    int n;cin >> n;
    while(n--){
        int a,b;cin >> a >> b;
        if(d.left()==a) d.roll('E');
        if(d.right()==a) d.roll('W');
        while(d.top()!=a) d.roll('N');
        while(d.front()!=b) d.roll('R');
        cout << d.right() << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

int range(int l, int r) {
    if (l > r) {
        return 0;
    } else {
        return r - l + 1;
    }
}

int range_and(int l1, int r1, int l2, int r2) {
    if (l1 > r1 || l2 > r2) {
        return 0;
    } else {
        int r = min(r1, r2);
        int l = max(l1, l2);
        return range(l, r);
    }
}

int solve(const vector<pair<int, int>> &v) {
    int N = v.size();
    vector<pair<int, int>> other(N+1);
    int l = 1;
    int r = 1000000000;
    for (int i = N-1; i >= 0; i--) {
        if (l < v[i].first) {
            l = v[i].first;
        }
        if (r > v[i].second) {
            r = v[i].second;
        }
        if (l > r) {
            l = 0;
            r = -1;
        }
        other[i].first = l;
        other[i].second = r;
    }
    //for (int i = 0; i < N; i++) {
    //    cout << ": " << v[i].first << " " << v[i].second << " " << other[i].first << " " << other[i].second << endl;
    //}
    int rmax = 0;
    int rmin = 1000000000;
    int ans = 0;
    for (int i = 0; i < N;) {
        int j = i + 1;
        for (; j < N; j++) {
            if (v[j].first != v[i].first) {
                break;
            }
        }
        rmax = max(rmax, v[j-1].second);
        rmin = min(rmin, v[i].second);
        //cout << "rmin=" << rmin << ", rmax=" << rmax << endl;
        if (i == 0 && j == i+1) {
            int s1 = range(
                other[j == N ? N-1 : j].first,
                other[j == N ? N-1 : j].second
            ) + range(v[i].first, v[i].second);
            //cout << "s1=" << s1 << endl;
            ans = max(ans, s1);
        } else if (j < N || j == i+1) {
            int s0 = range(
                other[j].first,
                other[j].second
            ) + range(v[i].first, rmin);
            int s1 = range_and(
                other[j].first,
                other[j].second,
                v[i].first,
                rmin
            ) + range(v[i].first, rmax);
            int s2 = range_and(
                other[j].first,
                other[j].second,
                v[i].first,
                rmax
            ) + range(v[i].first, rmin);
            //cout << "s0=" << s0 << ", s1=" << s1 << ", s2=" << s2 << endl;
            ans = max(ans, max(s0, max(s1, s2)));
        } else {
            int s0 = range(
                v[N-1].first,
                v[N-1].second
            ) + range(v[i].first, rmin);
            int s1 = range(
                v[i].first,
                v[i].second
            ) + range(v[i].first, rmax);
            //cout << "s0=" << s0 << ", s1=" << s1 << endl;
            ans = max(ans, max(s0, s1));
        }
        i = j;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    int ans = solve(v);
    cout << ans << endl;
}


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

int main()
{
	unsigned long long int m, n;
	const unsigned long long int p = 1000000007;

	cin >> m >> n;

	int i = 2;
	while (n > 1)
	{
		if (n % i != 0)
		{
			i++;
			continue;
		}
		n /= i;
		unsigned long long int tmp = 1;
		for (int j = 0; j < i; j++)
		{
			tmp *= m;
			tmp %= p;
		}
		m = tmp;
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
bool judge(int a,int b,int c,int d,int x)
{
    if(a==x||b==x||c==x||d==x) return true;
    else return false;
}
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int t=0;
    if(judge(a,b,c,d,1)) t++;
    if(judge(a,b,c,d,9)) t++;
    if(judge(a,b,c,d,7)) t++;
    if(judge(a,b,c,d,4)) t++;
    if(t==4) printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, a, b;
    scan(n, a, b);
    auto h = new long[](n);
    foreach (i; iota(n))
        h[i] = lread();

    long ok = (h.reduce!(max) + b - 1) / b, ng = -1;
    while (abs(ok - ng) > 1)
    {
        long mid = (ok + ng) / 2;
        bool solve()
        {
            long cnt;
            foreach (e; h)
            {
                if (e - mid * b > 0)
                {
                    cnt += ((e - mid * b) + (a - b) - 1) / (a - b);
                }
            }
            return (cnt <= mid);
        }

        if (solve())
            ok = mid;
        else
            ng = mid;
    }
    writeln(ok);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 4424
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

struct edge{int from, to, cost; };

edge es[2020];
int d[1010];
bool dd[1010];
int N, M;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        a --; b --;
        es[i] = edge{a, b, -c};
    }

    rep(i, N) d[i] = INF;
    rep(i, N) dd[i] = false;
    d[0] = 0; int cnt = 0;
    while(true) {
        bool update = true;
        cnt ++;
        rep(i, M) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(cnt >= N) {
            rep(i, M) {
                edge e = es[i];
                if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    dd[e.to] = true;
                }
                if(dd[e.from]) {
                    dd[e.to] = true;
                }
            }
        }
        if(!update) break;
        if(cnt >= 2 * N) break;
    }
    if(dd[N - 1]) {
        cout << "inf" << endl;
    } else {
        cout << -d[N - 1] << endl;
    }
	return 0;
}

Measured memory_bytes: 384
import math
import itertools

N = int(input())
X = []
Y = []
for i in range(N):
    x,y = map(int, input().split())
    X.append(x)
    Y.append(y)

l = list(range(1,N+1))

kai_list = list(itertools.permutations(l))

result = 0
count = 0

for item_i in kai_list:
    for i in range(1,len(item_i)):
        result += math.sqrt((X[item_i[0]-1] - X[item_i[i]-1])**2 + (Y[item_i[0]-1] - Y[item_i[i]-1])**2)

count = len(kai_list)
print(result/count)

Measured memory_bytes: 8052
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	m := map[int]struct{}{}
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		m[t] = struct{}{}
	}

	fmt.Println(len(m))

}


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

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long , long> pll;
typedef vector< pll > vll;
typedef set<ll> sl;
typedef map<string, int> msi;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define inf 0x3f3f3f3f
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

const ll md = 1000000007;
//void mod(ll &x){if (x >= md) x -= md; if (x < 0) x += md;}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s,t;
	vector<char> v;
	cin>>s>>t;
	ll len1 = s.length();
	ll len2 = t.length();
	ll dp[len1+1][len2+1];
	char path[len1+1][len2+1];
	ll i,j;
	for(i=0;i<=len1;i++){
		for(j=0;j<=len2;j++){
			if(i==0||j==0)
				dp[i][j] = 0;
			else if(s[i-1]==t[j-1]){
				dp[i][j] = 1+dp[i-1][j-1];
				path[i][j] = 'D';
			}else{
				if(dp[i-1][j]>dp[i][j-1]){
					dp[i][j] = dp[i-1][j];
					path[i][j] = 'U';	
				}else{
					dp[i][j] = dp[i][j-1];
					path[i][j] = 'L';
				}
			}
		}
	}
	i=len1;j=len2;
	while(i>0&&j>0){
		if(path[i][j] == 'D'){
			v.pb(s[i-1]);
			i--;
			j--;
		}
		else if(path[i][j]=='U')
			i--;
		else if(path[i][j]=='L')
			j--;
	}
	for(i=v.size()-1;i>=0;i--)
		cout<<v[i];
    return 0;
}




Measured memory_bytes: 79488
#include <iostream>
#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>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

string S;

int main()
{
	cin >> S;
	int k = S.length();
	int ans = 15 - k;
	//のこり前章したときのかず

	for (int i = 0; i < k; i++)
	{
		if (S[i] == 'o') ans++;
	}

	if (ans >= 8)
	{
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}

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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n;
    cin >> n;
    vector<string> s(n);
    for(ll i = 0;i < n;i++){
        cin >> s[i];
    }

    vector<ll> ans(26);
    for(ll i = 0;i < n;i++){
        vector<ll> t(26);
        for(ll j = 0;j < s[i].size();j++){
            t[(int)(s[i][j] - 'a')]++;
        }
        for(ll j = 0;j < 26;j++){
            if(ans[j] > t[j] || i == 0){
                ans[j] = t[j];
            }
            //cout << t[j];
        }
        //cout << endl;
    }

    for(ll i = 0;i < 26;i++){
        //cout << ans[i] << endl;
        while(ans[i] != 0){
            cout << (char)(i + 'a');
            ans[i]--;
        }
    }

    return 0;
}

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

int main()
{
	string s;
	int K;
	string tmp;
	map<string,bool> m;
	
	cin >> s >> K;
	
	for(int i=1;i<=K;i++)
	{
		for(int j=0;j<s.size()-i+1;j++)
		{
			tmp="";
			for(int k=0;k<i;k++)
				tmp+=s[j+k];
			m.insert({tmp,false});
		}
	}
	
	auto itr=m.begin();
	for(int i=0;i<K-1;i++)++itr;
	
	cout << itr->first << endl;
	return 0;
}


Measured memory_bytes: 1920
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

double inpro(const complex<double> &x, const complex<double> &y){// inner product
    return x.real()*y.real() + x.imag()*y.imag();
}

complex<double> projection(const complex<double> &x, const complex<double> &y){//projection of x onto y
    //cout << inpro(x,y) << endl;
    return y*(inpro(x, y)/norm(y));
}

int main(){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    complex<double> X(x2-x1, y2-y1), base(x1, y1);
    int p; cin >> p;
    vector<complex<double>> ans(p);
    rip(i,p,0){
        double x,y;
        cin >> x >> y;
        complex<double> now(x-x1, y-y1);
        ans[i] = projection(now, X) + base; 
    }
    rip(i,p,0){
        printf("%.10f %.10f\n", ans[i].real(), ans[i].imag());
    }
}


Measured memory_bytes: 3360
#include<stdio.h>
#include<string.h>
#define MAX 10000

int main(){
	char inichi[MAX],inni[MAX],insan[MAX],k;
	int a=0;
	int j,i,l;
	
	
	while(scanf("%s",inichi),inichi[0]-'-'){
		a=j=i=0;
		scanf("%s %s",inni,insan);
		
		k=inni[j++];
		l=strlen(inni)+strlen(inichi);
	
		while(--l){
			if(k==insan[i]){
		k=inichi[a++];
		i++;
			}
			else{
		printf("%c",k);
		k=inni[j++];
			}
		}
		printf("%c\n",k);
	}
	return 0;
}


Measured memory_bytes: 1976
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  int N, M; cin >> N >> M;
  int left = 0;
  int right = INF;
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    left = max(a, left);
    right = min(b, right);
  }
  cout << max((ll)0, right - left + 1) << endl;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int N;
string S[110];
int P[110];


int main(){

    cin >> N;
    vector<pair<pair<string, int>, int> > v;
    for(int i = 0; i < N; i++){
        cin >> S[i] >> P[i];
        v.emplace_back(make_pair(make_pair(S[i], -P[i]), i + 1));
    }
    sort(v.begin(), v.end());
    for(auto a : v){
        cout << a.second << endl;
    }



    return 0;
}


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

int main(void){
  int slen,tlen;
  int i;
  char s[11];
  char t[12];
  
  scanf("%s",s);
  scanf("%s",t);
  
  slen=strlen(s);
  tlen=strlen(t);
  
  for(i=0;i<slen;i++){
    if(s[i]!=t[i]){
      printf("No\n");
      return(0);
    }
  }
  printf("Yes\n");
  return(0);
}
  
  

Measured memory_bytes: 1592
from collections import deque

H, W = list(map(int, input().split()))
Ch, Cw = list(map(lambda x: int(x) - 1, input().split()))
Dh, Dw = list(map(lambda x: int(x) - 1, input().split()))
S = [input() for _ in range(H)]
maze = [[-1]*W for _ in range(H)]

def walk(h, w, warp_n):
    ans = []
    if maze[h][w] != -1:
        return []
    else:
        maze[h][w] = warp_n
        ans += [(h, w)]
        
    return ans

queue = deque([(Ch, Cw, 0)])
while queue:
    h, w, warp_n = queue.popleft()
    if maze[h][w] != -1:
        continue
    maze[h][w] = warp_n
    # walk
    for dh, dw in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if h+dh < 0 or w+dw < 0 or h+dh >= H or w+dw >= W:
                continue
            if S[h+dh][w+dw] == '#':
                continue
            queue.appendleft((h+dh, w+dw, warp_n))
    # warp
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if h+dh < 0 or w+dw < 0 or h+dh >= H or w+dw >= W:
                continue
            if S[h+dh][w+dw] == '#':
                continue
            if dh == 0 and dw == 0:
                continue
            queue.append((h+dh, w+dw, warp_n+1))

print(maze[Dh][Dw])

Measured memory_bytes: 255620
#include <stdio.h>
int SInsertSort(int A[],int n,int g)
{
    int k,c,cnt=0;
    for(int i=g-1;i<n;i++)
    {
        k=i;
        c=A[k];
        while (k>g-1 && c<A[k-g])
        {
            A[k]=A[k-g];
            k-=g;
            cnt++;
        }
        A[k]=c;
    }
    return cnt;
}
int A[1000010];
int main()
{
    int n,cnt=0,j,g[101];
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&A[i]);
    g[0]=1;
    for( j=0;g[j]<=n;j++) g[j+1]=g[j]*3+1;
    for(int i=j-1;i>-1;i--)cnt+=SInsertSort(A,n,g[i]);
    printf("%d\n",j);
    for(int i=j-1;i>-1;i--)printf("%d ",g[i]);
    printf("\n");
    printf("%d\n",cnt);
    for(int i=0;i<n;i++)printf("%d\n",A[i]);
    return 0;
}



Measured memory_bytes: 5612
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
    int N,M;
    while(cin>>N>>M,N){
      vector<int> h(N);
      vector<int> w(M);
      REP(i,N)cin>>h[i];
      REP(i,M)cin>>w[i];
      vector<int> sh(N+1);
      vector<int> sw(M+1);
      REP(i,N)sh[i+1] = sh[i] + h[i];
      REP(i,M)sw[i+1] = sw[i] + w[i];
      map<int,int> count;
      REP(i,N)FOR(j,i+1,N+1){
        count[sh[j]-sh[i]]++;
      }
      int ans = 0;
      REP(i,M)FOR(j,i+1,M+1){
        ans += count[sw[j]-sw[i]];
      }
      cout<<ans<<endl;
    }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> l(n);

    for (auto i = 0; i < n; i++)
    {
        long long l_i;
        cin >> l_i;
        l[i] = l_i;
    }

    long long sum = l[0];

    for (auto i = 1; i < n; i++)
    {
        sum ^= l[i];
    }

    string ans = "Yes";

    for (auto i = 0; i < n; i++)
    {
        if(l[i] != l[i]^sum){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
int n,i,a,b,c,d;
char s[200050];
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	if (c>d){
		for (i=a+1;i<c-1;i++) if (s[i]=='#'&&s[i+1]=='#'){
			puts("No");
			return 0;
		}
		for (i=b-1;i<d;i++) if (s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
			puts("Yes");
			return 0;
		}
		puts("No");
	}else{
		for (i=a+1;i<d-1;i++) if (s[i]=='#'&&s[i+1]=='#'){
			puts("No");
			return 0;
		}
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 384
import itertools
N,D = map(int,input().split())
N_List = [i for i in range(N)]
ND_List = []
for i in range(N):
    ND_List.append(list(map(int,input().split())))

cnt = 0
for comb in itertools.combinations(N_List,2):
    ans = 0
    for k in range(D):
        ans += (ND_List[comb[0]][k] - ND_List[comb[1]][k])**2
    ans =ans**0.5
    if ans.is_integer():
        cnt += 1
print(cnt)

Measured memory_bytes: 9272
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M, K := nextInt(), nextInt(), nextInt()
	An := make([]int, N)
	Bm := make([]int, M)
	CsumA := make([]uint, N+1)
	CsumB := make([]uint, M+1)
	var ans int
	for i := 0; i < N; i++ {
		An[i] = nextInt()
		CsumA[i+1] = CsumA[i] + uint(An[i])
	}
	for i := 0; i < M; i++ {
		Bm[i] = nextInt()
		CsumB[i+1] = CsumB[i] + uint(Bm[i])
	}
	// 二分探索する
	for i := 0; i <= N; i++ {
		if CsumA[i] > uint(K) {
			break
		}
		ok := 0
		ng := M + 1
		for abs(ng-ok) > 1 {
			mid := (ok + ng) / 2
			if uint(K) >= CsumA[i]+CsumB[mid] {
				ok = mid
			} else {
				ng = mid
			}
			ans = MaxOf(ans, i+ok)
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 15076
n = int(input())
dp = [float('inf')]*(n+1)
dp[0] = 0

for i in range(1, n+1):
  for j in range(7):
    if i - 6**j >= 0:
      dp[i] = min(dp[i], dp[i - 6**j] + 1)
  for j in range(7):
    if i - 9**j >= 0:
      dp[i] = min(dp[i], dp[i - 9**j] + 1)
      
print(dp[n])

Measured memory_bytes: 45648
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;

int main() {
	int D, N;
	cin >> D >> N;
	if (D == 0) {
		if (N == 100) {
			cout << 101 << endl;
			return 0;
		}
		else {
			cout << N << endl;
			return 0;
		}
	}
	if (D == 1) {
		if (N == 100) {
			cout << 10100 << endl;
			return 0;
		}
		else {
			cout << 100 * N << endl;
			return 0;
		}
	}
	if (D == 2) {
		if (N == 100) {
			cout << 1010000 << endl;
			return 0;
		}
		else {
			cout << N * 10000 << endl;
			return 0;
		}
	}
	return 0;
}

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

void fnInput(int& rnStair, vector<int>& rvnFine)
{
  int nFineSiz;
  cin >> rnStair >> nFineSiz;
  rvnFine.resize(rnStair + 1, true);

  for (int i = 0; i < nFineSiz; i++)
  {
    int nFine;
    cin >> nFine;
    rvnFine[ nFine ] = false;
  }
}

llong fnNumOfWays(int nStair, const vector<int>& cnrvnFine)
{
  const llong cnnMod = 1000000007;
  vector<llong> vnDPWays(nStair + 1);
  vnDPWays[0] = 1;

  for (int i = 1; i < vnDPWays.size(); i++)
  {
    if (cnrvnFine[i])
    {
      vnDPWays[i] += vnDPWays[i - 1];
      if (i > 1)
        vnDPWays[i] += vnDPWays[i - 2];

      vnDPWays[i] %= cnnMod;
    }
  }
  return vnDPWays[vnDPWays.size() - 1];
}
  
int main()
{
  int nStair;
  vector<int> vnFine;

  fnInput(nStair, vnFine);
  cout << fnNumOfWays(nStair, vnFine) << endl;

  return 0;
}

Measured memory_bytes: 4568
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

void print(int A[], int n) {
	for (int i = 0; i < n; ++i) {
		if (i != 0)
			cout << " " << A[i];
		else
			cout << A[i];
	}
	cout << endl;
}

//1 bubbleSort(A, N) // N ??????????´?????????? 0-????????????????????? A
//2   flag = 1 // ????????£??\????´?????????¨??????
//3   while flag
//4     flag = 0
//5     for j ??? N-1 ?????? 1 ?????§
//6       if A[j] < A[j-1]
//7         A[j] ??¨ A[j-1] ?????????
//8         flag = 1

int main() {

	int n;
	scanf("%d", &n);

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

//bubbleSort
	bool flag = false;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		flag = true;
		for (int j = n - 1; j > i; --j) {
			if (A[j] < A[j - 1]) {
				swap(A[j - 1], A[j]);
				++cnt;
				flag = false;
			}
		}
		if (flag)
			break;
	}

	print(A, n);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3184