akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  ll h,w;
  cin>>h>>w;
  ll a[h][w];
  rep(i,h){
    rep(j,w){
      cin>>a[i][j];
    }
  }
  vector<vector<ll>> c(0,vector<ll>(4));
  rep(i,h){
    if(i%2==1){
      per(j,w){
        if(j>0&&a[i][j]%2==1){
          --a[i][j];
          a[i][j-1]++;
          vector<ll> d{i,j,i,j-1};
          c.push_back(d);
        }
        if(j==0&&a[i][j]%2==1&&i<h-1){
          --a[i][j];
          a[i+1][j]++;
          vector<ll> d{i,j,i+1,j};
          c.push_back(d);
        }
      }
    }
    else{
      rep(j,w){
        if(j<w-1&&a[i][j]%2==1){
          --a[i][j];
          a[i][j+1]++;
          vector<ll> d{i,j,i,j+1};
          c.push_back(d);
        }
        if(j==w-1&&a[i][j]%2==1&&i<h-1){
          --a[i][j];
          a[i+1][j]++;
          vector<ll> d{i,j,i+1,j};
          c.push_back(d);
        }
      }
    }
  }
  cout<<c.size()<<endl;
  for(auto x:c){
    cout<<x[0]+1<<" "<<x[1]+1<<" "<<x[2]+1<<" "<<x[3]+1<<endl;
  }
}

Measured memory_bytes: 12848
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);
	
	ll X, K, D; cin >> X >> K >> D;
	if (K <= abs(X) / abs(D)) {
		cout << abs(X) - K*abs(D);
	}
	else {
		K -= abs(X) / abs(D);
		X = abs(X) % abs(D);
		if (K % 2) cout << abs(X - abs(D));
		else cout << X;
	}

}


Measured memory_bytes: 3640
s=str(input())
rl='R'
t=[0]*len(s)
a=0
b=0
cnt=1
for i in range(1,len(s)):
    if s[i]==rl and i!=len(s)-1:
        cnt+=1
    elif i!=len(s)-1:
        if cnt%2==0:
            if rl=='R':
                t[i-1]+=int(cnt/2)
                t[i]+=int(cnt/2)
                rl='L'
            elif rl=='L':
                t[i-(cnt+1)]+=int(cnt/2)
                t[i-(cnt)]+=int(cnt/2)
                rl='R'
        else:
            if rl=='R':
                t[i-1]+=int(cnt//2+1)
                t[i]+=int(cnt//2)
                rl='L'
            elif rl=='L':
                t[i-(cnt+1)]+=int(cnt//2)
                t[i-(cnt)]+=int(cnt//2+1)
                rl='R'
        cnt=1
    else:
        if cnt%2==0:
            if rl=='R':
                t[i-1]+=int(cnt/2)
                t[i]+=int(cnt/2+1)
            elif rl=='L':
                t[i-(cnt+1)]+=int(cnt/2)
                t[i-(cnt)]+=int(cnt/2+1)
        else:
            if rl=='R':
                t[i-1]+=int((cnt+1)//2)
                t[i]+=int((cnt+1)//2)
            elif rl=='L':
                t[i-(cnt+1)]+=int((cnt+1)//2)
                t[i-(cnt)]+=int((cnt+1)//2)
print(*t)

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

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

    int sum = 0;
    for(int i=0;i<N.length();i++)
        sum += N[i] - '0';

    if(sum % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
    
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;
// union find
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main(){
  cout << setprecision(10);
  int N,M; cin >> N >> M;
  UnionFind tree(N);

  for(int i = 0; i < M; i++){
    int x,y,z; cin >> x >> y >> z;
    x--; y--;

    tree.unionSet(x,y);
  }

  map<int,int> m;
  for(int i = 0; i < N; i++){
    m[tree.root(i)]++;
  }
  cout << m.size() << endl;
}


Measured memory_bytes: 8268
import bisect

N, K = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
sumB = [0]
for a, b in AB:
    sumB.append(sumB[-1] + b)
print(AB[bisect.bisect_left(sumB, K) - 1][0])


Measured memory_bytes: 21612
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll h, w;
    cin >> h >> w;
    string a[h];
    sidha (i, 0, h) cin >> a[i];

    ll dp[h][w];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    sidha (i, 0, h) {
        sidha (j, 0, w) {
            if (a[i][j] == '#' or !(i+j)) continue;
            if (i) dp[i][j] += dp[i-1][j];
            if (j) dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[h-1][w-1] << '\n';
    
    return 0;
}


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

int main() {
    int S;
    int h = 0; 
    int m = 0;

    cin >> S;
    h = S / 3600;
    m = S % 3600;
    S = m % 60;
    m = m / 60;
    cout << h << ":" << m << ":" << S << endl;
    
    return 0;
}


Measured memory_bytes: 3072
import scala.io.StdIn.readLine

object Main{
  def main(args : Array[String]): Unit ={
    val Array(n, m) : Array[Int] = readLine().split(' ').map(_.toInt)
    val can : Array[Int] = readLine().split(' ').map(_.toInt)
    val SLV = new SOLVE(n, can)
    println(SLV.solve(n))
  }
}

class SOLVE(private val n : Int, private val can : Array[Int]){
  val COST : Array[Int] = Array(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)
  val DP : Array[BigInt] = Array.fill(n + 10)(-1)
  DP(0) = 0
  def solve(k : Int): BigInt ={
    /*
    if(DP(k) != -1) DP(k)
    else{
      for(ele <- can){
        val idx = k - COST(ele)
        if(idx >= 0) if(DP(k) < ele + 10 * solve(idx)) DP(k) = ele + 10 * solve(idx)
      }
    }
    DP(k)
    */
    for(i <- 0 until k; j <- can){
      val idx : Int = i + COST(j)
      if(DP(idx) < 10 * DP(i) + j) DP(idx) = 10 * DP(i) + j
    }
    DP(k)
  }
}

Measured memory_bytes: 126920
import math
import cmath
def cross_product(a,b):
    return (a.conjugate()*b).imag
n = int(input())
for i in range(n):
    L = list(map(float,input().split()))
    a,b,c,d = [complex(L[j*2],L[j*2+1]) for j in range(4)]
    vec_A = b-a
    vec_B = d-c
    if abs(cross_product(vec_A,vec_B)) < 1e-11:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5720
#include <iostream>
#include <string.h>
using namespace std;

int main() {

    int N;
    int cnt = 0;

    cin >> N;

    int a[N];
    int a_next[N];

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

    do {
        int flg = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] % 2 == 0){
                a_next[i] = a[i] / 2;
            }
            else{
                flg = 1;
                break;
            }
        }

        if (flg == 0){
            cnt = cnt + 1;
            for (int j = 0; j < N; j++) {
                a[j] = a_next[j] ;
            }
        }
        else{
            cout << cnt << endl;
            return 0;
        }

    } while (true);

    return 0;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,d[100005];
string s;
bool dfs(int i)
{
	if(i==n-1)
	{
		if(s[i]=='o'&&d[i]&&d[(i+1)%n]==d[(i-1+n)%n])return false;
		if(s[i]=='o'&&!d[i]&&d[(i+1)%n]!=d[(i-1+n)%n])return false;
		if(s[i]=='x'&&d[i]&&d[(i+1)%n]!=d[(i-1+n)%n])return false;
		if(s[i]=='x'&&!d[i]&&d[(i-1+n)%n]==d[(i+1)%n])return false;
		if(dfs(0))return true;
		return false;
	}
	if(i==0)
	{
		if(s[i]=='o'&&d[i]&&d[(i+1)%n]==d[(i-1+n)%n])return false;
		if(s[i]=='o'&&!d[i]&&d[(i+1)%n]!=d[(i-1+n)%n])return false;
		if(s[i]=='x'&&d[i]&&d[(i+1)%n]!=d[(i-1+n)%n])return false;
		if(s[i]=='x'&&!d[i]&&d[(i-1+n)%n]==d[(i+1)%n])return false;
		return true;
	}
	if(s[i]=='o')
	{
		if(d[i]==1)
		{
			d[i+1]=!d[i-1];
			if(dfs(i+1))return true;
			return false;
		}
		if(d[i]==0)
		{
			d[i+1]=d[i-1];
			if(dfs(i+1))return true;
			return false;
		}
	}
	if(s[i]=='x')
	{
		if(d[i]==1)
		{
			d[i+1]=d[i-1];
			if(dfs(i+1))return true;
			return false;
		}
		if(d[i]==0)
		{
			d[i+1]=!d[i-1];
			if(dfs(i+1))return true;
			return false;
		}
	}
	
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<2;i++)
	for(int j=0;j<2;j++)
	{
		d[0]=i;d[1]=j;
		if(dfs(1))
		{
			for(int i=0;i<n;i++)
				printf("%c",d[i]?'W':'S');
			cout<<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, p;
    cin >> a >> p;
    p += a * 3;
    cout << (p / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int p = 0, q[2000000];
 
int max_num(int x, int y){
    if(q[x]>q[y])   return x;
    else    return y;
}
 
insert(int k){
    int i, j, temp;
    p++;
    q[p] = k;
    i = p;
    while(q[i]>q[i/2] && i>1){
        temp = q[i];
        q[i] = q[i/2];
        q[i/2] = temp;
        i = i/2;
    }
}
 
int extract(){
    int i, temp, max, a;
    a = q[1];
    q[1] = q[p];
    p--;
    i = 1;
    while(i*2<=p){
        if(i*2+1<=p)    max = max_num(i*2, i*2+1);
        else    max =i*2;
        if(max_num(max, i)==max){
            temp = q[max];
            q[max] = q[i];
            q[i] = temp;
            i = max;
        }
        else break;
    }
    return a;
}
 
int main(){
    int i, j, k;
    char cmd[10];
    while(1){
        scanf("%s",cmd);
        if(cmd[0]=='i'){
            scanf("%d",&k);
            insert(k);
        }
        if(cmd[0]=='e' && cmd[1]=='x')  printf("%d\n",extract());
        if(cmd[0]=='e' && cmd[1]=='n')  break;
    }
    return 0;
}


Measured memory_bytes: 5632
#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>;

ll x,y;
ll a,b,c;
ll solve(vector<ll> p,vector<ll> q,vector<ll> r){
 ll count=0;
 ll pi=0,qi=0,ri=0;
 ll sum=0;
 while(count<x+y)
 {
     ll max=-1;
     ll cur1=0,cur2=0,cur3=0;
     if(pi<a&&pi<x)cur1=p[pi];
     if(qi<b&&qi<y)cur2=q[qi];
     if(ri<c)cur3=r[ri];
     max=std::max(cur1,cur2);
     max=std::max(max,cur3);
     //cout<<max<<endl;
     if(max==cur3&&ri<c){
         sum+=cur3;
         ri++;
         count++;
         if(count==x+y)break;
     }
     if(max==cur1&&pi<x){
         sum+=cur1;
         pi++;
         count++;
        if(count==x+y)break;
     }
     if(max==cur2&&qi<y)
     {
         sum+=cur2;
         qi++;
         count++;
        if(count==x+y)break;
     }
    }
      return sum;
}

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

cin>>x>>y>>a>>b>>c;
vector<ll>p(a),q(b),r(c);
rep(i,a)cin>>p[i];
rep(i,b)cin>>q[i];
rep(i,c)cin>>r[i];

sort(p.begin(),p.end(),greater<ll>());
sort(q.begin(),q.end(),greater<ll>());
sort(r.begin(),r.end(),greater<ll>());
cout<<solve(p,q,r)<<endl;
return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r1 = Console.ReadLine();
            var r2 = Console.ReadLine();
            if (r1[0] == r2[2] && r1[1] == r2[1] && r1[2] == r2[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  int t,a;
  cin >> t >> a;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  int findID=-1;
  double res=1000.0;
  rep(i,n) {
    double x=t-6.0*h[i]/1000.0;
    double d=max(x-a,a-x);
    if(res>d) {
      res=d;
      findID=i+1;
    }
  }
  cout << findID << endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String s = cin.next();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                sb.append(s.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 25100
import math
A,B,H,M = map(int, input().split())
tmp = (5.5 *(H*60 +M))//360
t = 5.5 *(H*60 +M)-360*tmp
ans = math.sqrt(B**2 + A**2 -math.cos(math.radians(t))*2*A*B)
print(ans)

Measured memory_bytes: 9504
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n;
ll a[maxn];
void GG()
{
    cout<<-1<<endl; exit(0);
}
int main()
{
    fastio();
    cin>>n;
    rep(i,1,n) cin>>a[i];
    ll x = 0;
    rep(i,3,n) x ^= a[i];
    ll t = a[1] + a[2];
    ll b = (t-x)>>1;
    if(t<x || ((t-x)&1) || (b&x)) GG();
    vector<ll> g;
    rep(i,0,62){
        if ((x>>i)&1){
            ll tmp = 1LL<<i;
            g.pb(tmp);
        }
    }
    reverse(g.begin(),g.end());
    for(ll bb:g) if(b+bb<=a[1]) b+=bb;
    if(b>0 && b<=a[1])cout<<a[1]-b<<endl;
    else GG();
    return 0;
}


Measured memory_bytes: 3652
// abc068_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,ans=1;
  cin>>n;
  while(1) {
    if(ans*2>n) {
      break;
    }
    ans *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

int ans[4];

int main()
{
  FILE *inF, *outF;
  //inF = fopen("in", "r");
  //outF = fopen("out", "w");
  inF = stdin;
  outF = stdout;
  int a, b;
  
  fscanf(inF, "%d", &a);
  fscanf(inF, "%d", &b);
  
  ans[a] = 1;
  ans[b] = 1;
  
  for(int i = 1; i <= 3; i++)
    if(ans[i] == 0)
      printf("%d\n", i);
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int n;
	cin >> n;
	int a[100005] = {};
	rep(i,1,n+1)cin >> a[i];

	int ans = 0;
	rep(i,1,n+1){
        if(a[a[i]] == i)ans++;  
	}
	P(ans/2);
	return  0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  size_t R, D, X;
  cin >> R >> D >> X;

  size_t result = X;
  for (size_t i = 0; i < 10; i++) {
    result = result * R - D;
    cout << result << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    // Your code here!
    int h,w;
    cin>>h>>w;
    ll sum = 0;
    if(h==1 || w==1){ cout<<1<<endl;
    return 0;}
    for(int i=0;i<h;i++){
        if(i%2==0) sum += (w+1)/2;
        else sum += w/2;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;


int main(int argc, char **argv) {
    int bingo[3][3];

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

    int n;
    cin >> n;

    for (int i=0; i<n; ++i) {
        int num;
        cin >> num;
        for (int j=0; j<3; ++j) {
            for (int k=0; k<3; ++k) {
                if (bingo[j][k]==num) {
                    bingo[j][k] = -1;
                }
            }
        }
    }
    bool ok{false};
    for (int i=0; i<3; ++i) {
        if ((bingo[i][0] == -1 && bingo[i][1] == -1 && bingo[i][2] == -1) ||
            (bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i] == -1))
            ok =true;
    }
    if ((bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] ==-1) ||
            (bingo[0][2] == -1 && bingo[1][1] == -1 && bingo[2][0] == -1))
        ok =true;
    /*
    for (int i=0; i<3;++i) {
        for (int j=0; j<3; ++j) {
            cout << bingo[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << (ok? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  ll n;
  cin >> n;

  ll ans = INF;
  for (ll i = 1; i * i <= n; ++i) {
    ll j = n / i;
    if (i * j == n) {
      chmin(ans, i - 1 + j - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
 
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;
 
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }
 
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }
 
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
 
    return ret;
}

void solve(long long N, std::vector<long long> a){
    ll ans = LLONG_MAX;
    for(int i = -100; i < 101; i++)
    {
        ll cost = 0;
        for(int j = 0; j < N; j++)
        {
            cost += pow((i-a[j]),2);
        }
        ans = min(ans,cost);
    }

    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
import sys
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
def main():
    A,B=map(int, input().split())
    if (A+B)%2==0:
        print(int((A+B)/2))
    else:
        print('IMPOSSIBLE')

if __name__=='__main__':
    main()


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

using namespace std;

#define ll long long




void solve() {

	int x, a;
	cin >> x >> a;
	if(x < a) {
		cout << 0;
	}
	else {
		cout << 10;
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3628
N,M=map(int,input().split())
S=[]
for m in range(M):
    newinput=list(map(int,input().split()))
    S.append([s-1 for s in newinput[1:]])
P=list(map(int,input().split()))

def bit(n,N):
    return ('0'*10+bin(n)[2:])[-N:]

def switch_to_light(switch_state):
    light_state=[]
    for m in range(M):
        if sum([switch_state[s] for s in S[m]])%2==P[m]:
            light_state.append(1)
        else:
            light_state.append(0)
    return light_state

count=0
for state in range(2**N):
    switch_state=[int(b) for b in bit(state,N)]
    light_state=switch_to_light(switch_state)
    if sum(light_state)==M:
        count+=1
print(count)

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

int n;
long long a[200005],ans;

signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)	scanf("%d",&a[i]);
	for(int i=2;i<=n;++i)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]+=a[i-1]-a[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a == c && b == c){
    cout << 1 << '\n';
  } else if (a == b  && b != c || a == c && c != b || b == c && c != a){
    cout << 2 << '\n';
  } else if (a != b && b != c && a != c){
    cout << 3 << '\n';
  }
  
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int cnt[1000005];
int n;
int res=0;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		cnt[a]++;
		res=__gcd(res,a);
	}
	bool pair_coprime=1;
	for(int i=2;i<=1e6;i++){
		int cur=0;
		for(int j=i;j<=1e6;j+=i) cur+=cnt[j];
		if(cur>1) pair_coprime=0;
	}
	if(pair_coprime) cout<<"pairwise coprime";
	else cout<<(res==1?"setwise coprime":"not coprime");
	re 0;
}

Measured memory_bytes: 11492
#include <iostream>
#include <deque>
using namespace std;
long long n;
int i;
deque<int> solve(long long n)
{
    deque<int> ret;
    if(n==1) return ret;
    if(n%2)
    {
        ret=solve(n-1);
        ret.push_front(ret.size()+1);
    }
    else
    {
        ret=solve(n/2);
        ret.push_back(ret.size()+1);
    }
    return ret;
}
int main()
{
    cin>>n;n++;
    deque<int> ans=solve(n);
    int cate=ans.size();
    for(i=1;i<=cate;i++)
        ans.push_back(i);
    cout<<ans.size()<<'\n';
    for(i=0;i<ans.size();i++)
        cout<<ans[i]<<' ';
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> d(50);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }

  int result = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      result += d[i] * d[j];
    }
  }

  cout << result << endl;
} 

Measured memory_bytes: 256
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut tree = vec![vec![]; n+1];
    let mut f = 0;
    for i in 0..n-1 {
        let a = get!(usize);
        let b = get!(usize);
        tree[a].push((b, i));
        tree[b].push((a, i));
        f = a;
    }
    let col = tree.iter().map(Vec::len).max().unwrap();
    let mut edg = vec![0; n-1];
    for u in 1..n+1 {
        let mut tmp: Vec<_> = tree[u].iter().map(|&(_,e)| edg[e]).filter(|c|*c>0).collect();
        tmp.sort();
        let mut tc = 1;
        let mut ti = 0;
        for &(v, e) in tree[u].iter() {
            if edg[e] > 0 {
                continue;
            }
            loop {
                if ti >= tmp.len() {
                    edg[e] = tc;
                    tc += 1;
                    break;
                } else if tc < tmp[ti] {
                    edg[e] = tc;
                    tc += 1;
                    break;
                } else if tc == tmp[ti] {
                    tc += 1;
                    ti += 1;
                } else {
                    ti += 1;
                }
            }
        }
    }
    println!("{}", col);
    for &i in edg.iter() {
        println!("{}", i);
    }
}

Measured memory_bytes: 16764
using System;
using System.Collections.Generic;
using System.Text;

class C9{
  public static void Main(){
    StringBuilder sb = new StringBuilder();
    string[] str = new string[2];
    var<int> list = new List<int>();

    while(true){
      str = Console.ReadLine().Split(' ');

      if(str[0][0] == 'i'){
        int n = list.Count;
        list.Add(int.Parse(str[1]));

        while(true){
          if(n == 0) break;

          int id = (n - 1) / 2;
          if(list[n] > list[id]){
            int temp = list[n];
            list[n] = list[id];
            list[id] = temp;
          }

          n = id;
        }
      }else if(str[0] == "end") break;
      else if(str[0] == "extract"){
        sb.AppendLine(list[0].ToString());
        int n = list.Count - 1;
        list[0] = list[n];
        list.RemoveAt(n);
        int c = 0;
        for(int i = 0;(i = 2 * c + 1) < n;){
          if((i != n - 1) && (list[i] < list[i + 1])) i++;
          if(list[c] < list[i]){
            int temp = list[i];
            list[i] = list[c];
            list[c] = temp;
          }
          c = i;
        }
      }
    }
    Console.Write(sb);
  }
}



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

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

	int a = -1;
	int b = -1;
	int c = -1;

	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n-i; j++){
			int k = n-i-j;
			if(10000*i + 5000*j + 1000*k == y){
				a = i;
				b = j;
				c = k;
				break;
			}
		}
	}
	cout << a << " " << b << " " << c << endl;
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;
bool OK(string s)
{
string t = s;
reverse(ALL(t));
return t == s;
}

int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
       int n; cin>>n;
       int arr[n];
       map<int,int> mp,mpp;
       for (int i = 0; i < n; i++)
	   {
			cin>>arr[i];   
			mp[arr[i]]++;
	   }
	   int ans = 0;
	   for(auto x : mp)
	   {
			ans += (x.S-1)*(x.S)/2;
	   }   
	   for (int i = 0; i < n; i++)
	   {
		   int cnt = mp[arr[i]];
		   cout << ans - cnt + 1 <<endl;
	   }
	   
    }
    return 0;

}


Measured memory_bytes: 11136
#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
struct my
{
    int ding,hou,key;
    bool operator <(const my &p)const{
     return key<p.key;
    }
};
int n;
vector<my>G;
int d[100000];
struct zhishu
{
    vector<int>p,high;
    void make(int x)
    {
        p.resize(x,0);
        high.resize(x,0);
        for (int i=0;i<x;i++)
        {
            high[i]=0;
            p[i]=i;
        }
    }
    void unite(int x,int y)
    {
        link(findside(x),findside(y));
    }
    bool same(int x,int y)
    {
      return findside(x)==findside(y);
    }
    void link(int x,int y)
    {
        if(high[x]>high[y])
            p[y]=x;
        else{
            p[x]=y;
            if(high[x]==high[y])
                high[y]++;
        }
    }
    int findside(int x)
    {
        if(x!=p[x])
        {
            p[x]=findside(p[x]);
        }
        return p[x];
    }
};
int main()
{
    my ans;
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++)
    {
        scanf("%d%d%d",&ans.ding,&ans.hou,&ans.key);
        G.push_back(ans);
    }
    zhishu l;
    int sum=0;
    sort(G.begin(),G.end());
    l.make(n+1);
    for (int i=0;i<G.size();i++)
    {
      if(!l.same(G[i].ding,G[i].hou))
      {
          sum+=G[i].key;
          l.unite(G[i].ding,G[i].hou);
      }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 4036
c = []
for i in range(3):
   tmp = [int(x) for x in input().split()]
   c.append(tmp)

# set a1 = 0
# bi = c1,i - a1
b = [c[0][i] for i in range(3)]
# ai = ci,1 - b1
a = [c[i][0] - b[0] for i in range(3)]

for i in range(3):
   for j in range(3):
      if (c[i][j] != a[i] + b[j]):
         print('No')
         exit()
print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];

  if (N == 1) {
    cout << a[0] << endl;
    return;
  }

  vector<int> odds, evens;
  rep(i, 0, N) {
    if (i%2 == 0) odds.push_back(a[i]);
    else evens.push_back(a[i]);
  }

  if (N%2 == 1) {
    reverse(all(odds));
    cout << odds[0];
    rep(i, 1, (int)odds.size())  cout << " " << odds[i];
    rep(i, 0, (int)evens.size()) cout << " " << evens[i];
  } else {
    reverse(all(evens));
    cout << evens[0];
    rep(i, 1, (int)evens.size()) cout << " " << evens[i];
    rep(i, 0, (int)odds.size())  cout << " " << odds[i];
  }
  cout << endl;
}

Measured memory_bytes: 3956
#include<stdio.h>

int func(int x);

int main(){
	int d;
	while(scanf("%d",&d)!=EOF){
		int i;
		int sum=0;
		for(i=0;i*d<600;i++){
			sum+=d*func(i*d);
		}
		printf("%d\n",sum);
		sum=0;
	}
	return 0;

}

int func(int x){
	return x*x;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n, a;
V vi;

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> a;
			vi.push_back(a);
		}
		sort(ALL(vi));
		ll sum = 0;
		REP(i, n){
			REP(j, i){
				sum += vi[j];
			}
		}
		cout << sum << endl;
		vi.clear();
	}
}

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

struct Node{
	long long d;
	int id;
	Node(){}
	Node(long long d, int id) : d(d), id(id){}
	bool operator <(const Node& p) const{
		return d < p.d;
	}
};

const int N = 1e5 + 10;

Node a[N];
int sz[N];
map <long long, int> sav;
vector <int> tr[N];
long long ans;

void dfs(int x, int now){
	ans += now;
	for (int i = 0; i < tr[x].size(); i++) dfs(tr[x][i], now + 1);
}

int main(){
	int n, num;
	long long rec;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++){
		scanf("%lld",&a[i].d);
		a[i].id = i;
		sz[i] = 1;
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) sav.insert({a[i].d, i});
	for (int i = n; i >= 2; i--){
		rec = a[i].d - n + sz[i] * 2;
		if (!sav.count(rec)){
			printf("-1\n");
			return 0;
		}
		num = sav[rec];
		if (num == i){
			printf("-1\n");
			return 0;
		}
		tr[num].push_back(i);
		sz[num] += sz[i];
	}
	dfs(1, 0);
	if (ans != a[1].d){
		printf("-1\n");
		return 0;
	}
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < tr[i].size(); j++){
			printf("%d %d\n", a[i].id, a[tr[i][j]].id);
		}
	}
	return 0;
} 

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

typedef long long ll;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);
//#define cerr if(false)cerr
#define PRINT(x) cerr<<"\n" << (#x) << " is " << (x) << endl;
//Erase duplicates in vector
#define REMOVE_DUP(x) x.erase(unique(x.begin(), x.end()), x.end());
#define UP toupper // lowercase to uppercase;
#define DOWN tolower
#define SZ(a) (int)a.size()
#define EB emplace_back
#define PB push_back
#define REP(i, a, b) for(int i=a; i<b; i++)
#define PER(i, a, b) for(int i=a; i>=b; i--)
ostream_iterator<int> output(cout, " ");
#define MOD 1e9+7
#define INF INT_MAX;
#define lim_size 200007

void solve(){
	string s; cin >> s;
	if(s.length() == 6 && s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	FAST_IO;
	int t=1; //cin >> t;
	while(t--){
		solve();
		//solve1();
	}
}			


Measured memory_bytes: 256
N = input()
M = list(N)
n =[]
n.append(int(M[0]))
n.append(int(M[1]))
n.append(int(M[2]))
if n[0]<n[1]:
  print(100*(n[0]+1)+10*(n[0]+1)+n[0]+1)
elif n[0]>n[1]:
  print(100*n[0]+10*n[0]+n[0])
else:
  if n[1]<n[2]:
    print(100*(n[0]+1)+10*(n[0]+1)+n[0]+1)
  else:
    print(100*n[0]+10*n[0]+n[0])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << LF;

  return 0;
}



Measured memory_bytes: 256
def disp(c):
    for cc in c:
        print(cc, end=' ')
    print()

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

i = 0
for x in range(H):
    c = []
    for y in range(W):
        c.append(i + 1)
        a[i] -= 1
        if a[i] == 0:
            i += 1

    if x % 2 == 0:
        disp(c)
    else:
        disp(c[::-1])


Measured memory_bytes: 3700
#include<stdio.h>
#include<string.h>
int main()
{
	long long k;
	int i=0;
	char s[100];
	scanf("%s\n%d",&s,&k);
	while(s[i]=='1')
		i++;
	printf(k<=i?"1":"%c",s[i]);
	return 0;
}


Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def bs(f, mi, ma):
    mm = -1
    while ma > mi + eps:
        mm = (ma+mi) / 2.0
        if f(mm):
            mi = mm + eps
        else:
            ma = mm
    if f(mm):
        return mm + eps
    return mm

# 面積
def area(xy):
    xy = sorted(xy)
    x = [xy[i][0] - xy[0][0] for i in range(3)]
    y = [xy[i][1] - xy[0][1] for i in range(3)]
    return abs(x[1]*y[2] - x[2]*y[1]) / 2

# 内接円の半径
def inside_r(xy):
    s = area(xy)
    a = [((xy[i][0] - xy[i-1][0])**2 + (xy[i][1] - xy[i-1][1])**2) ** 0.5 for i in range(3)]
    return 2 * s / sum(a)

def main():
    xy = sorted([LI() for _ in range(3)])
    a = [((xy[i][0] - xy[i-1][0])**2 + (xy[i][1] - xy[i-1][1])**2) ** 0.5 for i in range(3)]
    ma = max(a)
    r = inside_r(xy)

    def f(i):
        return (1-i/r) * ma - 2*i > 0


    return bs(f, 0, ma)




print(main())



Measured memory_bytes: 5448
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
void GCD(int a,int b,int n){
    if(!b){
        printf("%d %d\n",a,n);
        return;
    }
    GCD(b,a%b,n+1);
}
int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0&&b==0)break;
        GCD(max(a,b),min(a,b),0);
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    int sum_1 = 0, sum_2 = 0;
    rep(i, 0, n){
        if(i%2) sum_1 += a[i];
        else sum_2 += a[i];
    }
    cout << abs(sum_1 - sum_2) << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

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

		
		if(inputArray.length == 3){
			for(int i = 0; i< inputArray.length - 1; i++){
				for(int j = inputArray.length -1; j > i; j--){
					if(Integer.parseInt(inputArray[j]) < Integer.parseInt(inputArray[j - 1])){
						String str = inputArray[j];
						inputArray[j] = inputArray[j - 1];
						inputArray[j - 1] = str;
					}
				}
			}
			System.out.println(inputArray[0] + " " + inputArray[1] + " " + inputArray[2]);
		}
	}
}



Measured memory_bytes: 26084
int main()
{
  int a[13];
  int i = 0;
  while (i < 13)
  {
    scanf("%c",&a[i]);
    //if (i % 2 == 0 && i != 0)
    i++;
  }
  printf("%c%c%c",a[0],a[5],a[10]);
}

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

int main(void){
    int a[5] = {};
    for(int i = 0;i < 6;i++){
        int b;
        cin >> b;
        a[b]++;
    }
    sort(a,a+5,greater<int>());
    if(a[0] != 3)cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
N = int(input())
S = input()
nums = '1234567890'
lst=[]
res = 0
for i,si in enumerate(S):
  if si in lst: continue
  lst.append(si)
  lst2=[]
  for j,sj in enumerate(S[i+1:N]):
    j+=i+1
    if sj in lst2: continue
    lst2.append(sj)
    res += sum(_ in S[j+1:N]\
 for _ in nums)
print(res)

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

using namespace std;
typedef long long ll;

int main() {
	int n, m, r, a, b, c, d[200][200];
	cin >> n >> m >> r;
	int vis[8];
	for (int i = 0; i < r; ++i) {
		cin >> vis[i];
		--vis[i];
	}
	sort(vis, vis + r);
	memset(d, 0x3f, sizeof(d));
	for (int i = 0; i < m; ++i) {
		cin >> a >> b >> c;
		d[a-1][b-1] = d[b-1][a-1] = c;
	}
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = 1<<30;
	do {
		int cost = 0;
		for (int i = 1; i < r; ++i) {
			cost += d[vis[i-1]][vis[i]];
		}
		ans = min(ans, cost);
	} while (next_permutation(vis, vis + r));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int a, b, i, j, chk;
	for (j = 0; ; j++) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0)
			return 0;
		if (j != 0)
			puts("");
		chk = 0;
		for (i = a; i <= b; i++) {
			if (i % 400 == 0) {
				printf("%d\n", i);
				chk++;
			}
			else if (i % 4 == 0) {
				if (i % 100 != 0) {
					printf("%d\n", i);
					chk++;
				}
			}
		}
		if (chk == 0)
			puts("NA");
	}
}

Measured memory_bytes: 612
N = int(input())
ans = ''
if N == 0:
    print(0)
    exit(0)
else:
    while N != 0:
        r = N % -2
        if r != 0:
            ans += "1"
            N -= 1
        else:
            ans += "0"
        N //= -2
    print(ans[::-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;++i) 
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vlli vector<long long int>
#define pb push_back
#define mp make_pair
#define all(c)  ((c).begin()), ((c).end())
using namespace std;
int main(){
	long long int n,m;
	cin>>n>>m;
	long long int sum;
	if(m>2*n){
		sum=n;
		m-=2*n;
		sum+=m/4;
	}
	else{
		sum=m/2;
	}
	cout<<sum<<endl;
}




Measured memory_bytes: 256