akhauriyash/Code-Regression huggingface dataset:
/*
    LEARNING DP:    Vacation
        + Three types of activity
        + Chose one
        + No same activity on two or more consecutive days.
        + Maximum happiness

        => So the question are WHICH ACTIVITY? and WHICH DAY?
    IF WE KNOW: consider we are on the i-th day
        if we choose the first activity,
            so on the PREVIOUS DAY, obviously we chose the second or the third BECAUSE the condition.

        => If we know the answer on the PREVIOUS day, we can calculate the current day.
    PRE DP:
        day 1: act 1 = a1, act 2 = a2, act 3 = a3.
    TIME COMPLEXITY:
        O(N*3)

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

#define DB(_x)      cout << #_x << " is " << (_x) << "\n";
#define FOR(_a,_b)  for (_a = 0; _a < _b; ++_a)
//#define IOFILE

using LL = long long;
using LD = long double;
using VI = vector<int>;
using PI = pair<int,int>;

void Excalibur(){
    int n, i, j;
    while (cin >> n){
        vector<VI> a(n,VI(3));
        FOR(i,n) FOR (j,3) cin >> a[i][j];

        vector<VI> dp(n, VI(3,0));
        dp[0][0] = a[0][0];
        dp[0][1] = a[0][1];
        dp[0][2] = a[0][2];
        FOR (i,n){
            if (i == 0) continue;
            FOR (j,3){
                dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[i][j];
            }
        }

        cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << "\n";
    }
}

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

#ifdef  IOFILE
    freopen("INPUT.in", "r", stdin);
    freopen("OUTPUT.out", "w", stdout);
#endif

Excalibur();
return 0;}


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

int main(){
    int N, tmp;
    cin >> N ;
    vector<int> ans(N+1, 0);

    for(int i=1; i<N+1; i++){
	ans[i] = ans[i-1]+1;
	tmp=1;
	for(int j=0; ; j++){
	    tmp *= 6;
	    if(i-tmp<0)
		break;
	    ans[i] = min(ans[i], ans[i-tmp]+1);
	}
	tmp=1;
	for(int j=0; ; j++){
	    tmp *= 9;
	    if(i-tmp<0)
		break;
	    ans[i] = min(ans[i], ans[i-tmp]+1);
	}
    }
    
    cout << ans[N] <<endl;
}




Measured memory_bytes: 640
#include <string>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int counter(int n){
  int cnt = 0;
  int minus = 1;
  while (1)
  {
    if (n>=minus)
    {
      n-=minus;
      minus++;
      cnt++;
    }
    else
    {
      break;
    }
  }
  return cnt;
}

int main(int argc, char const *argv[])
{
    ll N;
    cin >> N;
    // cout << N << ":";
    int cnt = 0;
    for(auto p : prime_factor(N)) {
        cnt+=counter(p.second);
    }

    cout << cnt;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#define rep(i,n) for(int i=0; i<n; i++)

int main(void){
    int N, K;
    scanf("%d %d", &N, &K);

    int *A;
    A = (int *)malloc(sizeof(int)*N);

    rep(i,N) scanf("%d", &A[i]);

    for(int i=K; i<N; i++){
        if(A[i-K] < A[i]) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(int i = 1; i < S.size(); i++) {
        if(S[i] == S[i-1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll t = n%k;
    cout<<min(abs(t-k), t)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int bus = 0;
		int train = 0;

		if (a < b) {
			train = a;
		} else {
			train = b;
		}

		if (c < d) {
			bus = c;
		} else {
			bus = d;
		}

		System.out.println(bus + train);

	}

}


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

int main() {
  string S;
  int max_len = 0;
  int tmp_len = 0;
  cin >> S;
  
  for(int i=0; i<S.length(); i++) {
    char c = S[i];
    if(c=='A'||c=='T'||c=='G'||c=='C') {
      tmp_len++;
      if(max_len < tmp_len) {
        max_len = tmp_len;
      }
    } else { 
      tmp_len = 0;
    }
  }
  cout << max_len;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll a, b;
	cin >> a >> b;
	if ((a - b) % 2 == 0) cout << (a + b) / 2;
	else cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s = sc.nextInt();
        int[] ary = new int[n];
        int[] sum = new int[n];
        ary[0] = sc.nextInt();
        sum[0] = ary[0];
        for(int i = 1;i < n;i++){
            ary[i] = sc.nextInt();
            sum[i] = sum[i-1] + ary[i];
        }
        int poyo = 0;
        int ans = MAX;
        for(int i = 0;i < n;i++){
            if(sum[i] < s)continue;
            for(int j = poyo;j < n;j++){
                poyo = j;
                if(ans > i-j)ans = i-j;
                if(sum[i]-sum[j]<s)break;
            }
        }
        if(ans==MAX)ans=-1;
        System.out.println(ans+1);
    }    
}






Measured memory_bytes: 71512
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visted=true;
    for(int i = 0; i < N; i++){
        if(visited[i] == false){
            all_visted = false;
        }
    }

    if(all_visted){
        return 1;
    }

    int ret =0;

    for(int i = 0; i < N; i++){
        if(graph[v][i] == false)continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret+=dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int a, b;
    REP(i, M){
        cin >> a >> b;
        graph[a-1][b-1] = true;
        graph[b-1][a-1] = true;
    }
    bool visited[N];
    REP(i, N) visited[i] = false;
    visited[0] = true;
    int ans = dfs(0,N,visited);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int dp[2100][2100];

int a[2100];
int n, z, w;

int main() {
	cin >> n >> z >> w;
	a[0] = z;
	a[1] = w;
	for (int i = 2; i <= n + 1; ++i)
		cin >> a[i];
	for (int i = 0; i <= n; ++i) {
		dp[i][n + 1] = abs(a[i] - a[n + 1]);
		dp[n + 1][i] = abs(a[i] - a[n + 1]);
	}
	for (int i = n; i >= 0; --i) {
		int mx = 0;
		int mn = 1e9 + 1000;
		for (int j = i + 1; j <= n + 1; ++j)
			mx = max(mx, dp[j][i]), mn = min(mn, dp[i][j]);
		for (int j = i - 1; j >= 0; --j)
			dp[j][i] = mx, dp[i][j] = mn;
	}
	cout << dp[0][1] << "\n";
	return 0;
}




Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define yes cout<<"YES"<<nl
#define no  cout<<"NO"<<nl
#define nl  '\n'
#define tr ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define tst int t;cin>>t;while(t--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
#define vi    vector<int>
#define    vl    vector<ll>
#define    si    set<int>
#define    sl    set<ll>
#define    msi    multiset<int>
#define    msl    multiset<ll>
#define    pii    pair<int,int>
#define    pil    pair<int,ll>
#define    pli    pair<ll,int>
#define    pll    pair<ll,ll>
#define    mp    make_pair
#define    pb    push_back

int main()
{
    int a;
    cin>>a;
    int b=a+(a*a)+(a*a*a);
    cout<<b<<nl;
    
}


Measured memory_bytes: 3564
n,m=map(int,input().split())
cost=[0]*m
keys=[0]*m
for i in range(m):
  a,b=map(int,input().split())
  cost[i]=a
  k=list(map(int,input().split()))
  for j in range(b):
    keys[i]|=(1<<(k[j]-1))

INF=10**9+1
dp=[INF]*(2**n)
dp[0]=0
for i in range(len(keys)):
  for j in range(len(dp)-1,-1,-1):
    if dp[j]!=INF:
      dp[j|keys[i]]=min(dp[j|keys[i]],dp[j]+cost[i])
if dp[-1]!=INF:
  print(dp[-1])
else:
  print(-1)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	while(true){
		string str1, str2;
		cin >> str1;
		if(str1[0] == '.' && str1.size() == 1){
			break;
		}
		cin >> str2;
		vector<string> v1, v2;
		string s = "";
		for(int i = 0; i < str1.size(); i++){
			if(str1[i] == '"'){
				v1.push_back(s);
				s = "";
			}else{
				string ss = " ";
				ss[0] = str1[i];
				s = s + ss;
			}
		}
		v1.push_back(s);
		s = "";
		for(int i = 0; i < str2.size(); i++){
			if(str2[i] == '"'){
				v2.push_back(s);
				s = "";
			}else{
				string ss = " ";
				ss[0] = str2[i];
				s = s + ss;
			}
		}
		v2.push_back(s);
		if(v1.size() != v2.size()){
			cout << "DIFFERENT" << endl;
		}else{
			int cnt = 0;
			for(int i = 0; i < v1.size(); i++){
				//cout << v1[i] << " " << v2[i] << endl;
				if(v1[i] != v2[i]){
					if(i % 2 == 0){
						cnt += 2;
					}else{
						cnt++;
					}
				}
			}
			if(cnt == 0){
				cout << "IDENTICAL" << endl;
			}else if(cnt == 1){
				cout << "CLOSE" << endl;
			}else{
				cout << "DIFFERENT" << endl;
			}
		}
	}
	
	return 0;
	
}



Measured memory_bytes: 3168
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}



int main(){
  int n,k;
  cin >> n >> k;
  double ans = 0;
  double prob = 1 / (double)n;
  for(int i = 1;i <= n;i++){
    double p = 1;
    int tmp = i;
    while(tmp < k){
      tmp *= 2;
      p /= 2;
    }
    ans += p * prob;
  }
  printf("%.10lf\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =99999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

  int D,N;
  cin>>D>>N;
  if(N!=100){
  if(D==0){
    cout<<N<<endl;
  }else if(D==1){
    cout<<N<<"00"<<endl;
  }else if (D==2){
cout<<N<<"0000"<<endl;
  }
  }else{
      if(D==0){
    cout<<101<<endl;
  }else if(D==1){
    cout<<101<<"00"<<endl;
  }else if (D==2){
cout<<101<<"0000"<<endl;
  }
  }
}


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

int main() {
	ios_base::sync_with_stdio( false );

	string s;
	cin >> s;

	stack<int> x;
	vector<pair<int,int>> y;
	int area = 0;

	for( int i = 0; i < s.size(); ++i ) {
		if( s.at( i ) == '\\' ) {
			x.push( i );
		}
		else if( s.at( i ) == '/' && !x.empty() ) {
			int w = i - x.top();
			area += w;

			while( !y.empty() && y.back().first > x.top() ) {
				w += y.back().second;
				y.pop_back();
			}

			y.push_back( { x.top(), w } );
			x.pop();
		}
	}

	cout << area << '\n' << y.size();

	if( !y.empty() ) {
		cout << ' ';
	}

	for( int i = 0; i < y.size(); ++i ) {
		cout << y.at( i ).second << (i < y.size()-1 ? " " : "");
	}

	cout << endl;
}



Measured memory_bytes: 3312
#include <stdio.h>


int main(void)
{
	//変数の宣言
	int n;
	int a[2][100];
	int ans=0;
	int i,j,k;
	int temp;
	
	//データの読み込み
	scanf("%d",&n);
	
	for(i=0;i<2;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<n;i++){
		temp=0;
		for(j=0;j<=i;j++){
			temp=temp+a[0][j];
		}
		for(j=i;j<n;j++){
			temp=temp+a[1][j];
		}
		if(temp>ans) ans=temp;
	}
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



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

int gcd(int A,int B){
  if(B>A)swap(A,B);
  if(B==0)return A;
  return gcd(B,A%B);
}

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for(int i=min(A,B);i>0;i--){
    if(A%i==0&&B%i==0){
      K--;
      if(K==0){
        cout << i << endl;
      }
    }
  }
}
  
  

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define INF 1e9+7
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    vector<int>dp(n);
    
    rep(i,n)dp[i]=INF;
    dp[0]=0;
    rep(i,n)for(int j=1;j<=k&&i+j<n;j++){
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(){
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	
	while(A>0 && C>0){
		
		C-=B;
		if(C<=0){
			printf("Yes\n");
			break;
		}
		A-=D;
		if(A<=0){
			printf("No\n");
			break;
		}
		
	}

	return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
int main()
{
   fast ;
   ll a,b,c ;
   cin>>a>>b>>c ;
   if(a==b&&a!=c||b==c&&b!=a||a==c&&a!=b)
    cout<<"Yes" ;
   else
    cout<<"No" ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <algorithm>
#include <set>
#include <utility>

#define FOR( i, l, r) for(int i = (l)    ; i <  (r); i++)
#define FOR1(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define REV( i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define REV1(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define INC( i, n) FOR( i, 0, n)
#define INC1(i, n) FOR1(i, 1, n)
#define DEC( i, n) REV( i, 0, n)
#define DEC1(i, n) REV1(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
std::pair<int, int> p[200000];
std::set< std::pair<int, int> > s;
LL ans;

void add(int i) {
	auto q = s.insert(p[i]);
	
	auto it1 = q.first;
	auto it2 = q.first;
	
	it1--;
	it2++;
	
	int v = p[i].second;
	int m = p[i].first;
	int l = (*it1).first;
	int r = (*it2).first;
	
	ans += static_cast<LL>(m - l) * (r - m) * v;
}

int main() {
	scanf("%d", &n);
	INC(i, n) { int a; scanf("%d", &a); p[i] = std::make_pair(a, i); }
	
	std::sort(p, p + n);
	
	INC(i, n) { p[i] = std::make_pair(p[i].second, p[i].first); }
	
	s.insert( std::make_pair(-1, 0) );
	s.insert( std::make_pair( n, 0) );
	INC(i, n) { add(i); }
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

long long int c[10][2000];
int now[10];
int nn[10];
long long int f[11][2222];
long long int j[10][2000];

int main()
{
	int n,k;

	{
		scanf("%d %d",&n,&k);
		for(int i = 0; i < 10; i++)
		{
			now[i] = 0;
		}
		long long int cw,gw;
		for(int i = 0; i < n; i++)
		{
			scanf("%lld %lld",&cw,&gw);
			c[gw - 1][now[gw - 1]] = cw;
			now[gw - 1]++;
		}
	}

	{
		for(int i = 0; i < 10; i++)
		{
			sort(c[i],c[i] + (now[i]),greater<int>());
			j[i][0] = c[i][0];
			for(int ii = 1; ii < now[i]; ii++)
			{
				j[i][ii] = j[i][ii - 1] + c[i][ii] + ii * 2;
			}
		}
	}

	{
		for(int i = 0; i < 11; i++)
		{
			for(int ii = 0; ii < 2222; ii++)
			{
				f[i][ii] = 0;
			}
		}
	}

	{
		for(int i = 1; i <= 10; i++)
		{
			for(int ii = 1; ii <= k; ii++)
			{
				f[i][ii] = f[i - 1][ii];
				for(int iii = 1; iii <= now[i - 1]; iii++)
				{
					if(ii - iii < 0)
					{
						continue;
					}
					if(f[i][ii] < f[i - 1][ii - iii] + j[i - 1][iii - 1])
					{
						f[i][ii] = f[i - 1][ii - iii] + j[i - 1][iii - 1];
					}
				}
			}
		}
	}

	{
		printf("%lld\n",f[10][k]);
	}

	return 0;
}

Measured memory_bytes: 1512
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;
int A[MAX_N];
pi P[MAX_N];

void solve() {
	cin >> N >> K;
	rep(i, 0, N) {
		cin >> P[i].fst;
		P[i].sec = i;
	}
	sort(P, P + N);
	reverse(P, P + N);
	vi vec;
	rep(i, 0, K) {
		rep(j, 0, N - 1) {
			P[j].fst %= 114514;
			P[j].fst--;
			if(P[j].fst < 0) {
				cout << -1 << "\n"; return;
			}
			vec.pb(P[j].sec);
		}
		P[N - 1].fst += 114514;
		sort(P, P + N);
		reverse(P, P + N);
	}
	rep(j, 0, N) {
		P[j].fst %= 114514;
		P[j].fst--;
		if(P[j].fst < 0) {
			cout << -1 << "\n"; return;
		}
		vec.pb(P[j].sec);
	}
	cout << sz(vec) << "\n";
	rep(i, 0, sz(vec)) {
		cout << vec[i] + 1 << " ";
	}
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n,k;
  cin>>n;
  cin>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  ll sum=0;
  for(ll i=0;i<n-k;i++)
  {
    sum=sum+a[i];
  }
  cout<<sum<<"\n";
return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int k;
vpii adj[100010];
bool vis[100010];
ll dist[100010];
void dijkstra(){
    for(int i=0;i<k;i++)dist[i]=INT_MAX;
    priority_queue < pii > q;
    q.push(mp(0,1));
    dist[1] = 0;
    while(!q.empty()){
        int node = q.top().se;
        q.pop();
        if(!vis[node]){
            vis[node]=true;
            for(int i=0;i<adj[node].size();i++){
                int nex = adj[node][i].fi;
                int w = adj[node][i].se;
                if(dist[nex] > dist[node] + w){
                    dist[nex] = dist[node] + w;
                    q.push(mp(-dist[nex],nex));
                }
            }

        }

    }
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    cin>>k;
    for(int i=0;i<k;i++){
        adj[i].pb(mp((i+1)%k,1));
        adj[i].pb(mp((i*10)%k,0));
    }
    dijkstra();
    cout<<dist[0]+1<<newl;

}


Measured memory_bytes: 7292
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s, t := next(), next()
	ns := len(s)

	// place[i][j]: sのi番目より後で，文字jが出てくる最近の場所
	place := make([][26]int, ns+1)
	for i := range place[ns] {
		place[ns][i] = -1
	}
	for i := ns - 1; i >= 0; i-- {
		for j := range place[i] {
			place[i][j] = place[i+1][j]
		}
		place[i][int(s[i]-'a')] = i + 1
		// puts(i, place[i])
	}

	// 答えを持つか判定
	for i := range t {
		if place[0][int(t[i]-'a')] < 0 {
			puts(-1)
			return
		}
	}

	l, x := 0, 0
	for i := 0; i < len(t); i++ {
		c := int(t[i] - 'a')
		if place[x][c] == -1 {
			l++
			x = 0
		}
		x = place[x][c]
		// puts(string(t[i]), x)
	}

	ans := ns*l + x
	puts(ans)
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    string s, t ;
    ll ans = 0, cnt = 0, sz ;
    cin >> s >> t ;
    sz = s.size() - t.size() ;
    ans = t.size() ;

    for (int i = 0; i <= sz; i++) {
        cnt = 0 ;
        for (int j = 0, k = i; j < t.size(); j++, k++) {
            if (s[k] != t[j]) {
                cnt++ ;
            }
        }
        ans = min(ans, cnt) ;
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  vector<int> a(3);
  rep(i, 3) cin >>a.at(i);
  sort(all(a));
  cout <<a.at(0) <<" " <<a.at(1) <<" " <<a.at(2) <<endl;
}



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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long valu[31][31];
long long freq[3][31];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, c;

    cin >> n >> c;

    for(int i = 0; i < c; ++i){
        for(int j = 0; j < c; ++j){
            cin >> valu[i][j];
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            int k;
            cin >> k;
            ++freq[(i + j) % 3][k - 1];
        }
    }

    long long best = -1;

    for(int ca = 0; ca < c; ++ca){

        long long costa = 0;
        for(int other = 0; other < c; ++other)
            costa += valu[other][ca] * freq[0][other];

        for(int cb = 0; cb < c; ++cb){

            if(ca == cb)
                continue;

            long long costb = 0;
            for(int other = 0; other < c; ++other)
                costb += valu[other][cb] * freq[1][other];

            for(int cc = 0; cc < c; ++cc){

                if(ca == cc || cc == cb)
                    continue;

                long long costc = 0;
                for(int other = 0; other < c; ++other)
                    costc += valu[other][cc] * freq[2][other];

                if(best == -1){
                    best = costa + costb + costc;
                } else {
                    best = min(best, costa + costb + costc);
                }
            }
        }
    }

    cout << best;

    return 0;
}


Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
        "strings"
)

func solution(s string) int {
        n := len(s) + 1
        a := make([]int, n)
        for i := 0; i < n-1; i++ {
                if s[i] == '<' {
                        a[i+1] = max(a[i+1], a[i]+1)
                }
        }

        for i := n - 2; i >= 0; i-- {
                if s[i] == '>' {
                        a[i] = max(a[i], a[i+1]+1)
                }
        }
        out := 0
        for i := 0; i < n; i++ {
                out += a[i]
        }
        return out
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        reader := bufio.NewReaderSize(os.Stdin, 10240*10240)
        str, _, _ := reader.ReadLine()
        fmt.Println(solution(strings.TrimRight(string(str), "\r\n")))
}

Measured memory_bytes: 8960
A, B, C, X, Y = map(int, input().split())


if A + B <= 2 * C:
    ans = Y * B + X * A
else:
    if X > Y:
        ans = min(2 * C * Y + (X-Y) * A, 2*C*X)
    else:
        ans = min(2 * C * X + (Y-X) * B, 2*C*Y)

print(ans)

Measured memory_bytes: 38384
import java.util.*;

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

	void doIt() {
		int rcnt = 0, bcnt = 0;
		int n = sc.nextInt();
		String s = sc.next();
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == 'R') rcnt++;
			else bcnt++;
		}
		if(rcnt > bcnt)System.out.println("Yes");
		else System.out.println("No");
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll s = 0;
    rep(i, n) s ^= a[i];
    ll ans = s;
    rep(i, n)a[i] &= ~s;

    int r = 0;
    vector<int> top(n);
    for (int i = 60; i >= 0; --i) {
        int j = r;
        for (; j < n; ++j) {
            if (a[j] >> i & 1) {
                swap(a[r], a[j]);
                break;
            }
        }
        if (j == n) continue;
        top[r] = i;
        rep(k, n) {
            if (r == k) continue;
            if (a[k] >> i & 1) a[k] ^= a[r];
        }
        ++r;
    }

    ll x = 0;
    for (int i = 60; i >= 0; --i) {
        ll nx = x | (1ll << i);
        {
            ll b = nx;
            rep(j, r) {
                if (b >> top[j] & 1) b ^= a[j];
            }
            if ((b & nx) == 0) {
                x = nx;
            }
        }
    }

    ans += x * 2;
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string o, e;
    cin >> o >> e;

    int n = o.size() + e.size();
    string ans(n, '\0');
    rep (i, o.size())
    {
        ans[2 * i] = o[i];
    }
    rep (i, e.size())
    {
        ans[2 * i + 1] = e[i];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

const int dh[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dw[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int H, W;
string m[10];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    while (true) {
        cin >> H >> W;
        if (H+W == 0) break;
        for (int j = 0; j < H; ++j) {
            cin >> m[j];
        }

        string ans = "0";
        for (int a = 0; a < H*W; ++a) {
            int h1 = a / W, w1 = a % W;
            for (int b = a; b < H*W; ++b) {
                int h2 = b / W, w2 = b % W;
                if (m[h1][w1] != m[h2][w2]) continue;

                for (int d1 = 0; d1 < 8; ++d1) {
                    for (int d2 = ((h1==h2&&w1==w2)?(d1+1):0); d2 < 8; ++d2) {

                        string t = string(1, m[h1][w1]);
                        for (int j = 1; ; ++j) {
                            int nh1 = (h1 + dh[d1]*j + 100*H) % H;
                            int nw1 = (w1 + dw[d1]*j + 100*W) % W;

                            int nh2 = (h2 + dh[d2]*j + 100*H) % H;
                            int nw2 = (w2 + dw[d2]*j + 100*W) % W;

                            if ((nh1 == h1 && nw1 == w1) || (nh2 == h2 && nw2 == w2)) {
                                break;
                            }
                            if (m[nh1][nw1] != m[nh2][nw2]) {
                                break;
                            }

                            t.push_back(m[nh1][nw1]);
                        }
                        if (t.size() <= 1) continue;
                        if (t.size() >= 5) {
                        }

                        bool ok = false;
                        if (t.size() > ans.size()) {
                            ok = true;
                        } else if (t.size() == ans.size()) {
                            for (int j = 0; j < t.size(); ++j) {
                                if (t[j] < ans[j]) {
                                    ok = true;
                                    break;
                                } else if (t[j] > ans[j]) {
                                    break;
                                }
                            }
                        }
                        if (ok) {
                            ans = t.substr(0, t.size());
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
        return 0;
    }

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

int main(){
	long int n,ma=0,aa=0,ra=0,ca=0,ha=0;
  	cin >> n;
  	for (int i=0;i<n;i++){
    	string t;
      	cin >> t;
      	if (t[0]=='M' ) ma++;
        if (t[0]=='A' ) aa++;
      	if (t[0]=='R' ) ra++;
      	if (t[0]=='C' ) ca++;
      	if (t[0]=='H' )	ha++;
    }
  	cout << ma*aa*ra+ma*aa*ca+ma*aa*ha+ma*ra*ca+ma*ra*ha+ma*ca*ha+aa*ra*ca+aa*ra*ha+aa*ca*ha+ra*ca*ha << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}

int main()
{
	char a,b;
	cin>>a>>b;
	if(a==b) cout<<"H";
	else cout<<"D";
	return 0;
}

Measured memory_bytes: 256
l = list(map(int, input().split()))
print(l[1] + l[2] - l[3], end=' '),
print(l[3] + l[2] - l[0], end=' '),
print(l[1] - l[3] + l[0], end=' '),
print(l[1] - l[0] + l[2], end=' ')

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define rep(i, j, k) for (int i = j; i < k; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define mt make_tuple

#define iv inline void
#define ii inline int
#define ill inline ll

template <typename S, typename T>
inline bool smin(S &l, T r) {
  return r < l ? l = r, 1 : 0;
}
template <typename S, typename T>
inline bool smax(S &l, T r) {
  return l < r ? l = r, 1 : 0;
}

constexpr int MOD = 1e9 + 7;  // 998244353;

template <typename S>
inline S mod(S &l) {
  return l = (l % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}
ill po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

constexpr int N = 2e3 + 10;

int n, x;
ll a[N], bt[N][N];

int main() {
#ifndef LOCAL
  // fileIO("");
#endif

  memset(bt[0], 63, sizeof(bt[0]));
  cin >> n >> x;
  rep(i, 0, n) cin >> a[i];

  ll answer = 1e18;
  rep(j, 0, n) {
    ll res = 1ll * j * x;
    rep(i, 0, n) {
      int id = (i - j + n) % n;
      res += (bt[j + 1][i] = min(bt[j][i], a[id]));
    }
    smin(answer, res);
  }

  cout << answer << endl;

  return 0;
}


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

public class Main {

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

  public void solve() {

    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int m = input.nextInt();
    int x = input.nextInt();
    int y = input.nextInt();

    int[] citesA = new int[n];
    for (int i = 0; i < citesA.length; i++) {
      citesA[i] = input.nextInt();
    }

    int[] citesB = new int[m];
    for (int i = 0; i < citesB.length; i++) {
      citesB[i] = input.nextInt();
    }

    Arrays.sort(citesA);
    Arrays.sort(citesB);

    int xmax = citesA[n - 1];
    int ymin = citesB[0];

    for (int z = x + 1; z < y; z++) {
      if (z > xmax) {
        if (z <= ymin) {
          System.out.println("No War");
          return;
        }
      }
    }
    System.out.println("War");
  }
}


Measured memory_bytes: 23252
#include<stdio.h>

int main(void)
{
   int i,x;
   int a[10000];

   for(i=0;;i++)
   {
      scanf("%d",&a[i]);
      if(a[i]==0)
      {
         break;
      }
   }

   x=i;
   i=0;

   while(i<x)
   {
      printf("Case %d: %d\n",i+1,a[i]);
      i++;
   }

   return 0;
}

Measured memory_bytes: 640
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M

solve :: M.Map Int (Int,Int) -> (Int, String) -> M.Map Int (Int,Int)
solve m (i, "AC")
    | m' == Nothing = M.insert i (1,0) m
    | fst (fromJust m') > 0 = m
    | otherwise = M.insert i (fst (fromJust m') + 1,snd (fromJust m')) m
        where
            m' = M.lookup i m
solve m (i, "WA")
    | m' == Nothing = M.insert i (0,1) m
    | fst (fromJust m') > 0 = m
    | otherwise = M.insert i (fst (fromJust m'),snd (fromJust m') + 1) m
        where
            m' = M.lookup i m

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    psm <- map (\xs -> (read (xs!!0)::Int,xs!!1)) <$> map words <$> replicateM m getLine
    putStrLn $ unwords $ map show $ foldl (\[x,y] (z,w) -> if z > 0 then [x+z,y+w] else [x,y] ) [0,0] $ M.elems $ foldl solve M.empty psm
    


Measured memory_bytes: 69244
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;

    for(int i=0; i<(int)s.size(); i++){       
        if(i < a){
            if(!(s[i]-'0' >= 0 && s[i]-'0' <= 9)){
                COUT("No");
                return 0;
            }
        }else if(i == a){
            if(s[i] != '-'){
                COUT("No");
                return 0;
            }
        }else{
            if(!(s[i]-'0' >= 0 && s[i]-'0' <= 9)){
                COUT("No");
                return 0;
            }
        }
    }

    COUT("Yes");
    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split());m=998244353;D=[[0]*(d+1)for _ in range(c+1)];D[a][b]=1
for i in range(c):
 for j in range(d):D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%m
print(D[c][d])

Measured memory_bytes: 133892
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define itn int
int N;
string S;
itn s[30303];
bool dbg = false;
int c1[11], c2[111], c3[1111];
void solve() {
    FOR(i, 0, N) {
        s[i] = S[i] - '0';
    }
    FOR(k, 0, N) {
        int t = s[k];
        FOR(i, 0, 100) {
            if (c2[i]) {
                c3[i * 10 + t] = 1;
            }
        }
        FOR(i, 0, 10) {
            if (c1[i]) {
                c2[i * 10 + t] = 1;
            }
        }
        c1[t] = 1;
    }
    int ans = 0;
    FOR(i, 0, 1000) {
        ans += c3[i];
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    solve();
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);

  for(int i=0; i<h.size(); i++) cin>>h.at(i);

  sort(h.begin(), h.end());

  int min=2147483647;
  int length;
  for(int i=0; i<N-K+1; i++) {
    length=h.at(i+K-1)-h.at(i);
    if(length<min) min=length;
  }
  cout << min << endl;
}


Measured memory_bytes: 640
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-10 14:44:31
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string S[3];
  for (auto i = 0; i < 3; i++)
  {
    cin >> S[i];
  }
  for (auto i = 0; i < 3; i++)
  {
    cout << S[i][i];
  }
  cout << endl;
}

Measured memory_bytes: 256