akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  string s = stin();
  string t = stin();

  if(SZ(s) > SZ(t)){
    puts("GREATER");
  } else if(SZ(s) < SZ(t)){
    puts("LESS");
  } else {
    REP(i, SZ(s)){
      if(s[i] > t[i]){
        puts("GREATER");
        return 0;
      } else if(s[i] < t[i]){
        puts("LESS");
        return 0;
      }
    }
    puts("EQUAL");
  }
  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int a, b, c, d;
  int sum;
  string op(3,'+');
  cin >> d;
  a = d / 1000;
  b = d / 100 % 10;
  c = d / 10 % 10;
  d = d % 10;
  for (int i = 0; i < (1 << 3); i++) {
    bitset<3> tmp(i);
    if (tmp[0]) {
      op[0] = '+';
      sum = a + b;
    } else {
      op[0] = '-';
      sum = a - b;
    }
    if (tmp[1]) {
      op[1] = '+';
      sum += c;
    } else {
      op[1] = '-';
      sum -= c;
    }
    if (tmp[2]) {
      op[2] = '+';
      sum += d;
    } else {
      op[2] = '-';
      sum -= d;
    }
    if (sum == 7) {
      printf("%d%c%d%c%d%c%d=7\n", a, op[0], b, op[1], c, op[2], d);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3700
def f(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
 
N = int(input())
ans = [0]*N

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            M = f(x,y,z)
            if M <= N:
                ans[M-1] += 1
for i in ans:
    print(i)

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

using namespace std;

#define int long long

const int MAX_N = 100010;
const int LOG_N = 22;

using Pi = pair<int, int>;
using vint = vector<int>;

int N, Q;
int w[MAX_N];
vint graph[MAX_N];

int subsz[MAX_N];
int depth[MAX_N];
vector<Pi> chdat[MAX_N];

int par[LOG_N][MAX_N];
int mxw[LOG_N][MAX_N];

int getchw(int u, int ch1 = -1, int ch2 = -1) {
  for(Pi p : chdat[u]) {
    if(p.second != ch1 && p.second != ch2) return p.first;
  }
  return 0;
}

void init() {
  memset(par, -1, sizeof(par));
  function<void(int, int, int)> dfs = [&dfs](int u, int p, int d) {
    par[0][u] = p;
    depth[u] = d;
    subsz[u] = w[u];
    for(int v : graph[u]) {
      if(v == p) continue;
      dfs(v, u, d+1);
      subsz[u] += subsz[v];
      chdat[u].emplace_back(subsz[v], v);
    }
    sort(chdat[u].rbegin(), chdat[u].rend());
  };
  dfs(0, -1, 0);
  for(int i = 1; i < N; ++i) {
    int p = par[0][i];
    mxw[0][i] = getchw(p, i);
  }
  for(int i = 0; i+1 < LOG_N; ++i) {
    for(int v = 0; v < N; ++v) {
      if(par[i][v] == -1) {
	par[i+1][v] = -1;
	mxw[i+1][v] = -1;
      } else {
	par[i+1][v] = par[i][par[i][v]];
	mxw[i+1][v] = max(mxw[i][par[i][v]], mxw[i][v]);
      }
    }
  }
}

int ask(int u, int v) {
  if(depth[u] > depth[v]) swap(u, v);
  int res = getchw(v);
  for(int i = 0; i < LOG_N; ++i) {
    if(((depth[v]-depth[u])>>i)&1) {
      res = max(res, mxw[i][v]);
      v = par[i][v];
    }
  }
  if(u == v) return max(res, subsz[0]-subsz[u]);

  res = max(res, getchw(u));
  for(int i = LOG_N-1; i >= 0; --i) {
    if(par[i][u] != par[i][v]) {
      res = max(res, mxw[i][u]);
      res = max(res, mxw[i][v]);
      u = par[i][u];
      v = par[i][v];
    }
  }

  int lca = par[0][u];
  return max({res, subsz[0]-subsz[lca], getchw(lca, u, v)});
}

signed main() {
  scanf("%lld", &N);
  for(int i = 0; i < N; ++i) scanf("%lld", &w[i]);
  for(int i = 0; i < N-1; ++i) {
    int u, v;
    scanf("%lld %lld", &u, &v);
    --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  init();
  scanf("%lld", &Q);
  for(int i = 0; i < Q; ++i) {
    int a, b;
    scanf("%lld %lld", &a, &b);
    --a, --b;
    printf("%lld\n", ask(a, b));
  }
  return 0;
}



Measured memory_bytes: 50996
package main

import "fmt"

func main() {
	var (
		n int
	)
	fmt.Scan(&n)
	d := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}

	sum := 0

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum += d[i] * d[j]
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1772
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t N, M;
std::vector<int64_t> s, c;

bool ok(std::string str)
{
	if(str.size() != N) return false;
	for (int64_t i = 0; i < M; i++)
	{
		if (str[s[i]] != (char)(c[i] + '0')) return false;
	} 

	return true;
}

void solve()
{
	std::cin >> N >> M;
	s.resize(M);
	c.resize(M);

	for (int64_t i = 0; i < M; i++)
	{
		std::cin >> s[i] >> c[i];
		s[i]--;
	}

	std::string ans = "-1";
	for (int64_t i = 0; i < 1000; i++)
	{
		std::stringstream i_ss;
		i_ss << i;
		std::string str = i_ss.str();
		if (ok(str))
		{
			ans = str; 
			break;
		}
	}

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

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int const N = 5000, M = 10000000, md = 1e9 + 7;
int fc[M + 1], inv[M + 1], fcin[N + 1];

int ch(int n, int k) { return (ll)fc[n] * fcin[k] % md * fcin[n - k] % md; }
void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

int main(){
	fc[0] = 1;
	f(i, 1, M + 1)fc[i] = (ll)fc[i - 1] * i % md;
	inv[1] = 1;
	f(i, 2, M + 1)inv[i] = md - md / i * (ll)inv[md % i] % md;
	
	int n, a;
	scanf("%d%d", &n, &a);
	
	fcin[0] = 1;
	f(i, 1, a + 1)fcin[i] = (ll)fcin[i - 1] * inv[i] % md;
	n -= a;
	
	int an = 0;
	f(i, 2, a + 2)f(j, 0, i){
		int t = (ll)ch(i - 1, j) * (i - 1 - j) % md * fc[a - 1 + n - j + (i == a + 1)] % md * inv[n + i - 1 - j] % md;
		ad(an, j & 1 ? md - t : t);
	}
	
	printf("%d\n", an);
}

Measured memory_bytes: 81840
#include<stdio.h>
int main(void)
{
	int a = 0, b = 0, c = 0;
	scanf("%d%d", &a, &b);
	b = b * 2;
	c = a - b;
	if (c>=0) {
		printf("%d", c);
	}
	else if (c<=0) {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		a: usize,
		b: usize,
	}

	if a <= 8 && b <= 8 {
		println!("Yay!");
	}
	else {
		println!(":(");
	}
}


Measured memory_bytes: 2116
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    string s,t,w;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> w;
    if(s== w){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}

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

using namespace std;

int main(void)
{
  string str;
  int i = 0;
  
  cin >> str;
  i = str.size() - 1;
  if (str[i] == 's')
    cout << str << 'e' << 's' <<endl;
  else
    cout << str << 's' << endl;
  return 0;
}

Measured memory_bytes: 3572
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
import math
import time
ts=time.time()
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
print(n**3)

Measured memory_bytes: 38512
A, B = map(int,input().split())
X = 0
if A > B:
    X = A
    A -= 1
    if A > B:
        X += A
        print(X)
    else:
        X += B
        print(X)    
else:
    X = B
    B -= 1
    if A > B:
        X += A
        print(X)
    else:
        X += B
        print(X)


Measured memory_bytes: 3060
module S = Set.Make(String)

let words str = Str.split (Str.regexp " ") str

let () =
  let _ = read_int () in
  let s = read_line () |> words |> S.of_list in
  let _ = read_int () in
  let t = read_line () |> words in
  List.fold_left
    (fun acc e -> match S.mem e s with true -> acc+1 | false -> acc)
    0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 4856
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
void solve()
{
   int n; cin>>n;
   int h[n];
   rep(i,0,n) cin>>h[i];
   int dp[n+1];
   dp[0]=0;
   dp[1]=abs(h[1]-h[0])+dp[0];
   rep(i,2,n)
   {
      dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
   }
   cout<<dp[n-1];
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define int	    int64_t
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,flag=0,ans=0,a[25][25],m;
int dp[(1LL<<22)];
string d(int mask){
	string s="";
	int iter = n;
	while(iter--){
		s+=(mask%2)+'0';
		mask/=2;
	}
	reverse(all(s));
	return s;
}
int f(int mask){
	int x = __builtin_popcount(mask);
	if(x==n)
		return 1;
	if(dp[mask]!=-1)
		return dp[mask];
	int ans=0;
	for(int j=0;j<n;j++){
		if(((mask>>j)&1) == 0 and a[x][j]==1){
			ans+=f(mask|(1LL<<j));
			ans%=hell;
		}
	}
	return dp[mask]=ans;
}
void solve(){
	memset(dp,-1,sizeof dp);
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	cout<<f(0)<<endl;
}
signed main()
{
    ios
    int test = 1;
    //cin>>test;
    while(test--){
    	solve();
    }
    return 0;
}

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

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

    vector<int> A(N), B(N), C(N - 1);
    rep (i, N) {
        cin >> A[i];
    }
    rep (i, N) {
        cin >> B[i];
    }
    rep (i, N - 1) {
        cin >> C[i];
    }

    int ans = 0;
    rep (i, N) {
        ans += B[A[i] - 1];

        if (i != 0 && A[i] - 1 == A[i - 1]) {
            ans += C[A[i - 1] - 1];
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    a.emplace_back(0);
    sort(_all(a));

    int res = 0;
    rep(i, 1, n + 1){
        int num = a[i] - a[i-1];
        if(num % 2){
            res ^= (n - i + 1);
        }
    }
    cout << (res ? "first":"second") << endl;

    return 0;
}

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

using namespace std;

int n, a[102];

int main(){
	cin >> n; int ans = 1e9;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	for(int i = 0; i <= 100; ++i){
		int sum = 0;
		for(int j = 1; j <= n; ++j)
			sum += (a[j] - i) * (a[j] - i);
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto abc  = readln.split.to!(int[]);
    if (abc[0] > abc[1]) {
        auto tmp = abc[0];
        abc[0] = abc[1];
        abc[1] = tmp;
    }
    writeln(abc[0] <= abc[2] && abc[2] <= abc[1] ? "Yes" : "No");
}


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

Int n, k;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	if((n-1)*(n-2)/2 < k){
		cout << -1 << "\n";
		return 0;
	}
	using E = pair<Int, Int>;
	vector<E> ans;
	for(Int i=1; i<n; ++i)
		ans.push_back(E(0, i));
	Int a = (n-1)*(n-2)/2 - k;
	for(Int i=1; i<n; ++i)
		for(Int j=i+1; j<n; ++j){
			if(a == 0) continue;
			ans.push_back(E(i, j));
			--a;
		}
	cout << ans.size() << "\n";
	for(auto i:ans) cout << i.first+1 << " " << i.second+1 << "\n";
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<queue>
#include <cctype>
#include <cstring>
using namespace std;
int main()
{
	char  n[20];
	scanf("%s",&n);
	int flag=1;
	int num=0;
	int k=-1;
	for(int i=0;i<strlen(n);i++)
	{
		if(i==0)
		{
			if(n[i]!='A')
			{
				flag=0;
				break;
			}
		}
		else if(!islower(n[i])&&i!=k&&n[i]!='C')
		{
			flag=0;
			break;
		}
		if(n[i]=='C')
		{
			k=i;
			num++;
		}
	}
	if(num==1&&k>=2&&k<=strlen(n)-2&&flag)
	{
		printf("AC\n");
	}
	else
	{
		printf("WA\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int M = 1e9 + 7;

int dp[105][4][4][4];

bool nnnok(int i, int j, int k) {
	return (i == 0 && j == 2 && k == 1) ;
}

bool nok(int i, int j, int k) {
	return (i == 0 && j == 2 && k == 1) || 
			(i == 0 && j == 1 && k == 2)||
			(i == 2 && j == 0 && k == 1);
}

bool nnok(int i, int j, int k, int l) {
	return nnnok(i, j, k) || nnnok(j, k, l) || nnnok(j, i, k) || nnnok(i, k, l) 
		|| nnnok(i, k, j) || nnnok(k, j, l) || nnnok(i, j, l) || nnnok(j, l, k);
	
}

int32_t main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<4;i++)
		for(int j=0;j<4;j++)
			for(int k=0;k<4;k++) {
				if(nok(i, j, k)) continue;
				dp[2][i][j][k] = 1;
			}
	for(int i=3;i<n;i++) {
		for(int j=0;j<4;j++) {
			for(int k=0;k<4;k++) {
				for(int l=0;l<4;l++) {	
					for(int m=0;m<4;m++) {
						if(nnok(j, k, l, m)) continue;
						dp[i][k][l][m] += dp[i-1][j][k][l];
						dp[i][k][l][m] %= M;
					}
				} 
			}
		}
	}
	int ans = 0;
	for(int i=0;i<4;i++)
		for(int j=0;j<4;j++) 
			for(int k=0;k<4;k++) {
				ans += dp[n-1][i][j][k];
				ans %= M;
			}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int main(){
    string str;
    while(getline(cin,str),str!="."){
       vector<string>s(1000);
       int num=0;
       bool check=true;
       REP(i,str.size()){
           if(str[i]=='('){
              s[num]="(";
              num++;
           }
           if(str[i]=='['){
              s[num]="[";
              num++;
           }
           if(str[i]==')'){
              if(num==0){
                 check=false;
                 break;
              }
              if(s[num-1]!="("){
                 check=false;
                 break;
              }
              num--;
           }
           if(str[i]==']'){
              if(num==0){
                 check=false;
                 break;
              }
              if(s[num-1]!="["){
                 check=false;
                 break;
              }
              num--;
           }
       }
       if(num!=0)check=false;
       if(check==true){
          cout<<"yes"<<endl;
       }else{
          cout<<"no"<<endl;
       }
    }
    return 0;
}

Measured memory_bytes: 3012
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(-100<=a,b,c<=100)
        if(a==b)
            cout<<c<<endl;
        else if(a==c)
            cout<<b<<endl;
        else
            cout<<a<<endl;
    else
        cout<<"enter number between(-100,100)"<<endl;
    return 0;
}

Measured memory_bytes: 256
//Sameer's Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define pb push_back
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt", "w", stdout);
#endif
	{
		long double d, t, s;
		cin >> d >> t >> s;
		if ((d / s) <= t)
		{
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3728
/* while(!success_achieved())
      work_hard();

   code by:aman_ayush
  */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
    fast;
     str s;
     cin>>s;
     int a=(s[0]-'0')*10+(s[1]-'0');
     int b=(s[2]-'0')*10+(s[3]-'0');
     if(a>0&&a<=12)
     {
         if((b>0)&&(b<=12))
          cout<<"AMBIGUOUS\n";
          else
           cout<<"MMYY\n";
     }
     else
     {
         if((b>0)&&(b<=12))
          cout<<"YYMM\n";
          else
           cout<<"NA\n";
     }
     return 0;
}

Measured memory_bytes: 256
s = gets.to_s.chomp
flg = "YES"
while s != "" do
    case s[s.length-1]
    when "m" then
        if "dream" == s[(s.length-5)..(s.length-1)]
            s.slice!((s.length-5)..(s.length-1))
        else
            s = ""
            flg = "NO"
        end
    when "e" then
        if "erase" == s[(s.length-5)..(s.length-1)]
            s.slice!((s.length-5)..(s.length-1))
        else
            s = ""
            flg = "NO"
        end
    when "r" then 
        if "dreamer" == s[(s.length-7)..(s.length-1)]
            s.slice!((s.length-7)..(s.length-1))
        elsif "eraser" == s[(s.length-6)..(s.length-1)]
            s.slice!((s.length-6)..(s.length-1))
        else
            s = ""
            flg = "NO"
        end
    end
end

puts flg

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

int main(void){
   int N;
   cin>>N;
   vector<long long> dp(N+1);
   dp[0]=2;
   dp[1]=1;
   for(int i=2;i<N+1;i++){
      dp[i]=dp[i-1]+dp[i-2];
   }
   cout<<dp[N]<<endl;
   return 0;
}



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

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int ans=n-1;
  for(Int i=1;i*i<=n;i++){
    if(n%i) continue;
    chmin(ans,(i-1)+(n/i-1));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt64()

	_, divlist := getDivlistSlow(n)
	sort.Slice(divlist, func(i int, j int) bool {
		return divlist[i] < divlist[j]
	})

	var minwalk int64 = n
	for _, v := range divlist {
		nowwalk := (v - 1) + (n/v - 1)
		minwalk = min(minwalk, nowwalk)
		if v*v > n {
			break
		}
	}
	fmt.Println(minwalk)
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

// 約数列挙リストを作成(愚直)
func getDivlistSlow(a int64) (cnt int64, divlist []int64) {
	for i := int64(1); i*i <= a; i++ {
		if a%i == 0 {
			cnt++
			divlist = append(divlist, i)
			if i*i != a { // 6*6=36 などを重複カウントしない
				cnt++
				divlist = append(divlist, a/i)
			}
		}
	}
	return cnt, divlist
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
    ll N, T;
    cin >> N >> T;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    ll ans = T;
    ll stop = a[0] + T;
    rep(i, 1, N){
        if(a[i] >= stop){
            ans += T;
        }else{
            ans += a[i] - a[i-1];
        }
        stop = a[i] + T;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: "List[int]", B: "List[int]"):
    ab = [[A[i],B[i]] for i in range(N)]
    x = sorted(ab, key=lambda x:-x[0])
    print(x[0][0]+x[0][1])
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26916
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const long long INF = 1LL<<60;

vector<long long> mindif(const vector<long long> &A) {
    int N = A.size();
    vector<long long> res(N+1, INF);
    res[0] = 0;

    long long j = 0, p = 0, q = 0;
    for (int i = 0; i < N; ++i) {
        q += A[i];
        while (j < i && p + A[j] <= q - A[j]) p += A[j], q -= A[j], ++j;
        res[i+1] = min( abs(p - q), abs((p+A[j]) - (q-A[j])) );
    }
    return res;
}

int main() {
    int N; cin >> N;
    vector<long long> A(N), S(N+1, 0);
    for (int i = 0; i < N; ++i) cin >> A[i], S[i+1] = S[i] + A[i];

    vector<long long> left(N+1, INF), right(N+1, INF);
    left = mindif(A);
    reverse(A.begin(), A.end());
    right = mindif(A);

    //COUT(left); COUT(right);

    long long res = INF;
    for (int i = 2; i <= N-2; ++i) {
        long long p = (S[i] - left[i]) / 2;
        long long q = (S[i] + left[i]) / 2;
        long long r = (S[N]-S[i] - right[N-i]) / 2;
        long long s = (S[N]-S[i] + right[N-i]) / 2;
        chmin(res, max(q, s) - min(p, r));
    }
    cout << res << endl;
}    
        
    


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

#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 FORR(i, m, n) for(int i = m;i >= n;i--)

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

int main(void) {
    int n, m, x, a;
    vector<int> vu;
    vector<int> vd;
    cin >>n >>m >>x;
    REP(i,m){
        cin >>a;
        if(x>a){
            vd.push_back(a);
        }else{
            vu.push_back(a);
        }
    }
    int ans;
    if(vd.size()>vu.size()){
        ans=vu.size();
    }else{
        ans=vd.size();
    }
    cout << ans << endl;
    return 0;
}


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

int main () {
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> r(n);
    rep(i, n) r[i] = i+1;
    
    int a, b, cnt = 0;
    do {
        cnt++;
        if (r == p) a = cnt;
        if (r == q) b = cnt;
    } while (next_permutation(all(r)));
    cout << abs(a-b) << endl;
    return 0;
}

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

signed main() {
    int N, M;
    cin >> N >> M;

    set<int> se;
    for (int i = 1; i * i <= M; i++) {
        if (M % i) continue;
        se.insert({i, M / i});
    }

    int ans = 1;
    for (int x : se) {
        if (N * x <= M) {
            ans = x;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
x='AC'
if s[0]!='A':
  x='WA'
else:
  if s[2:len(s)-1].count('C')!=1:
    x='WA'
  else:
    for i in range(len(s)):
      if s[i]=='C':
        s=s[:i]+s[i+1:]
        break
    if s[1:].islower()==False:
      x='WA'
print(x)

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

#define ll long long
#define ld long long
#define pi 3.14159265359

int main() {
    int N; cin >> N;
    vector<int> A(N), cnt(N);
    for (int i = 0; i < N - 1; i++) {
        cin >> A.at(i);
        cnt.at(A.at(i) - 1)++;
    }
    for (int i = 0; i < N; i++) {
        cout << cnt.at(i) << endl;;
    }
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
      ll a,b,c,k;
      Int(a,b,c);
      Int(k);

      ll res=0;
      res=min(a,k);
      k-=min(a,k);

      k-=min(b,k);

      res-=min(c,k);

      printf("%lld\n", res);

        //printf("Case %d: ",++te);
    }
    return 0;
}



Measured memory_bytes: 3584
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn detect(s: &Vec<Vec<char>>) -> bool {
    let h = s.len();
    let w = s[0].len();
    let mut used = vec![false; w];
    let mut center = w % 2 == 0;
    for i in 0..w {
        if used[i] {
            continue;
        }
        for j in (i + 1)..w {
            if used[j] {
                continue;
            }
            let mut ok = true;
            for k in 0..h {
                if s[k][i] != s[h - 1 - k][j] {
                    ok = false;
                }
            }
            if ok {
                used[i] = true;
                used[j] = true;
                break;
            }
        }
        if !used[i] {
            if center {
                return false;
            }
            for k in 0..h {
                if s[k][i] != s[h - 1 - k][i] {
                    return false;
                }
            }
            center = true;
            used[i] = true;
        }
        if !used[i] {
            return false;
        }
    }
    true
}

fn can(s: &mut Vec<Vec<char>>, k: usize, used: bool) -> bool {
    let h = s.len();
    if 2 * k + 2 >= h {
        return detect(s);
    }
    for i in (k + 1)..(h - k) {
        if used && 2 * i + 1 == h {
            continue;
        }
        s.swap(i, h - 1 - k);
        if can(s, k + 1, used) {
            return true;
        }
        s.swap(i, h - 1 - k);
    }
    if !used {
        s.swap(k, h / 2);
        if can(s, k, true) {
            return true;
        }
        s.swap(k, h / 2);
    }
    false
}

fn run() {
    input! {
        h: usize,
        _w: usize,
        s: [chars; h],
    }
    let mut s = s;
    if can(&mut s, 0, h % 2 == 0) {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,N) for(i=0;i<N;++i)
#define fos(i,b,N) for(i=b;i<N;++i)
#define forr(i,N) for(i=N-1;i>=0;--i)
#define disp(n) cout<<n<<endl;
#define N 100005
#define M 10000007
#define ll long long
#define vll vector <long long int>
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
long c=0;
if(n<2)
  c+=0;
else
  c+=n*(n-1)/2;
if(m<2)
  c+=0;
else
  c+=m*(m-1)/2;
cout<<c;
return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    string S;
    cin >> S;
    int b = 0;
    int w = 0;
    ull result = 0;
    for (char c: S) {
        if (c == 'B') {
            ++b;
        } else if (c == 'W') {
            ++w;
            result += b;
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  int INF = 1000000;

  int n=0;
  while(cin >> n){
    int res=0;
    res = 2 + (n*(n+1))/2 - 1;
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
n=int(input())
w=list(map(int,input().split()))

ans=1000000000000000000000000000000000
for i in range(n):
    if abs(sum(w[0:i])-sum(w[i:n]))<=ans:
        ans=abs(sum(w[0:i])-sum(w[i:n]))
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

#define DEBUG 1



int main() {

	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	int sum = 0;
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (sum + a[i] <= x) {
			sum += a[i];
			ans++;
		}
		else
		{
			break;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 + y1 - y2
y3 = y2 - x1 + x2
x4 = x1 + y1 - y2
y4 = y1 - x1 + x2
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int sum = 0;
            if(m==-1&&f==-1&&r==-1){
                break;
            }else if(m==-1 || f==-1){
                System.out.println("F");
            }else{
                sum =  m + f;
                if(sum >= 80){
                    System.out.println("A");
                }else if(sum >= 65){
                    System.out.println("B");
                }else if(sum >= 50){
                    System.out.println("C");
                }else if(sum >= 30){
                    if(r >=50){
                        System.out.println("C");
                    }else{
                        System.out.println("D");
                    }
                }else if(sum < 30){
                    System.out.println("F");
                }
            }
        }
    }
}


Measured memory_bytes: 26220
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> A(N);
  for (auto& item : A) {
    cin >> item;
  }

  auto display = [&]() { 
    const char* sep = "";
    for (auto& item : A) {
      cout << sep << item;
      sep = " ";
    }
    cout << endl;
  };

  display();
  for (int i = 1; i < N; ++i) {
    int tmp = A[i];
    int j = i;
    while (0 < j) {
      if (A[j - 1] < tmp) {
        break;
      }
      A[j] = A[j - 1];
      --j;
    }
    A[j] = tmp;
    display();
  }
  return 0;
}



Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_136
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int res = 0;
            for(int i = 1; i <= n; i++)
            {
                int cnt = 0;
                int tmp = i;
                while (tmp > 0)
                {
                    cnt++;
                    tmp /= 10;
                }
                if (cnt % 2 == 1) res++;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	final int MAX_P = 100000 * 10000;
	int n, k;
	int[] w;
	void run() {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		k = scan.nextInt();
		w = new int[n];
		for (int i = 0; i < n; i++)
			w[i] = scan.nextInt();

		int low = 0;
		int hight = MAX_P;
		while (low <= hight) {
			int mid = (low + hight) / 2;
			if (canPile(mid))
				hight = mid - 1;
			else
				low = mid + 1;
		}
		System.out.println(hight);
	}
	
	boolean canPile(int p) {
		int sum = 0;
		int index = 0;

		for (int i = 0; i < k; i++) {
			sum = 0;
			while (sum + w[index] < p) {
				sum += w[index];
				index++;
				if (index == n)
					return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)
#define oo 2000000000000000000


using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

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

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

int32_t main(){
    IOS
    int n;
    cin>>n;
    int arr[n];
    int cost[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=0;i<n;i++){
        cost[i] = 1000000000;
    }
    cost[0] = 0;
    for(int i=0;i<n-2;i++){
        cost[i+1] = min(cost[i+1],cost[i]+abs(arr[i]-arr[i+1]));
        cost[i+2] = min(cost[i+2],cost[i]+abs(arr[i]-arr[i+2]));
    }
    cost[n-1] = min(cost[n-1],cost[n-2]+abs(arr[n-1]-arr[n-2]));
    cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}

Measured memory_bytes: 256