akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int N = S.size();

	ll mod = 1e9 + 7;
	ll dp[100001][2] = {};
	dp[0][0] = 1;
	rep(i, N) {
		if (S[i] == '1') {
			dp[i + 1][0] = dp[i][0] * 2 % mod;
			dp[i + 1][1] = dp[i][1] * 3 % mod;
			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] %= mod;
		}
		else {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][1] * 3 % mod;
		}
	}

	co((dp[N][0] + dp[N][1]) % mod);

	Would you please return 0;
}

Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,r;cin>>n>>r;
    if(n>=10)cout<<r<<endl;
    else cout<<r+100*(10-n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;

	int cnt=0;
	bool che=0;
	for(int i=0; i<n; i++){
		int u, v;
		cin>>u>>v;
		if(u==v){
			cnt++;
		}
		else{
			cnt=0;
		}
		if(cnt>=3){
			che=1;
		}
	}
	if(che){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,m,x,y;
    cin >> n>>m>>x>>y;
    vector<int> vec_x(n+1);
    vector<int> vec_y(m+1);
    vec_x.at(n)=x;
    vec_y.at(m)=y;
    for(int i=0;i<n;i++){
        cin >> vec_x.at(i);
    }
    for(int i=0;i<m;i++){
        cin >> vec_y.at(i);
    }
    sort(vec_x.begin(),vec_x.end());
    sort(vec_y.begin(),vec_y.end());
    if(vec_x.at(n)<vec_y.at(0)){
        cout <<"No War"<<endl;
    }else{
        cout <<"War"<<endl;
    }
}

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

int bits[41] = {0};


std::string toBinary(long long n,bool f_cnt){
    string r;
	long long i = 0;
    while(n!=0){
    	if(n%2==0){
    		r = r + "0" ;
    	}else{
    		r = r +"1" ;
    		if(f_cnt)bits[i]++;
    	}
    	i++;
    	n/=2;
    }
    return r;
}

long long data[1000000];

int main(){
	long long n,k;
	cin >> n >> k;
	for(int i=0;i<n;++i){
		cin >> data[i];
		toBinary(data[i],true);
	}
	string k_string = toBinary(k,false);
	
	long long res = 0;

	//x = k
	for(int i=0;i<n;++i){
		res += data[i] ^ k;
	}
	
	for(int i=0;i<k_string.size();++i){
		if(k_string[i] == '0') continue;
			// i bit目が 1 なので 0にしてタス
		long long tmp =(1ll << i) * bits[i];
		
			//i bit未満のやつを最適化
		for(int j=0;j<i;++j){
			long long a = n-bits[j];
			if(a < bits[j]) a = bits[j];
			tmp += (1ll << j) * a;
		}
			//i bit を超える場所を xor していく
		for(int j=i+1;j<40;++j){
			long long a = bits[j];
			if(j < k_string.size() && k_string[j] == '1'){
				 a = n-bits[j];
			}
			tmp += (1ll << j) * a;
		}
	//	cout << tmp <<endl;
		
		res = max(res,tmp);
	}
	cout << res << endl;
	
	
	return 0;
}	



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,0,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    rep(i,0,k)
    sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define health first
#define strength second

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	pair<int,int> taka = {a, b};
	pair<int,int> aoki = {c, d};
	while (taka.health > 0 && aoki.health > 0) {
		aoki.health -= taka.strength;
		taka.health -= aoki.strength;
	}
	if (aoki.health <= 0) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 3688
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<50);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
	ll h,w,n;cin>>h>>w>>n;
  cout<<min((n+h-1)/h,(n+w-1)/w)<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int A[3][3],N,b[10],i,j,k,num,num1,l,m,n,p,q,s,t;
  int check[3][3]={};
  for(i=0;i<3;i++)
  {
    for(j=0;j<3;j++)
    {
      scanf("%d",&A[i][j]);
    }
  }
  scanf("%d",&N);
  for(k=0;k<N;k++)
  {
    scanf("%d",&b[k]);
  }
  
  for(l=0;l<N;l++)
  {
    for(m=0;m<3;m++)
    {
      for(n=0;n<3;n++)
      {
        if(b[l]==A[m][n])
        {
          check[m][n]=1;
        }
      }
    }
  }
  
  
  for(p=0;p<3;p++)
  {
    num=0;
    for(q=0;q<3;q++)
    {
       if(check[p][q]==1)
       {
          num=num+1;
       }
    }
    
     if(num==3)
        {
          printf("Yes");
          exit(0);
        } 
  }
  for(s=0;s<3;s++)
  {
     num1=0;
    for(t=0;t<3;t++)
    {
      if(check[t][s]==1)
       {
          num1=num1+1;
       }
    }
   
    if(num1==3)
        {
         printf("Yes");
         exit(0);
        } 
    
  }
  if(check[0][0]==1&&check[1][1]==1&&check[2][2]==1)
  {
    printf("Yes");
    exit(0);
  }
  if(check[2][0]==1&&check[1][1]==1&&check[0][2]==1)
  {
    printf("Yes");
    exit(0);
  }
  printf("No");
}
  
      
          
  
              
  

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int max (int a, int b){
  if (a < b) return b;
  else return a;
}
int min (int a, int b) {
  if (a < b) return a;
  else return b;
}
int main () {
  int N, A, B;
  cin >> N >> A >> B;
  int ma = min(A, B);
  int mi = max(0, A + B - N);
  cout << ma << " " << mi << endl;
}


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

using namespace std;

#define EPS (1e-7)
#define INF (1e9)


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rep2(i, n) for(int i = 1; i <= (n); i++)
#define all(a) begin(a),end(a)
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

inline void init(vector<int>& uf) {

    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {

    if(uf[x] == x) {

        return x;
    }
    else {

        return uf[x] = root(uf, uf[x]);
    }
}

inline bool same(vector<int>& uf, int x, int y) {

    return root(uf, x) == root(uf, y);
}

inline void unite(vector<int>& uf, int x, int y) {

    x = root(uf, x);
    y = root(uf, y);

    if(x == y) return;

    uf[x] = y;
}

string s;
void Input() {

    cin >> s;
}



void Solve() {


    int len = int(s.size());
    for(int i = 1; i <= len; i++) {

        cout << 'x';
    }
    cout << endl;

}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s;
  cin >> s;
  if(s.at(1)==s.at(2) && s.at(2)==s.at(0)){
    cout << "No" <<endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
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); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

ll d[101][101];

void pri() {
    cout << "100 100" << endl;
    REP(i, 100) {
        REP(j, 100) {
            cout << (d[i][j] == 0 ? '#' : '.');
        }
        cout << endl;
    }
}

int main() {
    cin >> n >> m;
    FOR(i, 50, 100) {
        REP(j, 100) {
            d[i][j] = 1;
        }
    }
    if (n == 1 && m == 1) {
        pri();
        return 0;
    }
    ll change = 0;
    cnt = 0;
    REP(i, n - 1) {
        if (cnt >= 100) {
            cnt = 0;
            change += 2;
        }
        d[change][cnt] = 1;
        cnt += 2;
    }
    change = 51;
    cnt = 0;
    REP(i, m - 1) {
        if (cnt >= 100) {
            cnt = 0;
            change += 2;
        }
        d[change][cnt] = 0;
        cnt += 2;
    }
    pri();
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    string s;
    cin >> s;
    int len = s.size();
    if (s[len - 1] == 's')
    {
        cout << s << "es" << "\n";
    }
    else
    {
        cout << s << "s" << "\n";
    }
    
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main() {
	int N;
	scanf("%d", &N);
	int d[50];
	for (int i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}

	long long sum = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i; j++) {
			sum += d[i] * d[j];
		}
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long ;
using ld=long double;
 
int main(){
    ll n;
    cin>>n;
    vector<ld> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    ld sum=0;
    for(int i=0;i<n;i++){
        sum+=(1/a[i]);
    }
    
    cout<<fixed<<setprecision(7)<<1/sum;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    int w, h, n, xl, xs, yl, ys;
    cin >> w >> h >> n;
    xl = w;
    xs = 0;
    yl = h;
    ys = 0;
    rep(i, n)
    {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a)
        {
        case 1:
            xs = max(xs, x);
            break;

        case 2:
            xl = min(xl, x);
            break;

        case 3:
            ys = max(ys, y);
            break;

        case 4:
            yl = min(yl, y);
            break;

        default:
            break;
        }
    }
    if (xs >= xl || ys >= yl)
        cout << 0 << endl;
    else
        cout << (xl - xs) * (yl - ys) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}
int gcd(ll(a), ll(b)) {
	ll q = a;
	ll w = b;
	ll e = q;
	while (q % w != 0) {
		e = q % w;
		q = w;
		w = e;
	}
	return w;

}





int main() {
	int N,K;
	int m=0, d = 0;
	cin >> N;
	string an = "Yes";
	rep(i, N) {
		cin >> K;
		d += K;
		m = max(m, K);
	}
	if (d-m <= m) {
		an = "No";
	}
	cout << an << endl;
	
}

Measured memory_bytes: 384
#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム
text = gets("").downcase    #テキストに小文字をとる

for alphabet in "a".."z"           #sをA から　Zまで２６回繰り返す
  puts "#{alphabet} : #{text.count(alphabet)}"      #まずAからZまで繰り返して　テキストの中のアルファベットをカウントする
end



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

public class Main{
	public static void main(String[] args){
	Scanner kbs=new Scanner(System.in);
	int kushi=kbs.nextInt();
	int goukei=0;
	int[] nagasa=new int[2*kushi];
	for(int i=0;i<2*kushi;i++){
		nagasa[i]=kbs.nextInt();
	}
	Arrays.sort(nagasa);
	for(int i=0;i<2*kushi;i+=2){
		goukei+=nagasa[i];
	}
	System.out.println(goukei);
		}
		
	}


Measured memory_bytes: 10196
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    string board[50];
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; ++i){
        cin >> board[i];
    }


    const int dj[4] = {0, 1, 0, -1};
    const int di[4] = {1, 0, -1, 0};

    bool can = true;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(board[i][j] == '.') continue;

            bool exist = false;
            for(int d = 0; d < 4; ++d){
                int nj = j + dj[d];
                int ni = i + di[d];

                if(nj < 0 || w <= nj) continue;
                if(ni < 0 || h <= ni) continue;
                if(board[ni][nj] == '#') exist = true;
            }

            if(!exist) can = false;
        }
    }


    if(can){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int n;
    int array[100] = {};
    int count = 0;
    int i, j;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    // bubble sort
    int flag = 1;
    i = 0;

    while (flag) {
        flag = 0;
        for (j = n-1; j > 0; j--) {
            if (array[j] < array[j-1]){
                int tmp = array[j];
                array[j] = array[j-1];
                array[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
        i++;
    }

    for (i = 0; i < n; i++) {
        printf("%d", array[i]);
        if (i != (n-1)) printf(" ");
    }
    printf("\n%d\n", count);

    return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> w(n+1);
    vector<ll> e(n+1);
    ll ww=0,ee=0;
    rep(i, n){
        if (s[i] =='W') {
            ww++;
        }else ee++;
        w[i]=ww;
        e[i]=ee;
    }
    ll minn = n;
    rep(i, n){
        if(i==0){
            minn = e[n-1]-e[0];
            continue;
        }
        ll arg = w[i-1]+(e[n-1] - e[i]);
        minn = min(arg,minn);
    }
    pr(minn);
}



Measured memory_bytes: 5380
#include<stdio.h>

int main(){
 int n;
 scanf("%d", &n);
 char str[n+1];
 scanf("%s", str);
 
 if (n%2==1){
 
 puts("No");
}
else{
 int flag = 1;
 
 for ( int i =0; i<n/2; i++){
 if(str[i]!= str[i+n/2]){
 
 flag=0;
}
}
if (flag){
 puts("Yes");
}
else{
 puts("No");
}
}
 return 0;
}

Measured memory_bytes: 1660
n = int(input())
arr = list(map(int,input().split()))

dp = [[0]*2 for i in range(n)]

dp[1][0] = sum(arr[:2])
dp[1][1] = -sum(arr[:2])

for i in range(2,n):
    dp[i][0] = max((dp[i-1][0] + arr[i]),(dp[i-1][1] + arr[i]))
    dp[i][1] = max((dp[i-1][0] - arr[i-1]*2 - arr[i]),(dp[i-1][1] + arr[i-1]*2 - arr[i]))
print(max(dp[-1]))

Measured memory_bytes: 24796
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mp make_pair
    #define mod 1e9+7
    #define sz 100000
    #define f(i,n) for(ll i=0;i<n;i++)
    #define fab(i,a,b) for(ll i=a;i<b;i++)
    #define fr(i,n) for(ll i=n-1;i>=0;i--)
    #define fba(i,b,a) for(ll i=b-1;i>=a;i--)
    #define tc(t) ll t;cin>>t;while(t--)
     
    ll pw(ll x,unsigned ll y) 
    { 
        if (y==0) 
            return 1; 
        else if (y%2==0) 
            return pw(x,y/2)*pw(x,y/2); 
        else
            return x*pw(x,y/2)*pw(x,y/2);
    }
     
    int main() 
    {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a,b;
        cin>>a>>b;
        if(a==b) cout<<"Yes";
        else cout<<"No";
        return 0;
    }

Measured memory_bytes: 256
N = int(input())
c = list(input())

ans = 0
left = 0
right = N-1
while left < right:
    if c[left] != c[right]:
        if c[left] == 'W' and c[right] == 'R':
            ans += 1
        left += 1
        right -=1
        
    if c[left] == 'R' and c[right] == 'R':
        left += 1
    if c[left] == 'W' and c[right] == 'W':
        right -=1
        
print(ans)

Measured memory_bytes: 10636
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

//素因数分解
vector<P> prime_factorize(ll n){
    vector<P> res;
    for (ll a = 2; a * a <= n; ++a){
        ll ex = 0; //指数
        //割り切れる限り割る
        while(n % a == 0){
            ++ex;
            n /= a;
        }
        res.push_back({a,ex});
    }
    if (n != 1) res.push_back({n,1});
    return res;
}

int main(){
    ll n;
    cin >> n;
    auto res = prime_factorize(n);
    ll ans = 0;
    for (auto p : res){
        ll now = p.first;
        ll ex = p.second;
        int i = 1;
        while(1){
            if(i > ex)break;
            ex -= i;
            i++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19712
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;

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

  cin >> S;

  map<char, int> mp;
  for (int i = 0; i < len(S); ++i) {
    mp[S[i]]++;
  }

  if (mp.size() != 2) {
    cout << "No" << endl;
    return 0;
  }

  for (auto a : mp) {
    if (a.sc != 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt;
void insertionSort(int *A,int n,int g){
    for (int i=g; i<n; i++){
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt ++;
        }
        A[j+g] = v;
    }
}
void shellSort(int *A,int n){
    cnt = 0;
    int r = 1;
    vector<int> G;
    while (r <= n){
        G.push_back(r);
        r *= 2;
    }
    int m = G.size();
    reverse(G.begin(), G.end());
    cout << m << endl;
    for (int i=0; i<m; i++){
        if (i == m-1){
            cout << G[i] << endl;
        } else {
            cout << G[i] << " ";
        }
    }
    for (int i=0; i<m; i++){
        insertionSort(A,n,G[i]);
    }
    cout << cnt << endl;
}
int main() {
    int n;
    cin >> n;
    int A[n];
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    shellSort(A,n);
    for (int i=0; i<n; i++){
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6948
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long min = Long.MAX_VALUE;
        for(int i = 1; i<=100000; i++) {
            if(n%i==0) min = Math.min((long)Math.max(Math.log10(n/i)+1,Math.log10(i)+1),min);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    private static int[] p;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = i;
        }

        for (int i = 0; i < M; i++) {
            int X = sc.nextInt()-1;
            int Y = sc.nextInt()-1;
            int Z = sc.nextInt();
            unite(X, Y);
        }

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            set.add(root(i));
        }

        //System.out.println(Arrays.toString(p));
        System.out.println(set.size());
    }

    private static int root(int x) {
        if (p[x] == x) {
            return x;
        }

        p[x] = root(p[x]);

        return p[x];
    }

    private static void unite(int x, int y) {
        int rootX = root(x);
        int rootY = root(y);
        p[rootY] = rootX;
    }
}



Measured memory_bytes: 92068
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]
import math

X = int(input())
y = 0
m = 100

while m < X:
    m = math.floor(m * 1.01)
    y += 1

print(y)


Measured memory_bytes: 9184
LARGE = 10 ** 9 + 7


def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    z = (x + y) // 3
    if x < z or y < z:
        return 0
    # zC(x-z)
    r = min(x - z, y - z)
    res = 1
    for i in range(r):
        res *= z - i
        res *= pow(i + 1, LARGE - 2, LARGE)
        res %= LARGE
    return res


def main():
    x, y = map(int, input().split())
    res = solve(x, y)
    print(res)


def test():
    assert solve(3, 3) == 2
    assert solve(2, 2) == 0
    assert solve(999999, 999999) == 151840682


if __name__ == "__main__":
    # test()
    main()


Measured memory_bytes: 41196
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    typedef long long ll;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define take(a,n) f(i,0,n)cin>>a[i];
    #define show(a,n) f(i,0,n){cout<<a[i]<<" ";}
    #define ashow(a)  for(auto i:a)cout<<i<<" ";
    #define khtm     cout<<endl;
    #define all(s) s.begin(),s.end()
    #define len(a) a.length()
    #define INF 1e18
    #define MAXN 2000009
    const double pi=3.14159265358979323;
    const int mod=1e9+7;
    int ng(int n){
      int i=0;
      while(n>pow(2,i))
        i++;
      i--;
      return pow(2,i)-1-n;

    }
     signed main() {
     // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n,k,x=0,y=0;
        int mx=-1,mi=INF,mn=INF;
        int tm=0;
        vector<int>ans;
        string s;

     cin>>n>>k;

        x=(k-2*n)/2;
        y=(4*n-k)/2;
        if(x>=0&&y>=0&&(k-2*n)%2==0&&(4*n-k)%2==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
         


        }


 }

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string o,e;
    cin >> o >> e;
    if(o.length()-e.length()){
        REP(i,o.length()-1){
            cout << o[i] << e[i];
        }
        cout << o[o.length()-1] << endl;
    }
    else{
        REP(i,o.length()){
            cout << o[i] << e[i];
        }
        cout<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())

F = []
for _ in range(N):
    F.append(list(map(int,input().split())))

P = []
for _ in range(N):
    P.append(list(map(int, input().split())))

ans = -10 ** 12
for i in range(1, 1024):
    chk = list(str(bin(i+1024)))[3:]
    profit = 0
    for n in range(N):
        total = 0
        for j, c in enumerate(chk):
            if c == "1":
                total += F[n][j]
        profit += P[n][total]
    if profit > ans:
        ans = profit

print(ans)


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  string a, b;
  cin >> a >> b;

  if(a == b) {
    cout << "EQUAL" << endl;
    return 0;
  }

  if(a.length() > b.length()) {
    cout << "GREATER" << endl;
    return 0;
  }else if(a.length() < b.length()) {
    cout << "LESS" << endl;
    return 0;
  }

  rep(i, 0, a.length()) {
    if(a[i] > b[i]) {
      cout << "GREATER" << endl;
      return 0;
    }else {
      cout << "LESS" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
"use strict";
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var leng = 0, nextV = 0, day = 0, takeday = -1;
var score = 0;

const INF = 1e9;
var V; //200-400
var E; //1.5V-2V
var dist;
var directDist;
var e;
var f;
var tmax; //10000
var tmax2;
const has = new Set();
var orderTime = xArray("[]",V);
const item = [];
const out = [];

var cx = 0;
function next(){return +item[cx++];}

function deliver(){
  if(has.size === 0){
    if(nextV === 0)return -2;
    return minPath(0);
  }
  var maxid = -1, max = 0;
  for(var v of has){
    if(max < orderTime[v].length)
    if(dist[nextV][v] <= tmax-day){
      maxid = v, max = orderTime[v].length;
    }
  }
  if(maxid === -1)return -2;
  return minPath(maxid);
}

function minPath(to){
  for(var v of e[nextV]){
    if(dist[nextV][to] === directDist[nextV][v]+dist[v][to]){
      leng = dist[nextV][v]-1;
      return nextV = v;
    }
  }
  return -2;
}

function solve(){
  if(leng){
    leng--;
    return nextV;
  }
  if(nextV === 0)take();
  else give();
  return deliver();
}

function take(){
  while(takeday < day){
    takeday++;
    var n = next();
    for(var i = 0; i < n; i++){
      var id = next()-1, d = next()-1;
      has.add(d);
      orderTime[d].push(takeday);
    }
  }
}

function give(){
  has.delete(nextV);
  while(orderTime[nextV].length){
    var t = day - orderTime[nextV].pop();
    score += tmax2 - t*t;
  }
}

const rl=require("readline").createInterface(process.stdin,process.stdout);
const g=(function*(){
  const gets=()=>rl.once("line",s=>g.next(s));
  var V = yield gets();
  V = V.split(" "); E = +V[1], V = +V[0];
  dist = xArray(INF,V,V);
  directDist = xArray(INF,V,V);
  e = xArray("[]",V);
  for(var i = 0; i < V; i++)dist[i][i] = 0;
  for(var i = 0; i < E; i++){
    var t = (yield gets()).split(" ");
    var v1 = t[0]-1, v2 = t[1]-1, d = +t[2];
    dist[v1][v2] = dist[v2][v1] = directDist[v1][v2] = directDist[v2][v1] = d;
    e[v1].push(v2);
    e[v2].push(v1);
  }
  for(var k = 0; k < V; k++)
  for(var i = 0; i < V; i++)
  for(var j = 0; j < V; j++){
    if(dist[i][k]+dist[k][j]<dist[i][j])dist[i][j]=dist[i][k]+dist[k][j];
  }
  f = (yield gets()).split(" ").map(a=>+a);
  tmax = +(yield gets()); //10000
  tmax2 = tmax*tmax;
  orderTime = xArray("[]",V);

  for(; day < tmax; day++){
    var t = +(yield gets());
    item.push(t);
    for(var i = 0; i < t; i++){
      var u = (yield gets()).split(" ").map(a=>+a);
      item.push(u[0],u[1]);
    }
    t = +(yield gets());
    for(var i = 0; i < t; i++){
      var u = yield gets();
    }

    out[day] = solve()+1;
    console.log(out[day]);

    t = yield gets();
    if(t[0] !== "O")return;
    t = +(yield gets());
    for(var i = 0; i < t; i++){
      var u = yield gets();
    }
  }
})();
g.next();

Measured memory_bytes: 28896
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll dp[202][101010];
ll mod = 1000000007;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, X;
	cin >> N >> X;
	vector<int>S(N);
	for (int i = 0; i < N; i++)cin >> S[i];
	sort(all(S));

	for (int i = 0; i <= X; i++)dp[1][i] = i % S[0];
	for (int i = 2; i <= N; i++)for (int j = 0; j < 101010; j++) {
		dp[i][j] = dp[i - 1][j%S[i - 1]] + ((ll)i - 1LL)*dp[i-1][j];
		dp[i][j] %= mod;
	}
	puts(dp[N][X]);
	return 0;
}



Measured memory_bytes: 158080
def bmi(a):
	return a[0], abs(22-a[2]/((a[1]/100.0)**2))
	
while 1:
	n=input()
	if n==0:break
	print sorted(sorted([bmi(map(int,raw_input().split())) for i in range(n)]),key=lambda x:x[1])[0][0]

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;

int n, m;

int main()
{
	cin >> n >> m;
	int k = m / n;
	for (int i = k; i; i -- )
		if (m % i == 0)
		{
			cout << i << endl;
			return 0;
		}
    return 0;
}

Measured memory_bytes: 256
//ICPC2014 problem B
#include<stdio.h>

int main()
{
	int i,j,k,l;
	int h;
	int mat[10][5];
	int cnt;
	while(1){
		scanf("%d",&h);
		if( h==0 ) break;
		for( i=0 ; i<h ; i++ ){
			scanf("%d %d %d %d %d",&mat[i][0],&mat[i][1],&mat[i][2],&mat[i][3],&mat[i][4]);
		}
		int sum = 0;
		int flag = 1;
		while(flag==1){
		flag = 0;
		for( i=0 ; i<h ; i++ ){
			for( j=0 ; j<3 ; j++){
				cnt = 1;
				for( k=j+1 ; k<5; k++){
					if( mat[i][j] == mat[i][k] && mat[i][j] != 0 ){
						cnt++;
					}else if( cnt >= 3 ){
						sum += cnt*mat[i][j];
						for( l=j;l<(j+cnt);l++ ){
							mat[i][l] = 0;
						}
						flag = 1;
						break;
					}else{
						cnt=0;
						break;
					}
					if( mat[i][j] == mat[i][k] && k==4 && cnt >= 3 && mat[i][j] != 0){
						sum+= cnt * mat[i][j];
						for( l=j;l<(j+cnt);l++ ){
							mat[i][l] = 0;
						}
						flag = 1;
					}
				}
			}
		}
		//石を下に落とす作業
		for(k=0;k<h;k++){
			for( i=h-1 ; i > 0 ; i-- ){
					for( j=0;j<5;j++){
						if( mat[i][j] == 0 ){
							mat[i][j] = mat[i-1][j];
							mat[i-1][j] = 0;
						}
					}
				}
			}
			
		}
		printf("%d\n",sum);
							
	}
	return 0;
}


Measured memory_bytes: 2036
N = int(input())
S = [[0]*3 for i in range(N)] 

for i in range(N):
   a,b = input().split()
   S[i][0] = a
   S[i][1] = int(b)*(-1)
   S[i][2] = i+1

S.sort()

l = []
for i in range(N):
   l.append(str(S[i][2]))

ans = "\n".join(l)
print(ans)

Measured memory_bytes: 38256
import sys
def input():
    return sys.stdin.readline()[:-1]

def check(num,s):
    curr = 0
    for k in range(len(s)):
        if num[curr] == s[k]:
            curr += 1
            if curr == 3:
                return True
    return False

def main():
    N = int(input())
    S = input()
    ans = 0
    for k in range(1000):
        t = str(k).zfill(3)
        if check(t,S) == True:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=-1+(1LL<<61);
const LL p=7+1e9;

int main(){
	int N;
	string s;
	cin >> N;
	cin >> s;
	int ans=s.size();
	REP(i,s.size()){
		if(i && s[i]=='x' && s[i-1]=='x'){
			ans=i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string s;
  cin >> s;
  string tmp = "AB";
  int cnt = 0;
  
  for (int i = 0; i < s.size(); i++) {
    
    for (int j = 1; j <= s.size(); j++) {
      
      if (s.substr(i, j) != tmp) {
        cnt++;
        tmp = s.substr(i, j);
        i = i+j-1;
        break;
      }
    }
  }
  
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//Tariquzzaman Faisal
//_Faisal101_
//IUT_CSE'19
//190041101
 
#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<climits>
#include<cmath>
#include<iterator>
#include<set>
#define fileOut freopen("out.txt","w",stdout)
#define fileIn freopen("in.txt","r",stdout)
#define testcases ll TC,T; cin >> TC; for(T=1; T<=TC; T++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INFLL 9223372036854775807
#define INF 2147483647
#define pi acos(-1.0)
#define ll long long
#define endll printf("\n")
#define CASE printf("Case %lld: ",T)
#define ff first
#define ss second
#define mem(ara,n) memset(ara,n,sizeof ara)
#define ull unsigned long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mid3(a,b,c) min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define endl '\n'
#define ld long double
 
 
using namespace std;


int main(){
    ll n, x;
    cin >> n;
    ll counter = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        if(x != i+1){
            counter++;
        }
    }
    if(counter <= 2){
        cout<<"YES"<<endl;
    }
    else{
        cout <<"NO" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
n = int(input())
h = [int(i) for i in input().split()] 
dp = [10**10]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13976
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}};

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

const int INF = 1e9;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N;
    while(cin >> N && N) {
        vector<string> city(N);
        for(auto& x : city) cin >> x;

        vector<vector<int>> str_comp(N, vector<int>(N, 0));
        for(int i : _in(N)) for(int j : _in(N)) if(i != j) {
            str_comp[i][j] = city[j].size();
            for(int len : _in(min(city[i].size(), city[j].size()), 0))
              if(city[j].substr(0, len) == city[i].substr(city[i].size() - len, len)) {
                  str_comp[i][j] -= len;
                  break;
              }
            
            if(city[i].size() >= city[j].size())
              for(int s : _in(city[i].size() - city[j].size()))
                if(city[i].substr(s, city[j].size()) == city[j]) {
                    str_comp[i][j] = 0;
                    break;
                }
        }
        
        vector<vector<int>> dp(1 << N, vector<int>(N, INF));
        for(int i : _in(N)) dp[1 << i][i] = city[i].size();
        for(int S : _in(1 << N)) for(int i : _in(N))
          if(S & (1 << i)) for(int j : _in(N)) if(!(S & (1 << j))) {
              if(str_comp[i][j] == 0) 
                dp[S | (1 << j)][i] = min(dp[S | (1 << j)][i], dp[S][i]);
              else
                dp[S | (1 << j)][j] = min(dp[S | (1 << j)][j], dp[S][i] + str_comp[i][j]);
          }

        int S = (1 << N) - 1;
        cout << *min_element(dp[S].begin(), dp[S].end()) << endl;
    }
    return 0;
}

Measured memory_bytes: 4364
m = {}
n = int(input())
prev = ""
ok = True
for i in range(n):
  s = input()
  if i != 0:
    if prev[-1] != s[0]:
      ok = False
  if s in m:
    ok = False
  prev = s
  m[s] = 1
print("Yes" if ok else "No")
  

Measured memory_bytes: 3060
def main():
    N = input()
    n = len(N) - 1
    if N[n] == "2" or N[n] == "4" or N[n] == "5" or N[n] == "7" or N[n] == "9":
        print("hon")
    elif N[n] == "3":
        print("bon")
    else:
        print("pon")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
   int x;
   cin>>x;
   if(x==0)
   {
       cout<<1<<endl;
   }
   else
   {
       cout<<0<<endl;
   }
    return 0;
}



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

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

    bool f = true;
    for(int i=0; i<2; i++){
        for(int j=i+1; j<3; j++){
            for(int k=0; k<2; k++){
                for(int l=k+1; l<3; l++){
                    if(c[i][k] - c[i][l] != c[j][k] - c[j][l]
                       || c[i][k] - c[j][k] != c[i][l] - c[j][l]){
                        f = false;
                    }
                }
            }       
        }
    }
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  
    return 0;
}


Measured memory_bytes: 256
// atcoder/abc052/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s;
  while (cin >> n >> s) {
    int mx = 0;
    int x = 0;
    each (c, s) {
      if (c == 'I') ++x;
      else --x;
      setmax(mx, x);
    }
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  if(N < 1200) cout << "ABC" << endl;
  else if(1199 < N && N < 2800) cout << "ARC"  << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int N, C;
int D[100][100];
int c[1000][1000];
int d[3][100];

int main(int argc, char** argv) {
    cin >> N >> C;
    cout << max(N * C, max(N - C, N + C)) << endl;
}

Measured memory_bytes: 256
n=int(input())
li=["AC","WA","TLE","RE"]
out=[0]*4
for i in range(n):
  x=input()
  for (j,k)in zip(range(4),li):
    if x==k:
      out[j]+=1
      break
for (x,y)in zip(li,out):
  print("{} x {}".format(x,y))

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n, y;
	cin >> n >> y;

	int num[3] = {-1, -1, -1};
	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < (n + 1) - i; j++) {
			ll sum = i * 1000 + j * 5000 + (n - (i + j)) * 10000;
			if (sum == y) {
				num[0] = i;
				num[1] = j;
				num[2] = n - (i + j);
				i = n + 1;
				break;
			}
		}
	}

	cout << num[2] << " " << num[1] << " " << num[0] << endl;
	return 0;
}


Measured memory_bytes: 256