akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }



int main()
{
  fastio();

  int n; cin >> n;

  int c = 0;
  for (int i = 1; i < n - i; i++)
    c++;

  cout << c << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int x;
   cin >> x;
   if (x < 1200) cout << "ABC" << endl;
   else cout << "ARC" << endl;
   return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
f = [False] * n
f[0] = True
num = [1] * n

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1

    num[x] -= 1
    num[y] += 1

    if f[x]:
        f[y] = f[x]

    if num[x] == 0:
        f[x] = False

cnt = 0
for i in range(n):
    if f[i]:
        cnt += 1

print(cnt)

Measured memory_bytes: 53848
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++ ){
            p[i] = sc.nextInt();
            if(p[i] - 1 != i){
                p[i] = -1;
            }
        }
        if(n < 3){
            System.out.println("YES");
        }else{
            Arrays.sort(p);
            if(p[2] == -1){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }
        sc.close();

    }
}

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

using namespace std;
#define PI acos(-1)

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

	int num = 0;
	


	int* M = new int[N];

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

	for (int i = 0; i < N - 2; i++)
	{
		for (int j = i + 1; j < N - 1; j++)
		{
			for (int k = j+1; k < N; k++)
			{
				if (M[i] != M[j] && M[k] != M[j] && M[i] != M[k])
				{


					if (M[i] + M[j] > M[k] && M[i] + M[k] > M[j] && M[k] + M[j] > M[i])
					{
						//cout << M[i] << M[j] << M[k] << endl;
						num++;
					}
				}
			}
		}
	}



	if (N < 3)
	{
		num = 0;
	}

	
	
	cout << num;

	
}



Measured memory_bytes: 3616
import sys


class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
P = list(map(int, input().split()))
uf = UnionFind(N)
for IN in sys.stdin.readlines():
    x, y = map(int, IN.split())
    x -= 1; y -= 1
    uf.union(x, y)

ans = 0
for i, p in enumerate(P):
    p -= 1
    if i == p:
        ans += 1
    else:
        if uf.find(i) == uf.find(p):
            ans += 1

print(ans)


Measured memory_bytes: 17076
#include <bits/stdc++.h>
using namespace std;
int main() {
string a,b,c;
cin>>a>>b>>c;
if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0))
	cout<<"YES";
else
	cout<<"NO";
}

		


Measured memory_bytes: 256
from collections import Counter
from collections import defaultdict
import math

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[str(s)] += 1

for c in L.values():
    if c > 1:
        ans += combination(c, 2)
print(ans)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<vector<int>> f(n,vector<int>(10)), p(n,vector<int>(11));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	long long ans = -1e18;
	for(int i = 1 ; i < (1 << 10); i++) {
		long long tmp = 0;
		vector<int> cnt(n, 0);
		for(int j = 0; j < 10; j++) {
			if(1 & (i >> j)) {
				for(int k = 0; k < n; k++) {
					if(f[k][j]) {
						cnt[k]++;
					}
				}
			}
		}
		for(int j = 0; j < n; j++) {
				tmp += p[j][cnt[j]];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
import heapq

N,M = map(int,input().split())
#lst = list(map(int,input().split()))
lst = [-int(x) for x in input().split()]

heapq.heapify(lst)
 
for i in range(M):
    lstmin = heapq.heappop(lst)
    b = (-(lstmin) // 2)
    heapq.heappush(lst,-b)
    
print (-sum(lst))

Measured memory_bytes: 14180
#include <iostream>
#include <stdio.h>

bool judge(int, int, int);

int main() 
{
	int N;
	int a;
	int b;
	int c;
	
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> a >> b >> c;
		if (judge(a, b, c)){
			std::cout << "YES" << std::endl;
		} else {
			std::cout << "NO" << std::endl;
		}
	}
	
	return 0;
}

bool judge(int a, int b, int c) {
	if (a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b) {
		return true;
	} else {
		return false;
	}
}

Measured memory_bytes: 1152
L,R = map(int,input().split())
S = list()
n = R-L
if n >= 673:
    print(0)
else:
    for i in range(n+1):
        for j in range(i+1,n+1):
            l = L+i
            r = L+j
            S.append((l*r)%2019)
    print(min(S))

Measured memory_bytes: 6804
N = int(input())
A = list(map(int, input().split()))

gokei = 0
ans1 = 0

for i in range(N):
    gokei += A[i]
    # 偶数番目を負に
    if i % 2 == 0:
        if gokei >= 0:
            ans1 += abs(-1 - gokei)
            gokei -= abs(-1 - gokei)
    if i % 2 == 1:
        if gokei <= 0:
            ans1 += 1 - gokei
            gokei += (1 - gokei)


gokei = 0
ans2 = 0
for i in range(N):
    gokei += A[i]
    # 偶数番目を正に
    if i % 2 == 0:
        if gokei <= 0:
            ans2 += 1 - gokei
            gokei += (1 - gokei)
    else:
        if gokei >= 0:
            ans2 += abs(-1 - gokei)
            gokei -= abs(-1 - gokei)

print(min(ans1, ans2))

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

int main(){
  int N,M,X,Y;
  cin >>N>>M>>X>>Y;
  
  vector<int> x(N+1);
  rep(i,0,N) cin >>x[i];
  x[N] = X;
  
  vector<int> y(M+1);
  rep(i,0,M) cin >>y[i];
  y[M] = Y;
  
  int zx = *max_element(x.begin(),x.end());
  int zy = *min_element(y.begin(),y.end());
  
  string ans;
  if(zx<zy) ans = "No War";
  else ans = "War";
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
x = (tx-sx)
y = (ty-sy)

order = "L"

order += "U"*(y+1)
order += "R"*(x+1)
order += "D"

order += "R"
order += "D"*(y+1)
order += "L"*(x+1)
order += "U"

order += "U"*y
order += "R"*x
order += "D"*y
order += "L"*x
print(order)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int32_t n;
  cin >> n;
  double dp[2][n + 1];
  double p[n];
  rep(i, n) {
    cin >> p[i];
    dp[0][i + 1] = 0;
  }

  dp[0][0] = 1.0 - p[0];
  dp[0][1] = p[0];

	//cerr << 0 << ": " << dp[0][0] << ' ' << dp[0][1] << '\n'; 
  loop(i, 1, n) {
		//cerr << i << ": ";
    rep(k, n + 1) {
      if (k == 0) {
        dp[i % 2][k] = (1.0 - p[i]) * dp[(i + 1) % 2][k];
      } else {
        dp[i % 2][k] =
            (1.0 - p[i]) * dp[(i + 1) % 2][k] + p[i] * dp[(i + 1) % 2][k - 1];
      }
			//cerr << dp[i % 2][k] << ' ';
    }
		//cerr << '\n';
  }

	double psum = 0;
	for (int k = n; k >= (n / 2) + 1; k--)  {
		psum += dp[(n - 1)%2][k];
	}

	cout << psum;
}

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

int main() {
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(r>x||r>y||r+x>W||r+y>H){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	
}

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

using i64 = int64_t;

struct Node{
    int friends, blocks;
};

template <template <class> class Container> class union_find {
protected:
  class node_type;

public:
  using container_type = Container<node_type>;
  using size_type = typename container_type::size_type;

protected:
  class node_type {
  public:
    typename union_find::size_type parent;
    typename union_find::size_type size;
  };

  container_type tree;

public:
  union_find() : tree() {}
  explicit union_find(const size_type size) : tree(size, {0, 1}) {
    for (size_type i = 0; i < size; ++i)
      tree[i].parent = i;
  }

  bool empty() const { return tree.empty(); }
  size_type size() const { return tree.size(); }

  size_type find(size_type x) {
    assert(x < size());
    while (tree[x].parent != x)
      x = tree[x].parent = tree[tree[x].parent].parent;
    return x;
  }
  bool same(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < size());
    return tree[find(x)].size;
  }

  ::std::pair<size_type, size_type> unite(size_type x, size_type y) {
    assert(x < size());
    assert(y < size());
    x = find(x);
    y = find(y);
    if (x != y) {
      if (tree[x].size < tree[y].size)
        ::std::swap(x, y);
      tree[x].size += tree[y].size;
      tree[y].parent = x;
    }
    return {x, y};
  }
};

template<class T>
using vec_alias = ::std::vector<T>;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<Node> v(n+1);
    union_find<vec_alias> uft(n+1);
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        uft.unite(a, b);
        v[a].friends++;
        v[b].friends++;
    }
    for(int i=0;i<k;++i){
        int c, d;
        cin >> c >> d;
        if(uft.same(c, d)){
            v[c].blocks++;
            v[d].blocks++;
        }
    }

    for(int i=1;i<=n;++i){
        if(i > 1)cout << " ";
        cout << uft.size(i) - v[i].friends - v[i].blocks - 1;
    }
    cout << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b;
	while(cin >> a >> b){
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18 + 7;
const int N = 2e5 + 7;
int n;
int a[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    int sum = 0;
    for (int i = 0; i < n; ++i) sum += a[i];
    int ans = INF;
    int cur = 0;    
    for (int i = 0; i < n - 1; ++i) {
        cur += a[i];
        ans = min(ans, abs(cur - (sum - cur)));    
    }   
    cout<< ans << '\n';
}   

Measured memory_bytes: 1792
n = int(input())
ans = 1
k = 107
i = 1
count = 0
if n < 105:
    print(0)
else:
    while k <= n:
        while i <= k:
            if k % i == 0 :
                count += 1
            if count == 8:
                ans += 1
                break   
            i += 2
        count = 0
        i = 1
        k += 2
    print(ans)
    
        
            


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/
 
signed main(){
  string s;
  cin>>s;
  if(s=="SUN")cout<<"7"<<endl;
  if(s=="MON")cout<<"6"<<endl;
  if(s=="TUE")cout<<"5"<<endl;
  if(s=="WED")cout<<"4"<<endl;
  if(s=="THU")cout<<"3"<<endl;
  if(s=="FRI")cout<<"2"<<endl;
  if(s=="SAT")cout<<"1"<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3628
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

l=[0]*10**5

for item in A:
    l[item-1]+=1

ex=0
for item in l:
    ex+=max(item-1,0)

if ex%2==1:
    print(N-ex-1)
else:
    print(N-ex)





Measured memory_bytes: 14004
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) { return cost < b.cost; }
	bool operator>(const P &b) { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) { return cost < b.cost; }
	bool operator>(const E &b) { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
bool b[2000000];
signed main() {
	int s;
	cin >> s;
	b[s] = 1;
	for (int i = 2;; i++) {
		if (s % 2 == 0) s /= 2;
		else s = 3 * s + 1;
		if (b[s]) {
			cout << i << endl;
			break;
		}
		b[s] = 1;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#include<cstdio>
#define PI 3.1415927
int counts[300000];
char a[300000];
int main()
{
   int i,n,temp=0;

   while(scanf("%d",&n)!=EOF)
   {
       memset(a,'\0',sizeof(a));


      scanf("%s",a);
    for(i=0,temp=0;i<n;i++)
       {
        counts[i]=temp;
         if(a[i]=='W')
         {

             temp++;

         }

       }

      for(i=n-1,temp=0;i>=0;i--)
       {
           counts[i]=counts[i]+temp;
           if(a[i]=='E')
           {

               temp++;

           }


       }
       sort(counts,counts+n);
    printf("%d\n",counts[0]);


      }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
        
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif  
 
        fast;
        string s;
        cin>>s;
        if(s[2]==s[3] && s[5]==s[4]) cout<<"Yes";
        else cout<<"No";
        return 0;  
    } 

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

int main(){
    int N;
    cin >> N;
    long A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    long x[2] = {};
    int cnt=0;
    for (int i=N-1;i>0;i--){
        if(A[i] == A[i-1]){x[cnt]=A[i];cnt++;i--;}
        if(cnt>=2)break;
    }
    cout << x[0] * x[1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int a,b,v;
	scanf("%lld%lld%lld",&a,&b,&v);
	if(v>(double)a*a*b/2)
	{
		v=a*a*b-v;
		double x=(double)v/a/a*2;
		printf("%.20lf",(double)atan(x/a)/acos(-1)*180);
	}
	else
	{
		double x=(double)v/a/b*2;
		printf("%.20lf",(double)atan(b/x)/acos(-1)*180);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,O,P,Q,Z;
  Z=0;
  cin >> N;
  O=N;
  P=N;
  N %=10;//1桁目
  P /=10;
  Q=P;
  Z +=N;//代入
  P %=10;//2桁目
  Q /=10;
  Z +=P;//代入
  Q %=10;//3桁目
  Z +=Q;//代入
  cout << Z <<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX_N = 2e5;
vector<ll>v[MAX_N];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,x, i;
     cin >> n;
    for(i=1; i<n; i++)
    {
        cin >> x;
        v[x].push_back(i);
    }
    for(i=1; i<=n; i++)
    {
        cout<<v[i].size()<<endl;
    }
    return 0;
}


Measured memory_bytes: 14536
#include<cstdio>
int n,c[510],s[510],f[510],i,a,j,k;main(){for(scanf("%d",&n);k<n-1;++k)scanf("%d%d%d",c+k,s+k,f+k);for(f[k]=1;i<n;a=0)for(j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(~-a/f[j]+1)*f[j])+c[j++];}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<boost/multiprecision/cpp_int.hpp>

#define ll unsigned long long

using boost::multiprecision::cpp_int;

cpp_int func(cpp_int N,cpp_int A,cpp_int B)
{
	if ((B-A)% 2==0)
		return (B-A)/2;
	else
	{
		cpp_int temp = A - 1 + (B - A) / 2 + 1;
		cpp_int temp2 = (N - B) + (B - A) / 2 + 1;
		return std::min(temp, temp2);
	}
	
}
int main()
{
	cpp_int N,A,B;
	std::cin >> N >> A >> B;
	std::cout<<func(N, A, B);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll x;
    cin >> x;

    ll k = 0;
    while (1)
    {
        k++;
        if (k * (k + 1) / 2 >= x)
        {
            break;
        }
    }

    cout << k << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int IsPrime (int n);

int main(void){

  int n;
  int max;
  int count;

  while(cin >> n&&n){

    count=0; 
    max=2*n;

    for(int i=n+1;i<=max;i++){
      if(IsPrime(i))
	count++;
    }

      cout << count <<endl;
    
  }


  
  return 0;

}

int IsPrime (int n)
{
  int i;

  if (n < 2)
    return 0;
  else if (n == 2)
    return 1;

  if (n % 2 == 0)
    return 0;

  for (i = 3; i <= n / i; i += 2)
    if (n % i == 0)
      return 0;
  return 1;
}

Measured memory_bytes: 3088
#include<cstdio>

#define ran 101101

int n;
int a[ran];

int main() {
	scanf("%d", &n);
	
	int cur = 0;
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		if(i%2) cur -= a[i];
		else cur += a[i];
	}
	
	printf("%d", cur);
	for(int i=1;i<n;i++) {
		cur = (a[i-1]-cur/2)*2;
		printf(" %d", cur);
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(){
  int N,i,j,cnt=0,tmp=0,flag=1,A[100];
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  while(flag==1){
    flag=0;
    
    for(j=N-1;j>0;j--){      
      if (A[j] < A[j-1]){
	tmp=A[j];   //A[j] と A[j-1] を交換
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	cnt++;
      }
    }
  } 
  
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
using namespace std;
int main(){
    int S;
    int h;
    int m;
    int s;
    
    cin>>S; 
    cin>>h;
    cin>>m;
    cin>>s;
    
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}


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

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

vector<edge> es;
int V,E; //頂点数、辺数

struct UF{
  vector<int> par; //親
  vector<int> size; //集合の大きさ

  void init(int n){
    par.resize(n);
    size.resize(n);
    for(int i = 0; i < n; i++){
      par[i] = i;
      size[i] = 1;
    }
    size[0] = 100000;
  }

  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }

  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(size[x] < size[y]) swap(x,y);
    par[y] = x;
    size[x] += size[y];
  }

}uf;

int kruskal(){
  sort(es.begin(),es.end(),comp);
  uf.init(V+1);
  int total = 0;
  for(int i = 0; i < es.size(); i++){
    edge e = es[i];
    if(uf.root(e.u) != uf.root(e.v)){
      total += e.cost;
      uf.unite(e.u,e.v);
    }
  }
  return total;
}

signed main(){

  cin >> V >> E;

  for(int i = 0; i < E; i++){
    int x,y,z; cin >> x >> y >> z;
    es.push_back({x,y,0});
    es.push_back({x,0,1});
  }

  int ans = kruskal();
  for(int i = 0; i <= V; i++){
    if(uf.par[i] == i && uf.size[i] == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8432
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.Array

modNum :: Int
modNum = 10^9 + 7

solve :: Int -> Int -> Int
solve n m
    | n > m = solveI n m
    | n < m = solveI m n
    | otherwise = ((solveI n m) + (solveI m n)) `mod` modNum

solveI :: Int -> Int -> Int
solveI 1 1 = 1
solveI n m
    | n - m >= 2 = 0
    | otherwise = (n * (solveI m (n - 1))) `mod` modNum

main :: IO()
main = do
    [n, m] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ solve n m


Measured memory_bytes: 8060
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a == b){
            System.out.println("a == b");
        }else if(a > b){
            System.out.println("a > b");
        }else{
            System.out.println("a < b");
        }
        sc.close();
    }
}



Measured memory_bytes: 26204
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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














int main() {
    string s;
    cin >> s;
    vector<ll> v;
    bool r = false;
    ll n = s.size();
    REP(i, n){
        if(s[i] == 'R'){
            r = true;
        }
        else{
            if(r){
                r = false;
                v.push_back(i - 1);
            }
        }
    }
    vector<ll> ans(n);
    REP(i, n){
        if(s[i] == 'R'){
            ll idx = *lower_bound(v.begin(), v.end(), i);
            cerr << idx << endl;
            if(abs(i - idx) % 2 == 0){
                ans[idx]++;
            }
            else{
                ans[idx + 1]++;
            }
        }
        else{
            ll idx = *--lower_bound(v.begin(), v.end(), i);
            cerr << idx << endl;
            if(abs(idx - i) % 2 == 0){
                ans[idx]++;
            }
            else{
                ans[idx + 1]++;
            }
        }
    }
    REP(i, n){
        cout << ans[i] << " \n"[i == n - 1];
    }
}

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

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  vector<ll> s(n);// 累積和
  s[0] = a[0];
  rep(i, n-1) s[i+1] = s[i] + a[i+1];

  ll ans = INF;
  for (int i = 0; i < n-1; i++) {
    chmin(ans,abs(s[i]-(s[n-1]-s[i])));
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

    if(n<10)cout << r + 100*(10-n) << endl;
    else cout << r << endl;

    return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m,k,h;
  while(cin>>n>>m>>h>>k,n){
    vector<Int> s(n);
    for(Int i=0;i<n;i++) cin>>s[i];
    vector<vector<Int> > b(h);   
    for(Int i=0;i<m;i++){
      Int x,y;
      cin>>x>>y;
      x--;
      b[y].emplace_back(x);
    }
    //cout<<"OK"<<endl;
    vector<Int> ord(n);
    iota(ord.begin(),ord.end(),0);
    for(Int i=0;i<h;i++)
      for(Int j:b[i])
	swap(ord[j],ord[j+1]);

    vector<Int> rev(n);
    for(Int i=0;i<n;i++) rev[ord[i]]=i;

    Int sum=0;
    for(Int i=0;i<k;i++) sum+=s[rev[i]];
    Int ans=sum;
    
    vector<Int> cur(n);
    iota(cur.begin(),cur.end(),0);
    for(Int i=0;i<h;i++){
      for(Int j:b[i]){
	//cout<<cur[j]<<" "<<cur[j+1]<<endl;
	//cout<<rev[cur[j]]<<" "<<rev[cur[j+1]]<<endl;
	if(cur[j]<k&&cur[j+1]>=k){
	  Int tmp=sum+s[rev[cur[j+1]]]-s[rev[cur[j]]];
	  chmin(ans,tmp);
	}
	if(cur[j+1]<k&&cur[j]>=k){
	  Int tmp=sum+s[rev[cur[j]]]-s[rev[cur[j+1]]];
	  chmin(ans,tmp);
	}	
	swap(cur[j],cur[j+1]);       
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 4192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()

	dp := [60][60][10000]int{}
	dp[0][0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j < i+1; j++ {
			for x := 0; x < k+1; x++ {
				if j > 0 {
					dp[i+1][j-1][x+(j-1)*2] += dp[i][j][x]*j*j%MOD
					dp[i+1][j-1][x+(j-1)*2] %= MOD
				}
				dp[i+1][j][x+j*2] += dp[i][j][x] + dp[i][j][x]*j*2%MOD
				dp[i+1][j][x+j*2] %= MOD
				dp[i+1][j+1][x+(j+1)*2] += dp[i][j][x]
				dp[i+1][j+1][x+(j+1)*2] %= MOD
			}
		}
	}

	fmt.Fprintln(wr, dp[n][0][k])
}

// MOD constant
const MOD = 1000000007


Measured memory_bytes: 290944
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    for(ll i=K;i<N;++i){
        if(A[i-K]<A[i])prt("Yes");
        else prt("No");
    }

    return 0;
}



Measured memory_bytes: 4760
import numpy as np
n,m,x = map(int,input().split())
value = []
books = []
for i in range(n):
    a = list(map(int,input().split()))
    value.append(a[0])
    books.append(np.array(a[1:]))
if min(sum(books))<x:
    print(-1)
else:
    ans = 10**8
    for i in range(2**n):
        M = np.array([0]*m)
        v = 0
        for j in range(n):
            if i >> j & 1:
                M += books[j]
                v += value[j]
        if min(M)>= x:
            ans = min(ans,v)
    print(ans)

Measured memory_bytes: 27156
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
ll modinv(ll a, ll m) {
    ll b=m,u=1,v=0;
    while(b){
        ll t = a/b;
        a -= t*b; swap(a,b);
        u -= t*v; swap(u,v);
    }
    u %= m;
    if (u<0) u += m;
    return u;
}
vector<ll> kaijou(100010);
ll p(int x,int y){
    if(x<y || y<0)  return 0;
    return kaijou[x]*modinv(kaijou[x-y],MOD)%MOD;
}

ll ans;
int k;
vector<vector<int>> children;
void dfs(int now,int parent){
    int s=children[now].size();
    if(now==0) ans*=p(k-1,s);
    else ans*=p(k-2,s-1);
    ans%=MOD;
    
    for(int child:children[now]){
        if(parent==child) continue;
        dfs(child,now);
    }

}

int main(){
    kaijou[0]=1;
    rep(i,1,100010) kaijou[i]=(kaijou[i-1]*i)%MOD;
    
    int n;
    cin>>n>>k;
    children.resize(n);
    
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        children[a].push_back(b);
        children[b].push_back(a);
    }
    
    ans=(ll)k;
    dfs(0,-1);
    cout<<ans<<endl;
}


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

using namespace std;

int main(){
	long long int N;
	cin >> N;
	vector<long long int>D(N);
	for( size_t i = 0; i < N; i++ ){
		cin >> D[i];
		if( D[i] > i ){
			cout << -1 << endl;
			return 0;
		}
		if( i ){
			if( D[i - 1] + 1 < D[i] ){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	vector<long long int>E(N);
	long long int ans = 0;
	for( int i = N - 1; i >= 0; i-- ){
		if( i != N - 1 ){
			E[i] = max(E[i + 1] - 1, 0LL);
		}
		if( E[i] > D[i] ){
			cout << -1 << endl;
			return 0;
		} else if( E[i] == D[i] ){
			continue;
		} else{
			E[i] = D[i];
			ans += D[i];
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int maxn = 800;
int main() {
	long long n, k;
	long long ans = 0;
	cin >> n >> k;
	if(k == 0){
		cout << n*n;
		return 0;
	}
	for(int i = k + 1; i <= n; ++i){
		long long numeros = (n/i) * (i - k);
		ans+= numeros;
		ans+= max((n%i - k + 1LL), 0LL);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x,y;
	cin>>x>>y;
	bool result=false;
	int i;
	for(i=0;i<=x;i++)
	{
		int here=2*i+(x-i)*4;
		if(here==y)
		{
			result=true;
			break;
		}
	}
	if(result)
	{
	    cout<<"Yes"<<endl;
	}
	else
	  cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;
const int M = 1e5 + 10;
int f[600] , cnt[600] , c[600];
vector<int>vc[600];
void init() {
    for(int i = 0 ; i <= 555 ; i++) {
        cnt[i] = 0;
        c[i] = 0;
        f[i] = i;
    }
}
int find(int x) {
    if(x == f[x]) return x;
    int tmp = find(f[x]);
    return f[x] = tmp;
}

int main() {
    int n , h;
    scanf("%d%d" , &n , &h);
    init();
    for(int i = 1 ; i <= n ; i++) {
        int a , b , c , d;
        scanf("%d%d%d%d" , &a , &b , &c , &d);
        int x = c , y = -d;
        if(c == 0) x = -a;
        if(d == 0) y = b;
        x += 250 , y += 250;
        vc[x].push_back(y);
        cnt[x]++ , cnt[y]--;
        f[find(x)] = find(y);
    }
    int flag = 1;
    for(int i = 0 ; i <= 500 ; i++) {
        if(i > 250 && cnt[i] > 0) flag = 0;
        if(i < 250 && cnt[i] < 0) flag = 0;
        if(cnt[i] > 0) {
            c[find(i)] = 1;
        }
    }
    for(int i = 0 ; i <= 500 ; i++) {
        if(vc[i].size() > 0 && !c[find(i)]) flag = 0;
    }
    flag ? puts("YES") : puts("NO");
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main() {
  int c = 0;
  std::string s1, s2;
  std::cin >> s1 >> s2;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] != s2[i]) {
      c++;
    }
  }
  std::cout << c;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
#define fout cout << fixed << setprecision(20)
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<double> a(n);
    double sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(all(a), greater<int>());
    cout << (a[m - 1] >= sum / (4.0 * m) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[100010],to[100010],co[100010],nt[100010],it[100010],l[100010];
void mklsb(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[a[i]]=i  ]=c[i];      
    co[ta[b[i]]=i+e]=0;
  }
}
/*int MF(int e,int s,int t,int min){
  if(s==t)return min;
  int i,r;
  for(i=ta[s];i+1;i=nt[i]){
    if(co[i]==0||l[s]>=l[to[i]])continue;
    r=MF(e,to[i],t,MIN(min,co[i]));
    co[i]-=r;
    co[(i+e)%(2*e)]+=r;
    return r;
  }
  return 0;
  }//*/
int MF(int e,int s,int t,int min){
  if(s==t)return min;
  int i,r;
  for(;it[s]+1;it[s]=nt[it[s]]){
    if(co[it[s]]==0||l[s]>=l[to[it[s]]])continue;
    //printf("fr%2d to%2d co%2d nt%2d\n",s,to[it[s]],co[it[s]],nt[it[s]]);
    //if(nt[it[s]]==0)continue;
    r=MF(e,to[it[s]],t,MIN(min,co[it[s]]));
    if(r>0){
      co[it[s]]-=r;
      co[(it[s]+e)%(2*e)]+=r;
      return r;
    }
  }
  return 0;
}
int maxf(int v,int e,int s,int g){
  int i,a=0,q[100010],t,r,c=3;
  while(1){
    /*for(i=0;i<v;i++){//printf("%d\n",i);
      for(r=ta[i];r+1;r=nt[r]){
	//printf("id%2d to%2d co%2d nt%2d\n",r,to[r],co[r],nt[r]);
      }
      //printf("\n");
      }//printf("\n");//*/
    q[0]=s;
    for(i=t=0;i<v;i++)l[i]=-1;
    l[q[0]]=0;
    for(r=1;r-t;t++){
      for(i=ta[q[t]];i+1;i=nt[i]){
	if(co[i]==0||l[to[i]]+1)continue;
	l[to[i]]=l[q[t]]+1;
	q[r++]=to[i];
      }
    }//printf("BFS%d\n",a);
    //for(i=0;i<v;i++)printf("%d %d\n",i,l[i]);
    if(l[g]<0)return a;
    for(i=0;i<v;i++)it[i]=ta[i];
    for(;(r=MF(e,s,g,1e9))>0;a+=r);//printf("DFS%d\n",r);
  }
  return a;
}
int main(){
  int n,m,i,a[100010],b[100010],c[1000010],m1,m2;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  mklsb(n,m,a,b,c);//prls(n);
  m1=maxf (n,m,0,n-1);
  printf("%d\n",m1);
  return 0;
}
  

Measured memory_bytes: 2716
def solve(sa, sb, sc, t):
	d = {'a': sa, 'b': sb, 'c': sc}
	if d[t] == '':
		return t.upper()
	u = d[t][0]
	d[t] = d[t][1:]
	return solve(d['a'], d['b'], d['c'], u)

SA = input()
SB = input()
SC = input()
print(solve(SA, SB, SC, 'a'))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, ans;
  cin >> S;
  if (S == "Sunny"){
    ans = "Cloudy";
  }
  if (S == "Cloudy"){
    ans = "Rainy";
  }
  if (S == "Rainy"){
    ans = "Sunny";
  }
  cout << ans << endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    set<int> E[N];
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        E[a].insert(b);
        E[b].insert(a);
    }
    int A[N], ans = 0;
    rep(i, N) A[i] = i;
    do{
        int t = 1;
        rep(i, N - 1){
            if(E[A[i]].find(A[i + 1]) == E[A[i]].end()) t = 0;
        }
        ans += t;
    }while(next_permutation(A + 1, A + N));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n, m;   cin >> n >> m;
    vector<bool> v(n-1, true);
    vector<pair<int, int>> g;
    for(int i=0; i<m; i++){
        int a, b;   cin >> a >> b;
        g.push_back(make_pair(b, a));
    }
    sort(g.begin(), g.end());
    int left=0;
    int cnt=0;
    for(int i=0; i<m; i++){
        if(left<=g.at(i).second){
            cnt += 1;
            left = g.at(i).first;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout<<fixed;cout<<setprecision(10);
#define in cin>>
#define out cout<<
#define br cout<<"\n";

void solve(){
    int n,m,k;
    cin>>n>>m>>k;
    int a[n];
    int b[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int sum = 0;
    int suma = 0;
    int count = 0;
    int maxcount = 0;
    for(int i = 0 ; i < n; i++){
        sum+=a[i];
        count++;
        suma++;
        if(sum > k){
            count--;
            suma--;
            sum-=a[i];
            break;
        }
    }
    maxcount = count;
    for(int i = 0; i < m; i++){
        sum+=b[i];
        count++;
        if(sum > k){
            count--;
            if(suma == 0){
                break;
            }
            count--;
            sum -= b[i];
            sum -= a[suma-1];
            suma--;
            i--;
        }
        maxcount = max(maxcount,count);
    }
    cout<<maxcount<<"\n";
}

int32_t main(){
    FASTIO
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    #endif

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

    #ifndef ONLINE_JUDGE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
    #endif

    return 0;
}

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

int HCF(int a, int b){
	int num;
	if(a < b){
		num = a;
		a = b;
		b = num;
  	}
  	num = a % b;
	while(num != 0){
		a = b;
		b = num;
		num = a % b;
	}
	return b;
}

int main(){
	int A, B, C;
	cin >> A >> B >> C;	
	if(HCF(B, C) % HCF(A, B) == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import itertools as ite
import math
import random

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
x = map(int, raw_input().split())

ls = []
for i in range(N):
    ls += [(x[i] - 1, i + 1)]
ls.sort()
ans = [-1] * (N * N)

pos = 0
for id, num in ls:
    ans[id] = num
    cnt = num - 1
    while cnt > 0:
        if pos >= id:
            print "No"
            exit()
        if ans[pos] == -1:
            ans[pos] = num
            cnt -= 1
        pos += 1

pos = N * N - 1

for id, num in ls[::-1]:
    cnt = N - num
    while cnt > 0:
        if pos <= id:
            print "No"
            exit()
        if ans[pos] == -1:
            ans[pos] = num
            cnt -= 1
        pos -= 1

print "Yes"
print " ".join(map(str, ans))


Measured memory_bytes: 17652