akhauriyash/Code-Regression huggingface dataset:
/******
	~site:    atcoder.jp
	~user:    Turkhuu
	~problem: AtCoder Beginner Contest 177 - A (abc177_a)
** **/

#include<bits/stdc++.h>

#define FFOR(i,s,e,k) for(int i=s;(k==1?i<=e:i>=e);i+=k)
#define FOR(i,n) FFOR(i,0,n-1,1)
#define FORR(i,s,e) FFOR(i,s,e,1)
#define ll long long
#define PQ priority_queue
#define pb push_back
#define ppb pop_back()
#define pp push
#define MIN(v) *min_element(v.begin(),v.end())
#define MAX(v) *max_element(v.begin(),v.end())
#define SORT(v) sort(v.begin(),v.end())
#define TROS(v) sort(v.rbegin(),v.rend())
#define CNT(v,x) count(v.begin(),v.end(),x)

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int d,t,s;
	cin>>d>>t>>s;
	cout<<(t*s>=d?"Yes":"No");
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int n,m;
int a[N];
set<int> s;
vector<int> c;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int u,v;scanf("%d%d",&u,&v);
        a[v]=max(a[v],u);s.insert(u);s.insert(v);
    }
    int ans = 0;
    for(auto it=s.begin();it!=s.end();it++) c.push_back(*it);
    int cur=0;
    for(int i=1;i<c.size();i++){
        if(!a[c[i]] || a[c[i]]<cur) continue;
        cur = c[i];ans++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 6012
n = int(input())
a = []
for i in range(n):
    x,y = map(int,input().split())
    a.append([x,y,x+y])
a.sort(key = lambda x:x[2])
ans = 0
for i in range(n):
    x = a.pop()
    if i %2==0:
        ans+=x[0]
    else:
        ans-=x[1]
print(ans)

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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i,j,k;
  bool s;
  int ans=0;
  vector<vector<int>> x(n,vector<int>(n-1,-1));
  vector<vector<int>> y(n,vector<int>(n-1,-1));
  for(i=0;i<n;i++)
  {
    cin>>a.at(i);
    for(j=0;j<a.at(i);j++)
    {
      cin>>x.at(i).at(j)>>y.at(i).at(j);
    }
  }
  for(i=0;i<(1<<n);i++)
  {
    s=false;
    for(j=0;j<n;j++)
    {
      if(i&(1<<j))
      {
        for(k=0;k<a.at(j);k++)
        {
          int ch=(1<<(x.at(j).at(k)-1))&i;
          if(ch>0)ch=1;
          if(ch!=y.at(j).at(k))
          {
            s=true;
            break;
          }
        }
      }
      if(s)break;
    }
    if(!s)
    {
      int kans=0;
      for(j=0;j<n;j++)
      {
        if((1<<j)&i)kans++;
      }
      if(ans<kans)ans=kans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
w_list = list(map(int, input().split()))
min_abs = float('inf')
for i in range(0, (n-1)):
  s1 = sum(w_list[0:i+1])
  s2 = sum(w_list[i+1:n])
  digit = abs(s1-s2)
  #print(w_list,s1,s2,digit)
  if digit < min_abs:
    min_abs = digit

print(min_abs)



 


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>

int main(){
  int a,a_max,sum,c;
  std::cin>>a;
  a_max=0;
  std::vector <int>b(a);
  for(int i=0;i<a;i++){
    std::cin>>b.at(i);
    a_max=std::max(a_max,b.at(i));
  }
  sum=a_max*a_max*a;
  for(int i=0;i<a_max;i++){
    for(int j=0;j<a;j++){
      c=c+(i+1-b.at(j))*(i+1-b.at(j));
    }
    if(sum>c){
      sum=c;
    }
    c=0;
  }
  std::cout<<sum<<std::endl;
}

  



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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,K;
	cin>>N>>K;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
    }
    sort(A.begin(),A.end());

    ll min_ans = -1e18;
    --min_ans;
    ll max_ans = 1e18;
    ll tmp_ans;
    ll tmp_s = 0;
    ll tmp_a;
    ll max_i,min_i,mid_i;
    ll tmp;
    ll border;
    ll debug = 0;
    // cout<<min_ans<<"\n";
    while(min_ans+1!=max_ans){
        tmp_ans = (max_ans + min_ans)/2;
        tmp_s = 0;
        rep(i,N){
            tmp_a = A[i];
            if(tmp_a>0){
                border = tmp_ans/tmp_a;
                while(border*tmp_a < tmp_ans) ++border;
                while(border*tmp_a > tmp_ans) --border;
                auto itr = upper_bound(A.begin(),A.end(),border);
                tmp_s += itr-A.begin();
                if(itr-A.begin()>i) tmp_s--;
            }else if(tmp_a==0){
                if(0<=tmp_ans){
                    tmp_s += N-1;
                }
            }else{    
                border = tmp_ans/tmp_a;
                while(border*tmp_a > tmp_ans) ++border;
                while(border*tmp_a <= tmp_ans) --border;
                auto itr = upper_bound(A.begin(),A.end(),border);
                tmp_s += N-(itr-A.begin());
                if(!(itr-A.begin()>i)) tmp_s--;
            }
        }
        // if(debug>55) cout<<tmp_s/2<<" "<< tmp_ans<<"\n";
        // cout<<tmp_s/2<<" "<< tmp_ans<<"\n";
        if(tmp_s/2 >=K){
            max_ans = tmp_ans;
        }else{
            min_ans = tmp_ans;
        }
        ++debug;
        
    }
    // cout<<debug<<"\n";
    // cout<<min_ans<<"\n";
    cout<<max_ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline

from heapq import heappop as hpp, heappush as hp
class MinCostFlowwithDijkstra:
    INF = 1<<31
    
    def __init__(self, N):
        self.N = N
        self.Edge = [[] for _ in range(N)]
    
    def add_edge(self, st, en, cap, cost):
        self.Edge[st].append([en, cap, cost, len(self.Edge[en])])
        self.Edge[en].append([st, 0, -cost, len(self.Edge[st])-1])
    
    def get_mf(self, so, si, fl):
        N = self.N
        INF = self.INF
        res = 0
        Pot = [0]*N
        geta = N
        
        
        prv = [None]*N
        prenum = [None]*N
        while fl:
            dist = [INF]*N
            dist[so] = 0
            Q = [so]
            
            while Q:
                cost, vn = divmod(hpp(Q), geta)
                if dist[vn] < cost:
                    continue
                
                for enum in range(len(self.Edge[vn])):
                    vf, cap, cost, _ = self.Edge[vn][enum]
                    cc = dist[vn] + cost - Pot[vn] + Pot[vf]
                    if cap > 0 and dist[vf] > cc:
                        dist[vf] = cc
                        prv[vf] = vn
                        prenum[vf] = enum
                        hp(Q, cc*geta + vf)
            
            if dist[si] == INF:
                return -1
            
            for i in range(N):
                Pot[i] -= dist[i]
            
            cfl = fl
            vf = si
            while vf != so:
                cfl = min(cfl, self.Edge[prv[vf]][prenum[vf]][1])
                vf = prv[vf]
            
            fl -= cfl
            res -= cfl*Pot[si]
            vf = si
            while vf != so:
                e = self.Edge[prv[vf]][prenum[vf]]
                e[1] -= cfl
                self.Edge[vf][e[3]][1] += cfl
                vf = prv[vf]
        return res

N, M, F = map(int, readline().split())
T = MinCostFlowwithDijkstra(N)
for _ in range(M):
    u, v, cap, cost = map(int, readline().split())
    T.add_edge(u, v, cap, cost)

print(T.get_mf(0, N-1, F))


Measured memory_bytes: 5940
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]

ans = [k-q]*n
for i in range(q):
  ans[a[i] - 1] += 1

for i in range(n):
  if ans[i] > 0:
    print("Yes")
  else:
    print("No")

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

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;
    vector<int> ans;
    reverse(all(S));
    int now   = 0;
    bool flag = false;
    while (now <= N && !flag) {
        flag = true;
        for (int i = M; i >= 1; --i) {
            if (now + i > N) continue;
            if (S[now + i] == '0') {
                now = now + i;
                ans.push_back(i);
                flag = false;
                break;
            }
        }
    }

    if(now != N){
        cout << -1 << endl;
        return 0;
    }

    reverse(all(ans));
    for(auto e:ans) cout << e << " ";
    cout << endl;
}

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

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
      cin >> A.at(i);
  }
  vector<int> B(N-1);
  for(int i = 0;i < N-1;i++){
      if(A.at(i) < A.at(i+1)) B.at(i) = 1;
      else if(A.at(i) == A.at(i+1)) B.at(i) = 0;
      else B.at(i) = -1; 
  }
  
  if(N == 1) cout << 1 <<endl;
  else {
      int a = B.at(0);
      int cnt = 1;
      for(int i = 1;i < N-1;i++){
          if(a == 0){
              a = B.at(i);
              cnt += 0;
          }
          if(B.at(i) != 0){
              if(a != B.at(i)){
                  cnt++;
                  a = 0;
              }
          }
      }
      cout << cnt <<endl;
  }
  
  
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX = 1e5+5;
LL MOD = 1e9+7;
vector<LL> GRAPH[MAX];
LL dp[MAX][2];
bool vis[MAX];

void DFS(LL x)
{
        vis[x] = true;
        if(GRAPH[x].size() == 1 && x != 1)
        {
                dp[x][0] = 1;
                dp[x][1] = 1;
                return;
        }
        LL white = 1,black = 1 , sum = 1;
        for(int i = 0 ; i < GRAPH[x].size() ; i++)
        {
                
                LL child = GRAPH[x][i];
                if(!vis[child])
                {
                        DFS(child);
                        white = (white%MOD * (dp[child][0])%MOD)%MOD;
                        black = (black%MOD * (dp[child][1])%MOD)%MOD;
                        sum = (sum%MOD *((dp[child][0]%MOD + dp[child][1]%MOD)%MOD))%MOD;
                }
        }
        //cout << x << " " << white << " " << black << endl;
                dp[x][1] = white;
                dp[x][0] = sum;
}

int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        LL n;
        cin >> n;
        LL m = n-1;
        memset(vis,false,sizeof(vis));
        while(m--)
        {
                LL x,y;
                cin >> x >> y;
                GRAPH[x].push_back(y);
                GRAPH[y].push_back(x);
        }
        DFS(1);
        // for(int i = 1 ; i <= n ; i++)
        // {
        //         cout << dp[i][0] << " " << dp[i][1] << endl;
        // }
        LL ans = (dp[1][0]%MOD + dp[1][1]%MOD)%MOD;
        if(ans < 0) ans += MOD;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 14336
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
long long A;
long long B;
long long N;
int main(){
  rd(A);
  rd(B);
  rd(N);
  chmin(N, B-1);
  wt_L((A*N)/B - A*(N/B));
  wt_L('\n');
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// ll A, B, N;
// {
//   rd(A,B,N);
//   N <?= B-1;
//   wt((A*N)/B - A*(N/B));
// }


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
#define P 924844033
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,p[N],size[N],fac[N],inv[N],r[N*3],f[N*3],g[N*3],ans[N],t;
struct data{int to,nxt;
}edge[N<<1];
void addedge(int x,int y){t++;edge[t].to=y,edge[t].nxt=p[x],p[x]=t;}
int ksm(int a,int k)
{
	int s=1;
	for (;k;k>>=1,a=1ll*a*a%P) if (k&1) s=1ll*s*a%P;
	return s;
}
int C(int n,int m){if (m>n) return 0;return 1ll*fac[n]*inv[m]%P*inv[n-m]%P;}
void dfs(int k,int from)
{
	size[k]=1;
	for (int i=p[k];i;i=edge[i].nxt)
	if (edge[i].to!=from)
	{
		dfs(edge[i].to,k);
		size[k]+=size[edge[i].to];
	}
}
void force()
{
	for (int k=1;k<=n;k++)
	{
		int ans=1ll*C(n,k)*(n+1)%P;
		for (int i=1;i<=n;i++)
		ans=((ans-C(size[i],k)-C(n-size[i],k))%P+P)%P;
		printf("%d\n",ans);
	}
}
void DFT(int *a,int n,int g)
{
	for (int i=0;i<n;i++) if (i<r[i]) swap(a[i],a[r[i]]);
	for (int i=2;i<=n;i<<=1)
	{
		int wn=ksm(g,(P-1)/i);
		for (int j=0;j<n;j+=i)
		{
			int w=1;
			for (int k=j;k<j+(i>>1);k++,w=1ll*w*wn%P)
			{
				int x=a[k],y=1ll*w*a[k+(i>>1)]%P;
				a[k]=(x+y)%P;a[k+(i>>1)]=(x-y+P)%P;
			}
		}
	}
}
void work()
{
	memset(f,0,sizeof(f));memset(g,0,sizeof(g));
	int t=1;while (t<=(n<<1)) t<<=1;
	for (int i=0;i<t;i++) r[i]=(r[i>>1]>>1)|(i&1)*(t>>1);
	//for (int i=1;i<=n;i++) f[n-size[i]]=(f[n-size[i]]+fac[size[i]])%P;
	//f[n-k]=Σrevfac[n-size[i]]*inv[size[i]-k]
	//f[n-k]=Σg[n-i]*inv[i-k] 
	for (int i=1;i<=n;i++) f[size[i]]=(f[size[i]]+fac[size[i]])%P;
	reverse(f,f+n+1);
	for (int i=0;i<=n;i++) g[i]=inv[i];
	DFT(f,t,5),DFT(g,t,5);
	for (int i=0;i<t;i++) f[i]=1ll*f[i]*g[i]%P;
	DFT(f,t,ksm(5,P-2));
	reverse(f,f+n+1);
	int u=ksm(t,P-2);
	for (int i=1;i<=n;i++) ans[i]=(ans[i]-1ll*f[i]*u%P*inv[i]%P+P)%P;
}
int main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y),addedge(y,x);
	}
	dfs(1,1);
	fac[0]=1;for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%P;
	inv[0]=inv[1]=1;for (int i=2;i<=n;i++) inv[i]=P-1ll*(P/i)*inv[P%i]%P;
	for (int i=2;i<=n;i++) inv[i]=1ll*inv[i-1]*inv[i]%P;
	//force();
	for (int i=1;i<=n;i++) ans[i]=1ll*C(n,i)*(n+1)%P;
	work();
	for (int i=1;i<=n;i++) size[i]=n-size[i];
	work();
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 24192
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int f=0,x=1;char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')x=-1;ch=getchar();
	}
	while(ch>='0'&&ch<='9')f=(f<<1)+(f<<3)+ch-'0',ch=getchar();
	return f*x;
} 
int a,b,c;
int main()
{
	a=read();b=read();c=read();
	int x=b/a;
	x=min(c,x);
	printf("%d\n",x);
	return 0;
}

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

int main() {
    map<int, int> mp;
    for (int i = 0; i < 3; ++i) {
        int a;  cin >> a;
        ++mp[a];
    }
    cout << (mp.size() == 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
s = list(input())
while s:
    if ''.join(s[-5:]) == 'erase' or ''.join(s[-5:]) == 'dream':
        for i in range(5):
            s.pop()
    elif ''.join(s[-6:]) == 'eraser':
        for i in range(6):
            s.pop()
    elif ''.join(s[-7:]) == 'dreamer':
        for i in range(7):
            s.pop()
    else:
        print('NO')
        exit()
    
    if len(s) == 0:
        print('YES')
        exit()

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

void f(stringstream &ss, int r, int &j, int &l) {
    int s = abs(r);
    while(s < j)
        ss << --j << " 0\n", l++;
    while(s > j)
        ss << ++j << " 0\n", l++;
    if(r < 0)
        ss << s << " 1\n"
           << s - 1 << " 1\n"
           << s - 1 << " 0\n",
            j = s - 1, l += 3;
    else
        ss << s << " 1\n"
           << s + 1 << " 1\n"
           << s + 1 << " 0\n",
            j = s + 1, l += 3;
}
vector<int> g(int k) {
    int i = 0;
    while(!(k & 1 << i))
        i++;
    vector<int> v;
    v.push_back(i);
    if(k == 1 << i)
        return v;
    auto w = g(k ^ 1 << i);
    v.insert(v.end(), w.begin(), w.end());
    v.push_back(-1 - i);
    for(int &l : w)
        l = -1 - l;
    reverse(w.begin(), w.end());
    v.insert(v.end(), w.begin(), w.end());
    return v;
}
int main() {
    int n;
    string a;
    cin >> n >> a;
    vector<int> b;
    for(int i = 0; i < 1 << n; i++) {
        int x = 0;
        for(int &k : b) {
            if((k & i) == k) {
                if(a[i] == '1') {
                    cout << "Impossible" << endl;
                    return 0;
                }
                x = 1;
            }
        }
        if(a[i] == '0' && !x)
            b.push_back(i);
    }
    cout << "Possible\n";
    stringstream ss;
    int l = 0, j = 0;
    ss << "0 0\n";
    for(int k : b) {
        auto v = g(k);
        for(int i : v)
            f(ss, i, j, l);
    }
    if(j)
        for(j--; j >= 0; j--)
            ss << j << " 0\n", l++;
    cout << l << '\n' << ss.str() << flush;
    return 0;
}


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

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

	double s = 0;
	int t = 0;
	for (int i = 0; i < n; i++) {
		s += a[i];
		t += a[i] * a[i];
	}
	int x = round(s / n);
	int ans = n * x * x - 2 * s * x + t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)

for i in range(m):
  b=heapq.heappop(a)
  heapq.heappush(a,(-1)*(-b//2))
  
print(-sum(a))


Measured memory_bytes: 14380
def main():
  num = [int(input()) for i in range(5)]
  min_num=num[0]%10
  last_index=0
  ans=0
  for i in range(1,len(num)):
    if( num[i]%10 < min_num and num[i]%10!=0) or min_num==0 :
      min_num=num[i]%10
      last_index=i
  
  for i in range(0,len(num)):
    if i==last_index or num[i]%10==0:
      ans+=num[i]
    else:
      ans+=((int(num[i]/10)+1)*10)
  print(ans)

main()

Measured memory_bytes: 9068
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>
#include<functional>
#include<iterator>
#include<cctype>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define EPS 1e-9
#define PI 3.14159265359
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
int arr[101][2];
int main(){


	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, i;
	cin >> n >> i;
	int x = n - i + 1;
	cout << x;

	return 0;
}

Measured memory_bytes: 256
//Heaplax
#include<bits/stdc++.h>
#define N 100005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,x,ans,cnt,a[N],b[N],fa[N];
map<int,int> s,dy;
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main()
{
	re(n);
	for(int i=1;i<=n;++i)
		re(a[i]),--s[a[i]],x^=a[i];
	for(int i=1;i<=n;++i)
		re(b[i]),++s[b[i]];
	--s[x];
	for(auto i:s)
		if(i.second>0)
			return puts("-1"),0;
	for(int i=1;i<=n;++i)
		if(a[i] != b[i])
		{
			if(!dy[a[i]])dy[a[i]]=++cnt,fa[cnt]=cnt;
			if(!dy[b[i]])dy[b[i]]=++cnt,fa[cnt]=cnt;
			fa[find(dy[a[i]])]=find(dy[b[i]]);
			++ans;
		}
	if(!ans)return puts("0"),0;
	if(!dy[x])++ans;
	--ans;
	for(int i=1;i<=cnt;++i)
		ans+=find(i)==i;
	printf("%d\n",ans);
}


Measured memory_bytes: 12416
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main() {
    int N; scanf("%d", &N);
    vector<int> C(N);
    for(int i=0; i<N; i++) scanf("%d", &C[i]), C[i]--;
    vector< vector<int> > G(N);
    for(int i=0; i+1<N; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    int all = 0;
    vector<int> sub(N), cnt(N);
    vector<ll> ans(N, 1LL*N*(N+1)/2);
    auto dfs = [&](auto &&self, int cur, int par) -> void {
        sub[cur] = 1;

        // v: cur と親子関係にないような、色が cur と同じものの個数
        ll v = cnt[ C[cur] ];
        for(auto to : G[cur]) {
            if(to == par) continue;
            ll pre = all - cnt[ C[cur] ];

            // ここで dfs を呼ぶことで to 以下の部分木に関しては cnt に足される
            // 差分をとると to 以下でどれくらいの数あったかがわかる
            self(self, to, cur);
            ll nxt = all - cnt[ C[cur] ];
            sub[cur] += sub[to];
            ans[ C[cur] ] -= (nxt - pre) * (nxt - pre + 1) / 2;
        }
        all++;
        cnt[ C[cur] ] = v + sub[cur];
    };
    dfs(dfs, 0, -1);

    // 色 i を含まない連結成分サイズ (根が含まれる部分木)
    for(int i=0; i<N; i++) {
        ll pre = 0, nxt = N - cnt[i];
        ans[i] -= (nxt - pre) * (nxt - pre + 1) / 2;
    }
    for(int i=0; i<N; i++) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 36192
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    string s=get_str();
    bool flag=1;
    if(s[0]!='A')flag=0;
    int ct=0;
    for(int i=2;i<s.size()-1;++i){
        if(s[i]=='C')++ct;
    }
    if(ct!=1)flag=0;
    ct=0;
    for(int i=1;i<s.size();++i){
        if(s[i]>'Z')++ct;
    }
    if(ct!=s.size()-2)flag=0;
    print(flag?"AC":"WA");
    return 0;
}

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

using namespace std;

int main(int argc, char **argv)
{
	int *t, *h, n, tmp, p, q, i, j, l;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		} else if(n == 1){
			cout << n << endl << "0" << endl;
			cin >> n;
			cin >> n;
			continue;
		}
		t = (int *)calloc(n, sizeof(int));
		h = (int *)calloc(n, sizeof(int));
		
		for(i=0; i < n; i++){
			cin >> tmp;
			t[i] = tmp;
		}
		
		sort(t, t+n);
		for(i=1, p=0, q=0; i <= 2*n; i++){
			if(t[q] == i){
				q++;
			} else {
				h[p] = i;
				p++;
			}
		}
		
		tmp = i = j = l = 0;
		while(p*q > 0){
			if(l == 0){
				l = 1;
				while(t[i] <= tmp && i < n){
					i++;
				}
				if(i < n){
					p--;
					tmp = t[i];
					t[i] = 0;
				}
			} else {
				l = 0;
				while(h[j] <= tmp && j < n){
					j++;
				}
				if(j < n){
					q--;
					tmp = h[j];
					h[j] = 0;
				}
			}
			if(i == n || j == n){
				tmp = i = j = 0;
			}
		}
		cout << q << endl << p << endl;

		free(t);
		free(h);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};


int main() {
    int n,m; cin >> n >> m;
    vector<pair<int,int>> mp[n];
    vector<int> a(n),b(n),c(m),d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];

    rep(i,n) rep(j,m){
        mp[i].push_back(make_pair(abs(a[i]-c[j])+abs(b[i]-d[j]),j));
    }
    rep(i,n){
        sort(mp[i].begin(),mp[i].end());
    }
    rep(i,n) cout << mp[i][0].second + 1 << endl;

}


Measured memory_bytes: 256
N,K=map(int,input().split())
P=10**9+7

L=[0]*(K+1)
for i in range(1,K+1)[::-1]:
    minus=0
    count=2
    while True:
        if count*i<=K:
            minus+=L[count*i]
            minus=minus%P
            count+=1
        else:
            break

    L[i]=(pow(K//i,N,P)-minus)%P

ans=0
for j in range(1,K+1):
    ans+=j*L[j]
    ans=ans%P

print(ans)

Measured memory_bytes: 11220
A = str(input())
B = str(input())
C = str(input())
x = "a"
while True:
    if x == "a":
        x = str(A[0:1])
        if len(A) == 0:
            print("A")
            exit()
        A = A[1:]
    elif x == "b":
        x = str(B[0:1])
        if len(B) == 0:
            print("B")
            exit()
        B = B[1:]
    elif x == "c":
        x = str(C[0:1])
        if len(C) == 0:
            print("C")
            exit()
        C = C[1:]


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

signed main(){
	int N; cin>>N;
	map<int,int> a;
	vector<int> dict;
	for(int i=0;i<N;i++){
		int tmp; cin>>tmp;
		if(a.count(tmp))a[tmp]++;
		else {a[tmp]=1; dict.push_back(tmp);}
	}
	sort(dict.begin(),dict.end());
	reverse(dict.begin(),dict.end());
	int i=0;
	int ans=-1;
	while(true){
		if(a[dict[i]]>=2 && ans==-1) ans=dict[i];
		else if(a[dict[i]] >=2 && ans>0){
			ans*=dict[i];
			break;
		}
		else if(a[dict[i]]>=4)ans=(ans<dict[i]*dict[i] ? dict[i]*dict[i] : ans);
		i++;
		if(i==dict.size()-1)break;
	}
	i=0;
	while(true){
		if(a[dict[i]]>=4)ans=(ans<dict[i]*dict[i] ? dict[i]*dict[i] : ans);
		i++;
		if(i==dict.size()-1)break;
	}
	cout<<(ans<0? 0 : ans)<<endl;

}


Measured memory_bytes: 7284
#include<iostream>
#include<math.h>

using namespace std;

int sosuu(int n) {
	int i;
	int limit;

	if (n == 2) {
		return n;
	}
	else if (n % 2 == 0) {
		return 0;
	}
	else {
		limit = (int)sqrt(n);
		for (i = 3; i <= limit; i += 2) {
			if (n%i == 0) {
				return 0;
			}
		}
	}
	return n;
}

int main() {
	int *sosu, i, n,count=0;

	sosu = new int[55];

	cin >> n;

	for (i = 1; i <= 1000; i++) {
		if (sosuu(60 * i + 1) != 0) {
			sosu[count] = 60 * i + 1;
			if (++count == 55)
				break;
		}
	}

	for (i = 0; i < n; i++) {
		cout << sosu[i];
		if (i < n - 1) {
			cout << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    readln;
    auto xs = readints();

    int n = cast(int) xs.length;
    auto segTree = new SegmentTree(n + 1);
    foreach (x; xs) {
        auto max = segTree.query(1, x);
        segTree.update(x, x + max);
    }

    auto max = segTree.query(1, n + 1);
    writeln(cast(long) n * (n + 1) / 2 - max);
}

class SegmentTree {
    private long[] _data;

    this(int n) {
        int len = 1;
        while (len < n)
            len *= 2;

        _data = new long[len * 2];
    }

    /// k ?????????????´????(0-indexed)??? a ????????´
    void update(int k, long a) {
        // ????????\???
        k += (_data.length / 2) - 1;
        _data[k] = a;
        // ?????????????????´??°
        while (k > 0) {
            k = (k - 1) / 2;
            _data[k] = max(_data[k * 2 + 1], _data[k * 2 + 2]);
        }
    }

    /// [a, b) ???????°????????±???????
    long query(int a, int b, int k, int l, int r) {
        // [a, b) ??¨ [l, r) ??????????????????
        if (r <= a || b <= l)
            return 0;

        // [a, b) ??? [l, r) ????????¨???????????§????????°???????????\?????????
        if (a <= l && r <= b) {
            return _data[k];
        }

        // ????????§???????????°???2 ?????????????????§???
        auto vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        auto vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    }

    long query(int a, int b) {
        return query(a, b, 0, 0, cast(int)(_data.length / 2));
    }
}

Measured memory_bytes: 7000
MOD = 1000000007

n=int(input())
a=list(map(int,input().split()))

array_sum = 0
for i in range(0, n, 1): 
    array_sum += a[i]

array_sum_square = pow(array_sum,2)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2)

ans=(array_sum_square - individual_square_sum) //2
print(ans%MOD)

Measured memory_bytes: 31504
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int num;
  int money[]={500,100,50,10,5,1};
  int i,ans;
    
  for(;;){
    cin>>num;
    if(num==0) break;
    
    i=0;ans=0;
    num=1000-num;
    while(num!=0){
      ans += num/money[i];
      num = num%money[i];
      i++;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
using System;
 
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(Console.ReadLine());
      switch (n) {
        case 7:
          Console.WriteLine("YES");
          break;
        case 5:
          Console.WriteLine("YES");
          break;
        case 3:
          Console.WriteLine("YES");
          break;
        default:
          Console.WriteLine("NO");
          break;
      }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    multiset<int> st;
    rep(i,n){
        int a;
        cin >> a;
        st.insert(a);
    }
    int mx = *(--st.end());
    if(mx > n){
        cout << "Impossible\n";
        return 0;
    }
    if(mx % 2 == 0){
        srep(i,mx/2,mx+1){
            rep(j,2){
                if(j == 1 && i == mx/2){
                    continue;
                }
                auto it = st.find(i);
                if(it == st.end()){
                    cout << "Impossible\n";
                    return 0;
                }else{
                    st.erase(it);
                }
            }
        }
        each(it,st){
            if(it <= mx/2 || it > mx){
                cout << "Impossible\n";
                return 0;
            }
        }
        cout << "Possible\n";
    }else{
        srep(i,(mx+1)/2,mx+1){
            rep(j,2){
                auto it = st.find(i);
                if(it == st.end()){
                    cout << "Impossible\n";
                    return 0;
                }else{
                    st.erase(it);
                }
            }
        }
        each(it,st){
            if(it <= (mx+1)/2 || it > mx){
                cout << "Impossible\n";
                return 0;
            }
        }
        cout << "Possible\n";
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x;
    cin >> x;
    ll ans = 0;

    ll ka = x/500;

    ans += 1000*ka;

    x-=ka*500;

    ll kh = x/5;
    ans += kh*5;

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main(){
    let mut buf = String::new();
    let _ = io::stdin().read_line(&mut buf);

    let vec : Vec<i64> = buf.split_whitespace().map(|x| i64::from_str(x).unwrap()).collect();
    let (a, b) = (vec[0], vec[1]);

    println!("a {} b", if a > b { ">" } else if a < b { "<" } else { "==" });
}



Measured memory_bytes: 5016
import sys

def parse(inp):
    a,b,c=map(int,next(inp).split())
    return a,b,c
  
def main(inp):
    a,b,c=inp  
    if(a+b >= c-1): return b+c
    else: return a+2*b+1
    
print(main(parse(sys.stdin)))

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

// Union Find
const int MAX_N = 200002;
int par[MAX_N], tree_rank[MAX_N];
void init_union_find(int n){
	for(int i=0; i<n; i++){
		par[i] = i;
		tree_rank[i] = 0;
	}
}

int root(int x){
	return par[x] == x ? x : par[x] = root(par[x]);
}

bool same(int x, int y){
	return root(x) == root(y);
}

void unite(int x, int y){
	x = root(x);
	y = root(y);
	if(x == y) return;

	if(tree_rank[x] < tree_rank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(tree_rank[x] == tree_rank[y]) tree_rank[x]++;
	}
}

// Kruskal
struct edge{int u, v, cost;};
bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

const int MAX_E = 200002;
vector<edge> es;
int kruskal(int node_n){
	sort(es.begin(), es.end(), comp);
	init_union_find(node_n);
	int res = 0;
	for(int i=0; i<es.size(); i++){
		edge e = es[i];
		if(!same(e.u, e.v)){
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	int en = 0;
	vector<pair<int, int> > x;
	vector<pair<int, int> > y;
	for(int i=0; i<n; i++){
		int tx, ty;
		cin >> tx >> ty;

		x.pb(make_pair(tx, i));
		y.pb(make_pair(ty, i));
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	for(int i=0; i<n-1; i++){
		int x1 = x[i].first;
		int x2 = x[i+1].first;
		int i1 = x[i].second;
		int i2 = x[i+1].second;

		es.pb(edge{i1, i2, x2 - x1});
	}

	for(int i=0; i<n-1; i++){
		int y1 = y[i].first;
		int y2 = y[i+1].first;
		int i1 = y[i].second;
		int i2 = y[i+1].second;

		es.pb(edge{i1, i2, y2 - y1});
	}

	cout << kruskal(n) << endl;
	
	return 0;
}


Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  vector<int> y(n);
  vector<vector<int>> xy(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i)>>y.at(i);
    xy.at(i)={x.at(i),y.at(i)};
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  sort(xy.begin(),xy.end());
  vector<vector<int>> s(n+1,vector<int>(n+1,0));
  for(int p=0,i=0;i<n;i++){
    for(int j=0;j<n;j++){
      s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j];
      if(p<n&&xy.at(p).at(0)==x.at(i)&&xy.at(p).at(1)==y.at(j)){
        s[i+1][j+1]++;
        p++;
      }
    }
  }
  int64_t m=(int64_t)(x.at(n-1)-x.at(0))*(y.at(n-1)-y.at(0));
  for(int il=0;il<n-1;il++)
    for(int jl=0;jl<n-1;jl++)
      for(int ig=il+1;ig<n;ig++)
        for(int jg=jl+1;jg<n;jg++)
          if(s[ig+1][jg+1]-s[il][jg+1]-s[ig+1][jl]+s[il][jl]>=k)
            m=min(m,(int64_t)(x.at(ig)-x.at(il))*(y.at(jg)-y.at(jl)));
  cout<<m<<endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int rows,cols;
    int [][] a,b,c;

    Scanner in = new Scanner(System.in);

    rows = in.nextInt();
    cols = in.nextInt();

    a = new int[rows][cols];
    b = new int[cols][1];
    c = new int[rows][1];
    in.nextLine();

    for(int i=0; i<a.length; i++){
        for(int j=0; j<a[0].length; j++){
            a[i][j] = in.nextInt();
        }
        in.nextLine();
    }

    for(int i=0; i<b.length; i++){
        b[i][0] = in.nextInt();
        in.nextLine();
    }

    for(int i=0; i<a.length; i++){
        int tmp = 0;
        for(int j=0; j<a[0].length; j++)
            tmp += a[i][j]*b[j][0];
        c[i][0] = tmp;
    }

    for(int i=0; i<c.length; i++){
        System.out.println(c[i][0]);
    }
  }
}

Measured memory_bytes: 46372
#!/usr/bin/env python

N = int(input())
plist = list(map(int, input().split(" ")))

cnt = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        cnt += 1
        plist[i], plist[i + 1] = plist[i + 1], plist[i]

if plist[N - 1] == N:
    cnt += 1
    
print(cnt)
# print(plist)

Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int L, R, d;
    cin >> L >> R >> d;
    int ans = L % d == 0 ? R / d - L / d + 1 : R / d - L / d;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n,m,p[200000];

ll par[200000];
ll ran[200000];

void init(ll n) {
    REP(i,n){
        par[i] = i;
        ran[i] = 0;
    }
}

ll find(ll x) {
    if(par[x] == x)
        return x;
    return par[x] = find(par[x]);
}

void unite(ll x,ll y) {
    x = find(x);
    y = find(y);

    if(x == y) {
        return ;
    }

    if(ran[x] < ran[y]) {
        par[x] = par[y];
    }else {
        par[y] = par[x];
        if(ran[y] == ran[x]) ran[x]++;
    }
}

bool same(ll x,ll y) {
    return find(x) == find(y);
}

int main() {
    cin >> n >> m;
    REP(i,n)
        cin >> p[i];

    init(n + 1);

    REP(i,m) {
        ll x,y;
        cin >> x >> y;
        unite(x,y);
    }

    ll ans = 0;

    REP(i,n) {
        if(same(i + 1,p[i]))ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
n = int(input())
a = [int(i) for i in input().split()]
k = 1 + n%2
dp = [[-float('inf')] * (k + 2) for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(k + 1):
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j])
        now = dp[i][j]
        if (i + j) % 2 == 0:
            now += a[i]
        dp[i + 1][j] = max(dp[i + 1][j], now)
print(dp[n][k])

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

// @author: pashka

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

    int a, b, c;
    cin >> a >> b >> c;
    int s = (a == b) + (a == c) + (b == c);
    if (s == 1) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            sys.exit()
        check[index] = count
        count += 1
        index = a[index]


if (K + 1 - start) % len(loop[start:]) == 0:
    print(loop[-1] + 1)
else:
    print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)


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

//===
struct UnionFind {
    vector<int> parent;

    UnionFind(){}
    
    UnionFind(int nmemb)
    {
        init(nmemb);
    }

    void init(int nmemb)
    {
        parent.clear();
        parent.assign(nmemb, -1);
    }

    int root(int x)
    {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);

        if (x == y) return;

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    }

    int size(int x)
    {
        x = root(x);
        return -parent[x];
    }
};
//===

int main()
{
    int n, m;
    int a[105];
    int b[105];
    int ans = 0;

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

    for (int i = 0; i < m; i++) {
        UnionFind uf(n + 1);

        for (int j = 0; j < m; j++) {
            if (i == j) continue;
            uf.unite(a[j], b[j]);
        }

        if (uf.size(1) < n) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll a;
    double b;
    cin>>a>>b;
    ll b100=(ll)(b*100+0.001);
    //cout<<b100<<endl;
    cout<<a*b100/100<<endl;
return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

struct comb{
	vector<ll> f,fr;
	ll MOD_;
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p=-1){//a^(b) mod p
		if(p==-1)p=MOD_;  
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD_ = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll Q,x,d,n;
	cin >> Q;
	comb co;
	ll md = 1000003;
	co.init(1000007,md);
	FOR(i,0,Q){
		cin >> x >> d >> n;
		if(d==0){
			cout << co.calc(x,n) << endl;
			continue;
		}
		(x *= co.calc(d,md-2)) %= md;
		if(x+n-1>=md){
			cout << 0 << endl;
			continue;
		}
		ll ans = co.calc(d,n) * co.f[x+n-1] % md;
		if(x>0)(ans *= co.fr[x-1]) %= md;
		cout << ans << endl;
	}
}


Measured memory_bytes: 16512
#include<vector>
#include<iostream>
#include<list>
#include<algorithm>
#include<chrono>
#include<map>
#include<set>
#include<string>
#include<unordered_map>

using namespace std;


int main(){
    string a, b;
    cin >> a; 
    cin >> b;
    int ans = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] != b[i]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3468
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
  
int main() {
    int N;
    vector<int> v;
    cin >> N;
    for (int i = 0; i < N; ++i){
    	int a;
    	cin >> a;
    	v.push_back(a); 
    }

    vector<int> v2(v);
    sort(v2.begin(), v2.end());

    int sum = 0;
    for (int i = 0; i < N; ++i){
    	if (v[i] != v2[i]) sum++;
    }
    if (sum <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int a[3][3];
int c[3][3]={0};
for(int i=0;i<3;i++)
{for(int j=0;j<3;j++)
{cin>>a[i][j];
}
}
int n;
cin>>n;
int b[n];
for(int k=0;k<n;k++)
{cin>>b[k];
for(int i=0;i<3;i++)
{for(int j=0;j<3;j++)
{if(a[i][j]==b[k])
  {c[i][j]=1;
  }
}
}
}
if(c[0][0]+c[0][1]+c[0][2]==3)
  cout<<"Yes";
else if(c[1][0]+c[1][1]+c[1][2]==3)
  cout<<"Yes";
else if(c[2][0]+c[2][1]+c[2][2]==3)
  cout<<"Yes";
else if(c[0][0]+c[1][0]+c[2][0]==3)
  cout<<"Yes";
else if(c[0][1]+c[1][1]+c[2][1]==3)
  cout<<"Yes";
else if(c[0][2]+c[1][2]+c[2][2]==3)
  cout<<"Yes";
else if(c[0][0]+c[1][1]+c[2][2]==3)
  cout<<"Yes";
else if(c[0][2]+c[1][1]+c[2][0]==3)
  cout<<"Yes";
else
  cout<<"No";
}

Measured memory_bytes: 256