akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#define SIZE 2000000

int main() {
  static int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  static char com[21], buf[20];
  buf[19]='\n';
  char outbuf[3000];
  int outlen=0;
  char *p;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') { // insert
      A[++H] = 0;
      p = com+7;
      do {
        A[H] = A[H]*10 + *p-'0';
        p++;
      } while (*p&0x20);  // (*p!='\n');
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }
    } else if (com[1]=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      //      fputs(buf+i+1, stdout);
      strncpy(outbuf+outlen, buf+i+1, 19-i);
      outlen += 19-i;
      if (outlen>2980) {
        write(1, outbuf, outlen);
        outlen=0;
      }
      
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        largest = i;
        if (l < H && A[l] > A[i])        largest = l;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    } else {
      write(1, outbuf, outlen);
      break;
    }
  } while (1); //(com[2]!='d'); // end
  return 0;
}


Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, q; cin >> n >> q;
    vector<vector<int>> adj(n + 10);
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    vector<ll> add(n + 10, 0);
    vector<ll> res(n + 10, 0);
    for (int i = 0; i < q; i++) {
        int p, x; cin >> p >> x;
        add[p] += x;
    }
    function<void(int, int)> dfs = [&](int v, int p) {
        res[v] += add[v];
        for (int &u : adj[v]) {
            if (u == p) {
                continue;
            }
            add[u] += add[v];
            dfs(u, v);
        }
    };
    dfs(1, 0);
    for (int i = 1; i <= n; i++) {
        cout << res[i] << "\n";
    }
}


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  REP(i,5) {
    int x;
    cin >> x;
    if (x == 0) {
      COUT(i+1);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3640
N, M = map(int, input().split())
if N > 1:
    number = [1] + [0] * (N-1)
else:
    number = [0]
SC = {}
for _ in range(M):
    s, c = map(int, input().split())
    if SC.get(s, c) != c:
        print(-1)
        exit()
    if N >= 2 and (s == 1 and c == 0):
        print(-1)
        exit()
    number[s-1] = c
    SC[s] = c
print("".join(map(str, number)))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm> 
#include <cmath>
#include <cstdlib>
using namespace std;
#define ll long long 
#define gc getchar_unlocked
const ll int INF = 1e18;
const int MOD = 1000000007;

const int MAXN = 200001;
ll tree[4*MAXN];
ll h[MAXN];
ll a[MAXN];
ll dp[MAXN];

void build(int i,int l,int r)
{
    if(l == r)
    {
        tree[i] = dp[l]; return;
    }
    int mid = (l+r)/2; 
    build(2*i,l,mid);
    build(2*i+1,mid+1,r);
    tree[i] = max(tree[2*i],tree[2*i+1]);
}
ll query(int i,int l,int r,int ql,int qr)
{
    if(l > qr || r < ql)
        return 0;
    if(l >= ql && r <= qr)
        return tree[i];
    int mid = (l+r)/2; 
    ll ans1 = query(2*i,l,mid,ql,qr);
    ll ans2 = query(2*i+1,mid+1,r,ql,qr); 
    return max(ans1,ans2);
}
void update(int i,int l,int r,int j)
{
    if(l == r)
    {
        tree[i] = dp[l]; return;
    }
    int mid = (l+r)/2; 
    if(j <= mid)
        update(2*i,l,mid,j);
    else 
        update(2*i+1,mid+1,r,j);
    tree[i] = max(tree[2*i],tree[2*i+1]);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
        cin>>h[i]; 
    for(i=1;i<=n;i++)
        cin>>a[i]; 
    memset(dp,0,sizeof(dp)); 
    build(1,1,n); 
    for(i=1;i<=n;i++)
    {
        if(h[i] == 1)
            dp[h[i]] = a[i];
        else 
            dp[h[i]] = a[i] + query(1,1,MAXN,1,h[i]-1);
        update(1,1,MAXN,h[i]);
    }
    ll ans = 0;
    for(i=1;i<=n;i++)
    {
        ans = max(ans,dp[h[i]]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 12360
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

struct edge {
  int to, cost;
  bool used;
};
typedef vector<vector<edge>> graph;

void warshallFloyd(int n, const graph &g, vector<vector<int>> &d) {

  REP(i, n) {
    REP(j, n) { d[i].push_back(100000000); }
  }
  REP(i, n) {
    for (auto e : g[i]) {
      d[i][e.to] = e.cost;
    }
  }
  REP(i, n) { d[i][i] = 0; }

  REP(k, n) {
    REP(i, n) {
      REP(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  graph g(n);

  REP(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back({b, c, false});
    g[b].push_back({a, c, false});
  }

  vector<vector<int>> d(n);
  warshallFloyd(n, g, d);

  REP(i, n) {
    REP(j, n) {
      REP(k, g[i].size()) {
        if (d[j][i] == d[j][g[i][k].to] + g[i][k].cost) {
          g[i][k].used = true;
        }
      }
    }
  }

  int ans = 0;
  REP(i, n) {
    for (auto e : g[i]) {
      if (!e.used) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
    
	int x = a, y = d;
	if (a < c)x = c;
	if (b < d)y = b;
	int t = y - x;
	if (t < 0)t = 0;

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
class Practice
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]), b = int.Parse(str[1]), c = int.Parse(str[2]);
        int cnt = 0;
        for (int i = a; i <= b; ++i) if (c % i == 0) ++cnt;
        Console.WriteLine(cnt);
    }
}


Measured memory_bytes: 15976
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int n;
    cin >> n;
    int x[n];
    rep(i,n) cin >> x[i];
    int m;
    cin >> m;
    int a[m];
    rep(i,m) cin >> a[i];
    
    rep(i,m) {
        if(x[a[i]-1] != 2019 && ((a[i] < n && x[a[i]-1]+1 != x[a[i]]) || n == a[i])) x[a[i]-1]++;
    }
    rep(i,n) cout << x[i] << endl;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
// const int mod=998244353;
const int INF=4e18+10;
const int MOD=mod;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


bool no(string s)
{
    return !(s=="0011" || s=="0101"|| s=="1110" || s=="1111");
}

int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int inverse(int q)
{
   return pow(q, mod-2);
}

vector<int> factorize(int n)
{
    vector<int> out;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            out.pb(i);
            if(i!=n/i)
                out.pb(n/i);
        }
    }
    if(n!=1)
    out.pb(n);
    return out;
}
bool check (int n, int i)
{
    while(n%i==0)
        n/=i;
    n%=i;
    return n==1;
}
signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
    int n;
    cin>>n;
    vector<int> fac, fac1;
    fac=factorize(n);
    fac1=factorize(n-1);
    int cnt=fac1.size();
    for(auto i:fac)
    {
        //brute force check;
        if(check(n, i))
            cnt++;
    }
    cout<<cnt<<endl;

    // -------------------------------------Code ends here------------------------------------------------------------------

 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

using namespace std;

#define MOD 1000000021

int n;
char x[55];
int p[30];
map<pair<long long, long long>, int> m[55];
long long ans;

void go(int a, long long b, long long c, int d) {
	if (a == n)
		m[d][{b, c}]++;
	else {
		go(a + 1, (b * 30 + x[a]) % MOD, c, d + 1);
		go(a + 1, b, (c * 30 + x[a]) % MOD, d + 1);
	}
}

void go2(int a, long long b, long long c, int d) {
	if (a == n) {
		ans += m[d][{b, c}];
	} else {
		go2(a + 1, (b * 30 + x[a]) % MOD, c, d + 1);
		go2(a + 1, b, (c * 30 + x[a]) % MOD, d + 1);
	}
}

int main() {
	for (int i = 0; i < 30; i++)
		p[i] = i;
	random_shuffle(p, p + 30);
	scanf("%d%s", &n, x);
	for (int i = 0; i < n * 2; i++) {
		x[i] -= 'a';
		x[i] = p[x[i]];
	}
	reverse(x + n, x + n + n);
	go(0, 0, 0, 0);
	memcpy(x, x + n, n);
	go2(0, 0, 0, 0);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
const int N=5005,Mod=1e9+7,inv=(Mod+1)>>1;
int dp[N][N];char a[N];
int mo(int x){return x>=Mod?x-Mod:x;}
int main (){
	int n;scanf ("%d",&n);
	scanf ("%s",a+1);
	int l=strlen(a+1);
	dp[0][0]=1;
	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++){
			dp[i+1][max(j-1,0)]=mo(dp[i][j]+dp[i+1][max(j-1,0)]);
			dp[i+1][j+1]=mo(mo(dp[i][j]*2)+dp[i+1][j+1]);
		}
	for (int i=1;i<=l;i++) dp[n][l]=1ll*dp[n][l]*inv%Mod;
	printf ("%d",dp[n][l]);
	return 0;
}


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

namespace Contest.cs
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = ReadInt()[0];
			int ans;
			if (n % 2 == 0)
			{
				ans = n;
			}
			else
			{
				ans = n * 2;
			}
			Console.WriteLine(ans);
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadInt()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for(int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowElemCnt(const vector<int>& cnrvnSeq)
{
  int nLowElemCnt = 0;
  int nMinLowElem = cnrvnSeq[0] + 1;

  for (int i = 0; i < cnrvnSeq.size(); i++)
    if (cnrvnSeq[i] < nMinLowElem)
    {
      nLowElemCnt++;
      nMinLowElem = cnrvnSeq[i];
    }

  return nLowElemCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowElemCnt(vnSeq) << endl;

  return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
ans = N
a = ans // K
b = ans % K

if a > 0:
    ans = N - K * a
    a = ans // K
    b = ans % K

if a  == 0:
    if ans > abs(ans - K):
        print(abs(ans - K))
    else:
        print(ans)

Measured memory_bytes: 9180
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

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

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 3010;
ld a[mxn];
int n;
ld dp[mxn][mxn];
// map<ld,ii> dp;

ld solve(int i, int tails, int heads, ld val){
	if((tails+heads==n) and heads > tails){
		return val*1.0;
	}
	if(i>=n) return 0.0;
	ld &ans  = dp[tails][heads];
	if(ans!=-1.0) return ans; 
	ans = 0.0;
	ans = solve(i+1,tails+1,heads,1.0*val*(1-a[i])) + solve(i+1,tails,heads+1,1.0*val*a[i]);
	// cout << val*(1-a[i]) << " " << val*a[i] << endl;
	cout << ans << endl;
	return ans;
}

int32_t main(){
	NINJA;
	// fo(i,mxn) fo(j,mxn) dp[i][j]=-1.0;
	cin >> n;
	fo(i,n) cin >> a[i];
	// cout << fixed << setprecision(12) << solve(0,0,0,1.0) << endl;
	dp[0][0] = 1-a[0];
	dp[0][1] = a[0];
	for1(i,n-1){
		fo(j,mxn){
			dp[i][j] += (1-a[i])*dp[i-1][j];
			if(j>0) dp[i][j] += (a[i]*dp[i-1][j-1]); 
		}
	}
	ld ans = 0;
	for(int i=n/2+1;i<mxn;i++){
		ans += dp[n-1][i];
	}
	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[120][10200] = {};
int main() {
	int N;
	cin >> N;
	int maxa = 0;
	int mina = 1000000;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		mina = min(mina, a);
		maxa = max(maxa, a);
	}
	cout << maxa - mina;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#define maxn 50
using namespace std;
int main(){
	long long x, y;
	cin >> x >> y;
	if(x < y)
		swap(x, y);
	if(x - y <= 1)
		printf("Brown\n");
	else
		printf("Alice\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n + 1];
		Arrays.fill(a, n + 1);
		int idx, b, cnt = 0;
		for(int i = 0; i < m; i++) {
			idx = sc.nextInt();
			b = sc.nextInt();
			if(a[idx] > b) a[idx] = b;
		}
		for(int i = 1; i <= n; i++) {
			if(a[i] <= n) {
				BreakBridge(a, i, a[i], n + 1);
				cnt++;
			}
		}
		System.out.println(cnt);
	}
	static void BreakBridge(int[] a, int l, int r, int max){
		for(int i = l + 1; i < r; i++) {
			if(a[i] < max) {
				BreakBridge(a, i, Math.min(a[i], r), max);
				break;
			}
		}
		a[l] = max;
	}
}


Measured memory_bytes: 67096
n = int(input())
flag = 0
buf = input()
last = buf[-1]
S = {buf}

for i in range(n-1):
	buf = input()
	if(buf[0] != last or buf in S):
		flag = 1
	S.add(buf)
	last = buf[-1]
	
if(flag == 0):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ri() - 1
	}

	// fmt.Println(a)

	ans := 0
	for i, aa := range a {
		if a[aa] == i {
			ans++
		}
	}
	fmt.Println(ans / 2)
}


Measured memory_bytes: 1408
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 2e5 + 5;

int n, k;
int arr[N], tmp[N], acc[N];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  for(int it = 0; it < k; it++) {
    for(int i = 0; i < n; i++) {
      int l = max(0, i - arr[i]);
      int r = min(n - 1, i + arr[i]);
      acc[l]++;
      acc[r + 1]--;
    }
    for(int i = 1; i < n; i++) {
      acc[i] += acc[i - 1];
    }
    bool same = true;
    for(int i = 0; i < n; i++)
      same &= acc[i] == arr[i];
    if(same) break;
    for(int i = 0; i < n; i++) {
      arr[i] = acc[i];
      acc[i] = 0;
    }
  }
  for(int i = 0; i < n; i++)
    cout << arr[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 5188
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int a[200000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n;
	//*
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &a[i]);
	}
	/*/
	n = 2e5;
	REP(i, n) {
		a[i] = i;
	}
	FOR(i, 1e5, n)a[i] = 1e5;
	//*/
	REP(i, n) {
		if (a[i] > i) {
			puts("-1");
			return 0;
		}
		if (i > 0) {
			if (a[i] > a[i - 1] + 1) {
				puts("-1");
				return 0;
			}
		}
	}
	ll cnt=0;
	REP(i, n) {
		if (i == 0)continue;
		if (a[i] <= a[i - 1]) {
			cnt += a[i - 1];
		}
		if (i == n - 1) {
			cnt += a[i];
		}
	}
	PRINTL(cnt);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q; cin >> n >> q;
  vector<int> line(n),from_list(n),vec,ans(q);
  for(auto&e:line)cin >> e;
  map<int,int> mp;
  for(int i = 0; i < n; ++i){
    if(mp.count(line[i]) == 0) from_list[i] = -1;
    else from_list[i] = mp[line[i]];
    mp[line[i]] = i;
  }
  vector<pair<int,int>> queries(q);
  for(auto&e:queries){cin >> e.first >> e.second;--e.first;--e.second;}
  static vector<pair<int,int>> r_base[500000];
  for(int i = 0; i < q; ++i)
    r_base[queries[i].second].emplace_back(queries[i].first,i);
  for(int i = 0; i < n; ++i){
    auto it = lower_bound(vec.begin(),vec.end(),from_list[i]);
    if(it == vec.end() || *it != from_list[i])vec.insert(it,from_list[i]);
    for(auto e:r_base[i])
      ans[e.second] = i-e.first+1-(vec.end()-lower_bound(vec.begin(),vec.end(),e.first));
  }
  for(auto e:ans)cout << e << endl;
}

Measured memory_bytes: 58672
S= str(input())
#N,K = map(int,input().split())
#N = int(input())
#V = list(map(int,input().split()))
C=[]
c=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='T' or S[i]=='C' or S[i]=='G':
        c+=1
    else:
        C.append(c)
        c=0
C.append(c)
print(max(C))


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

static const int N = 100;

int main(){
  int n,p[N+1],m[N+1][N+1];
  
  cin >> n;
  
  for(int i=1;i<=n;i++){
    cin >>p[i-1] >> p[i];
  }

  for(int i=1;i<=n;i++) m[i][i]=0;

  for(int j=2;j<=n;j++){
    for(int i=1;i<= n-j+1;i++){
      int l = i+j-1;
      m[i][l]=(1 << 21);
      for(int k=i;k<= l-1;k++){
	m[i][l]=min(m[i][l],m[i][k]+m[k+1][l]+p[i-1]*p[k]*p[l]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}



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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll x; cin>>x;
    for(int i=1;i<=1000;i++){
        if(100*i<=x && x<=105*i){
            cout<<1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    string s = "ACL";

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cout<<s;


    return 0;
}


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

def ceil(a, b):
    return (a + b - 1) // b

n, k = inm()
a = inl()
start = a.index(1)
ans = 10**9
for i in range(max(0, start-k+1), min(n-1, start+k)):
    ans = min(ans, ceil(i, k-1) + ceil(n-i-1, k-1))
print(ans)

Measured memory_bytes: 20716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
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...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);

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

    for (int i = 1; i < n - 1; i++)
    {
        if ((a[i] > a[i - 1] && a[i] < a[i + 1]) || (a[i] < a[i - 1] && a[i] > a[i + 1]))
            ans++;
    }    cout << ans << '\n';



}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
//   cin >> t;
    while (t--)
        solve();
    return 0;
}




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

using namespace std;

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;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    for (int i = 0; i < q; i++){
        cin >> key;
        if (search(A, n, key)) sum++;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
using namespace std;
long m=1e9+7,n;
long fac[1<<20],inv[1<<20];
long p(long a,long b){return b?p(a*a%m,b/2)*(b%2?a:1)%m:1;}
long c(int a,int b){return fac[a]*inv[b]%m*inv[a-b]%m;}
main()
{
	cin>>n;
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%m;
	inv[n]=p(fac[n],m-2);
	for(int i=n;i--;)inv[i]=inv[i+1]*(i+1)%m;
	long ans=fac[n];
	for(int k=(n+1)/2;k<n;k++)
	{
		ans=(ans-c(k-1,n-k-1)*fac[k]%m*fac[n-k-1]%m+m)%m;
	}
	cout<<ans<<endl;
}

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

const int N = 100000 + 10;
 
int a[N];

int main() {
    int n , k ;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[n];
    }
    cout << (n  + k - 3) / (k - 1);
    return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	double W,H,x,y;
  cin >> W >> H >> x >> y;
  printf("%.11f %d", W * H / 2,(x*2 == W) && (y * 2 == H));
return 0;
}

Measured memory_bytes: 3772
S = list(input())
S.append("?")
for i in range(len(S) - 2):
    if S[i] == S[i + 1]:
        print(i + 1, i + 2)
        exit()
    elif len(set(S[i:i + 3])) <= 2:
        print(i + 1, i + 3)
        exit()

print("-1 -1")

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define SZ(x) (int)(x.size())
#define pb(x) push_back(x)
#define P pair<int,int>
using namespace std;
const int M = 210000;
const ll inf = 9e18;
int n,m,k;
int a[M]={0};
const int mod = 1e9+7;
void solve() {
    cin >> n;
    ll sum = 0;
    fo(i,1,n) {
        cin >> a[i];
        sum = (sum + 1ll * a[i] * a[i-1] % mod) % mod;
        a[i] = (a[i] + a[i-1]) % mod;
    }
    cout << sum << endl;
}
int main()
{ 
    int t;
    //cin >> t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4460
def main():
    N, H = (int(i) for i in input().split())
    ab = [[int(i) for i in input().split()] for j in range(N)]
    a_max = -1
    a_max_idx = -1
    b_max = -1
    for i,v in enumerate(ab):
        b_max = max(b_max,v[1])
        if a_max < v[0]:
            a_max = v[0]
            a_max_idx = i
    b = [val[1] for i,val in enumerate(ab) if val[1] >= a_max]
    b.sort(reverse=True)
    ans = 0
    for throw in b:
        if H <= 0:
            break
        ans += 1
        H -= throw
    if 0 < H:
        from math import ceil
        ans += int(ceil(H/a_max))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 67672
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int i){
  Node b = NIL;
  Node a = root;
  Node c;
  c = malloc(sizeof(struct node));
  c->key = i;
  c->left = NIL;
  c->right = NIL;
  while(a != NIL){
    b = a;
    if(c->key < a->key) a = a->left;
    else a = a->right;
  }
  c->parent = b;
  if(b == NIL) root = c;
  else if(c->key < b->key) b->left = c;
  else b->right = c;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char c[20];
  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    scanf("%s", c);
    if(c[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    else if(c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
}



Measured memory_bytes: 25128
n = input()
s = [0, 0]
while n>0:
	n -= 1
	l = raw_input().split()
	if l[0] == l[1]:
		s[0] += 1
		s[1] += 1
	elif sorted(l) == l:
		s[1] += 3
	else:
		s[0] += 3
print s[0], s[1]
	

Measured memory_bytes: 4212
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

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

	LL ans = 1;
	for (LL i = 1; i <= N; i++) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
#-----

def count_brackets(brackets):
    cnt = 0
    min_cnt = 0
    
    for i in range(len(brackets)):
        if brackets[i] == "(":
            cnt += 1
        else:  # brackets[i] == ")"
            cnt -= 1
            min_cnt = min(min_cnt, cnt)
    
    return cnt, min_cnt


tmp_cnt_plus  = []
tmp_cnt_minus = []

for S in S_list:
    cnt, min_cnt = count_brackets(S)
    
    if cnt == min_cnt == 0:
        continue
    
    if cnt >= 0:
        tmp_cnt_plus.append( (cnt, min_cnt) )
    else:  # cnt < 0
        tmp_cnt_minus.append( (cnt, min_cnt) )


tmp_cnt_plus.sort(key=lambda x: -x[1])
tmp_cnt_minus.sort(key=lambda x: -(x[0]-x[1]) )


sum_bracket = 0
flag = True

for cnt, min_cnt in (tmp_cnt_plus + tmp_cnt_minus):
    if (sum_bracket + min_cnt) < 0:
        flag = False
        break
    
    sum_bracket += cnt


if (sum_bracket == 0) and flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 99580
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  string s,t;
  cin>>s>>t;
  char a;
  a = t.at(t.size()-1);
  if(t == s+a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < S.length() / 2; i++) {
    if (S[i] != S[S.length() - i - 1]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int dp[101][10001];
int main() {
  int n, w;
  cin >> n >> w;
  vector<pair<int, int> > sorted;
  for (int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    sorted.push_back(make_pair(b, a));
  }
  sort(sorted.begin(), sorted.end());
  int ma = 0;
  for (int i=0; i<n; i++){
    int we = sorted[i].first; 
    int va = sorted[i].second; 
    for (int j=0; j<=w; j++){
      if (we > j){
        if (i != 0){
          dp[i][j] = dp[i-1][j];
        }
        continue;
      }
      if (i != 0){
        dp[i][j] = max(dp[i-1][j-we]+va, dp[i-1][j]);
      }else{
        dp[i][j] = va;
      }
      if (dp[i][j] > ma){
        ma = dp[i][j];
      }
    }
  }
  /*for (int i=0; i<n; i++){
    for (int j=0; j<=w; j++){
      cout << dp[i][j] <<" ";
    }
    cout << endl;
  }*/
  cout << ma << endl;
	return 0;
}


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

#define ll long long
#define int ll
#define endl "\n"

signed main () {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector <int> numbers(n);
	//set <int> taken;
	for (int i = 0; i < n; i++) {
		//int x;
		cin >> numbers[i];
		//numbers.emplace_back(x);
	}
	sort(numbers.rbegin(), numbers.rend());
	int ans = 0;
	n = numbers.size();
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (numbers[k] + numbers[j] > numbers[i] and numbers[i] != numbers[j] and numbers[j] != numbers[k]) ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<double> A(N); for(auto& in:A) cin >> in;
    for(int i = 0; i < N;i++){
        res += 1/A[i];
    }
    res = 1/res;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int a[n];
  map <int, int> mp;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }

  int count = 0;
  for(auto p: mp) {
    int f = p.first;
    int s = p.second;
    if(f > s) {
      count += s;
    }
    else if(f < s) {
      count += s - f;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
ll N;
map<ll,ll>mp;
inline ll calc(ll x){
	if(x==1)return 1;
	if(mp[x])return mp[x];
	return calc(x/2)*2+1;
}
int main(){
	scanf("%lld",&N);
	printf("%lld\n",calc(N));
	return 0;
}

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

int main() {
	string s;
	cin>>s;
	deque<char> q;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='B')
		{
			if(!q.empty())
				q.pop_back();
		}
		else
			q.push_back(s[i]);
	}
	while(!q.empty())
	{
		cout<<q.front();
		q.pop_front();
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,i,j,k;
char ch[100];
bool b[300];
bool f(){
	for (int i=n;i>=1;i--) if (ch[i-1]!=123-i) return false;return true;
}
bool ff(int k){
	for (int i=97;i<=122;i++) b[i]=false;for (int i=1;i<=k;i++) b[ch[i-1]]=true;for (int i=ch[k]+1;i<=122;i++) if (!b[i]) return true;return false;
}
int main(){
	scanf("%s",ch);n=strlen(ch);
	if (n!=26){for (i=1;i<=n;i++) b[ch[i-1]]=true;for (i=1;i<=n;i++) printf("%c",ch[i-1]);for (i=97;i<=122;i++) if (!b[i]){printf("%c",i);return 0;}}
	if (f()){printf("%d\n",-1);return 0;}
	for (i=24;i>=0;i--) if (ff(i)){for (j=1;j<=i;j++) printf("%c",ch[j-1]);for (j=ch[i]+1;j<=122;j++) if (!b[j]){printf("%c",j);return 0;}}
}

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

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static void main(String[] args) {
		String s=sc.next();
		int ctn=0;
		for(int i=0;i<s.length()/2;i++) {
			if(s.charAt(i)!=s.charAt(s.length()-i-1)) {
				ctn++;
			}
		}
		p(ctn);
	}
	
	
	
	
}


Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		var t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		Console.WriteLine((t[0] * t[1]) % 2 == 1 ? "Yes" : "No");

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 11092
n = int(input())

i = 1
num = ""
SUM = 0
amari = 1
while not(n == amari == SUM or SUM == n) or num == "":
  amari = n % 2**i
  if amari == SUM % 2**i:
    num += "0"
  else:
    SUM += (-2)**(i-1)
    num += "1"
  i += 1
  #print(amari,SUM)
print(num[::-1])

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

int32_t main() {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m;
	cin >> n >> m;
	int h[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	int ct = 0;
	vector<int> gr[100001];
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		gr[a].push_back(b);
		gr[b].push_back(a);

	}


	for (int i = 1; i <= n; i++) {
		int mx = INT_MIN;
		for (int j = 0; j < gr[i].size(); j++) {
			mx = max(mx, h[gr[i][j]]);
		}
		if (h[i] > mx) ct++;

	}


	cout << ct;

}

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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }else if(b == c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

n = int(input())
num_list = list(map(int, input().split()))
combination = combinations(num_list, 3)
count = 0
for i in combination:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    int a;
    cin >> a;
    if(a%2==0) cout << a << endl;
    else cout << 2*a << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  for(Int i=0;i<n;i++) cout<<s[i]<<t[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-9);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}


int findSign(int x)
{
    if (x == 0)
        return 0;
    return x < 0 ? -1 : 1;
}

pair<int, int> handleFraction(int a, int b)
{
    if (b == 0)
        return {1, 0}; // DO YOU NEED SIGN HERE? In slopes -1, 0 is same as 1, 0
    if (a == 0)
        return {0, 1}; // Does it need findSign(b)?? is sloe {0, -1} same as slope {0, 1}?
    int div = __gcd(abs(a), abs(b));
    a /= div;
    b /= div;
    int sign = findSign(a) * findSign(b);
    return {sign * abs(a), abs(b)};
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    map<pair<int, int>, int> mp;
    rep(i,0,n)
    {
        cin >> v[i].X >> v[i].Y;
        mp[{v[i].X, v[i].Y}] = i;
    }

    int ans = n;
    rep(i1, 0, n)
    {
        rep(j1, 0, n)
        {
            if (i1 == j1)
                continue;
            pair<int, int> s = {v[j1].X - v[i1].X, v[j1].Y - v[i1].Y};
            vector<bool> visit(n);
            int temp = n;
            rep(i2, 0, n)
            {
                if(visit[i2])
                    continue;
                pair<int, int> p = {v[i2].X, v[i2].Y};
                while(true)
                {
                    auto it = mp.find({p.first + s.first, p.second +s.second});
                    if (it == mp.end())
                        break;
                    --temp;
                    visit[it->second] = 1;
                    p.first += s.first;
                    p.second += s.second;
                }
                p = {v[i2].X, v[i2].Y};
                while(true)
                {
                    auto it = mp.find({p.first - s.first, p.second - s.second});
                    if (it == mp.end())
                        break;
                    --temp;
                    visit[it->second] = 1;
                    p.first -= s.first;
                    p.second -= s.second;
                }
            }
            ans = min(ans, temp);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n<10) printf("%d\n",n);
    else if(n<100) printf("9\n");
    else if(n<1000) printf("%d\n",9+n-99);
    else if(n<10000) printf("909\n");
    else if(n<100000) printf("%d\n",909+n-9999);
    else printf("90909\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
using Graph = vector<vector<int>>;
int n, m;
Graph G;

bool visited[1001000];
int dp[1001000];

int dfs(int x) {
  if (dp[x] > 0) return dp[x];
  int mx = 0;
  for (int i = 0; i < G[x].size(); i++) {
    mx = max(mx, dfs(G[x][i]) + 1);
  }
  dp[x] = mx;
  return mx;
}

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

  G.resize(n);

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (dp[i] == 0) ans = max(ans, dfs(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 10988
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int N,Qq,*x,*z,*count,**G;


int dp(int n, int sum)
{
  int temp;
  int a,b,c;
  
  count[n]=sum;
  if(z[n]!=0)
  {
    for(a=0;a<z[n];a++)
    {
      b=G[n][a];
      temp=0;
      for(c=0;c<z[b] && temp==0;c++)
      {
        if(G[b][c]==n)
        {
          G[b][c]=G[b][z[b]-1];
          z[b]--;
          temp=1;
        }
      }

      dp(b,sum+x[b]);
    }
  }

  
  return ;

  
}


int main()
{
  
  int i,j,s,t,k,u;
  scanf("%d %d",&N,&Qq);
  
  G=(int **)malloc(sizeof(int * )*N);
  for(i=0;i<N;i++)
  {
    G[i]=(int *)malloc(sizeof(int )*N);
  }
  z=(int *)malloc(sizeof(int )*N);  
  x=(int *)malloc(sizeof(int )*N);
  count=(int *)malloc(sizeof(int )*N);
  
  
  for(i=0;i<N;i++)
  {
    z[i]=0;
    x[i]=0;
  }

  for(i=0;i<N-1;i++)
  {
    scanf("%d %d",&s,&t);
    s--;
    t--;
    G[s][z[s]]=t;
    G[t][z[t]]=s;
    z[s]++;
    z[t]++;
    
  }
  
    
  for(i=0;i<Qq;i++)
  {
    scanf("%d %d",&s,&t);
    s--;
    x[s]+=t;
  }
  dp(0,x[0]);


  for(j=0;j<N;j++)
  {
    printf("%d ",count[j]);
  }
  
  return 0;
}


Measured memory_bytes: 817664