akhauriyash/Code-Regression huggingface dataset:
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

ll global_x = 0;
bool tmp_comp(const ll & p1, const ll & p2)
{
	ll delta_1 = abs(global_x - p1);
	ll delta_2 = abs(global_x - p2);
	return delta_1 < delta_2;
}

// main function
int main()
{
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll ans = 0;

	cin >> A >> B >> C;

	ll num = B / A;
	ans = min(num, C);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System.Linq;
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var m = int.Parse(line[0]);
        var ans = 0;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            ans = Max(ans, line.Count(x => x == "1"));
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 18268
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()

def n_base(n,k):
    if n==0:
        return 0
    else:
        bi=''
        while n!=0:
            bi+=str(n%abs(k))
            if k<0:n=-(-n//k)
            else:n=n//k
        return bi[::-1]

print(n_base(N,-2))

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

#define mod 1000000007
#define ll long long

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

    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll cnt;
    ll ans = 0, m = 1;
    for (int i = 0; i < 60; i++) {
        cnt = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] & 1) cnt++;
            a[j] >>= 1;
        }
        cnt *= (n - cnt);
        cnt %= mod;
        ans += m * cnt;
        ans %= mod;
        m <<= 1;
        m %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))

a_bunpu = [0 for i in range(10 ** 5 + 1)]
for _a in a:
  a_bunpu[_a] += 1

q = int(input())
ans = sum(a)

for i in range(q):
  b, c = map(int, input().split())
  
  ans += (c - b) * a_bunpu[b]
  print(ans)
  
  if b != c:
    a_bunpu[c] += a_bunpu[b]
    a_bunpu[b] = 0

Measured memory_bytes: 20884
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	M := sc.NextInt()
	S := make([][]int, M)
	P := make([]int, M)
	for i := 0; i < M; i++ {
		k := sc.NextInt()
		S[i] = make([]int, k)
		for j := 0; j < k; j++ {
			S[i][j] = sc.NextInt()
		}
	}
	for i := 0; i < M; i++ {
		P[i] = sc.NextInt()
	}

	ans := 0
	for i := 0; i < 1<<uint(N); i++ {
		s := make([]bool, N+1)
		for j := 0; j < N; j++ {
			if (1<<uint(j))&i != 0 {
				s[j+1] = true // j+1番目がon
			}
		}
		ok := true
		for j := 0; j < M; j++ {
			cnt := 0
			for _, ms := range S[j] {
				if s[ms] {
					cnt++ // on
				}
			}
			if cnt%2 != P[j] {
				ok = false
				break
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Println(ans)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func gcd(x, y int) int {
	if y > 0 {
		return gcd(y, x%y)
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func max64(x, y float64) float64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func min64(x, y float64) float64 {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


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

int main() {
	int		h,a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	cin >> h >> n;
	for(i=0;i<n;i++) {
		cin >> j;
		ans += j;
	}

	if (ans >= h) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
N = input()
K = int(input())
ng = [0] * (K + 1)
ok = [0] * (K + 1)

ng[0] = 1
ng_count = 0
for n in N:
    n = int(n)
    if n == 0:
        for k in range(K, 0, -1):
            ok[k] = ok[k] + ok[k - 1] * 9
    else:
        ng_count += 1
        for k in range(K, 0, -1):
            ok[k] = ok[k] + ok[k - 1] * 9 + ng[k - 1] * (n - 1) + ng[k]
        ok[0] = 1
        for k in range(K+1):
            ng[k] = int(k == ng_count)

print(ng[-1] + ok[-1])


Measured memory_bytes: 38256
n, m = map(int, input().split())
graph = []
for _ in range(m):
	a, b = map(int, input().split())
	a, b = a - 1, b - 1
	graph.append([a, b])

class UnionFind:
	def __init__(self, n):
		self.n = n
		self.parents = [i for i in range(n)]
		self.rank = [1] * n
		self.size = [1] * n

	def find(self, x):
		if self.parents[x] == x:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		x, y = self.find(x), self.find(y)
		if x == y: return
		if self.rank[x] < self.rank[y]:
			self.parents[x] = y
			self.size[y] += self.size[x]
		else:
			self.parents[y] = x
			self.size[x] += self.size[y]
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def group_size(self, x):
		return self.size[self.find(x)]

cnt = 0
for i in range(m):
	uf = UnionFind(n)
	for j, e in enumerate(graph):
		if j == i: continue
		a, b = e[0], e[1]
		uf.union(a, b)
	a, b = graph[i][0], graph[i][1]
	if uf.group_size(0) < n: cnt += 1

print(cnt)

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


int main(){
	int e[4];
	int c = 0;
	int d = -1;

	for (auto& x : e) cin >> x;

	for (int i = 0;i < 4;i++){
		for (int j = i+1;j < 4;j++){
			if (e[i] == e[j]){
				e[j] = (d--);
				c++;
				break;
			}
		}
	}

	if (c == 2) cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}

Measured memory_bytes: 3064
import std;

int calc(string s) {
    int[int] d = [0: 1];
    int x = 0;
    int p = 1;
    foreach_reverse (c; s) {
        x = (x + (c - '0') * p) % 2019;
        p = 10 * p % 2019;
        d[x]++;
    }
    return d.values.map!(e => e * (e - 1) / 2).sum;
}

void main() {
    string s = read!string;
    writeln(calc(s));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 4172
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii < (ll)(ee); ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
ll a,b,c, cl[MAXN];
int main(){
	FAST
	string s; cin>>s; ll n=s.length();
	ll r=-1;
	for(ll i=0;i<n;++i) {
		if(s[i]=='R') r=i;
		else {
			cl[i]=r;
		}
	}
	ll l=-1;
	for(ll i=n-1;i>=0;--i) {
		if(s[i]=='L') l=i;
		else {
			cl[i]=l;
		}
	}
	ll moves=2e5; vector<ll>pos(n+2, 0);
	for(ll i=0;i<n;++i) {
		if(s[i]=='L') {
			moves-=i-cl[i];
			if(moves&1) pos[cl[i]+1]++;
			else pos[cl[i]]++;
			moves+=i-cl[i];
		} else {
			moves-=cl[i]-i;
			if(moves&1) pos[cl[i]-1]++;
			else pos[cl[i]]++;
			moves+=cl[i]-i;
		}
	}
	for(ll i=0;i<n;++i) cout<<pos[i]<<' ';cout<<'\n';
}


Measured memory_bytes: 2256
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

class S{
	public:
	int x,now,bef;
	S(int x,int now,int bef):x(x),now(now),bef(bef){}
	bool operator<(const S&a)const{
		return now>a.now;
	}
};

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		
		int to[111][111]={0};
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			
			to[a][b]=c;
			to[b][a]=c;
		}
		
		priority_queue<S> que;
		que.push(S(0,0,-1));
		
		int ans=0;
		
		int visit[111]={0};
		while(1){
			if(que.empty())break;
			
			S u = que.top();
			que.pop();
			
			if(visit[u.x]==1)continue;
			visit[u.x]=1;
			
			if(u.bef!=-1){
				ans += u.now;
			}
			
			rep(i,n){
				if(to[u.x][i]==0)continue;
				que.push( S(i ,to[u.x][i] ,u.x) );
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
//----------------------------------------------------------------------------------------------------------------------
  
  
void swap(char &a, char & b){
    char temp = a;
    a = b;
    b = temp;
 
}
 
const ll MOD = 1e9 + 7;
const int MAXN = 1e3 + 5;
 
vector< int > graph[MAXN];
int in_degrees[MAXN];
int dist[MAXN];
bool visited[MAXN];
ll inf = 1e18*1LL;


//char grid[MAXN][MAXN];

void add_self(int &a, int b){
    a+= b;
    while(a > MOD){
        a-=MOD;
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    vector< string > grid (h);
    for(int i = 0;i < h;i++){
        cin >> grid[i];
    }
    vector < vector< int > > dp(h + 1,vector<int> (w + 1));
    dp[0][0] = 1;
    //cout << "rame" << endl;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            int qvemotI = i;
            int qvemotJ = j + 1;
            if(j + 1 < w && grid[qvemotI][qvemotJ] == '.') add_self(dp[qvemotI][qvemotJ],dp[i][j]);
            int marcxnivI = i + 1;
            int marcxnivJ = j;
            if(i + 1 < h && grid[marcxnivI][marcxnivJ] == '.') add_self(dp[marcxnivI][marcxnivJ],dp[i][j]);
        }   
    }
    
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 5248
using System;

class A{
	public static void Main(){


		while (true) {
			string[] input = Console.ReadLine ().Split (' ');
			int H = int.Parse (input [0]);
			int W = int.Parse (input [1]);
		 
			if (H == W && H == 0) {
				break;
			}
		
			for (int x =0; x<H; x++) {
				for (int i =0; i<W; i++) {
					if(x==0 || x==H-1 || i==0 | i==W-1){
							Console.Write("#");
					}else{
						Console.Write(".");
					}
				}
				Console.WriteLine ();
			}
			Console.WriteLine ();
		}	
	}

}

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

typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='?'){
      s[i] = char('D');
      if(i==0) continue;
      if(s[i-1]=='P') ans += 2;
    }else if(s[i]=='D'){
      ans++;
      if(i==0) continue;
      if(s[i-1]=='P') ans++;
    }else{
      continue;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int n,k;
	int res = 0;
	cin >> n >> k;
	fi(n) {
		int temp;
		cin >> temp;
		if (temp >= k) {
			res++;
		}
	}
	ce(res);
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

int N;
int A[100000];

signed main() {
  cin >> N;
  int sum = 0;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) sum += A[i];

  int x = sum;
  for(int i=1; i<N; i+=2) x -= A[i]*2;
  cout << x;
  for(int i=1; i<N; i++) {
    x = A[i-1] * 2 - x;
    cout << " " << x;
  }
  cout << endl;
}


Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES//(M_PIに使える（π）)

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<numeric>
#include<random>
#include <functional>
using namespace std;

int main() {
	int N = 0;
	vector <int> D;
	int r[1000] = {0};
	int l[1000] = { 0 };
	int ans = 0;
	cin >> N;
	
	for (int i = 0;i<N;i++) {
		cin >> l[i] >> r[i];
		ans += r[i] - l[i]+1;
	}

	cout << ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 998244353L;

int64_t dpow(int64_t x, int64_t y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return dpow(x * x % MOD, y / 2);
  } else {
    return x * dpow(x, y - 1) % MOD;
  }
}

int64_t inv(int64_t x) { return dpow(x, MOD - 2); }

int main() {
  int64_t N, M, K;
  cin >> N >> M >> K;

  vector<int64_t> fact(N);
  fact[0] = 1;
  rep(i, N - 1) { fact[i + 1] = fact[i] * (i + 1) % MOD; }

  int64_t result = 0;
  irep(i, K) {
    int64_t cmb = fact[N - 1] * inv(fact[N - 1 - i]) % MOD * inv(fact[i]) % MOD;
    int64_t term = cmb * dpow(M - 1, N - 1 - i) % MOD;
    result += term;
    result %= MOD;
  }
  cout << result * M % MOD << endl;
  return 0;
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, d;
    cin >> n >> d;
    d = d * d;
    int ans = 0;
    for (int i = 0; i < n ; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d)
            ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
int a[105],b[105];
int main()
{
    int i,n,sum=0,m1,m2;
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    scanf("%d",&a[1]);
    for(i=2; i<=n; i++)
    {
        int x;
        scanf("%d",&x);
        a[i]=a[i-1]+x;
    }
    sum=a[n]/2;
    for(i=1; i<=n; i++)
    {
        if(sum-a[i]<=0)
        {
            m1=i;
            break;
        }
    }
    m2=(a[n]-2*a[m1-1])<(2*a[m1]-a[n])?(a[n]-2*a[m1-1]):(2*a[m1]-a[n]);
    printf("%d\n",m2);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int N = 0,M = 0;
  cin >> N >> M;
  if(abs(N - M) > 1){
    cout << 0;
    return 0;
  }
  ll x = 1,y = 1;
  for(ll a = 1; a <= N; a++){
    x = (x * a) % 1000000007;
  }
  for(ll b = 1; b <= M; b++){
    y = (y * b) % 1000000007;
  }
  
  if(abs(N - M) == 1){
    cout << (x * y) % 1000000007;
  }
  if(abs(N - M) == 0){
    cout << (x * y * 2) % 1000000007;
  }
}

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

int main() {
	// your code goes here


	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	ll ans=0;
	unordered_map<ll,ll>mp;
	for(int i=0;i<n;i++)
	{
		int x=i-a[i];
		ans+=mp[x];
		mp[i+a[i]]++;
	}
	cout<<ans<<"\n";

	
	return 0;
}

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

char s[111];

int main(void)
{
	int i, cnt = 0;

	scanf("%s" ,&s[1]);
	int n = strlen(&s[1]);

    for (i = 1; i <= n / 2; i++)
        if (s[i] != s[n - i + 1])
			++cnt;

	printf("%d" ,cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N,X,Y; cin >> N >> X >> Y;
  int dis;
  vector<int> ans(N);
  FOR(i,1,N){ 
    FOR(j,i+1,N+1){
      dis = min(min(j-i,abs(X-i)+1+abs(Y-j)),abs(Y-i)+1+abs(X-j));
      ans[dis]++;
    }
  }
  FOR(i,1,N)
    cout << ans[i] << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, H[101010];
vector<int> E[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, N) cin >> H[i];
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	int ans = 0;
	rep(cu, 0, N) {
		bool ok = true;
		fore(to, E[cu]) if (H[cu] <= H[to]) ok = false;
		if (ok) ans++;
	}
	cout << ans << endl;
}







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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(max(max(b*d, a*c), a*d), b*c) << endl;

    return 0;
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
#dp1 = [[0, 0] for i in range(n)]
#dp2 = [[0, 0] for i in range(n)]
s=[0]*n
m=[0]*n

if a[1]>a[0]:
  s[0]=1000//a[0]
  m[0]=1000-a[0]*s[0]
else:
  s[0]=0
  m[0]=1000

for i in range(1, n-1):
  m[i]= m[i-1]+a[i]*s[i-1]
  s[i] = 0
  if a[i]<a[i+1]:
    s[i] = m[i]//a[i]
    m[i] -= s[i]*a[i]

m[n-1]=m[n-2]+a[n-1]*s[n-2]
print(m[n-1])

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

using namespace std;

int main()
    {
    int m,c,x,y,cnt=0;
    vector<int>v;
   string s;
   cin>>s;
   for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
        v.push_back(0);

    }
    else if(s[i]=='1'){
        v.push_back(1);
    }
    else{
        if(v.size()>=1){
            v.pop_back();
        }
    }
   }
   for(int i=0;i<v.size();i++){
    cout<<v[i];
   }
        return 0;
    }


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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD ((long) 1e9 + 7)
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

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

  long n;
  cin >> n;

  if (n < 1000) printf("ABC\n");
  else          printf("ABD\n");
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

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


Measured memory_bytes: 7040
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

const int O = 1000000007;
int mul(int a, int b)
{
	return (a * b) % O;
}

int N;
int A[100010];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
	}

	int ans = 1;
	int c[3] = {};
	for (int i = 0; i < N; i++)
	{
		int a = A[i];
		int n = 0;

		for (int j = 0; j < 3; j++)
		{
			if (c[j] == a)
			{
				n++;
			}
		}

		ans = mul(ans, n);

		for (int j = 0; j < 3; j++)
		{
			if (c[j] == a)
			{
				c[j]++;
				break;
			}
		}
	}

	cout << ans << endl;
}



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

int main(){
  int a,b,j;
  cin >>a>>b;
  j = 0;
  
  for(int i = a; i <= b ; i ++){
    int n,p,q,r,s,t;
    n = i;
    p = n / 10000;
    n -= p * 10000;
    q = n / 1000;
    n -= q * 1000;
    r = n / 100;
    n -= r * 100;
    s = n / 10;
    n -= s * 10;
    t = n;
    
    if (p == t && q == s)
      j ++;
  }
  cout << j << endl;
}

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

#define pb push_back

typedef long long ll;
const int N = 1e5+5;
const ll MOD = 1e9+7;

int n;
ll dp[N][2];
vector<int> adj[N];

void dfs(int u , int p){
  for(auto v : adj[u])
    if(v != p) 
      dfs(v,u) , dp[u][0] = (dp[u][0]*((dp[v][0]+dp[v][1])%MOD))%MOD , dp[u][1] = (dp[u][1]*dp[v][0])%MOD;
}

int main(){

  cin >> n;

  for(int i = 0 ; i < N ; i++)
    for(int j = 0 ; j < 2 ; j++) dp[i][j] = 1;

  for(int i = 1 ; i < n ; i++){
    int x , y;
    cin >> x >> y;
    adj[x].pb(y) , adj[y].pb(x);
  }

  dfs(1,0);

  cout << (dp[1][0] + dp[1][1])%MOD << "\n";

}


Measured memory_bytes: 17552
import java.io.*
import java.util.*

enum class Direction { LEFT, UP, LEFTUP, NODIRECTION }
data class Lcs(var length: Int, var direction: Direction)
fun solve(s: String, t: String) {
    // dp[i][j] = sからi, tからj文字使ったときのLCS
    val dp = Array(s.length + 1) { IntArray(t.length + 1) }
    for (i in 1..s.length) {
        for (j in 1..t.length) {
            dp[i][j] = when (s[i - 1] == t[j - 1]) {
                true -> dp[i - 1][j - 1] + 1
                false -> Math.max(dp[i - 1][j], dp[i][j - 1])
            }
        }
    }
    val ans = StringBuilder()
    var y = s.length
    var x = t.length
    while (y > 0 && x > 0) {
        when (dp[y][x]) {
            dp[y - 1][x] -> { y-- }
            dp[y][x - 1] -> { x-- }
            dp[y - 1][x - 1] + 1 -> { ans.append(s[y - 1]); x--; y-- }
            else -> {}
        }
    }
    println(ans.reversed())
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    solve(s, t)
}


Measured memory_bytes: 89864
S = [int(input()) for _ in range(5)]
l=[]
m=10
for i in range(5):
    if (S[i]%10)<m and S[i]%10!=0:
        m=S[i]%10
        a=S[i]
        j=i
if m==10:
    a=S[0]  
    j=0      
for i in range(5):
    if  i!=j:
        if S[i]%10!=0:
            S[i]+=10-(S[i]%10)
        l.append(S[i])
l.append(a)
print(sum(l))

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
// #define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
    ll n; 
    cin >> n;
    vector<string> res{{"AC"}, {"WA"}, {"TLE"}, {"RE"}};
    map<string, ll> hist;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        hist[s]++;
    }

    for(int i = 0; i < 4; ++i){
        cout << res[i] << " x " << hist[res[i]] << endl;
    }
    
	return 0;
} 
// 1 2 3 4 6 12
// 0	1	2	3	4	5	6	7	8	9	10
// -	(	(	(	)	)	)	)	)	)	-
// 0	1	1	1	1	1	1	0	0	0	0
// 0	1	2	3	3	3	3	3	3	3	3
// 0	0	0	0	1	2	3	3	3	3	3
// 0	0	1	2	3	3	3	3	3	3	3



// 6 - 
// 5 - a
// 0 - ababba
// 2 - abba
// 4 - ba
// 1 - babba
// 3 - bba


// -$a
// -aa
// -aa
// -aa
// -a$

Measured memory_bytes: 3668
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int in = 0;

		while (true) {
			String string = new String();
			string = sc.nextLine();

			if (string.equals("0 0")) {
				break;
			}

			lines.add(string);
			in++;
		}

		for (int i = 0; i < in; i++) {
			int h = 0;
			int w = 0;
			int v = 0;
			String[] str = lines.get(i).split(" ");
			h = Integer.parseInt(str[0]);
			w = Integer.parseInt(str[1]);
			v = w;

			StringBuilder str01 = new StringBuilder();
			StringBuilder str02 = new StringBuilder();

			while (w > 0) {
				str01.append("#");
				w--;
				if (w == 0) {
					break;
				}
				str01.append(".");
				w--;
			}
			
			w = v;
			
			while (w > 0) {
				str02.append(".");
				w--;
				if (w == 0) {
					break;
				}
				str02.append("#");
				w--;
			}
			
			while (h>0) {
				System.out.println(str01);
				h--;
				if (h==0) {
					break;
				}
				System.out.println(str02);
				h--;
			}
			System.out.println("");
		}
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    string strs; 
    cin >> strs; 
    for (auto &s: strs) {
        if (s == '1') cout << '9';
        else if (s == '9') cout << '1'; 
        else cout << s; 
    }
    cout << endl; 
    return 0; 
}

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

#define ll long long

using namespace std;

int n;
int Y[109] ={};
int M[109] ={};
int D[109] ={};

int main(){

    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d %d %d",&Y[i],&M[i],&D[i]);
    }

    for(int i=0;i<n;i++){
        int ans = 0;
        for(int j = Y[i]+1;j< 1000 ; j++){
            if(j%3 == 0){
                ans += 200;
            }else{
                ans += 195;
            }
        }

        if(Y[i]%3 == 0){
            ans += (10 - M[i]) * 20;
        }else{
            for(int j=M[i]+1;j<=10;j++){
                if(j%2){
                    ans += 20;
                }else{
                    ans += 19;
                }
            }
        }

        if(M[i]%2 || Y[i]%3 == 0){
            ans += 21-D[i];
        }else{
            ans += 20-D[i];
        }
        printf("%d\n",ans);
    }

}


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

using namespace std;

int main() {
  unsigned long long n;
  cin>>n;
 
  vector<char> vec;
  
  for(int i=0;i<20;i++){
    
    unsigned long long c=((n-1)%26)+1;
    char b='a'+c-1;
    vec.push_back(b);
    
    n-=c;
    n/=26;
    if(n==0){
      break;
    }
   
    
    
  }
  int s=vec.size();
  for(int i=0;i<s;i++){
    cout<<vec.at(s-i-1);
  }
  cout<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

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

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    auto t = make_vec(h, w, -1); //塗り分け
    int cnt = 0;
    rep(i,h) rep(j,w)
    {
        if(t[i][j] != -1) continue;
        if(field[i][j] == '#') continue;
        queue<P> que;
        que.emplace(i, j);
        t[i][j] = cnt;

        while(!que.empty())
        {
            auto [y, x] = que.front();
            que.pop();
            rep(i,4)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if(field[ny][nx] == '#') continue;
                if(t[ny][nx] != -1) continue;
                que.emplace(ny, nx);
                t[ny][nx] = cnt;
            }
        }
        cnt++;
    }

    int n = cnt+1;
    vector<vector<int>> G(n, vector<int>(0));
    rep(y,h) rep(x,w) rep2(dy,-2,3) rep2(dx,-2,3)
    {
        int ny = y + dy;
        int nx = x + dx;
        if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        int u = t[y][x];
        int v = t[ny][nx];
        if(u == v || u == -1 || v == -1) continue;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    rep(i,n)
    {
        sort(G[i].begin(), G[i].end());
        G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
    }

    vector<int> dist(n, INF);
    int s = t[sy][sx], g = t[gy][gx];
    queue<int> que;
    que.emplace(s);
    dist[s] = 0;
    while(!que.empty())
    {
        auto v = que.front();
        que.pop();
        for(auto w:G[v])
        {
            if(dist[w] != INF) continue;
            que.emplace(w);
            dist[w] = dist[v] + 1;
        }
    }

    int ans = dist[g];
    if(ans == INF) ans = -1;
    cout << ans << endl;

    /*
    cout << G << endl;
    cout << dist << endl;
    cout << t << endl;
    //*/
    
    return 0;
}

Measured memory_bytes: 31836
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
#define MOD 1000000007
typedef int ll;
using namespace std;
ll n,i,j,k,z,m,q,r,timer,v,tot,x,y,xx, yy,INF, sz;
ll a[100500], cnt[100500];
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> m;
    a[1] = 1;
    for (int i = 1; i <= n; i++)
        cnt[i] = 1;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        if (a[x] == 1)
            a[y] = 1;
        if (cnt[x] == 1) {
            a[x] = 0;
        }
        cnt[x]--;
        cnt[y]++;
    }
    for (int i = 1; i <= n; i++) {
        k += a[i];
    }
    cout << k << endl;
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;

    for(int i=s.size()-1;i>=0;i-=2){
        string s1 = s.substr(0,i/2);
        string s2 = s.substr(i/2,i/2);
        //out(s1);
        //out(s2);
        if(s1 == s2){
            out(s1.size()+s2.size());
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  std::string inp;
  std::cin >> inp;
  bool is = true;
  for(int i = 0; i < inp.length(); i++) {
    if(i % 2 == 0) {
      char a = inp.at(i);
      if(a != 'R' && a != 'U' && a != 'D') {
        std::cout << "No";
        return 0;
      }
    }
    else {
      char a = inp.at(i);
      if(a != 'L' && a != 'U' && a != 'D') {
        std::cout << "No";
        return 0;
      }
    }
  }
  std::cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double ans = 0;
    int sw, s;
    for (int i = 0;i <= 30;i++){
        for (int j = 0;j <= 30;j++){
            int water = 100*a*i + 100*b*j;
            if (water > f){
                continue;
            }
            int mx = min(water/100 * e, f - water);
            for (int k = 0;k <= mx;k++){
                for (int l = 0;c*k + d*l <= mx;l++){
                    int sugar = c*k + d*l;
                    double de = sugar * 100.0f / (sugar + water);
                    if (de >= ans){
                        ans = de;
                        sw = sugar + water;
                        s = sugar;
                    }
                }
            }
        }
    }
    cout << sw << " " << s << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	for(int i = n ; i <= 999; i++ ){
		if(i % 111 == 0) {
			cout << i << endl;
			return 0;
		}	
	}
	return 0;                                              
}
	


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 1005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,tp;
int maxlog = 39;
ll a[maxn],sub[500005];
bool del[500005];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i] += a[i - 1];
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			sub[++tp] = a[j] - a[i - 1];
		}
	}
	ll ans = 0;
	for(int i = maxlog;i >= 0;i--){
		int cnt = 0;
		for(int j=1;j<=tp;j++) if(!del[j] && (sub[j] & (1ll << i))) cnt++;
		if(cnt < k) continue;
		ans |= (1ll << i);
		for(int j=1;j<=tp;j++) if(!del[j] && !(sub[j] & (1ll << i))) del[j] = true;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>

using namespace std;

int main() {
	int t;
    while(1){
        cin>>t;
        if(!t)break;
        
        int n,s,f,time=0;
        cin>>n;
        while(n--){
            cin>>s>>f;
            time+=(f-s);
        }
        if(time>=t)cout<<"OK"<<endl;
        else cout<<t-time<<endl;
    }
	return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class DSU {
	private int n;
	private int[] parentOrSize;

	public DSU(int n) {
		this.n = n;
		this.parentOrSize = new int[n];
		Arrays.fill(parentOrSize, -1);
	}

	int merge(int a, int b) {
		if (!(0 <= a && a < n))
			throw new IndexOutOfBoundsException("a=" + a);
		if (!(0 <= b && b < n))
			throw new IndexOutOfBoundsException("b=" + b);

		int x = leader(a);
		int y = leader(b);
		if (x == y) return x;
		if (parentOrSize[x] > parentOrSize[y]) {
			parentOrSize[x] += parentOrSize[y];
			return parentOrSize[y] = x;
		}else{
			parentOrSize[y] += parentOrSize[x];
			return parentOrSize[x] = y;
		}
	}

	boolean same(int a, int b) {
		if (!(0 <= a && a < n))
			throw new IndexOutOfBoundsException("a=" + a);
		if (!(0 <= b && b < n))
			throw new IndexOutOfBoundsException("b=" + b);
		return leader(a) == leader(b);
	}

	int leader(int a) {
		if (parentOrSize[a] < 0)
			return a;
		else
			return parentOrSize[a] = leader(parentOrSize[a]);
	}

	int size(int a) {
		if (!(0 <= a && a < n))
			throw new IndexOutOfBoundsException("" + a);
		return -parentOrSize[leader(a)];
	}

	ArrayList<ArrayList<Integer>> groups() {
		int[] leaderBuf = new int[n];
		int[] groupSize = new int[n];
		for (int i = 0; i < n; i++) {
			leaderBuf[i] = leader(i);
			groupSize[leaderBuf[i]]++;
		}
		ArrayList<ArrayList<Integer>> result = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			result.add(new ArrayList<>(groupSize[i]));
		}
		for (int i = 0; i < n; i++) {
			result.get(leaderBuf[i]).add(i);
		}
		result.removeIf(ArrayList::isEmpty);
		return result;
	}
}

public class Main {
	public static void main(String[] $) {
		var s = new Scanner(System.in);

		var n = Integer.parseInt(s.next());
		var q = Integer.parseInt(s.next());

		var uf = new DSU(n);

		for (int i = 0; i < q; ++i) {
			var t = Integer.parseInt(s.next());
			var u = Integer.parseInt(s.next());
			var v = Integer.parseInt(s.next());

			if (t == 0)
				uf.merge(u, v);
			else
				System.out.println(uf.same(u, v) ? 1 : 0);
		}
	}
}


Measured memory_bytes: 61360
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
#include<ctime>
#include<complex>
#include<sstream>
#include<cstring>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)
typedef pair<int,pii>piii;

int N,T,H,L;
int t[100],h[100];

int total;
bool solve(int now){
    if(t[now]==0&&h[now]==0)return true;
    if(t[now]){
        total+=10;t[now]--;T++;
    }
    else if(h[now]){
        total+=100;h[now]--;H++;
    }
    if(T>L)return true;

    if(total>=90){
        total-=90;
        if(total>=100&&H){
            h[now]++;
            H--;
            total-=100;
        }
        if(total/10>T)return true;
        t[now]+=total/10;
        T-=total/10;
        total=0;
    }
    return false;
}

int main(){
    scanf("%d%d%d%d",&N,&T,&H,&L);
    rep(i,N)scanf("%d%d",&t[i],&h[i]);

    for(int i=0;true;i++){
        if(solve(i%N)){
            printf("%d\n",i%N+1);
            break;
        }

    }
    return 0;
}

Measured memory_bytes: 1192
N = int(input())
s = list(map(int, input().split()))

m = min(s)
M = max(s)

lis = []
ans = 0

for i in range(m,M + 1):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))

Measured memory_bytes: 38512