akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << ' '<< a << ' ' << b;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 200010
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int n,k,a[MAXN],ans;
int main(){
	k=read(),n=read();
	FUP(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	FUP(i,2,n) ans=max(ans,a[i]-a[i-1]);
	ans=max(ans,a[1]+k-a[n]);
	printf("%d",k-ans);
    return 0;
}

Measured memory_bytes: 1024
s=list(input())

ans='Yes'
for i in range(len(s)):
    if i%2!=0:
        if s[i]=='L' or s[i]=='U' or s[i]=='D':
            continue
        else:
            ans='No'
    else:
        if s[i]=='R' or s[i]=='U' or s[i]=='D':
            continue
        else:
            ans='No'
print(ans)

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int N = sc.nextInt();
		int[] p = new int[N];
		int[] np = new int[100-N+2];
		if(N==0) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int pc = 0;
		np[0] = 0;
		np[100-N+1] = 101;
		int npc = 1;
		for(int i=0; i<100; i++) {
			if(pc < N && i+1 == p[pc]) {
				pc++;
			}else {
				np[npc] = i+1;
				npc++;
			}
		}
		int res = 100;
		int diff = 100;
		for(int i=np.length-1; i>=0; i--) {
			if(diff>=Math.abs(X-np[i])) {
				res = np[i];
				diff = Math.abs(X-np[i]);
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 35916
#include<iostream>

using namespace std;

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

int main(){
  int r, D, x;
  cin >> r >> D >> x;
  rep(i,10){
    int tmp = r*x-D;
  	cout << tmp << endl;
    x = tmp;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, h, w, ans=0;
  cin >> n >> h >> w;
  ll a, b;
  rep(_, n) {
    cin >> a >> b;
    if(h<=a && w<=b) ans++;
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll g(n,vll(0)) ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g.at(a).emplace_back(b) ;
		g.at(b).emplace_back(a) ;
	}
	vll ans(n,0) ;
	ans.at(0) = 1 ;
	queue<ll> q ;
	q.push(0) ;
	while(!q.empty()){
		ll p = q.front() ;
		q.pop() ;
		for(int i=0;i<g.at(p).size();i++){
			if(ans.at(g.at(p).at(i))==0){
				ans.at(g.at(p).at(i)) = p+1 ;
				q.push(g.at(p).at(i)) ;
			}
		}
	}
	cout << "Yes" << endl ;
	for(int i=1;i<n;i++){
		cout << ans.at(i) << endl ;
	}
}


Measured memory_bytes: 13032
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++){    ;
int main() {
ll N;
cin>>N;
ll h=N/10;
int count=0;
long long answer=0;
  if(N%2==0){
for(int i=0; i<39; i++){
if(h>4){
h=h/5;
count++;
}
else
{
    break;
}
}
for(int i=0; i<count+2; i++){
    long long Q=10;
    if(i!=0){
    for(int j=0; j<i; j++){
        Q=Q*5;
    }
    }
answer+=N/Q;
}
  }
  cout<<answer<<endl;
 }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int getNum(int num, int digit) {
    int res = 0;
    for (int i = 0; i < digit; i++) {
        res += num % 10;
        num /= 10;
    }
    return res;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int res = 0;

    for (int i = 1; i <= n; i++) {
        int sum = getNum(i, 5);
        if (sum >= a && sum <= b) {
            res += i;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};



int main(){
    int n,k;cin >> n >> k;
    vector<LL> p(n);
    vector<LL> ps(1001,0);
    for (int i = 0; i < 1000; i++) {
        ps[i+1] = ps[i] + i + 1;
    }
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    vector<double> cp(n+1,0);
    for (int i = 0; i < n; i++) {
        cp[i+1] = cp[i] + 1. * ps[p[i]] / p[i];
    }
    double ans = 0.0;
    for (int i = 0; i <= n-k; i++) {
        ans = max(ans, cp[i+k] - cp[i]);
    }
    cout << setprecision(30) << fixed <<  ans << endl;
    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s,t;cin>>s>>t;
  bool ok=true;
  int i;
  if(s.size()+1!=t.size())ok=false;
  else
  {
    rep(i,s.size())if(s[i]!=t[i])ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <string.h>
#define m 1000000007
using namespace std;

int a,b,c,n,i,d,o[230300],l[100010],e,dx[10]={0,-1,1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,-1,1,-1,1};
long long x,y,z,k;
stack<int> s;
queue<int> qx,qy,qn;
string r1,r2;
vector<pair<int,int> > v[200010];
//char r1[1010],r2[1010],r3[1010];



int main()
{
    scanf("%d %d",&a,&b);
    if(b==1||b==2*a-1)
        printf("No");
    else
    {
        for(int t=a-1,w=2*a-1;t>=1;w--)
        if(w!=b)
        {
            o[t]=w;
            t--;
        }
        o[a]=b;
        for(int t=a+1,w=1;t<=2*a-1;w++)
        if(w!=b)
        {
            o[t]=w;
            t++;
        }
        puts("Yes");
        for(int t=1;t<=a*2-1;t++)
        printf("%d\n",o[t]);
    }


    return 0;
}

Measured memory_bytes: 7040
program problemB
  implicit none


integer(8) :: n,m, yr, l, i, k, j,judge, small, kref, r, t, f, ref
integer(8) :: BNUM, RNUM, NMAX, count,MMAX, sum, A, B, C, D,multi,countA,countC
character(len=4) :: color



read(*,*) A,B,C,D


countA=0
countC=0
do while (A>0)
  A=A-D
  countA=countA+1
end do
do while (C>0)
  C=C-B
  countC=countC+1
end do

if (countA>=countC) then
  write(*,*) 'Yes'
else
  write(*,*) 'No'
end if 

stop
end program


Measured memory_bytes: 2792
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <int>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
bool isOK(int mid, double key){
 
    if((double)mid*mid > key) {
             return true;
     } else {
              return false;
     }
}

 int binary_search(double key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


bool isKaibun(string st){
    bool ans = true;
    int n = st.length();
    REP(i,n/2){
        if(st[i] != st[n-i-1]){
            return false;
        }
    }
    return true;
}


void solve() {
int L;
cin >> L;
double o = (double)L/3;
cout <<fixed << o*o*o;

}
 
signed main() {
 
    solve();
 
    return 0;
}


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

const long N = 8;
const long FREE = -1;
const long NOT_FREE = 1;

long row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];
bool X[N][N];

void initialize(){
	for (long i = 0; i < N; i++){
		row[i] = FREE;
		col[i] = FREE;
	}
	for (long i = 0; i < 2 * N - 1; i++){
		dpos[i] = FREE;
		dneg[i] = FREE;
	}
}

void printBoard(){
	for (long i = 0; i < N; i++){
		for (long j = 0; j < N; j++){
			if (X[i][j]){
				if (row[i] != j) return;
			}
		}
	}
	for (long i = 0; i < N; i++){
		for (long j = 0; j < N; j++){
			cout << ((row[i] == j) ? "Q" : ".");
		}
		cout << endl;
	}
}

void recursive(long i){
	if (i == N){
		printBoard();
		return;
	}

	for (long j = 0; j < N; j++){
		if (NOT_FREE == col[j] ||
			NOT_FREE == dpos[i + j] ||
			NOT_FREE == dneg[i - j + N - 1]) continue;
		row[i] = j;
		col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
		recursive(i + 1);
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
	}
}

int main(){
	initialize();

	for (long i = 0; i < N; i++){
		for (long j = 0; j < N; j++) X[i][j] = false;
	}

	long k;
	cin >> k;
	for (long i = 0; i < k; i++){
		long r, c;
		cin >> r >> c;
		X[r][c] = true;
	}

	recursive(0);

	return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n;
    cin >> n;
    cout << "ABC" << n << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

int caesar[26][255], x, enkrip[100];
int thiss[] = {'t', 'h', 'i', 's'}, the[] = {'t', 'h', 'e'}, that[] = {'t', 'h', 'a', 't'};
string s;
int main() {
	for(int i = 0; i <= 25; i++) {
		for(char j = 'a'; j <= 'z'; j++) {
			if(j + i > 'z') x = j + i - 26; else x = j + i;
			caesar[i][x] = j;
		}
	}
	while(getline(cin, s)) {
	for(int k = 0; k <= 25; k++) {
		int l = 0, z = 0, zz = 0;
		for(int i = 0, j = s.size(); i != j; i++) {
			if(s[i] <= 'z' && s[i] >= 'a') {
				enkrip[i] = caesar[k][s[i]];
				if(enkrip[i] == thiss[l]) l++;
				if(enkrip[i] == the[z]) z++;
				if(enkrip[i] == that[zz]) zz++;
			} else {enkrip[i] = s[i]; if(l < 4) l = 0; if(z < 3) z = 0;if(zz < 4) zz = 0; }
		}
		if(l >= 4 || z >= 3 || zz >= 4) {
			for(int i = 0, j = s.size(); i != j; i++) {
				printf("%c", enkrip[i]);
			}
			printf("\n");
			break;
		}
	}}
	return 0;
}

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

using namespace std;

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    string s;
    cin >> s;
    int a[n];
    int p = 0;
    rep (i, n) a[i] = 0;
    rep (i, 100) {
      int j = i % n;
      if (s[i] == 'M') {
	++a[j];
      } else if (s[i] == 'S') {
	p += a[j] + 1;
	a[j] = 0;
      } else {
	a[j] += p + 1;
	p = 0;
      }
    }
    sort(a, a + n);
    rep (i, n) cout << a[i] << " ";
    cout << p << endl;
  }
}

Measured memory_bytes: 1224
#include <iostream>

using namespace std;

int main()
{
	char n[2];
	cin >> n;
	
	if(n[0] == '9' || n[1] == '9')
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	static int h, w;
	static char field[][];
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		h = fs.nextInt(); w = fs.nextInt();
		field = new char[h][w];
		for(int i=0;i<h;i++) {
			String s = fs.next();
			for(int j=0;j<w;j++) {
				field[i][j] = s.charAt(j);
			}
		}

		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(field[i][j]=='#'&&!check(i,j)) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}

	static boolean check(int x, int y) {
		for(int i=0;i<4;i++) {
			int nx = x + DX[i], ny = y + DY[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w) {
				if(field[nx][ny]=='#')return true;
			}
		}
		return false;
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007


int main() {
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        int count=0;
        double x;
        for(int i=2; i<n; i++){
            if(i % 2 == 0){
                x = n / (double)i;
                if(ceil(x) != floor(x)){
                    x *= 2;
                    if(ceil(x) == floor(x)){
                        if((x / 2) / (double)i >= 0.5){
                            count++;
                            //cout << i << endl;
                        }
                    }
                }
                
            }else{
                if(n % i == 0){
                    if((n / i) / (double)i >= 0.5){
                        count++;
                        //cout << i << endl;
                    }
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3076
/*
 © 2020-08-29 06:57:42 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const lli MOD = 1e9 + 7;
struct DSU{
  vector<lli> rank, pr;
  DSU(int n){
    rank.resize(n + 5, 1);
    pr.resize(n + 5);
    iota(all(pr), 0);
  }
  lli find(lli u){
    return u == pr[u] ? u : pr[u] = find(pr[u]);
  }
  void unite(lli u, lli v){
    u = find(u), v = find(v);
    if(u != v){
      if(rank[u] < rank[v]) swap(u, v);
      rank[u] += rank[v];
      pr[v] = u;
    }
  }
};
int main(){ _
  lli n, m; cin >> n >> m;
  DSU dsu(n);
  fore(i, 0, m){
    lli x, y; cin >> x >> y;
    dsu.unite(x, y);
  }
  cout << *max_element(all(dsu.rank)) << ENDL;
  return 0;
}


Measured memory_bytes: 6364
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

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

vl a,p;

ll rec(int n, ll x){
  if(n == 0) return 1;
  else if(x == 1) return 0;
  else if(x <= 1+a[n-1]) return rec(n-1, x-1);
  else if(x == 2+a[n-1]) return 1+p[n-1];
  else if(x <= 2*a[n-1] + 2) return 1+p[n-1]+rec(n-1, x-a[n-1]-2);
  else return p[n];

  return 0;
}

int main(){
  int n; ll x; cin >> n >> x;
  a.pb(1); rep(i, n) a.pb(2*a[i] + 3);
  p.pb(1); rep(i, n) p.pb(2*p[i] + 1);
  std::cout << rec(n, x) << '\n';
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    q = int(input())
    n = [0 for _ in range(100000+1)]
    for i in a:
        n[i] += 1
    for _ in range(q):
        b, c = map(int, input().split())
        s += (c - b) * n[b]
        print(s)
        n[c] += n[b]
        n[b] = 0


if __name__ == '__main__':
    solve()


Measured memory_bytes: 20848
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;i+j<=n;j++){
      if(10000*i+5000*j+1000*(n-i-j)==y){
        cout<<i<<' '<<j<<' '<<n-i-j<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
}

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

using namespace std;
typedef long long ll;

const int MAXN = 100000;

ll gcd(ll u, ll v);


ll pref[MAXN];
ll suff[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> arr(N);
    
    for (int i=0; i < N; ++i) {
        cin >> arr[i];
        if (i == 0) {
            pref[i] = arr[i];
        } else {
            pref[i] = gcd(pref[i-1], arr[i]);
        }
    }
    
    for (int i=N-1; i>=0; --i) {
        if (i == N-1) suff[i] = arr[i];
        else suff[i] = gcd(suff[i+1], arr[i]);
    }
    
    ll ans = 0;
    for (int i=1; i < N-1; ++i) {
        ans = max(ans, gcd(suff[i+1], pref[i-1]));
    }
    
    ans = max(ans, suff[1]);
    ans = max(ans, pref[N-2]);
    cout << ans << endl;
    
    return 0;
}


ll gcd(ll u, ll v) {
    if (u == v)
        return u;

    if (u == 0)
        return v;

    if (v == 0)
        return u;

    // look for factors of 2
    if (~u & 1) // u is even
    {
        if (v & 1) // v is odd
            return gcd(u >> 1, v);
        else // both u and v are even
            return gcd(u >> 1, v >> 1) << 1;
    }

    if (~v & 1) // u is odd, v is even
        return gcd(u, v >> 1);

    // reduce larger argument
    if (u > v)
        return gcd((u - v) >> 1, v);

    return gcd((v - u) >> 1, u);
}


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

int main()
{
  int X;
  cin>>X;
  if((X >= 400)&&(X <= 599))
    cout<<8<<"\n";
  if((X >= 600)&&(X <= 799))
    cout<<7<<"\n";
  if((X >= 800)&&(X <= 999))
    cout<<6<<"\n";
  if((X >= 1000)&&(X <= 1199))
    cout<<5<<"\n";
  if((X >= 1200)&&(X <= 1399))
    cout<<4<<"\n";
  if((X >= 1400)&&(X <= 1599))
    cout<<3<<"\n";
  if((X >= 1600)&&(X <= 1799))
    cout<<2<<"\n";
  if((X >= 1800)&&(X <= 1999))
    cout<<1<<"\n";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

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

int main(){
  int H,A;
  cin >> H >> A;
  
  if(H % A != 0)
  {
  	cout << (H / A) + 1;
  }
  else{
  	cout << H /A;  
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, q, a, b, l, val[800007][3], tag[800007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c<'0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int add(int w, int v)
{
	for (int j = 0; j <= 2; j++)
		val[w][j] += v;
	tag[w] += v;
	return 0;
}
int down(int w)
{
	if (!tag[w])return 0;
	add(2 * w, tag[w]);
	add(2 * w + 1, tag[w]);
	tag[w] = 0;
	return 0;
}
int up(int w)
{
	for (int i = 0; i <= 2; i++)
		val[w][i] = min(val[2 * w][i], val[2 * w + 1][i]);
	return 0;
}
int change(int w, int l, int r, int x, int v)
{
	if (l == r)
	{
		val[w][0] = v;
		val[w][1] = v - x;
		val[w][2] = v + x;
		return 0;
	}
	down(w);
	int mid = (l + r) / 2;
	if (x <= mid)change(2 * w, l, mid, x, v);
	else change(2 * w + 1, mid + 1, r, x, v);
	up(w);
	return 0;
}
int ask(int p, int w, int l, int r, int x, int y)
{
	if (x <= l && r <= y)
		return val[w][p];
	down(w);
	int mid = (l + r) / 2, res = 1e18;
	if (x <= mid)res = min(res, ask(p, 2 * w, l, mid, x, y));
	if (y > mid)res = min(res, ask(p, 2 * w + 1, mid + 1, r, x, y));
	return res;
}
signed main()
{
	n = read();
	q = read();
	a = read();
	b = read();
	l = read();
	memset(val, 0x3f, sizeof val);
	change(1, 1, n, b, abs(l - a));
	change(1, 1, n, a, abs(l - b));
	for (int i = 2; i <= q; i++)
	{
		int num = read(), len = abs(num - l);
		int res1 = ask(0, 1, 1, n, num, num) + len;
		int res2 = ask(1, 1, 1, n, 1, num) + num;
		int res3 = ask(2, 1, 1, n, num + 1, n) - num;
		add(1, len);
		change(1, 1, n, l, min(res1, min(res2, res3)));
		l = num;
	}
	printf("%lld\n", val[1][0]);
	return 0;
}

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

using namespace std;

int n;
string s;
string t = "";

int main(){
  cin >> n >> s;
  t = s[0];
  int j=0;
  for (int i = 0; i < n-1; i++){
    if(s[i] == s[i+1]){
      continue;
    }else{
      j++;
      t += s[j];
    }
  }
  cout << t.size() << endl;
  return 0;
}

Measured memory_bytes: 512
S = input()
T = input()
N, M = len(S), len(T)
ma = 0
for i in range(N-M+1):
    c = 0
    for j in range(M):
        if S[i+j] == T[j]:
            c += 1
    ma = max(ma, c)

print(M - ma)

Measured memory_bytes: 9120
#include"bits/stdc++.h"
using namespace std;

void Main() {
  string s, t;
  cin >> s;
  cin >> t;

  bool r = false;
  for (int i = s.size() - t.size(); 0 <= i; i--) {
    string tmp = s.substr(i, t.size());
    for (int j = 0; j < tmp.size(); j++) {
      if (tmp[j] == '?') {
        tmp[j] = t[j];
      }
    }
    if (tmp == t) {
      for (int j = 0; j < t.size(); j++) {
        s[i + j] = t[j];
      }
      r = true;
      break;
    }
  }

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') {
      s[i] = 'a';
    }
  }

  if (r) cout << s << endl;
  else cout << "UNRESTORABLE" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
n , k = map(int, input().split())
p = list(map(int, input().split()))
p_accu = [p[0] + 1]

if k == 1:
    print((max(p) + 1 ) / 2 )
    exit()
elif k == n:
    print((sum(p) + n ) / 2 )
    exit()

for i in range(1, n):
    p[i] += p[i-1] + 1
    p_accu.append(p[i])

S = p_accu[k-1]

for i in range(n - k):
    if S < p_accu[i+k] - p_accu[i]:
        S = p_accu[i+k] - p_accu[i]
    
print(S/2)

Measured memory_bytes: 25052
read = input 
rn = lambda :list(map(int, read().split()))
d = {}
n, = rn()
for i in range(n):
    s = read()
#     print(s)
    if s not in d: d[s] = 0
    d[s] += 1
max_cnt = sorted(d.items(), key=lambda tp:tp[1])[-1][1] # max cnt
a1 = filter(lambda tp:tp[1] == max_cnt, d.items())
a2 = map(lambda tp:tp[0], a1)
for s in sorted(a2):
    print(s)

Measured memory_bytes: 43228
data = int(input())
     
ans = ""
flag = True
if __name__ == "__main__":
  for i in range(1,10):
    if flag:
      for j in range(1,10):
        ans = i*j
        if ans == data:
          print("Yes")
          flag = False
          break
    else:
      break
  if flag:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
  using namespace std;
   
  typedef long long ll;
  typedef long double ld;
  typedef pair<ll, ll> pi;
  typedef pair<ll, ll> pll;
  #define fi first
  #define se second
  #define pb push_back
  #define ppb pop_back

  int main() {
    int l,r,d,ans=0;
    cin >> l >> r >> d;
    for (int i=l;i<=r;++i) {
      if (i%d==0) ++ans;
    }
    cout << ans << endl;
    return 0;
  }

Measured memory_bytes: 3576
#include <stdio.h>

int main (void)
{
  int A[9], N, B[10], C[9]={0};
  int i, j;
  
  for (i=0; i<3; i++) {
  	scanf("%d %d %d", &(A[i*3]), &(A[i*3+1]), &(A[i*3+2]));
  }
  
  scanf("%d", &N);
  
  for (i=0; i<N; i++) {
    scanf("%d", &(B[i]));
    
    for (j=0; j<9; j++) {
      if (A[j] == B[i]) {
        C[j] = 1;
      }
    }
  }
  
  if ((C[0]+C[1]+C[2]) == 3 ||
      (C[3]+C[4]+C[5]) == 3 ||
      (C[6]+C[7]+C[8]) == 3 ||
      (C[0]+C[3]+C[6]) == 3 ||
      (C[1]+C[4]+C[7]) == 3 ||
      (C[2]+C[5]+C[8]) == 3 ||
      (C[0]+C[4]+C[8]) == 3 ||
      (C[2]+C[4]+C[6]) == 3 ) {
    puts("Yes");
  } else {
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var L = new long[N + 1];
            L[0] = 2;
            L[1] = 1;
            for (var i = 2; i < L.Length; i++)
            {
                L[i] = L[i - 1] + L[i - 2];
            }
            Console.WriteLine(L[N]);
        }
    }
}


Measured memory_bytes: 27340
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main()
{
    vector<vector<int>>dp(3000, vector<int>(3000));
    int n;
    cin>>n;
    vector<int>a(n, 0);
    for(auto &ai:a) cin>>ai;

    for(int l=0; l<n; ++l)
    {
        dp[l][l]=a[l];
    }

    for(int d=1; d<=n-1; ++d)
    {
        for(int l=0; l<n-d; ++l)
        {
            int r=l+d;
            dp[l][r]=max(-dp[l][r-1]+a[r], -dp[l+1][r]+a[l]);
        }
    }
    cout<<dp[0][n-1];
}

Measured memory_bytes: 70656
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())

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

  ll N; cin >> N;
  if((N%10) == 9){
    cout << "Yes" << endl;
    return 0;
  }
  if((N/10) == 9){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<char,int>m;
    map<char,int>::iterator it;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        m[s[i]]++;
    }
    int f=1;
    for(it=m.begin();it!=m.end();it++)
    {
        if(it->second>1)
        {
            f=0;
            break;
        }
    }
    if(f==0) cout<<"no"<<endl;
    else if(f==1) cout<<"yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    string a = "";
    int b = -1;
    cin >> a;
    int times = 0;
    bool f = false;
    for (int i = 0; i < a.length(); i++)
    {
        int now = +a.at(i);
        if (now == b)
        {
            if (!f)
                times++;
            times++;
            f = true;
        }
        else
        {
            if (times < 3)
                times = 0;
            f = false;
        }
        b = now;
    }
    if (times >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N, K, Q = input().split(' ')
N = int(N)
K = int(K)
Q = int(Q)
P = np.ones(N) * K
for i in range(Q):
  A = int(input())
  P[A-1] += 1
P -= Q
for i in range(N):
  if P[i] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 27676
#include<stdio.h>
#include<string.h>
int main(){
	int K,i=0,n=0;
	char s[110];
	scanf("%d",&K);
	getchar();
	do{
		scanf("%c",&s[i]);
		i++;
	}
	while(s[i-1]!='\n');
	n=i-1;
	if(n<=K){for(i=0;i<n;i++){
		printf("%c",s[i]); 
	}
		
	}
	else{
	for(i=0;i<K;i++){
		printf("%c",s[i]); 
	}
	printf("...");
	}
	return 0;
}

Measured memory_bytes: 1720
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int a, b, k;
vector<int> v;


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	cin >> a >> b >> k;
	int _min = min(a, b);
	for(int i = 1; i <= _min; i++) {
		if(a % i == 0 && b % i == 0) v.push_back(i);
	}
	int n = v.size();
	if(k <= n) printf("%d", v[n - k]);
	return 0;
}
/**/

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
count = [0]*(10**5+1)
for e in a:
  count[e] += 1

s = sum(a)

for i in range(q):
  b, c = map(int, input().split())
  s = s - b * count[b] + c * count[b]
  print(s)
  count[c] += count[b]
  count[b] = 0
  


Measured memory_bytes: 20836
n,m=map(int,input().split())
L1,L2,L3=[],[],[]
for s in range(n):
  L1.append(list(map(int,input().split())))
for s in range(m):
  L2.append(list(map(int,input().split())))
for x in L1:
  L3=[]
  for y in L2:
    L3.append(abs(x[0]-y[0])+abs(x[1]-y[1]))
  print(L3.index(min(L3))+1)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100000
int A[MAX],n;
    
int partition(int p,int r){ 
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }    
    }   
    swap(A[i+1],A[r]);
    return i+1;
}    

int main(){
    int i,q;
    cin>>n;
    
    for(i=0;i<n;i++)cin>>A[i];
    q=partition(0,n-1);                                                   

    for(i=0;i<n;i++){
        cout<<(i?" ":"")<<(i==q?"[":"")<<A[i]<<(i==q?"]":"");
    }   
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 3444
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <cmath>

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

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string s;
	cin >> s;
	int length = s.size();
	int first = 0;
	int end = length - 1;

	int count = 0;
	while (end - first >= 0)
	{
		if (s[first] != s[end])
		{
			count++;
		}
		first++;
		end--;
	}
	cout << count;
}


Measured memory_bytes: 31488
#include<stdio.h>
#include<stdlib.h>

int uf[131072];

void resuf(){
  int i;
  for(i=0;i<131072;i++){uf[i]=i;}
}

int find(int v){
  if(uf[v]==v){return v;}
  uf[v]=find(uf[v]);
  return uf[v];
}

void uni(int a,int b){
  if(find(a)==find(b)){return;}
  if(rand()%2){
    uf[find(a)]=find(b);
  }
  else{
    uf[find(b)]=find(a);
  }
}

int main(){
  int n,m,a,b,c[131072],d[131072],e[131072],i,fl;
  while(scanf("%d%d",&n,&m),n!=0){
    resuf();
    fl=1;
    for(i=1;i<=n;i++){c[i]=0;d[i]=0;e[i]=0;}
    for(i=0;i<m;i++){
      scanf("%d%d",&a,&b);
      if(a<=0 || a>n || b<=0 || b>n){fl=0;continue;}
      c[a]++;c[b]++;
      uni(a,b);
    }
    for(i=1;i<=n;i++){
      //printf("%d\n",find(i));
      if(c[i]>=3){fl=0;break;}
      d[find(i)]++;
      e[find(i)]+=c[i];
    }
    for(i=1;i<=n;i++){
      //printf("%d : <%d %d>\n",i,d[i],e[i]);
      if(d[i]==0){continue;}
      if(e[i]!=2*d[i]-2){fl=0;}
    }
    if(fl==1){printf("yes\n");}
    else{printf("no\n");}
  }
}



Measured memory_bytes: 3356
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
struct xy
{
    double x, y;
};

void koch(int d, xy p1, xy p2){
    xy s, t, u;
    if(d==0)return;
    s.x = p1.x + (p2.x - p1.x) / 3.0;
    s.y = p1.y + (p2.y - p1.y) / 3.0;
    u.x = p2.x + (p1.x - p2.x) / 3.0;
    u.y = p2.y + (p1.y - p2.y) / 3.0;
    t.x = (s.x + u.x)/2 + (s.y - u.y)*sqrt(3.0)/2.0;
    t.y = (s.y + u.y)/2 + (u.x - s.x)*sqrt(3.0)/2.0;
    koch(d-1, p1, s);
    cout << setprecision(10) << s.x << " " << s.y << endl;
    koch(d-1, s, t);
    cout << setprecision(10) << t.x << " " << t.y << endl;
    koch(d-1, t, u);
    cout << setprecision(10) << u.x << " " << u.y << endl;
    koch(d-1, u, p2);
    
}

int main(){
    int n; cin >> n;
    xy p1, p2;
    p1.x = 0.00000000;   p1.y = 0.000000000;
    p2.x = 100.00000000; p2.y = 0.000000000;
    cout << setprecision(10)<< p1.x << " " << p1.y << endl;
    koch(n, p1, p2);
    cout << setprecision(10) <<p2.x << " " << p2.y << endl;
}


Measured memory_bytes: 3296
#include<cstdio>
#define int long long
int n,m,x,a;
signed main()
{
	scanf("%lld%lld",&n,&m),a=n,n-=m;
	for(;m;)x=n%m,a+=n-x<<1,n=m,m=x;
	return printf("%lld",a-n),0;
}

Measured memory_bytes: 1712
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
q=int(input())
d=defaultdict(int)
s=0
for i in range(n):
    d[a[i]]+=1
    s+=a[i]
for i in range(q):
    b,c=map(int,input().split())
    k=0
    if(d[b]>0):
        k=d[b]*b
        d[c]+=d[b]
        s-=k
        s+=(d[b]*c)
        d[b]=0
    print(s)
    

Measured memory_bytes: 94556
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------


///--------------------------

bool check(string x)
{
    int head=0;
    int tail =x.size()-1;
    while (head<=tail)
    {
        if (x[head]!=x[tail]) return false;
        head++;
        tail--;
    }
    return true;
}

int main()
{
    Phuong_;
    double n;
  	cin >> n;
  	n/=3;;
  	n=n*n*n;
  	cout << setprecision(10) << fixed << n ;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    vector<int>a(5);
    int i;
    int n=1;
    rep(i,5){
        cin>>a.at(i);
        if (a.at(i)==0){
            n+=i;
            cout<<n<<endl;
        }
    }    
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		char c = str[1].charAt(0);
		sb.append("A"+c+"C");
		System.out.println(sb);
	}
}

Measured memory_bytes: 8148
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long

using namespace std;

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

    int n;

    cin >> n;

    unordered_map<int, int> m;

    int in, sum = 0;

    int ans = 0;
    m[0] = 1;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        sum += in;
        ans += m[sum]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8520
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    if (n >= 105) ans++;
    if (n >= 135) ans++;
    if (n >= 165) ans++;
    if (n >= 189) ans++;
    if (n >= 195) ans++;
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

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

	vector<int> a(100005);

	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x != 0) {
			a[x - 1]++;
		}
		a[x]++;
		a[x + 1]++;
	}
	
	sort(a.begin(), a.end(), greater<int>());

	cout << a[0] << endl;

	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())

g = [0] * (n+2)
for i in range(m):
    l,r = map(int,input().split())
    g[l] += 1
    g[r+1] -= 1

now = 0
ans = 0
for i in range(1, n+1):
    now += g[i]
    if now >= m:
        ans += 1

print(ans)


Measured memory_bytes: 9804
#include <stdio.h>
int main(){
	int a[3],b;

	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	if(a[0]>a[1]){
		b=a[0];
		a[0]=a[1];
		a[1]=b;
	}
	if(a[1]>a[2]){
		b=a[1];
		a[1]=a[2];
		a[2]=b;
	}
	if(a[0]>a[1]){
		b=a[0];
		a[0]=a[1];
		a[1]=b;
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <math.h>
#include <string>
using namespace std;
const int M=998244353;


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

	int n;
	cin>>n;
	int ans=(n/500)*1000;
	n=n%500;
	ans+=(n/5)*5;
	printf("%d\n",ans );

 	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

num = input().rstrip().split(" ")

if (0 <= (int(num[2])-int(num[4]))) and ((int(num[2])+int(num[4])) <= int(num[0])) and (0 <= (int(num[3])-int(num[4]))) and ((int(num[3])+int(num[4])) <= int(num[1])):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7700
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

const int maxn=200000+10;

int a[maxn];

int main()
{
//	freopen("std.in","r",stdin);
	int n;cin>>n;
	rep(i,1,n) cin>>a[i];
	int m=a[1];
	int ans=1;
	rep(i,2,n){
		if(m>=a[i]) ++ans;
		m=min(m,a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
if __name__ == '__main__':
    h,w = list(map(int, input().split()))
    s = []
    for i in range(h):
        s.append(input())
    
    yoko = [[0 for i in range(w)] for j in range(h)]
    tate = [[0 for i in range(w)] for j in range(h)]
 
    for i in range(h):
        index = 0
        while(index < w):
            count = 0
            for j in range(index, w):
                if(s[i][j] == "#"):
                    break
                count += 1
            
            if(count == 0):
                yoko[i][index] = 0
                index += 1
 
            else:
                for j in range(index, index + count):
                    yoko[i][j] = count
                index += count
 
    for i in range(w):
        index = 0
        while(index < h):
            count = 0
            for j in range(index, h):
                if(s[j][i] == "#"):
                    break
                count += 1
            
            if(count == 0):
                tate[index][i] = 0
                index += 1
 
            else:
                for j in range(index, index + count):
                    tate[j][i] = count
                index += count
 
    result = 0
 
    for i in range(h):
        for j in range(w):
            result = max(result, yoko[i][j] + tate[i][j] - 1)
 
 
    print(result)

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
 
int main() {
  string S;
  cin >> S;
  
  bool ok = false;
  if(S == "AKIHABARA") ok =true;
  
  if(S == "KIHABARA") ok =true;
  if(S == "AKIHBARA") ok =true;
  if(S == "AKIHABRA") ok =true;
  if(S == "AKIHABAR") ok =true;
  
  if(S == "AKIHABR") ok =true;
  if(S == "AKIHBAR") ok =true;
  if(S == "KIHABAR") ok =true;
  
  if(S == "AKIHBRA") ok =true;
  if(S == "KIHABRA") ok =true;
  if(S == "KIHBARA") ok =true;
  
  if(S == "KIHBRA") ok =true;
  if(S == "KIHBAR") ok =true;
  if(S == "KIHABR") ok =true;
  if(S == "AKIHBR") ok =true;
  
  if(S == "KIHBR") ok =true;
  
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
}
  



Measured memory_bytes: 256