akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x;
	cin >> x;
	int h = (x / 500) * 1000;
	x %= 500;
	h += (x / 5) * 5;
	cout << h;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c;
int main() {
	scanf("%d",&n);
	a=b=c=0;
	for (int i=1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		if (x%4==0)
			c++;
		else if (x%2==0)
			b++;
		else a++;
	}
	if (c>=a||(b==0&&c==a-1))
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int a,b;
    cin>>a>>b;
    int h,m;
    cin>>h>>m;
    int eachhr = 30,eachmin = 6;
    double angle;
    double anglehr = h*30;
    double minhr   = 6*m;
    double extra  = ((double)m/60)*(double)30;
    angle = ((anglehr+extra)-minhr);
    angle = (angle/180)*M_PI;
    double ans = (a*a + b*b - 2*b*a*cos(angle));
    cout<<setprecision(10)<<fixed<<sqrt(ans);
}

Measured memory_bytes: 4176
using System;

class Program{
    static void Main(string[] args){
        string str = Console.ReadLine();
        if(System.Text.RegularExpressions.Regex.IsMatch(str, "111")){
            Console.WriteLine(3);
        }else if(System.Text.RegularExpressions.Regex.IsMatch(str, ".*1.*1.*")){
            Console.WriteLine(2);
        }else if(System.Text.RegularExpressions.Regex.IsMatch(str, ".*1.*")){
            Console.WriteLine(1);
        }else{
            Console.WriteLine(0);
        }
    }
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s[s.length() - 1] == 's') {
		cout << s << "es" << endl;
	}
	else {
		cout << s << "s" << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 705;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m, cnt[2], tot, x[MAXN], y[MAXN];
bool vis[MAXN], col[MAXN], a[MAXN][MAXN], dp[MAXN][MAXN];
void dfs(int pos) {
	vis[pos] = true;
	cnt[col[pos]]++;
	for (int i = 1; i <= n; i++)
		if (a[pos][i] == false) {
		if (!vis[i]) {
			col[i] = !col[pos];
			dfs(i);
		}
		else if (col[i] == col[pos] && i != pos) {
			printf("-1\n");
			exit(0);
		}
		}
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		a[x][y] = a[y][x] = true;
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			cnt[0] = cnt[1] = false;
			dfs(i);
			tot++;
			x[tot] = cnt[0];
			y[tot] = cnt[1];
		}
	}
	dp[0][0] = true;
	for (int i = 1; i <= tot; i++){
		for (int j = 0; j <= n; j++){
			if (dp[i - 1][j]) {
				dp[i][j + x[i]] = true;
				dp[i][j + y[i]] = true;
			}
		}
	}
	int ans = n * n;
	for (int i = 0; i <= n; i++)
		if (dp[tot][i] && dp[tot][n-i]) chkmin(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	writeln(ans);
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000000007
#define mod2 998244353

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}


void solve(){
	int p,n;cin>>p>>n;
	int dis,prev=0,s,e,max=0;
	rep(i,0,n){
		int temp;cin>>temp;
		if(i==0)s=temp;
		if(i==n-1)max=std::max(max,p-temp+s);
		dis=temp-prev;
		max=std::max(max,dis);
		prev=temp;
	}
	cout<<p-max;
	return;
} 
signed main(){
	IOS;

	// int n;  cin>>n;  rep(i,0,n){solve();cout<<endl;}
	solve();
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$B = explode(" ", trim(fgets(STDIN)));
$ans = 0;
for ($i = 0; $i < $N - 2; $i++) {
    $ans += min($B[$i], $B[$i + 1]);
}
$ans += $B[0];
$ans += $B[$N - 2];
echo $ans;


Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, m, v, p;
int a[100000];

bool check(int x) {
	if (x < p) return true;
	
	if (a[x] + m < a[p - 1]) return false;
	int vv = v - p;
	if (vv <= 0) return true;
	
	int i;
	int ssum = 0;
	rep(i, n) {
		if (i == x || i < p - 1) continue;
		int res = min(m, a[x] + m - a[i]);
		ssum += res;
	}
	if (ssum < vv * m) return false;
	return true;
}

signed main() {
	int i;
	
	cin >> n >> m >> v >> p;
	rep(i, n) cin >> a[i];
	sort(a, a + n, greater<int>());
	
	int st = 0, ed = n, mid;
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (check(mid)) st = mid;
		else ed = mid;
	}
	cout << st + 1 << endl;
	return 0;
}

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

int dp[100001];
vector<int> G[100001];

int solve(int s){
	if(dp[s] != -1) return dp[s];
	dp[s] = 0;
	for(int i=0; i<G[s].size(); i++){
		if(dp[s] < solve(G[s][i]) + 1) dp[s] = solve(G[s][i]) + 1;
	}
	return dp[s];
}

int main(){
	int n, m;
	cin >> n >> m;
	rep(i,m){
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}
	rep(i,n) dp[i] = -1;
	int ans = 0;
	rep(i,n){
		if(solve(i) > ans) ans = solve(i);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int ans[n];
	int p = 0;
	rep(i, n - 1) p ^= a[i + 1];
	ans[0] = p;
	rep(i, n - 1) {
		ans[i + 1] = a[i] ^ a[i + 1];
		ans[i + 1] ^= ans[i];
	}
	rep(i, n) {
		if (i) cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  int N;
  cin >> N;
  char S[N];
  rep(i, 0, N){
    cin >> S[i];
    if (S[i] == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
M = 40
C = [[0]*2 for _ in range(M+1)]
for a in A:
  for i in range(M+1):
    C[i][a>>i & 1] += 1
dp = [[0]*2 for _ in range(M+1)]
dp[M][1] = -float("inf")
for i in range(M-1, -1, -1):
  j = k>>i & 1
  dp[i][0] = dp[i+1][0]*2 + C[i][j^1]
  dp[i][1] = dp[i+1][1]*2 + max(C[i])
  if j:
    dp[i][1] = max(dp[i][1], dp[i+1][0]*2 + C[i][1])
ans = max(dp[0])
print(ans)

Measured memory_bytes: 20420
#include <iostream>
using namespace std;
 
int main(){
  int K,S;
   cin >> K;
   cin >> S;
  int ans = 0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j<=K && (S-i-j>=0))
	   ans++;
    }
  }
  cout << ans << endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll n;
    cin>>n;
    ll ans=(modexp(10,n,mod)+modexp(8,n,mod))%mod;
    ans = (ans - (2*modexp(9,n,mod))%mod + mod)%mod;
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int a[4];
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[3]-a[1]<<endl;
	return 0;
 } 

Measured memory_bytes: 256
n = int(input())
num = [int(x) for x in input().split()]
count = 0
a = 0

while(a==0):
    nl = []
    sl = []
    for i in num:
        if i %2 ==0:
            nl.append(i/2)
        else:
            sl.append(i)
    if sl == []:
        num =nl
        count += 1
    else:
        a = 1

print(count)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}

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

using namespace std;

struct StronglyConnectedComponents
{
  vector< vector< int > > gg, rg;
  vector< pair< int, int > > edges;
  vector< int > comp, order, used;

  StronglyConnectedComponents(size_t v) : gg(v), rg(v), comp(v, -1), used(v, 0) {}

  void add_edge(int x, int y)
  {
    gg[x].push_back(y);
    rg[y].push_back(x);
    edges.emplace_back(x, y);
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  void dfs(int idx)
  {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt)
  {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector< vector< int > > &t)
  {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    set< pair< int, int > > connect;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      if(connect.count({x, y})) continue;
      t[x].push_back(y);
      connect.emplace(x, y);
    }
  }
};

template< typename T >
struct MinimumSpanningTree_Arborescence
{

  struct edge
  {
    int to;
    T cost;
  };
  vector< vector< edge > > graph;
  T INF;

  MinimumSpanningTree_Arborescence(size_t v) : INF(numeric_limits< T >::max()), graph(v) {}

  void add_edge(int a, int b, T x)
  {
    graph[a].emplace_back((edge) {b, x});
  }

  T build(vector< vector< edge > > &g, int start, T sum)
  {
    int N = (int) g.size();

    vector< int > rev(N, -1);
    vector< T > weight(N, INF);
    for(int idx = 0; idx < N; idx++) {
      for(auto &e : g[idx]) {
        if(e.cost < weight[e.to]) {
          weight[e.to] = e.cost;
          rev[e.to] = idx;
        }
      }
    }

    StronglyConnectedComponents scc(N);
    for(int idx = 0; idx < N; idx++) {
      if(start == idx) continue;
      if(rev[idx] == -1) return (INF);
      scc.add_edge(rev[idx], idx);
      sum += weight[idx];
    }
    vector< vector< int > > renew;
    scc.build(renew);
    if(renew.size() == N) return (sum);
    vector< vector< edge > > fixgraph(renew.size());
    for(int i = 0; i < N; i++) {
      for(auto &e : g[i]) {
        if(scc[i] == scc[e.to]) continue;
        fixgraph[scc[i]].emplace_back((edge) {scc[e.to], e.cost - weight[e.to]});
      }
    }
    return (build(fixgraph, scc[start], sum));
  }

  T build(int start)
  {
    auto get = build(graph, start, 0);
    if(get >= INF) return (-1);
    return (get);
  }
};


void solve()
{
  int V, E, R;
  cin >> V >> E >> R;
  MinimumSpanningTree_Arborescence< int > mst(V);
  while(E--) {
    int a, b, c;
    cin >> a >> b >> c;
    mst.add_edge(a, b, c);
  }
  cout << mst.build(R) << endl;
}

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

Measured memory_bytes: 3816
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define db(n) cout << "### " << n << " ###" << endl;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
//------------------------------------------------------------------------------------------------------

int dp[3100][3100]={0};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    //dp[i+1][j+1] := sのi文字目までと tのj文字目まででの LCS の長さ
    //LCSの長さ dp[s.size()][t.size()]
    string s,t; cin >> s >> t;
    REP(i,s.size())REP(j,t.size()){
        if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
    }

    //復元
    string res = "";
    int i = (int)s.size() , j = (int)t.size();
    while(i>0 && j>0){//どちらかが0になったら打ち切る
        /*(i-1, j) -> (i, j)*/if(dp[i][j]==dp[i-1][j])i--;
        /*(i, j-1) -> (i, j)*/else if(dp[i][j]==dp[i][j-1]) j--;
        /*(i-1, j-1)->(i, j)*/else{res = s[i-1]+res; i--; j--;}
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

struct edge
{
    int to,cost;
};

vector<edge> G[MAX_N];
bool flag[MAX_N];

P dfs(int u)
{
    flag[u] = true;
    if(G[u].size() == 0){
        return P(0,0);
    }
    int mx = 0;
    int sm = 0;
    rep(i,G[u].size()){
        if(!flag[G[u][i].to]){
            P p = dfs(G[u][i].to);
            if(p.se == 0){
                sm += G[u][i].cost;
            }else{
                mx = max(mx,p.fi+G[u][i].cost);
                sm += 3*G[u][i].cost+p.se;
            }
        }
    }
    return P(mx,sm);
}

int main()
{
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> v1(n-1),v2(n-1);
        rep(i,n-1){
            cin >> v1[i];
            v1[i]--;
        }
        rep(i,n-1){
            cin >> v2[i];
        }
        rep(i,n){
            G[i].clear();
        }
        rep(i,n-1){
            G[i+1].pb((edge){v1[i],v2[i]});
            G[v1[i]].pb((edge){i+1,v2[i]});
        }
        int ans = INF;
        rep(i,n){
            rep(j,n){
                flag[j] = false;
            }
            P p = dfs(i);
            ans = min(ans,p.se-p.fi);
        }
        cout << ans << "\n";
    }
}

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

num = [0]*n
flag = [False]*n

for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if flag[p]:
    continue
  else:
    if s == "AC":
      flag[p] = True
    else:
      num[p] += 1

for i in range(n):
  if flag[i] == False:
    num[i] = 0
    
print(flag.count(True),sum(num))


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

signed main(){
  int x=0,y=0,z=0,w=0,n=0;
  string s;
  std::cin >> x>>y>>z;
  if(x==y&&y==z)std::cout << "No" << '\n';
  else if(x!=y&&y!=z&&x!=z)std::cout << "No" << '\n';
  else  std::cout << "Yes" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n,0);
	rep(i,m){
		int s,c;
		cin >> s >> c;
		s--;
		if(a[s] != 0 && a[s] != c){
			cout << "-1" << endl;
			return 0;
		}else if(s==0 && c == 0 && n!=1){
			cout << "-1" << endl;
			return 0;
		}else if(c<0 || c>10){
			cout << "-1" << endl;
			return 0;
		}else if(n<1 || n>3){
			cout << "-1" << endl;
			return 0;
		}else{
			a[s] = c;
		}
	}
	if(a[0]==0 && n!=1){
		a[0] = 1;
	}
	int sum=0;
	int dig=1;
	rep(i,n){
		sum += a[n-i-1] * dig;
		dig *= 10;
	}
	cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;
 
const int Inf = 1000000007;
//const int mod = 998244353;//1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

long long n, d = 0, t = 100;
 
void Solve()
{
	cin >> n;
	while(n > t)
	{
		long long x = t / 100;
		t += x;
		d++;
	}
	cout << d;
}
 
int main()
{
	Fastio();
	Solve();
}

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

using namespace std;

void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}




int main()
{
    init();
    int n ;
    cin>>n;
    //int v=1;
    int odd=0;
    for(int i =1;i<=n;i++){
            int d=0;
            int v=i;

        while(v>0){
            v=v/10;
             d++;

        }
        if(d%2!=0) odd++;
    }
    cout<<odd;
   }


Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e5+69, INF=2e9+6969;

int qq;

int main()
{
	int n,k,t[R];
	cin >> n >> k;
	for(int i=1;i<=n;++i) cin >> t[i];
	for(int i=k+1;i<=n;++i)
	{
		puts(t[i]>t[i-k] ? "Yes" : "No");
	}
	return 0;
}


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

const int N = 1e5+5 ; 
vector<vector<int> >v ; 
int n , m , dp[N] ; 
bool vis[N] ; 
int dfs(int u) {
	
	if(vis[u])
		return dp[u] ;
	
	vis[u] = 1 ; 
	int &mx = dp[u] ; 
	for (int i =0 ; i<v[u].size() ;++i ) {
		mx = max(mx , 1+dfs(v[u][i])) ; 
	}
	
	return mx ; 
}

int main() {
	
	scanf("%d %d" , &n , &m) ; 
	v.resize(n) ; 
	for (int i =0 ; i<m  ;++i) {
		int x , y ; 
		scanf("%d %d" ,&x , &y) ; 
		v[--x].push_back(--y) ; 
	}
	
	for (int i =0 ; i<n ; ++i) 
		if (!vis[i]){
			dp[i] = dfs(i) ; 	
		}
	int ans = 0 ;
	for (int i =0 ; i<n ; ++i)
		ans = max(ans , dp[i]) ; 
	
	printf("%d\n" , ans) ;
	
	return 0;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
 
// Tushar Goyal : Chalie Shuru karte hai

/*

dp(i,j)   -> sum({	dp(i-1,j) ,dp(i-1,j-1) ,dp(i-1,j-2)  , ............ dp(i-1,j-ai)	})
dp(i,j-1) -> sum({			  dp(i-1,j-1) ,dp(i-1,j-2) ,dp(i-1,j-3)  , ......... dp(i-1,j-1-ai)	})
dp(i,j)   -> dp(i,j-1)  - dp(i-1,j-1-ai) + dp(i-1,j)

*/

const int mod = 1e9+7;

void solve() 
{
	int n,k;
	cin>>n>>k;

	vector<int> a(n+1);
	for(int i = 1 ; i<=n ; i++)cin>>a[i];

	vector<vector<int>> dp(n+1,vector<int>(k+1,0));
	dp[0][0]=1;

	for(int i = 1 ; i<=n ; i++)
	{
		for(int j = 0 ; j<=k; j++)
		{
			dp[i][j] = dp[i][j-1]+dp[i-1][j];
			dp[i][j]%=mod;
			if(j-1-a[i]>=0)dp[i][j]-=dp[i-1][j-1-a[i]];
			dp[i][j] = (dp[i][j]+ mod)%mod;
		}
	}
	cout<<dp[n][k]<<endl;
}
 
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
    return 0;
}

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

int main(){
  int N; cin>>N;
  vector<int> x(N),y(N),h(N);
  for(int i=0;i<N;i++)
    cin>>x[i]>>y[i]>>h[i];
  for(int cy=0;cy<=100;cy++){
    for(int cx=0;cx<=100;cx++){
      int H = 1;
      for(int i=0;i<N;i++){
        if(h[i]) H = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
      }
      bool ok = true;
      for(int i=0;i<N;i++){
        if(max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i])
          ok = false;
      }
      if(ok){
        cout<<cx<<" "<<cy<<" "<<H<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main () {
  
  int S;
  
  scanf("%d", &S);
  if(S >= 0 && S < 86400) {
    printf("%d:%d:%d\n",S/3600, (int)(S-3600*(S/3600))/60, (S-3600*(S/3600))-((S-3600*(S/3600))/60)*60 );
  }
  return 0;
  
}

Measured memory_bytes: 592
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};

struct Node T[MAX];
int n,D[MAX],H[MAX];


void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l==NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
   scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
	if(j==0)T[v].l=c;
	else T[l].r=c;
	l=c;
	T[c].p=v;
      }
    }
    for(i=0;i<n;i++){
      if(T[i].p==NIL)r=i;
    }

    rec(r,0);

    for(i=0;i<n;i++)
      print(i);
    return 0;}
  



Measured memory_bytes: 7360
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long 
#define double long double
int check(int a,int b,int x){
    return a*x/b-a*(x/b);
}
main (void){
    int a,b,c;
    cin>>a>>b>>c;
    int d=b/a;
    int e=a*(d+1);
    if(e<=c||(d*a)==b){
        cout<<"OK"<<endl;
    }
    else{
        cout<<"NG"<<endl;
    }
}

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

int num_of_packs(int packs[], const int& n, const int& k, const int& max_load)
{
  int i = 0;
  for (int j = 0; j < k; ++j)
  {
    int truck = 0;
    while (truck + packs[i] <= max_load)
    {
      truck += packs[i];    // Load onto the truck
      ++i;                  // The next pack
      if (i == n) return n; // No more pack
    }
  }
  return i;
}

int get_p(int packs[], const int& n, const int& k)
{
  int p_left = 0;
  int p_right = 100000 * 10000;
  int p_mid;
  while (p_right - p_left > 1)
  {
    p_mid = (p_left + p_right) / 2;
    int v = num_of_packs(packs, n, k, p_mid);
    if (v >= n) p_right = p_mid;
    else p_left = p_mid;
  }

  return p_right;
}

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

  int packs[100000];
  for (int i = 0; i < n; ++i)
  {
    cin >> packs[i];
  }

  cout << get_p(packs, n, k) << endl;

  return 0;
}



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

int main() {
    int n, count = 0;
    cin >> n;
    vector<int>l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end());
    for(int i = 0; i < n-2; i++) {
        for(int j = i+1; j < n-1; j++) {
            for(int k = j+1; k < n; k++) {
                if(l[k] < l[i] + l[j]) count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc127/tasks/abc127_e
//シグマの順番を入れ替える
//足し算はシグマから切り離せる
//参考：https://drken1215.hatenablog.com/entry/2019/06/15/111500
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL N,M,K;

LL ans = 0;

//
void solve(){
    mint pattern(0);
    combination c(N*M-2);
    for(int i=1;i<M;i++){
        pattern += i*(M-i)*N*N;
    }
    for(int i=1;i<N;i++){
        pattern += i*(N-i)*M*M;
    }
    pattern *= c(N*M-2,K-2).x;
    ans = pattern.x;
}
 
int main(){
	cin >> N >> M >> K;
 
	solve();

	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
#ifndef	ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string ans = "";
    ll n;
    cin >> n;
    ll len = n;
    while(len > 0) {
    	--len;
    	ans += ('a' +  len % 26);
    	len /= 26;
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}


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

ll dist(ll x1, ll y1, ll x2, ll y2){
  ll dist = abs(x1-x2) + abs(y1-y2);
  return dist;
}

ll altitude(ll cx, ll cy, ll h, ll x, ll y){
  ll alt = (h > dist(cx, cy, x, y)) ? (h - dist(cx, cy, x, y)) : 0;
  return alt;
}

int main(){
  ll n; cin >> n;
  ll py[n][3];
    
  for(int i=0; i<n; i++)
    cin >> py[i][0] >> py[i][1] >> py[i][2];

  ll piv;
  for(int i=0; i<n; i++)
    if(py[i][2] != 0){piv = i; break;}
  

  for(int cx=0; cx<=100; cx++){
    for(int cy=0; cy<=100; cy++){
      ll h = py[piv][2] + dist(cx, cy, py[piv][0], py[piv][1]);
      int flag = 1;
      for(int i=0; i<n; i++){
        if(py[i][2] != altitude(cx, cy, h, py[i][0], py[i][1])){
          flag = 0;
          break;
        }
      }
      if (flag == 1){
        cout << cx << " " << cy << " " << h << endl;
        return 0;
      }
    }
  }
  cout << "error" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const ll mod = 1000000007;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号

    UnionFind(int N) : par(N) { // 最初は全てが根であるとして初期化
        for (int i = 0; i < N; ++i) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る
        if (par[x] == x) return x;
        return par[x] = root(par[x]); // 経路圧縮
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) { // 2つのデータx,yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<int> cnt;
bool divisor(ll n)
{
    bool ok = true;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            cnt[i]++;
            if (i * i != n)	cnt[n / i]++;
            if (i != 1 && 1 < cnt[i]) ok = false;
            if (n / i != 1 && 1 < cnt[n / i]) ok = false;
        }
    }
    return ok;
}
ll getGCD(ll a, ll b)
{
    // Greatest Common Divisor
    if (b == 0)	return a;
    return getGCD(b, a % b);
}
int main()
{
    /*int d, t, s; cin >> d >> t >> s;
    if (d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    */

    /*string s, t; cin >> s >> t;
    int mx = 0;
    rep(i, s.size()) {
        int tmp = 0;
        if (s.size() < i + t.size()) continue;
        rep(j, t.size()) {
            if (s[i + j] == t[j]) tmp++;
        }
        mx = max(mx, tmp);
    }
    cout << t.size() - mx << endl;
    */

    /*int n; cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n + 1, 0);
    sum[0] = 0;
    rep(i, n) {
        cin >> a[i];
        sum[i + 1] = a[i] + sum[i];
        sum[i + 1] %= mod;
    }
    ll ans = 0;
    rep(i, n) {
        ll s = sum.back() - sum[i + 1];
        s %= mod;
        if (s < 0) s += mod;
        ans += a[i] * s;
        ans %= mod;
    }
    cout << ans << endl;
    */

    /*int n, m; cin >> n >> m;
    UnionFind tree(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        tree.unite(x - 1, y - 1);
    }
    int ans = 0;
    vector<int> cnt(n, 0);
    rep(i, n) {
        cnt[tree.root(i)]++;
    }
    rep(i, n) {
        ans = max(ans, cnt[i]);
    }
    cout << ans << endl;
    */

    int n; cin >> n;
    vector<ll> a(n);
    bool pc = true;
    cnt.assign(1000005, 0);
    rep(i, n) {
        cin >> a[i];
        if (pc) pc = divisor(a[i]);
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    ll gcd = a[0];
    for(int i = 1; i < n; ++i) {
        gcd = getGCD(gcd, a[i]);
    }
    if (gcd == 1) {
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;

    return 0;
}

Measured memory_bytes: 14736
#include<iostream>
#include<cstdio>
#include<cmath> 
#include<algorithm>
using namespace std;
int N,h[100001],f[100001];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d",&h[i]);
	f[0]=0;f[1]=abs(h[1]-h[0]);
	for(int i=2;i<N;i++)
	f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	printf("%d",f[N-1]);
	return 0;
}

Measured memory_bytes: 1024
def checkABC(S):
    count = 0
    for i in range(len(S)):
        if S[i] == 'A':
            if i+1 < len(S) and S[i+1] == 'B':
                if i+2 < len(S) and S[i+2] == 'C':
                    count += 1
    
    return count


N = int(input())

S = list(input())

print(checkABC(S))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line_input = System.Console.ReadLine();
            var split = line_input.Split(' ');
            int N = int.Parse(split[0]);
            int R = int.Parse(split[1]);
            int result = 0;
            if (N >= 10) { result = R; } else
            {
               result =  R + 100 * (10 - N);
            }
            System.Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

int main(void) {
    int debt;
    int tmp;
    int count;
    debt = 100000;
    scanf("%d",&count);
    while(count != 0){
        debt = (int)((double)debt * 1.05);
        if(debt%1000 != 0){
            debt = ((debt/1000)+1) * 1000;
        }
        count--;
    }
    printf("%d\n",debt);
	return 0;
}

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

int main()
{
  int a,b,c;
  int tmp;
  cin >> a >> b >>c;
  tmp=a;
  a=b;
  b=tmp;
  tmp=a;
  a=c;
  c=tmp;
  cout << a <<" "<< b <<" "<< c <<endl;
}


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

int main(){
	int X;
	cin >> X;
	int N = X/100;
	X -= 100*N;
	int M = 0;
	for (int i = 5; i >0; i--) {
		M += X/i;
		X -= i*(X/i);
	}
	if (X==0 && M<=N) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n,m;
long long a;
long long b;
long long f;
long long p,q;
long long v[100006];
vector<long long> G[100006];

void saiki(long long now,long long color)
{
	v[now]=color;
	rep(i,G[now].size())
	{
		if(v[G[now][i]]==color)
		{
			f=1;
			break;
		}
		if(v[G[now][i]]==0)
		{
			v[G[now][i]]=3-color;
			saiki(G[now][i],3-color);
		}
	}
}
int main()
{
	cin>>n;
	cin>>m;
	rep(i,m)
	{
		cin>>a>>b;a--;b--;
		G[a].push_back(b);G[b].push_back(a);
	}
	saiki(0,1);
	rep(i,n)
	{
		if(v[i]==1)p++;
		if(v[i]==2)q++;
	}
	if(f==1)
	{
		cout<<n*(n-1)/2-m<<endl;
	}
	else cout<<p*q-m<<endl;
	return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    //i =  1, 2, 3
    //P =  2, 3, 1
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int t[3];
int u[3];
int func(int k){
  if(t[k]==0)return 0;
  
  for(int i=0;i<3;i++)u[i]=t[i];
  
  int sum=k,cnt=t[0]+1;
  t[k]--;
  while(1){
    if(sum==2){
      if(t[2]==0){
        if(t[1]>0)cnt++;
        break;
      }
      
      t[2]--;
      cnt++;
      sum=1;
    }else if(sum==1){
      if(t[1]==0){
        if(t[2]>0)cnt++;
        break;
      }
      
      t[1]--;
      cnt++;
      sum=2;
    }
  }
  for(int i=0;i<3;i++)t[i]=u[i];
  return cnt;
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    a%=3;
    t[a]++;
  }

  if(t[0]==n){
    printf("1\n");
  }else{
    printf("%d\n",max(func(1),func(2)));
  }
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<cstdlib>
#include<climits>
using namespace std;

struct Point {
    int x, y;
    Point(const int x = 0, const int y = 0) :x(x), y(y) {}
};

class Compare {
public:
    Compare(const bool y = false) :y(y) {}
    bool operator()(const Point& lhs, const Point& rhs) const {return y ? lhs.y < rhs.y : lhs.x < rhs.x;}
    bool y;
};

long long int distance(const Point& p, const Point& q) {return abs(p.x - q.x) + abs(p.y - q.y);}

int main() {
    int W, H, N;
    cin >> W >> H >> N;

    vector<Point> home(N);
    for(auto& h: home) cin >> h.x >> h.y;

    set<int> median_x;
    sort(home.begin(), home.end(), Compare());
    median_x.insert(home[N / 2].x);
    median_x.insert(home[(N - 1) / 2].x);

    set<int> median_y;
    sort(home.begin(), home.end(), Compare(true));
    median_y.insert(home[N / 2].y);
    median_y.insert(home[(N - 1) / 2].y);

    long long int answer_distance = LLONG_MAX;
    int answer_x = 0;
    int answer_y = 0;
    for(const auto& x: median_x) for(const auto& y: median_y) {
        Point santa(x, y);
        long long int farthest = 0;
        long long int sum = 0;
        for(const auto& h: home) {
            long long int d = distance(santa, h);
            farthest = max(farthest, d);
            sum += d * 2;
        }
        sum -= farthest;
        if(answer_distance <= sum) continue;
        answer_distance = sum;
        answer_x = x;
        answer_y = y;
    }

    cout << answer_distance << endl;
    cout << answer_x << " " << answer_y << endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, M;
LL dp[301][301][301];

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

  cin >> N >> M;
  vector<vector<PII>> ban(301);
  REP(i,M){
	int l, r, x;
	cin >> l >> r >> x;
	ban[r].EB(l,x);
  }

  dp[0][0][0] = 1;
  REP(r,N) REP(g,N) REP(b,N){
	int k = max({r, g, b});
	(dp[k+1][g][b] += dp[r][g][b]) %= MOD;
	(dp[r][k+1][b] += dp[r][g][b]) %= MOD;
	(dp[r][g][k+1] += dp[r][g][b]) %= MOD;

	for(auto&& p: ban[k+1]){
	  int nr = (p.FF <= r);
	  int ng = (p.FF <= g);
	  int nb = (p.FF <= b);
	  if(1+ng+nb != p.SS)
		dp[k+1][g][b] = 0;
	  if(nr+1+nb != p.SS)
		dp[r][k+1][b] = 0;
	  if(nr+ng+1 != p.SS)
		dp[r][g][k+1] = 0;
	}
  }

  LL ans = 0;
  REP(i,N) REP(j,N) (ans += dp[N][i][j] + dp[i][N][j] + dp[i][j][N]) %= MOD;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 213376
n = int(input())
transport = [int(input()) for x in range(0,5)]

trans_min_index = transport.index(min(transport))
if transport[trans_min_index] == 1 :
    time = 5-1 + int(n/transport[trans_min_index])
else:
    time = 5-1 + int(n/transport[trans_min_index] + 1)

print(time)


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int n,k,ans;
	cin >> n >> k;
	int h[n];
	rep(i,n) cin >> h[i];
	rep(i,n) {
		if (h[i] >= k) ans += 1;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

const int inf = numeric_limits<int>::max() / 3;

struct edge{
    int to,cost;
    edge(){}
    edge(int to_,int cost_) : to(to_) , cost(cost_) {}
};

int N,M,cap;
int src,dest;
vector<edge> g[6000];

void solve(){
    for(int i=0;i<6000;i++) g[i] = vector<edge>();
    string srcc,destt;
    cap *= 10;
    cin >> srcc >> destt;
    int namecount=0;
    map<string,int> names;
    for(int i=0;i<N;i++){
        string c1,c2;
        int dist;
        cin >> c1 >> c2 >> dist;
        if(!names.count(c1)){
            names[c1] = namecount++;
        }
        if(!names.count(c2)){
            names[c2] = namecount++;
        }

        g[names[c1]].push_back(edge(names[c2],dist));
        g[names[c2]].push_back(edge(names[c1],dist));
    }

    if(!names.count(srcc)){
        names[srcc] = namecount++;
    }
    if(!names.count(destt)){
        names[destt] = namecount++;
    }
    int src = names[srcc];
    int dest = names[destt];

    set<int> s;
    for(int i=0;i<M;i++){
        string ss;cin >> ss;
        s.insert(names[ss]);
    }

    using Vertex = pair<int,int>; // ?????????????,???????????¨
    using State = pair<int,Vertex>; // ????????????¢, ????????????? 

    // dist[?????????????][?????£?????????????¨??????????????¢???????\] = ?????????????????????????¢
    vector<vector<int>> dist(6000,vector<int>(3000,inf));
    
    priority_queue<State,vector<State>,greater<State>> que;
    que.push(State(0,Vertex(src,cap)));
    dist[src][cap] = 0;

    //for(auto p : names) cerr << p.first << " " << p.second << endl;

    while(!que.empty()){
        int d = que.top().first;
        Vertex v = que.top().second;
        que.pop();
        
        int node = v.first;
        int c = v.second;

        //cerr << node << " " << c << " " << d << endl;

        if(s.count(node)){
            c = cap;
        }

        for(edge& e : g[node]){
            int ncap = c - e.cost;
            //cerr << "e = " << e.to << " " << e.cost << endl;
            if(ncap < 0) continue;
            if(dist[e.to][ncap] > d + e.cost){
                //cerr << "push " << e.to << " " << ncap << endl;
                dist[e.to][ncap] = d + e.cost; 
                que.push(State(dist[e.to][ncap],Vertex(e.to,ncap)));
            }
        }
    }

    int ans = inf;
    for(int i=0;i<3000;i++) ans = min(ans,dist[dest][i]);

    if(ans==inf) cout << -1 << endl;
    else cout << ans << endl;
}

int main(){
    while(1){
        cin >> N >> M >> cap;
        if(N==0 and M==0 and cap==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 99028
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

int DP[100001];
int A[100001];

#define INF (1000000001)


void LCS(int n){
    
    for (int i = 0; i < n; i++){
        *lower_bound(DP, DP + 100001, A[i]) = A[i];
    }
}


int main(){
    
    int n;
    scanf("%d", &n);

    for (int i = 0; i< n ; i++) {
        scanf("%d", &A[i]);
    }
    
    fill(DP, DP + 100001, INF);
    
    LCS(n);
    
    int ans = 0;
    
    for (int i = 0;  i < n; i++) {
        if (DP[i] != INF) {
            ans++;
        }
        else{
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1988
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif

	ll a,b,c;
	cin>>a>>b>>c;
	((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) ? cout<<"Yes" : cout<<"No";

	return 0;
}


Measured memory_bytes: 256