akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

int a, n;
int tot;

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

    cin >> a >> n;
    for (int i=0;i<n;i++){
        int tm;
        cin >> tm;
        tot+=tm;
    }
    if (tot >= a){
        cout << "Yes" << el;
    } else{
        cout << "No" << el;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
using namespace std;

template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

int mod_pow(int x, int y, int m = mod) {
	int res = 1;
	while (y) {
		if (y % 2) {
			res *= x;
			res %= m;
		}
		x = x * x % mod;
		y /= 2;
	}
	return res;
}

int n, m;
bool con[800][800];
int co[805];
int cnt;
void dfs(int x, int color) {
	co[x] = color;
	if (color > 0)
		cnt++;
	else
		cnt--;
	rep(i,n)
	{
		if (!con[i][x])
			continue;
		if (co[i] && co[x] == co[i]) {
			cout << -1 << endl;
			exit(0);
		}
		if (!co[i])
			dfs(i, color * -1);
	}
}
signed main() {
	cin >> n >> m;
	rep(i,n)
		rep(j,n)
			con[i][j] = i != j;
	rep(i,m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		con[a][b] = con[b][a] = false;
	}
	vector<int> v;
	rep(i,n)
	{
		if (!co[i]) {
			cnt = 0;
			dfs(i, 1);
			v.push_back(abs(cnt));
		}
	}
	bitset<1600> bit;
	bit.set(800);
	for (int i : v) {
		bit = (bit >> i) | (bit << i);
	}
	int ans = inf;
	rep(i,1600)
	{
		if (bit[i]) {
			chmin(ans, abs(800 - i));
		}
	}
	int w, r;
	w = (n + ans) / 2;
	r = n - w;
	cout << w * (w - 1) / 2 + r * (r - 1) / 2 << endl;
}


Measured memory_bytes: 768
s = int(input())
l = []
l.append(s)
count = 1
while True:
  if l[-1]%2 == 1:
    a = l[-1]*3+1
  else:
    a = l[-1]//2
    
  count += 1
  if a in l:
    print(count)
    exit()
  else:
    l.append(a)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w, k;
  cin >> h >> w >> k;
  vector<string> v(h);
  rep(i, 0, h) cin >> v[i];
  int total = 0;
  rep(i, 0, h) rep(j, 0, w) if (v[i][j] == '#') total++;

  vector<vector<int>> hv(1 << h), wv(1 << w);
  rep(i, 0, 1 << h) {
    rep(j, 0, h) {
      if (i >> j & 1)
        hv[i].push_back(1);
      else
        hv[i].push_back(0);
    }
  }

  rep(i, 0, 1 << w) {
    rep(j, 0, w) {
      if (i >> j & 1)
        wv[i].push_back(1);
      else
        wv[i].push_back(0);
    }
  }

  int ans = 0;

  rep(i, 0, 1 << h) {
    int row = 0;
    rep(a, 0, h) {
      if (hv[i][a]) {
        rep(l, 0, w) {
          if (v[a][l] == '#')
            row++;
        }
      }
    }
    rep(j, 0, 1 << w) {
      int col = 0;
      rep(a, 0, w) {
        if (wv[j][a]) {
          rep(l, 0, h) {
            if (hv[i][l] && v[l][a] == '#')
              continue;
            if (v[l][a] == '#')
              col++;
          }
        }
      }
      if (total - (row + col) == k)
        ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vi A(N),B(N);
  vpii S(N);
  rep(i,N) {
    cin >> A[i] >> B[i];
    S[i]=make_pair(A[i]+B[i],i);
  }
  sort(S.begin(),S.end());
  reverse(S.begin(),S.end());
  ll ans=0;
  rep(i,N) {
    if(i%2) ans-=B[S[i].second];
    else ans+=A[S[i].second];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
'use strict'

// const conv = (str) => {
//     if(str === 'A') return 10
//     if(str === 'B') return 11
//     if(str === 'C') return 12
//     if(str === 'D') return 13
//     if(str === 'E') return 14
//     if(str === 'F') return 15
// }

const main = (input) => {
    let X = input.split('\n')[0].split(' ')[0]
    let Y = input.split('\n')[0].split(' ')[1]
    if(X === Y){
        console.log('=')
    }else if(X > Y){
        console.log('>')
    }else{
        console.log('<')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
let a, b, c, d, e, f = Scanf.scanf " %d %d %d %d %d %d" @@ fun a b c d e f -> a, b, c, d, e, f
let ws = Array.make (f + 1) false
let ss = Array.make (f + 1) false
let (<@) (w, s) (w2, s2) = (w2 + s2) * s < (w + s) * s2
let ans = ref (100 * a, 0)
let _ =
  for i = 0 to f / 100 do
    for j = 0 to f / 100 do let w = 100 * i * a + 100 * j * b in if w <= f then ws.(w) <- true done done;
  for i = 0 to f do
    for j = 0 to f do if i * c + j * d <= f then ss.(i * c + j * d) <- true done done;
  for i = 0 to f do
    for j = 0 to f do if ws.(i) && ss.(j) && i + j <= f && 100 * j <= i * e then (ans := if !ans <@ (i, j) then i, j else !ans) done done;
  let w, s = !ans in Printf.printf "%d %d\n" (w + s) @@ s

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  int b[6];
  rep(i,6)b[i]=-1;
  if(m==0){
    if(n==1){
    	cout<<0<<endl;
        return 0;
    }
    bool f=0;
 	 for(int i=1;i<=n;i++){
    	if(b[i]!=-1) cout<<b[i];
		else if(f==0) cout<<1;
		else if(f==1)cout<<0;
        f=1;
  }
  cout<<endl;
  return 0;
  }
  vector<pair<int,int>> a(m);
  rep(i,m)cin>>a.at(i).first>>a.at(i).second;
  sort(all(a));
  b[a.at(0).first]=a.at(0).second;
 for(int i=1;i<m;i++){
    if(a.at(i-1).first==a.at(i).first){
      if(a.at(i-1).second!=a.at(i).second){
      cout<<-1<<endl;
      return 0;
      }
      else continue;
    }
    b[a.at(i).first]=a.at(i).second;
  }
  if(n!=1&&b[1]==0){
    cout<<-1<<endl;
    return 0;
  }
  if(n==1&&b[1]==0){
    cout<<0<<endl;
    return 0;
  }
  bool f=0;
  for(int i=1;i<=n;i++){
   	if(b[i]!=-1) cout<<b[i];
    else if(f==0) cout<<1;
	else if(f==1)cout<<0;
    f=1;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int bangou[28];
	for(int i=0;i<28;i++){
	cin>>bangou[i];}
	for(int ii=1;ii<31;ii++){
		int a=0;
		for(int iii=0;iii<28;iii++){
			if(ii==bangou[iii]){a++;}}
		if(a==0){cout<<ii<<endl;}}
	return 0;}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  unsigned long long a, b, c;
  cin >> a >> b >> c;
  if(c < (a + b)) {
    cout << "No" << endl;
    return 0;
  }
  unsigned long long ans1 = a * a + b * b + c * c;
  unsigned long long ans2 = 2 * a * b + 2 * b * c + 2 * c * a;
  cout << (ans1 > ans2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
    public static void main(String[] args) {
        int n = 0, m = 0;
        Edge[][] edges = new Edge[0][0];
        String[] elems;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            elems = br.readLine().split(" ");
            n = Integer.parseInt(elems[0]);
            m = Integer.parseInt(elems[1]);
            edges = new Edge[n][n];
            for (int i = 0; i < m; i++) {
                elems = br.readLine().split(" ");
                int from = Integer.parseInt(elems[0]);
                int to = Integer.parseInt(elems[1]);
                int cost = Integer.parseInt(elems[2]);
                Edge e = new Edge(cost);
                edges[from-1][to-1] = e;
                edges[to-1][from-1] = e;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (int i = 0; i < n; i++) {
            Queue<Node> queue = new PriorityQueue<>((s1, s2) ->
                    Integer.compare(s1.totalCost, s2.totalCost));
            int[] dist = new int[n];
            for (int j = 0; j < n; j++){
                dist[j] = Integer.MAX_VALUE;
            }
            dist[i] = 0;
            Node start = new Node(i, 0, 0);
            Node[] result = new Node[n];
            queue.add(start);
            while (!queue.isEmpty()) {
                Node trg = queue.poll();
                if (dist[trg.current] != trg.totalCost)
                    continue;
                int current = trg.current;
                result[current] = trg;
                for (int j = 0; j < n; j++){
                    if(edges[current][j] == null)
                        continue;
                    int tmp = trg.totalCost + edges[current][j].cost;
                    if (dist[j] > tmp) {
                        queue.add(new Node(j, current, tmp));
                        dist[j] = tmp;
                    }
                }
            }
            for (Node node:result) {
                int current = node.current;
                int prev = node.prev;
                if (prev == 0)
                    continue;
                edges[prev][current].check = true;
            }
        }
        int sum = 0;
        for (Edge[] es:edges)
            for (Edge e:es) {
                if (e == null) continue;
                if (!e.check) sum++;
            }
        System.out.println(sum / 2);
    }
}

class Node {
    int prev;
    int current;
    int totalCost;
    Node (int i, int prev, int totalCost) {
        this.prev = prev;
        current = i;
        this.totalCost = totalCost;
    }

    Node (int current) {
        this.current = current;
    }
}

class Edge {
    int cost;
    boolean check;
    public Edge (int cost) {
        this.cost = cost;
        check = false;
    }
}


Measured memory_bytes: 28372
#include<bits/stdc++.h>
using namespace std;
int dp[200005];
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<=k;i++)
    {
        if(dp[i]!=true)
        {
        for(int j=0;j<n;j++)
        {
            dp[i+a[j]]=true;
           // if(dp[])
        }
    }
    }
    if(dp[k]==true)
    {
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;

    }
    return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
string s;
int main(){
	cin >> s;
	int numc = 0;
	int numda = 0;
	for(int i=2;i<s.size()-1;i++){
		if(s[i] == 'C') numc++;
	}
	for(int i=0;i<s.size();i++){
		if('A' <= s[i] && s[i] <= 'Z') numda++;
	}
	if(s[0] != 'A') puts("WA");
	else if(numc != 1) puts("WA");
	else if(numda > 2) puts("WA");
	else puts("AC");
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

lcm = lambda a, b: a * b // gcd(a, b)

N, M, *A = map(int, open(0).read().split())

Y = reduce(lcm, A)

if any((Y // a) % 2 == 0 for a in A):
    print(0)
    quit()

print(M // (Y // 2) - (M // Y))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

int main()
{
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;cin>>N>>M;
  int wa=0;
  for(int i=0;i<M;i++){
    int a;cin>>a;
    wa+=a;
  }
  cout<<(N<wa?-1:N-wa)<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <math.h>
#include <string>
using namespace std;
 
const double PI = acos(-1);
const int M=998244353;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define oo 1e16


int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	
	int n;
	cin>>n;
	vi f(n+1);
	long long sum=0;
	for (int i = 1; i <= n; ++i)
	{
		for(int j=i;j<=n;j+=i){
			f[j]++;
			sum+=j;
		}
	}
	printf("%lld\n",sum );
	/*for (int i = 1; i < n; ++i)
	{
		printf("%d\n",f[i] );
	}*/
	return 0;
}

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

int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  vector<vector<int>> dp(h, vector<int>(w, INF));
  rep(i, h) rep(j, w) cin >> s[i][j];
  if (s[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;
  rep(i, h) rep(j, w) {
    if (i+1 < h) {
      if (s[i][j] == s[i+1][j])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
      else
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1);
    }
    if (j+1 < w) {
      if (s[i][j] == s[i][j+1])
        dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
      else
        dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1);
    }
  }
  if (s[h-1][w-1] == '#') dp[h-1][w-1]++;
  cout << dp[h-1][w-1]/2 << endl;
  return 0;
}

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

int main(){
  string N;
  cin >> N;
  if(N.at(0)==N.at(1) && N.at(1)==N.at(2)){
    cout << "Yes" << endl;
  }
   else if(N.at(1)==N.at(2) && N.at(2)==N.at(3)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
        const char* c = strchr(na + 1, ',');
        cerr.write(na, c - na) << " : " << arg1 << " , ";
        __f(c + 1, args...);
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)), V.erase(unique(all(V)), V.end())
typedef pair <int,int> pii;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int inf = 1e9;
const long long INF = 1e18;
const int N = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    #ifdef LOCAL
        //freopen("input.txt", "r", stdin);
    #endif // LOCAL
    int t = 1; //cin >> t;
    for (int tc = 1; tc <= t; tc++) {
        int len;
        string a, b;
        cin >> len >> a >> b;
        for (int i = 0; i < len; i++) {
            cout << a[i];
            cout << b[i];
        }
        cout << endl;
    }
    return 0;
}







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

int main(){
  char str[1001];
  
  while(1){
   cin >> str ;
   if ( str[0] == '0') break;
   int sum = 0;
   for ( int i = 0; i < strlen(str); i++ ){
     sum += (str[i]-'0');
   }
  
   cout << sum << endl;
}

return 0;
}


Measured memory_bytes: 3108
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x == 3 | x == 5 | x == 7){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value << '\n';
    });
  return os;
}

void solve(void)
{
  using std::vector;
  using std::pair;
  using std::cin;

  ui N{}; cin >> N;
  typedef pair<ui, ull> Branch; // 辺
  typedef vector<Branch> BranchList; // ノードが持つ辺s
  typedef vector<BranchList> Node; // ノードリスト

  Node nodes(N);
  vector<int> nodes_color(N, -1); // 求めたいあれ。
  rep(0, N - 1)
  {
    ui node1{}, node2{};
    ull weight{};
    cin >> node1 >> node2 >> weight;
    --node1; --node2;

    nodes[node1].push_back(Branch{ node2, weight });
    nodes[node2].push_back(Branch{ node1, weight });
  }

  std::queue<ui> mqueue; // 処理用

  auto push_next = [&nodes_color, &mqueue](BranchList ls, int current_color){
    boost::for_each(ls, [&nodes_color, &mqueue, &current_color](Branch bc) {
      if (nodes_color[bc.first] != -1) return; // 決定済ノードはスルー

      if (bc.second % 2)
        nodes_color[bc.first] = !current_color; // 奇数距離
      else
        nodes_color[bc.first] = current_color; // 偶数距離

      mqueue.push(bc.first);
      });
  };

  // 初期条件
  nodes_color[0] = 0;
  push_next(nodes[0], 0);

  while (!mqueue.empty())
  {
    ui it = mqueue.front();
    mqueue.pop();
    push_next(nodes[it], nodes_color[it]);
  }

  using std::cout;
  cout << nodes_color << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 8320
s = input()
j = 'Yes'
for i in range(len(s)):
  if (s[i] == 'U') or (s[i] == 'D'):
    continue
  if (i % 2) == 0:
    if (s[i] == 'R'):
      continue
    else:
      j = 'No'
      break
  if (i % 2) == 1:
    if (s[i] == 'L'):
      continue
    else:
      j = 'No'
      break
print(j)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


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

int main() {
  int a, b, c , d;
  //string op;
  cin >> a >> b >> c >>d;
  int L = a + b;
  int R = c + d;
  if (L == R){
    cout << "Balanced" <<endl;
  }
  else if (L > R){
    cout << "Left" << endl;
  }
  else if (L < R){
    cout << "Right" <<endl;
  }
}

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

int main(){
 int N,M;
  cin>>N>>M;
  
  int a[50],b[50],c[50],d[50];
  for(int i=0; i<N; i++){ cin>>a[i]>>b[i]; }
  for(int i=0; i<M; i++){ cin>>c[i]>>d[i]; }
 
  for(int i=0; i<N; i++){
  int ans=0;
    for(int j=0; j<M; j++){
    if(abs(a[i]-c[j])+abs(b[i]-d[j])
       <abs(a[i]-c[ans])+abs(b[i]-d[ans])){ans=j;}
    }  //座標c[ans],d[ans]の起点に対してそれより距離が短い組み合わせを
       //ループして全検索すればans=jは最小値を指す。
    cout<<ans+1<<endl; }// プログラムはa[0]で0から始まるから、+1して
                        //実際の位置を表示。
  
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> mochi(N);
  for(int i=0; i<N; i++){
    int d;
    cin >> d;
    mochi.at(i) = d;
  }
  
  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(), mochi.end());
  
  int step = 1;//もちの段数
  
  for(int i=1; i<N; i++){//２つ目の要素から比較を開始
    
    if ( mochi.at(i)<mochi.at(i-1) ){
      step++;
    }
  }
  
  cout << step << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __mr__
    #include "prettyprint.hpp"
#else
    #define endl                    '\n'
#endif
#define len(x)                      (uint)(x).size()
#define int                         int32_t
#define uint                        uint32_t
#define ulong                       uint64_t
#define long                        int64_t
#define maxof(x)                    numeric_limits<x>::max()
#define minof(x)                    numeric_limits<x>::min()
using namespace std;
const ulong mod = 1000000007ul;

struct unionfind {
    size_t length;
    uint32_t *roots, *ranks;
    unionfind(size_t n) {
        length = n;
        roots = new uint32_t[n];
        ranks = new uint32_t[n];
        for (int i = 0; i < n; ++i) {
            roots[i] = i;
            ranks[i] = 0;
        }
    }
    void connect(uint32_t a, uint32_t b) {
        uint32_t aroot = find_root(a);
        uint32_t broot = find_root(b);
        if(aroot == broot)
            return;
        if(ranks[aroot] < ranks[broot]) {
            roots[aroot] = broot;
        } else if (ranks[aroot] > ranks[broot]) {
            roots[broot] = aroot;
        } else {
            roots[broot] = aroot;
            ++ranks[aroot];
        }
    }
    bool is_connected(uint32_t a, uint32_t b) {
        return find_root(a) == find_root(b);
    }
    int32_t find_root(uint32_t a) {
        while(roots[a] != a) {
            roots[a] = roots[roots[a]];
            a = roots[a];
        }
        return a;
    }
};


int main(int argc, char const *argv[]) {
    #ifndef __mr__
        ios::sync_with_stdio(0);cin.tie(0);
    #endif
    int n, k, l;
    cin >> n >> k >> l;
    unionfind roads(n);
    vector<int> us;
    vector<int> vs;
    for (int i = 0; i < k; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        us.push_back(u);
        vs.push_back(v);
        roads.connect(u, v);
    }
    unionfind railways(n);
    unionfind both(n);
    for (int i = 0; i < l; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        us.push_back(u);
        vs.push_back(v);
        railways.connect(u, v);
    }
    for (int i = 0; i < k + l; ++i) {
        if (roads.is_connected(us[i], vs[i]) && railways.is_connected(us[i], vs[i]))
            both.connect(us[i], vs[i]);
    }

    map<int, set<int>> roads_groups;
    map<int, set<int>> railways_groups;
    for (int i = 0; i < n; ++i) {
        roads_groups[roads.find_root(i)].insert(i);
        railways_groups[railways.find_root(i)].insert(i);
    }
//    cout << roads_groups << endl;
//    cout << railways_groups << endl;
    map<pair<int, int>, int> intersected_sets;
    for (int i = 0; i < n; ++i) {
        ++intersected_sets[make_pair(roads.find_root(i), railways.find_root(i))];
    }
    for (int i = 0; i < n; ++i) {
        cout << intersected_sets[make_pair(roads.find_root(i), railways.find_root(i))] << ' ';
    }
    cout << endl;

    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    int cnt = 0;
    map<string,int> mp;
    REP(i, n){
        string s;
        cin >> s;
        mp[s]++;
        chmax(cnt, mp[s]);
    }
    for(const auto& i : mp){
        if(i.second == cnt) {
            cout << i.first << '\n';
        }
    }
    return 0;
}


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

P ab(int n){
  int a = n%10;
  int b = n%10;
  while(n/10 != 0){
    n = n/10;
    a = n;
  }
  P p(a,b);
  return p;
}

int main(){
  int n;
  cin >> n;
  vector<P> ans(n);
  rep(i,n){
    ans[i-1] = ab(i);
  }
  map<P,int> count;
  rep(i,9){
    rep(j,9){
      P pair1(i,j);
      count[pair1] = 0;
    }
  }
  //<1,1>~<9,9>の数を数える
  rep(i,n){
    count[ans[i-1]]++;
  }
  ll answer = 0;
  rep(i,9){
    rep(j,9){
      P pair1(i,j);
      P pair2(j,i);
      if (i==j)
      	answer = answer + count.at(pair1)*count.at(pair2);
      else
        answer = answer + count.at(pair1)*count.at(pair2);
    }
  }
  cout << answer << endl;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e3 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
 
}

void solve()
{
	vector<string> v = {"AC", "WA", "TLE", "RE"};
	vector<int> cnt(4, 0);
	int n;
	cin >> n;
	rep(i, n){
		string x;
		cin >> x;
		rep(j, sz(v)){
			if(v[j] == x) cnt[j]++;
		}
	}
	rep(i, 4){
		cout << v[i] << " x " << cnt[i] << "\n";
	}
}	

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();
    for (int i = B - A + 1; i <= B + A - 1; i++) {
      System.out.println(i);
    }
  }
}


Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.math.BigInteger;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		long[] NM = readLineLong();
		BigInteger X = new BigInteger(NM[0]+"");
		BigInteger X101 = new BigInteger("101");
		BigInteger X100 = new BigInteger("100");
		long ans = 0;
		for(BigInteger have=X100;have.compareTo(X)<0;ans++) {
			have = have.multiply(X101).divide(X100);
		}
		
		print(ans);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static long[] readLineLong(){
		try{
			String[] s = readLine();
			long[] ints = new long[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Long.parseLong(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


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

int main() {
  int n,k;
  cin >>n>>k;
  int kazu=1;
  for(int i=0;i<n;i++){
    if(kazu+k>kazu*2)kazu*=2;
    else kazu+=k;
  }
  cout<<kazu<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,i,j,flag,t;
    char s[200],ans[200],tmp[81]={0},ch;
//while(gets(s)!=NULL){
/*while(scanf("%c",ch)!=NULL){
    s[0]=ch;
    i=1;
    while(1){
        scanf("%c",&ch);
        if(ch=='\n'){
            s[i]='\0';
            break;
        }else{
            s[i]=ch;
        }
        i++;
    }*/
    gets(s);
        for(j=0;s[j]!='\0';j++){
            if('a'<=s[j]&&s[j]<='z'){
            	ans[j]=s[j]-'a'+'A';
            }else{
                ans[j]=s[j];
            }
        }
        ans[j]='\0';
        printf("%s\n",ans);
    
//}
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int a[2*maxn];

int fen[2*maxn];

void add(int ind, int val){
	for(int i=ind;i<=(200000);i+=(i&(-i))){
		fen[i]+=val;
	}
}

int sum(int ind){
	int res = 0;
	for(int i=ind;i>0;i-=(i&(-i))){
		res+=fen[i];
	}
	return res;
}
int32_t main(){
	fastio();
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	bool ok = true;
	while(k>0 and ok){
		ok = false;
		for(int i=1;i<=n;i++){
			fen[i] = 0;
		}
		for(int i=1;i<=n;i++){
			add(max(1ll,i-a[i]),1);
			add(min((int)2e5+1,i+a[i]+1),-1);
		}

		for(int i=1;i<=n;i++){
			a[i]=sum(i);
			if(a[i]<n)ok = true;	
		}
		k--;
	}
	//cout<<k<<" ";
	for(int i=1;i<=n;i++){
		a[i]  = sum(i);
		if(a[i]>n) a[i] = n;
		cout<<a[i]<<" ";
	}
}

Measured memory_bytes: 6732
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int eight = scan.nextInt(), ten = scan.nextInt();
		
		for(int i = ten * 10; i < ten * 10 + 10; i++) {
			if((int)(i * 0.08) == eight) {
				System.out.println(i);
				System.exit(0);
				
			}
			
		}
		
		System.out.println(-1);
		
	}
	
}





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



int main() { 
  int n,m;
  cin >>n>>m;
  int p[100010],y[100010];
  vector<int> id[100010];
  for(int i=0;i<m;i++){
    cin >> p[i]>>y[i];
    id[p[i]].push_back(y[i]);
  }

  for(int i=0;i<n;i++){
    sort(id[i+1].begin(),id[i+1].end());
  }
  for(int i=0;i<m;i++){
    printf("%06d",p[i]);
    auto itr = lower_bound(id[p[i]].begin(),id[p[i]].end(),y[i]);
    printf("%06d",itr-id[p[i]].begin()+1);
    cout << endl;
  }
}


Measured memory_bytes: 7808
a,b=input().split()
List = []
for i in range(len(b)):
  x = b[i]
  List.append(x)
  
for i in range(len(a)):
  x = a[i]
  List.append(x)
  
p=List[0]
for i in range(1,len(List)):
    p=p+List[i]
    
print(p)

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

using namespace std;
const int MAXSIZE = 1000000007;
int h, w;
int dp[10005][10005];
char c[10005][10005];

int main() {
    cin >> h >> w;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> c[i][j];
        }
        getchar();
    }
    memset(dp, 0, sizeof(dp));
    dp[1][1] = 1;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (i == 1 && j == 1) continue;
            if (c[i][j] == '.') {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%MAXSIZE;
            }
        }
    }
    cout<<dp[h][w]%MAXSIZE<<endl;
    return 0;
}

Measured memory_bytes: 402048
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = LI()
    ans = 0
    for i in L:
        ans += i-1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back

const int N = 1e5;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
int main(){
  int n;
  scanf("%d", &n);
  int now = 1;
  int bisa = 1;
  for(int i = 0;i < n; ++i){
    int x;
    scanf("%d", &x);
    now *= 3;
    if(!(x & 1)){
      bisa <<= 1;
    }
  }
  printf("%d\n", now - bisa);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void)
{
    int N,T,c,t;

    cin >> N >> T;

    int cmin = 1001;
    int count = 0;
    for (int i = 1; i <= N; i++) {
        cin >> c >> t;
        if (t <= T) {
            count++;
            if (cmin > c) {
                cmin = c;
            }
        }
    }

    if (count == 0) {
        cout << "TLE" << endl;
    }
    else {
        cout << cmin << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 1e9+7;
const int SQ =320;
const long double EPS = 1e-7;
int cntExtra[505];
int cntNeed[505];
int n;
ii x[505];
int take[505*505];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  cin >> n;
  f(i,1,n+1){
    cin >> x[i].F;  x[i].S=i;
    take[x[i].F]=i;
    cntNeed[i]=i-1;
  }

  sort(x+1,x+n+1);
  vector<int> v;
  for(int j = 1; j <= n * n; j++){
    if(!take[j]){
      bool f = false;
      f(i,1,n+1){
        if(cntNeed[x[i].S]){
          cntNeed[x[i].S]--;
          v.push_back(x[i].S);
          f=true;
          break;
        }
      }
      if(!f){
        for(int j = 1; j <= n; j++)
        if(cntExtra[j]){
          f=true;
          v.push_back(j);
          cntExtra[j]--;
          break;
        }
        if(!f){
          cout << "No\n"; return 0;
        }
      }

    } else {
      if(cntNeed[take[j]]){
        cout << "No\n"; return 0;
      }
      v.push_back(take[j]);
      cntExtra[take[j]] += n - take[j];
    }
  }
  cout << "Yes\n";
  for(auto x:v)cout << x << ' ';

  return 0;
}


Measured memory_bytes: 4720
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

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

int size = n.size();

  int ans = 0;
  
for(int i = 0;i<size;i++){
     

char ch = n[size-1];

n.erase(size-1);
  
std::string str(1, ch); 
  
n=str+n;
  
//n.replace(size-1, 1, strtemp);
  
  if(n==m){
    ans = 1;
    
    break;
    
  }
  
}
 if(ans==1){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
   
  
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=INF; cin>>n;
    vector<ll> a(n,0),sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    rep(i,n-1){
        ans=min(abs(sum[i+1]-(sum[n]-sum[i+1])),ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
n = int(input())
c = {i: {j: 0 for j in range(1, 10)} for i in range(1, 10)}
for i in range(1, n + 1):
    i = str(i)
    if i[-1] == "0":
        continue
    j, k = map(int, [i[0], i[-1]])
    c[j][k] += 1

result = 0
for i in range(1, 10):
    for j in range(1, 10):
        result += c[i][j] * c[j][i]

print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  int ans = 0;
  vi v(n), c(n);
  rep(i, n) {
    cin >> v[i];
  }
  rep(i, n) {
    cin >> c[i];
  }
  rep(i, n) {
    if (v[i]-c[i] > 0) {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string S; cin >> S;
  int ans = 0;
  for (auto i = S.begin(); i != S.end(); i++) {
    int length = 0;
    for (auto j = i; j != S.end(); j++) {
      if (*j=='A'||*j=='T'||*j=='G'||*j=='C') length++;
      else break;
    }
    if (length > ans) ans = length;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
int h,w;
cin >> h >> w;
vector<string> s(h);
for(int i = 0; i < h; i++) cin >> s[i];
for(int i = 0; i < h; i++) {
  for(int j = 0; j < w; j++) {
    if(s[i][j]=='#') continue;
    int n = 0;
    for(int d = -1; d <= 1; d++) for(int e = -1; e <= 1; e++) {
      int x,y; x = i+d; y = j+e; if(x<0||x>=h||y<0||y>=w) continue; if(s[x][y]=='#') n++;
    }
    s[i][j] = '0'+n;
  }
}
for(int i = 0; i < h; i++) cout << s[i] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <string>

void insert(std::list<int> &lst);
void del(std::list<int> &lst);
void deleteFirst(std::list<int> &lst);
void deleteLast(std::list<int> &lst);
void command(std::list<int> &lst, std::string str);
void print(std::list<int> &lst);

int main(){
    int n;
    std::string str;
    std::list<int> lst;
    std::cin >> n;
    for(int i=0;i<n;i++){
        std::cin >> str;
        command(lst,str);
    }
    print(lst);
}

void insert(std::list<int> &lst){
    int x;
    std::cin >> x;
    lst.push_front(x);
}
void del(std::list<int> &lst){
    std::list<int>::iterator itr;
    int x;
    std::cin >> x;
    for(itr=lst.begin();itr!=lst.end();++itr){
        if(*itr==x){
            lst.erase(itr);
            break;
        }
    }
}
void deleteFirst(std::list<int> &lst){
    lst.pop_front();
}
void deleteLast(std::list<int> &lst){
    lst.pop_back();
}
void command(std::list<int> &lst, std::string str){
    if(str=="insert"){
        insert(lst);
    }else if(str=="delete"){
        del(lst);
    }else if(str=="deleteFirst"){
        deleteFirst(lst);
    }else{
        deleteLast(lst);
    }
}

void print(std::list<int> &lst){
    std::list<int>::iterator itr;
    std::list<int>::iterator itr2 = lst.end();
    itr2--;
    for(itr = lst.begin();itr != lst.end();++itr){
        std::cout << *itr;
        if(itr!=itr2){
            std::cout << " ";
        }
    }
    std::cout << "\n";
}


Measured memory_bytes: 34380
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String t = in.nextLine();
		System.out.println(check(s, t));
	}
	public static String check(String s, String t){
		if(s.length() == 0 || t.length() == 0) return "";
		int m = s.length();
		int n = t.length();
		int[][] dp = new int[m+1][n+1];
		for (int i = 1; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				if(s.charAt(i-1) == t.charAt(j-1)) dp[i][j] = dp[i-1][j-1] + 1;
				else dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
			}
		}
		int i = m, j = n;
		StringBuilder sb = new StringBuilder();
		while(i >= 1 && j >= 1){
			if(dp[i][j] == dp[i][j-1]) j--;
			else if(dp[i][j] == dp[i-1][j]) i--;
			else {
				sb.append(s.charAt(i-1));
				i--;
				j--;
			}
		}
		return sb.reverse().toString();
	}
}

Measured memory_bytes: 83012
n, q = map(int, input().split())
que = []
for i in range(n):
    p, t = map(str, input().split())
    que.append([p, int(t)])
total = 0
while que != []:
    pt = que.pop(0)
    if pt[1] <= q:
        total += pt[1]
        print(pt[0], total)
    else:
        total += q
        que.append([pt[0], pt[1]-q])


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt H, W, M, x[300000], y[300000];
	cin >> H >> W >> M;
	map<lnt, lnt> mpx, mpy;
	REP(i, M){
		cin >> x[i] >> y[i];
		mpx[x[i]]++;
		mpy[y[i]]++;
	}
	set<lnt> stx, sty;
	lnt mxx = -1, mxy = -1;
	for(auto i: mpx){
		chmax(mxx, i.second);
	}
	for(auto i: mpx){
		if(i.second == mxx) stx.insert(i.first);
	}
	for(auto i: mpy){
		chmax(mxy, i.second);
	}
	for(auto i: mpy){
		if(i.second == mxy) sty.insert(i.first);
	}

	lnt cnt = 0, num = (lnt)stx.size() * (lnt)sty.size();
	REP(i, M){
		if(stx.count(x[i]) and sty.count(y[i])) cnt++;
	}
	if(cnt >= num) cout << mxx + mxy - 1 << ln;
	else cout << mxx + mxy << ln;
}

Measured memory_bytes: 73896