akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
    int n, k, cnt;
    scanf("%d", &n);
    
    for ( cnt=0; n>0; --n) {
        scanf("%d", &k);
        cnt += isprime(k);
    }
    printf("%d\n", cnt);
    
    return 0;
}

int isprime(int n)
{
    int i;
    
    if ( n == 2)
        return 1;
    if ( n < 2 || n%2 == 0)
        return 0;
    
    for ( i=3; i*i <= n; i+=2) {
        if ( n%i == 0)
            return 0;
    }
    
    return 1;
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"
using namespace std;

struct edge {
	int from;
	int to;
	int t;
};

int N, M, T;
void bfs(const vector<vector<edge>>&edges, vector<int>&can_go) {
	queue<pair<int, int>>que;
	que.emplace(0, 0);
	can_go[0] = true;
	while (!que.empty()) {
		auto atop(que.front());
		que.pop();
		const int nexttime = atop.second + 1;
		for (auto e : edges[atop.first]) {
			if (nexttime <= e.t&&!can_go[e.to]) {
				can_go[e.to] = true;
				que.emplace(e.to, nexttime);
			}
		}
	}
}


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int main() { cin >> N >> M >> T;
	vector<vector<edge>>edges(N);
	vector<edge>all_edges;
	for (int i = 0; i < M; ++i) {
		int a, b, t; cin >> a >> b >> t;
		a--; b--;
		edges[a].push_back(edge{ a,b,t });
		edges[b].push_back(edge{ b,a,t });
		all_edges.push_back(edge{ a,b,t });
	}
	sort(all_edges.begin(), all_edges.end(), [](const edge&l, const edge&r) {
		return l.t > r.t;
	});
	vector<long long int>scores(N);
	vector<long long int>latest_connect(N, T);
	UnionFind uf(N);
	vector<int>can_go(N);
	bfs(edges, can_go);
	for (auto e : all_edges) {
		int a(e.from);
		int b(e.to);
		const int root_a = uf.root(a);
		const int root_b = uf.root(b);
		if (root_a ==root_b)continue;
		else {
			long long int new_score = 0;
			if (can_go[root_a]) {
				new_score = max(new_score, scores[root_a] + ( latest_connect[root_a]-e.t)*uf.size(root_a));
			}
			if (can_go[root_b]) {
				new_score = max(new_score, scores[root_b] + (latest_connect[root_b]-e.t)*uf.size(root_b));
			}
			uf.unionSet(root_a, root_b);
			const int root_n = uf.root(root_a);
			if (can_go[root_a]) {
				can_go[root_n] = true;
			}
			if (can_go[root_b]) {
				can_go[root_n] = true;
			}
			latest_connect[root_n] = e.t;
			scores[root_n] = new_score;
		}
	}
	const int aroot = uf.root(0);
	long long int ans = scores[aroot] + latest_connect[aroot] * N;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}
      

Measured memory_bytes: 384
S = input()

if S == "SUN":
  print(7)
elif S == "MON":
  print(6)
elif S == "TUE":
  print(5)
elif S == "WED":
  print(4)
elif S == "THU":
  print(3)
elif S == "FRI":
  print(2)
elif S == "SAT":
  print(1)

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int sum=0;
	for(int i=1;i<n-1;++i)
		if(a[i-1]<a[i]&&a[i+1]>a[i]||a[i-1]>a[i]&&a[i+1]<a[i])
			++sum;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

struct Pos {
	double x, y;
};

double func() {
	return 0;
}

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

	int count = 1;
	for (int i = 2; i <= n; i++) count *= i;
	int coe = count * (n - 1);

	int c = n * (n - 1) / 2;

	vector<Pos> pos(n);
	rep(i, n) cin >> pos[i].x >> pos[i].y;
	double ans = 0;
	rep (i, n) {
		for (int j = i + 1; j < n; j++) {
			ans += sqrt((pos[i].x - pos[j].x) * (pos[i].x - pos[j].x) + (pos[i].y - pos[j].y) * (pos[i].y - pos[j].y)) * (coe / c);
		}
	}
	cout << setprecision(16) << ans / count << endl;
}

Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;

int main()
{
	qq=1;
	while(qq--)
	{
	ll a,b,v,w,t;
	scanf("%lld%lld", &a, &v);
	scanf("%lld%lld", &b, &w);
	scanf("%lld", &t);
	if(v<=w) puts("NO");
	else
	{
	if(abs(b-a)<=t*abs(v-w)) puts("YES");
	else puts("NO");
	}
	}
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 20;
int N, K, h[MN];
int dp[MN];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N >> K;
    for (int i = 1; i <= N; i++) cin >> h[i];
    memset(dp, 0x3f, sizeof(dp));
    dp[1] = h[0];
    for (int i = 2; i <= N; i++)
        for (int j = max(1, i - K); j < i; j++)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    cout << dp[N] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    ll mod=1e9+7;
    for(int i=k; i<=n+1; i++){
        ll tmp = ((n+n+1LL-i)*i/2LL)-((i-1LL)*i/2LL)+1LL;
        //cout<<tmp<<endl;
        sum+=tmp;
        sum%=mod;
    }
    cout<<max(1LL,sum)<<endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
using namespace std;
int kumi(int n, int x){
    int count = 0;
    for(int i=1; i<=n-2; i++){
        for(int j=i+1; j<=n-1; j++){
            for(int k=j+1; k<=n; k++){
             if(i+j+k==x)count=count+1;   
            }
        }
    }
    return count;
}
int main(){
    int n,x;
    while(1){
        cin >> n >>x;
        if(n==0 && x==0)break;
        cout << kumi(n,x) << endl;
    }
    return 0;
}


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

int main(){
    long long N,M; cin >> N >> M;
    long long a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    long long sum[N+1]={};
    map<long long,long long> ma;
    for(int i=0;i<N;i++){
        sum[i+1]=sum[i]+a[i];
        ma[sum[i+1]%M]++;
    }
    long long ans=0;
    for(auto it=ma.begin();it!=ma.end();it++){
        long long res=it->second;
        if(it->first==0){
            ans+=res;
        }
        if(res>=2){
            ans+=res*(res-1)/2;
        }
    }
    cout << ans << endl;
}

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

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

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			 System.out.println(b*2>=a ? 0 : a-b*2);
		}
	}
}

Measured memory_bytes: 25332
#include <stdio.h>
#include <string.h>
#define N 1001

int  LCSLength(char *, char *);


char X[N+1],Y[N+1];
int c[N+1][N+1];


int main(){

  int q;
  int i;
  scanf("%d",&q);

  for(i=0;i<q;i++){
    X[0] = ' ';
    Y[0] = ' '; 
    scanf(" %s %s",&X[1],&Y[1]);

    // printf("%s\n%s\n",X,Y);

    
  
       printf("%d\n",LCSLength(X,Y));
  }

 

  return 0;
}

int LCSLength(char *X, char *Y){
  int i,j;
  int m,n;
  m = strlen(X);
  n = strlen(Y);

  for(i=1;i<=m;i++){
    c[i][0] = 0;
      }

  for(j=0;j<=n;j++){
    c[0][j] = 0;
  }

  for(i=1; i<=m ;i++){
    for(j=1; j<=n;j++){
    if(X[i] == Y[j]){
      c[i][j] = c[i-1][j-1]+1;
    }
    else if( c[i-1][j] >= c[i][j-1]){
      c[i][j] = c[i-1][j];
    }
    else c[i][j] = c[i][j-1];
  }
}

  return c[m][n]-1;
}



Measured memory_bytes: 5624
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long X = sc.nextLong();

		int A = 0;
		int B = 0;
		for(int i=0; i<=1000; i++) {
			for(int j=-1000; j<=1000; j++) {
				long ans = (long)Math.pow(i, 5) - (long)Math.pow(j, 5);
				if(ans == X) {
					A = i;
					B = j;
					break;
				}
			}
		}

		System.out.println(A + " " + B);

	}


}


Measured memory_bytes: 38588
import java.util.Scanner;
//???????????´??° W???H???x???y???r 
public class Main {
		static int W = 0;
		static int H = 0;
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		W = sc.nextInt();
		H = sc.nextInt();
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(x <= 0 || y <= 0){
			if(r < 0){
				System.out.println("No");				
			}else if(r == 0){
				System.out.println("Yes");				
			}
			System.out.println("No");
		}else if(x + r <= W  && y + r <= H ){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
		
		sc.close();
	}

}

Measured memory_bytes: 26160
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(void)
{
	int x, y;
	char a = 'a';
	char b = 'b';
	char c = 'c';
	cin >> x >> y;
	switch (x)
	{
	case 1: x = a; break;
	case 3:x = a;
	case 5:x = a;
	case 7:x = a;
	case 8:x = a;
	case 10:x = a;
	case 12:x = a; break;
	case 4:x = b;
	case 6:x = b;
	case 9:x = b;
	case 11:x = b; break;
	case 2:x = c;
	}
	switch (y)
	{
	case 1: y = a; break;
	case 3:y = a; break;
	case 5:y = a; break;
	case 7:y = a; break;
	case 8:y = a; break;
	case 10:y = a; break;
	case 12:y = a; break;
	case 4:y = b; break;
	case 6:y = b; break;
	case 9:y = b; break;
	case 11:y = b; break;
	case 2:y = c; break;
	}
	if (x == y)
	{
		cout << "Yes";
		if (x == c || y == c)
		{
			cout << "No";
		}
	}
	else
	{
		cout << "No";
	}
	return 0;
}

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

using namespace std;


inline int Gcd(int x , int y)
{
    int r;
    while(y)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    int n;
    long long sum = 0;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        for(int j = 1 ; j <= n ; j++)
            for(int k = 1 ; k <= n ; k++)
                sum += Gcd(Gcd(i , j) , k);
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 3632
import math
n = int(input())
p = []
dis = []
for i in range(n):
  x,y = map(int, input().split())
  p.append([x,y])
for i in range(n):
  for j in range(n):
    if i != j:
      dx = p[i][0] - p[j][0]
      dy = p[i][1] - p[j][1]
      dis.append(math.sqrt(dx*dx + dy*dy)/n)
print(round(sum(dis), 10))

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[MAXN];

//string sample[4] = {"erase", "eraser", "dream", "dreamer"};
  string sample[4] = {"esare", "resare", "maerd", "remaerd"};

void solve(){
	scanf("%s", &s[0]);
	int n = strlen(s);
	reverse(s, s + n);
	for(int i = 0; i < n; ){
		int fl0 = -1;
		REP(j, 0, 4){
			int fl = 0;
			REP(k, 0, (int)sample[j].length()){
				if (s[i + k] != sample[j][k]){
					fl = 1;
					break;
				}
			}
			if (!fl){
				fl0 = j;
				break;
			}
		}
		if (fl0 == -1){
			printf("NO\n");
			return;
		}
		i += sample[fl0].length();
	}
	printf("YES\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    if (n == 1)
    {
        cout << "Hello World" << endl;
        return 0;
    }
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main()
{
    int n(0);
    std::cin >> n;
    
    std::vector<long long> mons(n+1, 0);
    for(auto& v : mons){
        std::cin >> v;
    }
    
    long long n_hit(0);
    long long c(0);
    for(int i=0; i < n; ++i){
        std::cin >> n_hit;
        
        const auto& n_mons = mons[i];
        
        c += std::min(n_hit, n_mons);
        if(n_hit > n_mons){
            const auto diff = n_hit - n_mons;
            auto& next_m = mons[i+1];
            c += std::min(diff, next_m);
            next_m = std::max(next_m-diff, 0LL);
        }
    }
    
    std::cout << c << std::endl;
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		long D=sc.nextLong();
		System.out.println(B-A+1 -(B/C-(A-1)/C+B/D-(A-1)/D-B/lcm(C,D)+(A-1)/lcm(C,D)));
	}
	static long gcd(long C,long D){
		long dai=Math.max(C,D);
		long shou=Math.min(C,D);
		long amari=dai%shou;
		while(amari!=0){
			dai=shou;
			shou=amari;
			amari=dai%shou;
		}
		return shou;
	}
	static long lcm(long C,long D){
		return C*D/gcd(C,D);
	}
}




Measured memory_bytes: 35696
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

struct xyz {
    ll x, y, z;
};
vector<int> G[int(1e5)];
vector<bool> seen(int(1e5), false);
ll ans = 0;

void dfs(int idx) {
    seen[idx] = true;
    for (int i = 0; i < G[idx].size(); ++i) {
        if (seen[G[idx][i]])continue;
        dfs(G[idx][i]);
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl(), m = inl();
        vector<xyz> a;
        rep(i, m) {
            xyz tmp;
            tmp.x = inl(), tmp.y = inl(), tmp.z = inl();
            tmp.x--, tmp.y--;
            a.eb(tmp);
            G[tmp.x].eb(tmp.y);
            G[tmp.y].eb(tmp.x);
        }
        for (int i = 0; i < n; ++i) {
            if (seen[i]) continue;
            ans++;
            dfs(i);
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 11184
#include "stdio.h"
#include <stdlib.h>

int main (){
  //  const int size=200000;                                                                                  
  int a, b, c;
  scanf("%d %d",&a, &b);
  if ((a+b)%2==0){
    c = (a+b)/2;
    printf("%d\n",c);
  } else{
    printf("IMPOSSIBLE\n");
  }

  return 0;
}

Measured memory_bytes: 128
// Integral Rectangles
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if ((w | h) == 0)
				break;
			int resw = 150;
			int resh = 150;
			e: for (int i = 1; i <= 150; i++)
				for (int j = i + 1; j <= 150; j++) {
					if (i > resw && j > resw)
						break e;
					if ((w * w + h * h < i * i + j * j || (w * w + h * h == i
							* i + j * j && i > h))
							&& (resw * resw + resh * resh > i * i + j * j || (resw
									* resw + resh * resh == i * i + j * j && resh > i))) {
						resw = j;
						resh = i;
					}
				}
			System.out.println(resh + " " + resw);
		}
		sc.close();
	}
}

Measured memory_bytes: 20364
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <string>

int main() {
  int n, r;
  scanf("%d %d", &n, &r);

  if (n >= 10) {
    printf("%d\n", r);
  } else {
    r += 100 * (10-n);
    printf("%d\n", r);
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  int dist = 0;
  for (int i = 0; i < N; ++i){
    int x;
    cin >> x;
    if (x < K - x){
      dist += x;
    }
    else{
      dist += K - x;
    }
  }
  cout << dist*2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a%b); 
} 
// Use __gcd(int, int) as inbuilt function.
/*int spf[M];
void sieve(int MaxN){
	spf[1] = 1;
	for(int i = 2; i<MaxN; i++){
		spf[i] = i;
	}
	for(int i = 4; i<MaxN; i+=2){
		spf[i] = 2;
	}
	for(int i = 3; i*i <MaxN; i++){
		if(spf[i]==i){
			for(int j = i*i; j<MaxN; j+=i){
				if(spf[j]==j){
					spf[j] = i;
				}
			}
		}
	}
}
vector<int> factorise(int x){
	vector<int> factor;
	while(x!=1){
		factor.push_back(spf[x]);
		x = x / spf[x];
	}
	return factor;
}*/
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p) 
{ 
    long long int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1;  
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p; 
}*/

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
   	string s; cin>>s;
   	for(int i = 0; i<3; i++){
   		if(s[i]=='7'){
   			cout<<"Yes";
   			return 0;
   		}
   	}
   	cout<<"No";
   	return 0;
}


Measured memory_bytes: 3640
n, m = gets.chomp.split(' ').map(&:to_i)

if n - m <= -2 || n - m >= 2
  puts 0
else
  answer = 1
  (1..n).each do |i|
    answer = (answer * i) % 1_000_000_007
  end
  (1..m).each do |i|
    answer = (answer * i) % 1_000_000_007
  end
  if n == m
    answer = (answer * 2) % 1_000_000_007
  end
  puts answer
end

Measured memory_bytes: 1788
// Code by Denverjin.
#include <bits/stdc++.h>
using namespace std;

using ld = double;
using ll = long long;
using ull = unsigned long long;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;

const int SZ = 1 << 13;
char buff[SZ], *pos = buff + SZ - 1;
#define getchar() (++ pos == buff + SZ ? fread(pos = buff, 1, SZ, stdin), *pos : *pos)

inline ll read() {
	ll x = 0; int f = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x<<3) + (x<<1) + (c^48);
	return x * f;
}

const int N = 1 << 24;
int n, D;
int a[N];
ll e[N][3];
int m;
int id[N];

void solve(int l, int r) {
	if (l + 1 >= r) return;
	int md = (l + r) >> 1;
	int mL = l; for (int i = l; i < md; ++ i) if (-1LL * i * D + a[i] < -1LL * mL * D + a[mL]) mL = i;
	int mR = md; for (int i = md; i < r; ++ i) if (1LL * i * D + a[i] < 1LL * mR * D + a[mR]) mR = i;
	for (int i = md; i < r; ++ i) e[m][0] = mL, e[m][1] = i, e[m][2] = 1LL * (i - mL) * D + a[i] + a[mL], id[m] = m ++;
	for (int i = l; i < md; ++ i) e[m][0] = i, e[m][1] = mR, e[m][2] = 1LL * (mR - i) * D + a[i] + a[mR], id[m] = m ++;
	solve(l, md);
	solve(md, r);
}

int par[N];
void init() { for (int i = 0; i < N; ++ i) par[i] = i; }
int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
void merge(int x, int y) { x = find(x), y = find(y); par[x] = y; }
bool same(int x, int y) { return find(x) == find(y); }

int main() {
	init();
	n = read(), D = read();
	for (int i = 0; i < n; ++ i) a[i] = read();
	solve(0, n);
	sort(id, id + m, [&](int a, int b) {
		return e[a][2] < e[b][2];
	});
	ll ans = 0;
	for (int ii = 0; ii < m; ++ ii) {
		int i = id[ii];
		if (!same(e[i][0], e[i][1])) {
			merge(e[i][0], e[i][1]);
			ans += e[i][2];
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 166528
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B ;
    int tasu = A + B ,hiku = A - B ,kakeru = A * B;
    if(tasu>=hiku&&tasu>=kakeru){
        cout << tasu <<endl;
    }else if (hiku>=tasu&&hiku>=kakeru){
        cout << hiku <<endl;
    }else{
        cout << kakeru <<endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    string s;
    cin >> s;
    string ans = "Good";
    FOR(i, 3)if (s[i] == s[i+1])ans = "Bad";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,p[1<<17];
main()
{
	cin>>N;
	int cnt=0;
	for(int i=0;i<N;i++)cin>>p[i];
	for(int i=0;i<N;i++)
	{
		if(p[i]==i+1)
		{
			cnt++;
			swap(p[i],p[i+1]);
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> dp1(n), dp2(n), dp3(n),arr1(n),arr2(n),arr3(n);
    for(int i=0; i<n; i++)
    {
        cin >> arr1[i] >> arr2[i] >> arr3[i];
    }
    dp1[0] = arr1[0];
    dp2[0] = arr2[0];
    dp3[0] = arr3[0];
    for(int i=1; i<n; i++)
    {
        dp1[i] = arr1[i]+max(dp2[i-1],dp3[i-1]);
        dp2[i] = arr2[i]+max(dp1[i-1],dp3[i-1]);
        dp3[i] = arr3[i]+max(dp1[i-1],dp2[i-1]);
    }
    int ans = max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int h,w,k;
   cin>>h>>w>>k;
   char c[h][w];
   char copy[h][w];
   char co[h][w];
   rep(i,h){
      rep(j,w){
         cin>>c[i][j];
         copy[i][j]=c[i][j];
         co[i][j]=c[i][j];
      }
   }
   
   int ans=0;

   for(int bit=0;bit<(1<<h);bit++){
      for(int i=0;i<h;i++){
         if(bit & (1<<i)){
            rep(j,w){
               copy[i][j]='o';
               co[i][j]='o';
            }
         }
      }

      for(int bitt=0;bitt<(1<<w);bitt++){
         for(int i=0;i<w;i++){
            if(bitt & (1<<i)){
               rep(j,h){
                  co[j][i]='o';
               }
            }
         }

         int count=0;
         rep(i,h){
            rep(j,w){
               if(co[i][j]=='#') count++;
               co[i][j]=copy[i][j];
            }
         }
         if(count==k) ans++;
         count=0;
      }

      rep(i,h){
         rep(j,w){
            copy[i][j]=c[i][j];
            co[i][j]=c[i][j];
         }
      }




      
      
   }
   
   cout<<ans;
return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#define NILL -1

typedef struct
{
  int parent;
  int r; //right sibling
  int l; //left  sibling
} TREE;

int sibling(int);
int degree(int);
int depth(int,int);
int height(int);

int n;
int h[30];
TREE t[30];

int main()
{
  int i;
  int n;
  scanf("%d",&n);
  //TREE &point = t;
  
  for(i=0;i < n;i++) t[i].parent = NILL;

  int v;
  for(i=0;i < n;i++){
    scanf("%d",&v);
    scanf("%d%d",&t[v].l,&t[v].r);
    if(t[v].l != NILL) t[t[v].l].parent = v;
    if(t[v].r != NILL) t[t[v].r].parent = v;
  }
  
  for(i=0;i < n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i,t[i].parent,sibling(i),degree(i),depth(i,0),height(i));
    if(t[i].parent == NILL) printf("root\n");
    else if(t[i].l == NILL && t[i].r == NILL) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

int sibling(int i)
{
  if(t[i].parent == NILL) return NILL;//root
  if(t[t[i].parent].r != i && t[t[i].parent].r != NILL) return t[t[i].parent].r;
  if(t[t[i].parent].l != i && t[t[i].parent].l != NILL) return t[t[i].parent].l;
  return -1;
}

int degree(int i)
{
  int cnt=0;
  if(t[i].l != NILL) cnt++;
  if(t[i].r != NILL) cnt++;
  return cnt;
}

int depth(int i, int di)
{
  di = 0;
  while(t[i].parent != NILL){
    i = t[i].parent;
    di++;
  }
  return di;
}

int height(int i)
{
  int h1=0,h2=0;
  if(t[i].r != NILL) h1 = height(t[i].r)+1;
  if(t[i].l != NILL) h2 = height(t[i].l)+1;

  if(h1 > h2) h[i] = h1;
  else h[i] = h2;
  return h[i];
}



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


int main() {
    int n;cin>>n;
    vector<ll> by(0);
    vector<ll> a(n);
    vector<bool> ch(n,true);
    for(ll i=1;i<=20000000000;i*=2) by.push_back(i);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int ans=0;
    
    for(int i=n-1;i>=0;i--){
        if(!ch[i]) continue;
        ll k=a[i];
        ll l=*upper_bound(by.begin(),by.end(),k); 
        ch[i]=false;   
        auto its=lower_bound(a.begin(),a.end(),l-k);
        if(*its==l-k&&ch[its-a.begin()]){
            ans++;
            ch[its-a.begin()]=false;
            a[its-a.begin()]--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
B = []
C = 0
for i in range(N):
  if A[i]//400 < 8:
    B.append(A[i]//400)
  else:
    C += 1
b = set(B)
if len(b) == 0:
  print(1, C)
else:
  print(len(b), len(b)+C)

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

int main(){
    int A,B;cin>>A>>B;
    cout<<max(0,A-B*2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<ll>

#define sz(x) ((int) (x).size())
#define pll pair<long long,long long>
#define mp make_pair
#define F first
#define S second
#define T int tt; cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);
 
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define display(x) for(auto i : x) cout << i << " "; cout << '\n';
#define input(x) for(int i = 0; i < n; i++) cin >> x[i];
#define make(x,y) fill(all(x), y)
#define FO(i,startLoop,n) for (int i = startLoop; i < n; i++)

#define mod 1000000007
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define ITFO(myiterator, mymap) for(auto myiterator = mymap.begin(); myiterator!=mymap.end(); ++myiterator)
using namespace std;  
 

int main()
{
    fastio
    cin.tie(NULL); cout.tie(0);
    
    
  

  string s,t; cin>>s>>t;
  int s1 =sz(s), s2 = sz(t); 
  int dp[s1+1][s2+1];
  FO(i, 0, s1+1) FO(j, 0, s2 + 1) dp[i][j] = 0;

  FO(i, 1, s1 + 1)
  {
    FO(j, 1, s2 + 1)
    {
      // if(i==1 && j == 1) cout<<s[i]<<""
       if(s[i-1] == t[j-1])
       {
          // if(i == 1 && j == 1) cout<<"dc";
         dp[i][j] = 1 + dp[i-1][j-1];
      }
       else   dp[i][j] = max(dp[i][j-1], dp[i-1][j]);

       // cout<<dp[i][j]<<"  ";
    }
    // cout<<endl;
  } 
  // FO(i,0,s1+1) {FO(j,0,s2+1) cout<<dp[i][j]<<"  "; cout<<endl; }
  // cout<<dp[s1][s2];
  int j = s2, i = s1;
  string res = "";
  while(i && j)
  {
    if(dp[i][j] == dp[i][j-1]){
        j--;
    }else if(dp[i][j] == dp[i-1][j]){
      i--;
    }else{
      res+=s[i-1];
      i--, j--;
    }
  }
  reverse(all(res)); cout<<res;
  cerr << "\nTime elapsed: "<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0;
}

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

void main_()
{
    ll a, b, c;
    cin >> a >> b >> c;

    auto d = (c - a - b);
    cout << (d > 0 && (4L * a * b < d * d) ? "Yes" : "No") << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
int A;
int B;
int C;
	cin >> N; 
A=N/100;
B=N/10-10*A;
C=N-(100*A+10*B);
if(A==7||B==7||C==7){
  cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}

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

int main() {
  int n;
  cin >> n;
  bool ans=false;
  rep2(i,1,10){
    rep2(j,1,10){
      if(i*j==n){
        ans=true;
        break;
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b,c,d = list(map(int,input().split()))
e = c*d//gcd(c,d)
ans = (b-a+1)-((b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//e-(a-1)//e))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;	cin>>n;
	vector<int> ls;
	for(int i=0;i<n;i++){
		int a;	cin>>a;
		if(ls.empty())	ls.push_back(a);
		else if(ls[ls.size()-1]<a)	ls.push_back(a);
		else{
			auto it=lower_bound(ls.begin(),ls.end(),a);
			*it=a;
		}
	}
	cout<<ls.size()<<endl;
	return 0;
}

Measured memory_bytes: 3488
n,T = map(int,input().split())
t = list(map(int,input().split()))
sa = [0]
if n == 1:
    print(T)
    exit()
for i in range(n-1):
    if abs(t[i+1] - t[i]) <= T:
        ans = abs(t[i+1] - t[i])
    elif abs(t[i+1] - t[i]) > T:
        ans = T
    sa.append(ans)
sa.append(T)
print(sum(sa))
        
    


Measured memory_bytes: 98000
# n = gets.split.map(&:to_i)
# array = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
str = gets.chomp
n = 1
s = 1
w = 1
e = 1
str.length.times do |i|
  if str[i] == 'S'
    s = 0
  elsif str[i] == 'N'
    n = 0 
  elsif str[i] == 'W'
    w = 0
  elsif str[i] == 'E'
    e = 0
  end
end
if ((s ^ n) | (w ^ e)) == 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;
    map<Int, Int> l, r;
    for (Int i = 1; i <= n; i++) {
        Int in;
        cin >> in;

        l[i + in]++;
        r[i - in]++;
    }

    Int ans = 0;
    for (auto L : l) {
        ans += r[L.first] * L.second;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 37920
import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    N, P, Q = map(int, readline().split())
    *C, = [int(readline()) for i in range(N)]
    A = [0]*N
    su = sum(C)
    for i in range(N):
        A[i] = P*(Q-i) - C[i]
    A.sort(reverse=1)
    ans = su
    for i in range(N):
        su += A[i]
        ans = max(ans, su + P*i*(i+1))
    write("%d\n" % ans)
solve()


Measured memory_bytes: 47432
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


int main() {
	string a, b;
	cin >> a >> b;
	string s = a + b;
	double x = atoi(s.c_str());
	if (sqrt(x) != (int)sqrt(x)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

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



int main(void){
    int N,M,Q;
    scanf("%d%d%d",&N,&M,&Q);
    int po[N+1][N+1];
    for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)po[i][j]=0;
    for(int i=0;i<M;i++){
        int l,r;
        scanf("%d%d",&l,&r);
        po[0][r-1]++;
        po[l][r-1]--;
    }
    for(int i=0;i<=N;i++)for(int j=0;j<N;j++)po[i][j+1]+=po[i][j];
    for(int i=0;i<N;i++)for(int j=0;j<=N;j++)po[i+1][j]+=po[i][j];
    for(int i=0;i<Q;i++){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",po[l-1][r-1]);
    }
    return 0;
}


Measured memory_bytes: 1920
# include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;

  lint i;
  for(i=1;i<=n;i++) {
    if(i*(i+1)/2 >= n) { break; }
  }

  vector<lint> v;
  lint sum=0;
  for(lint j=i;j>=1;j--) {
    if(sum+j > n) { continue; }
    v.push_back(j);
    sum += j;
    if(sum == n) { break; }
  }

  for(lint j=0;j<(int)v.size();j++) { cout << v[j] << endl; }
  return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
char l[100002];
ll dp[100001][2];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	scanf("%s", l);;
	dp[0][0] = 1;
	int len = strlen(l);
	REP(i, len) {

		//既に小さいものの遷移
		if (dp[i][1] != -1) {
			dp[i + 1][1]=(dp[i][1] * 3)%MOD;
		}

		//i桁まで一致の繊維
		if (dp[i][0] != -1) {
			if (l[i]=='1') {
				dp[i + 1][1] = (dp[i+1][1] + dp[i][0])%MOD;
			}
		}

		//少なくともi+1桁までは一致の繊維
		if (dp[i][0] != -1) {
			if (l[i] == '1') dp[i + 1][0] = (dp[i][0]*2)%MOD;
			else dp[i + 1][0] = dp[i][0];
		}
		//printf("%lld %lld\n", dp[i + 1][0], dp[i+1][1]);
	}

	PRINTL((dp[len][0]+dp[len][1])%MOD);
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  int res = max({a + b, a - b, a * b});
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans=0;
    int min=1e5*2+1;
    for(int i=0; i<N; i++) {
        int p;
        cin >> p;
        if(min>p) {
            min = p;
            ans++;
        }
    }
    
    cout << ans << endl;



    return 0;
    
}

Measured memory_bytes: 256
# ITP1_5_D
# 構造化プログラミング

n = int(input())
for i in range(1, n+1):
	x = i
	if x % 3 == 0:
		print(" " + str(i), end = "")
	else:
		while x:
			if x % 10 == 3:
				print(" " + str(i), end = "")
				break
			x //= 10
print()



Measured memory_bytes: 5872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GCD_on_Blackboard
{
    class Program
    {
        static int GCD(int a, int b)
        {
            if (a == 0)
            {
                return b;
            }
            if (b == 0)
            {
                return a;
            }
            var large = a > b ? a : b;
            var small = a > b ? b : a;
            int remain = large % small;

            if (remain == 0)
            {
                return small;
            }
            return GCD(remain, small);

        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] L = new int[n + 1];
            int[] R = new int[n + 1];
            int[] C = new int[n];
            L[0] = 0;
            R[n] = 0;
            for (int i = 0; i < n; i++)
            {
                L[i + 1] = GCD(L[i], A[i]);
                R[n - i - 1] = GCD(R[n - i], A[n - i - 1]);
            }
            for (int i = 0; i < n; i++)
            {
                C[i] = GCD(L[i], R[i + 1]);
            }

            Console.WriteLine(C.Max());
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 29404
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


int main(void)
{
    IOS
    int n;
    cin >> n;
    vector<int> v(n);
    map<int,int> mp;
    REP(i,n) {
        cin >> v[i];
        mp[v[i]]++;
    }
    sort(RALL(v));
    ll ans = 0;

    REP(i,n) {
        if (mp[v[i]] <= 0) continue; 
        double l2 = log2(v[i]);
        if (l2 == floor(l2)) {
            //cerr << "p" << endl;
            if (mp[v[i]] >= 2) {
                ans++;
                mp[v[i]]--;
            }
        } else {
            l2 = ceil(l2);
            int p = pow(2,l2);
            if (mp[p-v[i]] > 0) {
                //cerr << v[i] <<" "<< p << " " <<p-v[i]<<" "<< mp[p-v[i]] << endl;
                ans++;
                mp[p-v[i]]--;
            }
        }
        mp[v[i]]--;
    }


    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 19840
#include<iostream>
#include<set>

using namespace std;

int main() {
  int n;
  set<string> registered;
  cin>>n;
  for(int i=0; i<n; i++) {
    string str;
    cin>>str;
    registered.insert(str);
    //cout<<str<<endl;
  }
  string state = "closed";
  int m;
  cin>>m;
  for(int i=0; i<m; i++) {
    string str;
    cin>>str;
    set<string>::iterator itr;
    itr = registered.find(str);
    if(itr != registered.end()) {
      if(state == "closed") {
	cout<<"Opened by "<<str<<endl;;
	state = "opened";
      }
      else {
	cout<<"Closed by "<<str<<endl;
	state = "closed";
      }
    }
    else {
      cout<<"Unknown "<<str<<endl;
    }
  }
}

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

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

#define MOD 1000000007

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
#define MAXN 2000000

ll fac[MAXN+1]; 

void precomFac(ll p){
	fac[0] = 1; 
	for (int i=1 ; i<=MAXN; i++) 
	    fac[i] = fac[i-1]*i%p; 	
}

// Returns nCr % p using Fermat's little 
// theorem. 
ll nCrModPFermat(ll n,ll r,ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

int main(){
	
	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    precomFac(MOD);

    ll k;
    cin>>k;

    string s;
    cin>>s;

    ll ogl = s.length();
    ll nl = s.length() + k;

    ll ans=0;

    for(ll j=0;j<=nl-ogl;j++){
    	ll temp;
    	temp=nCrModPFermat(nl,j+ogl,MOD);
    	temp*=power(25ll,nl-j-ogl,MOD);
    	temp%=MOD;
    	ans+=temp;
    	ans%=MOD;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 19896
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	putStrLn $ which "Yes" "No" $ n `mod` s n == 0

s = sum . map digitToInt . show

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

typedef long long ll;

vector<int> ch[100005];
int col[100005];
int n, m;

bool impossible()
{
	bool had = false;
	for (int i = 0;i < n;i++) if (ch[i].size() >= 2)
	{
		if (had) return false;
		had = true;
	}
	return true;
}

bool dfs(int at)
{
	for (int u: ch[at])
	{
		int c = !col[at];
		if (col[u] == 2)
		{
			col[u] = c;
			if (!dfs(u)) return false;
		} else if (col[u] != c)
			return false;
	}
	return true;
}

bool bipartite()
{
	for (int i = 0;i < n;i++) col[i] = 2;
	col[0] = 0;
	return dfs(0);
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0;i < m;i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		--a, --b;
		ch[a].push_back(b);
		ch[b].push_back(a);
	}
	if (impossible()) printf("0\n");
	else if (!bipartite()) printf("%lld\n", 1ll*n*(n-1)/2-m);
	else
	{
		ll a = 0, b = 0;
		for (int i = 0;i < n;i++) (col[i]?a:b)++;
		printf("%lld\n", a*b-m);
	}
	return 0;
}


Measured memory_bytes: 6400
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X, K, D = mapint()
if abs(X)>=K*D:
    print(abs(abs(X)-K*D))
else:
    l, r = 0, K
    X = abs(X)
    while r-l>1:
        half = (r+l)//2
        if half*D>X:
            r = half
        else:
            l = half
    now = X-l*D
    if (K-l)%2==0:
        print(now)
    else:
        print(D-now)

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	int ans = 0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == '1'){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;

}

Measured memory_bytes: 3748