akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace KPC2019
{
    class C
    {
        static void Main(string[] args)
        {
            //input
            long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] B = Console.ReadLine().Split().Select(long.Parse).ToArray();

            //Aの総和がBよりもどうなっているか
            if (A.Sum() < B.Sum())
            {
                //小さい
                ///-1を出力
                Console.WriteLine(-1); return;
            }
            else
            {
                //大きい
                ////メイン処理を書く
                ////N繰り返して、BとAの差分を調べる O(N)
                ////aとbのリストを作成する
                List<long> a = new List<long>();
                List<long> b = new List<long>();
                for (long i = 0; i < N; i++)
                {
                    if (A[i] < B[i]) b.Add(Math.Abs(B[i] - A[i])); // 不足
                    else if (B[i] < A[i]) a.Add(Math.Abs(A[i] - B[i]));  // 余り
                }

                if (b.Count == 0) { Console.WriteLine(0); return; }

                ////bの要素分繰り返す。最大でもO(N)
                a = a.OrderByDescending(x => x).ToList();
                long bsum = b.Sum();
                long asum = 0;
                for (int i = 0; i < a.Count; i++)
                {
                    asum += a[i];
                    if (bsum < asum) { Console.WriteLine(b.Count + i + 1); return; }
                }
                //Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 32352
#include<stdio.h>

void trace(int A[],int N){
int a;
for(a=0; a<N; a++){
  if(a>0) printf(" ");
     printf("%d",A[a]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
  int i,j,v;

  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A,N);
  }
}

int main(){
  int N,i,j,A[100];

  scanf("%d",&N);

  for(i=0; i<N; i++) scanf("%d",&A[i]);
  trace(A,N);
  insertionSort(A,N);

  return 0;
}




Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans = (b - (b / c)) - ((a - 1) - ((a - 1) / c));
    ans += (b - (b / d)) - ((a - 1) - ((a - 1) / d));
    long long lcm = (c * d) / __gcd(c, d);
    ans -= (b - (b / lcm)) - ((a - 1) - ((a - 1) / lcm));
    cout << ans;
}

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

int abso(int n , int j ){
	int c = n-j;
	if(c<0) c=c*-1;
	return c;
}


int main() {


	int n,suma1=0,suma2=0;
	int dif=0, difmin=9999999;
	cin>>n;
	vector<int>arr(n);
	for ( int i = 0 ; i<n ; i++){
		cin>>arr[i];
		suma2=suma2+arr[i];
	}
	 
	for(int i =0 ; i < n ; i ++){

		suma1+=arr[i];
		suma2-=arr[i];
		dif=abso(suma1,suma2);
		if(dif<difmin){
			difmin=dif;
		}
	}
	cout<<difmin;

	return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    vector<ll> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    if(a.at(0)%2==0||a.at(1)%2==0||a.at(2)%2==0){
        cout << 0 << endl;
        return 0;
    }
    stable_sort(a.begin(),a.end());
    //for(int i=0;i<3;i++)cout << a.at(i)<< endl;
    cout << a.at(0)*a.at(1) << endl;
    return 0;
}

Measured memory_bytes: 256
def solve():
    d = [int(input()) for _ in range(5)]
    d.sort(reverse=True, key=lambda a: a % 10 if a % 10 > 0 else 9)
    for i in range(4):
        d[i] = -(-d[i]//10) * 10
    print(sum(d))


if __name__ == '__main__':
    solve()


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

int N;
vector<int> A;

int main () {
  cin >> N;
  A.resize(N);
  rep(i,N) cin >> A[i];

  multiset<int> v;

  v.insert(A[0]);
  for(int i = 1; i < N; i++) {
    if(*v.begin() < A[i]) {
      auto it = v.lower_bound(A[i]);
      it--;
      v.erase(it);
    }
    v.insert(A[i]);
  }

  cout << v.size() << endl;

  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;cin>>r;
    cout<<r*r<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define BLUCK 1
#define INF 2000000000
#define NIL -1

void dijkstra(int,int);
void initializeSingleSource(int,int);
int matrix[100][100];
int d[100];
int pi[100];
int color[100];

int main(){

  int i,j,sumnode,nodenum,sumconnect,toconnect,weight;

  scanf("%d",&sumnode);

  for(i = 0; i < sumnode; i++){

    scanf("%d",&nodenum);
    scanf("%d",&sumconnect);

    for(j = 0; j < sumconnect; j++){

      scanf("%d",&toconnect);

      scanf("%d",&weight);

      matrix[i][toconnect] = weight;

    }
  }

  dijkstra(sumnode,0);

  return 0;

}


void initializeSingleSource(int sumnode, int start){

  int v;

  for(v = 0; v < sumnode; v++){

    d[v] = INF;

    pi[v] = NIL;

  }

  d[start] = 0;

}

void dijkstra(int sumnode, int start){

  int mincost,i,u,v,j;

  initializeSingleSource(sumnode,start);


  while(1){

    mincost = INF;
 
    for(i = 0; i < sumnode; i++){

      if(color[i] != BLUCK && d[i] < mincost){

	mincost = d[i];

	u = i; //?????¨????????????

      }

    }
      if(mincost == INF){

	break;

      }

      color[u] = BLUCK;

  
      for(v = 0; v < sumnode; v++){

	if(color[v] != BLUCK && matrix[u][v] != 0){

	  if(d[u] + matrix[u][v] < d[v]){

	    d[v] = matrix[u][v] + d[u];
	    pi[v] = u;

	  }

	}

      }

  }
  /*      for(i = 0; i < sumnode; i++){

	for(j = 0; j < sumnode; j++){

	printf("%d ",matrix[i][j]);

	}
	printf("\n");
	}*/


      for(i = 0; i < sumnode; i++){

	printf("%d %d\n",i,d[i]);

      }


}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int gcd(ll a, ll b){
  if(b == 0){
    return a;
  }else{
    return gcd(b,a%b);
  }
}

vector<ll> sieve(ll n){
  int p = 0;
  vector<bool> is_prime(n+1,true);
  vector<ll> res;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      res.push_back(i);
      for(int j=2*i;j<=n;j+=i){
        is_prime[j] = false;
      }
    }
  }
  return res;
}

vector<ll> divisor(ll n){
  vector<ll> list;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      list.push_back(i);
      if(n/i != i){
        list.push_back(n/i);
      }
    }
  }
  return list;
}

umap<int,int> prime_factor(ll n){
  umap<int,int> fac;
  for(int i=2;i*i<=n;i+=2){
    if(n%i == 0){
      int count = 0;
      while(n%i == 0){
        count++;
        n /= i;
      }
      fac[i] = count;
    }
  }
  if(n!=1)fac[n] = 1;
  return fac;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int x;
  cin >> x;
  if(x >= 30){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

//NodePointer listSearch(int key){
//  /* your code */
//}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->next->prev = t->prev;
  t->prev->next = t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer x = nil->next;

  for(x = nil->next; x != nil; x = x->next) {
    if (x->key == key) {
      if (x->next == nil)
        deleteLast();
      else if (x->prev == nil)
        deleteFirst();
      else 
        deleteNode(x);
      break;
    }
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  x->prev = nil;

  nil->next->prev = x;
  nil->next = x;

}


int main(void)
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      size++;
    } else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key);
        nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33108
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
  int a[10010]={};
  long long int n,i,sum=0,max=0,min=0,temp=0,j;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j-1]>a[j]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
      }
    }
  }
  max=a[n-1];
  min=a[0];
  cout<<min<<" "<<max<<" "<<sum<<endl;
  return 0;
}

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

int main() {
  while(true) {
    int D, E; cin >> D >> E;
    if(D == 0 && E == 0) break;
    double ans = 1e9;
    for(int y = 0; y <= D; ++y) {
      for(int x = 0; x <= D; ++x) {
        if(x + y == D) {
          ans = min(ans, abs(E - sqrt(x*x + y*y)));
        }
      }
    }
    cout.setf(ios::fixed);
    cout.precision(3);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, a, b, c, x;
    while(cin >> n >> a >> b >> c >> x, n|a|b|c|x){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int cur = 0, ans = 0;
        if(x == v[cur]) cur++;
        while(ans <= 10000 && cur < n){
            x = (a*x+b)%c;
            if(x == v[cur]) cur++;
            ans++;
        }
        cout << (ans <= 10000 ? ans : -1) << "\n";
    }
    return 0;
}



Measured memory_bytes: 3108
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [0] * (N + 1)
    for a in A:
        B[a] += 1

    total = 0
    for b in B:
        total += b * (b - 1) // 2

    ans = [0] * N
    for i, a in enumerate(A):
        ans[i] = total - (B[a] - 1)

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 117552
import java.util.*;

@SuppressWarnings("unused")
public class Main {

  private static void solve() {
    int s = ni();
    int mod = (int) 1e9 + 7;

    long[][] dp = new long[s + 1][s + 1];
    dp[0][0] = 1;
    long ret = 0; 
    for (int i = 0; i < s; i++) {
      for (int j = 0; j + 3 <= s; j++) {
        dp[i + 1][j + 3] += (j == 0 ? 0 : dp[i + 1][j + 2]) + dp[i][j];
        dp[i + 1][j + 3] %= mod;
      }
      ret += dp[i][s];
      ret %= mod;
    }

    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int search(int);

int n, q, i, c=0;
int S[100000];
int T[50000];

int main(){
 
  scanf("%d",&n);
  if( n>100000 ) exit(1);

  for( i=0 ; i<n ; i++ ){
    scanf("%d",&S[i]);
    if( S[i]<0 || 1000000000<S[i] ) exit(2);
  }
  
  scanf("%d",&q);
  if( q>50000 ) exit(3);

  for( i=0 ; i<q ; i++ ){
    scanf("%d",&T[i]);
    if( T[i]<0 || 1000000000<T[i] ) exit(4);
  }

  for( i=0 ; i<q ; i++ ){    
    if(search(T[i]) == 1){
      c++;
    }
  }

  printf("%d\n",c);
  return 0;
}

int search(int x){
  int right = n, left = 0;
  int middle = (right+left)/2;


  while( left<right ){
    middle = (left+right)/2;

    if( x == S[middle] ) return 1;
    if( x > S[middle] ) left = middle+1;
    else if( x < S[middle] ) right = middle;
  }
  

  return 0;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 mod = (i64)1e9 + 7;
i64 n, k;
const i64 maxn = 2 * (i64)1e5 + 1000;
i64 fac[maxn],inv[maxn];
i64 pow_mod(i64 a,i64 n)
{
    i64 ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(i64 i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
i64 CC(i64 x, i64 y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFIN
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> k;
    i64 noPeople = min(n - 1, k);
    i64 ans = 1;
    //cout << CC(2, )
    for (i64 i = 1; i <= noPeople; ++i) {
        ans = (ans + (CC(n, i) * CC(n - 1, n - i - 1)) % mod) % mod;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

void solve()
{
	unsigned long long int num;
	while(cin >> num)
	{
		int a[10][10];
		for(int i = 9; i >= 0; --i)
		{
			a[0][i] = num % 10;
			num /= 10;
		}
		for(int i = 0; i < 9; ++i)
		{
			for(int j = 0; j < 9 - i; ++j)
			{
				a[i + 1][j] = (a[i][j] + a[i][j + 1]) % 10;
			}
		}
		cout << a[9][0] << endl;
	}
}

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

Measured memory_bytes: 1156
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int N;
    cin >> N;
    vi A(N);
    vector<ll> R(N), L(N);
    rep(i, N) {
        cin >> A[i];
        if(i+1-A[i] > 1){
            R[i+1-A[i]]++;
        }
        if(i+1+A[i] < N){
            L[i+1+A[i]]++;
        }
    }
    ll counter=0LL;
    rep(i, N) {
        counter += R[i]*L[i];
    }
    cout << counter << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    ll w;
    cin >> n >> w;
    vector<vector<ll>> vals(4, {0});
    ll w1 = 0;
    for (int i=0; i<n; ++i) {
        int x, y;
        cin >> x >> y;
        if (i == 0) {
            w1 = x;
        }
        vals.at(x-w1).push_back(y);
    }
    for (int i=0; i<4; ++i) sort(vals.at(i).begin(), vals.at(i).end());
    for (int i=0; i<4; ++i) reverse(vals.at(i).begin()+1, vals.at(i).end());
    int l0 = (int)vals.at(0).size();
    int l1 = (int)vals.at(1).size();
    int l2 = (int)vals.at(2).size();
    int l3 = (int)vals.at(3).size();
    for (int i=1; i<l0; ++i) vals.at(0).at(i) += vals.at(0).at(i-1);
    for (int i=1; i<l1; ++i) vals.at(1).at(i) += vals.at(1).at(i-1);
    for (int i=1; i<l2; ++i) vals.at(2).at(i) += vals.at(2).at(i-1);
    for (int i=1; i<l3; ++i) vals.at(3).at(i) += vals.at(3).at(i-1);
    ll res = 0;
    for (int i=0; i<l0; ++i) {
        for (int j=0; j<l1; ++j) {
            for (int k=0; k<l2; ++k) {
                for (int l=0; l<l3; ++l) {
                    if (w1 * (i+j+k+l) + j + 2*k + 3*l <= w) {
                        chmax(res, vals.at(0).at(i)+vals.at(1).at(j)+vals.at(2).at(k)+vals.at(3).at(l));
                    }
                }
            }
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.equals("A")) {
			System.out.println("T");
		}
		else if(S.equals("T")) {
			System.out.println("A");
		}
		else if(S.equals("C")) {
			System.out.println("G");
		}
		else {
			System.out.println("C");
		}
    }

}

Measured memory_bytes: 21076
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  int y2 = y/2;
  if(((y&1)==0) && (y2>=x) && (y2<=x*2)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

constexpr int MAX_H = 2000;
constexpr int MAX_W = 2000;

char grid[MAX_H][MAX_W+1];
int L[MAX_H][MAX_W];
int R[MAX_H][MAX_W];
int U[MAX_H][MAX_W];
int D[MAX_H][MAX_W];

int main() {
  int H, W;
  scanf("%d%d", &H, &W);
  for (int i{}; i < H; ++i) {
    scanf("%s", grid[i]);
  }

  for (int i{}; i < H; ++i) {
    for (int j{}; j < W; ++j) {
      if (grid[i][j] == '#') {
        L[i][j] = 0;
      } else {
        L[i][j] = (j == 0 ? 1 : L[i][j-1] + 1);
      }
    }
  }
  for (int i{}; i < H; ++i) {
    for (int j{W-1}; j >= 0; --j) {
      if (grid[i][j] == '#') {
        R[i][j] = 0;
      } else {
        R[i][j] = (j == W-1 ? 1 : R[i][j+1] + 1);
      }
    }
  }
  for (int j{}; j < W; ++j) {
    for (int i{}; i < H; ++i) {
      if (grid[i][j] == '#') {
        U[i][j] = 0;
      } else {
        U[i][j] = (i == 0 ? 1 : U[i-1][j] + 1);
      }
    }
  }
  for (int j{}; j < W; ++j) {
    for (int i{H-1}; i >= 0; --i) {
      if (grid[i][j] == '#') {
        D[i][j] = 0;
      } else {
        D[i][j] = (i == H-1 ? 1 : D[i+1][j] + 1);
      }
    }
  }

  int  ans{};
  for (int i{}; i < H; ++i) {
    for (int j{}; j < W; ++j) {
      if (grid[i][j] != '#') {
        int val = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
        if (ans < val) ans = val;
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 66688
from collections import deque
n = int(input())
Graph = [[] for _ in range(n)]
edge = {}
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    Graph[a].append(b)
    Graph[b].append(a)
    edge[1000*a+b] = i
    edge[1000*b+a] = i

data = []

def f(u,v):
    prev = [u]*n
    used = [False]*n
    que = deque([u])
    while que:
        now = que.popleft()
        for nex_v in Graph[now]:
            if used[nex_v]:continue
            prev[nex_v] = now
            used[nex_v] = True
            que.append(nex_v)
            if nex_v == v:
                break
    path = [v]
    path_edge = []
    t = v
    while prev[t] != u:
        path.append(prev[t])
        path_edge.append(edge[1000*t+prev[t]])
        t = prev[t]
    path_edge.append(edge[1000*t+prev[t]])
    path.append(u)
    return path_edge

m = int(input())
for i in range(m):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    path = f(u,v)
    data.append(path[::-1])

#print(data)
ans = 2**(n-1)
for i in range(1,1<<m):
    now = []
    for j in range(m):
        if i>>j&1:
            now.append(j)

    this = [True]*(n-1)
    for j in now:
        for k in data[j]:
            this[k] = False

    ponta = 1
    q = 0
    for j in range(n-1):
        if this[j]:
            ponta *= 2
            q += 1

    if len(now)%2 == 0:
        ans += ponta
    else:
        ans -= ponta

print(ans)

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

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;

    vector<vector<int>> graph(n, vector<int>(0));
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
    }

    vector<int> counter(n, 0);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        counter[p - 1] += x;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < static_cast<int>(graph[i].size()); j++) {
            counter[graph[i][j]] += counter[i];
        }
    }

    cout << counter[0];
    for (int i = 1; i < n; i++) {
        cout << " " << counter[i];
    }
    cout << endl;
}


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

#define DEBUG

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;

const int MOD = 1000000007;
const double PI=acos(-1.0);

// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;

// 繰り返し
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep_(i,n) for(int i=0;i<(int)(n-1);i++)
#define rep__(i,n) for(int i=n-1;i>=0;i--)

// メモリ関連
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define MEMSET(v,h) memset((v),h,sizeof(h)

// 最大値と最小値を更新する
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// 素数判定
bool isPrime(int n){if(n<2)return false;else if(n==2)return true;else if(n%2==0)return false;double sqrtNum=sqrt(n);for(int i=3;i<=sqrtNum;i+=2)if(n%i==0)return false;return true;}

// ソート
template<class T>vector<T>sortVector(vector<T>v,bool b=true){if(b)sort(v.begin(),v.end());else sort(v.begin(),v.end(),greater<T>());return v;}

// Z-Algorithm O(|S|)
vector<int>z_algorithm(string s){vector<int>a(s.length());a[0]=s.size();for(ulint i=1,j=0,k;i<s.size();){while(i+j<s.size()&&s[j]==s[i+j])++j;a[i]=j;k=!!j;while(i+k<s.size()&&k+a[k]<j)a[i+k]=a[k],++k;i+=k+!j;j-=k;}return a;}

bool func(string s, int i) {
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') return true;
    return false;
}

int main(void) {
    int n;
    string s;
    
    cin >> n >> s;
    
    int ans = 0;
    
    rep(i, n-2) {
        if(func(s, i)) ans++;
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i+=2){
    if(s[i]!='h'||s[i+1]!='i'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;

int main()
{
  string search_str;
  int n;
  vector<string> vec_str;
  string ring_str;
  
  cin >> search_str;
  cin >> n;
  cin.ignore();
  while (n--) {
    cin >> ring_str;
    ring_str += ring_str;
    vec_str.push_back(ring_str);
    cin.ignore();
  }

  int count = 0;
  for (int i = 0; i != vec_str.size(); i++) {
    if (vec_str.at(i).find(search_str) != string::npos) count++;
  }

  cout << count << endl;
}
    



Measured memory_bytes: 3160
from collections import*;M=lambda:map(int,input().split());n,k,l=M();d=[-1]*n;t=[-1]*n;r=range(n)
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):
  if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x)
for i in range(k+l):a,b=M();u(d if i<k else t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in r];c=Counter(p);print(*[c[p[i]]for i in r])

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

using namespace std;
using Graph=vector<vector<int>>;

void depth_firstsearch(const Graph& graph, int vertex, vector<bool>& seen, vector<int>& first_order, vector<int>& last_order, int& time) {

	first_order.at(vertex) = time++;
	seen.at(vertex) = true;

	for (int v : graph.at(vertex)) {
		if (seen.at(v)) continue;
		depth_firstsearch(graph, v, seen, first_order, last_order, time);
	}
	last_order.at(vertex) = time++;
}

int main(void) {
	int size, vnum, adjnum, temp, time;
	cin >> size;
	Graph graph(size);
	vector<bool> seen(size, false);
	vector<int> first_order(size);
	vector<int> last_order(size);

	for (int i = 0; i < size; i++) {
		cin >> vnum >> adjnum;
		for (int j = 0; j < adjnum; j++) {
			cin >> temp;
			graph.at(vnum - 1).push_back(temp - 1);
		}
	}
	time = 1;
	for (int i = 0; i < size; i++) {
		if(seen.at(i)==false) depth_firstsearch(graph, i, seen, first_order, last_order, time);
	}

	for (int i = 0; i < size; i++) {
		cout << i + 1 << " " << first_order.at(i) << " " << last_order.at(i) << endl;
	}
	return 0;
}



Measured memory_bytes: 3120
n=int(input())
hs=list(map(int,input().split()))
judge=True
for i in range(n-1):
    if hs[i]<hs[i+1]:
        hs[i+1]-=1
    elif hs[i]>hs[i+1]:
        judge=False
        break


if judge:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 63984
#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;
const ll INF = 1LL << 60;

int N, W;
vector<ll> w, v;
ll dp[110][(int)1e5 + 10];

int main() {
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    rep(i, N) cin >> w[i] >> v[i];

    rep(i, N) {
        for (int j = 0; j <= W; j++) {
            // if (j < w[i]) {
            //     dp[i + 1][j] = dp[i][j];
            // } else {
            //     // dp[i + 1][] = max(dp)
            //     dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            // }

            // dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
import math

a,b,h,m = map(int,input().split())

minitu = 360*(m/60)

hour = 360*(h/12)+(360//12)*(m/60)

kakudo = min(abs(hour-minitu),360-abs(hour-minitu))

kakudo_ra = math.radians(kakudo)

c = (a**2+b**2-2*a*b*math.cos(kakudo_ra))**0.5

print(c)

Measured memory_bytes: 62344
xs = gets.chomp.each_char.map &:to_i
(1 << 3).times do |i|
  r = xs[0]
  3.times do |j|
    if i[j] == 1
      r += xs[j+1]
    else
      r -= xs[j+1]
    end
  end
  if r == 7
    s = xs[0].to_s + 3.times.map { |j| (i[j] == 1 ? "+" : "-") + xs[j+1].to_s }.join("")
    s += "=7"
    puts s
    exit
  end
end


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const ll INF = 1e15;
int main(){

  int n;
  cin >> n;
  ll dp[n+10][3];
  rep(i,3) dp[0][i] = 0;

  FOR(i,1,n)rep(j,3) dp[i][j] = INF;

  rep(i,n){
    ll cost[3];
    rep(j,3) cin >> cost[j];

    dp[i+1][0] = max<ll>(dp[i][1] ,dp[i][2])  + cost[0];
    dp[i+1][1] = max<ll>(dp[i][0] ,dp[i][2])  + cost[1];
    dp[i+1][2] = max<ll>(dp[i][0] ,dp[i][1])  + cost[2];

  }
  ll ans = 0;
  rep(i,3) ans = max<ll>(ans,dp[n][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int pow2a = a * a;
		int pow3a = pow2a * a;
		int ans = a + pow2a + pow3a;

		System.out.println(ans);
	}
}


Measured memory_bytes: 35724
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
b = list(set(a))
ans = 0
for i in range(len(b)):
  cnt = 1
  while len(a) > 1 and a[-1] == a[-2]:
    a.pop()
    cnt += 1
  c = a.pop()
  if c <= cnt:
    ans += cnt - c
  else:
    ans += cnt
print(ans)

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e20;
const int INF = 1e9;
const double EPS = 0.000000001;
struct edge {ll to, cost; };
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VL x(n), y(n);
  REP(i, n){
    cin >> x[i] >> y[i];
  }
  ll ans = LINF;
  REP(i, n){
    REP(j, n){
      REP(a, n){
        REP(b, n){
          int count = 0;
          REP(z, n){
            if(x[z] <= x[i] && x[z] >= x[j] && y[z] <= y[a] && y[z] >= y[b]) count++;
          }
          if(count >= k) ans = min(ans, abs(x[j] - x[i]) * abs(y[b] - y[a]));
        }
      }
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  
  for(int i=0;i<31;i++){
    if(pow(K,i+1)>N && N>=pow(K,i) ){
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 4136
#
# abc057 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2
2 0
0 0
-1 0
1 0"""
        output = """2
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5"""
        output = """3
1
2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000"""
        output = """5
4
3
2
1"""
        self.assertIO(input, output)


def resolve():
    N, M = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(N)]
    C = [list(map(int, input().split())) for _ in range(M)]

    ans = []
    for s in S:
        D = float("inf")
        t = 0
        for i in range(M):
            d = abs(s[0]-C[i][0]) + abs(s[1]-C[i][1])
            if d < D:
                D = d
                t = i
        ans.append(t+1)

    for a in ans:
        print(a)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16196
#include <fstream>
#include <vector>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int SIZE = 1 << 17;

char buffer[SIZE];
int pointer = SIZE;

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    long long n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    printf("%lld\n", max((n - 2) * (b - a) + 1, 0LL));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
    int n;
    string s;

    cin >> n >> s;

    vector<int> num_E(n);

    num_E[0] = (s[0] == 'E');

    for (int i = 1; i < s.size(); i++) {
        num_E[i] = num_E[i-1] + (s[i] == 'E');
    }

    int ans = num_E[s.size()-1] - num_E[0];

    for (int i = 1; i < s.size(); i++) {
        ans = min(ans, num_E[s.size()-1] - num_E[i] - num_E[i-1] + i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(c) printf("%s\n",c?"Yes":"No");
#define pYN(c) printf("%s\n",c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    string s,ans=""; cin>>s;
    rep(i,s.size()){
        if(s[i]=='0'||s[i]=='1') {
            ans.push_back(s[i]);
        } else if(ans.size()!=0 && s[i]=='B') {
            ans.pop_back();
        }
    }
    c(ans);
}


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

int main() {
  int a, b;
  cin >> a >> b;

  int mx = max(a, b);
  for (int k = mx; k >= 0; k--) {
    if (abs(a - k) == abs(b - k)) {
      cout << k << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> qq(n+1, 0);

    rep(i, q)cin >> a[i];
    rep(i,q)qq[a[i]] += 1;
    rep(i, n+1)qq[i] -= q-k+1;
    for (int i = 1; i <= (int)(n); i++) {
        if (qq[i] < 0)cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, N2, WA;
  cin >> N;
  N2 = N;
  
  for(int i = 0; i < 9; i++){
    WA += N % 10;
    N = N /10;
  }
    
  if(N2 % WA == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> P1;
    vector<int> P2;
    vector<int> P3;
    rep(i, N) {
        int pi;
        cin >> pi;
        if (A >= pi) {
            P1.pb(pi);
        } else if (A < pi && B >= pi) {
            P2.pb(pi);
        } else {
            P3.pb(pi);
        }
    }
    int result = min(P1.size(), min(P2.size(), P3.size()));
    cout << result << endl;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int H, W, K, res = 0;
	vector<vector<bool>> m, tmp0, tmp1;

	cin >> H >> W >> K;

	m.resize(H);
	rep(i, H){
		string s;
		cin >> s;
		rep(j, W){
			m[i].push_back((s[j]=='#'));
		}
	}

	for (int biti = 0; biti < (1<<H); ++biti) {
		tmp0 = m;
		for (int i = 0; i < H; ++i) {
            if (biti & (1<<i)) { 
                rep(k, W){
					tmp0[i][k] = false;
				}
            }
        }
		tmp1 = tmp0;
		for (int bitj = 0; bitj < (1<<W); ++bitj) {
			for (int j = 0; j < W; ++j) {
				if (bitj & (1<<j)) { 
					rep(l, H){
						tmp0[l][j] = false;
					}
				}
    		}
			long long int count = 0;
			rep(p, H){
				rep(q, W){
					if(tmp0[p][q]){
						count++;
					}
				}
			}
			if(count == K){
				res++;
			}
			tmp0 = tmp1;		
		}
		
    }
	

	cout << res;

	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int maxn=2010;
int n,ans,h[maxn],a[maxn][maxn],f[maxn][maxn];
inline int read()
{
	int x=0;
	char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
	{
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return x;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<n;j++)
			a[i][j]=read();
		h[i]=1;
	}
	for(;;)
	{
		int flag=0;
		for(register int i=1;i<=n;i++)
			if(h[i]<n)
			{
				int x=a[i][h[i]];
				if(h[x]<n && a[x][h[x]]==i)
				{
					h[i]++;
					h[x]++;
					f[x][h[x]]=f[i][h[i]]=max(f[x][h[x]-1],f[i][h[i]-1])+1;
					flag=1;
				}
			}
		if(!flag)
			break;
	}
	for(register int i=1;i<=n;i++)
		if(h[i]<n)
		{
			puts("-1");
			return 0;
		}
	for(register int i=1;i<=n;i++)
		ans=max(ans,f[i][n]);
	printf("%d",ans);
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0) << endl;
}

Measured memory_bytes: 256
// Problem : A - Table Tennis Training
// Contest : AtCoder - AtCoder Grand Contest 041
// URL : https://atcoder.jp/contests/agc041/tasks/agc041_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll N,A,B;
	cin>>N>>A>>B;
	if(abs(A-B)%2==0)
	{
		cout<<abs(A-B)/2<<nl;
		return 0;
	}
	cout<<min(A-1,N-B)+1+(B-A-1)/2;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3664
N,K = map(int,input().split())
A = list(map(int,input().split()))

P = 10**9+7

ans1 = 0
ans2 = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] > A[j]:
            if i < j:
                ans1 += 1
            else:
                ans2 += 1

K1 = (K*(K+1)//2)%P
K2 = (K*(K-1)//2)%P

ans = (ans1*K1+ans2*K2)%P

print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0;i < n;i++){
        cin >> p.at(i);
    }

    vector<int> r(n);
    r = p;
    vector<int> q(n);
    sort(p.begin(),p.end());
    q = p;
    bool ans = false;
    if (r == q){
        ans = true;
    }
    for (int i = 0;i < n - 1;i++){
        for(int j = i + 1;j < n;j++){
            p = r;
            int a = p.at(i);
            p.at(i) = p.at(j);
            p.at(j) = a;

            if (p == q){
                ans = true;
                break;
            }
        }
    }
    
    if (ans){
        cout << "YES" << endl;
    }
    else { 
        cout << "NO" << endl;
    }
}    

Measured memory_bytes: 256