akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

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

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

// TODO: 単一始点最短経路（ダイクストラ法）
// O(ElogV)
struct edge { I to, cost; };
vector<edge> GA[100010];
vector<edge> GB[100010];

// 始点sから各頂点への最短経路を求める
V dijkstra(auto G, I s){
  V d(100010);
  priority_queue<P, vector<P>, greater<P>> que;
  //fill(d, d+V, MAX);
  REP(i,100010){
    d[i] = MAX;
  }
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    I v = p.second;
    if (d[v] < p.first) continue;
    REP(i,G[v].size()){
      edge e = G[v][i];
      if (d[e.to] < 0 || d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  return d;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;t--;
  REP(i,m){
    I u,v,a,b;
    cin >> u >> v >> a >> b;
    u--;v--;
    edge e;
    e.to = v;
    e.cost = a;
    GA[u].push_back(e);
    e.to = u;
    GA[v].push_back(e);
    e.cost = b;
    GB[v].push_back(e);
    e.to = v;
    GB[u].push_back(e);
  }
  V d1 = dijkstra(GA, s);
  V d2 = dijkstra(GB, t);
  V d3(n);
  REP(i,n){
    d3[i] = d1[i] + d2[i];
  }
  for (I i=n-2;i>=0;i--){
    //d3[i] = min(d3[i], d3[i+1]);
    chmin(d3[i], d3[i+1]);
  }
  REP(i,n){
    cout << I(1e15) - d3[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 19200
/*...Bismillahir Rahmanir Rahim...*/
#include <bits/stdc++.h>
using namespace std;

#define  ff         first
#define  ss         second
#define  ll         long long
#define  i64        __int64
#define  pb         push_back
#define  pii        pair<int, int>
#define  all()      v.begin(),v.end()
#define  debug(x)   cerr << x << '\n'
#define  mset(a,v)  memset(a,v,sizeof(a));
#define  fast_io    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define  file_in    freopen("input.txt", "r", stdin);
#define  file_out   freopen("output.txt", "w", stdout);
#define  t_casout1  int n=1;while (n--) solve();
#define  t_casout   int n;cin>>n;while (n--) solve();
#define  t_casein   int n;cin>>n;while (n--)
#define  pi         acos(-1)
#define  nl         '\n' 

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int c=0,cc=0;
    for (int i = 0; i < 2; ++i)
    {
        if (a[i] != a[i+1]){
            c=1;
        }
        else cc=1;
    }
    if (c && cc) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();
        System.out.println(Math.PI*R*2);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 27176
#include <stdio.h>

int main(void)
{
	int n;
	long res;
	int i;
	
	scanf("%d", &n);
	res = 1;
	for (i = 1; i <= n; i++){
		res *= i;
	}
	
	printf("%ld\n", res);
	
	return (0);
}

Measured memory_bytes: 592
n = gets.chomp!.to_i
#ns = Array.new
is = gets.split.map(&:to_i)
count = 0
is.each_with_index do |value, key|
  #print(count, key, value, "\n")
  if value != key+1
    count += 1
  end
end

if count == 2 || count == 0
  print("YES\n")
else
  print("NO\n")
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N, i; std::cin >> N >> i;
  std::cout << N-i+1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
N, S = map(int,input().split())
A = [int(s) for s in input().split()]
DP = [[0 for j in range(S + 1)] for i in range(N + 1)]
mod = 998244353
DP[0][0] = 1

for i in range(N):
  for j in range(S + 1):
    DP[i + 1][j] += 2 * DP[i][j]
    DP[i + 1][j] %= mod
    if j + A[i] <= S:
      DP[i + 1][j + A[i]] += DP[i][j]
      DP[i + 1][j + A[i]] %= mod

print(DP[N][S])

Measured memory_bytes: 147816
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



void solve(){
    ll N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    REP(i,M){
        int a, b;
        cin >> a >> b;
        G[--a].emplace_back(--b);
        G[b].emplace_back(a);
    }
    vector<int> color(N, -1);
    auto dfs = [&](auto self, int v, int cur=0) -> bool{
        color[v] = cur;
        for(auto nv:G[v]){
            if(color[nv]!=-1){
                if(color[nv]==cur) return false;
                continue;
            }
            if(!self(self, nv,1-cur)) return false;
        }
        return true;
    };
    bool bipartite = true;
    ll cnt = 0;
    REP(v,N){
        if(color[v]!=-1) continue;
        if(!dfs(dfs, v)) bipartite = false;
    }
    if(!bipartite){
        cout << N * (N - 1) / 2 - M << endl;
        return;
    }
    REP(i,N) if(color[i]) cnt++;
    cout << cnt * (N - cnt) - M << endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

const int INF = 2e9+5;

/*
    filippos
    AtCoder Regular Contest 84
    Task : B
    Given integer K, find the smallest digit sum of a multiple of k
    Solved using dijkstra
*/


int main(){
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

    int k; cin >> k;

    // smallest sum for each remainder
    vi sum(k, INF);

    // we visit all remainders in order of increasing sums
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({0, 0});

    int ans = -1;

    while(!pq.empty()){
    	pii curr = pq.top(); pq.pop();
    	// if we found a solution
    	if(curr.second == 0 && curr.first != 0){
    		ans = curr.first;
    		break;
    	}
    	// skip useless entries
    	if(sum[curr.second] < curr.first) continue;
    	// try to add all digits
    	for(int digit = 0; digit <= 9; digit++){
    		// skip leading zeroes
    		if(digit == 0 && curr.first == 0) continue;
    		// check if sum is too big
    		int next_rem = (curr.second * 10 + digit) % k;
    		int next_sum = curr.first + digit;
    		// skip if can't improve
    		if(sum[next_rem] <= next_sum) continue;
    		sum[next_rem] = next_sum;
    		pq.push({next_sum, next_rem});
    	}
    }

    // print the smallest sum found
    cout << ans;


    return cout << '\n', 0;
}

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

int main() {
  
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++)
    cin >> x.at(i);
  
  int res = 10000000;
  for (int i = 1; i < 101; i++){
    int dis = 0;
    for (int j = 0; j < n; j++){
      int dj = pow(x.at(j) - i, 2);
      dis += dj;
    }
    res = min(res, dis);
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	HashMap<Integer, Character> map = new HashMap<Integer, Character>();
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ1218().doIt();
	}
	
	class AOJ1218{
		int w,h;
		int[][] map;
		int sx,sy,px,py,gx,gy;
		int[] ax = {1,0,-1,0};
		int[] ay = {0,1,0,-1};
		void doIt(){
			while(in.hasNext()){
				w = in.nextInt();
				h = in.nextInt();
				if(w+h==0)break;
				map = new int[h][w];
				for(int i=0;i<h;i++)for(int s=0;s<w;s++){
					map[i][s] = in.nextInt();
					if(map[i][s]==2){
						sx = s;sy = i;
					}else if(map[i][s]==3) {
						gx = s;gy = i;
					}else if(map[i][s]==4){
						px = s;py = i;
					}
				}
//				System.out.println("Person is = "+px+" "+py);
				solve();
			}
		}
		
		void solve(){
			PriorityQueue<State> q = new PriorityQueue<State>();
			q.add(new State(sx, sy, 0, px, py));
			int result = -1;
			int[][][] memo = new int[h][w][4];
			for(int i=0;i<h;i++)for(int s=0;s<w;s++)Arrays.fill(memo[i][s], Integer.MAX_VALUE/2);
			while(q.size()>0){
//				System.out.println();
				State now = q.remove();
//				System.out.println("x = "+now.x+" y = "+now.y+" px = "+now.px+" py = "+now.py);
				if(now.x==gx&&now.y==gy){
					result = now.cost;
					break;
				}
				for(int i=0;i<4;i++){
					int nx = ax[i]+now.x;
					int ny = ay[i]+now.y;
//					System.out.println("nx = "+nx+" ny = "+ny);
					if(nx<0||nx>=w||ny<0||ny>=h||map[ny][nx]==1||!canGo(now.px, now.py, now.x, now.y, now.x+ax[(i+2)%4], now.y+ay[(i+2)%4]))continue;
//					System.out.println(memo[ny][nx][i]);
					if(memo[ny][nx][i]>now.cost+1){
//						System.out.println("******");
						memo[ny][nx][i] = now.cost+1;
						q.add(new State(nx, ny, now.cost+1, now.x+ax[(i+2)%4], now.y+ay[(i+2)%4]));
					}
				}
			}
			System.out.println(result);
		}
		
		boolean canGo(int fromx,int fromy,int cx,int cy,int tox,int toy){
			PriorityQueue<State> q = new PriorityQueue<State>();
			q.add(new State(fromx, fromy,0,0,0));
			int[][] memo = new int[h][w];
			for(int i=0;i<h;i++)Arrays.fill(memo[i], Integer.MAX_VALUE/2);
			while(q.size()>0){
				State now = q.remove();
				if(now.x == tox && now.y == toy)return true;
				for(int i=0;i<4;i++){
					int nx = now.x+ax[i];
					int ny = now.y+ay[i];
					if(nx<0||nx>=w||ny<0||ny>=h||map[ny][nx]==1||(nx==cx&&ny==cy))continue;
					if(memo[ny][nx]<now.cost+1)continue;
					q.add(new State(nx, ny, now.cost+1,0,0));
					memo[ny][nx] = now.cost+1;
				}
			}
//			System.out.println();
//			for(int i=0;i<h;i++){
//				for(int s=0;s<w;s++)System.out.print(memo[i][s]+" ");
//				System.out.println();
//			}
			return false;
		}
		
		class State implements Comparable<State>{
			int x,y,cost,px,py;
			public State(int x,int y,int cost,int px,int py){
				this.x = x;
				this.y = y;
				this.cost = cost;
				this.px = px;
				this.py = py;
			}
			public int compareTo(State o) {
				return this.cost-o.cost;
			}
		}
	}
}

Measured memory_bytes: 26104
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 250;
int main()
{
    std::ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    int cnt = 0;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'R'){
            cnt++;
        }
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> Vi;
typedef pair<int,int> Pii;
typedef pair<int,Pii> Pip; 
const int INF = (1<<30);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  string s;
  cin >> s;

  int n;
  cin >> n;

  int cnt = 0;
  for(int i=0; i<n; i++) {
    string ss;
    cin >> ss;
    ss += ss;
    for(int j=0; j<ss.size() - s.size(); j++) {
      string tmp = "";
      for(int k=j; k<(j+s.size()); k++) {
	tmp += ss[k];
      }
      if( tmp == s ) {
	cnt++;
	j = ss.size();
      }
    }
  }

  cout << cnt << endl;
}

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

#define LENGTH 12
#define N 1000000

struct node {
    char str[LENGTH + 1];
    struct node* next;
};

struct node *hash[N];

int getChar(char ch) {
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else return 4;
}

long long hash_fnc(char *str){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum % N;
}

int h1(int key){ return key % N; }
int h2(int key){ return 1 + (key % (N - 1)); }

void insert(char *s) {
    long long key = hash_fnc(s);
    struct node* p;
    if (hash[key] == NULL) {
        hash[key] = (struct node*)malloc(sizeof(struct node));
        strcpy(hash[key] -> str, s);
        hash[key] -> next = NULL;
    } else {
        for (p = hash[key]; p -> next != NULL; p = p -> next) {
            if (!strcmp(p -> str, s)) return;
        }
        p -> next  = (struct node*)malloc(sizeof(struct node));
        strcpy(p -> next -> str, s);
        p -> next -> next = NULL;
    }
}

int find(char *s) {
    long long key = hash_fnc(s);
    struct node *p;
    if (hash[key] == NULL) {
        return 0;
    } else {
        for (p = hash[key]; p != NULL; p = p -> next) {
            if (!strcmp(p -> str, s)) {
                return 1;
            }
        }
    }
    return 0;
}

int main() {
    int i, n;
    char s[LENGTH + 1], command[7];
    
    for (i=0; i < N; i++) {
        hash[i] = NULL;
    }
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s %s", command, s);
        if (!strcmp(command, "insert")) insert(s);
        else if(find(s)) {
            printf("yes\n");
        } else {
            printf("no\n");   
        }
    }
    
    return 0;
}



Measured memory_bytes: 20272
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  string a, b; cin >> a >> b;
  int num = stoi(a+b);
  int i=(int)sqrt(num);
  printf("%s\n", i == sqrt(num) ? "Yes":"No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 305, MOD = 1e9 + 7;
const double C = 1;

int n;
double dp[N][N][N];
bool F[N][N][N];

double go (int a, int b, int c){
    if (a < 0)
        return 0;
    if (b < 0)
        return 0;
    if (c < 0)
        return 0;
    if (F[a][b][c])
        return dp[a][b][c];
    F[a][b][c] = 1;
    double x = a, y = b, z = c, t = a + b + c;
    if (a)
    dp[a][b][c] += (x / t) * (go (a - 1, b, c) + C);
    if (b)
    dp[a][b][c] += (y / t) * (go (a + 1, b - 1, c) + C);
    if (c)
    dp[a][b][c] += (z / t) * (go (a, b + 1, c - 1) + C);
    double p = n;
    dp[a][b][c] += p / t - 1;
    return dp[a][b][c];
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin>>x;
        if (x == 1)
            a++;
        else if (x == 2)
            b++;
        else
            c++;
    }
    F[0][0][0] = 1;
    go (a, b, c);
    printf ("%.10f\n", dp[a][b][c]);
    return 0;
}


Measured memory_bytes: 246016
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N,K;
	cin >> N >> K;
	string S;
	cin >> S;
	S[K-1] = S[K - 1] - 'A' + 'a';
	cout << S << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

using namespace std;

#define pii pair<int,int> 
#define F first 
#define S second 
#define int long long
#define mpr make_pair
typedef long long ll;

const int maxn = 210;
const int mod = 1e9+7;
const ll inf = 1e18+10;

bool good[maxn];
bool is(vector<int> s, int x)
{
    memset(good, 0, sizeof good);
    ll res = 0;
    for(int i = 61; i >= 0; i--)
        {
            int id = -1;
            for(int j = 0; j < s.size(); j++)
                if((s[j] & (1ll<<i)) && !good[j])
                    id = j;
            
            bool XX = ((1ll<<i) & x);
            bool YY = ((1ll<<i) & res);
            if((XX^YY) && id != -1) (res ^= s[id]);
            
            good[id] = 1; 
            for(int j = 0; j < s.size(); j++)
                if(id != j && ((1ll<<i) & s[j]))
                    s[j] ^= s[id];
        }
    if(res == x) return 1;
    else return 0;
}

int a[maxn];
signed main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);


  //  cout<< is({7,6,5}, 3) <<" ";
    int q; cin>> q;
    while(q--)
    {
        int n; cin>> n;
        for(int i = 0; i < n; i++) cin>> a[i];
        string s; cin>> s;

        vector<int> ve;
        bool ans = 0;
      //  cout<<"\n";
        for(int i = n-1; i >= 0; i--)
        {
            if(s[i] == '0') ve.push_back(a[i]);
            else
                if(!is(ve,a[i]))
                {
             //       cout<< i <<" ";
                    ans = 1;
                    break;
                }
        }
        cout<< ans <<"\n";
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long M = 1e9+7;
int dp[100001][2];
long long solve1(vector<vector<int>>&Adj, int i,int p){
	//if(p) then iske upr wala black hua hai; else nii
	if(dp[i][p]!=-1) return dp[i][p];
	long long y=1;
	for(int v:Adj[i]) y=(y*solve1(Adj,v,0))%M;
	if(p){
		//i has to be white;
		dp[i][p]=y;
		return y;
	}
	long long x=1; 
	//if i white then y 
	//if i is black then x
	for(int v:Adj[i]) x=(x*solve1(Adj,v,1))%M;
	dp[i][p]=(x+y)%M;
	return dp[i][p];
}

void solve(){
	int n,m,x,y,p,q;
	cin>>n;
	vector<vector<int>>A(n,vector<int>());
	for(int i=1;i<n;i++){
		cin>>x>>y;
		A[x-1].push_back(y-1);
		A[y-1].push_back(x-1);
	}
	vector<vector<int>>Adj(n,vector<int>());
	vector<bool>V(n);
	queue<int>Q;
	Q.push(0);
	V[0]=1;
	while(!Q.empty()){
		int u=Q.front();
		Q.pop();
		for(int v:A[u]){
			if(V[v]) continue;
			V[v]=1;
			Q.push(v);
			Adj[u].push_back(v);
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve1(Adj,0,0);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 21872
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final int MOD = 2019;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i=0; i < n; i++) {
            a[i] = in.nextInt();
        }

        for (int i=0; i < n-1; i++) {
            if (i % 2 == 0) {
                a[n-1] -= a[i];
            } else {
                a[n-1] += a[i];
            }
        } // Row N = (0, 0, ... , 1)

        for (int i=0; i < n-1; i++) {
            a[i] *= 2;
        }

        for (int i=n-2; i >= 0; i--) {
            a[i] -= a[i+1];
        }

        StringBuilder o = new StringBuilder();
        for (int ans : a) {
            o.append(ans).append(" ");
        }
        out.println(o.substring(0, o.length()-1));
    }
}


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

int main(){
  while(1){
  int e,min=100000000,ans;
 cin>>e;
 if(e==0) break;
 for(int i=0;i*i*i<=e;i++){
   for(int j=0;j*j<=e;j++){
     ans=e-(i*i*i+j*j);
     if(min>ans+j+i && e>=ans && ans>=0) min=ans+i+j;
   }
 }
 cout<<min<<endl;
  }
 return 0;
}

  

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int n;
int a[MAXX];
int b[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    for(int i = 0; i < n + 1; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
            int k = min(b[i] , a[i]);
            b[i] = b[i] - k;
            a[i] = a[i] - k;
            ans = ans + k;
            k = min(b[i] , a[i + 1]);
            b[i] = b[i] - k;
            a[i + 1] = a[i + 1] - k;
            ans = ans + k;
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

using namespace std;

int a[4];

int x,y,z;

int main() {
	scanf("%d%d%d",&x,&y,&z);
	
	x = x*100+y*10+z;
	
	x%4==0? puts("YES"): puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#define int long long
using namespace std;
const int N=2e5+5,MOD=1e9+7;
int n,m,ans;
int bin[N],inv[N];

inline int pow(int a,int n)
{
	int res=1ll;
	while (n)
	{
		if (n&1ll) res=res*a%MOD;
		n>>=1ll;
		a=a*a%MOD;
	}
	return res;
}

inline int C(int x,int y)
{
	return bin[x]%MOD*inv[x-y]%MOD*inv[y]%MOD;
}

signed main(){
	scanf("%lld%lld",&n,&m);
	bin[0]=1; inv[0]=1;
	for (register int i=1; i<=n; ++i) bin[i]=bin[i-1]*i%MOD;
	for (register int i=1; i<=n; ++i) inv[i]=pow(bin[i],MOD-2ll)%MOD;
	ans=1;
	for (register int i=1; i<n; ++i) 
	if (n-i<=m) ans=(ans+C(n,i)*C(n-1,i-1)%MOD+MOD)%MOD;
	printf("%lld\n",ans);
return 0;	
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n;
string a, b;
 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	cin >> n;
	cin >> a >> b;
	forn(i, a.size()) {
		cout << a[i];
		cout << b[i];
	}
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	ll n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	ll idx = 0;
	if (n%2==0) {
		ll prev = 1;
		for (int i = 0; i < n; i+=2) {
			idx++;
//			cout << a[i+1] << " " << a[i] << "\n";
			if(a[i+1]!=a[i]||a[i]!=prev){
				cout << 0 << "\n";
				return 0;
			}
			prev = a[i]+2;
		}

	} else {
		ll prev = 2;
		if (a[0]!=0) {
			cout << 0 << "\n";
			return 0;
		}
		for (int i = 1; i < n; i+=2) {
			idx++;
			if(a[i+1]!=a[i]||a[i]!=prev){
				cout << 0 << "\n";
				return 0;
			}
			prev=a[i]+2;
		}
	}
	ll ret=1;

	for (int i = 0; i < idx; i++) {
		ret = ret*2%MOD;
	}
	cout << ret << endl;

}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    int n;
    int[] a;

    Main(int n, int[] a) {
        this.n = n;
        this.a = a;
    }

    /**
     * 
     * @return greeting message
     */
    public int[] solve() {

        ArrayList<Pair> plist = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            plist.add(new Pair(i, a[i - 1]));
        }

        Collections.sort(plist);

        int[] ans = new int[n];

        for (int i = 0; i < n; i++) {
            ans[i] = plist.get(i).num;
        }

        return ans;
    }

    class Pair implements Comparable<Pair> {

        int num;
        int ord;

        Pair(int num, int ord) {
            this.num = num;
            this.ord = ord;
        }

        @Override
        public int compareTo(Pair other) {
            return Integer.compare(this.ord, other.ord);
        }
    }

    public static void main(String[] args) {

        // input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        // solve
        int[] p = new Main(n, a).solve();

        // display
        for (int pi : p) {
            System.out.print(pi + " ");
        }
        System.out.println();
    }

}


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

int main () {
  vector<int> line(6) ;
  vector<int> nul(5) ;
  for(int i = 0 ; i<6 ; i++ ) cin >> line[i] ;
  for(int i = 0 ; i < 6 ; i++) {
    nul[line[i]-1] ++ ;
  }
  int pre = 0 ;
  for(int i = 0 ; i < 4 ;i++){
    if(nul[i]== 2) pre ++ ;
  }
  if(pre==2) cout << "YES" << endl ;
  else cout << "NO" << endl ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using LL = long long;

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

    int A[N + 1], B[N];
    for (int i = 0; i < N + 1; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    LL ans = 0;

    for (int i = 0; i < N; i++) {
        ans += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        ans += min(A[i + 1], B[i]);
        A[i + 1] -= min(A[i + 1], B[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(){
	auto v = vector<int>(istream_iterator<int>(cin),istream_iterator<int>());

	int _min = 256;
	int _second = 0;
	int num = 0;
  	bool flag = false;
	for(auto i:v){
      
      if(i%10==0){
			_second +=i;
		}else{
			if(_min > (i%10)){
              	if(flag)
					_second += num + 10 - _min;
                 flag = true;
				_min = i%10;
				num = i;
			}else{
				_second += i + 10 - (i %10);
			}
		}
	}

	_second += num;
	cout <<_second;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(void){
  int n;
  scanf("%d", &n);
  int a[n];
  int i, j;
  int pos=0;
  int sum=0;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    sum += abs(pos-a[i]);
    pos = a[i];
  }
  sum += abs(pos);
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n", sum-abs(a[n-2]-a[n-1])-abs(a[n-1])+abs(a[n-2]));
    }else if(i==0){
      printf("%d\n", sum-abs(a[0])-abs(a[0]-a[1])+abs(a[1]));
  	}else{
        printf("%d\n", sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
    }
  }
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <iomanip>
//#include <cmath>
#include <queue>
#include <deque>
#include <stack>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long double ld;
typedef long long ll;
typedef double db;
#define endl '\n'
#define pb push_back
#define pii pair<ll, ll>
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define optimize1() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma warning(disable:4996)

using namespace std;

const ll MX = 2e5 + 10, INF = 1e9 + 1;
ll n, m, t, d[MX], l[MX], r[MX], a[MX];
bool used[MX];
vector<vector<int>> g;

bool dfs(int v) {
	used[v] = true;
	bool f = true;
	for (auto c : g[v]) {
		int tmp = a[v], pos = l[c] + r[c] - v;
		if (l[c] == v)
			tmp += d[c];
		else
			tmp -= d[c];
		if (used[pos])
			f = f && (a[pos] == tmp);
		else {
			a[pos] = tmp;
			f = f && dfs(pos);
		}
	}
	return f;
}

signed main() {
	optimize1();
	cin >> n >> m;
	g.resize(n + 1);
	for (int i = 0; i < m; ++i) {
		cin >> l[i] >> r[i] >> d[i];
		g[l[i]].pb(i);
		g[r[i]].pb(i);
	}
	for (int i = 1; i <= n; ++i) {
		if (used[i])
			continue;
		a[i] = 0;
		if (!dfs(i)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  n%=10;
  if(n==3) {
    cout << "bon" << endl;
  }
  else if(n==0||n==1||n==6||n==8) {
    cout << "pon" << endl;
  }
  else cout << "hon" << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 3000 + 10 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n;
ld dp[maxn][maxn] , a[maxn] , sum;

int32_t main() {
    FAST
    cin >> n;
    cout << setprecision(10);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] = 1 - a[i];
    }

    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i][j] += a[i - 1] * dp[i - 1][j];
            if(j)
                dp[i][j] += (1 - a[i - 1]) * dp[i - 1][j - 1];
        }
    }

    // cout << dp[3][2] << ' ' << dp[3][3] << endl;
    for (int j = (n / 2) + 1; j <= n; ++j) {
        sum += dp[n][j];
    }

    cout << fixed << sum << '\n';
 }


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

const long long MOD = 1000000007;

vector<pair<ll, ll>> div_cnt(ll N)
{
    vector<pair<ll, ll>> prime;
    for (long long A = 2; A * A <= N; A++)
    {
        if (N % A != 0)
            continue;
        ll exp = 0;
        while (N % A == 0)
        {
            exp++;
            N = N / A;
        }
        prime.push_back({A, exp});
    }

    if (N != 1)
    {
        prime.push_back({N, 1});
    }

    return prime;
}

void solve(long long N)
{
    cout << fixed << setprecision(10);
    //素数の数識別
    map<int,ll> num;
    for(long long i=1; i<=N; i++)
    {
        for(auto u : div_cnt(i)) //{{a1,e1},{a2,e2},{a3,e3},{..}}
            num[u.first] += u.second; //u.first,整数
    }
    
    ll cnt=1;
    
    for(auto s : num)
    {
        //(s.second+1)%MODは×
        cnt = (cnt * (s.second+1)) % MOD;
        //cnt *= (s.second + 1); 
        //cnt %= MOD;
    }

    cout << cnt << endl;

    /*long long cnt = 1;
    for (long long  i = N; i > 0; i--)
    {
        const auto &prime = div_cnt(i);
        for (auto s : prime)
        {
            cnt = (cnt * (s.second + 1)%MOD) %MOD;
        }
    }

    cout << cnt << endl;
    //vector<pair<ll, ll>> prime = div_cnt(Factorial_N);
    */

    /*
    long long Factorial_N = 1;
    long long cnt = 1;
    for (long long  i = N; i > 0; i--)
    {
        Factorial_N *= i;
    }
    //vector<pair<ll, ll>> prime = div_cnt(Factorial_N);

    const auto &prime = div_cnt(Factorial_N);
    for (auto s : prime)
    {
        cnt *= (s.second + 1);
        cnt %= MOD;
        //    cnt++;
        //個数は(e1+1)(e2+1)…(eK+1)個
    }
    cout << cnt << endl;*/
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "math"
)

func main() {
  var n int
  fmt.Scan(&n)
  A := make([]int, 5)
  min := math.MaxInt64
  for i := 0; i < 5; i++ {
    fmt.Scan(&A[i])
    if A[i] < min {
      min = A[i]
    }
  }
  fmt.Println((n+min-1)/min + 4)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,dp[200005][55],p[N],k,t,ans;
struct zh
{
	int a,b;
}a[N];
bool cmp(zh a,zh b){return 1ll*(a.b+1)*b.a<1ll*(b.b+1)*a.a;}
int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].a,&a[i].b);
		if(a[i].a==0)
		{
			p[++k]=a[i].b;
			i--;
			n--;
		}
	}
	sort(a+1,a+n+1,cmp);
	for(int j=1;j<=50;j++)
		dp[0][j]=t+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=50;j++)
			dp[i][j]=min(1ll*dp[i-1][j],dp[i-1][j-1]+1+1ll*(dp[i-1][j-1]+1)*a[i].a+a[i].b);
	sort(p+1,p+k+1);
	for(int i=0;i<=30;i++)
	{
		if(dp[n][i]<=t)
		{
			long long s=0;
			int j;
			for(j=1;j<=k;j++)
			{
				s+=p[j]+1;
				if(dp[n][i]+s>t)
					break;
			}
			ans=max(ans,j-1+i);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 45056
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> x(n);
	ll sum = 0,ans=10000000000;
	rep(i, n) {
		cin >> x[i];
		sum += x[i];
	}
	ll b = 0;
	rep(i, n - 1) {
		b += x[i];
		ans = min(ans, abs(2*b-sum));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i,j,n,*r,max,min;
  scanf("%d",&n);
  r=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&r[i]);
  
  min=r[0];
  max=r[1]-r[0];
  for(i=1;i<n;i++)
    if(max<r[i]-r[0])
    max=r[i]-r[0];
  
  for(i=1;i<n-1;i++){
    if(r[i]<min){
      min=r[i];
      for(j=i+1;j<n;j++){
	if(max<r[j]-r[i])
	max=r[j]-r[i];
      }
    }
  }

  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b,x,y;
    cin>>n>>a>>b;
    if((b-a)%2 == 0)
        cout<<(b-a)/2;
    else
    {
        x = a + (b-a-1)/2;
        y = (n-b)+1 + (n-(a+n-b+1))/2;
        cout<<min(x,y);
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a,b,ans;
	cin >> a >> b;
	ans = b;
	REP(i, a - 1) ans *= b - 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n;
int a[120000];
int gcdd(int a,int b)
{
    return (a%b==0)?b:gcdd(b,a%b);
}

int main()
{
    cin>>n;
    int ans=0;
    for (int i=0; i<n; ++i)
    {
        scanf("%d",&a[i]);
        ans=(i==0)?a[0]:gcdd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

void solve(){
	string s;
	cin>>s;
	
	bool a = s[0] == 'R';
	bool b = s[1] == 'R';
	bool c = s[2] == 'R';
	
	if(a && b && c){
		cout<<3<<endl;
	}
	else if((a && b ) || (b && c)){
		cout<<2<<endl;
	}
	else if(a || b || c)
		{
			cout<<1<<endl;
		}
	else{
			cout<<0<<endl;
		}
	
	
	}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	
	
	}	
	


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	
	ll a,b,c;cin >> a >> b >> c;
	a = (b - ((a+c-1)/c)*c + 1);
	cout << (a+c-1)/c << endl;
	return 0;
}

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

using namespace std;

int main()
{
  	int n1,n2;
  	cin >> n1 >> n2;
  	//cout << n1 << " " << n2 << endl;
  	for(int i=1;i<=100000;i++)
    {
      	double p1 = i*(0.08) , p2 = i*(0.1);
      	int k11 = ceil(p1), k12 = floor(p1) , k21 = ceil(p2) , k22 = floor(p2);
      	int k1f , k2f;
      	if(abs(k11-p2)<abs(k12-p2))
          	k1f = k11;
     	else
          	k1f = k12;
      	
        if(abs(k11-p2)<abs(k12-p2))
            k2f = k21;
      	else
        	k2f = k22;
      	if(k12==n1 && k22==n2)
        {
          	cout << i << endl;
          	return 0;
        }
    }
  	cout << -1 << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main()
{
 
    double w, h, x, y;
 
    cin >> w >> h >> x >> y;
 
    if(x == w/2 && y == h/2) cout << w*h/2 << ' ' << 1 << endl;
 
    else cout << w*h/2 << ' ' << 0 << endl;
 
	return 0;
 
}

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

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

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    set<lint> st(a.begin(), a.end());
    cout << (st.size() == n ? "YES" : "NO") << endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vvll d(h, vll(w, INFL));
    bool updated = true;
    typedef tuple<ll, ll, ll> tup;
    deque<tup> que;
    que.push_front(make_tuple(ch, cw, 0));
    d[ch][cw] = 0;
    while(!que.empty()) {
        ll ci, cj, cd;
        tie(ci, cj, cd) = que.front();
        que.pop_front();
        if(d[ci][cj] < cd) continue;
        for(int di = -2; di <= 2; ++di) {
            for(int dj = -2; dj <= 2; ++dj) {
                if(di == 0 && dj == 0) continue;
                ll ni = ci + di;
                ll nj = cj + dj;
                if(ni < 0 || ni >= h) continue;
                if(nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                ll dd = abs(di) + abs(dj) - 1;
                if(dd > 1) dd = 1;
                if(d[ni][nj] <= cd + dd) continue;
                d[ni][nj] = cd + dd;
                tup t = make_tuple(ni, nj, cd + dd);
                if(dd == 0) que.push_front(t);
                else que.push_back(t);
            }
        }
    }
    if(d[dh][dw] == INFL) d[dh][dw] = -1;
    cout << d[dh][dw] << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 12892
#include <iostream>

int main()
{
	int a[3], max, k;
	std::cin >> a[0] >> a[1] >> a[2];
	std:: cin >> k;
	for(int i = 1; i <= k; i++)
	{
		if(a[1] < a[0] && a[2] < a[0])
		{
			a[0] = a[0] * 2;
		}else if(a[0] < a[1] && a[2] < a[1]){
			a[1] = a[1] * 2;
		}else{
			a[2] = a[2] * 2;
		}
	}
	for(int i = 0; i < 3; i++)
	{
		max += a[i]; 
	}
	std::cout << max << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string S;
  cin>>S;
  S[3]='8';
  cout<<S;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll dp[405][405];
ll dp1[405][405];
ll N,C;
int main(){
  cin>>N>>C;
  vector<ll>A(N);vector<ll>B(N);
  for(int i=0;i<N;i++)
    cin>>A[i];
  for(int i=0;i<N;i++)
    cin>>B[i];
  for(int i=0;i<=404;i++){
    dp[i][0]=1;dp1[i][0]=1;
  }ll x=1;
  for(int i=1;i<=N;i++){
    for(ll k=A[i-1];k<=B[i-1];k++)
      for(int j=1;j<=C;j++)
        if(j!=1)
      dp1[k][j]=(dp[i-1][j]+(dp1[k][j-1]*k))%mod;
    else
      dp1[k][j]=(dp[i-1][j]+(dp[k][j-1]*((k*x)%mod)))%mod;
      for(int j=1;j<=C;j++){
      ll a=0;
        for(ll k=A[i-1];k<=B[i-1];k++)
          a=(a+dp1[k][j])%mod;
        dp[i][j]=a;
      }x=(x*(B[i-1]-A[i-1]+1))%mod;
  }
  cout<<dp[N][C]<<endl;
  return 0;
}

Measured memory_bytes: 6196
import sys

nlist = list(map(int, input().split()))

if nlist[0] == nlist[1] and nlist[1] == nlist[2] and nlist[0] == nlist[2]:
  print('No')
  sys.exit()

if nlist[0] == nlist[1] or nlist[1] == nlist[2] or nlist[0] == nlist[2]:
  print('Yes')
  sys.exit()
  
print('No')

Measured memory_bytes: 3060