akhauriyash/Code-Regression huggingface dataset:
//Coded By Visnunathan

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.lang.*;

public class Main {
    // public static void main(String[] args) {
    //     FastScanner sc=new FastScanner();
    //     char[] arr = sc.next().toCharArray();
    //     int sum = 0;
    //     for(char c:arr) {
    //         sum += (c-'0');
    //     }
    //     System.out.println(sum%9==0 ? "YES":"NO");
    // }
    public static void main(String[] args) {
        FastScanner fs=new FastScanner();
        char[] line=fs.next().toCharArray();
        int sum=0;
        for (char c:line) sum+=c-'0';
        System.out.println(sum%9==0?"Yes":"No");
    }

    static final Random random=new Random();
    
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

    
}


Measured memory_bytes: 36780
#include<iostream>
#include<string>

using namespace std;

int main() {
	
	string A, B, C;
	int n, w;
	
	while( cin >> A) {
		
		if( A == "-")
		break;
		
		cin >> n;
		
		for(int i=0;i<n;i++) {
		 cin >> w;
		 
		 for(int j=w;j<A.length();j++)
		 	C.push_back(A[j]);
		 			 	
		for(int j=0;j<w;j++)
		 	C.push_back(A[j]);
		
			A = C;
			B = C;
			C.clear();
	}
			cout << B << "\n";
	}
	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int x,y;
    cin>>x>>y;
    if(y<2*x || y>4*x) {cout<<"No"<<endl;return 0;}

    for(int i=0;i<=x;i++)
    {
        if(i*2+(x-i)*4==y){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

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

    int now = 1;
    for(int i=0;i<n;i++){
        if(now * 2 > now + k){
            now += k;
        }
        else{
            now *= 2;
        }
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    h = list(map(int, input().split()))
    cost = [0 for i in range(n)]
    cost[1] = abs(h[0] - h[1])

    for i in range(2, n):
        c1 = cost[i-2] + abs(h[i-2] - h[i])
        c2 = cost[i-1] + abs(h[i-1] - h[i])
        cost[i] = c1 if c1 < c2 else c2

    print(cost[n-1])

if __name__ == "__main__":
    main()

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

    int n; cin >> n;
    int sqn = sqrt(n);
    cout << sqn * sqn << endl;

    return 0;
}


Measured memory_bytes: 256
class Priority_queue
  def initialize(max)
    @h = 0
    @a = Array.new(max+1)
    @INF = 1<<30
  end
  
  def max_heapify(i)
    l = 2*i
    r = 2*i+1
    
    if l<=@h && @a[l]>@a[i]
      largest = l
    else
      largest = i
    end
    
    if r<=@h && @a[r] > @a[largest]
      largest = r
    end
    
    if largest != i
      @a[i], @a[largest] = @a[largest], @a[i]
      max_heapify(largest)
    end
  end
  
  def extract
    if @h <1
      return -@INF
    end
    
    maxv = @a[1]
    @a[1] = @a[@h]
    @h-=1
    max_heapify(1)
    return maxv
  end
  
  def increase_key(i, key)
    if key < @a[i]
      return
    end
    
    @a[i] = key
    
    while i>1 && @a[i/2] < @a[i]
      @a[i], @a[i/2] = @a[i/2], @a[i]
      i = i/2
    end
  end
  
  def insert(key)
    @h+=1
    @a[@h] = -@INF
    increase_key(@h, key)
  end
end

q = Priority_queue.new(2000000)

while command = gets.chomp.split
  case command[0]
  when "end"
    break
  when "insert"
    q.insert(command[1].to_i)
  when "extract"
    puts q.extract
  end
end



Measured memory_bytes: 22508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf = 1e9;
const int MAX = 1e5+5;
const ll MOD = 1e9+7;
#define REP(i, n) for (int i = 0; i < (n); ++i)

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    ll a, b; cin >> a >> b;
    ll gcd = __gcd(a, b);
    ll ans = 0;
    ll lim = (int)sqrt(gcd)+1;
    for(int i=2; i<=lim; i++){
        if(gcd%i == 0){
            ans += 1;
            gcd /= i;
        }
        while(gcd%i == 0){
            gcd /=i;
        }
        if(gcd < i) break;
    }
    if(gcd > 1) ans += 1;
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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



int main(){
  int N;
  cin >> N;
  int idx = 1;
  int cnt = 0;
  rep(i,N){
    int a;
    cin >> a;
    if(a == idx) cnt++,idx++;
  }
  if(cnt == 0) cout << -1 << endl;
  else cout << N-cnt << endl;
  return 0;
}




Measured memory_bytes: 256
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll wt[110]; ll pf[110];
const int N = 1e5 + 10;
ll dp[110][N] = {};
ll knapsack(ll n, ll W) {
	for (ll i = 0; i <= n; i++) {
		for (ll w = 0; w <= W; w++) {
			if (i == 0 or w == 0) {
				dp[i][w] = 0;
			} else if (wt[i - 1] <= w) {
				dp[i][w] = max(pf[i - 1] + dp[i - 1][w - wt[i - 1]], dp[i - 1][w]);
			} else {
				dp[i][w] = dp[i - 1][w];
			}
		}
	}
	return dp[n][W];
}
int main() {

	ll n, W; cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> wt[i] >> pf[i];
	}
	cout << knapsack(n, W) << endl;
 
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n+1);
    for(int i=0; i<=n; i++)
    {
        cin >> as.at(i);
    }

    vector<ll> chotenmax(n+1); // chotenmax[i] 深さiの時に考えられる頂点の最大数
    chotenmax.at(0) = 1;
    for(int i=0; i<n; i++)
    {
        if(chotenmax.at(i) < as.at(i))
        {
            cout << "-1\n";
            return 0;
        }
        chotenmax.at(i+1) = (chotenmax.at(i) - as.at(i)) * 2;
        if(chotenmax.at(i+1) >= 1LL << 60) chotenmax.at(i+1) = 1LL << 60;
    }
    if(chotenmax.at(n) < as.back())
    {
        cout << "-1\n";
        return 0;
    }
    // for(auto ne : chotenmax) cout << ne << '\n';

    ll num = 0;
    ll ans = 0;
    for(int i=n; i>=0; i--)
    {
        num += as.at(i);
        if(chotenmax.at(i) < num) num = chotenmax.at(i);
        ans += num;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4492
#include <iostream>

int main() {
	unsigned long long int a, b, c;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;

	if (c < b || c < a) {
		std::cout << "No";
	} else if (4 * a * b < (c - a - b) * (c - a - b)) {
		std::cout << "Yes";
	} else {
		std::cout << "No";
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
// 素数列を作る
// N: 上限
// v: 出力先
void GetPrimes(int N, vector<int> &v) {
	v = vector<int>();
	int c = 1;
	while (c < N) {
		c++;
		bool flag = true;
		int d = (int)sqrt(c);
		for (int i = 0; i < v.size(); i++) {
			if (c % v[i] == 0) {
				flag = false;
				break;
			}
			if (d < v[i])
				break;
		}
		if (flag)
			v.push_back(c);
	}
}
int main() {
    const int M = 1e5 + 800;
    int Q;
    cin >> Q;
    vector<int> p_vec;
    GetPrimes(M, p_vec);
    set<int> p;
    for(auto x : p_vec) p.insert(x);
    vector<int> ans(M + 1, 0);
    for(int i = 0; i <= M; i++) {
        ans[i] = p.count(i) && p.count((i + 1) / 2);
        if(i > 0) ans[i] += ans[i - 1];
    }
    for(int q = 0; q < Q; q++) {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  string str; cin >> str;
  int size;
  size = str.size();
  
  //compute
  long long sum;
  sum = 0;
  vector<int> x(size+1);
  x[0] = 0;

  if(str.at(0) == 'B') {
     x[0] = 1;
  }

  for(int i = 1; i < size; i++) {
    if(str.at(i) == 'B') {
     x[i] = x[i - 1] + 1;
  }else if(str.at(i) == 'W'){
     x[i] = x[i - 1]; 
  }
  }


  for(int i = 1; i < size; i++) {
    if(str.at(i) == 'W') {
     sum += x[i-1];
  }
  }
 
  //output
  cout << sum << endl;
 
}


Measured memory_bytes: 4388
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    s=[0]*n
    for i in range(n):
        if i==0:
            s[i] = abs(a[i]-a[i-1])
        else:
            s[i] = k-abs(a[i]-a[i-1])
    print(min(s))

if __name__ == '__main__':
    main()



Measured memory_bytes: 78540
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
	int N;
	int[] A;
	
	public void solve() {
		N = nextInt();
		A = new int[N];
		for(int i = 0;i < N;i++){
			A[i] = nextInt();
		}
		long ans = 0;
		int i = 0;
		while(i < N){
			long sum = 0;
			while(i < N && A[i] != 0){
				sum += A[i];
				i++;
			}
			ans += sum/2;
			i++;
		}
	
		out.println(ans);
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair

using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    int b = 1;

    rep(i,m){
        b = b * 2;
    }

    cout << b * (1900 * m + 100 * (n - m)) << endl; 
        
    return 0;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun main (d x lst)
  (+ x
     (loop for i in lst
           sum (+ 1 (floor (1- d) i)))))

(let ((n (read))
      (d (read))
      (x (read)))
  (princ (main d x (read-times n))))


Measured memory_bytes: 21048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define takearr(a,n) int a[n];for(int i=0;i<n;i++)cin>>a[i]
#define rep(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define mods 1000000007

int main()
{

  int n,m;cin>>n>>m;
  char a[n][m];
  rep(i,n)rep(j,m)cin>>a[i][j];
  int ans[n][m];memset(ans,0,sizeof(ans));
  ans[0][0]=1;
  rep(i,n)
    {
    rep(j,m)
      {
      if((i==0)&&(j==0))continue;
      if(a[i][j]=='#')continue;
        if(i==0)
          {
            ans[i][j]=ans[i][j-1];
          }
        else if(j==0)
          {
            ans[i][j]=ans[i-1][j];
          }
        else
          {
            ans[i][j]=(ans[i-1][j]+ans[i][j-1])%mods;
          }

      }
    }
    cout<<ans[n-1][m-1]<<endl;
}


Measured memory_bytes: 5120
#include <stdio.h>
 
int main(){
    int n,x,count;
    while(true){
        scanf("%d %d",&n,&x);
        if(n == 0 && x == 0) break;
        count = 0;
        for(int min = 1; min < x/3 && min <= n-2;min++){
            for(int middle = min+1;middle < x - (min+middle) && middle <= n-1; middle++){
                if(x-(min+middle) <= n) count++;
            }
        }
        printf("%d\n",count);
    }
 
}


Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int x;
    cin >> x;
    
    int cnt = (x % 100) / 5;
    if((x % 100) % 5 != 0) {
        cnt++;
    }
    
    if(cnt * 100 > x) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
#include<typeinfo>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 

lli power(lli x,lli y)
{
     lli res=1;
     while(y>0)
     {
        if(y&1)res = ((res%mod)*(x%mod))%mod;
        y>>=1;
        x= ((x%mod)*(x%mod))%mod;
     }
     return res;
}

int main()
{
   
         

    fio

    int x;
    cin>>x;
    cout<<(!x);

    
    


  
    

    


  
     

    


     

     


    
      




 

return 0;}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<char>al(26);
	al = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	int N;
	cin >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	vector<int>mal(26);
	int ch = 0;
	int CH = 100;
	rep(i, 26) {
		rep(j, N) {
			rep(k, S[j].size()) {
				if (S[j][k] == al[i]) {
					ch++;
				}
			}
			CH = min(CH, ch);
			ch = 0;
		}
		mal[i] = CH;
		CH = 100;
	}
	rep(i, 26) {
		rep(j, mal[i]) {
			cout << al[i];
		}
	}
	cout << endl;
}




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

class Plogram
{
    static void Main()
    {
        var line = Console.ReadLine().Split();
        int N = int.Parse(line[0]);
        int M = int.Parse(line[1]);
        int X = int.Parse(line[2]);
        int Y = int.Parse(line[3]);

        var x = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
        var y = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();

        if(Math.Max(X,x.Max()) < Math.Min(Y, y.Min()))
        {
            Console.WriteLine("No War");
        }
        else
        {
            Console.WriteLine("War");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 != d2) {
      cnt = 0;
    } else {
      cnt++;
      if (cnt >= 3) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3608
/*
 * @Author: Kaizyn
 * @Date: 2020-04-26 17:02:29
 * @LastEditTime: 2020-04-26 17:06:05
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 2e5+7;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n, k;

inline void solve()
{
    cin >> n >> k;
    long long res = 0;
    for (int i = k; i <= n+1; ++i) {
        long long l = (0+i-1ll)*i/2,
                  r = (n+n-i+1ll)*i/2;
        res = (res+(r-l+1))%MOD;
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll dx[4]={-1,1,0,0};
  ll dy[4]={0,0,-1,1};
  ll h,w;
  cin>>h>>w;
  vector<string> v(h);
  rep(i,h){
    cin>>v[i];
  }
  vector<vector<ll>> a(h,vector<ll>(w,-1));
  queue<pair<ll,ll>> que;
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      if(v[i][j]=='#'){
        a[i][j]=0;
        que.push(pair<ll,ll>(i,j));
      }
    }
  }
  while(!que.empty()){
    auto tmp=que.front();
    que.pop();
    for(ll i=0;i<4;i++){
      ll nx=tmp.second+dx[i];
      ll ny=tmp.first+dy[i];
      if(nx<0 || w<=nx || ny<0 || h<=ny) continue;
      if(a[ny][nx]==-1){
        que.push(pair<ll,ll>(ny,nx));
        a[ny][nx]=a[tmp.first][tmp.second]+1;
      }
    }
  }
  ll ans=0;
  rep(i,h){
    rep(j,w){
      ans=max(ans,a[i][j]);
    }
  }
  cout<<ans<<endl;
}

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

int main(void){
  int n,q, ans=0;
  int ary[10000];
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> ary[i];
  cin >> q;
  for (int i=0; i<q; i++){
    int t, flg=0;
    cin >> t;
    for (int j=0; j<n; j++){
      if (ary[j]==t){
        flg = 1;
        break;
      }
    }
    ans += flg;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod=1000 * 1000 * 1000 + 7;
ll mul(ll a, ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll add(ll a, ll b)
{
	return ((a%mod)+(b%mod))%mod;
}
ll sub(ll a, ll b)
{
	return ((a%mod)-(b%mod)+mod)%mod;
}

int main() 
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	map<ll,ll> m;
	vector<ll> v,v1;
	ll s1=0,s2=0;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		v.push_back(x);
		v1.push_back(y);
	}
	sort(v.begin(),v.end());
	sort(v1.begin(),v1.end());
	reverse(v.begin(),v.end());
	if(n%2)
	{
		ll x=v[n/2];
		ll y=v1[n/2];
		x=y-x+1;
		cout<<x;
	}
	else
	{
		ll x=v[n/2]+v[(n/2)-1];
		ll y=v1[n/2]+v1[(n/2)-1];
		x=y-x+1;
		cout<<x;
	}
	
}

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

using std::pair;
using std::vector;
using std::string;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 100000;

int n, m;
bool vis[N + 5];
pii delta[N + 5];
vector <pii> G[N + 5];

void dfs(int u, pii temp) {
    if(vis[u]) return;

    vis[u] = true;
    delta[u] = temp;

    for(auto v : G[u]) {
        dfs(v.fst, mp(v.snd - temp.fst, - temp.snd));
    }
}

signed main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(m);
    for(int i = 1; i <= m; ++i) {
        static int u, v, w;
        read(u), read(v), read(w);
        G[u].pb(mp(v, w));
        G[v].pb(mp(u, w));
    }

    dfs(1, mp(0, 1));

    int x = LLONG_MIN;
    for(int i = 1; i <= n; ++i) {
        for(auto v : G[i]) {
            if(delta[v.fst].snd + delta[i].snd) {

                int tx = (v.snd - delta[v.fst].fst - delta[i].fst); 
                int ty = delta[v.fst].snd + delta[i].snd;

                if(x == LLONG_MIN) { x = tx / ty; }
                if(tx != x * ty) { puts("0"); return 0; }
            } else {
                if(delta[v.fst].fst + delta[i].fst != v.snd) { puts("0"); return 0; }
            }
        }
    }

    int l = 1, r = LLONG_MAX;
    for(int i = 1; i <= n; ++i) {
        assert(delta[i].snd == -1 || delta[i].snd == 1);
        if(delta[i].snd > 0) chkmax(l, 1 - delta[i].fst);
        if(delta[i].snd < 0) chkmin(r, delta[i].fst - 1);
    }
    if(x == LLONG_MIN) return !printf("%lld\n", (l <= r) ? r - l + 1 : 0);

    printf("%d\n", (x > 0) && (l <= x && x <= r));
    return 0;
}


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

int main() {
    string w;
    cin >> w;
    for (char c = 'a'; c <= 'z'; ++c) {
        int cnt = 0;
        rep(i, w.size()) {
            if (w[i] == c) cnt += 1;
        }
        if (cnt % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

// input
int d, g;
vector<pair<int, int>> table;

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

    cin >> d >> g;

    int p, c;
    int ans = 99999999;

    for (int i = 0; i < d; i++)
    {
        cin >> p >> c;
        table.push_back(make_pair(p, c));
    }

    for (int bit = 0; bit < (1 << d); bit++)
    {
        vector<int> pat;
        int nm = 0;

        for (int i = 0; i < d; i++)
        {
            if (bit & (1 << i))
                pat.push_back(i);
            else
                nm = max(nm, i);
        }

        int count = 0;
        int total = 0;

        for (int value : pat)
        {
            total += (value + 1) * 100 * table[value].first + table[value].second;
            count += table[value].first;
        }

        if (total + table[nm].first * 100 * (nm + 1) < g)
            continue;

        while (total < g)
        {
            total += (nm + 1) * 100;
            count++;
        }

        if (total >= g)
            ans = min(ans, count);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N],b[N],c[N],fa[N],len,nw=0,ans=0;
map<int,int>vis;bool f__k[N];
int find(int x)
{return fa[x]==x?x:fa[x]=find(fa[x]);}
void mg(int x,int y)
{
	if(find(x)!=find(y))
		fa[find(x)]=find(y),f__k[find(y)]=1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),vis[a[i]]++,nw^=a[i];
	vis[nw]++,a[n+1]=nw,nw=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]),vis[b[i]]--,nw^=b[i];
		if(vis[b[i]]<0)return puts("-1"),0;
	}
	b[++n]=nw;
	for(int i=1;i<=n;i++)c[i]=a[i];
	sort(c+1,c+n+1);
	len=unique(c+1,c+n+1)-c-1;
	for(int i=1;i<=n;i++)
		a[i]=lower_bound(c+1,c+len+1,a[i])-c;
	for(int i=1;i<=n;i++)
		b[i]=lower_bound(c+1,c+len+1,b[i])-c;
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=b[i])
		{
			if(i<n)ans++;
			mg(a[i],b[i]);
		}
	}
	if(!ans)return puts("0"),0;
	f__k[a[n]]=f__k[b[n]]=1;
	for(int i=1;i<=len;i++)
		if(fa[i]==i&&f__k[i])ans++;
	cout<<ans-1;	
}

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

using namespace std;

int main()
{
  string s;
   cin>>s;
   long long res=0;
   for(long i=0;i<s.length();i++){
       res+=s[i]-'0';
   }
   if(res%9==0){
      
       cout<<"Yes";
   }
   else{
    
       cout<<"No";
   }

    return 0;
}


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

using namespace std;

int INF=1e9;

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

    int n;
    cin>>n;

    vector<pair<int,int>> p1(n),p2(n);

    for(int i=0;i<n;i++)cin>>p1[i].first>>p1[i].second;
    for(int i=0;i<n;i++)cin>>p2[i].first>>p2[i].second;

    sort(p1.begin(),p1.end());
    sort(p2.begin(),p2.end());

    int ans=0;

    vector<bool> used(n);

    for(int i=0;i<n;i++)used[i]=false;

    for(int i=0;i<n;i++){

        int pos=-1;
        pair<int,int> p;
        p.first=-1;p.second=-1;

        for(int j=0;j<n;j++){
            if(p2[i].first>p1[j].first && p2[i].second>p1[j].second && !used[j]){
                if(p.second<p1[j].second){
                    p=p1[j];
                    pos=j;
                }
            }
        }
        if(pos!=-1){
            used[pos]=true;
            ans++;
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <queue>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int argc, const char* argv[])
{
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> rooms(n, vector<int>());
    vector<int> parents(n, -1);
    for(int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;

        rooms[a].push_back(b);
        rooms[b].push_back(a);
    }

    struct Info
    {
        int index;
        int parent;
    };

    queue<Info> q;
    q.push({0, 0});
    while(!q.empty())
    {
        auto info = q.front();
        q.pop();

        if(parents[info.index] != -1)
        {
            continue;
        }

        parents[info.index] = info.parent;
        auto& r = rooms[info.index];
        for(auto to : r)
        {
            q.push({to, info.index});
        }
    }

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

    return 0;
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

signed main() {
   fio;
   int n; cin >> n;
   string s; cin >> s;
   int res = 0 , cntr = 0;
   for(auto c : s) {
      if(c == 'R') {
         cntr++;
      }
   }
   for(int i = 0; i < cntr; i++) {
      if(s[i] == 'W') {
         res++;
      }
   }
   
   cout << res << endl;

   
   return 0;
}




Measured memory_bytes: 3772
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] v = new int[n];
		for(int i = 0; i < n; i++) v[i] = sc.nextInt();
		sc.close();

		//処理
		Arrays.sort(v);
		double ans = (double)(v[0] + v[1])/2;
		for(int i = 2; i < n; i++){
			ans = (ans + v[i])/2;
		}

		//出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <string.h>
#include<string>
#include <math.h>
#include <algorithm>
#include<stdio.h>
#include<queue>
#define maxn 1010
using namespace std;
int pre[maxn];
int height[maxn];
char str[105][105];
struct stu
{
    int sum;
    int id;
}ans;
bool operator < (stu a,stu b)
{
    if(a.sum==b.sum)
        return a.id > b.id;
    return a.sum < b.sum;
}
void dfs(int x,int y)
{
    int dx,dy,nx,ny;
    str[x][y]='*';
    for(dy=-1;dy<=1;dy++)
    {
        for(dx=-1;dx<=1;dx++)
        {
            nx=x+dx;ny=y+dy;
            if(str[nx][ny]=='@')
            {
                dfs(nx,ny);
            }
        }
    }
}
int findit(int x)
{
    if(pre[x]==x)
        return x;
    else
        return pre[x]=findit(pre[x]);
}

void mix(int a,int b)
{
    a=findit(a);
    b=findit(b);
    if(a==b)
        return;
    if(height[a]<height[b])
        pre[a]=b;
    else
    {
        pre[b]=a;
        if(height[a]==height[b])
            height[a]++;
    }
}

void init(int n)
{
    for(int i=1;i<=n;i++)
    {
        pre[i]=i;
        height[i]=0;
    }
}
int main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    if(a<=0&&b>=0)
        printf("Zero\n");
    else
    {
        if(a>0)
        {
            printf("Positive\n");
        }
        else
        {
            if(b>0)
            {
                if(a%2==0)
                    printf("Positive\n");
                else
                    printf("Negative\n");
            }
            else
            {
                if(a%2==0&&b%2==0||a%2!=0&&b%2!=0)
                    printf("Negative\n");
                else
                    printf("Positive\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
# C
N = int(input())
lst = list(map(int, input().split()))
high = max(lst)
low = min(lst)
ans = 5000000
for i in range(low, high+1):
    cost = 0
    for j in range(N):
        cost += (i-lst[j])**2
    if (cost <= ans):
        ans = cost
print(ans)

Measured memory_bytes: 38512
n = int(input())
T = [input().split() for _ in range(n)]
ans = list(range(1, n + 1))

for i in range(n):
    j = i
    while j > 0:
        if T[j][0] < T[j - 1][0]:
            T[j], T[j - 1] = T[j - 1], T[j]
            ans[j], ans[j - 1] = ans[j - 1], ans[j]
            j = j - 1
        else:
            break

for i in range(n):
    j = i
    while j > 0:
        if int(T[j][1]) > int(T[j - 1][1]) and T[j][0] == T[j - 1][0]:
            T[j], T[j - 1] = T[j - 1], T[j]
            ans[j], ans[j - 1] = ans[j - 1], ans[j]
            j = j - 1
        else:
            break


for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
from math import factorial
def P(n,r):
    return factorial(n)//factorial(n-r)
def C(n,r):
    return P(n,r)//factorial(r)
def calc(n,k):
    ans = 0
    for i in range(k):
        ans += (k-i)**n*C(k,i)*(-1)**i
    return ans
n, k = map(int, input().split())
print(calc(n,k)%(pow(10,9)+7) if n > k else factorial(n)%(pow(10,9)+7) if n == k else 0 )


Measured memory_bytes: 5668
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var selectN = (N * (N - 1)) / 2;
  var selectM = (M * (M - 1)) / 2;
  myout(selectN + selectM);
}

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
template<typename TP>inline void read(TP &tar)
{
	TP ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+(ch-'0');ch=getchar();}
	tar=ret*f;
}
template<typename TP,typename... Args>inline void read(TP& t,Args&... args){read(t),read(args...);}
namespace RKK
{
const int N=100011,M=200011;
const int mo=1000000007;
void doadd(int &a,const int &b){if((a+=b)>=mo) a-=mo;}
int add(const int &a,const int &b){return a+b>=mo?a+b-mo:a+b;}
void domul(int &a,const int &b){a=(lint)a*b%mo;}
int mul(const int &a,const int &b){return (lint)a*b%mo;}
struct sumireko{int to,ne,w;}e[M<<1];int he[N],ecnt;
void addline(int f,int t,int w){e[++ecnt].to=t,e[ecnt].w=w;e[ecnt].ne=he[f],he[f]=ecnt;}
int n,m,S,T;
int ex[M],ey[M],ew[M];
lint dis1[N],dis2[N];
int f1[N],f2[N];
struct pat{int x;lint d;pat(int x=0,lint d=0):x(x),d(d){}bool operator<(const pat &p)const{return d>p.d;}};
void dijkstra(int s,lint dis[],int f[])
{
	memset(dis,0x3f,sizeof(lint[N]));
	priority_queue<pat> q;q.push(pat(s,dis[s]=0)),f[s]=1;
	pat pt;int x;
	while(!q.empty())
	{
		pt=q.top(),q.pop(),x=pt.x;if(pt.d!=dis[x]) continue;
		for(int i=he[x],t=e[i].to;i;i=e[i].ne,t=e[i].to)
			if(dis[t]==dis[x]+e[i].w) doadd(f[t],f[x]);
			else if(dis[t]>dis[x]+e[i].w) f[t]=f[x],dis[t]=dis[x]+e[i].w,q.push(pat(t,dis[t]));
	}
}
int ans;
int main()
{
	#ifdef RDEBUG
	freopen("sample.in","r",stdin);
	#endif
	read(n,m,S,T);for(int i=1;i<=m;i++) read(ex[i],ey[i],ew[i]),addline(ex[i],ey[i],ew[i]),addline(ey[i],ex[i],ew[i]);
	dijkstra(S,dis1,f1),dijkstra(T,dis2,f2);
	ans=mul(f1[T],f1[T]);
	// for(int i=1;i<=n;i++) cerr<<f1[i]<<" ";cerr<<endl;
	// for(int i=1;i<=n;i++) cerr<<f2[i]<<" ";cerr<<endl;
	for(int i=1;i<=n;i++)if(dis1[i]+dis2[i]==dis1[T]&&dis1[i]==dis2[i])
		doadd(ans,mo-mul(mul(f1[i],f1[i]),mul(f2[i],f2[i])));
	for(int i=1;i<=m;i++)
	{
		if(dis1[ex[i]]+ew[i]+dis2[ey[i]]==dis1[T]&&dis1[ex[i]]+ew[i]>dis2[ey[i]]&&dis2[ey[i]]+ew[i]>dis1[ex[i]])
			doadd(ans,mo-mul(mul(f1[ex[i]],f2[ey[i]]),mul(f1[ex[i]],f2[ey[i]])));
		swap(ex[i],ey[i]);
		if(dis1[ex[i]]+ew[i]+dis2[ey[i]]==dis1[T]&&dis1[ex[i]]+ew[i]>dis2[ey[i]]&&dis2[ey[i]]+ew[i]>dis1[ex[i]])
			doadd(ans,mo-mul(mul(f1[ex[i]],f2[ey[i]]),mul(f1[ex[i]],f2[ey[i]])));
	}
	printf("%d\n",ans);
	return 0;
}
}
int main(){return RKK::main();}

Measured memory_bytes: 16496
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    int n,m;
    n=s.length();
    m=t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int j=0;j<=m;j++)
        dp[0][j]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(s[i]==t[j])
                dp[i+1][j+1]=dp[i][j]+1;
            else
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    string ans="";
    int i=n,j=m;
    while(i>=0 && j>=0)
    {
        if(dp[i][j]==dp[i-1][j-1]+1 && s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;j--;
        }
        else if(dp[i][j]==dp[i-1][j])
            i--;
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

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


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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  vector<llint> a(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  vector<llint> b(n + 2, 0);
  for (int i = 0; i <= n; i++) {
    b[i + 1] = b[i] + a[i];
  }

  llint now = 1, ans = 0;
  for (int i = 0; i <= n; i++) {
    llint c = now - a[i];
    if (c < 0) {
      cout << -1 << endl;
      return 0;
    }
    ans += a[i] + c;
    llint next = 2 * c;
    llint m = b.back() - b[i] - a[i];
    if (m < next) {
      next = m;
    }
    now = next;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            char[] S = sc.next().toCharArray();

            int ans = 0;

            for (int i = 0; i < S.length / 2; i++) {
                if (S[i] != S[S.length - 1 - i]) {
                    ans++;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
  int book[10], i, ad;

  while(1){
    ad = 0;
    for(i = 0; i < 10; i++){
      scanf("%d", &book[i]);
      if(book[0] == 0) return 0;
    }

  for(i = 1; i < 10; i++)
    ad += book[i];

  printf("%d\n", book[0] - ad);
  }

  return 0;
}

Measured memory_bytes: 600
N = int(input())
a = list(map(int,input().split()))
b = 0

for i in range(N):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            b = 1
            break
if b == 0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll a, b;
	cin >> a >> b;
	cout << max((ll)0, a - b * 2) << endl;
	ggr
}

Measured memory_bytes: 256