akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <stdlib.h>

struct restaurant {
    int64_t i;
    char S[11];
    int64_t P;
};

int comparestr (const void *a, const void *b)
{
    return strcmp(((struct restaurant *)a)->S, ((struct restaurant *)b)->S);
}

int compare (const void *a, const void *b)
{
    if(((struct restaurant *)a)->P - ((struct restaurant *)b)->P < 0)
        return 1;
    if(((struct restaurant *)a)->P - ((struct restaurant *)b)->P > 0)
        return -1;
    return 0;
}

int main (int argc, char const *argv[])
{
    int64_t N;
    struct restaurant r[100];
    int64_t ans = 0;

    scanf("%"PRId64, &N);
    for (int i = 0; i < N; i++) {
        scanf("%s""%"PRId64, &r[i].S, &r[i].P);
        r[i].i = i + 1;
    }

    qsort(r, N, sizeof(struct restaurant), comparestr);

    for (int i = 0, j = 0; i < N; i = j) {
        while (strcmp(r[i].S, r[j].S) == 0) {
            j++;
        }
        qsort(&r[i], (j - i), sizeof(struct restaurant), compare);
    }

    for (int i = 0; i < N; i++) {
        printf("%"PRId64"\n", r[i].i);
    }
}


Measured memory_bytes: 128
def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

Q = int(input())
l, r = [0]*Q, [0]*Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
 
K = max(r)
prime = prime(K)
a = [1]*(K+1)
s = [0]*(K+1)
a[0] = 0
a[1] = 0
for i in range(2,K+1):
    if a[i]:
        for j in range(i*i, K+1, i):
            a[j] = 0

for i in range(3,K+1,2):
    if a[i] and a[(i+1)//2]:
        s[i] = 1

for i in range(K):
    s[i+1] += s[i]

for i in range(Q):
    rr, ll = r[i], l[i]
    if rr == ll:
        if s[ll]-s[ll-2] == 1:
            print(1)
        else:
            print(0)
    else:
        print(s[rr] - s[ll-1])

Measured memory_bytes: 15924
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m; cin >> n >> m;
  cout << (n == m ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  10005
ll d;
ll a[N];
ll n;
ll dp[N][2][105];

ll calc(ll pos, ll f, ll mod){
	if(dp[pos][f][mod]!=-1)return dp[pos][f][mod];
	ll ret=0;
	ll mx=9;
	if(!f)mx=a[pos];
	if(pos==n){
		return mod==0;
	}
	rep(i,0,mx+1){
		ll nf=f;
		if(i<a[pos])nf=1;
		ll modreq = (mod-i+d)%d;
		ret=(ret+calc(pos+1,nf,modreq))%hell;
	}
	return dp[pos][f][mod]=ret;
}


void solve()
{
	string s;
	cin>>s;
	cin>>d;
	n=sz(s);
	rep(i,0,n)a[i]=s[i]-'0';
  	rep(i,0,N){
    	rep(j,0,2){
        	rep(k,0,105){
            	dp[i][j][k]=-1;
            }
        }
    }
	cout<<(calc(0,0,0)-1+hell)%hell<<endl;

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 20936
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
#define maxn 10050
#define INF 1e9
struct note
{
    int to,next,c,w;
};
int pi,head[maxn],dis[maxn],cost[maxn];
note edge[2005000];
bool vis[maxn];
void add(int u,int v,int w,int c)
{
    edge[pi].to=v;
    edge[pi].c=c;
    edge[pi].w=w;
    edge[pi].next=head[u];
    head[u]=pi++;
}
queue<int>q;
int spfa(int s,int n)
{
    memset(vis,false,sizeof(vis));
    while(!q.empty())
        q.pop();
    for(int i=1;i<=n;i++)
        cost[i]=dis[i]=INF;
    dis[s]=0;
    cost[s]=0;
    vis[s]=true;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=edge[i].next)
        {
            int to=edge[i].to;
            int val=edge[i].w;
            if(dis[to]>dis[u]+val||(dis[to]==dis[u]+val&&cost[to]>edge[i].c))
            {
                dis[to]=dis[u]+val;
                cost[to]=edge[i].c;
                if(!vis[to])
                {
                    q.push(to);
                    vis[to]=true;
                }
            }
        }
    }
}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)&&n+m)
    {
        int a=0,u,v,c,w;
        memset(head,-1,sizeof(head));
        pi=0;
        for(int i=0;i<m;i++)
        {
            scanf("%d%d%d%d",&u,&v,&c,&w);
            add(u,v,c,w);
            add(v,u,c,w);
        }
        spfa(1,n);
        for(int i=1;i<=n;i++)
            a+=cost[i];
        printf("%d\n",a);
    }
}

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	bool isValid = true;
	isValid &= ((x >= -100) && (x <= 100));
	isValid &= ((y >= -100) && (y <= 100));
	isValid &= ((W > 0) && (W <= 100));
	isValid &= ((H > 0) && (H <= 100));
	isValid &= ((r > 0) && (r <= 100));
	
	if(isValid) {
		bool inRange = true;
		inRange &= ((x - r >= 0) && (x + r <= W));
		inRange &= ((y - r >= 0) && (y + r <= H));
		if(inRange) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 3108
package main

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

func main() {
	n := readI()
	a, b, c := make([]int, n+1), make([]int, n+1), make([]int, n+1)
	for i := 1; i <= n; i++ {
		a[i], b[i], c[i] = readI(), readI(), readI()
	}

	dp := make([][]int, n+1)
	dp[1] = []int{a[1], b[1], c[1]}
	for i := 2; i <= n; i++ {
		dp[i] = make([]int, 3)
		pre := dp[i-1]
		dp[i][0] = a[i] + max(pre[1], pre[2])
		dp[i][1] = b[i] + max(pre[0], pre[2])
		dp[i][2] = c[i] + max(pre[0], pre[1])
	}

	fmt.Println(max(dp[n]...))
}

func max(a ...int) int {
	m := a[0]
	for i := 1; i < len(a); i++ {
		if m < a[i] {
			m = a[i]
		}
	}
	return m
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, P; cin >> N >> P;
	string S; cin >> S;
	vint cnt(P+1, 0);
	cnt[0] = 1;
	int dat = 0;
	ll ans = 0;
	ll weight = 1;
	if (P == 2 || P == 5) {
		for (int i = 0; i < N; i++) {
			if ((S[i] - '0') % P == 0) {
				ans += i+1;
			}
		}
		cout << ans << endl;
		return;
	}
	for (int i = N-1; i >= 0; i--) {
		(dat += (S[i] - '0') * weight) %= P;
		(weight *= 10) %= P;
		dat %= P;
		ans += cnt[dat];
		cnt[dat]++;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 720
<?php
  $n = trim(fgets(STDIN));
  $count = [];
  for($i=0; $i<$n; $i++){
      $s = trim(fgets(STDIN));
      $s_li = [];
      for($j=0; $j<10; $j++){
          $s_li[] = $s[$j];
      }
      sort($s_li);
      $a = "";
      for($j=0; $j<10; $j++){
          $a .= $s_li[$j];
      }
      $count[$a]++;
  }
  
  function perm($k){
      return ($k*($k-1))/2;
  }
  
//   print_r($count);
  $ans = 0;
  foreach($count as $d){
      $ans += perm($d);
  }
  echo $ans;

Measured memory_bytes: 13048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
int vis[107];

int main(){
	memset(vis,0,sizeof(vis));
	int n,k;
	scanf("%d %d",&n,&k);
	while(k--){
		int d;
		scanf("%d",&d);
		while(d--){
			int x;
			scanf("%d",&x);
			vis[x] = 1;
		}
	}
	int sum = 0;
	for(int i = 1;i <= n;i++){
		if(!vis[i]) sum++;
	}
	printf("%d\n",sum);
    return 0;
}

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

using namespace std;

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

    vector<vector<int>> pos(26, vector<int>());

    // save all the appearances of s[i]
    for(int idx = 0; idx < s.size(); ++idx)
        pos[s[idx] - 'a'].push_back(idx);

    long long ans = 0LL;
    int x = -1; // last match
    
    for(int idx = 0; idx < t.size(); ++idx) {
        int c = t[idx] - 'a';

        if(pos[c].empty()) {
            cout << -1 << endl;
            return 0;
        }

        // binary search for c
        // get the first appearance of c after the last match x
        int it = upper_bound(pos[c].begin(), pos[c].end(), x) - pos[c].begin();

        if(pos[c].size() == it) {
            // match was at the end
            ans += pos[c][0] - x + s.size();
            x = pos[c][0];
        } else {
            ans += pos[c][it] - x;
            x = pos[c][it];
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main()
{
  string a,b;
  cin >> a >> b;
  
  int ans = stoi(a+b);
  for(int i = 1; i <= 500; i++){
    if(i + i > ans){
      break;
    }
    if(i * i == ans){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
  int N, M;
  cin >> N >> M;
  
  dsu uf(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    uf.merge(--A, --B);
  }
  
  int components = 0;
  for (int i = 0; i < N; i++) {
    if (uf.leader(i) == i) ++components;
  }
  
  cout << components - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3820
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int M = sc.nextInt();
		int N = sc.nextInt();
		int[] P = new int[M];
		for (int i = 0; i < M; ++i) {
			P[i] = sc.nextInt();
		}
		Arrays.sort(P);
		int[] dp = new int[M + 10001];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for (int i = 0; i < N; ++i) {
			int C = sc.nextInt();
			int E = sc.nextInt();
			for (int j = dp.length - 1; j - C >= 0; --j) {
				if (dp[j - C] == Integer.MAX_VALUE) continue;
				dp[j] = Math.min(dp[j], dp[j - C] + E);
			}
		}
		int[] sum = new int[dp.length];
		for (int i = 0; i < M; ++i) {
			sum[i + 1] = sum[i] + P[M - 1 - i];
		}
		for (int i = M + 1; i < sum.length; ++i) {
			sum[i] = sum[M];
		}
		int ans = 0;
		for (int i = 0; i < sum.length; ++i) {
			if (dp[i] == Integer.MAX_VALUE) continue;
			ans = Math.max(ans, sum[i] - dp[i]);
		}
		System.out.println(ans);
	}
}

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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
#define int long long

const int INF = 1e18 + 12;

const int N = 1e5 + 10;

signed main(){

	int n , w;
	cin>>n>>w;

	std::vector<int> val(n) , weight(n);
	int tot_val = 0;
	for(int i = 0 ; i < n ; ++i){
		cin>>weight[i]>>val[i];

		tot_val += val[i];
	}


	vector<int> dp(1000*tot_val+1 , INF);

	dp[0] = 0;

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

		for(int j = tot_val-val[i] ; j >= 0 ; --j)
			dp[j+val[i]] = min(dp[j+val[i]] , dp[j] + weight[i]);


	}

	int ans = 0;

	for(int i = 0 ; i <= tot_val ; ++i)
		if(dp[i]<=w)
			ans = max(ans , i);

	cout<<ans<<endl;

}

Measured memory_bytes: 781440
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans = 0;
	if (N <= K)ans += X*N;
	else {
		ans += K*X;
		ans += (N - K)*Y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	s := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
		fmt.Println(s[i])
		fmt.Println(s[i])
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<endl;
using namespace std;
set<int> pos[30];
int cx[30];
int main(){
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();++i){
		pos[s[i]-'a'].insert(i);
		cx[s[i]-'a']=1;
	}
	long long ret=0;
	long long ans=0;
	for(int i=0;i<t.length();++i){
		if(cx[t[i]-'a']==0){
			puts("-1");
			return 0;
		}
		auto it=pos[t[i]-'a'].lower_bound(ret);
		if(it==pos[t[i]-'a'].end()){
			ret=*(pos[t[i]-'a'].lower_bound(-1));
			if(i!=t.length()-1&&t[i]==t[i+1]){
				++ret;
			}
			ans+=s.length();
		}else{
			ret=*it;
			if(i!=t.length()-1&&t[i]==t[i+1]){
				++ret;
			}
			
		}
	}
	cout<<ans+ret+1;
	return 0;
}



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

using namespace std;

int main(){
  int n,a;
  cin >> n;
  a = n%10;
  if(a==2||a==4||a==5||a==7||a==9)cout <<"hon";
  if(a==0||a==1||a==6||a==8)cout <<"pon";
  if(a==3)cout <<"bon";

return 0;
}

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

#define N_MAX 10000
#define Q_MAX 500

int linearsearch(int n,int* A,int key){
	
	int i=0;
	A[n]= key;
	while (A[i]!=key){
		i++;
	}
	if(i>=n){
		return N_MAX+1;
	}
	return i;
	
}

int main(void){

	int A[N_MAX+1];
	int n;
	int B[Q_MAX+1];
	int q;
	int s=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&B[i]);
	}
	
	for(int i=0;i<q;i++){
		if(linearsearch(n,A,B[i])!=N_MAX+1)s++;
	}
	
	printf("%d\n",s);
	
	return 0;
}


Measured memory_bytes: 2144
<?php
/*
    http://agc006.contest.atcoder.jp/tasks/agc006_a
 
    Score  :
    Result :
    Time   : ms
    Memory : KB
 */
 
// define('DEBUG', true);
define('DEBUG', false);
 
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%s", $t);
 
for ($i = $N; $i >= 0; $i--) {
	$ss = substr($s, strlen($s) - $i);
	$tt = substr($t, 0, $i);
	// echo "{$ss} {$tt}\n";
	if ($ss == $tt) {
		echo ($N * 2 - $i) . PHP_EOL;
		exit;
	}
}

Measured memory_bytes: 3064
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val N, M, C = sc.nextInt()
    val B: IndexedSeq[Int] = for (i <- 0 until M) yield sc.nextInt()
    val A: IndexedSeq[IndexedSeq[Int]] = for (i <- 0 until N) yield{
      for (j <- 0 until M) yield sc.nextInt()
    }
    (N,M,C,B,A)
  }

  def solve(n:Int, m:Int, c:Int, b:IndexedSeq[Int], a:IndexedSeq[IndexedSeq[Int]]):Int= {
    def mult(s:Int, t:Int) :Int = s*t
    def decision_funcion(x: IndexedSeq[Int]): Int= (0 until m).map(i => b(i) * x(i)).sum + c
    def predict(x:IndexedSeq[Int]): Boolean = decision_funcion(x)>0
    a.map(aElem=>predict(aElem)).count(p=>p==true)
  }

  def main(args: Array[String]): Unit = {
    val (n,m,c,b,a) = read()
    println(solve(n,m,c,b,a))
  }
}

Measured memory_bytes: 25676
import itertools

def path(n):
    l = len(n)
    i = 0
    while i < l - 1:
        a = n[i]
        b = n[i + 1]

        if a < b:
            c = (a, b)
        else:
            c = (b, a)

        for m in C:
            if m == c:
                break
        else:
            return False
        i += 1
    return True

N, M = map(int, input().split())
C = []
i = 0
while i < M:
    C += [tuple(map(int, input().split()))]
    i += 1

i = 0
l = range(1, N + 1)
for n in itertools.permutations(l, N):
    if n[0] != 1:
        break
    if path(n) == True:
        i += 1
print(str(i))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge{
	int s,t,nxt;
}e[200005];
int last[100005],e_cnt;
void ins(int a,int b){
	e[e_cnt]=(edge){a,b,last[a]};
	last[a]=e_cnt++;
}
int d[100005],p[100005],cnt;
int fa[100005];
bool dfs(int x){
	if(x==p[1])return false;
	for(int i=last[x];i!=-1;i=e[i].nxt)if(e[i].t!=fa[x]){
		if(e[i].t==p[2])return true;
		fa[e[i].t]=x;
		if(dfs(e[i].t))return true;
	}
	return false;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	memset(last,-1,sizeof(last));
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		ins(x,y);
		ins(y,x);
		d[x]++; d[y]++;
	}
	bool ok=1,fl=0;
	for(int i=1;i<=n;i++){
		if(d[i]&1)ok=0;
		if(d[i]>2)p[++cnt]=i;
		if(d[i]>4)fl=1;
	}
	if(ok&&(cnt>2||fl||(cnt==2&&dfs(p[2]))))puts("Yes");
	else puts("No");
}

Measured memory_bytes: 4480
#include <stdio.h>
int ax, ay, ar, bx, by, br;
int main() {
	scanf("%d%d%d%d%d%d", &ax, &ay, &ar, &bx, &by, &br);
	int norm = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
	if(norm > (ar + br) * (ar + br)) puts("4");
	else if(norm == (ar + br) * (ar + br)) puts("3");
	else if(norm > (ar - br) * (ar - br)) puts("2");
	else if(norm == (ar - br) * (ar - br)) puts("1");
	else puts("0");
}

Measured memory_bytes: 2692
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
if N > 1:
  devides[1] = 1
  for prime in primes:
    _devides = [d for d in devides]
    for i in range(N):
      if devides[i]:
        if i * prime < N:
          _devides[i * prime] = 1
        else:
          ans = max(M // i // prime, ans)
    devides = _devides
else:
  ans = M
print(ans)

Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n,k,x,ans=0;
    long long worst[100005],best[100005];
    worst[0]=best[0]=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        worst[i]=worst[i-1];
        best[i]=best[i-1];
        cin>>x;
        if(x>0)
            best[i]+=x;
        else
            worst[i]+=x;
    }
    for(int i=1;i<=n-k+1;i++)
        ans=max(max(ans,best[n]+worst[i+k-1]-worst[i-1]),best[n]-best[i+k-1]+best[i-1]);
    cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using i64 = long long;

struct Edge {
    int from, to;
    i64 cost;
    Edge(int f, int t, i64 c) : from(f), to(t), cost(c) {}
};

std::vector<std::vector<std::pair<int, i64>>> g;
std::vector<int> done;
std::vector<Edge> edges;

void dfs(int v) {
    done[v] = 1;
    for (auto to : g[v]) {
        edges.emplace_back(to.first, v, to.second);
        if (done[to.first]) continue;
        dfs(to.first);
    }
}

int main() {
    int n, m;
    i64 p;
    std::cin >> n >> m >> p;
    g.resize(n); done.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        i64 c;
        std::cin >> a >> b >> c;
        --a; --b;
        g[b].emplace_back(a, p - c);
    }

    dfs(n - 1);

    constexpr i64 inf = std::numeric_limits<i64>::max();
    std::vector<i64> dist(n, inf);
    dist[0] = 0;
    for (int i = 0; i < n - 1; i++) {
        for (auto &e : edges) {
            if (dist[e.from] == inf) continue;
            dist[e.to] = std::min(dist[e.to], dist[e.from] + e.cost);
        }
    }

    for (auto &e : edges) {
        if (dist[e.from] == inf) continue;
        if (dist[e.from] + e.cost < dist[e.to]) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    std::cout << std::max(-dist.back(), 0ll) << std::endl;

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, h, w, a, b;
  scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
  for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) printf("%d", (i < b) ^ (j < a));
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
    char a[1000]={0};
    int i,j,k;
    while(scanf("%s",a)!=EOF)
    {
        for(i=0;i<1000;i++)
        {
            if(a[i]=='\0')break;
            else if(a[i]=='A')a[i]='X';
            else if(a[i]=='B')a[i]='Y';
            else if(a[i]=='C')a[i]='Z';
            else a[i]=a[i]-3;
        }
        for(i=0;i<1000;i++)
        {
            if(a[i]!='\0')printf("%c",a[i]);
            a[i]=0;
        }
        printf("\n");
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a * b * 1 % 2 != 0) cout << "Yes" << endl;
  else if (a * b * 2 % 2 != 0) cout << "Yes" << endl;
  else if (a * b * 3 % 2 != 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

vector<int> solve(long long int x){
	if(x==1)	return vector<int>();
	if(x&1){
		auto res = solve(x-1);
		res.insert(res.begin(),res.size()+1);
		return res;
	}
	else{
		auto res = solve(x>>1);
		res.emplace_back(res.size()+1);
		return res;
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long int n;
	cin>>n;
	n++;
	auto res = solve(n);
	cout<<res.size()*2<<endl;
	for(int it:res)
		cout<<it<<' ';
	for(int i=1;i<=res.size();i++)
		cout<<i<<' ';
	cout<<endl;
}


Measured memory_bytes: 256
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;
const int K = 1e2 + 5;
ll we[K], v[K];
ll dp[K][N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++){
        cin >> we[i] >> v[i];
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= w; j++){
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(we[i] <= j)
                dp[i][j] = max(dp[i - 1][j], v[i] + dp[i - 1][j - we[i]]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][w];
return 0;
}


Measured memory_bytes: 80128
N = gets.to_i
S = gets.chomp.chars.map{|c|c == ?W ? 0 : 1}
min = curr = (1...N).count{|i|S[i] == 1}

(1...N).each{|i|
  curr += 1 if S[i-1] == 0
  curr -= 1 if S[i] == 1
  min = [min, curr].min
}
p min


Measured memory_bytes: 31876
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
int main()
{
   m["SUN"]=7; 
      m["MON"]=6; 
         m["TUE"]=5; 
            m["WED"]=4; 
               m["THU"]=3; 
               
                 m["FRI"]=2; 
                    m["SAT"]=1; 
                    string str;cin>>str;cout<<m[str];
}

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

int main() {
	int n, x, answer;
	
	while (1) {
		answer = 0;
		cin >> n >> x;

		if (n == 0 && x == 0)
			break;

		for (int i = 1;i < n+1;i++) {
			for (int j = i+1;j < n+1;j++) {
				for (int k = j+1;k < n+1;k++) {
					if (i + j + k == x)
						answer++;
				}
			}
		}
		cout << answer << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int K,S;cin>>K>>S;
    int ans=0;
    REP(X,K+1) REP(Y,K+1){
        int Z = S-X-Y;
        if(0<=Z&&Z<=K) ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll n,t;
	cin>>n>>t;

	vector<P> ab;
	Array bb;//a=0
	REP(i,n){
		ll a,b;
		cin>>a>>b;
		b++;
		if(a==0){
			bb.push_back(b);
		}else{
			ab.push_back({a,b});
		}
	}

	//a>0のパターン
	sort(all(ab),[&](P x, P y){
		return y.first*x.second < x.first*y.second;
	});
	
	ll m=30;
	Matrix dp(ab.size()+1,Array(m+1,INF));//i番目までにj点回る最小時間
	dp[0][0]=0;
	REP(i,ab.size()){
		ll a=ab[i].first;
		ll b=ab[i].second;
		REP(j,m+1){
			if(dp[i][j]>t) break;
			ll next = dp[i][j] + a*(dp[i][j]+1)+b;
			if(j+1<=m && next<=t) chmin(dp[i+1][j+1],next);
			chmin(dp[i+1][j],dp[i][j]);
		}
	}

	//a=0のパターン
	sort(all(bb));
	Array sum(bb.size()+1,0);
	REP(i,bb.size()) sum[i+1]=sum[i]+bb[i];

	ll ans=0;
	REP(i,m+1){
		if(dp[ab.size()][i]>t) break;
		ll con=i;
		if(bb.size()>0) con += upper_bound(all(sum), t-dp[ab.size()][i]) - sum.begin() -1;
		chmax(ans,con);
	}
	cout<<ans<<en;
}

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

	solve();
    return 0;
}

Measured memory_bytes: 58604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //最大の友達集合を求める
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4028
import random

global NN
NN = 26


class Contest:
    """
    d: ある日付
    i: テストの種類
    self.day: 最後にテストiを開催した日
    """

    def __init__(self, c, s, D):
        self.test = [i % NN for i in range(D)]
        self.last = [0 for _ in range(NN)]
        self.C = c
        self.S = s
        self.score = 0

    def update_day(self, i, d):
        self.last[i] = d

    def minus_score(self, d, i):
        m = self.C[i] * (d - self.last[i])
        return m

    def sum_minus_scores(self, d):
        m = 0
        for i in range(NN):
            m += self.minus_score(d, i)

        return m

    # テストiを開催したときのスコア
    def update_score(self, i, d):
        s = self.score
        self.update_day(i, d)
        s += S[d][i]
        s -= self.sum_minus_scores(d)
        return s


D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

r = [random.randrange(1, NN + 1) for _ in range(D)]
print(*r)

# T = Contest(C, S, D)
#
# for i in range(D):
#     j = i % NN
#     score = T.update_score(j, 1)
#     print(j, score)
#
# print()
#
# T = Contest(C, S, D)
#
# for i in range(D):
#     j = random.randrange(NN)
#     score = T.update_score(j, 1)
#     print(j, score)


"""
+ 方針
  + Cの大きいテストは定期的に開催する
  + Cの小さいテストはまれに開催する
    + d = 1, 2, 3, 4, 5 ....
    + d-last[d] = 1, 3, 6, 10, 15 ...
    + 結構緩やか？

+ スコアを伸ばす方法
  + プラスを大きくする
  + マイナスを小さくする

"""


Measured memory_bytes: 9872
#include<iostream>

using namespace std;

int main() {
    int a,b;
    char c;
    while(1){
        cin >> a >> c >> b;
        if(c == '?') break;
        switch(c){
            case '+' :
                cout << a+b;
                break;
            case '-' :
                cout << a-b;
                break;
            case '*' :
                cout << a*b;
                break;
            case '/' :
                cout << a/b;
                break;
        }
    cout << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <stack>
#include <vector>

using i64 = long long;

int main() {
  i64 n;
  std::cin >> n;
  std::vector<i64> a(n);
  for (auto &e : a) {
    std::cin >> e;
  }

  std::vector<i64> pp(n), p(n), s(n), ss(n);
  {
    std::stack<i64> st0, st1, temp;
    for (i64 i = 0; i != n; ++i) {
      while (!st1.empty() && a[st1.top()] < a[i]) {
        ss[st1.top()] = i;
        st1.pop();
      }
      while (!st0.empty() && a[st0.top()] < a[i]) {
        s[st0.top()] = i;
        temp.push(st0.top());
        st0.pop();
      }
      st0.push(i);
      while (!temp.empty()) {
        st1.push(temp.top());
        temp.pop();
      }
    }
    while (!st0.empty()) {
      s[st0.top()] = n;
      ss[st0.top()] = n;
      st0.pop();
    }
    while (!st1.empty()) {
      ss[st1.top()] = n;
      st1.pop();
    }
  }
  {
    std::stack<i64> st0, st1, temp;
    for (i64 i = n; i != 0;) {
      --i;
      while (!st1.empty() && a[st1.top()] < a[i]) {
        pp[st1.top()] = i;
        st1.pop();
      }
      while (!st0.empty() && a[st0.top()] < a[i]) {
        p[st0.top()] = i;
        temp.push(st0.top());
        st0.pop();
      }
      st0.push(i);
      while (!temp.empty()) {
        st1.push(temp.top());
        temp.pop();
      }
    }
    while (!st0.empty()) {
      p[st0.top()] = -1;
      pp[st0.top()] = -1;
      st0.pop();
    }
    while (!st1.empty()) {
      pp[st1.top()] = -1;
      st1.pop();
    }
  }

  i64 ans = 0;
  for (i64 i = 0; i != n; ++i) {
    ans += a[i] * ((p[i] - pp[i]) * (s[i] - i) + (i - p[i]) * (ss[i] - s[i]));
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 4864
s = input()
n = len(s)

se = ['A', 'C', 'G', 'T']

ans = 0
count = 0
for i in range(n):
    if s[i] in se:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
ans = max(ans, count)
print(ans)


Measured memory_bytes: 3060
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << "\n"
using namespace std;
template <class T>
string to_binary(T n)
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void print(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
void solve()
{
	int i,j;
	ll sum = 0,prod = 1;
	string s,t;
	cin >> s >> t;
	s = s+t.back();
	if(s == t )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3620
n=io.read("*n")
a={-2}
for i=1,n do
  table.insert(a,io.read("*n"))
end

for i=2,n+1 do
  if a[i-1]>a[i] then
    if a[i-1]>a[i]+1 then
      print("No")
      os.exit()
    else
      a[i]=a[i]+1
    end
  end
end

print("Yes")

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

typedef long long ll;

vector<ll> layer;
vector<ll> p;

//anは層の長さの数列、bnはパティの量の数列

ll rec(ll N ,ll X){
    if(N == 0) return 1;
    if(X == 1) return 0;
    ll an = (1ll<<(N+1)) - 3;
    ll bn =  (1ll<<(N)) - 1;

    if(X == an + 2) return bn+1; //層と下から数える数の一致
    else if(X <= an + 1) return rec(N-1,X-1); 
    else if(X <= (an+1)*2) return bn + 1 + rec(N-1,X-an-2);
    else return bn*2+1;
}

int main(){
    ll N,X;
    cin>>N>>X;

    ll ans = rec(N,X);

    cout<<ans<<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, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
  cin >> n;
  pair<ll, ll> xy[50];

  REP(i, n)
  {
    ll x, y;
    cin >> x >> y;
    xy[i] = make_pair(x, y);
  }

  int count = 0;
  if (n == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  REP(i, n)
  {
    REP(j, n)
    {
      if (i == j)
        continue;
      int tmp = 0;
      ll p = xy[i].first - xy[j].first;
      ll q = xy[i].second - xy[j].second;
      REP(k, n)
      {
        REP(l, n)
        {
          if (p == xy[k].first - xy[l].first && q == xy[k].second - xy[l].second)
          {
            tmp++;
          }
        }
      }
      count = max(tmp, count);
    }
  }

  cout << n - count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N, L; cin >> N >> L;
  int sum = 0, vmin = 1e9;;
  for (int i = 0; i < N; ++i) {
    sum += L + i;
    if (abs(vmin) >  abs(L + i)) {
      vmin = L + i;
    }
  }
  cout << sum - vmin << endl;
}


Measured memory_bytes: 3580
let ar =
  Array.init 3 (fun _ -> Scanf.scanf "%d %d %d\n" (fun a b c -> (a, b, c)))

let rec eq a b c = a = b && b = c && c = a

let rec solve () =
  let c11, c12, c13 = ar.(0)
  and c21, c22, c23 = ar.(1)
  and c31, c32, c33 = ar.(2) in
  eq (c11 - c21) (c12 - c22) (c13 - c23)
  && eq (c21 - c31) (c22 - c32) (c23 - c33)
  && eq (c11 - c12) (c21 - c22) (c31 - c32)
  && eq (c12 - c13) (c22 - c23) (c32 - c33)


let () = (if solve () then "Yes" else "No") |> print_endline

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
	int n,i,j,a[30005]={0},vis[10]={0},ans=0,x,vis1[10]={0};
	char s[30005];
	scanf("%d",&n);
	getchar();
	scanf("%s",s);
	a[n-1]=1;
	for(i=n-2;i>=0;i--)
	{
		int w=0;
		for(j=n-1;j>i;j--)
		{
			if(s[j]==s[i]){w=1;break;}
		 }
		 a[i]+=a[i+1];
		 if(w==0)a[i]+=1;
	}
		for(i=0;i<n;i++)
	{
		if(i==n-1||a[i]>a[i+1])a[i]--;
	}
	for(i=0;i<n;i++)
	{
		
		if(!vis1[(int)(s[i]-'0')]){
			vis1[(int)(s[i]-'0')]=1;
		for(j=i+1;j<n-1;j++)
		{
			x=s[j]-'0';
			if(!(vis[s[j]-'0'])){
			ans+=a[j];
			vis[x]=1;
			}
		}
		memset(vis,0,sizeof(vis));
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
     
      boolean ans = false;
      for(int i = 0; i <= 25; i++) {
        for(int j = 0; j <= 14; j++) {
          if((i*4)+(j*7)==n) {
            ans = true;
          }
        }
      }

      if(ans) {
        System.out.println("Yes");
      }else {
        System.out.println("No");
      }
    
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 100001
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
vector<ll >graph[mx];
ll dist[mx]={0};
bool vis[mx];
ll dp[mx] ={0};
ll ans=0;
void dfs(ll root)
{
    vis[root]=true;
    for(auto x:graph[root])
    {
        if(vis[x]==false)
        {
            dfs(x);
        }
        dist[root]=max(dist[root],dist[x]+1);
    }
    ans=max(ans,dist[root]);
}
int main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        ll a,b;
        cin>>a>>b;
        graph[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }
    cout<<ans;
}


Measured memory_bytes: 8704
void main()
{
    long n = readln.chomp.to!long;

    long[5] cnts;
    string t = "MARCH";
    foreach (i; 0 .. n)
    {
        string s = readln.chomp;
        foreach (j, x; t)
        {
            if (x == s[0]) ++cnts[j];
        }
    }

    long result;
    foreach (i; 0 .. 3)
    {
        foreach (j; i+1 .. 4)
        {
            long mul = cnts[i] * cnts[j];
            foreach (k; j+1 .. 5)
            {
                result += mul * cnts[k];
            }
        }
    }

    result.writeln;
}

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

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;
 
int main (){
  int n,m;
  bool flag;
  cin >> n >> m;

  string a[n],b[m];

  rep(i,0,n){
    cin >> a[i];
  }
  rep(i,0,m){
    cin >> b[i];
  }

  int c = n-m+1;
  rep(k,0,c){
    rep(l,0,c){
      flag =1;
      rep(i,0,m){
        rep(j,0,m){
          if(a[i+k][j+l] != b[i][j]) flag = 0;
        }
      }
      if(flag){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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

typedef unsigned long long int ull;

struct data { ull A; int B; };

bool cmp(const data &value_a, const data &value_b) {
  return value_a.A < value_b.A;
}

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

  struct data drink[N]; 
  for (int i = 0; i < N; ++i) {
    cin >> drink[i].A >> drink[i].B; 
  }
  
  sort(drink, drink+N, cmp);
  
  int sum = M;
  ull answer = 0;
  for (int i = 0; i < N; ++i) {
    if (sum == 0) { break; }
    else if (sum - drink[i].B < 0) { 
      for (int j = drink[i].B; j > 0; --j) {
        if (sum == 0) { break; }
        sum--;
        answer += drink[i].A;
      }
    }
    else {
      sum -= drink[i].B;
      answer += drink[i].A * drink[i].B;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll n; cin >> n;
    ll ch = n;
    vector<int> ans;
    while(ch >= 26) {
        ll amari = ch%26;
        ch = ch/26;
        if(amari == 0) {
            amari = 26;
            ch--;
        }
        ans.emplace_back(amari);
    }
    ans.emplace_back(ch);
    reverse(ans.begin(), ans.end());
    vector<char> aans;
    for(int i = 0; i < (int)ans.size(); ++i) {
        if(ans.at(i) == 0) continue;
        aans.emplace_back(ans.at(i)-1 + 'a');
    }
    for(int i = 0; i < (int)aans.size(); ++i) {
        cout << aans.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	int n,a,max,min,i;
	max=0; min=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(max<a) max=a;
		if(min>a) min=a;
	}
	printf("%d\n",max-min);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
	"strings"
	"errors"
	"log"
)

// 文字列を1行入力
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)

	return
}

// 整数値を1つ取得
// func IntStdin() (int, error) {
// 	stringInput := StrStdin()
// 	return strconv.Atoi(strings.TrimSpace(stringInput))
// }

// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
    // 文字列で1行取得
    stringInput := StrStdin()

    // 空白で分割
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// 文字列スライスを取得
	stringSplited := SplitStrStdin(" ")

	// 整数スライスに保存
	for i := range stringSplited {
		var iparam int
		var errMsg string
		iparam, err = strconv.Atoi(stringSplited[i])
		
		if err != nil {
			return
		}
		errMsg = catchNumError(iparam, i)
		if errMsg != "" {
			if errMsg := numError(); errMsg != nil {
				log.Fatal(errMsg)
				return
			}
		}
		intSlices = append(intSlices, iparam)

	}

	return
}

// 数値の条件を判定
func catchNumError(num int, index int) (errMsg string) {
	if (index == 0 && num >= 1) || (index == 1 && num <= 10000) {
		return
	}else {
		errMsg = "条件満たしてないよ"
		return
	}

}


// 偶数か奇数を判定
func detectEvenOdd(num []int) (msg string) {
	if ((num[0]*num[1]) % 2) == 0 {
		msg = "Even"
		return
	}else {
		msg = "Odd"
		return
	}
}
func numError() error {
	return errors.New("条件満たしてないよ")
}
func main() {
	i, err := SplitIntStdin(" ")
	var msg string
	if err == nil {
		msg = detectEvenOdd(i)
		fmt.Println(msg)
	}
}

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

int main()
{
  int N;
  cin >> N;
  set<int> num;
  for (int i=0; i<N; i++){
    int j;
    cin >> j;
    num.insert(j);
  }
  cout << num.size();
  
  return 0;
}

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

int main() {
  long ans=0;
  string s;
  cin >> s;
  for(long bit=0;bit<(1<<(s.size()-1));bit++) {
    long a=s[0]-'0',b=0;
    for(long i=1;i<s.size();i++) {
      if(bit&(1<<(i-1))) a=(a*10)+(s[i]-'0');
      else b+=a,a=s[i]-'0';
    }
    b+=a;
    ans+=b;
  }
  cout << ans << endl;
}

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

int main() {
	int n; cin >> n;
	rep(i, n) {
		double h, m; scanf("%lf:%lf", &h, &m);
		double d = abs(h * 30. - 5.5 * m);
		if (360 - d < d)d = 360 - d;
		if (0. <= d&&d < 30.)puts("alert");
		else if (90. <= d&&d <= 180.)puts("safe");
		else puts("warning");
	}
}

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String kosu=br.readLine();
            int nako=Integer.parseInt(kosu);
            String strArr[] = br.readLine().split(" ");
            int[] a=new int[nako];

            for(int j=0; j<nako; j++){
                a[j]=Integer.parseInt(strArr[j]);
            }

            String aa="";
            for(int i=nako-1; i>=1; i--){
                aa=aa+""+(a[i]+" ");
            }aa=aa+""+a[0];

            System.out.println(aa);
            aa="";



    }
}

Measured memory_bytes: 24296