akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  string s,t,u;
  int a,b;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(s==u) a--;
  else b--;
  cout<<a<<" "<<b<<endl;

  return 0;
}




Measured memory_bytes: 256
# coding=utf-8


def is_rect(quadr):
    if quadr[0]**2 + quadr[1]**2 == quadr[2]**2:
        return True
    return False


def is_rhombus(quadr):
    if quadr[0] == quadr[1]:
        return True
    return False


if __name__ == '__main__':
    counter_list = [0, 0]
    while True:
        try:
            quadr = list(map(int, input().split(',')))
            if is_rect(quadr):
                counter_list[0] += 1
            if is_rhombus(quadr):
                counter_list[1] += 1
        except EOFError:
            break
    print(counter_list[0])
    print(counter_list[1])



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

int main(){
	ll n;
	scanf("%lld", &n);
	ll an = n / 11 * 2;
	n %= 11;
	if (n > 6)an += 2;
	else if (n)++an;
	printf("%lld\n", an);
}


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

using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = s[k-1] + 0x20;
    cout << s << endl;
}

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

Measured memory_bytes: 3556
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N, M = LI()
S = input()
T = input()

#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(N, M)
L = X
#  XS = ['X' for i in range(L+1)]
#  XT = ['X' for i in range(L+1)]
XS, XT = {}, {}
count = 0
LN = L/N
while True:
    XS[int(count*LN)] = S[count]
    count += 1
    if count > N-1:
        break

count = 0
LM = L/M
while True:
    XT[int(count*LM)] = T[count]
    count += 1
    if count > M-1:
        break

for key, value in XS.items():
    #  print(key, value)
    if key in XT:
        if value != XT[key]:
            print(-1)
            exit()
#  print(XS, XT)
#  for i in range(0, L+1):
#      if XS[i] != 'X' and XT[i] != 'X':
#          if XT[i] != XS[i]:
#              print(-1)
#              exit()
print(L)


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    rep(i, 1, n) {
        rep(j, i + 1, n + 1) {
            int k = 0;
            while((i & (1 << k)) == (j & (1 << k))) {
                k++;
            }
            cout << k + 1 << " ";
        }
        cout << en;
    }
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vsz = vector<size_t>;

int main ()
{
    i64 a, b, c, k;
    cin >> a >> b >> c >> k;
    i64 sum;
    if (a < k) {
        sum = a;
        k -= a;
        if (b < k) {
            k -= b;
            if (c < k) {
                sum += -c;
            } else {
                sum += -k;
            }
        }
    } else {
        sum = k;
    }
    cout << sum;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

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

using namespace std;

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

    ull a, b, x;
    cin >> a >> b >> x;
    if (a == 0) cout << b/x + 1 << endl;
    else cout << b/x - (a-1)/x << endl;

    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
const int N = 1e5 + 5;

int32_t main(){
	fast;
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)    cin >> a[i];
    sort(a,a+n);
    int diff = INT_MAX;
    int d1 = a[n-1]/2;
    int d2 = (a[n-1] + 1)/2;
    int y;
    for(int i=0;i<n-1;i++)
    {
        if(abs(a[i] - d1) < diff)
            diff = abs(a[i] - d1) , y = a[i];
        if(abs(a[i] - d2) < diff)
            diff = abs(a[i] - d2) , y = a[i];
        
    }
    cout<<a[n-1]<<" "<<y;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  set<string> w;
  int ans=0;
  rep(i,n){
    string s;
    cin >> s;
    if(w.count(s))continue;
    else{
      w.insert(s);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 19124
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;
const double pi = acos(-1);

const int maxN=1e5;

void solve(){
    int n;
    cin>>n;
    cout<<(n*(n+1)/2)<<"\n";
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
		String str = "";
		StringTokenizer st;
		int num[] = new int[3];
		int index[] = new int[2];
		int max = 0, i, j, k;
		
		str = br.readLine();
		int datasets =  Integer.parseInt(str);
		
		for (i = 0; i < datasets; i++) {
			str = br.readLine();
			st = new StringTokenizer(str, " ");
			num[0] = Integer.parseInt(st.nextToken());
			num[1] = Integer.parseInt(st.nextToken());
			num[2] = Integer.parseInt(st.nextToken());
			for (j =0; j < 3; j++) 
	            if(num[max] < num[j]) max = j;
			k = 0;
			for (j = 0; j < 3; j++) 
	            if(num[j] != num[max]) index[k++] = j;
			if ((num[max] * num[max]) == (num[index[0]] * num[index[0]] + num[index[1]] * num[index[1]]))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 24296
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[110][100010];
vector <pair<int, int>> wv;

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	//int k=0; // 最大value總和 
	for (int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		wv.emplace_back(a, b); //wv
		//k+=b;
	}
	int MAX = w+100;
	for (int i = 0; i < 100010; i++){
		dp[0][i] = MAX;
	}
	for (int i = 0; i < 110; i++){
		dp[i][0] = MAX;
	}
	int cnt1 = 0, cnt2=0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= 100010; j++){ 
			if (wv[i-1].second >= j){
				dp[i][j] = min(dp[i-1][j], wv[i-1].first);
			}else{
				dp[i][j] = min(dp[i-1][j-wv[i-1].second]+wv[i-1].first, dp[i-1][j]);
			}
		}
	}
	/*
	for (int i = 1; i <= 110; i++)
		cout << setw(4) << i << " ";
	cout << "\n";
	for (int i = 1; i <=n; i++){
		for (int j = 1; j <= 110; j++){
			cout << setw(4)<<dp[i][j] <<" "; 
		}
		cout << "\n";
	}
	*/
	for (int i = 1; i < 100010; i++){
		if (dp[n][i+1]>w){
			cout << i << "\n";
			break;
		}
	}
} 

Measured memory_bytes: 84224
//  cd Desktop/Atcoder
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,n) for(i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

long double to_deg(long double r) {
    return r * 180.0 / (atan(1.0) * 4.0);
}

int main(){
    long double a,b,x,ans=0;
    scanf("%Lf%Lf%Lf",&a,&b,&x);
    ans=atan2l(2*(a*a*b-x),a*a*a);
    if (tanl(ans)*a>b) ans=atan2l(a*b*b,2*x);
    printf("%.10Lf",to_deg(ans));
    return 0;
}

Measured memory_bytes: 2500
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    bool judge = false;
    int n[26];
    char ans;
    string s;
    cin >> s;
    for(int i = 0;i < 26;i++){n[i] = 0;}
    for(int i = 0;i < s.size();i++)
    {
        n[s[i] - 97] = 1;
    }
    for(int i = 0;i < 26;i++)
    {
        if(n[i] == 0){ans = i + 97; judge = true; break;}
    }
    if(judge){cout << ans << endl;}
    else{cout << "None" << endl;}
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
ll M3 = 1e8;
ll MAX = 5001;
string s = "Everything correct till here!";

void show(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<v[i].ff<<" "<<v[i].ss<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;
    while(T--)
    {
        ll n; cin>>n;
        ll a[n]; f(i,n) cin>>a[i];
        ll dp[n];
        dp[0] = 0;
        dp[1] = abs(a[1]-a[0]);
        for(ll i=2; i<n; i++)
        {
            dp[i] = min(abs(a[i-1]-a[i])+dp[i-1],abs(a[i-2]-a[i])+dp[i-2]);
        }
        //showarr(dp,n);
        cout<<dp[n-1];
    }
    return 0;
}



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

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

	bool flag = false;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == N) flag = true;
		}
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
#define PI acos(-1)
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n,ans;
bool P(ll n){
	if(n<=1)return false;
	for(int i=2;i<=sqrt(n);i++)if(n%i==0)return false;
	return true;
}
void solve(){
	ll a,b;
	cin>>a>>b;
	ll gcd=__gcd(a,b);
	vector<ll> s;
	for(int i=1;i<=sqrt(gcd);i++){
		if(gcd%i==0){
			s.pb(i);
			if(i*i!=gcd){
				s.pb(gcd/i);
			}
		}
	}
	int size = sz(s);
	rep(i,0,size){
		if(P(s[i]))ans++;
	}	
	cout<<ans+1;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 384
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <set>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;
	set<int> start, end;

	rep(i, M)
	{
		int a, b;
		cin >> a >> b;

		if (a == 1)
		{
			start.insert(b);
		}
		else if (b == 1) 
		{
			start.insert(a);
		}

		if (a == N)
		{
			end.insert(b);
		}
		else if (b == N)
		{
			end.insert(a);
		}
	}

	set<int>::iterator it=start.begin();
	bool find_ = false;
	/*
	for(; it!=start.end(); it++)
	{
		cout<<*it<<endl;

	}
	cout << "sdf" <<endl;
	set<int>::iterator ite=end.begin();
	for(; ite!=end.end(); ite++)
	{
		cout << *ite << endl;
	}

	cout <<"sfag" <<(end.find(2) != end.end()) << endl;
	*/
	for(; it!=start.end(); it++)
	{
		//cout << *it << endl;
		if (end.find(*it) != end.end())
		{
			find_ = true;
			break;
		}

	}

	if (find_)
	{
		cout << "POSSIBLE" << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

	
	return 0;
}


Measured memory_bytes: 9600
h, w = map(int,input().split())
a = [list(input()) for _ in range(h)]
b = [[0 for _ in range(w)]for _ in range(h)]
H = [-1,-1,-1, 0, 0, 1, 1, 1]
W = [-1, 0, 1,-1, 1,-1, 0, 1]
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            b[i][j] = "#"
            for k in range(len(H)):
                if i+H[k] < 0 or i+H[k] >= h:continue
                elif j+W[k] < 0 or j+W[k] >= w:continue
                elif a[i+H[k]][j+W[k]] == "#":continue
                b[i+H[k]][j+W[k]] += 1
for i in range(h):
    print(*b[i],sep="")

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;

struct UnionFind {
    vector<int> par; 
    vector<int> sizes;
    UnionFind(int N) : par(N),sizes(N,1) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        if (sizes[rx]<sizes[ry])swap(rx,ry);
        // xがyの親になるように連結する
        par[ry] = rx; 
        sizes[rx]+=sizes[ry];
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        return sizes[root(x)];
    }

};

int ans[111111],ans2;
int n,m;
int a[111111],b[111111];


signed main(){

	cin>>n>>m;
	UnionFind UF(n);

	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
	}
	ans[m-1]=n*(n-1)/2;
	repb(i,m){
		if(i==0)continue;
		if(UF.same(a[i],b[i])){
			ans[i-1]=ans[i];
		}
		else{
			ans[i-1]=ans[i]-UF.size(a[i])*UF.size(b[i]);
		}
		UF.unite(a[i],b[i]);
	}
	rep(i,m)cout<<ans[i]<<endl;
}


Measured memory_bytes: 5248
def factorize(n):
  factors=[1]
  i=2
  while n>1:
    if n%i==0:
      factors.append(i)
    if i==n:
      break
    else:
      i+=1
  return factors
      
n=int(input())
nums=[]
for i in range(1,n+1):
  if i%2==1:
    if len(factorize(i))==8:
      nums.append(i)
print(len(nums))

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#define ESP 0.000000001
typedef struct O{int x,y,z,r;long long l;}O;
typedef struct P{int x,y,z;}P;
typedef struct V{double x,y,z;}V;

O obj[51];
P s,t,v;
int N,Q,i,j;
long long res;

int main()
{
	scanf("%d%d",&N,&Q);
	for(i=0;i<N;i++)
		scanf("%d%d%d%d%lld",&obj[i].x,&obj[i].y,&obj[i].z,&obj[i].r,&obj[i].l);
	for(i=0;i<Q;i++)
	{
		res=0;
		scanf("%d%d%d%d%d%d",&s.x,&s.y,&s.z,&t.x,&t.y,&t.z);
		for(j=0;j<N;j++)
		{
			P v={t.x-s.x,t.y-s.y,t.z-s.z};
			double a=v.x*(obj[j].x-s.x)+v.y*(obj[j].y-s.y)+v.z*(obj[j].z-s.z);
			double b=v.x*v.x+v.y*v.y+v.z*v.z;
			double c=a/b;
			V l={s.x+v.x*c,s.y+v.y*c,s.z+v.z*c};
			if(c<ESP)
			{
				l.x=s.x;l.y=s.y;l.z=s.z;
			}
			else if(c-1>ESP)
			{
				l.x=t.x;l.y=t.y;l.z=t.z;
			}
			double len=sqrt(pow(l.x-obj[j].x,2)+pow(l.y-obj[j].y,2)+pow(l.z-obj[j].z,2));
			if(len-obj[j].r<=ESP)
				res+=obj[j].l;
		}
		printf("%lld\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main()
{
    int h,w,i,j,k,num=0;
	int a[501][501];
	static int ans[251000][4];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			scanf("%d",&(a[i][j]));
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(a[i][j]%2==1&&(i!=h-1||j!=w-1))
			{
				if(j!=(w-1))//右
				{
					a[i][j+1]++;
					ans[num][0]=i+1;
					ans[num][1]=j+1;
					ans[num][2]=i+1;
					ans[num][3]=j+2;
				}
				else//下
				{
					a[i+1][j]++;
					ans[num][0]=i+1;
					ans[num][1]=j+1;
					ans[num][2]=i+2;
					ans[num][3]=j+1;
				}
				num++;
			}
		}
	}
	printf("%d\n",num);
	for(k=0;k<num;k++)
	{
		printf("%d %d %d %d\n",ans[k][0],ans[k][1],ans[k][2],ans[k][3]);
	}
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n;
	cin>>n;
	vector<vector<ll>> arr(n,vector<ll>(n));
	fr(i,0,n)
	fr(j,0,n)
	cin>>arr[i][j];
	vector<ll> dp(1<<n,0);
	vector<vector<ll>> len(1<<n);
	for(int mask=1;mask<(1<<n);mask++){
		vector<int> cur;
		len[__builtin_popcount(mask)].pb(mask);
		fr(i,0,n)
			if(mask&(1<<i))
				cur.pb(i);	
		fr(i,0,cur.size())
			fr(j,i,cur.size())
				dp[mask]+=arr[cur[i]][cur[j]];
	}
	fr(l,1,n+1)
		for(auto x: len[l])
			for(int s=x;s;s=(s-1)&x)
				dp[x]=max(dp[x],dp[s]+dp[s^x]);
	cout<<dp[(1<<n)-1]<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 6152
#include <cstdio>
int main(){
 int top3[3];
 int i,tmp,data;
 for(i=0;i<3;i++) top3[i]=0;
 for(i=0;i<10;i++){
  scanf("%d",&data);
  if (top3[2]>data) {} 
  else {
   top3[2]=data;
   if (top3[1]>data) {} 
   else {
    top3[2]=top3[1];
    if (top3[0]>data) top3[1]=data;
    else {
     top3[1]=top3[0];
     top3[0]=data;
    };
   };
  };
 };
 for(i=0;i<3;i++)
    printf("%d\n",top3[i]);
 return 0;
};
 

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


string x,y;
int    lcs[3500][3500];
char   path[3500][3500];

void LCS()
{
    int m=x.length(),i,j;
    int n=y.length();

    for(i=0; i<=m; i++)
    {
        for(j=0; j<=n; j++)
        {
            if(i==0|| j==0)
                lcs[i][j]=0;
            else if(x[i-1]==y[j-1])
            {
                lcs[i][j]=lcs[i-1][j-1]+1;
                path[i][j]='k';
            }
            else if(lcs[i-1][j]>=lcs[i][j-1])
            {
                lcs[i][j]=lcs[i-1][j];
                path[i][j]='o';
            }
            else
            {
                lcs[i][j]=lcs[i][j-1];
                path[i][j]='p';
            }
        }
    }
    //cout<<lcs[m][n]<<endl;


}


void print_path(int i,int j)
{
    if(i==0 || j==0)return;
    else if(path[i][j]=='k')
    {
        print_path(i-1,j-1);
        cout<<x[i-1];
    }
    else if(path[i][j]=='o')print_path(i-1,j);
    else if(path[i][j]=='p')print_path(i,j-1);
}

int main()
{
    cin>>x>>y;

    for(int i=0;i<3500;i++)
    {
        for(int j=0;j<3500;j++)
        {
            path[i][j]='*';
        }
    }

    LCS();
    int m=x.length();
    int n=y.length();

    print_path(m,n);

    return 0;
}


Measured memory_bytes: 53632
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> list = nextIntArray();
      int output = 0;
      Collections.sort(list);
      output += Math.abs(list.get(0) - list.get(1)) + Math.abs(list.get(1) - list.get(2));
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33060
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
int a[55], b[55], c[55], d[55];
int A[15];
int ans = 0;
void rec(int id){
    if (id == n+1){
        int sum = 0;
        for (int i = 0; i < q; i++){
            if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans,sum);
        return;
    }
    for (int j = A[id-1]; j <= m; j++){
        A[id] = j;
        rec(id+1);
    }
}
int main(){
    scanf("%d%d%d",&n,&m,&q);
    for (int i = 0; i < q; i++){
        scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
    }
    A[0] = 1;
    rec(1);
    printf("%d",ans);
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int n;
    cin >> n;

    int aux = 1;
    fo(i, n) {
        int a;
        cin >> a;
        if ( a & 1 ) continue;
        aux *= 2;
    }

    int ans = pow(3, n);

    cout << ans - aux << endl;

    return 0;
}

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

int main(){
    int num;
    int i,j,k;
    scanf("%d",&num);
    int time[num];
    for(i=0;i<num;i++){
        scanf("%d",&time[i]);
    }
    
    int memo;
    scanf("%d",&memo);
    int p[memo],x[memo];
    for(j=0;j<memo;j++){
        scanf("%d%d",&p[j],&x[j]);
    }

    int sum;
    for(i=0;i<num;i++){
        sum += time[i];
    }

    for(k=0;k<memo;k++){
        printf("%d\n", sum + x[k] - time[p[k]-1]);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const ll MOD = pow(10,9)+7;
const ll H_MAX = pow(10,5);

// factorial(階乗)の計算

ll fac[H_MAX*2+10] ={};

ll c_fac(int n) {
  if (fac[n]!=0) return fac[n];
  if (n==0) return fac[n] =1;
  return fac[n] = (c_fac(n-1)*n)%MOD;
}

// inverse(逆元)の計算

ll inv(ll a,ll m) {
  ll b = m, x = 1, y = 0;
  while (b!=0) {
    ll d = a/b;
    a -= b*d; swap(a, b);
    x -= y*d; swap(x, y);
  }
  return x>=0 ? x : x+m;
}

// combinataionの計算

ll nck(ll n, ll k) { 
  if (n<k) return 0;
  ll nume = fac[n];
  ll deno = ( inv(fac[n-k],MOD) * inv(fac[k],MOD) ) % MOD;
  return ( nume * deno ) % MOD;
}

int main() {
  int H, W, A, B; cin >> H >> W >> A >> B;

  ll result = 0;
  c_fac(H+W);
  rep(i, H-A) {
    ll tmp = nck(B+(i-1), B-1) * nck(W-(B+1)+H-(i+1), W-(B+1));
    tmp %= MOD;
    if (tmp<=0) { cout<<i<<endl; break; }
    result += tmp;
    result %= MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep_1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define rep_2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {
  ll n;
  cin >> n;
  vector<int> f(n);
  ll lim = 10000;
  for (int x = 1; x <= lim; x++) {
    for (int y = 1; y <= lim; y++) {
      for (int z = 1; x <= lim; z++) {
        ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp > n) {
          break;
        }
        tmp--;
        f[tmp]++;
      }
    }
  }
  for (ll x : f) {
    cout << x << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n,k;
  cin >> n >> k;
  ll res = 0;
  res += 1LL*(n/k)*(n/k)*(n/k);
  if(!(k & 1))res += 1LL*((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
  cout << res << endl;





  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main(void){
    // Your code here!
    int num[3], K, total = 0, maxnum = 0, ans;
    scanf("%d%d%d%d", &num[0], &num[1], &num[2], &K);
    
    for(int i = 0; i < 3; i++){
        if(num[i] > maxnum) maxnum = num[i];
        total += num[i];
    }
    ans = maxnum;
    total -= maxnum;
    for(int i = 0; i < K; i++){
        ans = ans * 2;
    }
    printf("%d", ans + total);
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
cnt = 0

for i in range(1,n-1):
  if (p[i] > p[i-1] and p[i] < p[i+1]) or (p[i] > p[i+1] and p[i] < p[i-1]):
    cnt += 1

print(cnt)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

int n;
int x[55],y[55],xx[55],yy[55];

ll mask[102][102];
int col[102][102];
typedef pair<int,int> P;

inline bool valid(int x, int y){
    return 0 <= x && x < 102 && 0 <= y && y < 102;
}

int xs[102], ys[102];

int solve(){
    int cx=0, cy=0;
    rep(i,n){
        xs[cx++]=x[i];
        xs[cx++]=xx[i];
        ys[cy++]=y[i];
        ys[cy++]=yy[i];
    }
    xs[cx++]=-1;
    ys[cy++]=-1;
    sort(xs,xs+cx);
    sort(ys,ys+cy);
    cx = unique(xs,xs+cx)-xs, cy = unique(ys,ys+cy)-ys;

    memset(mask,0,sizeof(mask));
    rep(i,n){
        int x1=lower_bound(xs,xs+cx,x[i])-xs;
        int x2=lower_bound(xs,xs+cx,xx[i])-xs;
        int y1=lower_bound(ys,ys+cy,y[i])-ys;
        int y2=lower_bound(ys,ys+cy,yy[i])-ys;
        loop(x,x1,x2){
            loop(y,y2,y1){
                mask[y][x]|=1LL<<i;
            }
        }
    }

    int cnt = 0;
    memset(col,0,sizeof(col));
    int dx[]={0,0,1,-1};
    int dy[]={1,-1,0,0};
    rep(i,102)rep(j,102)if(col[i][j]==0){
        cnt++;
        stack<P> s; s.push(P(j,i));
        while(s.size()){
            int x,y;
            tie(x,y) = s.top(); s.pop();
            if(col[y][x]) continue;
            col[y][x] = cnt;
            rep(d,4){
                int nx,ny;
                tie(nx,ny) = P(x+dx[d], y+dy[d]);
                if(!valid(nx,ny)) continue;
                if(mask[y][x]!=mask[ny][nx]) continue;
                if(col[ny][nx]) continue;
                s.push(P(nx,ny));
            }
        }
    }
    return cnt;
}

int main(){
    while(~scanf("%d",&n) && n){
        rep(i,n)scanf("%d%d%d%d",&x[i],&y[i],&xx[i],&yy[i]);
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3540
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))

int main(void){
    unsigned long long x,k;
    scanf("%llu %llu",&x,&k);
    if(x < k){
        printf("%llu",min(k-x,x));
        return 0;
    }if(x == k){
        puts("0");
        return 0;
    }
    printf("%llu",min(x % k,k - (x % k)));
    return 0;
}


Measured memory_bytes: 128
# A,B = map(int, input().split())
# C,D = map(int, input().split())
N = int(input())

tmp = int(N/1.08)

ans = ":("
for i in range(5):
    if int((tmp-2+i)*1.08)==N:
        ans = tmp-2+i
        break
    
print(ans)
#print(tmp, N)


Measured memory_bytes: 2940
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int[] count = new int[4];
		while(stdIn.hasNext())
		{
			String[] str = stdIn.next().split(",");
			String blood = str[1];
			if(blood.equals("A"))
			{
				++count[0];
			}
			else if(blood.equals("B"))
			{
				++count[1];
			}
			else if(blood.equals("AB"))
			{
				++count[2];
			}
			else
			{
				++count[3];
			}
		}
		for(int i = 0; i < 4; ++i)
		{
			System.out.println(count[i]);
		}
	}
}

Measured memory_bytes: 12000
import java.io.*;
 
class Main {
    public static void main(String[] args) {
        // BufferedReader br = new BufferedReader(new
        // InputStreamReader(System.in));
        try {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = br.readLine();
            // n:????????????°???k:??????????????????°
            int n = Integer.parseInt(str.split(" ")[0]);
            int k = Integer.parseInt(str.split(" ")[1]);
            // ??????????????´?????????????
            int[] nimotu = new int[n];
            // ???¨?????????????????????????????¨?????????????
            int totalWeight = 0;
            // ???????????????????????´?????????????????????±???????
            for (int i = 0; i < n; i++) {
                nimotu[i] = Integer.parseInt(br.readLine());
                totalWeight += nimotu[i];
            }
            // ????????????????????±???????
            int aver = totalWeight / k;
            int maxweight = aver;
            int tracknum;
            while(maxweight <= totalWeight){
                //if(limit == 1)break;
                int weight = 0;
                tracknum = 1;
                boolean flg = true;
                // ????????????????????¶???????????????????????????????????????????
                for(int i = 0;i < n && tracknum <= k;) {
                    // ?????????????????????????????????°?????????
                    if(weight + nimotu[i] <= maxweight){
                        weight += nimotu[i];
                        i++;
                    //???????????????????????????????????????????????????£??????????????????°??¬????
                    } else if(weight > 0){
                        if(maxweight < weight){
                            maxweight = weight;
                        }
                        weight = 0;
                        tracknum++;
                    //???????????????¨?????¨???????§???????????????????????????????????????°??¬????
                    } else {
                        flg = false;
                        break;
                    }
                }
                /* ????????????¶
                 * 1.tracknum = k??????¨???????????????????????????¨??????????????????¨
                 * 2.flg = true?????????¨??????????????????????????????????????????¨
                */
                if(tracknum <= k && flg){
                    System.out.println(maxweight);
                    break;
                }
                // ??????????????????´??????????????????????????¬????
                maxweight++;
            }
        } catch (IOException e) {
            System.out.println("error");
        }
    }
}

Measured memory_bytes: 29380
//A問題//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
 
 
int main(){
    string S;
    cin >> S;

    if(S=="ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main()
{
    ll s;
    cin>>s;
    ll cnt=1;
    map<ll,ll> mp;
    mp[s]++;

    while(true){
        cnt++;
        if(s%2==0)s/=2;
        else s=3*s+1;
        
        if(mp[s])break;
        else mp[s]++;       
    }
    
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	bool dp[20+4][2000+100] = {};
	int n;
	cin >> n;
	int a;
	rep2(i,1,n+1) {
		cin >> a;
		dp[i][a] = 1;
		rep(j,2000) {
			if(a+j>2000) break;
			if(dp[i-1][j]) {
				dp[i][j] = 1;
				dp[i][a+j] = 1;
			}
		}
	}
	int q; 
	cin >> q;
	int m;
	rep(i,q) {
		cin >> m;
		if(dp[n][m]) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    ll n, a[200000], r[200000][2];
    cin >> n;
    priority_queue<pair<ll, ll>> q;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++) {
        q.push(make_pair(a[i], i));
        while (q.top().first > a[i]) {
            r[q.top().second][0] = i;
            q.pop();
        }
    }
    while (!q.empty()) {
        r[q.top().second][0] = n;
        q.pop();
    }
    for (ll i = n - 1; i >= 0; i--) {
        q.push(make_pair(a[i], i));
        while (q.top().first > a[i]) {
            r[q.top().second][1] = i;
            q.pop();
        }
    }
    while (!q.empty()) {
        r[q.top().second][1] = -1;
        q.pop();
    }
    ll c = 0;
    for (ll i = 0; i < n; i++) {
        ll l2 = i - r[i][1];
        ll r2 = r[i][0] - i;
        c += l2 * r2 * a[i];
    }
    cout << c << endl;
}

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

const int N = 100010;

int n, a[N];
int ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] = (a[i] == i);
	}

	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] == 1) {
			++cnt;
		} else {
			ans += (cnt + 1) / 2;
			cnt = 0;
		}
	}
	ans += (cnt + 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll mod = 998244353;

struct point{
    ll x,y;
};

ll fpow(ll x, ll p){
    ll r=1;
    for (; p; p>>=1){
        if (p&1) r=(r*x)%mod;
        x=(x*x)%mod;
    }
    return r;
}

ll ccw(point A, point B, point C){
    return (A.x*B.y+B.x*C.y+C.x*A.y-B.y*C.x-C.y*A.x-A.y*B.x);
}

ll N; point a[210];
bool v[210][210];

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

    int i,j,k;
    for (i=1; i<=N; i++) cin >> a[i].x >> a[i].y;

    ll res=fpow(2,N)-1-N-N*(N-1)/2;

    for (i=1; i<=N; i++)
        for (j=i+1; j<=N; j++){
            if (v[i][j]) continue;

            int cnt=0;
            vi ind;
            for (k=1; k<=N; k++)
                if (ccw(a[i],a[j],a[k])==0) cnt++,ind.pb(k);


            for (int x=0; x<(int)ind.size(); x++)
                for (int y=x+1; y<(int)ind.size(); y++)
                    v[ind[x]][ind[y]]=v[ind[y]][ind[x]]=1;
            res=(res-(fpow(2,cnt)-1-cnt-cnt*(cnt-1)/2))%mod;
        }

    res=(res+mod)%mod;
    cout << res << "\n";

    return 0;
}


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

#define mp make_pair
#define ll long long
#define pb push_back
int min(int a,int b)
{
	if(a<b)
	return a;
	return b;
}
int main() 
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
 int a[n];
 for(int i=0;i<n;i++)cin>>a[i];
 int Xor = 0;
for (int i = 0; i < n; i++)
    Xor ^= a[i];
    
 for (int i = 0; i < n; i++) 
 a[i] = Xor^a[i];
  for(int i=0;i<n;i++)
  cout<<a[i]<<" ";
         
    
    
    
}
	

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	int n; cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];

	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);
	}
	cout << g << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int ntr[55];
	int dtr[55];
	for(int i=0;i<n;i++){
		scanf("%d",&ntr[i]);
	}
	for(int i=0;i<n;i++) dtr[i]=i+1;
	int j=0;
	for(int i=0;i<n;i++){
		if(ntr[i]!=dtr[i]) j++;
	}
	if(j==0||j==2) printf("YES\n");
	else printf("NO\n");
}


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

vector<long long int> combination_list(int n){
  vector<long long int> ret(n+1,1);
  long long int t = 1LL;
  for(int i = 0; i < n; ++i){
    for(int j = 1; j <= i; ++j){
      long long int t_ = ret[j];
      ret[j] += t;
      t = t_;
    }
  }
  return ret;
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<long long int> V(N);
  for(int i = 0; i < N; ++i) cin >> V[i];
  sort(V.begin(),V.end());
  double mean = 0;
  for(int i = 0; i < A; ++i){
    mean += (double)V[N-1-i]/A;
  }
  printf("%.12f\n",mean);
  int n = upper_bound(V.begin(),V.end(),V[N-A]) - lower_bound(V.begin(),V.end(),V[N-A]), k = upper_bound(V.begin(),V.end(),V[N-A]) - V.begin() - N + A;
  vector<long long int> nC = combination_list(n);

  long long int ans = nC[k];
  if(V[N-A] == V[N-1]){
    for(int i = k+1; i <= min(n,B); ++i){
      ans += nC[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
long bigp = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll min_abs = abs(a[0]);
    int num_minus = 0;
    ll abs_sum = 0;
    rep(i,n){
        if(abs(a[i]) < min_abs){
            min_abs = abs(a[i]);
        }
        if(a[i] < 0){
            num_minus += 1;
        }
        abs_sum += abs(a[i]);
    }
    if(num_minus % 2==0){
        cout << abs_sum;
    }
    else{
        cout << abs_sum - 2*min_abs;
    }

}

Measured memory_bytes: 1024