akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
string s;

bool a[100100];
char res[100100];

void output() {
    for (int i = 0; i < n; i++) cout << res[i];
    cout << endl;
}

bool check() {
    for (int i = 1; i < n; i++) {
        if (a[i] && s[i] == 'o') {
            a[i+1] = a[i-1];
        } else if (a[i] && s[i] == 'x') {
            a[i+1] = !a[i-1];
        } else if (!a[i] && s[i] == 'o') {
            a[i+1] = !a[i-1];
        } else {
            a[i+1] = a[i-1];
        }
    }
    if (a[0] != a[n]) return false;
    if (a[0] && s[0] == 'o' && a[1] != a[n-1]) return false;
    if (a[0] && s[0] == 'x' && a[1] == a[n-1]) return false;
    if (!a[0] && s[0] == 'o' && a[1] == a[n-1]) return false;
    if (!a[0] && s[0] == 'x' && a[1] != a[n-1]) return false;
    
    for (int i = 0; i < n; i++) {
        if (a[i]) res[i] = 'S';
        else res[i] = 'W';
    }

    return true;
}

void solve() {
    a[0] = a[1] = true;
    if (check()) {
        output();
        return;
    }
    a[0] = a[1] = false;
    if (check()) {
        output();
        return;
    }
    a[0] = true; a[1] = false;
    if (check()) {
        output();
        return;
    }
    a[0] = false; a[1] = true;
    if (check()) {
        output();
        return;
    }
    cout << "-1" << endl;
}

void input() {
    cin >> n >> s;
}

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

    input();
    solve();
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=15;
int vis[maxn];
int dig[maxn],cn;
int n,k;
int ans;
int dfs(int sum,int large,int id)
{
    if(id==-1)
    {
        ans=sum;
        return 1;
    }
    for(int i=0;i<10;i++)
    {
        if(vis[i]) continue;
        if(large)
        {
            if(dfs(sum*10+i,large,id-1)) return 1;
        }
        else
        {
            if(i>=dig[id]&&dfs(sum*10+i,i>dig[id],id-1)) return 1;
        }
    }
    return 0;
}
int main()
{
    scanf("%d%d",&n,&k);
    int x;
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&x);
        vis[x]=1;
    }
    int t=n;cn=0;
    while(t)
    {
        dig[cn++]=t%10;
        t/=10;
    }
    if(!dfs(0,0,cn-1))
    {
        ans=0;
        for(int i=1;i<10;i++)
        {
            if(vis[i]==0)
            {
                ans=i;
                break;
            }
        }
        int mnnum=0;
        for(int i=0;i<10;i++)
        {
            if(vis[i]==0)
            {
                mnnum=i;
                break;
            }
        }
        for(int i=1;i<=cn;i++)
        {
            ans=ans*10+mnnum;
        }
    }
    printf("%d\n",ans);
    return 0;
}
 

Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

if b > a:
    at = a + v*t
    bt = b + w*t
    if at >= bt:
        print("YES")
    else:
        print("NO")

elif a > b:
    at = a - v*t
    bt = b - w*t
    if at <= bt:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9196
import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String A = br.readLine();
		long B = Long.parseLong(br.readLine());
		String ans = "1";
		long count = 0;
		for(int i =0; i<A.length(); i++) {
			String sub = A.substring(i,i+1);
			if(A.substring(i,i+1).equals("1")) {
				count++;
			}
		
		
			else if(!sub.equals("1")) {
				ans = sub;
				break;
			}
		}
		if(count>=B) {
			System.out.println("1");
		}
		else {
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 32524
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] idxArr = new int[n + 1];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			arr[i] = a;
			idxArr[a] = i;
		}
		int max = 0;
		int tmp = 0;
		for (int i = 2; i <= n; i++) {
			if (idxArr[i - 1] < idxArr[i]) {
				tmp++;
				if (tmp > max) {
					max = tmp;
				}
			} else {
				tmp = 0;
			}
		}
		System.out.println(n - max - 1);
	}
}


Measured memory_bytes: 78804
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
s = input()

if s.count("R") > s.count("B"):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 6224
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
LL read(){
	LL rtn=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch<='9'&&ch>='0')rtn=(rtn<<3)+(rtn<<1)+ch-'0',ch=getchar();
	return rtn;
}
const int N=300010;
const LL mod=1e9+7;
LL fac[N];
int n,m;
int _abs(int x){
	return x>0?x:-x;
}
int main(){
#ifdef WK
	freopen("in.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	if(_abs(n-m)>1){
		printf("0\n");
		return 0;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
	for(int i=n+1;i<=m;i++)fac[i]=fac[i-1]*i%mod;
	LL ans=fac[n]*fac[m]%mod;
	if(n==m)ans=ans*2%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
N = input()
if N.endswith("2") or N.endswith("4") or N.endswith("5") or N.endswith("7") or N.endswith("9"):
    print("hon")
elif N.endswith("0") or N.endswith("1") or N.endswith("6") or N.endswith("8"):
    print("pon")
else:
    print("bon")


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    int N;
    std::cin >> N;
    string S;
    std::cin >> S;

    vector<int> table(26, 0);
    REP(i, S.size()) {
        table[S[i] - 'a']++;
    }

    ll ans = 1;
    REP(i, 26) {
        ans *= table[i] + 1;
        ans %= MOD;
    }

    std::cout << ans - 1 << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 4
#define MAXH 4
#define MAXM 4
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 100005;

int main(){
	ll n,a[N];
	cin >> n;
	fu(i,1,n)cin >> a[i];
	fu(i,1,n)a[i] += a[i-1];
	ll ans = INF;
	// pos
	bool pos = 1;
	fu(j,0,1){
		pos = j;
		ll del = 0;
		ll tans = 0;
		fu(i,1,n){
			whatis(a[i] + del);
			whatis(pos);
			if(pos && a[i] + del <= 0){
				tans += 1 - a[i] - del;
				del += 1 - a[i] - del;
			}
			if(!pos && a[i] + del >= 0){
				tans += a[i] + del + 1;
				del -= a[i] + del + 1;
			}
			pos = !pos;
		}
		whatis(tans);
		ans = min(ans, tans);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 1024
# N:SW M:電球

N, M = map(int, input().split())
SW = [[] for _ in range(M)]

for i in range(M):
  SW[i] = [int(s)-1 for s in input().split()[1:]]

P = list(map(int, input().split()))

ans = 0
for bit in range(1<<N): #SW: on, off
  ok = True
  for i in range(M):
    con = 0
    for sw in SW[i]: # 1つずつ
      if bit & (1<<sw):
        con += 1
    if con%2 != P[i]:
      ok = False
  if ok:
    ans += 1
print(ans)    
      
      


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int h,w,i,j;

  for (;;){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0){
	    break;
          }
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
        if(i == 0 || i == h-1 || j == 0 || j == w-1){
          printf("#");
        }
        else{
	  printf(".");
        }
      }
      printf("\n");
      
    }
      printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
#include<math.h>

int main(){
    int N;
    int h[110000];
    int dp[110000];
    int i,j,k;
    int dpa, dpb;

    for(i=0; i<N; i++){
        dp[i] = -100000;
    }

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &h[i]);
    }

    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    for(i=2; i<N; i++){
        dpa = dp[i-1] + abs(h[i] - h[i-1]);
        dpb = dp[i-2] + abs(h[i] - h[i-2]);
        if(dpa<dpb){
            dp[i] = dpa;
        }else{
            dp[i] = dpb;
        }
    }

    printf("%d", dp[N-1]);

    return 0;
}

Measured memory_bytes: 896
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static int solve(int x) {
    if (x <= 599) return 8;
    if (x <= 799) return 7;
    if (x <= 999) return 6;
    if (x <= 1199) return 5;
    if (x <= 1399) return 4;
    if (x <= 1599) return 3;
    if (x <= 1799) return 2;
    if (x <= 1999) return 1;
    return 0;
}

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

    cout << solve(x) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int n, x[110], ans = INF, ss;

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &x[i]);
	for(int i = 1; i <= 100; i++){
		ss = 0;
		for(int j = 1; j <= n; j++)
			ss += (x[j] - i) * (x[j] - i);
		ans > ss ? ans = ss : 0;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        new Main().run();
    }
 
    private void run() throws NumberFormatException, IOException {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n; i++) {
            int v = scanner.nextInt();
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            nodes[v].l = l;
            nodes[v].r = r;
            if (l != -1)
                nodes[l].p = v;
            if (r != -1)
                nodes[r].p = v;
        }
 
        int root = 0;
        for (int i = 0; i < n; i++) {
            if (nodes[i].p == -1) {
                root = i;
            }
        }
        System.out.println("Preorder");
        preParse(root, nodes);
        System.out.println();
        System.out.println("Inorder");
        inParse(root, nodes);
        System.out.println();
        System.out.println("Postorder");
        postParse(root, nodes);
        System.out.println();
    }
 
    private void postParse(int u, Node[] nodes) {
        if (u == -1)
            return;
        postParse(nodes[u].l, nodes);
        postParse(nodes[u].r, nodes);
        System.out.print(" " + u);
    }
 
    private void inParse(int u, Node[] nodes) {
        if (u == -1)
            return;
        inParse(nodes[u].l, nodes);
        System.out.print(" " + u);
        inParse(nodes[u].r, nodes);
    }
 
    private void preParse(int u, Node[] nodes) {
        if (u == -1)
            return;
        System.out.print(" " + u);
        preParse(nodes[u].l, nodes);
        preParse(nodes[u].r, nodes);
    }
 
    class Node {
        int p = -1, l, r;
    }
}

Measured memory_bytes: 26244
package main

import(
	"fmt"
)

func max(a,b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func main() {
	//入力された文字列を受け取る
	var s string
	fmt.Scan(&s)

	//文字数カウント用変数を用意、初期化
	var tmp,cnt int
	cnt = -1
	for i:=0; i<len(s); i++ {
		//もしACGT文字列なら
		if s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G' {
			//カウントする
			tmp++
		} else {
			//カウントを初期化する
			tmp = 0
		}
		//暫定の最大(cnt)と今のカウント(tmp)を比較
		cnt = max(cnt,tmp)
	}
	
	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("Yes\n")
#define NO() printf("No\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int mi = INF;
	string s;
	cin >> s;
	for(int i = 0;i < 26;i++){
		string t = s;
		while(1){
			char c = t[0];
			bool flag = true;
			for(int j = 0;j < t.length();j++) if(t[j] != c) flag = false;
			if(flag){
				mi = min(mi,(int)s.length() - (int)t.length());
				break;
			}
			string next;
			for(int j = 0;j < t.length() - 1;j++){
				if(t[j] == i + 'a' || t[j + 1] == i + 'a') next += (char)(i + 'a');
				else next += t[j];
			}
			t = next;
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int x, y;
  scanf("%X%X", &x, &y);
  puts(x < y ? "<" : x > y ? ">" : "=");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  vector<string> s(3);
  for(ll i=0;i<3;i++) {
    cin >> s[i];
  }
  cout << "A" << s[1][0] << "C" << endl; 
}

Measured memory_bytes: 256
from bisect import bisect_right as br
INF = 10 ** 10
n = int(input())
alst = [int(input()) for _ in range(n)][::-1]
dp = [INF] * (n + 1)
dp[0] = -1
ans = 0
for a in alst:
  ind = br(dp, a)
  dp[ind] = a
  ans = max(ans, ind)
print(ans)

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

using namespace std;

char a[10][10];

int main(){
	for(int i=1;i<=2;i++)
	for(int j=1;j<=3;j++)
	cin>>a[i][j];
	
	if(a[1][1]!=a[2][3])
	{
		cout<<"NO";
		return 0;
	}
	if(a[1][2]!=a[2][2])
	{
		cout<<"NO";
		return 0;
	}
	if(a[1][3]!=a[2][1])
	{
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
require 'set'

N = gets.strip.to_i
S = gets.strip

max_val = 0
for i in 0..N-2 do
    x = S[0..i]
    y = S[i+1..N]
    curr_val = (Set.new(x.split('')) & Set.new(y.split(''))).size
    if max_val < curr_val then
        max_val = curr_val
    end
end

p max_val

Measured memory_bytes: 2300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Anirudh Rayabharam (mail@anirudhrb.com)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Adjacent4 solver = new Adjacent4();
        solver.solve(1, in, out);
        out.close();
    }

    static class Adjacent4 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int f, o, e;
            f = o = e = 0;
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                if (a % 2 == 1) ++o;
                else if (a % 4 == 0) ++f;
                else ++e;
            }
            if (o <= f || (e == 0 && o == f + 1)) out.println("Yes");
            else out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 35736
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 4;

int main() {
	int q;
	scanf("%d", &q);
	while(q--) {
		LL a, b;
		scanf("%lld %lld", &a, &b);
		LL pro = a * b;
		LL sq = sqrt(pro);
		LL ans = sq * 2;
		if(sq * sq == pro) ans -= 2;
		if((pro - 1) / sq == sq) ans--;
		if(a != b || b != sq) ans--;
		printf("%lld\n", ans);
	}
	return 0;
}

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

#define MAX_V 10000

int V, E, Q;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++) {
    if(!used[G[v][i]]) dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for(int i = 0; i < rG[v].size(); i++) {
    if(!used[rG[v][i]]) rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for(int v = 0; v < V; v++) {
    if(!used[v]) dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1; i>= 0; i--) {
    if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    add_edge(s, t);
  }

  scc();

  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int u, v;
    cin >> u >> v;
    if(cmp[u] == cmp[v]) cout << 1 << endl;
    else cout << 0 << endl;
  }

}

Measured memory_bytes: 2784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	map<ll, ll> mp;
	rep(i,n) {
		ll a;
		cin >> a;
		mp[a]++;
	}
	ll ans = 0;
	for (auto p: mp) {
		ll a = p.first;
		ll cnt = p.second;
		if (cnt < a) ans += cnt;
		else ans += (cnt - a);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 9544
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 1e9+5
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
   vector<int> dp(n,inf);
  dp[0]=0;
  for(int i=0;i<n;i++){
     for(int j:{i+1,i+2}){
         if(j<n){
             dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
         }
     }
  }
  cout<<dp[n-1];
}



Measured memory_bytes: 1024
/**************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

***************************/

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAXI 1000000007
#define mp make_pair
using namespace std;
int gcd(int p,int q){
    if(p%q==0)return q;
    return gcd(q,p%q);
}
int main()
{   ll v=0,h=0,d,m,n,cnt=0,j=0,l=0,y=0,t,k=0,sum=1,x=0,i,mask,min,r=1,adv,g=0,low,high,yeah=0;
    string s1,s2,s3;
    map<char,long long int>mp;
    vector<long long int> v1;
    vector<long long int> v2;
    set<char> sy;
    char c;
    long long pos=0,pred=0;
    long long MAX=1e9+7;
    cin>>k;
    for(i=1;i<=k;i++){
        for(j=1;j<=k;j++){
            r=gcd(i,j);
            for(l=1;l<=k;l++){t=gcd(r,l);cnt+=t;}
    }
}
    cout<<cnt;
     return 0;   
    
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m,r;
    cin>>n>>m>>r;
    int mati[r];
    for(int i=0;i<r;i++){
        cin>>mati[i];
        mati[i]--;
    }
    int a,b,c[n][n]={};
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if(i!=j) c[i][j]=1e9;
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        cin>>c[a][b];
        c[b][a]=c[a][b];
    }
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    }
    int ans=1e9;
    sort(mati,mati+r);
    while(next_permutation(mati,mati+r)){
        int ret=0;
        for(int i=0;i<r-1;i++){
            ret+=c[mati[i]][mati[i+1]];
        }
        ans=min(ans,ret);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 101

int matrixChainMultiplication(int, int *);
int min(int, int);

int main(){
  int n,p[MAX],i;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf(" %d %d",&p[i],&p[i+1]);
  }
  printf("%d\n",matrixChainMultiplication(n,p));
  return 0;
}

int matrixChainMultiplication(int n, int *p){
  int m[MAX][MAX],i,j,k,l;

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

int min(int a, int b){
  if(a < b) return a;
  else return b;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  REP(i,0,n-1) {
    cin>>s[i];
  }
  sort(all(s));
  REP(i,0,n-1) {
    cout<<s[i];
  }
}
int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3580
<?php
$input_line = trim(fgets(STDIN));
$a = '';

if ($input_line >= 400 && $input_line <= 599) {
  $a = 8;
} else if ($input_line >= 600 && $input_line <= 799) {
   $a = 7;
}else if ($input_line >= 800 && $input_line <= 999) {
   $a = 6;
}else if ($input_line >= 1000 && $input_line <= 1199) {
   $a = 5;
}else if ($input_line >= 1200 && $input_line <= 1399) {
   $a = 4;
}else if ($input_line >= 1400 && $input_line <= 1599) {
   $a = 3;
}else if ($input_line >= 1600 && $input_line <= 1799) {
   $a = 2;
}else if ($input_line >= 1800 && $input_line <= 1999) {
   $a = 1;
}

echo $a;
?>

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

#define inf 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

template< typename T >
struct FordFulkerson {

	struct FlowEdge {
		int to;
		T cap,rev;
		FlowEdge() {}
		FlowEdge(int to,T cap,T rev):to(to),cap(cap),rev(rev) {}
	};

	vector< vector<FlowEdge> > G;
	vector<int> used;

	FordFulkerson() {}
	FordFulkerson(int n) {
		G.resize(n);
		used.resize(n);
	}

	void add_edge(int from,int to,T cap) {
		G[from].emplace_back(to,cap,(int)G[to].size());
		G[to].emplace_back(from,0,(int)G[from].size()-1);
	}

	T dfs(int v,const int t,T flow) {
		if(v==t) return flow;
		used[v]=1;
		for(auto &e:G[v]) {
				if(!used[e.to]&&e.cap>0) {
				T d=dfs(e.to,t,min(flow,e.cap));
				if(d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}

	T max_flow(int s,int t,T lim) {
		T flow=0;
		while(true) {
			fill(ALL(used),false);
			T d=dfs(s,t,inf);
			if(d==0) return flow;
			flow+=d;
		}
		return flow;
	}

	T max_flow(int s,int t) {
		return max_flow(s,t,inf);
	}
};

int h,w;
string fld;
bool E[100][100];
P S,T;

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

	cin>>h>>w;
	FordFulkerson<ll> F(h+w+2);
	REP(i,h) {
		cin>>fld;
		REP(j,w) {
			if(fld[j]=='S') {
				F.add_edge(h+w,i+w,inf);
				F.add_edge(h+w,j,inf);
				S=P(i,j);
				E[i][j]=true;
			}
			else if(fld[j]=='T') {
				F.add_edge(i+w,h+w+1,inf);
				F.add_edge(j,h+w+1,inf);
				T=P(i,j);
				E[i][j]=true;
			}
			else if(fld[j]=='o') {
				E[i][j]=true;
			}
		}
	}
	REP(i,h) {
		REP(j,w) {
			if(E[i][j]) {
				F.add_edge(i+w,j,1);
				F.add_edge(j,i+w,1);
			}
		}
	}
	if(S.fi==T.fi||S.se==T.se) {
		cout<<-1<<endl;
		return 0;
	}
	cout<<F.max_flow(h+w,h+w+1)<<endl;

	return 0;
}


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

using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit); cout.tie(0);
typedef vector<int> vi;
typedef long long ll;
main(){
    FASTIO;
    ll N, W;
    cin >> N >> W;
    vector<ll> dp(123456, inf);
    dp[0] = 0;
    for (ll i = 0; i < N; ++i){
        ll w, v;
        cin >> w >> v;
        
        for (ll valor = 123456 - v - 1; valor >= 0; valor--){
            dp[valor + v] = min(dp[valor + v], w + dp[valor]);
        }
        dp[v] = min(dp[v], (ll)w);
    }
    for (int i = 123455; i > -1; --i){
        if (dp[i] <= W){
            cout << i << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 1280
use proconio::input;
fn main() {
    input!(n: usize);
    let mut v = Vec::new();
    let mut w = Vec::new();
    for _ in 0..n {
        input!(a: usize, b: usize);
        v.push(a);
        w.push(b);
    }

    v.sort();
    w.sort();

    let mut vv = Vec::new();
    for i in 0..n {
        vv.push((v[i], w[i]));
    }

    let ans = if n % 2 == 0 {
        let (a, b) = vv[n / 2 - 1];
        let (c, d) = vv[n / 2];
        (b + d) - (a + c) + 1
    } else {
        let (a, b) = vv[(n - 1) / 2];
        b - a + 1
    };

    println!("{}", ans);
}


Measured memory_bytes: 12840
n = int(input())
S = list(input())
q = int(input())

import sys
input = sys.stdin.readline

alp = "abcdefghijklmnopqrstuvwxyz"
appr = {a:[] for a in alp}

import bisect

for i, a in enumerate(S):
  appr[a].append(i+1)
#print(appr)
for i in range(q):
  inputs = input().split()
  if inputs[0] == '1':
    c = int(inputs[1])
    a = inputs[2]
    if S[c-1]==a:
      continue
    else:
      old = S[c-1]
      S[c-1] = a
      del_idx = bisect.bisect_left(appr[old], c)
      del appr[old][del_idx]
      in_idx = bisect.bisect_left(appr[a], c)
      appr[a].insert(in_idx, c)
  else:
    l, r = map(int, inputs[1:])
    res = 0
    for a in appr:
      l_idx = bisect.bisect_left(appr[a], l)
      if l_idx<len(appr[a]):
        if appr[a][l_idx]<=r:
          res += 1
    print(res)
    
#print(appr)

Measured memory_bytes: 29192
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let s: Vec<bool> = sc.cin::<String>().chars().map(|c| c == '1').collect();

    let mut g: Vec<usize> = vec![];
    if !s[0] { g.push(0) };
    {
        let mut last = s[0];
        let mut ac = 1;
        for i in 1..n {
            if last == s[i] {
                ac += 1;
            } else {
                g.push(ac);
                last = s[i];
                ac = 1;
            }
        }
        if ac > 0 {
            g.push(ac);
        }
    }

    // trace!(&s);
    // trace!(&g);

    let mut ans = 0;

    let mut x = 0;
    let mut p = 0;
    for i in 0..g.len() {
        if i % 2 == 0 {
            // trace!("add1", g[i]);
            x += g[i];
        } else {
            if p >= k {
                // trace!(g[i], g[i-1-2*k], g[i+0-2*k]);
                x += g[i];
                x -= g[i-1-2*k];
                x -= g[i+0-2*k];
            } else {
                // trace!("add0", g[i]);
                x += g[i];
                p += 1;
            }
        }
        // trace!(x);
        ans = max(ans, x);
    }
    put!(ans);

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

int main() {
  string S;
  cin >> S;
  
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'o') count++;
  }
  
  cout << 700 + 100 * count << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    map<char,ll> mp;
    ll n; cin >> n;
    rep(i,n){
        char c; cin >> c;
        mp[c]++;
    }
    if(mp.size()==3) puts("Three");
    else puts("Four");
}

Measured memory_bytes: 384
#include <iostream>                                                  
#include <cstdio>                                                                                                        
using namespace std;                                                 
                                                                     
int main() {                                                         
  char ch;                                                           
  while (true) {                                                     
    scanf("%c", &ch);                                                
    if (islower(ch)) {                                               
      ch = toupper(ch);                                              
    } else if (isupper(ch)) {                                        
      ch = tolower(ch);                                              
    }                                                                
    cout << ch << flush;                                             
    if (ch=='\n') {                                                  
      break;                                                         
    }                                                                
  }                                                                  
  return 0;                                                          
}                                                                    
                             

Measured memory_bytes: 3152
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
	static int X;
	static int Y;
	static int N;
	
	static HashMap<Integer,Integer> BK;
	
	static int[][] S;
	
	static boolean NA;
	static boolean OK;
	
	static int[][] now;
	static int[][] ans;
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			X = sc.nextInt();
			Y = sc.nextInt();
			N = sc.nextInt();
			if(X == 0 && Y == 0 && N == 0) break;
			BK = new HashMap<Integer,Integer>();
			for(int i = 0; i < N; i++) {
				BK.put(sc.nextInt(), sc.nextInt());
			}
			S = new int[Y][X];
			NA = false;
			OK = false;
			now = new int[Y][X];
			ans = new int[Y][X];
			for(int i = 0; i < Y; i++) {
				for(int j = 0; j < X; j++) {
					S[i][j] = sc.nextInt();
				}
			}
			solv(0,0);
			if(NA || !OK) {
				System.out.println("NA");
				continue;
			}
			for(int i = 0; i < Y; i++ ) {
				System.out.print(ans[i][0]);
				for(int j = 1; j < X; j++) {
					System.out.print(" " + ans[i][j]);
				}
				System.out.println();
			}
		}
	}
	static void solv(int y, int x) {
		if(NA) {
			return;
		}
		if(x == X) {
			solv(y+1,0);
			return;
		}
		if(y == Y) {
			if(OK) {
				NA = true;
				OK = false;
				return;
			}
			if(!OK && !NA) {
				OK = true;
				for(int i = 0; i < Y; i++) {
					ans[i] = Arrays.copyOf(now[i], now[i].length);
				}
				return;
			}
			return;
		}
		if(S[y][x] == 0) {
			solv(y,x+1);
			return;
		}
		for(int i = 1; i <= BK.get(S[y][x]); i++) {
			if(BK.get(S[y][x]) % i != 0) continue;
			for(int j = -(BK.get(S[y][x])/i)+1; j <= 0; j++) { //???????????? x
				IN:for(int k = -i + 1; k <= 0; k++) { //???????????? y
					for(int l = 0; l < i; l++) {
						for(int m = 0; m < BK.get(S[y][x]) / i; m++) {
							int tox = m + j + x;
							int toy = l + k + y;
							if(tox < 0 || toy < 0 || tox >= X || toy >= Y) continue IN;
							if(now[toy][tox] != 0 || (S[toy][tox] != S[y][x] && S[toy][tox] != 0)) continue IN;
						}
					}
					for(int l = 0; l < i; l++) {
						for(int m = 0; m < BK.get(S[y][x]) / i; m++) {
							int tox = m + j + x;
							int toy = l + k + y;
							now[toy][tox] = S[y][x];
						}
					}
					solv(y,x+1);
					for(int l = 0; l < i; l++) {
						for(int m = 0; m < BK.get(S[y][x]) / i; m++) {
							int tox = m + j + x;
							int toy = l + k + y;
							now[toy][tox] = 0;
						}
					}

				}
			}
		}

	}
	
}

Measured memory_bytes: 32720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    int n;
    cin >> n;
    int x[n],y[n];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            double tmp = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            ans += tmp;
        }
    }
    int mul = 2;
    for(int i = 1; i <= n-1; i++){
        mul *= i;
    }
    int div = 1;
    for(int i = 1; i <= n; i++){
        div *= i;
    }
    printf("%.10lf",ans * mul / div);
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  
  int x,y;
  
  char c[2];
  
  fgets(c,sizeof(c),stdin);
  sscanf(c,"%d",&x);
  
  y=x*x;
  x=y*x;
  
  printf("%d",x);
  
  
  
  return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;

int gcd(int x,int y){
    if(y == 0) return x;
    return gcd(y,x%y);
}

signed main() {
  int N, K, A;
  cin >> N >> K;

  int M = 0, G;
  REP(i, N){
    cin >> A;
    M = max(M, A);
    if(i == 0) G = A;
    else G = gcd(G, A);
  }

  if(K%G == 0 && K <= M) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>

class AHarmony {
public:
    void solve(std::istream &in, std::ostream &out) {
        long long a, b;
        in >> a >> b;

        if (a % 2 != b % 2) {
            out << "IMPOSSIBLE\n";
            return;
        }

        out << (a + b) / 2;
    }
};


int main() {
    AHarmony solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAXN 100015

int a[MAXN],sum[MAXN];

int _find(int l,int r,int k){

    int mid,i;
    if(a[l]+a[l-1]==0)i=sum[l-1]-1;
    else i=sum[l-1];
    while(l<=r){
        mid=l+r>>1;
        if(sum[mid]-i<=k)l=mid+1;
        else r=mid-1;
    }
    return r;
}

int main(){

    int i,n,k,j,ans=0;
    scanf("%d%d",&n,&k);
    a[0]=-1;
    for(i=1;i<=n;i++){
        scanf("%1d",&a[i]);
        sum[i]=sum[i-1];
        if(a[i]==0&&a[i-1]!=0)sum[i]++;
    }
    for(i=1;i<=n;i++){
        j=_find(i,n,k);
        ans=j-i+1>ans?j-i+1:ans;
        //printf("%d %d\n",i,j);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 896
s = input()
n = len(s)
ans = [0]*n
tmp = []
point = "R"
count = 1
for i in range(1,n):
    if s[i] == point:
        count +=1
    else:
        point = s[i]
        tmp.append(count)
        count=1
else:
    point = s[i]
    tmp.append(count)
    count=1
counter = 0
for x,i in enumerate(tmp):
    counter += i
    if x%2:
        pass
        ans[counter-i] += -(-i//2)
        ans[counter-i-1] += i//2
    else:
        ans[counter] += i//2
        ans[counter-1] += -(-i//2)
print(" ".join(map(str,ans)))

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

void print_vec(std::vector<bool> &v)
{
    for (auto i = v.begin(); i != v.end(); i++)
    {
        cout << *i << " ";
    }
    cout << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> v(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> v[i][j];
        }
    }
    vector<bool> ho(h, false), vi(w, false);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (v[i][j] == '#')
            {
                ho[i] = true;
            }
        }
    }
    for (int i = 0; i < w; i++)
    {
        for (int j = 0; j < h; j++)
        {
            if (v[j][i] == '#')
            {
                vi[i] = true;
            }
        }
    }
    //     for (int i = 0; i < h; i++)
    // {
    //     for (int j = 0; j < w; j++)
    //     {
    //         {
    //             cout << v[i][j];
    //         }
    //     }
    //     cout << endl;
    // }
    bool check;
    for (int i = 0; i < h; i++)
    {
        check = false;
        for (int j = 0; j < w; j++)
        {
            if (ho[i] && vi[j])
            {
                check = true;
                cout << v[i][j];
            }
        }
        if (check)
        cout << endl;
    }
    return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    set <int> a ;

    for (int i = 0 ; i < 3 ; i ++)
    {
        int x ;
        cin >> x ;
        a . insert (x) ;
    }
    if (a . size() == 2)

    cout << "Yes";
    else
        cout << "No";



    return 0;
}



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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

const int N = 200005;

ll n, k;
ll arr[N];

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> arr[i];
    for(int i = 1; i < n; i++) arr[i] += arr[i-1];
    for(int i = 0; i < n; i++) arr[i] -= (i+1)*k;
}

vector<int> tmp;
ll dc(int l, int r)
{
    if(l == r) return (arr[l] >= 0? 1 : 0);
    int mid = (l+r)/2;
    ll res = dc(l, mid) + dc(mid+1, r);
    tmp.clear();
    int i = l, j = mid+1;
    while(i <= mid && j <= r)
    {
        if(arr[i] <= arr[j]) res += r-j+1, tmp.push_back(arr[i++]);
        else tmp.push_back(arr[j++]);
    }
    while(i <= mid) tmp.push_back(arr[i++]);
    while(j <= r) tmp.push_back(arr[j++]);
    for(i = l, j = 0; i <= r; i++, j++) arr[i] = tmp[j];
    return res;
}

void process()
{
    cout << dc(0, n-1) << endl;
}



Measured memory_bytes: 4980