akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}



int32_t main() {

    zeus();
    int n; cin >> n;

    cout << ceil(n / 1000.0) * 1000 - n << endl;



}

Measured memory_bytes: 3800
awk 'NR==1{n=$1}
NR==2{
    for (i = 65; i < 65 + 26; ++i) {
        c = sprintf("%c", i)
        a[c] = i
    }
    t = ""
    for (i = 1; i <= length($1); ++i) {
        c = substr($1, i, 1)
        m = a[c] + n
        if (m >= 65 + 26) m -= 26
        t = t sprintf("%c", m)
    }
    print t
}'


Measured memory_bytes: 680
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enque(P x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P deque(){
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a, int b){return a<b?a:b;}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i=1;i<=n;i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;tail = n+1;

    while(head != tail){
        u = deque();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t>0)enque(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}

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

vector<int> bfs(int s) {
  vector<int> dist(sz(G),0);
  queue<int> que;

  que.push(s);
  dist[s] = 0;
  while(!que.empty()) {
    int u = que.front();
    que.pop();

    for (auto v : G[u]) {
      if (dist[v.first] != 0) continue;
      dist[v.first] = dist[u] + v.second;
      que.push(v.first);
    }
  }
  return dist;
}

int main(){
  int n, m;
  cin >> n >> m;
  G.resize(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back({b,1});
    G[b].push_back({a,1});
  }
  auto res = bfs(0);
  cout << (res[n-1] == 2 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using std::cin;
using std::ifstream;
using std::cout;
using std::vector;
using std::min;
using std::max;
using std::string;
using std::map;
using std::cerr;
using std::endl;
using std::sort;
using std::__gcd;
using std::ios_base;

#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
unsigned lcm(int a, int b) { return (a / __gcd(a, b) * b); }
#define fri(i,n) 			for(int i = 0 ; i < n;++i) 
#define jri(j,k,n) 		for(int j = k ; j >= n;j--) 
#define swapnumsxor 	a ^= b; b ^= a; a ^= b
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define inp(i) 				cin >> i 
#define inp2(i,j) 		cin >> i >> j  
#define inp3(i,j,k) 	cin >> i >> j >> k
#define oup(i) 				cout << i << "\n"
#define oup2(i,j) 		cout << i << " "<<j<< "\n"
#define oup3(i,j,k) 	cout << i << " "<< j << " "<<k<< "\n"
#define MOD 1000000007
#define rmdup 				std::sort(str.begin(), str.end());str.erase(std::unique(str.begin(), str.end()), str.end());

typedef long long int lli;
typedef unsigned long long int ulli;
#define pb 		emplace_back
#define mp 		make_pair
#define MAXN 	1000000
#define vi vector<int>
#define vlli vector<lli>
#define vulli vector<ulli>
const int INF = 0x3f3f3f3f;

int main()
{ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
		// ifstream in("input.txt");
		int n;
    inp(n);
    vi dp(3);
    fri(i , n){
      vi ndp(3 , 0);
      vi c(3);
      for( int &e : c ) inp(e);
      fri(i,3){
        fri(j,3){
          if(i!= j) {
            ndp[j] = max( ndp[j] , dp[i] + c[j] );
          }   
        }
      }
      dp = ndp;
    }
    cout << max({dp[0] , dp[1] , dp[2]});

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> A = new ArrayList<Integer>();
		for(int i =0; i<N; i++) {
			A.add(scanner.nextInt());
		}
		Collections.sort(A);
		List<Integer> B = new ArrayList<Integer>();
			for(int i=0; i<N;i++) {
				if(i+1 < N) {
					B.add(Math.abs(A.get(i)-A.get(i+1)));
				}else {
					B.add(K-Math.abs(A.get(i)-A.get(0)));
				}
			}
			int Max = B.get(0);
			for(int i = 1 ; i < B.size(); i++){
		        if(Max < B.get(i)){
		            Max = B.get(i);
		            }
		        }
		System.out.println(K-Max);
		
		
	}
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vll cntr(n, 0), cntw(n, 0);
    for(ll i=0;i<n;i++) {
    	if(s[i] == 'R') {
    		cntr[i]++;
    	} else {
    		cntw[i]++;
    	}
    	if(i > 0) {
    		cntr[i] += cntr[i-1];
    		cntw[i] += cntw[i-1];
    	}
    }
    ll ans = n + 1;
    for(ll i = 0; i <= n; i++) {
    	ll tmp = 0;
    	if(i == 0) {
    		tmp = cntr[n-1];
    		ans = min(tmp, ans);
    		continue;
    	}
    	ll lftr = cntr[i-1];
    	ll lftw = cntw[i-1];
    	ll rtr = cntr[n-1] - lftr;
    	ll rtw = cntw[n-1] - lftw;
    	tmp = max(lftw, rtr);
    	ans = min(tmp, ans);
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

Measured memory_bytes: 6768
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N, K; std::cin >> N >> K;
  std::vector<int> h(N); for(int i=0; i<N; i++) std::cin >> h[i];

  std::sort(h.begin(), h.end());

  int ans = std::numeric_limits<int>::max();
  for(int i=0; i<N; i++) {
    if ( i+K > N ) break;
    ans = std::min(ans, h[K+i-1]-h[i]);
  }

  std::cout << ans << std::endl;

  return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

 
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
}
 
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,k;
  cin>>n>>k;
  COMinit();
  
  ll ans=0;
  REP(i,min(k,n)+1)
    ans = (ans+COM(n,i)*COM(n-1,n-i-1))%MOD;

  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, Q;
    cin >> N >> Q;
    mat G(N);
    REP(i,0,N-1) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }
    vec X(N, 0);
    REP(i,0,Q) {
        ll p, x;
        cin >> p >> x;
        X[p-1] += x;
    }

    queue<ll> R;
    vec A(N, 0);
    vector<bool> F(N, false);
    R.push(0);
    A[0] += X[0];
    F[0] = true;
    while(!R.empty()) {
        ll v = R.front(); R.pop();
        FORR(nv,G[v]) {
            if(!F[nv]) {
                A[nv] += A[v] + X[nv];
                R.push(nv);
                F[nv] = true;
            }
        }
    }

    REP(i,0,N) PS(A[i]);
    PR("");

    return 0;
}

/*



*/

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

int main() {
  int N = 0, l = 0, r = 0, sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i=1;
  int ans[55]={};

  cin>>n;
  ans[0]=1;

  while(1){
    ans[i]=ans[i-1]*2;
    if(ans[i]>n) break;
    i++;
  }
  
  cout<<ans[i-1]<<endl;
  return 0;
}



Measured memory_bytes: 3116
s = input()
n = len(s)
cen1 = int((n-1)/2)
cen2 = int((n+3)/2)
if s == s[::-1] and s[:cen1] == s[cen1-1::-1] and s[cen2-1:n] == s[n:cen2-2:-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8976
<?php

fscanf(STDIN, "%d %d %d", $a, $b, $c);

$abs_a = abs($a - $b);
$abs_b = abs($a - $c);
$abs_c = abs($b - $c);

$arr=[
  $abs_a,
  $abs_b,
  $abs_c,
];

sort($arr);

$answer = $arr[0] + $arr[1];

echo $answer;
?>


Measured memory_bytes: 16108
import java.util.*;

public class Main {

  public static class Pair {
    int y;
    int x;
    int a;

    public Pair(int y, int x, int a) {
      this.y = y;
      this.x = x;
      this.a = a;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] a = new int[H][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    Pair[] root = new Pair[H * W];
    int count = 0;
    int sy = 0;
    int sx = 0;
    boolean right = true;
    while (count < H * W) {
      if (W <= sx) {
        sx--;
        sy++;
        right = false;
      } else if (sx < 0) {
        sx++;
        sy++;
        right = true;
      }
      root[count] = new Pair(sy, sx, a[sy][sx]);
      if (right) {
        sx++;
      } else {
        sx--;
      }
      count++;
    }
    boolean[] ans = new boolean[H * W];
    int anscount = 0;
    Arrays.fill(ans, false);
    for (int i = 0; i < H * W - 1; i++) {
      if (root[i].a % 2 == 1) {
        root[i + 1].a++;
        ans[i] = true;
        anscount++;
      }
    }
    System.out.println(anscount);
    for (int i = 0; i < H * W - 1; i++) {
      if (ans[i]) {
        System.out
            .println((root[i].y + 1) + " " + (root[i].x + 1) + " " + (root[i + 1].y + 1) + " " + (root[i + 1].x + 1));
      }
    }
  }
}

Measured memory_bytes: 106276
for i in range(10**5):
    n = int(input())
    if n == 0:
        break
    else:
        s = list(map(int,input().split()))
        k = sum(s)/n
        ans = 0
        for i in range(n):
            ans += ((s[i]-k)**2)/n
        print("{:.10}".format(ans**0.5))


Measured memory_bytes: 5672
import java.util.Scanner;

public class Main {

	static String s;
	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		n = s.length();
		long ans = dfs(0, "");
		System.out.println(ans);
	}

	public static long dfs(int i, String x) {
		if(i == n) {
			String[] split = x.split("\\+");
			long res = 0;
			for(int j = 0 ; j < split.length ; j++) {
				res += Long.valueOf(split[j]);
			}
			return res;
		}
		long ret = 0;
		ret += dfs(i + 1, x + s.charAt(i));
		if(i != 0) ret += dfs(i + 1, x + "+" + s.charAt(i));
		return ret;
	}

}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		int[][] mag = new int[2][n];
		for (int i = 0; i < n; i++) {
			mag[0][i] = Integer.parseInt(sc.next());
			mag[1][i] = Integer.parseInt(sc.next());
		}
		int[][] dp = new int[n][h];
		for (int i = 0; i < h; i++) {
			dp[0][i] = (i / mag[0][0] + 1) * mag[1][0];
		}
		int tmpd;
		int tmph;
		for (int i = 1; i < n; i++) {
			tmpd = mag[0][i];
			tmph = mag[1][i];
			for (int j = 0; j < h; j++) {
				if (j < tmpd) {
					dp[i][j] = Math.min(dp[i - 1][j], tmph);
				} else {
					dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - tmpd] + tmph);
				}
			}
		}
//		for (int i = 0; i < n; i++) {
//			for (int j = 0; j < h; j++) {
//				System.out.println(i + "," + j + " " + dp[i][j]);
//			}
//		}
		System.out.println(dp[n - 1][h - 1]);
	}
}


Measured memory_bytes: 83184
#include<bits/stdc++.h>
using namespace std;int N,M,L,R,C,A,i,j;string S;char Q[4];main(){scanf("%d",&N);scanf("%d",&M);cin>>S;vector<vector<int> >F(N+1,vector<int>()),D(N+1,vector<int>());for(i=0;i<M;i++){scanf("%s",Q);if(Q[0]=='L'&&Q[1]=='+'){L++;}if(Q[0]=='L'&&Q[1]=='-'){L--;}if(Q[0]=='R'&&Q[1]=='+'){R++;}if(Q[0]=='R'&&Q[1]=='-'){R--;}F[R-L+1].push_back(L);C=max(C,R-L+1);}for(i=1;i<=N;i++){sort(F[i].begin(),F[i].end());if(F[i].size()){D[i].push_back(F[i][0]);}for(j=1;j<F[i].size();j++){if(F[i][j-1]!=F[i][j]){D[i].push_back(F[i][j]);}}}for(i=1;i<=C;i++){set<string> s;for(j=0;j<D[i].size();j++){s.insert(S.substr(D[i][j], i));}A+=s.size();}printf("%d\n",A);}

Measured memory_bytes: 34760
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N; 
	long long int C; 
	cin >> N >> C; 
	long long int X[100010] = {}; 
	long long int V[100010] = {};
	long long int W[100010] = {}; //カロリーの累積和 
	long long int R[100010] = {}; //時計回りにi番まで進んだときの得の最大値
	long long int L[100010] = {}; //反時計回りにi番まで進んだときの得の最大値
	for(int i = 1; i <= N; i++){
		cin >> X[i] >> V[i]; 
		W[i] = W[i-1] + V[i]; 
	}
	X[N+1] = C; //便宜上そうしておく．
	for(int i = 1; i <= N; i++){
		R[i] = max(R[i-1], W[i] - X[i]); 
	}
	for(int i = N; i >= 1; i--){
		L[i] = max(L[i+1], (W[N] - W[i-1]) - (C - X[i])); 
	}
	long long int ans = 0; 
	for(int i = 0; i <= N; i++){//まず時計回りにi番まで行って反時計回りに最適化
		long long int sesshu = W[i] - X[i] * 2 + L[i+1]; 
		ans = max(ans, sesshu); 
	}
	for(int i = 1; i <= N+1; i++){//まず反時計回りにi番まで行って時計回りに最適化
		long long int sesshu = W[N] - W[i-1] - (C - X[i]) * 2 + R[i-1]; 
		ans = max(ans, sesshu); 
	}
	cout << ans << endl;
}

Measured memory_bytes: 4096
N,K=map(int,input().split())
S=input()
s=str()
for i in range(N):
	if not i==K-1:
		s+=S[i]
	else:
		if S[K-1]=='A': s+='a'
		if S[K-1]=='B': s+='b'
		if S[K-1]=='C': s+='c'
print(s)

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

void itov(int n, vector<int> &v){
	int digit = 4;
	for(int i=digit-1; i>=0; i--){
		v[i] = n%10;
		n /= 10;
	}
}

int gethash(string &s, int &p, vector<int> &v){
	if(s[p] != '['){
		return v[s[p++] -'a'];
	}
	p++;
	char op = s[p++];
	int a = gethash(s, p, v);
	int b = gethash(s, p, v);
	p++;
	if(op == '+') return a|b;
	if(op == '*') return a&b;
	return a^b;
}

int main(){
	while(1){
		string s;
		cin >> s;
		if(s == ".") break;
		int pass;
		cin >> pass;

		vector<int> hashv(10000);
		vector<int> v(4);
		for(int i=0; i<10000; i++){
			itov(i, v);
			int p = 0;
			hashv[i] = gethash(s, p, v);
		}

		int count = 0;
		for(int i=0; i<10000; i++){
			if(hashv[pass] == hashv[i]) count++;
		}
		cout << hashv[pass] << " " << count << endl;
	}
    return 0;
}


Measured memory_bytes: 3224
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
G = defaultdict(set)
for i in range(M):
    a,b = map(int,input().split())
    G[a-1].add(b-1)
    G[b-1].add(a-1)
color = [0 for i in range(len(G))]
color[0]=1
#二部グラフであるかの判定
def Isbipartite(G):
    """
    color = [[0] for i in range(len(G))]
    color[0]=1
    """
    que=deque([0])
    bipartite = True
    while que:
        p = que.popleft()
        for q in list(G[p]):
            if color[q]==0:
                color[q] = -color[p]
                que.append(q)
            elif color[q] == color[p]:
                bipartite = False
                break
    return bipartite


if Isbipartite(G):
    print(color.count(1)*color.count(-1)-M)
else:
    print(N*(N-1)//2-M)

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

using namespace std;

constexpr int MAX_N = 100000;
vector<int> pre_order(MAX_N, -1);//pre_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer
vector<int> post_order(MAX_N, -1);//post_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer
vector<int> parent(MAX_N, -1);//parent[i]:=??±???????????¢?´¢??§??¨????§????????????¨???????????????i??????

vector<vector<int>> G(MAX_N);

vector<int> ans;

void add_edge(int s, int t) {
	G[s].emplace_back(t);
	G[t].emplace_back(s);
}

void dfs(const vector<vector<int>>& G, int u = 0, int prev_u = -1, int timer = 1) {
	pre_order[u] = timer;
	post_order[u] = timer;
	++timer;
	for (auto&& v:G[u]) {
		if (pre_order[v] < 0) {
			parent[v] = u;
			dfs(G, v, u, timer);
			post_order[u] = min(post_order[u], post_order[v]);
		}
		else if (v != prev_u) {
			post_order[u] = min(post_order[u], pre_order[v]);
		}
	}
}

void articulation_points(const vector<vector<int>>& G, int G_sz, int root = 0) {
	dfs(G, root);
	vector<bool> used(G_sz, false);
	int root_child = 0;
	for (int j = 0; j < G_sz; ++j) {
		if (parent[j] == root)++root_child;
		if (root_child == 2) {
			ans.emplace_back(root);
			break;
		}
	}
	for (int i = 1; i < G_sz; ++i) {
		if (parent[i] != root
			&&pre_order[parent[i]] <= post_order[i]
			&& !used[parent[i]]) {

			ans.emplace_back(parent[i]);
			used[parent[i]] = true;
		}
	}
	sort(ans.begin(), ans.end());
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, E;cin >> N >> E;
	int s, t;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t;
		add_edge(s, t);
	}
	articulation_points(G, N);
	for (auto&& v : ans) {
		cout << v << endl;
	}
}

Measured memory_bytes: 6132
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        string s;
        cin >> s;
        ll r = 0;
        for(auto u : s){
            if(u == 'R'){
                r++;
            }
        }
        ll ans =0;
        for(i = 0; i < r; i++){
            if(s[i] == 'W'){
                ans++;
            }
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;
#define N 501

int main(){
    int n;
    double p[N],q[N];
    double pSum[N][N],qSum[N][N];
    double d[N][N];
    double t;
    
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> p[i];
    }
    
    for(int i = 0;i < n + 1;++i){
        cin >> q[i];
        d[i][i] = q[i];
    }
    
     // p
    for(int i = 0;i < n;++i){
        pSum[i][i] = p[i];
        for(int j = i + 1;j < n;++j){
            pSum[i][j] = pSum[i][j - 1] + p[j];
        }
    }
    
    // q
    for(int i = 0;i < n + 1;++i){
        qSum[i][i] = q[i];
        for(int j = i + 1;j < n + 1;++j){
            qSum[i][j] = qSum[i][j - 1] + q[j];
        }
    }
    
    for(int i = 1;i < n + 1;++i){
        for(int j = 0;j < (n + 1) - i;++j){
            d[j][j + i] = __DBL_MAX__;
            for(int k = 0;k < i;++k){
                t = d[j][j + k] + d[j + k + 1][j + i] + pSum[j][j + i - 1] + qSum[j][j + i];
                d[j][j + i] = min(d[j][j + i], t);
            }
        }
    }
    
    printf("%.8lf\n",d[0][n]);
    
    return 0;
}



Measured memory_bytes: 9088
#include<stdio.h>

int main(void){
	double a,b;
	scanf("%lf",&a);
	scanf("%lf",&b);
	
	if(a>b){
		printf("GREATER\n");
	}else if(a<b){
		printf("LESS\n");
	}else if(a=b){
		printf("EQUAL\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int MOD = 1e9 - 7;
const int INF = 1e9 + 7;

char a[101][101];

bool h[N], w[N];

int main () {
    to_pray();
    
    int n, m;
    cin >> n >> m;
    
    for (int i = 1; i <= n; ++ i) {
    	for (int j = 1; j <= m; ++ j) {
    		cin >> a[i][j];
    		if (a[i][j] == '#') {
    			h[i] = true;
    			w[j] = true;
    		}	
    	}
    }
    
    for (int i = 1; i <= n; ++ i) {
   		if (!h[i])
   			continue;
   		for (int j = 1; j <= m; ++ j) {
   			if (!w[j])
   				continue;
   			cout << a[i][j];
   		}
   		cout << '\n';
    }
    
    cerr << '\n';
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,s;
map<ll,ll> m;
ll R(ll r=0){return scanf("%lld",&r),r;}
int main()
{
	for (n=R(),m[0]=1;n--;a+=m[s+=R()]++);
	return printf("%lld\n",a),0;
}


Measured memory_bytes: 12800
#include<stdio.h>

int main(){
  int n,number,max = -1000000,min = 1000000;
  long int sum = 0;
  scanf("%d",&n);
  
    for(int i=1;i<=n;i++){
      scanf("%d",&number); 
      sum += number;
      if(max <= number){
        max = number;
      }
      if(min >= number){
        min = number;
      }
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}

Measured memory_bytes: 1852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int a;
	cin>>a;
	cout<<a/3<<endl;
	return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n, m;
	cin >> n >> m;
	int h[n], ma[n];
	rep(i,n){
		cin >> h[i];
		ma[i] = 0;
	}
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--,b--;
		ma[a] = max(ma[a],h[b]);
		ma[b] = max(ma[b],h[a]);
	}
	int ans = 0;
	rep(i,n){
		if(h[i] > ma[i]){
			ans ++ ;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4396
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<pair<ll ,ll> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const ll N=1e7 ,OO=1e9+5;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
ll TC,n,ans,sum,l,r,a,arr[N];
bool f,vis[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
        cin>>n;
        REP(i,n&&cin>>a)
         {
             if(a&1 && i&1 )ans++;
         }
         cout<<ans;
go;
}


Measured memory_bytes: 3520
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

int N;
int[][] adj;
int[] parent;
real[] ex, ans;

real dfs(int n, int prev) {
    parent[n] = prev;
    if (adj[n].length == 1 && prev != -1) return ex[n] = 0;
    real ret = 0;
    real num = adj[n].length.to!real;
    if (prev != -1) num -= 1;

    foreach (m; adj[n]) {
        if (m == prev) continue;
        ret += dfs(m, n) + 1;
    }

    return ex[n] = ret / num;
}

void dfs2(int n, int prev) {
    if (prev == -1) {
        ans[n] = ex[n];
    }
    else if (adj[n].length > 1 && adj[prev].length > 1) {
        ans[n] = ex[n] * (adj[n].length.to!real - 1) / (adj[n].length.to!real);
        ans[n] += ((ans[prev] - (ex[n]+1) / adj[prev].length) * adj[prev].length / (adj[prev].length - 1) + 1) / adj[n].length;
    }
    else if (adj[n].length > 1) {
        ans[n] = ex[n] * (adj[n].length.to!real - 1) / (adj[n].length.to!real);
        ans[n] += 1.0L / adj[n].length;
    }
    else {
        ans[n] += ((ans[prev] - (ex[n]+1) / adj[prev].length) * adj[prev].length / (adj[prev].length - 1) + 1) / adj[n].length;
        //ans[n] += (ans[prev] - (ex[n]) / (adj[prev].length.to!real) + 1) / adj[n].length;
    }

    foreach (m; adj[n]) {
        if (m != prev) dfs2(m, n);
    }
}


void main() {
    auto N = readln.chomp.to!int;
    adj = new int[][](N);
    parent = new int[](N);
    ex = new real[](N);
    ans = new real[](N);
    fill(ex, 0);
    fill(ans, 0);

    foreach (i; 0..N-1) {
        auto s = readln.split.map!(x => x.to!int - 1);
        adj[s[0]] ~= s[1];
        adj[s[1]] ~= s[0];
    }

    dfs(0, -1);
    dfs2(0, -1);

    foreach (i; 0..N) writefln("%.9f", ans[i]);
}


Measured memory_bytes: 46076
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;


int main()
{
    SYNC
    //clock_t tStart = clock();

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,m; in(n)>>m;
    vector<vector<ll>>tree(n+1);
    l(i,0,m)
    {
        ll a,b;
        in(a)>>b;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    bool visited[n+1];
    l(i,0,n+1)
    {
        visited[i]=0;
    }
    ll ans=0;
    l(i,1,n+1)
    {
        if(!visited[i])
        {
            queue<ll>q;
            q.push(i);
            visited[i]=1;
            ll temp=1;
            while(!q.empty())
            {
                ll curr=q.front();
                q.pop();
                for(ll j=0; j<tree[curr].size(); j++)
                {
                    if(!visited[tree[curr][j]])
                    {
                        visited[tree[curr][j]]=1;
                        q.push(tree[curr][j]);
                        temp++;
                    }
                }
            }
            ans=max(ans,temp);
        }
    }
    o(ans)<<endl;









    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


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

int main(void){
    using namespace  std;
    int a, b;
    cin >> a >> b;
    string ret = "";
    if(a<b)
        for (int i = 0; i < b;i++)
            ret += to_string(a);
    else
        for (int i = 0; i < a;i++)
            ret += to_string(b);

    cout << ret << endl;

    return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  string input;
  int R;
  cin >> input >> R;
  vi num;
  REP(i, input.length()){
    switch(input[i]) {
    case '+':
      num.push_back(-1);
      break;
    case '*':
      num.push_back(-2);
      break;
    default:
      num.push_back(input[i] - '0');
      break;
    }
  }

  int L = num[0];
  for(int i = 1; i < num.size(); i+=2) {
    if(num[i] == -1) {
      L += num[i + 1];
    }else {
      L *= num[i + 1];
    }
  }

  for(int i = 1; i < num.size(); i+=2) {
    if(num[i] == -2) {
      num[i + 1] = num[i - 1] * num[i + 1];
      num[i - 1] = 0;
      num[i] = -1;
    }
  }

  int M = num[0];
  for(int i = 1; i < num.size(); i+=2) {
      M += num[i + 1];
  }

  string result = "IMLU";
  int res = ((L==R) & 1) << 1 | (M==R);
  cout << result[res] << endl;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
int b;
cin>>b;
int c;
cin>>c;
int n;
cin>>n;
if(max(max(b,c),a)==a){
           cout<<(pow(2,n)*a)+b+c;
}
else if(max(max(b,c),a)==b){
           cout<<(pow(2,n)*b)+a+c;
}
else{
           cout<<(pow(2,n)*c)+a+b;
}
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

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

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int  card[60];
int tmp[60];
int p,c;

int main(){
	while(1){
		int n,r;
		scanf("%d %d",&n,&r);
		if(n + r == 0) break;
		for(int i = 0;i < n;i++){
			card[n-i] = i+1;
		}
		for(int i = 0;i < r;i++){
			scanf("%d %d",&p,&c);
			for(int j = 1;j <= c;j++){
				tmp[j] = card[j + p - 1];
			}
			for(int j = p-1;j > 0;j--){
				card[j+c] = card[j];
			}
			for(int j = 1;j <= c;j++){
				card[j] = tmp[j];
			}
		}
		printf("%d\n",card[1]);

	}
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=200005;
int n,mx,Q,a[N];
int vis[N],ans[N];
struct TREE{
	int t[N*4],nn;
	void build(int n){
		for (nn=1;nn<=n+1;nn<<=1);
	}
	void change(int x,int v){
		x+=nn; t[x]=v;
		for (x>>=1;x;x>>=1)
			t[x]=max(t[x<<1],t[x<<1|1]);
	}
	int ask(int x){
		x+=nn-(x!=0);
		int ans=0;
		for (;x^1;x>>=1)
			if (!(x&1)) ans=max(ans,t[x^1]);
		return ans;
	}
}T[2];
bool check(int HX,int HY,int CX,int CY){
	int tmp=CX-CY+Q;
	if (tmp>=0&&T[tmp&1].ask(HY)>=tmp) return 1;
	tmp=CY-CX+Q;
	if (tmp>=0&&T[tmp&1].ask(HX)>=tmp) return 1;
	return 0;
}
int main(){
	scanf("%d",&n);
	T[0].build(n);
	T[1].build(n);
	For(i,1,n){
		scanf("%d",&a[i]);
		if (a[i]>mx){
			mx=a[i];
			vis[i]=1;
			++Q;
		}
	}
	Rep(i,n,1){
		int t=T[0].ask(a[i]);
		int v0=0,v1=0;
		vis[i]?v0=t+2:v1=t+1;
		t=T[1].ask(a[i]);
		if (t) vis[i]?v1=t+2:v0=t+1;
		T[0].change(a[i],v0);
		T[1].change(a[i],v1);
	}
	int HX=0,HY=HX,CX=0,CY=0,fl=1;
	For(i,1,n){
		if (vis[i]) --Q;
		T[0].change(a[i],0);
		T[1].change(a[i],0);
		int _HX=HX,_CX=CX;
		if (a[i]>HX) HX=a[i],++CX;
		if (check(HX,HY,CX,CY)) continue;
		HX=_HX; CX=_CX; ans[i]=1;
		if (a[i]>HY) HY=a[i],++CY;
		if (check(HX,HY,CX,CY)) continue;
		fl=0;
	}
	if (!fl) puts("-1");
	else For(i,1,n) putchar('0'+ans[i]);
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int x, y;
VI memo(100, -1);
int fib(int n) {
    if (n <= 2)return 1;
    if (memo[n] != -1)return memo[n];
    return memo[n] = fib(n - 1) + fib(n - 2);
}

int dfs(int sx, int sy, int gx, int gy, int n) {
    int f = fib(n);
    if (n % 4 == 2)gx += f;
    else if (n % 4 == 3)gy += f;
    else if (n % 4 == 0)sx -= f;
    else sy -= f;
    if (sx <= x && x <= gx && sy <= y && y <= gy) {
        if (n % 3 == 1)return 1;
        if (n % 3 == 2)return 2;
        if (n % 3 == 0)return 3;
    }
    return dfs(sx, sy, gx, gy, n + 1);
}

int main() {
    init();

    cin >> x >> y;
    if (x == 0 && y == 0)cout << "1\n";
    else cout << dfs(0, 0, 0, 0, 2) << "\n";
}


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

using namespace std;

int Prime(int);
int main()
{
  int n,a,c=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    c+=Prime(a);
  }
  cout<<c<<endl;
}

int Prime(int n)
{
  if(n==2) return 1;
  if(n<2 || n%2==0) return 0;
  for(int i=3;i*i<=n;i+=2){
    if(n%i==0) return 0;
  }
  return 1;
}
    



Measured memory_bytes: 3108
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <unordered_set>

using namespace std;

typedef long long LL;

const int P0 = 23;
const int P1 = 67;
const int MOD0 = 998244353;
const int MOD1 = 1000000007;

typedef pair<int , int> P;

#define mkp(a , b) make_pair(a , b)
#define ft first
#define sd second

inline P operator + (P p , P q){return mkp((p.ft + q.ft) % MOD0 , (p.sd + q.sd) % MOD1);}
inline P operator - (P p , P q){return mkp((p.ft - q.ft + MOD0) % MOD0 , (p.sd - q.sd + MOD1) % MOD1);}
inline P operator * (P p , P q){return mkp(1ll * p.ft * q.ft % MOD0 ,  1ll * p.sd * q.sd % MOD1);}

inline P &operator +=(P &p , P q){return p = p + q;}
inline P &operator -=(P &p , P q){return p = p - q;}
inline P &operator *=(P &p , P q){return p = p * q;}

const int N = 100005;
const int L = 100005;

unordered_set<LL> exist;

P hash_value[L] , inv[L] , invp;
char s[L] , t[L];
int len[N];
int f[L];
int n , l;

inline int quick_power(int x , int y , int mod)
{
	int ret = 1;
	for (;y;y >>= 1 , x = 1ll * x * x % mod) if (y & 1) ret = 1ll * ret * x % mod;
	return ret;
}

inline void add(int &x , int y){x = x + y >= MOD1 ? x + y - MOD1 : x + y;}

int main()
{
	//freopen("b.in" , "r" , stdin) , freopen("b.out" , "w" , stdout);
	scanf("%d" , &n);
	for (int i = 1 , l_;i <= n;++ i)
	{
		scanf("%s" , s + 1) , l_ = strlen(s + 1) , len[i] = l_;
		P base = mkp(1 , 1) , cur = mkp(0 , 0);
		for (int j = 1;j <= l_;++ j)
		{
			cur += base * mkp(s[j] - 'a' + 1 , s[j] - 'a' + 1);
			base *= mkp(P0 , P1);
		}
		exist.insert(cur.ft * 1000000000ll + cur.sd);
	}
	sort(len + 1 , len + 1 + n) , n = unique(len + 1 , len + 1 + n) - (len + 1);
	scanf("%s" , t + 1) , l = strlen(t + 1);
	inv[0] = mkp(1 , 1) , invp = mkp(quick_power(P0 , MOD0 - 2 , MOD0) , quick_power(P1 , MOD1 - 2 , MOD1));
	P base = mkp(1 , 1);
	f[0] = 1;
	for (int i = 1;i <= l;++ i)
	{
		inv[i] = inv[i - 1] * invp;
		hash_value[i] = hash_value[i - 1] + base * mkp(t[i] - 'a' + 1 , t[i] - 'a' + 1);
		for (int j = 1;j <= n && len[j] <= i;++ j)
		{
			P range_hash = (hash_value[i] - hash_value[i - len[j]]) * inv[i - len[j]];
			if (exist.count(range_hash.ft * 1000000000ll + range_hash.sd)) add(f[i] , f[i - len[j]]);
		}
		base *= mkp(P0 , P1);
	}
	printf("%d\n" , f[l]);
	//fclose(stdin) , fclose(stdout);
	return 0;
}


Measured memory_bytes: 5972
import java.util.*;

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

		String s = sc.next();
		String t = sc.next();

		char[] s_chars = s.toCharArray();
		Arrays.sort(s_chars);
		s = String.valueOf(s_chars);

		char[] t_chars = t.toCharArray();
		Arrays.sort(t_chars);
		t = String.valueOf(t_chars);


		String t_desc = new StringBuilder(t).reverse().toString();

		if(s.compareTo(t_desc) < 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}

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

using namespace std;
typedef long long ll;

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

int divide_2(int n)
{
    int res = 0;
    while (n % 2 == 0 && n)
    {
        res++;
        n /= 2;
    }
    return res;
}

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

    int cnt = 0;
    bool odd = true;
    rep(i, n) if (a[i] % 2 == 0) odd = false;

    rep(i, n)
    {
        if (a[i] % 2 == 0)
        {
            cnt += divide_2(a[i]);
        }
    }

    cout << ((odd) ? 0 : cnt) << '\n';
    return (0);
}


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

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

    const int N = 2e5+5;
    vector<int> adj[N];

    ll n, k;
    cin >> n >> k;
    
    for(int i=0; i<n; ++i){
        int x; cin>>x;
        x --;
        adj[i].push_back(x);
    }

    vector<int> path;
    int cycle_start = -1;
    int cycle_len = 0;
    path.push_back(0);
    int curr = 0;
    map<int,int> seen;
    seen[0] = 0;
    while(true){
        int nxt = adj[curr][0];
        if( seen.count(nxt) ){
            cycle_start = seen[nxt];
            cycle_len = path.size() - cycle_start;
            break;
        }else{
            seen[nxt] = path.size();
            path.push_back(nxt);
        }
        curr = nxt;
    }

    // for(auto i : path){ cout << i << " "; } cout << endl;
    // cout << "cycle len : " << cycle_len << '\n';
    // cout << "cycle start:" << cycle_start << '\n';
    int pos = 0;
    while(true){
        if(k==0){ break; }
        if(cycle_start == pos){ break; }
        k--;
        pos++;
    }
    if(k ==0 ){ cout<< path[pos]+ 1 <<'\n'; return 0; }

    k %= cycle_len;
    while(true){
        if(k==0){ break; }
        k--;
        pos++;
    }
    cout << path[pos]+1 << '\n';


    return 0;
}

Measured memory_bytes: 24064
#include<stdio.h>

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while( A[i] != key) i++;
    return i != n; //戻り値を出すことで条件分岐に使えるようになっている。
}

int main(){
    int i, n, A[10000+1], q, key, sum = 0;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    
    scanf("%d" ,&q);
    for( i = 0; i < q; i++){
        scanf("%d", &key);
        if( search(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
}


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


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  char s[5000];
  char slist[30000][6];
  int K,count=0;

  cin>>s;

  cin>>K;

  int len=strlen(s);
  len=min(len,5);


  for(int i=1;i<=len;i++){ //候補を列挙
    for(int j=0;j<strlen(s)-i+1;j++){
      strncpy(slist[count],s+j,i);
      count++;
    }
  }
  strncpy(slist[0],s,1);


  char ans[6][5];
  for(int i=0;i<5;i++){
    strcpy(ans[i],"zzzzz");
  }

  for(int i=0;i<count;i++){
    if(strcmp(slist[i],ans[0]) < 0){
      strcpy(ans[0],slist[i]);
    }
  }
  for(int i=0;i<count;i++){
    if(strcmp(slist[i],ans[1]) < 0&&strcmp(slist[i],ans[0])>0){
      strcpy(ans[1],slist[i]);
    }
  }
  for(int i=0;i<count;i++){
    if(strcmp(slist[i],ans[2]) < 0&&strcmp(slist[i],ans[1])>0){
      strcpy(ans[2],slist[i]);
    }
  }
  for(int i=0;i<count;i++){
    if(strcmp(slist[i],ans[3]) < 0&&strcmp(slist[i],ans[2])>0){
      strcpy(ans[3],slist[i]);
    }
  }
  for(int i=0;i<count;i++){
    if(strcmp(slist[i],ans[4]) < 0&&strcmp(slist[i],ans[3])>0){
      strcpy(ans[4],slist[i]);
    }
  }
  for(int i=0;i<count;i++){
    if(strcmp(slist[i],ans[5]) < 0&&strcmp(slist[i],ans[4])>0){
      strcpy(ans[5],slist[i]);
    }
  }

  cout<<ans[K-1];

  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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 main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll k = (n)/(a+b);
    ll z = n%(a+b);
    cout << a*k + min(a,z) << endl;
    return 0;
}   

Measured memory_bytes: 888