akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a;cin>>n>>a;
    cout<<n*n-a<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200020];
int main()
{
    long long n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		long all = 0;
		long mi = 0;
		long ans = 0;
		BigInteger min = BigInteger.ZERO;

		for(int i = 0; i < n; i++) {
			long x = sc.nextLong();
			all += x;
			BigInteger t = BigInteger.valueOf(x*x);
			min = min.add(t);
		}
		BigInteger xt = BigInteger.valueOf(all);
		xt = xt.multiply(xt);
		xt = xt.subtract(min);
		xt = xt.divide(BigInteger.valueOf(2));
		xt = xt.remainder(BigInteger.valueOf(1000000007));

		System.out.println(xt);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

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

    for(int i=0; i<k ;i++){
        if(a >= b) {b *= 2; continue;}
        else if(b >= c) { c *= 2;  continue;}
    }

    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    string a;
    cin >> a ;
    //*/


    //SUN,MON,TUE,WED,THU,FRI,SAT
    //*
    if( a == "SUN" ){
        cout << 7 << endl;
    } else if ( a == "MON" ) {
        cout << 6 << endl;
    } else if ( a == "TUE" ) {
        cout << 5 << endl;
    } else if ( a == "WED" ) {
        cout << 4 << endl;
    } else if ( a == "THU" ) {
        cout << 3 << endl;
    } else if ( a == "FRI" ) {
        cout << 2 << endl;
    } else if ( a == "SAT" ) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    //*/
    
    return 0; 
}


Measured memory_bytes: 3596
S = input()
Q = int(input())
reverse = -1
left = ""
right = ""
for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    reverse *= (-1)
  else:
    if reverse > 0:
      if q[1] == '1':
        right = right + q[2]
      else:
        left = q[2] + left
    else:
      if q[1] == '1':
        left = q[2] + left
      else:
        right = right + q[2]
if reverse>0:
  print((left+S+right)[::-1])
else:
  print(left+S+right)
      
      

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

using namespace std;

int n;

long long gcd(long long x, long long y) {
  if (y > x) return gcd(y,x);
  else if (y == 0) return x;
  else return gcd(y, x%y);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (cin >> n) {
    long long ans = 1;
    for (int i = 0; i < n; i++) {
      long long x;
      cin >> x;
      ans = ans / gcd(ans, x) * x;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

bool is_m(int a) {
    return (1 <= a && a <= 12);
}

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

    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    if (is_m(a) && is_m(b)) cout << "AMBIGUOUS" << endl;
    else if (!is_m(a) && is_m(b)) cout << "YYMM" << endl;
    else if (is_m(a) && !is_m(b)) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}



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

using namespace std;

int main(){

  ll h;
  
  int culcC = 0;
  ll ans = 0;
  
  cin >> h;
  
  while(h >= 1){
    h /= 2;
    culcC++;
  }
  
  rep(i,culcC){
    
    ans += pow(2,i);
    
  }
  
  
  cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
K, N = map(int, input().split())

A = list (map(int, input().split()))

housekyori = []
for i,a in enumerate(A):
    if i == N-1:
        housekyori.append(K-a+A[0])
    else:
        housekyori.append(A[i+1]-a)
print(sum(housekyori)-max(housekyori))

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

typedef long double ld;

#define int long long

const int INF = 1e18 + 239;

struct Segment {
	ld l;
	ld r;

	int len;

	Segment(ld x) {
		l = x;
		r = x;
		len = 1;
	}

	Segment(ld l_, ld r_, int len_) {
		l = l_;
		r = r_;
		len = len_;
	}

	Segment(const Segment &a, const Segment &b) {
		l = a.l;
		r = b.r;
		len = a.len + b.len;
	}

	void apply(int x) {
		l += 2 * x;
		r += 2 * x;
	}
};

vector<int> calc(int n, vector<ld> a) {
	vector<int> ans(n + 1);
	vector<Segment> st = {Segment(a[0])};
	int cost = 0;
	for (int i = 1; i < n; i++) {
		// cerr << "+ " << i << endl;
		
		while (st.back().r < a[i]) {
			// cerr << "it: " << endl;
			// cerr << "st: " << endl;
			// for (auto t : st) {
			// 	cerr << t.l << ' ' << t.r << ' ' << t.len << endl;
			// }
			int ssz = (int)st.size();
			int can = ceil((a[i] - st.back().r) / 2);
			if (ssz > 1) {
				ld dl = (st[ssz - 2].r - st[ssz - 1].l) / 2;
				can = min(can, (int)dl);
			}
			cost += can * st.back().len;
			st.back().apply(can);
			if (ssz > 1 && st[ssz - 2].r < st[ssz - 1].l + 2) {
				auto bc = st.back();
				st.pop_back();
				st.back() = Segment(st.back(), bc);
			}
			// cerr << "st: " << endl;
			// for (auto t : st) {
			// 	cerr << t.l << ' ' << t.r << ' ' << t.len << endl;
			// }
		}
		// cerr << "- " << i << endl;
		st.push_back(Segment(a[i]));
		ans[i + 1] = cost;
	}
	return ans;
}

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

	cerr << fixed << setprecision(4);

	int n;
	cin >> n;
	vector<ld> a(n);
	for (auto &t : a) {
		int x;
		cin >> x;
		t = log2(x);
	}
	auto f = calc(n, a);
	reverse(a.begin(), a.end());
	auto s = calc(n, a);
	int ans = INF;
	for (int i = 0; i <= n; i++) {
		// cerr << i << ' ' << f[i] << ' ' << s[n - i] << endl;
		ans = min(ans, i + 2 * f[i] + 2 * s[n - i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 23624
#include <stdio.h>

int main(void){
   
   int A[6];
   
   scanf("%d %d",&A[0],&A[1]);
   scanf("%d %d",&A[2],&A[3]);
   scanf("%d %d",&A[4],&A[5]);

   int V[4] = {0,0,0,0};
   int i;
   
   for(i = 0;i < 6;i++){
      if(A[i] == 1){
         V[0] = V[0] + 1;
      }
      else if(A[i] == 2){
         V[1] = V[1] + 1;
      }
      else if(A[i] == 3){
         V[2] = V[2] + 1;
      }
      else if(A[i] == 4){
         V[3] = V[3] + 1;
      }
   }
   
   int even = 0;
   for(i = 0;i < 4;i++){
      if(V[i]%2 == 0){
         even = even + 1;
      }
   }
   
   if(even == 4 || even == 2){
      printf("YES\n");
   }
   else {
      printf("NO\n");
   }
   
   return 0;
}


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

int main() {
	long long s = 0;
	int K;
	cin >> K;
	for(int i = 1; i <= K; i++){
		for(int j = 1; j <= K; ++j){
			for(int k = 1; k <= K; ++k){
				s+= __gcd(__gcd(i,j), k);
			}
		}
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3572
module Main where

import Control.Applicative
import Numeric
import Data.Char


main :: IO ()
main = do
  {ln <- getLine
  ; putStrLn ( map conv ln)
  }

conv :: Char -> Char
conv c | isLower c = toUpper c
       | otherwise = toLower c
--
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



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

using namespace std;

int main(){
    string s;
    cin >> s;
    bool b = true;

    for (int i = 0; i < s.size(); i += 2){
        if(s[i] == 'L')
            b = false;
    }
    for (int i = 1; i < s.size(); i += 2){
        if(s[i] == 'R')
            b = false;
    }
    if(b)
        cout << "Yes";
    else
        cout << "No";

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int a;
    int b;
    int k;
    cin >> a >> b >> k;
    for(int i = min(a, b); i >= 1; i--){
        if(a % i == 0){
            if(b % i == 0){
                k--;
            if(k == 0){
                cout << i << endl;
                }
            }
        }
    }
    return 0;
}


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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n;
    cin >> n;
    vi a(n + 2);
    vi b(n + 1);
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    long long tot = min(a[1], b[1]);
    b[1] -= tot;
    for (int i = 1; i < n; i++) {
        auto to_defeat = min(b[i] + b[i + 1], a[i + 1]);
        tot += to_defeat;
        if (to_defeat >= b[i]) {
            to_defeat -= b[i];
        } else {
            to_defeat = 0;
        }
        b[i + 1] -= to_defeat;
    }
    tot += min(a[n + 1], b[n]);
    cout << tot;
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll a,b,n; cin >>a >>b >>n;
	ll ans=a*min(b-1,n)/b;
	cout <<ans;
	return 0;
}
/******************************************************************************
******************************************************************************/


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

int main(void) {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  bool flag = false;

  for (int a1 = 0; a1 <= 100; a1++) {
    for (int a2 = 0; a2 <= 100; a2++) {
      for (int a3 = 0; a3 <= 100; a3++) {
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
        if (a2 + b1 == c[1][0] && a2 + b2 == c[1][1] && a2 + b3 == c[1][2] &&
            a3 + b1 == c[2][0] && a3 + b2 == c[2][1] && a3 + b3 == c[2][2])
          flag = true;
      }
    }
  }

  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll a, b;
    cin >> a >> b;
    vector<ll> pa;
    vector<ll> pb;

    for (ll i = 2; i * i <= a; ++i) {
        if(a % i == 0){
            pa.push_back(i);
        }
        while(a % i == 0){
            a /= i;
        }
    }
    if(a != 1) pa.push_back(a);

    for (ll i = 2; i * i <= b; ++i) {
        if(b % i == 0){
            pb.push_back(i);
        }
        while(b % i == 0){
            b /= i;
        }
    }
    if(b != 1) pb.push_back(b);

    ll res = 1;
    for (auto i = pa.begin(); i != pa.end(); ++i){
        if(binary_search(pb.begin(), pb.end(), *i)) res++;
    }
    cout << res << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int A, B, C;
  cin >> A >> B >> C;
  if (B + C > A) {
    cout << C - (A - B) << endl;
  } else {
    cout << 0 << endl;
  }
}

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

  solve();

  return 0;
}


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

int main(){
  string str,p,que,tmp;
  int q,a,b;
  char temp;
  cin >> str;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> que >> a >> b;
    if(que == "replace"){
      cin >> p;
      str = str.replace(a,b - a + 1,p);
    }
    else if(que == "reverse"){
      reverse(str.begin() + a,str.begin() + b + 1);
    }
    else if(que == "print"){
      cout << str.substr(a,b - a + 1) << endl;
    }
  }
}



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

int main(){
 int n;cin >>n;
 vector<ll> a(n);
 for(int i=0;i<n;i++)cin >>a[i];
 bool ok=true;

 if(n%2==0){
   int cnt2=0,cnt4=0;
 for(int i=0;i<n;i++){
     if(a[i]%2==0 && a[i]%4!=0)cnt2++;
     if(a[i]%4==0)cnt4++;
   }
   if(cnt2<n && cnt4<n/2)ok=false;
   if(n-cnt4*2<=cnt2)ok=true;
  }
else if(n%2==1){
  int cnt2=0,cnt4=0;
for(int i=0;i<n;i++){
  if(a[i]%2==0)cnt2++;
  if(a[i]%4==0)cnt4++;
}
if(cnt2<n && cnt4<(n-1)/2)ok=false;
if(n-cnt4*2<=cnt2)ok=true;
 }

 if(ok)cout <<"Yes" << endl;
 else cout <<"No" << endl;

}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {

        static long cutSum(string s, List<int> a)
        {
            var ret = 0L;
            for (int i = 0; i < a.Count-1; i++)
            {
                ret += long.Parse(s.Substring(a[i], a[i + 1] - a[i]));
            }
            ret += long.Parse(s.Substring(a.Last()));
            return ret;
        }
        static long Solve(string s)
        {
            var ans = 0L;
            for (int i = 0; i < 1<<(s.Length-1); i++)
            {
                var a = new List<int>();
                a.Add(0);
                for (int j = 0; j < s.Length; j++)
                {
                    if ((i & (1 << j)) == (1 << j))
                    {
                        a.Add(j+1);
                    }
                }
                ans += cutSum(s, a);
            }
            return ans;
        }
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var ans = Solve(S);
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 3160
#include <stdio.h>

int arr[100];
int main(void){
	int i, j, N, count = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", arr + i);
	for (j = N; j; j--) {
		for (i = 1; i < j; i++) {
			if (arr[i - 1] > arr[i]) {
				arr[i - 1] ^= arr[i];
				arr[i] ^= arr[i - 1];
				arr[i - 1] ^= arr[i];
				count++;
			}
		}
	}
	printf("%d", *arr);
	for (i = 1; i < N; i++) printf(" %d", arr[i]);
	printf("\n%d\n", count);


}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, s, n) for (int i = s; i < (n); i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n)
    {
        cin >> a[i] >> b[i];
    }
    int mx = 0;
    rep(i, n)
    {
        mx = max(mx, a[i]);
    }
    sort(b.begin(), b.end(), greater<int>());
    int cnt = 0;
    rep(i, n)
    {
        if (b[i] >= mx && h > 0)
        {
            h -= b[i];
            cnt++;
        }
    }
    if (h > 0)
    {
        cnt += h / mx;
        if (h % mx)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
main :: IO ()
main = do
  p <- getLine
  if p == "#"
    then return ()
    else do
      putStrLn $ solve p
      main

solve :: String -> String
solve p = ask "A" p
  where
    ask :: String -> String -> String
    ask now []
      | now == "B" = "Yes"
      | otherwise = "No"
    ask "A" (x:xs)
      | x == '0' = ask "X" xs
      | otherwise = ask "Y" xs
    ask "B" (x:xs)
      | x == '0' = ask "Y" xs
      | otherwise = ask "X" xs
    ask "X" (x:xs)
      | x == '1' = ask "Z" xs
      | otherwise = "No"
    ask "Y" (x:xs)
      | x == '0' = ask "X" xs
      | otherwise = "No"
    ask "Z" (x:xs)
      | x == '0' = ask "W" xs
      | otherwise = ask "B" xs
    ask "W" (x:xs)
      | x == '0' = ask "B" xs
      | otherwise = ask "Y" xs

Measured memory_bytes: 3664
import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args){
		new Main().run();
    }

    void run(){
      Scanner sc=new Scanner(System.in);
      int N=sc.nextInt();
      int M=sc.nextInt();
      ArrayList<Integer>[] g=new ArrayList[N];
      for(int i=0;i<N;++i){
          g[i]=new ArrayList<>();
      }
      boolean[] valid=new boolean[N];
      Arrays.fill(valid,true);
      int[] in=new int[N];
      int[] out=new int[N];
      for(int i=0;i<M;++i){
          int x=sc.nextInt();
          int y=sc.nextInt();
          --x;
          --y;
          g[x].add(y);
          ++in[y];
          ++out[x];
      }
      ArrayDeque<Integer> pend=new ArrayDeque<>();
      for(int i=0;i<N;++i){
          if(in[i]==0)pend.add(i);
      }
      int[] dp=new int[N];
      while(!pend.isEmpty()){
          int src=pend.poll();
          for(int dst:g[src]){
            dp[dst]=Math.max(dp[dst],dp[src]+1);
            --in[dst];
            if(in[dst]==0){
                pend.add(dst);
            }
	    }
	}
	int ans=0;
	for(int v:dp)ans=Math.max(ans,v);
      System.out.println(ans);
    }

    void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}


Measured memory_bytes: 102500
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
  int W, H;
  cin >> W >> H;
  vector<pair<ll, int>> buf;
  for(int i=0;i<W;i++){
    ll p;
    cin >> p;
    buf.emplace_back(p, 0);
  }
  for(int i=0;i<H;i++){
    ll q;
    cin >> q;
    buf.emplace_back(q, 1);
  }
  priority_queue<
    pair<ll, int>,
    vector< pair<ll, int>>,
    greater< pair<ll, int>>>
      PQ(buf.begin(), buf.end());
  ll ans = 0;
  while(!PQ.empty()){
    auto C = PQ.top();PQ.pop();
    if(C.second == 0){
	  ans += (H + 1) * C.first;
      W--;
    }else{
      ans += (W + 1) * C.first;
      H--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7532
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) {
		cin >> c[i];
		rep(j,m) {
			cin >> a[i][j];
		}
	}
	//参考書の買い方は2^12=4096通り以下なので、全探索する。
	int ans = INF;
	rep(i, 1 << 12) {
		//参考書を買うor買わないの情報now
		bitset<12> now = i;
		//払ったお金cost
		int cost = 0;
		//高橋くんのそれぞれのアルゴリズムに対する理解度
		vector<int> skill(m);
		//j番目の参考書に注目する。
		rep(j, n) {
			//nowのj番目が1だったらj番目の参考書を買う
			if (now.test(j)) {
				cost += c[j];
				//j番目の参考書を買ったときに得られる各アルゴリズムへの理解度を加える
				rep(k, m) skill[k] += a[j][k];
			}
		}
		bool flag = true;
		//一つでもx未満の理解度が存在する場合は、flagを折る
		rep(j, m) {
			if (skill[j] < x) flag = false;
		}
		if (flag) {
			ans = min(ans,cost);
		}
	}
	if (ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
    int a, b, r;
    scanf("%d%d", &a, &b);
    if (a < 10) {
    r = b + (100 * (10 - a));
    }
    else{
    r = b;
    }
    
    printf("%d", r);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
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 mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  ll N;
  cin >> N;
  ll ans = 1;
  ll sum = 1;
  int cnt = 1;
  for(int i = 1; i < 15; i++) {
    if (ans+sum*26 > N)
      break;
    else {
      sum *= 26;
      ans += sum;
      cnt++;
    }
  }
  // cout << ans << endl;
  ans = N-ans;
  vector<int> a;
  rep(i, cnt) {
    if (ans != 0) {
      a.pb(ans%26);
      ans /= 26;
    }
    else
      a.pb(0);
  }
  for(int i = a.size()-1; i >= 0; i--) {
    // cout << a[i];
    cout << char('a'+a[i]);
  }
  cout << endl;
}


Measured memory_bytes: 3672
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int n, i, j, random;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; i++) {
        scanf("%d", &random);
        printf("Case %d:\n", i);
        for (j = 0; j < 10; j++) {
            random = random * random / 100 % 10000;
            printf("%d\n", random);
        }
    }
    
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  string t;
  int mi=10000000;
  cin>>S;
  for(int i=0; i<S.size()-2; i++){
    t=S.substr(i,3);
    int x=stoi(t);
    mi=min(abs(x-753),mi);
  }
  cout<<mi<<endl;
}
  

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

int main(){
		int n,x;
		while(cin >> n >> x and !(n==0 and x==0) )
		{
		int cnt = 0;
		for(int i=1;i<=n;i++){
				for(int j=i+1;j<=n;j++){
						if(i==j) continue;
						for(int k=j+1;k<=n;k++){
								if(j==k || i==k) continue;
								if(i+j+k == x) cnt++;
						}
				}
		}
		cout << cnt << endl;
	}
}


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


Measured memory_bytes: 256
from collections import Counter


n, k = map(int, input().split())
lst_A = list(map(int, input().split()))


set_A = set(lst_A)
cnt_A = sorted(Counter(lst_A).items(), key=lambda x:x[1])
num_change = len(set_A) - k
ans = 0
if num_change > 0:
    for i in range(num_change):
        ans += cnt_A[i][1]


print(ans)


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

using namespace std;

int arr[100005];
int n,c;

int main()
{
	cin >> n >> c;
	for(int i=0;i<n;i++) cin >> arr[i];
	long long ans=0;
	for(int i=1;i<n;i++)
	{
		if(arr[i]+arr[i-1]>c)
		{
			int z=min((arr[i]+arr[i-1])-c,arr[i]);
			arr[i]-=z; ans+=z;
			if(arr[i]+arr[i-1]>c)
			{
				ans+=arr[i-1]-c; arr[i-1]=c;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,k,c=0,cnt=0,f=0,b=0;
  string s;
  cin>>n>>k>>s;
  if(n==1){cout<<1;return 0;}
  if(s[0]=='0') cnt++;
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1]){
      if(s[i]=='1') ;
      else{
        if(cnt<k){
          cnt++;
        }else{
          while(true){
            b++;
            if(s[b]=='1'&&s[b-1]=='0'){
              break;
            }
          }
        }
      }
    }
    c=max(c,i-b+1);
  }
  cout<<c;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] al = new long[n];
        for(int i = 0 ; i < n; i++){
            al[i] = sc.nextLong();
        }
        long[][] dp = new long[n+1][2];
        dp[0][0] = 0;
        dp[0][1] = -Integer.MAX_VALUE;
        for(int i = 1; i <= n; i++){
            dp[i][0] = Math.max(dp[i-1][0] + al[i-1], dp[i-1][1] - al[i-1]);
            dp[i][1] = Math.max(dp[i-1][0] - al[i-1], dp[i-1][1] + al[i-1]);
        }
        System.out.println(dp[n][0]);
    }
}


Measured memory_bytes: 57384
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
  int N,M;	//N個の都市、M本の道路
  cin>>N>>M;
  vector<int> a(M),b(M),total(N);
  for(int ni =0;ni<M;ni++)
  {
    cin>>a.at(ni)>>b.at(ni);
    total.at(a.at(ni)-1)++;
    total.at(b.at(ni)-1)++;
  }
  
  for(int ni=0;ni<N;ni++)
  {
    cout<<total.at(ni)<<endl;
  }
  return 0;
}

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

int main()
{
	char S[10010];
	int Len;
	int Cnt = 0;
	int Check;
	int Try;
	scanf("%s", S);
	Len = strlen(S);

	Check = Len % 2;

	if (Check == 0) {
		Try = Len / 2;
	}
	else {
		Try = (Len - 1)  / 2 ;
	}

	for (int i = 0; i != Try; i++) {
		if (S[i] != S[Len - 1 - i]) {
			Cnt = Cnt + 1;
		}
	}

	printf("%d", Cnt);

	return 0;
}

Measured memory_bytes: 128
PROGRAM PalindromePhilia
      IMPLICIT NONE
      character(100) :: s
      integer :: l,h,i,ans
      
      read*,s
      l = len_trim( s )
      
      h = l /2
      ans = 0
      do i = 1,h
        if( s(i:i)/=s(l-i+1:l-i+1) )then
          ans = ans + 1
        end if
      end do
      
      print*,ans
      
      
      
      END PROGRAM

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 1000005
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(b>=a){
        cout<<"unsafe";
    }
    else cout<<"safe";
    
 
    
    return 0;
}

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

int main(){
    int n; cin >> n;
    int l[n] = {0}; rep(i, n) cin >> l[i];

    int ans = 0;
    sort(l, l+n);
    rep(i, n)rep(j, i)rep(k, j){
        if(l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and l[j] + l[k] > l[i])
            ans++;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N,X;
  cin >> N >> X;
  
  vector<int> m(N);
  for (int i = 0; i < N; i++)
    cin >> m.at(i);
  
  int sum = 0;
  for (int i = 0; i < N; i++)
    sum += m.at(i);
  
  sort(m.begin(),m.end());
  
  cout << N + ((X - sum) / m.at(0)) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>


using namespace std;

const int MAX	= 1e5 + 5;
const int LIM	= 3e5 + 5;
const int MOD	= 1e9 + 7;
const long double  EPS	= 1e-10;
const double PI = acos(-1.0);

typedef long long LL; 
typedef long double LD;


#define uint64 unsigned long long
#define int64 long long


#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

////////////////////////////////////////////////////////////////
int main() {
    IOS;
    int N, M, C, B[20];
    cin >> N >> M >> C;
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int res = 0;
    for(int i = 0; i < N; i++) {
        int sum = 0;
        for(int j = 0; j < M; j++) {
            int A;
            cin >> A;
            sum += A * B[j];
        }
        if (sum + C > 0) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
using namespace std;

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  
  for(int i=1;i<=1009;i++){
    if(int(i*0.08) == a && int(i*0.1) == b) {
      printf("%d", i); 
      break;
    }
    if(i==1009) printf("-1");
  }
  
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S[0] != S[1] || S[0] != S[2] || S[1] != S[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define ll long long
const int N = 3e5 + 5, MOD = 1e9 + 7;

int A[N];

int main(){
	int n, cntr = 0;
	ll ans = 0;
	cin>>n;
	for(int i = 0; i < 3*n; i++)	cin>>A[i];
	sort(A, A + 3*n);
	for(int i = 3*n - 2; ; i -= 2){
		ans += A[i];
		cntr++;
		if(cntr == n)	break;
	}
	cout<<ans<<endl;
}

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

int main()
{
  ll n,i,j;
  cin>>n;
  ll x[n+1],y[n+1],h[n+1];
  for(i=0;i<n;i++)
  {
      cin>>x[i]>>y[i]>>h[i];
  }
  ll cx,cy,ch,acx,acy,ach;
  bool f;
  for(i=0;i<=100;i++)
  {
      for(j=0;j<=100;j++)
      {
        //   cout<<i<<" "<<j<<endl;
          cx = i, cy = j;
          f = true;
          ll p = 1, q = 1000000200;
          
          ll poi = 0;
          for(ll k = 0;k<n;k++)
          {
              if(h[k]>h[poi])
              {
                poi = k;
              }
          }
          
          while(p<=q)
          {
              ll mid = (p+q)/2;
              ll th = max(mid - abs(x[poi]-cx) - abs(y[poi]-cy),0LL);
              if(th==h[poi])  break;
              else if(th<h[poi])
                p = mid+1;
              else
                q = mid-1;
          }
          if(p>q)
          {
            f = false;continue;
          }
          ll mid = (p+q)/2;
          ll th = max(mid - abs(x[poi]-cx) - abs(y[poi]-cy),0LL);
          if(th==h[poi])
          {
            //   cout<<cx<<" "<<cy<<" "<<mid<<" "<<th<<" "<<h[0]<<endl;
              ch = mid;
          }
          else
          {
            f = false;continue;
          }
          
          if(ch<1)
          {
              f =false;continue;
          }

          for(p=0;p<n;p++)
          {
            ll th = max(ch - abs(x[p]-cx) - abs(y[p]-cy),0LL);
            if(th!=h[p])
            {
                f = false;break;
            }
          }
          if(f)
          {
              acx = cx;
              acy = cy;
              ach = ch;
          }
      }
  }
//   if(ach>1000000000)    cout<<(1/0);
  cout<<acx<<" "<<acy<<" "<<ach;
  /*else
    cout<<(1/0);*/
  return 0;
}

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

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(int T)
{
    int x;
    cin >> x;
    x^=1;
    cout << x;
}



signed main()
{
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,i; cin>>n>>i;
	i--;
	string s; cin>>s;
	s[i]+=('a'-'A');
	cout<<s<<"\n";
	return 0;
}















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum[100009];

int main(){
  string s;
  int n,q;
  cin>>n>>q;
  cin>>s;
  int ans=0;
  for(int i=1;i<s.size();i++){
    sum[i+1]=sum[i];
    if(s[i-1]=='A'&&s[i]=='C'){
      sum[i+1]++;
    }
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<sum[r]-sum[l]<<endl;
  }
  return(0);
}


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

using namespace std;

int main(void) {
	int n, a;
	vector<int> L;
	int l = 1;
	cin >> n;
	cin >> a;
	L.push_back(a);
	for (int i = 1; i < n; i++)
	{
		cin >> a;
		vector<int>::iterator pos = lower_bound(L.begin(), L.end(), a);
		if (pos == L.end()) {
			L.push_back(a);
			l++;
		}
		else {
			*pos = a;
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 1672
n,m=map(int,input().split())
d={}
ans=0
pen=0

for i in range(m):
  s=input().split()
  if s[0] not in d:
    if s[1]=='WA':
      d[s[0]]=[0,1,1]
    else:
      d[s[0]]=[1,0,1]
      d[s[0]][2]*=0
  else:
    if s[1]=='WA' and d[s[0]][2]==1:
      d[s[0]][1]+=1
    elif s[1]=='AC' and d[s[0]][2]==1:
      d[s[0]][0]+=1
      d[s[0]][2]*=0

for i in d:
  if d[i][2]==0:
    pen+=d[i][1]
  ans+=d[i][0]    
print(ans,pen)



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

using namespace std;
typedef long long ll;
ll n,k;
ll gcd(ll a,ll b){return (a%b==0)?b:gcd(b,a%b);}

int main()
{
	scanf("%lld%lld",&n,&k);
	printf("%lld",3*(n-gcd(n,k)));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
	int n;
	std::cin >> n;
	char*s = new char[n+1];
	char*t = new char[n+1];
	std::cin >> s >> t;
	char*ans = new char[2 * n + 1];
	for (int i = 0; i < 2 * n; i++) {
		if (i % 2)ans[i] = t[i / 2];
		else ans[i] = s[i / 2];
	}
	ans[2 * n] = '\0';
	printf("%s\n", ans);
}

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

using namespace std;

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

    string s;
    cin >> s;

    if(s[K-1] == 'A'){
        s[K-1] = 'a';
    }else if(s[K-1] == 'B'){
        s[K-1] = 'b';
    }else{
        s[K-1] = 'c';
    }
    cout << s << endl;
    return 0;
}

    

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

using namespace std;

#define ll long long

int main()
{
    ll l, r, ans = 10000;
    cin >> l >> r;
    if (r - l + 1 >= 2019)
        cout << 0;
    else {
        for (ll i=l; i<=r; ++i) {
            for (ll j=i+1; j<=r; ++j) {
                ans = min(ans, ((i%2019)*j)%2019);
            }
        }
        cout << ans;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, A, B, C, D;
  string S;
  cin>>N>>A>>B>>C>>D;
  A--;
  B--;
  C--;
  D--;
  cin>>S;
  bool ans;
  while(true){
    if(C<D){
      if(B<D && B+2<=D && S[B+2]=='.' && B+2!=A){
        B += 2;
      }
      else if(B<D && B+1<=D && S[B+1]=='.' && B+1!=A){
        B += 1;
      }
      else if(A<C && A+1<=C && S[A+1]=='.' && A+1!=B){
        A += 1;
      }
      else if(A<C && A+2<=C && S[A+2]=='.' && A+2!=B){
        A += 2;
      }
      else if(A==C && B==D){
        ans = true;
        break;
      }
      else {
        ans = false;
        break;
      }
    }
    else{
      if(A<C && A+2<=C && S[A+2]=='.' && A+2!=B){
        A += 2;
      }
      else if(A<C && A+1<=C && S[A+1]=='.' && A+1!=B){
        A += 1;
      }
      else if(B<D && B+1<=D && S[B+1]=='.' && B+1!=A){
        B += 1;
      }
      else if(B<D && B+2<=D && S[B+2]=='.' && B+2!=A){
        B += 2;
      }
      else if(A==C && B==D){
        ans = true;
        break;
      }
      else {
        ans = false;
        break;
      }
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3680
A,B = map(int,input().split())

pre = 0

if A < B:
  big = B
  small = A
else:
  big = A
  small = B

if A + B > 16:
  print(":(")
else:
  for i in range(16):
    if pre == 0:
      big -= 1
      pre = 1
    else:
      small -= 1
      pre = 0
if small <= 0 and big <= 0:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3064
// This  Program is made by Jan(Codezebra)
#include<bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
using namespace std;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	map<int,int> num1,num2;
	for(int i=0;i<n;i+=2){
		int p;
		cin>>p;
		if(!num1.count(p)){
			num1[p]=0;
		}
		num1[p]++;
		//scheiding
		cin>>p;
		if(!num2.count(p)){
			num2[p]=0;
		}
		num2[p]++;
	}
	vector<pair<int,int> > o1,o2; 
	for (map<int,int>::iterator it=num1.begin(); it!=num1.end(); ++it){
		o1.push_back({it->second,it->first});
	}
	for (map<int,int>::iterator it=num2.begin(); it!=num2.end(); ++it){
		o2.push_back({it->second,it->first});
	}
	sort(o1.begin(),o1.end(), std::greater<pair<int,int> >());
	sort(o2.begin(),o2.end(),std::greater<pair<int,int> >());
/*	for(auto u:o1){
		cout<<u.first<<" "<<u.second<<"\n";
	}
	for(auto u:o2){
		cout<<u.first<<" "<<u.second<<"\n";
	}*/
	if(o1[0].second==o2[0].second){
		if(o1.size()==1 and o1.size()==1){
		//	cout<<"Case #1\n";
			cout<<n/2;
		}
		else if(o1.size()==1){
	//		cout<<"Case #2\n";
			cout<<n/2-o2[1].first;
		}
		else if(o2.size()==1){
	//		cout<<"Case #3\n";
			cout<<n/2-o1[1].first;
		}
		else{
			cout<<min(n-o1[1].first-o2[0].first,n-o1[0].first-o2[1].first);
		}
	}
	else{
	//	cout<<"Case #6\n";
		cout<<n-o1[0].first-o2[0].first;
	}
	return 0;
}



Measured memory_bytes: 8824
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int count;
	int n;
	int a, b, c, d;

	while (scanf("%d", &n) != EOF)
	{
		count = 0;
		for (a = 0; a <= 9; ++a)
		{
			for (b = 0; b <= 9; ++b)
			{
				for (c = 0; c <= 9; ++c)
				{
					for (d = 0; d <= 9; ++d)
					{
						if (a + b + c + d == n)
							count++;
					}
				}
			}
		}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.charAt(0) !='A') {
			System.out.println("WA");
			return;
		}
		int st = 2, ed = s.length()-2, cnt = 0;
		boolean bo = false;
		for(int i = st; i <= ed; i++) {
			if(s.charAt(i) =='C') {
				st = i;
				cnt++;
				bo = true;
				break;
			}
		}
		if(!bo || cnt > 1) {
			System.out.println("WA");
			return;
		}
		bo = false;
		for(int i = 1; i < s.length(); i++) {
			if(i == st) {
				continue;
			} else if(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
				System.out.println("WA");
				return;
			}
		}
		System.out.println("AC");
	}
}


Measured memory_bytes: 21588
let bin_search x a =
  let rec doit l r =
    if l >= r then false
    else begin
      let m = (l + r) / 2 in
      if x = a.(m) then true
      else if x < a.(m) then doit l m
      else doit (m + 1) r
    end
  in
  doit 0 (Array.length a)

let () =
  let read_seq () = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
  let _ = read_int () in
  let s = Array.of_list (read_seq ()) in
  let _ = read_int () in
  let t = read_seq () in
  Printf.printf "%d\n" (List.fold_left (fun acc e -> acc + (if bin_search e s then 1 else 0)) 0 t)

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = a * b - a - b + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def getlist():
    return list(map(int, input().split()))

K, X = getlist()

ans = []
for i in range(K - 1):
    ans.append(X - K + 1 + i)

ans.append(X)

for i in range(K - 1):
    ans.append(X + 1 + i)

print(" ".join(list(map(str, ans))))

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	vector<bool>Button(N, false);
	Button.at(0) = true;
	int j = 1, ans = 0;
	for (long long i = 0; i < N; i++) {
		ans++;
		int k = j;
		j = A.at(k - 1);
		if (j == 2) {
			cout << ans << endl;
			return 0;
		}
		if (Button.at(j - 1)) {
			cout << -1 << endl;
			return 0;
		}
		Button.at(j - 1) = true;
	}
}


Measured memory_bytes: 1024