akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::cmp;
use std::collections::BTreeMap;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let n_k = read_t_in_line::<i32>();
    let (n, k) = (n_k[0], n_k[1]);
    let aa = read_t_in_line::<i32>();
    let mut set : BTreeMap<i32, i32> = BTreeMap::new();
    for a in aa {
        if let None = set.get_mut(&a) {
            set.insert(a, 0);
        }
        *set.get_mut(&a).unwrap() += 1;
    }

    let mut seq = vec![];

    // 種類の小さい順番に並べる
    for (_, v) in set.iter() {
        seq.push(*v)
    }

    seq.sort();

    let mut sz = set.len() as i32;
    let mut res = 0;
    for s in seq {
        if sz <= k {
            break;
        }
        res += s;
        sz -= 1;
    }
    println!("{}", res);
}


Measured memory_bytes: 14532
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var tmp = line[0].split(" ");
	var lower = tmp[0];
	var upper = tmp[1];

	var ans = 0;
	if(lower.length <= 14 && upper.length <= 14){
		lower = Number(lower);
		upper = Number(upper);
		while(lower <= upper){
			lower = lower * 2;
			ans++;
		}
	} else{
		lower = "0000000000" + lower;
		upper = "0000000000" + upper;
		var lowerTop = lower.slice(0,-10);
		var lowerBottom = lower.slice(-10);
		var upperTop = upper.slice(0,-10);
		var upperBottom = upper.slice(-10);
		lower = [Number(lowerTop), Number(lowerBottom)];
		upper = [Number(upperTop), Number(upperBottom)];

		var compare = function(lower, upper){
			if(lower[0] < upper[0]){
				return true;
			} else if(lower[0] === upper[0] && lower[1] <= upper[1]){
				return true;
			} else{
				return false;
			}
		}

		while(compare(lower, upper)){
			var tmp = (lower[1]*2).toString();
			if(tmp.length === 11){
				lower = [lower[0]*2 + 1, Number(tmp.slice(-10))];
			} else{
				lower = [lower[0]*2, Number(tmp)];
			}
			ans++;
		}
	}
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include <iostream>
using namespace std;
#define int long long
int findXOR(int n)
{
    int mod = n % 4;
    if (mod == 0)
        return n;
    else if (mod == 1)
        return 1;
    else if (mod == 2)
        return n + 1;
    else if (mod == 3)
        return 0;
}
int findXOR(int l, int r)
{
    return (findXOR(l - 1) ^ findXOR(r));
}

signed main() 
{
	int a,b;cin>>a>>b;
	if (a==b){cout<<a;return 0;}
	if (a==0)a=1;
	cout<<findXOR(a,b);
	return 0;
}

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n,k;
  cin >> n >> k;
  ll val[n];
  REP(i,n) cin >> val[i];

  ll ans = 0;
  for (int l = 0; l <= n; l++) {
    for (int r = 0; n - l - r >= 0; r++) {
      if (l+r > k) continue;
      int left = k - l - r;
      ll tmp = 0;

      priority_queue<ll,vector<ll>,greater<ll>> pq;
      for (int i = 0; i < l; i++) {
        if (val[i] >= 0) tmp += val[i];
        else {
          pq.push(val[i]);
          tmp += val[i];
        }
      }
      for (int i = 0; i < r; i++) {
        if (val[n-1-i] >= 0) tmp += val[n-1-i];
        else {
          pq.push(val[n-1-i]);
          tmp += val[n-1-i];
        }
      }

      while (!pq.empty() && left > 0) {
        tmp -= pq.top();
        pq.pop();
        left--;
      }

      ans = max(ans, tmp);

    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){
  int case_num = 1;
  // while (1) if (solve()) break;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int MAXN = 1e6 + 5;
int n, A, B;
int dp[105][105][105];
int rek(int atA, int atB, int turn){
    if(dp[atA][atB][turn] != -1){
        return dp[atA][atB][turn];
    }
    int ret;
    if(turn == 0){
        if((atA + 1 >= n || atA + 1 == atB) && (atA - 1 < 0 || atA - 1 == atB))return INF;
        ret = INF;
        if(atA + 1 < n && atA + 1 != atB){
            ret = min(ret, rek(atA + 1, atB, 1 - turn));
        }
        else if(atA - 1 >= 0){
            ret = min(ret, rek(atA - 1, atB, 1 - turn));
        }
    
    }
    else{
        if((atB + 1 >= n || atB + 1 == atA) && (atB - 1 < 0 || atB - 1 == atA))return -INF;
        ret = -INF;
        if(atB - 1 >= 0 && atB - 1 != atA){
            ret = max(ret, rek(atA, atB - 1, 1 - turn));
        }
        else if(atB + 1 < n){
            ret = max(ret, rek(atA, atB + 1, 1 - turn));
        }
    
    }
    return dp[atA][atB][turn] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n >> A >> B;
    memset(dp, -1, sizeof dp);
    A --;
    B --;
    if(rek(A, B, 0) == -INF)cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}


Measured memory_bytes: 4736
#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=5e18;

const ll N=1e5+10;
ll n,u,v;
vector<set<ll>> G(N);
vec du(N,-1);
vec dv(N,-1);

int main() {
  cin >> n >> u >> v;
  u--,v--;
  for(ll i=0;i<n-1;i++) {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    G[a].insert(b);
    G[b].insert(a);
  }
  priority_queue<pll,vector<pll>,greater<pll>> q;
  q.push({0,u});
  while(q.size()) {
    ll d=q.top().first;
    ll f=q.top().second;
    q.pop();
    if(du[f]>-1) continue;
    du[f]=d;
    for(ll t:G[f]) {
      if(du[t]==-1) {
        q.push({d+1,t});
      }
    }
  }
  q.push({0,v});
  while(q.size()) {
    ll d=q.top().first;
    ll f=q.top().second;
    q.pop();
    if(dv[f]>-1) continue;
    dv[f]=d;
    for(ll t:G[f]) {
      if(dv[t]==-1) {
        q.push({d+1,t});
      }
    }
  }
  ll id=u;
  for(ll i=0;i<n;i++) {
    if(dv[i]>du[i]&&dv[i]>dv[id]) {
      id=i;
    }
  }
  ll ans=dv[id]-1;
  cout << ans << endl;
}

Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>//sort
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>//pair
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  long long N, K, count = 0;
  cin >> N >> K;
  long long H[N];
  rep(i, N)cin >> H[i];

  if(N <= K){
    cout << 0 << endl;
    return 0;
  }

  sort(H, H + N);

  rep(i, N - K){
    count += H[i];
  }

  cout << count << endl;
}


Measured memory_bytes: 1792
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner scan = new Scanner(System.in);
      	int c = scan.nextInt();
      	int r = scan.nextInt();
      if(c>=10)
      { 
        System.out.println(r);
      	return;
      }
      	int res = r+100*(10-c);
      	System.out.println(res);
    }
  
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

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

	float total = 0;
	for(int i=0;i<N;i++){
		float a;
		cin >> a;
		total += (1.0 / a);
	}

	cout << 1.0 / total << endl;

}






Measured memory_bytes: 3728
#include <iostream>
#include <cmath>


int main () {
    int n;
    std::cin >> n;
    int h[n][3], dp[n+1][3];

    for (int i = 0; i < n; ++i) {
        for(int j = 0; j < 3; ++j){
            std::cin >> h[i][j];
            dp[i][j] = -1000000000;
        }
    }

    dp[n][0] = 0;
    dp[n][1] = 0;
    dp[n][2] = 0;

    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <3; ++j){
            for(int k = 0; k < 3; ++k) {
                if (j == k) continue;
                if (dp[i+1][k] < dp[i][j] + h[i][k]) {
                    dp[i+1][k] = dp[i][j] + h[i][k];
                }
            }
        }
    }

    int ans = dp[n][0];

    for(int i=1; i<3; ++i){
        if(ans < dp[n][i]) {
            ans = dp[n][i];
        }
    }

    std::cout << ans << std::endl;

}

Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int A[505][505];
int ans[505*505][4];

int main(){
  int H,W; cin>>H>>W;
  int sum=0;
  rep(i,H) rep(j,W){
    cin>>A[i][j];
    (sum+=A[i][j])%2;
  }
  int cnt=0;
  rep(i,H-1) rep(j,W) if(A[i][j]%2){
    A[i+1][j]++;
    ans[cnt][0]=i+1;
    ans[cnt][1]=j+1;
    ans[cnt][2]=i+2;
    ans[cnt][3]=j+1;
    cnt++;
  }
  rep(j,W-1) if(A[H-1][j]%2){
    A[H-1][j+1]++;
    ans[cnt][0]=H;
    ans[cnt][1]=j+1;
    ans[cnt][2]=H;
    ans[cnt][3]=j+2;
    cnt++;
  }
  cout<<cnt<<endl;
  rep(i,cnt){
    rep(j,3) cout<<ans[i][j]<<" ";
    cout<<ans[i][3]<<endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());
    int area=v[0]*v[1];
    cout<<area/2<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;

Graph G;
int dp[MAX_N];

int dfs(int v) {

    if(dp[v] != -1) {
        return dp[v];
    }

    int cnt = 0;
    for(auto u : G[v]) {
        cnt = max(cnt, dfs(u) + 1);
    }

    dp[v] = cnt;

    return dp[v];
}

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

    G.assign(n, vector<int>());

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;  y--;
        G[x].push_back(y);
    }

    rep(v, n) {
        dp[v] = -1;
    }

    int ans = 0;
    rep(v, n) {
        ans = max(ans, dfs(v));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int t[10][10];
int n,m;
//int a[204][204];
int ans=0;
int main() {
	scanf("%d%d",&n,&m);
	for (int i=0;i<10;++i)
		for (int j=0;j<10;++j)
			scanf("%d",&t[i][j]);
	for (int k=0;k<10;++k)
		for (int i=0;i<10;++i)
			for (int j=0;j<10;++j)
				t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) {
			int x;
			scanf("%d",&x);
			if (~x&&x^1) ans+=t[x][1];
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int[][] arr;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		 arr = new int[h][w];
		//white == 0, black == 1
		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();
			switch(a) {
			case 1:
				paint(0, h, 0, x);
				break;
			case 2:
				paint(0, h, x, w);
				break;
			case 3:
				paint(0, y, 0, w);
				break;
			case 4:
				paint(y, h, 0, w);
				break;
			}
		}
		int result = 0;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(arr[i][j] == 0) result ++;
			}
		}
		System.out.println(result);
	}

	private static void paint(int ys, int ye, int xs, int xe) {
		for(int i = ys; i < ye; i++) {
			for(int j = xs; j < xe; j++) {
				arr[i][j] = 1;
			}
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;

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

    map<int,int> mp;
    vector<int> A;
    int a;
    for(int i=0;i<N;i++){
        scanf("%d", &a);
        if(mp.find(a) == mp.end()) A.push_back(a);
        mp[a]++;
    }
    int ans = 0;
    for(auto a : A){
        if(mp[a] < a) ans += mp[a];
        else if(mp[a] > a) ans += mp[a] - a;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 5112
#include <stdio.h>

int main(void)
{
	int x, y, gcd, tmp;

	scanf("%d %d", &x, &y);
	
	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}

	while (y > 0) {
		tmp = x % y;
		x = y;
		y = tmp;
	}
	gcd = x;
	printf("%d\n", gcd);

	return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a<=c&&c<=b) pr("Yes");
  else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

def xor(L):
    a = 0
    for l in L: a ^= l
    return a

def chk(L1, L2, k):
    L1.sort()
    L2.sort()
    s, j = 0, 0
    for i in range(N)[::-1]:
        while j < N and L1[i] + L2[j] < k:
            j += 1
        s += N - j
    return s % 2 * k

t = (xor(A) ^ xor(B)) * (N % 2)
for i in range(28):
    m = 1 << i+1
    t ^= chk([a%m for a in A], [b%m for b in B], m)

print(t)

Measured memory_bytes: 137216
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    long long int all = 0;
    int ai;
    for (int i = 0; i < m; i++)
    {
        cin >> ai;
        all += ai;
    }
    if (all <= n)
    {
        cout << n - all << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
n=int(input())
arr=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
	if(arr[i-1]>arr[i]>arr[i+1]):
		ans+=1
	elif(arr[i-1]<arr[i]<arr[i+1]):
		ans+=1
print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> dan = new ArrayList<>();
    int N = sc.nextInt();
    int d[] = new int[N];
    
    
    for(int i=0; i<N; i++){
      d[i]=sc.nextInt();
      if(!dan.contains(d[i])){
        dan.add(d[i]);
      }
    }
    
    System.out.println(dan.size());
  }
}
    

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int h,w;
int res;
int crtnum;
int num[22][22];

void dfs(int i,int j){
  if(i==h){
    bool ok=true;
    rep(a,h-1){
      rep(b,w-1){
        vector<int> tmp;
        tmp.push_back(num[a][b]); tmp.push_back(num[a][b+1]); tmp.push_back(num[a+1][b]); tmp.push_back(num[a+1][b+1]);
        sort(all(tmp)); uni(tmp);
        if(tmp.size()==4){
          ok=false;
          break;
        }
      }
      if(!ok)break;
    }
    if(ok)res++;
    return ;
  }
  int ni,nj;
  if(j==w-1){
    ni=i+1; nj=0;
  }else{
    ni=i; nj=j+1;
  }

  if(j+1<w&&num[i][j]==-1&&num[i][j+1]==-1){
    num[i][j]=num[i][j+1]=crtnum++;

    bool ok=true;
    for(int ci=max(0,i-1);ci<=min(h-1,i);ci++){
      for(int cj=max(0,j-1);cj<=min(w-1,j+1);cj++){
        vector<int> tmp;
        tmp.push_back(num[ci][cj]); tmp.push_back(num[ci][cj+1]); tmp.push_back(num[ci+1][cj]); tmp.push_back(num[ci+1][cj+1]);
        sort(all(tmp)); uni(tmp);
        if(tmp[0]!=-1&&tmp.size()==4){
          ok=false;
          break;
        }
      }
      if(!ok)break;
    }

    if(ok)dfs(ni,nj);
    num[i][j]=num[i][j+1]=-1;
    crtnum--;
  }
  if(i+1<h&&num[i][j]==-1&&num[i+1][j]==-1){
    num[i][j]=num[i+1][j]=crtnum++;
    
    bool ok=true;
    for(int ci=max(0,i-1);ci<=min(h-1,i+1);ci++){
      for(int cj=max(0,j-1);cj<=min(w-1,j);cj++){
        vector<int> tmp;
        tmp.push_back(num[ci][cj]); tmp.push_back(num[ci][cj+1]); tmp.push_back(num[ci+1][cj]); tmp.push_back(num[ci+1][cj+1]);
        sort(all(tmp)); uni(tmp);
        if(tmp[0]!=-1&&tmp.size()==4){
          ok=false;
          break;
        }
      }
      if(!ok)break;
    }

    if(ok)dfs(ni,nj);

    num[i][j]=num[i+1][j]=-1;
    crtnum--;
  }
  if(num[i][j]!=-1){
    dfs(ni,nj);
  }
}

int main(){
  while(1){
    cin>>h>>w;
    if(h==0)break;
    crtnum=0; res=0;
    memset(num,-1,sizeof(num));
    dfs(0,0);
    cout<<res<<endl;
  }
  return 0;
}



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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int mx = A.at(0) + (K - A.at(N - 1));
  for (int i = 1; i < N; i++) {
    mx = max(mx, A.at(i) - A.at(i - 1));
  }
  cout << K - mx << "\n";
}

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

#define MAX_N 8
int graph[MAX_N][MAX_N];


int dfs(int idx,int n,bool visited[MAX_N]){
	

	bool all_visited=true;
	for(int i=0;i<n;i++){
		if(!visited[i]) all_visited=false;
	}
	if(all_visited){
		return 1;
	}
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(!graph[idx][i])continue;
		if(visited[i])continue;
		visited[i] = true;
		int a = dfs(i,n,visited);
		cnt += a;
		visited[i]=false;
	}
	return cnt;
}


int main() {
    int n,m;
	cin >> n >> m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) graph[i][j]=false;
	}
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >>b;
		a--;b--;
		graph[a][b]=true;
		graph[b][a]=true;
	}
	bool visited[MAX_N];
	for(int i=1;i<n;i++){
		visited[i]=false;
	}
	visited[0]=true;
	int ret = dfs(0,n,visited);
	
	cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;

ll factorial(ll n)
{
    ll f = 1;

    while(n) {
        f = f * n;
        f = f%IMOD;
        n--;
    }
    return f;
}

int main() 
{
    ll n, m;
    cin >> n >> m;
    
    if(abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    } else {
        ll ans = factorial(n);
        ans = ans % IMOD;
        ans = ans * factorial(m);
        ans = ans % IMOD;
        if(n == m) {
            cout << ans * 2 % IMOD<< endl; 
        } else {
            cout << ans << endl; 
        }
    }

    return 0;
}


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

int main(void){
    
  string s;
  cin >> s;
  int len = s.size();
  int N = s.size() / 2;
  int ans = 0;
  
  for(int i=0;i<N;i++){
      if(s[i] != s[len-i-1]) ans++;
  }
  cout << ans << endl;
  
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec1(N), vec2(N);
  for (int i = 0; i < N; i++) {
    cin >> vec1.at(i);
  }
  
  for (int i = N - 1 ; i >= 0; i--) {
    int j = i + 1;
    int multiple_i_sum = 0;
    while(j <= N){
      multiple_i_sum +=  vec2.at(j-1);
      j += i + 1 ;
    }
    vec2.at(i) = ( multiple_i_sum + vec1.at(i) ) % 2;    
  }
  
  int M = 0;
  for (int i = 0; i < N; i++){
    M += vec2.at(i); 
  }
  cout << M << endl;
  
  for (int i = 0; i < N; i++){
    if(vec2.at(i) == 1){
      cout << i+1 << ' ';
    }
  }
  
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
cs int base = 233;
cs int ff = 2e6+1;
cs int mod = 998244353;
cs int inf = 1e17+1;
char s[ff];
int a[ff], ans;
void init()
{
	cin >> s;
	int len = strlen(s);
	int tail = 0;
	queue<int> q;
	//rep(i, 0, len) a[i] = inf;
	if( s[0] == '<' ) a[0] = 0, q.push(0);
	if( s[len-1] == '>' ) a[len] = 0, q.push(len);
	rep(i, 0, len-1)
		if(s[i] == '>' && s[i+1] == '<' )
			a[i+1] = 0, q.push(i+1);
	while(!q.empty())
	{
		int u = q.front(); q.pop();
		rep(i, u+1, len)
			if( a[i-1] + 1 <= a[i] || s[i-1] == '>' ) break;
			else a[i] = a[i-1] + 1;
		drep(i, u-1, 0)
			if( a[i+1] + 1 <= a[i] || s[i] == '<' ) break;
			else a[i] = a[i+1] + 1;
	}
	rep(i, 0, len) ans += a[i];
	cout << ans;
}
signed main()
{
	int T = 1;
	while(T--) 
		init();
} 

Measured memory_bytes: 7424
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
X = Counter()
for i in range(0, N):
    X[A[i]] += 1
width = 0
height = 0
for x, y in sorted(X.most_common(), reverse=True):
    if y >= 2:
        if y >= 4:
            width = max(width, x)
            height = max(height, x)
            break
        if width != 0:
            height = x
            break
        else:
            width = x
print(height*width)


Measured memory_bytes: 22052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second
using ll = long long;
using P = pair<ll ,ll>;
using Tu = tuple<ll, ll, ll>;
const ll INFLL = 1LL<<60LL;
const ll INF = 1LL<<60LL;
const ll MOD = 1e9+7;
using ld = long double;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

int main(){
  ll M, D;
  cin >> M >> D;
  ll ans = 0;
  for(int m=1;m<=M;m++)
    for(int d=1;d<=D;d++){
      ll a = d % 10;
      ll b = d / 10;
      if(a < 2 || b < 2)
	continue;
      if(a * b == m)
	ans++;
    }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define pii pair<int,int>
#define vi vector<int>
#define vit vector<int>::iterator it
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)(v.size())
#define si set<int>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int inf=0x7f7f7f7f;
const int N=2e5+10;
ll a[N],t[N];
ll n;
vi v;
int main() {
    cin>>n;
    for(ll i=1;i<=n;i++) {
        cin>>a[i];
        if(!t[a[i]]) v.pb(a[i]);
        t[a[i]]++;
    }
    ll s=0;
    for(ll i=0;i<sz(v);i++) {
        s+=t[v[i]]*(t[v[i]]-1)/2;
    }
    for(ll i=1;i<=n;i++) {
        ll ans=s;
        ans-=t[a[i]]*(t[a[i]]-1)/2;
        t[a[i]]--;
        ans+=t[a[i]]*(t[a[i]]-1)/2;
        t[a[i]]++;
        cout<<ans<<endl;
        // cout<<i<<endl;
    }
    return 0;
}   

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

int main(){
    while(1){
        int n,sum,data[1000],cnt = 0;
        cin >> n;
        if (n == 0) break;
        for(int i = 0;i<1000;i++){
            data[i] = i + 1;
        }

        for(int j = 0;j < 1000;j++){
            sum = data[j];
            for(int k = j+1;k < 1000;k++){
                sum += data[k];
                if(sum == n){
                cnt += 1;
                break;
                }else if (sum > n){
                    break;
                }
            }   
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	gcd(b, a%b);
}

int main() {
	ll a, b;
	ll ans;
	cin >> a >> b;
	if (a < b) {
		swap(a, b);
	}
	ans = gcd(a,b);
	ans = a * b / ans;
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
int n,i;
long long l[100]={2,1};
int main ()
{
	scanf ("%d",&n);
	for (i=2;i<=n;i++) l[i]=l[i-1]+l[i-2];
	printf ("%lld\n",l[n]);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
#define MOD 1000000007
#define N 100009
int main() {
	int n, W;
	cin >> n >> W;

	ll* wA = new ll[n];
	ll* vA = new ll[n] ;

	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;

		wA[i] = x;
		vA[i] = y;
	}


	ll** arr = new ll* [n + 1];
	for (int i = 0; i <= n; i++) {
		ll* temp = new ll[W + 1];
		arr[i] = temp;

	}

	for (int i = 0; i <= W; i++) {
		arr[0][i] = 0;
	}
	for (int i = 0; i <= n; i++) {
		arr[i][0] = 0;
	}


	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= W; j++) {

			if (wA[i - 1] <= j) {
				arr[i][j] = max(vA[i - 1] + arr[i - 1][j - wA[i - 1]], arr[i - 1][j]);
			}
			else {
				arr[i][j] = arr[i - 1][j];
			}

	 }


		
	}
	cout << arr[n][W] << endl;
}

Measured memory_bytes: 79488
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct graph{
	struct edge{
		int s,t,nxt;
	}e[105];
	int last[55],e_cnt;
	void ins(int a,int b){
		e[e_cnt]=(edge){a,b,last[a]};
		last[a]=e_cnt++;
	}
	void clr(){
		memset(last,-1,sizeof(last));
		e_cnt=0;
	}
	bool vis[55],inst[55];
	int fa[55];
	void dfs(int x){
		for(int i=last[x];i!=-1;i=e[i].nxt)if(e[i].t!=fa[x]&&!vis[e[i].t]){
			fa[e[i].t]=x;
			dfs(e[i].t);
		}
	}
	bool chk(int x){
		if(inst[x])return false;
		if(vis[x])return true;
		vis[x]=1;
		inst[x]=1;
		for(int i=last[x];i!=-1;i=e[i].nxt)if(!chk(e[i].t))return false;
		inst[x]=0;
		return true;
	}
}A,B,C;
#define v(x) (A.fa[x]==B.fa[x])
int main(){
	// freopen("a.in","r",stdin);
	int T;
	scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		A.clr();
		for(int i=1;i<n;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			A.ins(u,v);
			A.ins(v,u);
		}
		B.clr();
		for(int i=1;i<n;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			B.ins(u,v);
			B.ins(v,u);
		}
		int ans=1e9;
		for(int i=1;i<=n;i++){
			memset(A.fa,0,sizeof(A.fa));
			memset(B.fa,0,sizeof(B.fa));
			memset(A.vis,0,sizeof(A.vis));
			A.fa[i]=B.fa[i]=0;
			A.dfs(i); B.dfs(i);
			bool ok=1;
			int res=n-1;
			C.clr();
			for(int j=1;j<=n;j++)if(j!=i){
				if(v(j)){
					res--;
					if(!v(A.fa[j]))ok=0;
				}
				else{
					if(!v(A.fa[j]))C.ins(A.fa[j],j);
					if(!v(B.fa[j]))C.ins(j,B.fa[j]);
				}
			}
			if(!ok)continue;
			for(int j=1;j<=n;j++){
				memset(C.vis,0,sizeof(C.vis));
				memset(C.inst,0,sizeof(C.inst));
				if(!C.chk(j)){ok=0; break;}
			}
			if(ok)ans=min(ans,res);
		}
		if(ans<n)printf("%d\n",ans);
		else{
			for(int i=1;i<=n;i++)if(A.e[A.last[i]].nxt==-1)
				for(int t=1;t<=n;t++)if(t!=i){
					memset(A.vis,0,sizeof(A.vis));
					memset(A.fa,0,sizeof(A.fa));
					memset(B.fa,0,sizeof(B.fa));
					A.vis[i]=1;
					A.fa[i]=B.fa[i]=0;
					A.fa[t]=i;
					A.dfs(t); B.dfs(i);
					bool ok=1;
					int res=n-1;
					C.clr();
					for(int j=1;j<=n;j++)if(j!=i){
						if(v(j)){
							res--;
							if(!v(A.fa[j]))ok=0;
						}
						else{
							if(!v(A.fa[j]))C.ins(A.fa[j],j);
							if(!v(B.fa[j]))C.ins(j,B.fa[j]);
						}
					}
					if(!ok)continue;
					for(int j=1;j<=n;j++){
						memset(C.vis,0,sizeof(C.vis));
						memset(C.inst,0,sizeof(C.inst));
						if(!C.chk(j)){ok=0; break;}
					}
					if(ok)ans=min(ans,res+1);				
				}
			if(ans<=n)printf("%d\n",ans);
			else puts("-1");
		}
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

count = 1
state = 0  # 0 : 列の先頭、 1: 非減少, 2: 非増加

for i, item in enumerate(a):
    
    if i < len(a) -1:
        if a[i] < a[i+1]:
            if state == 0:
                state = 1
            elif state == 2:
                state = 0
                count += 1
        elif a[i] > a[i+1]:
            if state == 0:
                state = 2
            elif state == 1:
                state = 0
                count += 1

print(count)

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

int H, W;

int main(){
  
  cin >> H >> W;
  vector<vector <int> > board(H, vector<int> (W, 0) );
  vector<string> move;
  
  for(int i = 0; i < H ; i++){
    for(int j = 0; j < W; j++){
      cin >> board[i][j];
    }
  }
  
  int act = 0;
  for(int i = 0; i < H ; i++){
    for(int j = 0; j < W; j++){
      if(board[i][j] % 2 == 1) {
        ostringstream ss;
        if(j < W - 1) {
          board[i][j + 1]++;
          ss << i+1 << ' ' << j+1 << ' ' << i+1 << ' ' << j+2 << flush;
          move.push_back(ss.str());
          ss.str("");
          act++;
        }
        else if(i < H - 1) {
          board[i + 1][j]++;
          ss << i+1 << ' ' << j+1 << ' ' << i+2 << ' ' << j+1 << flush;
          move.push_back(ss.str());
          ss.str("");
          act++;
        }
      }
    }
  }

  cout << act << endl;
  for(int i = 0; i < move.size(); i++){
    cout << move[i] << endl;
  }
}

Measured memory_bytes: 9972
#C - Sum of gcd of Tuples (Easy)
K = int(input())
DP =[]
ans = 0
import math
# from functools import reduce
# def gcd(*numbers):
#     return reduce(math.gcd, numbers)


# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

for i in range(1, K + 1):
    for j in range(1, K + 1):
        a = math.gcd(i,j)
        for k in range(1,K+1):
            b = math.gcd(a,k)
            ans += b

print(ans)

Measured memory_bytes: 9188
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
// namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
using namespace std;

const ll SIZE = 3010;
ll dp[SIZE][SIZE][2];

int main() {
    ll N, T;
    cin >> N >> T;
    for(ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        for(ll j = 0; j < SIZE; j++) for(ll k = 0; k <= 1; k++) dp[i + 1][j][k] = dp[i][j][k];
        for(ll pre = 0; pre < T; pre++) for(ll used = 0; used <= 1; used++) {
            ll nxt = pre + a;

            if(!used) chmax(dp[i + 1][pre][1], dp[i][pre][0] + b);
            if(T <= nxt) {
                if(!used) chmax(dp[i + 1][SIZE - 1][1], dp[i][pre][used] + b);
            } else {
                chmax(dp[i + 1][nxt][used], dp[i][pre][used] + b);
            }
        }
    }

    ll ans = 0;
    for(ll i = 0; i < SIZE; i++) chmax(ans, dp[N][i][0], dp[N][i][1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 141568
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;




int main(){
ios::sync_with_stdio(false);
  int n; cin >> n;
  set<string> s;
  for(int i=0; i<n; i++){
    string s1,s2;
    cin >> s1 >> s2;
    if(s1[0] == 'i') s.insert(s2);
    else{
      if(s.find(s2) == s.end()) printf("no\n");
      else printf("yes\n");
    }
  }

}

Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C,K;cin>>A>>B>>C>>K;
  if(K<A)cout<<K<<endl;
  else if(K<A+B)cout<<A<<endl;
  else cout<<A-(K-A-B)<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int dp[1111111],d[22][111111];

int main(void){
	int n,m,i,j,a,p;
	cin >> n >> m;
	fill(d[0],d[22],0);
	fill(dp,dp+1111111,INF);
	for(i=0; i<n; ++i){
		cin >> a; --a;
		++d[a][i+1];
		for(j=0; j<m; ++j){
			d[j][i+1] += d[j][i];
		}
	}
	dp[0] = 0;
	for(i=0; i<(1<<m); ++i){
		p = 0;
		for(j=0; j<m; ++j){
			if(i&(1<<j)){
				p += d[j][n];
			}
		}
		for(j=0; j<m; ++j){
			if(i&(1<<j)){
				continue;
			}
			a = d[j][n];
			dp[i+(1<<j)] = min(dp[i+(1<<j)],dp[i]+d[j][n]-(d[j][a+p]-d[j][p]));
		}
	}
	cout << dp[(1<<m)-1] << endl;
	return 0;
}



Measured memory_bytes: 16936
#include <iostream>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

int x[5];
int main() {
	rep(i, 0, 5) cin >> x[i];
	rep(i, 0, 5) if(x[i] == 0) cout << i+1 << endl;
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char s[3]; cin >> s;
    sort(s, s + 3);
    //cout << s << endl;
    if (string(s) == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const ll MOD = 1e9+7;
const int MAX_N = 2050;

int n, m;
int s[MAX_N];
int t[MAX_N];
ll dp[MAX_N][MAX_N];
ll sum[MAX_N][MAX_N];

int main(void) {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("in.txt", "r", stdin);

	cin >> n >> m;
	rep(i,0,n) {
		cin >> s[i];
	}
	rep(i,0,m) {
		cin >> t[i];
	}
	rep(i,0,MAX_N) rep(j,0,MAX_N) {
		dp[i][j] = 0LL;
		sum[i][j] = 0LL;
	}

	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			if(s[i-1] == t[j-1]) {
				dp[i][j] = (sum[i-1][j-1] + 1) % MOD;
			}
			sum[i][j] = (sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] + MOD) % MOD;
		}
	}

	cout << (sum[n][m]+1) % MOD << endl;
	return 0;
}


Measured memory_bytes: 65920
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,X;cin>>N>>X;
    int S=0;
    int ans=1;
    REP(i,N){
        int a;cin>>a;
        if(a+S<=X){
            ans++;
            S+=a;
        }
        else break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    bool isOk = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if(i * j == N) {
                isOk = true;
            }
        }
    }

    string ans = isOk ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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;
    if(s=="Sunny") cout << "Cloudy";
    else if(s == "Cloudy") cout << "Rainy";
    else if(s == "Rainy") cout << "Sunny"; 
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  vector<Pl> cost(n);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    cost.emplace_back(a,b);
  }
  sort(all(cost));
  ll ans = 0;
  int tmp = 0;
  rep(i,m) {
    if(m-i <= cost[tmp].second) {
      ans += cost[tmp].first * (m-i);
      break;
    }
    else {
      ans += cost[tmp].first * cost[tmp].second;
      i += cost[tmp].second - 1;
      tmp++;
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 4096
/*
* @Author: _dp95
* @Date:   2020-04-03 07:58:57
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

signed main( ){
  timesaver ;
  ll x, y, a, b, c ;
  cin >> x >> y >> a >> b >> c ;
  vector< ll > r(a), g(b), p(c) ;
  for( ll &i : r ) cin >> i ;  sort(all(r), greater<ll>());
  for( ll &i : g ) cin >> i ;  sort(all(g), greater<ll>());
  for( ll &i : p ) cin >> i ;
  for( ll i = 0 ; i < x ; i++ )
    p.pb(r[i]);
  for( ll i = 0 ; i < y ; i++ )
    p.pb(g[i]);
  sort(all(p), greater<ll>());
  ll ans(0) ;
  for( ll i = 0 ; i < x+y ; i++ )
    ans += p[i] ;
  cout << ans << nl ;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
    int n, t;
    cin >> n >> t;
    vector<pair<int,int>> sor(n);
    for(int i = 0; i < n; i++)cin >> sor[i].first >> sor[i].second;
    sort(sor.begin(), sor.end());
    vector<int> w(n), v(n);
    for(int i = 0; i < n; i++)w[i] = sor[i].first, v[i] = sor[i].second;
    int ans = 0;
    vector<vector<int>> dp(n + 1, vector<int>(4000, -1000000000));
    dp[0][0] = 0;

    for(int i = 0; i < n - 1; i++){
        for(int j = 0; j < t; j++){
            if(j - w[i] >= 0)
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
        int cur = *max_element(dp[i + 1].begin(), dp[i + 1].end());
        ans = max(ans, cur + v[i + 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 47360
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<string> s(n);
	int a[n][5][2];
	string t = "";
	char g='\n';
	for(int i = 0; i<n; i++)
	{
		for(int j = 0 ;j<10; j++)
		{
			cin>>g;
			t.push_back(g);
		}
		s[i]=t;
		t = "";
	}
	int p[n][11];
	for(int i = 0; i<n; i++)
		for(int j = 0; j<11; j++)
			cin>>p[i][j];
	ll ans[(1<<11)] = {0};
	ans[0] = -1e15;
	for(int i = 1; i<(1<<11); i++)
	{
		bitset<12> b(i);
		int com = 0;
		for(int k =0; k<n; k++)
		{
			bitset<12> b2(s[k]);
			b2 &= b;
			com += b2.count();
			ans[i] += p[k][b2.count()];
		}
		if(com==0)
			ans[i] = -1e15;
	}
	cout<<*max_element(ans,ans+(1<<11))<<endl;
	return 0;
}

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

int a, b, c, d, e;

int main(){
	cin >> a >> b >> c >> d >> e;
	if(a < 0) cout << abs(a) * c + d + b * e << endl;
	if(a >= 0) cout << (b - a) * e << endl;
	return 0;
}

Measured memory_bytes: 3056