akhauriyash/Code-Regression huggingface dataset:
N=int(input())
p=list(map(int, input().split()))

q=[i for i in range(1, N+1)]

count = 0
for n in range(N):
    if p[n] != q[n]:
        count += 1
if count==0 or count==2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
	int len;
	string s;
	cin >> s;
	
	len = s.length();

	cout << s[0] << len-2 << s[len-1] << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
v=list(map(int,input().split()))

a=Counter(v[::2]).most_common(2)
b=Counter(v[1::2]).most_common(2)

a.append([0,0])
b.append([0,0])

if a[0][0]!=b[0][0]:
      print(n-(a[0][1]+b[0][1]))
else:
      print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

Measured memory_bytes: 15588
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
 int x,y;
  cin>>x>>y;
  rep(i,x+1){
    if(2*i+4*(x-i)==y){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
return 0;
}

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

int main(){
    int n;
    long long a;
    long long minValue = 1000000;
    long long maxValue = -1000000;
    long long sum=0;
    
    cin >> n;
    
    for(int i=0; i<n ; i++){
        cin >>a;
        if(a<minValue) minValue=a;
        if(a>maxValue) maxValue=a;
        sum+=a;
    }
    
    cout << minValue << " " << maxValue << " " << sum << endl;

    return 0;
}


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

int main(void){
    int x,y,z;
    cin >> x;
    cin >> y;
    cin >> z;
    if(x > y){
        int temp = x;
        x = y;
        y = temp;
    }if(y > z){
        int temp = y;
        y = z;
        z = temp;
    }if(x > y){
        int temp = x;
        x = y;
        y = temp;
    }
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true){
            String str = sc.nextLine();//先にstring変換

            if(str.equals("0")){//0の時ここ大事んご
                break;
            }
            
            else{
                int sum = 0;

                for(int i = 0; i < str.length(); i++){
                    sum += Character.getNumericValue(str.charAt(i));
                }
                System.out.println(sum);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26476
#include <bits/stdc++.h>
#define fr(a, b, c) for(int a = b, __ = c; a < __; a++)
#define dbg(x) cerr << ">>>>> " << x << endl;
#define _ << " , " <<

#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef long long ll;
const ll inf = ll(1e9) + 7;
const int ms = 1111111;

int rt[ms];
ii x[ms];
ii y[ms];
iii v[2*ms];

void init(int n){
	fr(i, 0, n+1)
		rt[i] = i;
}

int root(int a){
	if(rt[a] == a)
		return a;
	return rt[a] = root(rt[a]);
}

void conn(int a, int b){
	// dbg(a _ b)
	a = root(a), b = root(b);
	if(a == b)
		return;
	rt[a] = b;
}

bool check(int a, int b){
	return root(a) == root(b);
}


int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	fr(i, 0, n){
		int a, b;
		cin >> a >> b;
		x[i] = ii(a, i);
		y[i] = ii(b, i);
	}

	sort(x, x+n);
	sort(y, y+n);

	ll ans = 0;
	init(n);
	fr(i, 0, n-1){
		v[i] = iii(x[i+1].X - x[i].X, ii(x[i].Y, x[i+1].Y));
	}
	fr(i, 0, n-1){
		v[n-1+i] = iii(y[i+1].X - y[i].X, ii(y[i].Y, y[i+1].Y));
	}
	sort(v, v + 2*(n-1));
	fr(k, 0, 2*(n-1)){
		ii a = v[k].Y;
		if(!check(a.X, a.Y)){
			ans += v[k].X;
			conn(a.X, a.Y);
		}
	} 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15360
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,a;
	cin>>n>>a;
	n%=500;
	if(n>a)cout<<"No";
	else cout<<"Yes";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
import numpy as np
from numba import njit

@njit
def f(A):
  N = len(A)
  cnt = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        cnt += (A[k] < A[i] + A[j])
  return cnt

N = int(input())
A = np.int32(input().split())
A.sort()
print(f(A))


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main() {

    int n;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(n - 1));

    rep(i, n) {
        rep(j, n - 1) {
            int c;
            cin >> c;
            c--;
            a[i][j] = c;
        }
        reverse(a[i].begin(), a[i].end());
    }

    vector<P> q;
    auto check = [&](int i) {
        if (a[i].size() == 0) return;
        int j = a[i].back();
        if (a[j].size() == 0) return;
        if (a[j].back() == i) {
            P p(i, j);
            if (p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };

    rep(i, n) {
        check(i);
    }

    int day = 0;
    while (q.size() > 0) {
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());
        vector<P> prevQ;
        swap(prevQ, q);

        for (P p : prevQ) {
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }

        for (P p : prevQ) {
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    rep(i, n) {
        if(a[i].size() != 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << day << endl;

}


Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>

#define MAX 100001

using namespace std;

int parent(int i){
    //int p = i / 2;
    
    return i/2;
}

int left(int i){
    //int l = 2*i;
    
    return 2 * i;
}

int right(int i){
    //int r = 2*i + 1;
    
    return 2 * i + 1;
}

int main(){
    int H;//ヒープのサイズ
    cin >> H;

    int A[MAX];
    for(int i = 1; i<=H; i++){
        cin >> A[i];
    }
    
    for(int j=1; j<=H;j++){
        
        /*int pk = parent(j);
        int lk = left(j);
        int rk = right(j);*/
        
        cout << "node " << j<<": key = " << A[j] << ", ";
        
        if(parent(j) >= 1){
            cout << "parent key = " << A[parent(j)] << ", ";
        }
        
        if(left(j) <= H){
            cout << "left key = " << A[left(j)] <<", ";
        }
        
        if(right(j) <= H){
            cout << "right key = " << A[right(j)] << ", ";
        }
        
        cout << endl;
    }
    
    return 0;
    
    
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,m,a[maxn],mx;
int main() {
	//freopen("1.txt","r",stdin);
	read(m); read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<n;i++) mx=max(mx,a[i+1]-a[i]);
	mx=max(mx,m-a[n]+a[1]);
	printf("%d\n",m-mx);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 1024
#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 <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
ll tmp[101010];
int main() {
	cin>>N>>A>>B;
	cout<<min(A,B)<<" "<<max(0ll,A+B-N)<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for (int i = 0;i < N;i++) {
    int a,b;
    cin >> a >> b;
    sum += b;
    sum -= a;
    sum++;
  }
  
  cout << sum << endl;


}


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

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

  vector<int> A(N);

  rep(i, N) cin >> A[i];
  cout << (N - 1) / (K - 1) + min(1, (N - 1) % (K - 1)) << endl;
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[100100][13]; // i桁目まで見て、余りがjとなる場合の数

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  // 初期化: 0桁目までで余り0となるのは1通り
  // 1桁目の値がnumの時、余りがnumとなるのが+1通り、となるようにするにはdp[0][0]=1と初期化する必要がある
  dp[0][0]=1;
  rep(i,n){
    if(s[i]!='?'){
      ll num=s[i]-'0';
      // i-1桁目までで余りがjとなる通り数から、i桁目がnumのときの場合へ遷移する
      rep(j,13){
        ll rem=(j*10+num)%13;
        (dp[i+1][rem]+=dp[i][j])%=MOD;
      }
    }else{
      // s[i]=='?'なら、numは0~10の全ての場合を数える
      rep(num,10){
        rep(j,13){
          ll rem=(j*10+num)%13;
          (dp[i+1][rem]+=dp[i][j])%=MOD;
        }
      }
    }
  }
  
  cout<<dp[n][5]<<endl;
  
}

Measured memory_bytes: 10704
#include<stdio.h>

int main(){
  int a,b,c,d,n,i;
  char op[3];
  scanf("%d",&n);
  d=n%10;
  n/=10;
  c=n%10;
  n/=10;
  b=n%10;
  a=n/10;
  for(i=0;i<8;i++){
    n=a;
    if(i%2==0){
      op[2]='-';
      n-=d;
    }
    else{
      op[2]='+';
      n+=d;
    }
     if(i/2%2==0){
      op[1]='-';
      n-=c;
    }
    else{
      op[1]='+';
      n+=c;
    }
    if(i/2/2%2==0){
      op[0]='-';
      n-=b;
    }
    else{
      op[0]='+';
      n+=b;
    }
    if(n==7){
      printf("%d%c%d%c%d%c%d=7\n",a,op[0],b,op[1],c,op[2],d);
      break;
    }
  }
  return 0;
}

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

int main() {
    string s;
    cin >> s;

    if(s[0] == s[1]) {
        cout << "1 2" << endl;
        return 0;
    }
    
    char prev2 = s[0];
    char prev1 = s[1];
    for(int i=2; i<s.size(); ++i) {
        if(s[i] == prev1) {
            cout << i << " " << i+1 << endl;
            return 0;
        } else if(s[i] == prev2) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
        prev2 = prev1;
        prev1 = s[i];
    }
    
    cout << "-1 -1" << endl;
    return 0;
}

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vp;

ll dp[110][100100];
ll pesos[110];
ll costo[110];

int main(){
	int n, w;
	sii(n, w);

	for(int i = 1; i <= n; i++){
		sl(pesos[i]);
		sl(costo[i]);
	}

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 100000; j++){
			ll ans = 0;
			ans = dp[i-1][j];
			if(j-pesos[i] >= 0)
				ans = max(ans, costo[i] + dp[i-1][j-pesos[i]]);
			dp[i][j] = ans;
		}
	}
	printf("%lld\n", dp[n][w]);
    return 0;
}

Measured memory_bytes: 82028
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

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 facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}




int main() {
    ll n;
    cin>>n;
    vector<ll>a(n);
    ll SUM=0;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        SUM+=a.at(i);
    }
    vector<ll>b(n);
    b.at(0)=a.at(0);
    for(ll i=1;i<n;i++){
        b.at(i)=b.at(i-1)+a.at(i);
    }
    ll MIN=SUM+100;
    for(ll i=0;i<n;i++){
        MIN=min(MIN, abs(b.at(i)-(SUM-b.at(i))));
    }
    cout<<MIN<<endl;


    return 0;
}

Measured memory_bytes: 3328
from sets import Set

def solve():
	n, m = map(int, raw_input().split())
	to1 = Set()
	toN = Set()

	for i in range(m):
		x, y = map(int, raw_input().split())
		if x == 1:
			to1.add(y)
		if x == n:
			toN.add(y)
		if y == 1:
			to1.add(x)
		if y == n:
			toN.add(x)

	for i in range(n):
		if i in to1 and i in toN:
			print "POSSIBLE"
			return
			
	print "IMPOSSIBLE"

solve()

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

using namespace std;

int solve[100010];
int pan[100010];

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

    int cor = 0;
    int pa = 0;
    for(int i=0;i<m;i++){
        int p;
        string s;
        cin >>p>>s;
        if(s == "AC"){
            if(!solve[p]){
                solve[p] = 1;
            }
        }
        else{
            if(!solve[p]){
                pan[p]++;
            }
        }
    }

    for(int i=1;i<=n;i++){
        if(solve[i]){
            cor++;
            pa+=pan[i];
        }
    }

    cout << cor<<" "<<pa<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		A[i]=a+b;
		ret+=a;
	}
	sort(A,A+n);
	int l=0,r=n-1;
	for(int i=1;i<n;i+=2) ret-=A[n-i-1];
	printf("%lld\n",ret);
	return 0;
}


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

const int N = 1e5 + 5;

int n, a[N];
int amt[N][2];
map<int, int> cmp;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

	cin >> n;

	for(int i = 0; i < n; i++) {
		cin >> a[i];
		cmp[a[i]] = 0;
	}

	int nums = 0;
	for(auto &v : cmp) {
		v.second = nums++;
	}

	for(int i = 0; i < n; i++) {
		a[i] = cmp[a[i]];
		amt[a[i]][i & 1]++;
	}

	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(amt[a[i]][i & 1] > 0) {
			amt[a[i]][i & 1]--;
		}
		else {
			ans++;
		}
	}

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

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

#define INF 1000000000
#define MOD 1000000007

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

int main(){
    int N, T, c[100], t[100];
    cin >> N >> T;
    for(int i=0;i<N;i++)    cin >> c[i] >> t[i];
    
    int mini = INF;
    for(int i=0;i<N;i++){
        if(T < t[i])    continue;
        mini = min(mini, c[i]);
    }
    
    if(mini != INF)  cout << mini << endl;
    else            cout << "TLE" << endl;
}

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

int main(void) {
    int X,Y;
    cin >> X >> Y;

    int came,turu;
    for(int i=0; i<=X; i++){  

      turu = i;
      came = X-turu;

      if(Y==turu*2+came*4){
        cout << "Yes" << endl;
        return 0;

      }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3640
defmodule Main do
  def main do
    [a, b] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    if a == b do 
    IO.puts("Yes") 
    else 
    IO.puts("No") 
    end
  end
end


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

int main(){
  string s, sub;
  int i, half;
  cin >> s;
  
  for (i=1; i<s.size(); i++) 
  {
    sub = s.substr(0, s.size() - i);
    if (sub.size()%2 == 0) 
    {
      half = sub.size()/2;
      if (sub.substr(0, half) == sub.substr(half, sub.size()))
      {
        cout << sub.size() << endl;
        break;
      }
    }
  }
  
  return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
typedef long long int ll;
typedef unsigned long long int llt;
#define vector<int> vi
#define pair<int, int> pii
using namespace std;
int main()
{
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
    return 0;
}


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

using namespace std;

int Month;
int Day;

int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int ans[12][31];
int d;
int main()
{   
    
  scanf("%d %d",&d,&Month);
  double a = d*Month/3.305785;
  printf("%.6f",a);
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
#define lg __int128
using namespace std;
const int N=105,mo=998244353;
struct ha_lg{
	size_t operator()(const lg &a)const{return a;}
};
unordered_map<lg,int,ha_lg>f[N];
lg n;
string s;
int get(lg s,int n){
	if(f[n].count(s))return f[n][s];
	int su=(ll)get(s>>1,n-1)*((s&1)+1)%mo;
	fo(i,1,n/2){
		lg g=((lg)1<<i)-1,a=s&g;
		fo(j,2,n/i){
			a&=(s>>i*(j-1))&g;
			su=((ll)get(a,i)*get(s>>i*j,n-i*j)+su)%mo;
		}
	}
	return f[n][s]=su;
}
int main(){
	cin>>s;
	f[0][0]=1;
	f[1][0]=1;
	f[1][1]=2;
	fo(i,0,s.size()-1)n=n*2+s[i]-'0';
	cout<<get(n,s.size());
}

Measured memory_bytes: 4224
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
2 3 1"""
        output = """3 1 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5
1 2 3 4 5"""
        output = """1 2 3 4 5"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """8
8 2 7 3 4 5 6 1"""
        output = """8 2 4 5 6 7 3 1"""
        self.assertIO(input, output)
def resolve():
    N=int(input())
    A=[int(i) for i in input().split()]
    B=[[A[i],i+1] for i in range(N)]

    B.sort(key=lambda x: x[0])

    C=[str(i[1]) for i in B]
    print(" ".join(C))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 84840
N = $stdin.gets.to_i
A = $stdin.gets.split.map {|i| i.to_i }

M = 10 ** 9 + 7

sum = 0
asum = A.inject(0) {|r, a| r + a }
1.upto(N - 1) do |i|
  ai = A[i - 1]
  asum -= ai
  sum += ai * asum
  if sum >= M
    sum = sum % M
  end
end
puts sum


Measured memory_bytes: 33708
a = int(input())
ar = list(map(int,input().split(" ")))
f = 0
k = 0
for r in ar:
    if r % 4 == 0:
        f += 1
    if r % 2 == 1:
        k += 1
if k + f == a:
    if k <= f + 1:
        print("Yes")
    else:
        print("No")
else:
    if k <= f:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
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;}
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  a.pb(INF);
  for(int i=0;i<n;i++){
    if(a[i]==i+1){
      ans++;
      swap(a[i],a[i+1]);
    }
  }
  COUT(ans);
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ans1=0,ans2=0;
    
    for(int i=0;i<s.size();i++) {
        if (i%2==0){
            if (s[i]=='0')
                ans2++;
		    else 
                ans1++;
		} 
		else{
            if (s[i]=='0') 
                ans1++;
            else 
                ans2++;
        }
    }
    
    cout<<min(ans1,ans2)<<endl;
}

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

int main(){
  int h1,m1,h2,m2,k;
  int abs_hour,abs_min;
  int active_time;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  //cout << h1 << m1 << h2 << m2 << k;
  
  abs_hour = h2 - h1;
  abs_min = m2 - m1;
  
  active_time = abs_hour * 60 + abs_min;
  cout << active_time - k;
  return 0;
}

Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int n = nk[0], k = nk[1];
        var s = Console.ReadLine();
        int cnt = 1;
        long temp = 0;
        var list = new List<long>();
        long ans = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i] == s[i - 1]) cnt++;
            else
            {
                list.Add(cnt);
                cnt = 1;
            }
        }
        list.Add(cnt);
        int pin = 0;

        if (s[0] == '0')
        {
            k = k * 2;
            for (int i = 0; i < list.Count; i++)
            {
                temp += list[i];
                if (i % 2 == 1) ans = Math.Max(ans, temp);
                if (k <= 0)
                {
                    temp -= list[pin];
                    pin++;
                }
                else k--;
                if (i % 2 == 0) ans = Math.Max(ans, temp);
            }
        }
        else
        {
            k = k * 2 + 1;
            for (int i = 0; i < list.Count; i++)
            {
                temp += list[i];
                if (k <= 0 && i % 2 == 1)
                {
                    temp -= list[pin];
                    pin++;
                    temp -= list[pin];
                    pin++;
                }
                else k--;
                ans = Math.Max(ans, temp);
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13176
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    P, Q, R = map(int, input().split())
    print(P+Q+R-max(P,Q,R))

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc129","a",main)

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;




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;
}

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

const int inf=100000000;

int pownew(int m, int n) {
        if (n == 0) { return 1; }
        if (n % 2 == 0) { return pow(m*m, n/2); }
        return pow(m, n-1) * m;
    }

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

llong moda= 1000003;






int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    vector<string> ans;

    REP(i,ty-sy)
    {
        ans.push_back("U");
    }
    REP(i,tx-sx)
    {
        ans.push_back("R");
    }

    REP(i,ty-sy)
    {
        ans.push_back("D");
    }
    REP(i,tx-sx+1)
    {
        ans.push_back("L");
    }


    REP(i,ty-sy+1)
    {
        ans.push_back("U");
    }
    REP(i,tx-sx+1)
    {
        ans.push_back("R");
    }

    REP(i,1)
    {
        ans.push_back("D");
    }
    REP(i,1)
    {
        ans.push_back("R");
    }

    REP(i,ty-sy+1)
    {
        ans.push_back("D");
    }
    REP(i,tx-sx+1)
    {
        ans.push_back("L");
    }

    REP(i,1)
    {
        ans.push_back("U");
    }


    REP(j,ans.size())
    {
        cout<<ans[j];
    }
    cout<<endl;
    return  0;
}


Measured memory_bytes: 1152
#include<stdio.h>

int secsmall(int x, int y, int z) //is y second smallest
{
    if((y < x || y < z) && (y > x || y > z))
        return 1;
    else
        return 0;
}
int main()
{
    int n;
    scanf("%d", &n);
    int arr[25];
    for(int i=0; i<n; i++)
    {
        scanf("%d", &arr[i]);
    }
    int count=0;
    for(int i=0; i<=n-3; i++)
    {
        if(secsmall(arr[i], arr[i+1], arr[i+2])==1)
            count++;
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
arr=list(map(str,input()))
R=[]
L=[]
count=0
ans=[0]*len(arr)

kari="R"
for i in range(len(arr)):
    if arr[i]==kari:
      count+=1
    else:
        if kari=="R":
            R.append(count)
        else:
            L.append(count)
        kari=arr[i]
        count=1
L.append(count)

aa=0
for i in range(len(R)):
    a=R[i]+L[i]
    aa+=a
    if a%2==0:
        ans[aa-L[i]]=a//2
        ans[aa-L[i]-1]=a//2
    elif a%2==1 and L[i]%2==0:
        ans[aa-L[i]]=a//2
        ans[aa-L[i]-1]=a//2+1
    else:    
        ans[aa-L[i]]=a//2+1
        ans[aa-L[i]-1]=a//2
        
print(*ans)

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

#define min(a,b) ((a)>(b)?(b):(a))

long long n,m,i,a[111111][2];

int cmp(const long long *a,const long long *b){
  return *a-*b;
}

int main(){
  scanf("%lld%lld",&n,&m);
  for(i=0;i<n;i++){
    scanf("%lld%lld",&a[i][0],&a[i][1]);
  }
  qsort(a,n,sizeof(a[0]),cmp);
  long long ans=0;
  i=0;
  while(m>0){
    ans+=a[i][0]*min(a[i][1],m);
    m-=min(a[i][1],m);
    i++;
  }
  printf("%lld",ans);
}

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

int main() {
    int n; cin >> n;
    ll a, b;
    ll total = 0, mul, mul2;
    ll curr_a = 1, curr_b = 1;
    while(n--){
        cin >> a >> b;
        mul = curr_a / a;
        if( mul * a != curr_a) mul += 1;
        mul2 = curr_b / b;
        if(mul2 * b != curr_b) mul2+=1;
        mul = max(mul, mul2);
        curr_a = a * mul;
        curr_b = b * mul;
    }
    cout << curr_a + curr_b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli h,w;
lli t,s;
lli r;
lli ans;

int main(){
    cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    if(h > w) swap(h,w);
    lli i = 0;
    while((t+h)*3 < h*w) t += h,i++;
    r = h*w - t;
    while(s*2 < r) s += w-i;
    r -= s;
    //cout << r << " " << s << " " << t << endl;
    ans = max({abs(r-s),abs(s-t),abs(r-t)});
    i = 0;t = 0;s = 0;
    while(t*3 < h*w) t += h,i++;
    r = h*w - t;
    while(s*2 < r) s += w-i;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    i = 0;t = 0;s = 0;
    while((t+h)*3 < h*w) t += h,i++;
    r = h*w - t;
    while(s*2 < r) s += h;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    i = 0;t = 0;s = 0;
    while(t*3 < h*w) t += h,i++;
    r = h*w - t;
    while(s*2 < r) s += h;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    i = 0;t = 0;s = 0;
    while(t*3 < h*w) t += w,i++;
    r = h*w - t;
    while(s*2 < r) s += h-i;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    i = 0;t = 0;s = 0;
    while((t+w)*3 < h*w) t += w,i++;
    r = h*w - t;
    while(s*2 < r) s += h-i;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    i = 0;t = 0;s = 0;
    while(t*3 < h*w) t += w,i++;
    r = h*w - t;
    while(s*2 < r) s += w;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    i = 0;t = 0;s = 0;
    while((t+w)*3 < h*w) t += w,i++;
    r = h*w - t;
    while(s*2 < r) s += w;
    r -= s;
    ans = min(ans,max({abs(r-s),abs(s-t),abs(r-t)}));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MAX = 200000;

int main() {
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
template<typename T> istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec)	is >> x;
	return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
	os << "[";
	rep(i, vec.size())	os << (i ? ", " : "") << vec[i];
	os << "]";
	return os;
}
template<typename T> istream& operator >> (istream& is, pair<T, T>& p) {
	is >> p.first >> p.second;
	return is;
}
template<typename T> ostream& operator << (ostream& os, pair<T, T>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e9;
const ld infl = 1e100;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

vector<pii> path(3);

int main() {
	cin >> path;
	map<int, int> mp;
	for (auto it : path) {
		mp[it.first]++;
		mp[it.second]++;
	}
	map<int, int> mp2;
	srep(i, 1, 5) {
		mp2[mp[i]]++;
	}
	if (mp2[1] == 2 && mp2[2] == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

struct edge
{
  long long d;
  int a,b;
};

bool operator<(edge e1,edge e2)
{
  return e1.d>e2.d;
}

int rt(int *uf,int i)
{
  return uf[i]<0?i:uf[i]=rt(uf,uf[i]);
}

void con(int *uf,int a,int b)
{
  a=rt(uf,a);
  b=rt(uf,b);
  if(a!=b){
    if(-uf[a]<-uf[b]){
      uf[a]=b;
    }
    else if(-uf[a]>-uf[b]){
      uf[b]=a;
    }
    else{
      uf[a]=b;
      uf[b]--;
    }
  }
}


int main()
{
  int n,q;
  scanf("%d%d",&n,&q);
  priority_queue<edge> Q;
  for(int i=0;i<q;i++){
    int a,b;
    long long c;
    scanf("%d%d%lld",&a,&b,&c);
    edge e;
    e.a=a,e.b=b,e.d=c;
    Q.push(e);
    edge e2;
    e2.a=(a+1)%n,e2.b=b,e2.d=c+1;
    Q.push(e2);
  }
  long long A=0;
  static int uf[200000];
  for(int i=0;i<n;i++){
    uf[i]=-1;
  }
  int N=n;
  while(N>1){
    edge e=Q.top();
    Q.pop();
    int a=e.a,b=e.b;
    long long c=e.d;
    int r1=rt(uf,a),r2=rt(uf,b);
    //printf("%d %d %lld\n",a,b,c);
    if(r1!=r2){
      A+=c;
      N--;
      con(uf,r1,r2);
      edge ne;
      ne.d=c+2;
      ne.a=(a+1)%n;
      ne.b=(b+1)%n;
      Q.push(ne);
    }
  }
  printf("%lld\n",A);
  return 0;
}



Measured memory_bytes: 8684
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n"
//#pragma GCC optimize(2)
using namespace std;
const int N=1e3+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
int a,b;
char p[N][N];
int main(){Accel
	cin>>a>>b;
	FOR(i,1,100)
		FOR(j,1,100){
			if(i<=50)p[i][j]='.';
			else p[i][j]='#';
		}
	int x=100,y=1;
	FOR(j,1,a-1){
		p[x][y]='.';
		y+=2;
		if(y>100)x-=2,y=1;
	}
	x=1,y=1;
	FOR(j,1,b-1){
		p[x][y]='#';
		y+=2;
		if(y>100)x+=2,y=1;
	}
	cout<<100<<" "<<100<<endl;
	FOR(i,1,100){
		FOR(j,1,100)
			cout<<p[i][j];
		cout<<endl;
	}
 
}

Measured memory_bytes: 384
n,m = map(int, input().split())
l = list(map(int, input().split()))
g = l.copy()
while not any(x%2 for x in g): g = [x//2 for x in g]
if not all(x%2 for x in g): print(0); exit(0)
def gcd(a,b):
  while b: a,b = b,a%b
  return a
lcm = lambda a,b: a*b//gcd(a,b)
tot = 1
for x in l: tot = lcm(tot,x//2)
print((m//tot+1)//2)

Measured memory_bytes: 15916
#include <iostream>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while(true) {
		c -= b;
		if(c <= 0) {
			cout << "Yes\n";
			return 0;
		}
		a -= d;
		if(a <= 0) {
			cout << "No\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    while(1) {
        int h;
        int w;
        
        cin >> h >> w;
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    if (j % 2 == 0) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                } 
            } else {
                for (int j = 0; j < w; j++) {
                    if (j % 2 == 1) {
                        cout << "#";
                    } else {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


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

vector<int> factmod;
int modpower(int num, int mod, int to) {
  long ntemp = num;
  int ret = 1;
  for (int pow = 0; pow < 32; pow++) {
    if (to >> pow == 0) {
      return ret;
    }
    if ((to | 1 << pow) == to) {
      ret = (long)(ret * ntemp) % mod;
    }
    ntemp = (long)(ntemp * ntemp) % mod;
  }
  return ret;
}
int MOD = 1e9 + 7;
int modway(int r, int c) {
  int ret = ((long)factmod.at(r + c + 2) *
             modpower(factmod.at(r + 1), MOD, MOD - 2)) %
            MOD;
  ret = ((long)ret * modpower(factmod.at(c + 1), MOD, MOD - 2)) % MOD;
  return ret;
}

int main() {
  int r_1, c_1, r_2, c_2;
  cin >> r_1 >> c_1 >> r_2 >> c_2;
  int f_size = 2e6 + 3;
  factmod.resize(f_size);
  factmod.at(0) = 1;
  for (int f_i = 1; f_i < f_size; f_i++) {
    factmod.at(f_i) = ((long)factmod.at(f_i - 1) * f_i) % MOD;
  }
  cout << ((long)modway(r_2, c_2) + modway(r_1 - 1, c_1 - 1) + 2 * MOD -
           modway(r_2, c_1 - 1) - modway(r_1 - 1, c_2)) %
              MOD
       << endl;
}


Measured memory_bytes: 8064
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    A, B = input(), input()
    print("YES" if A == B[::-1] else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
N = int(input())
A = list(map(int, input().split()))
if A.count(0)>0:
  print(0)
else:
  ans = A[0]
  for i in range(N-1):
    ans *= A[i+1]
    if ans > 10**18:
      print('-1')
      exit()
  print(ans)


Measured memory_bytes: 21784
import fractions
A, B, C, D = map(int, input().split())
U = B - A + 1
S_c = B // C - (A-1) // C
S_d = B // D - (A-1) // D
S_cd = B // (C * D // fractions.gcd(C, D)) - ((A-1) // (C * D // fractions.gcd(C, D)))
print(U - S_c - S_d + S_cd)

Measured memory_bytes: 5048
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <cmath>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

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

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n;
    int a[MAX];
    int x[MAX];
    int y[MAX];
    cin >> n;
    rep(i, n){
        cin >> a[i];
        if(i == 0)x[i] = a[i];
        else x[i] = gcd(x[i-1], a[i]);
    }
    for(int i=n-1; i>=0; i--){
        if(i==n-1)y[i] = a[i];
        else y[i] = gcd(y[i+1], a[i]);
    }
    
    int ma = 0;
    rep(i, n){
        if(i==0){
            ma = max(ma, y[i+1]);
        }
        else if(i==n-1){
            ma = max(ma, x[i-1]);
        }
        else {
            ma = max(ma, gcd(x[i-1], y[i+1]));
        }
    }
    
    cout << ma << endl;
    
    return 0;
}


Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    p = -(-N // 2)
    print(p)




if __name__ == "__main__":
	main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long t = (2-N)*A + (N-2)*B + 1;
  if(t < 0) t = 0;
  cout << t << endl;
  return 0;
}

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

using namespace std;

int selectionSort(int *A, int n){
  int cnt=0;
  for(int i=0;i<n;i++){
    int minj = i;
    for(int j=i;j<n;j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(minj!=i){
      swap(A[minj],A[i]);
      cnt++;
    }

  }
  return cnt;
}
    

int main(){
  int n;
  cin >> n;
  int *a = new int [n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  int cnt = selectionSort(a, n);

  for(int i=0;i<n;i++){
    if(i!=0){cout<< " ";}
    cout << a[i];
  }
  cout << endl;

  cout << cnt << endl;
}
  

Measured memory_bytes: 1188
import math
pi = math.pi
rad = pi/180
a, b, C = map(float, input().split())
S = 0.5 * a * b * math.sin(C*rad)
L = a + b + math.sqrt(a**2 + b**2 -2*a*b*math.cos(C*rad))
h = abs(b*math.sin(C*rad))
print('{0:.5f}'.format(S))
print('{0:.5f}'.format(L))
print('{0:.5f}'.format(h))


Measured memory_bytes: 5692
A,B,C,D= map(int,input().split())
wflag = False

for count in range(0,1000):
    C = C-B
    if C <=0:
        wflag = True;
        break;
    A = A-D
    if A <=0:
        break;

if wflag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()==2)cout<<s<<endl;
	else{
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}
}

Measured memory_bytes: 256
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for k in range(N-2):
    for l in range(N-k-2):
#        print(k,l,bisect.bisect_left(L,L[-l-1]-L[k]+1))
        ans += min(N-k-l-2,N-bisect.bisect_left(L,L[-l-1]-L[k]+1)-l-1)
print(ans)


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

bool visited[200005];
vector<vector<int>> edge;
void dfs(int i){
	visited[i] = 1;
	for(int j = 0; j<edge[i].size();j++){
		if(!visited[edge[i][j]]){
			dfs(edge[i][j]);
		}
	}
}

int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	ll n,m,a,b;
	cin>>n>>m;
	edge.resize(n+1);
	for(int i = 0; i<m; i++){
		cin>>a>>b;
		edge[a].push_back(b);
	}
	for(int i = 0; i< edge[1].size();i++){
		for(int j = 0; j < edge[edge[1][i]].size();j++){
			if(edge[edge[1][i]][j] == n){
				cout<<"POSSIBLE\n";
				return 0;
			}
		}
	}

	cout<<"IMPOSSIBLE\n";
	

}

Measured memory_bytes: 11384
import itertools
import math
import fractions
import functools
import copy

a, b, h, m = map(int, input().split())

lo = 30*h + 0.5 * m
sh = 6 * m
do = min(lo - sh, 360 - (lo-sh))


ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(do)))
print(ans)

Measured memory_bytes: 91604