akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Vi = Sarray();
            if (1 == Vi.Distinct().Count())
            {
                WriteLine(N / 2);
                return;
            }
            var odd = new Dictionary<long, long>();
            var even = new Dictionary<long, long>();
            for (var i = 0; i < N; i += 2)
            {
                if (!odd.ContainsKey(Vi[i])) odd[Vi[i]] = 0;
                ++odd[Vi[i]];
                if (!even.ContainsKey(Vi[i + 1])) even[Vi[i + 1]] = 0;
                ++even[Vi[i + 1]];
            }
            var sodd = odd.OrderByDescending(o => o.Value).ToList();
            var seven = even.OrderByDescending(e => e.Value).ToList();
            var max = sodd[0].Value + seven[0].Value;
            if (sodd[0].Key == seven[0].Key)
            {
                if (sodd.Count == 1)
                    max = sodd[0].Value + seven[1].Value;
                else if (seven.Count == 1)
                    max = sodd[1].Value + seven[0].Value;
                else
                    max = Max(sodd[0].Value + seven[1].Value, sodd[1].Value + seven[0].Value);
            }
            WriteLine(N - max);
            //Out.Flush();
        }
    }
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int K = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		long a[] = new long[K];
		for(int i=0;i<K;i++) {
			a[i] = Long.parseLong(st.nextToken());
		}
		long min = 2;
		long max = 2;
		boolean success = true;
		for(int j=K-1;j>=0;j--) {
			if(a[j]>max) {
				success = false;
				System.out.println(-1);
				break;
			}
			long cmin;
			long cmax;
			if(a[j]>=min) {
				cmin = a[j];
			}else {
				long mod = min%a[j];
				cmin = (min/a[j]);
				if(mod>0)
					cmin++;
				cmin *= a[j];
			}
			cmax = (max/a[j])*a[j]+(a[j]-1);
			if(cmax<min||cmin<min||cmin>max) {
				success = false;
				System.out.println(-1);
				break;
			}
			
			max = cmax;
			min = cmin;
		}
		if(success) {
			System.out.println(min+" "+max);
		}
	}
}


Measured memory_bytes: 38348
mdlp = [31,29,31,30,31,30,31,31,30,31,30,31]
mdnm = [31,28,31,30,31,30,31,31,30,31,30,31]

isLeapYear :: Int -> Bool
isLeapYear y =
  if y `mod` 4 == 0
  then
    if y `mod` 400 == 0
    then True
    else
      if y `mod` 100 == 0
      then False
      else True
  else False

y2d :: Int -> Int
y2d y =
  if isLeapYear y
  then 366
  else 365

ans :: [Int] -> Int
ans (y1:m1:d1:y2:m2:d2:_) =
  let a1 = if y2 - y1 >= 1
           then sum $ map y2d [y1..y2-1]
           else 0
      a2 = if isLeapYear y1
           then d1 + (sum $ take (m1-1) mdlp)
           else d1 + (sum $ take (m1-1) mdnm)
      a3 = if isLeapYear y2
           then d2 + (sum $ take (m2-1) mdlp)
           else d2 + (sum $ take (m2-1) mdnm)
  in
    a1 - a2 + a3

main = do
  c <- getContents
  let i' = map (map read) $ map words $ lines c :: [[Int]]
      i  = takeWhile (/= [-1,-1,-1,-1,-1,-1]) i'
      o  = map ans i
--  print i
  mapM_ print o
  

Measured memory_bytes: 4084
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I() % 10
    if n in [2,4,5,7,9]:
        return "hon"
    if n == 3:
        return "bon"

    return "pon"

print(main())





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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int max = a * c;
    if (b >= max){
        cout << c << endl;
    }
    else{
      	int num1;
        num1 = (b - (b % a)) / a;
        cout << num1 << endl;
    }        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll h; cin>>h;
    int cnt = 0;
    while (h>0) {
        cnt++;
        h/=2;
    }
    ll ans = 0ll;
    ll k = 1;
    for (ll i = 1ll; i <= cnt; ++i) {
        ans += k;
        k *= 2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 2e5 + 10;
int n, K, a[N], q[N], ans, mark[N], b[N];

int main() {
    cin >> n >> K;
    rep(i, 1, n) cin >> a[i];
    ans = n - K + 1;

    int cnt = 0, tot = 0;
    rep(i, 1, n) {
        if (a[i] > a[i - 1]) b[i] = b[i - 1] + 1;
        else b[i] = 1;
    }

    int l = 1, r = 0;
    rep(i, 1, n) {
        if (i >= K) {
            while (l <= r && q[l] < i - K) ++l;
        }
        if (q[l] == i - K) mark[i]++;
        while (l <= r && a[q[r]] > a[i]) --r;
        q[++r] = i;
    }
    // rep(i, 1, n) printf("%d ", mark[i]); puts("");

    l = 1, r = 0;
    for (int i = n; i >= 1; i--) {
        if (i <= n - K + 1) {
            while (l <= r && q[l] > i + K) ++l;
        }
        if (q[l] == i + K) mark[i + K]++;
        while (l <= r && a[q[r]] < a[i]) --r;
        q[++r] = i;
    }
    // rep(i, 1, n) printf("%d ", mark[i]); puts("");

    bool ff = 0;
    rep(i, K, n) {
        if (b[i] >= K) {
            if (!ff) ff = 1;
            else tot++;
        } else if (mark[i] == 2) tot++;
    }
    printf("%d\n", ans - tot);
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int n0 = 0;
  int n1 = 0;

  for(int i = 0; i < S.size(); i++){
    if(S[i] == '0')
      n0++;
    else
      n1++;
  }

  cout << 2 * min(n0, n1) << endl;
  return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[100000], ta = 0;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 1)ta++;
	}
	if (ta % 2 == 1) cout << "NO" << endl;
	else cout << "YES" << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 1024
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_D"
// #include "../../math/combination.hpp"
// #include "../../math/modint.hpp"
#include <iostream>
constexpr const int MOD = (int)1e9 + 7;
#include <vector>

// template引数としてModIntをとることを想定
template <typename T>
class Combination {
    std::vector<T> fac, finv;

public:
    explicit Combination(int size)
        : fac(size + 1)
        , finv(size + 1)
    {
        fac[0] = 1;
        finv[0] = 1;
        for (int i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * T(i + 1);
            finv[i + 1] = finv[i] * T(i + 1).inv();
        }
    }

    // `nCr` を求める
    T C(int n, int r) const
    {
        if (r < 0 || n < r)
            return T(0);
        return fac[n] * finv[r] * finv[n - r];
    }

    // `nPr` を求める
    T P(int n, int r) const
    {
        if (r < 0 || n < r)
            return T(0);
        return fac[n] * finv[n - r];
    }
};
#ifndef _MODINT_H_
#define _MODINT_H_
#include <iostream>
#include <assert.h>

template<int Mod>
struct ModInt {
    int v;
    ModInt(): v(0){}
    template<typename T>
    explicit ModInt(T t) {
        v = t % Mod;
        if (v < 0) v += Mod;
    }

    ModInt pow(int k) {
        ModInt res(1), x(v);
        while(k) {
            if (k % 2 == 1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }

    template<typename T>
    ModInt& operator=(T a) { v = a % Mod; if (v < 0) v += Mod; return *this; }
    ModInt inv() { return pow(Mod - 2); }
    ModInt& operator+=(ModInt a) { v += a.v; if (v >= Mod) v -= Mod; return *this; }
    ModInt& operator-=(ModInt a) { v += Mod - a.v; if (v >= Mod) v -= Mod; return *this; }
    ModInt& operator*=(ModInt a) { v = 1LL * v * a.v % Mod; return *this; }
    ModInt& operator/=(ModInt a) { assert(a.v != 0); return (*this) *= a.inv(); }
    ModInt operator+(ModInt a) const { return ModInt(v) += a; }
    ModInt operator-(ModInt a) const { return ModInt(v) -= a; }
    ModInt operator*(ModInt a) const { return ModInt(v) *= a; }
    ModInt operator/(ModInt a) const { return ModInt(v) /= a; }
    ModInt operator-() { return ModInt(-v); }
    bool operator==(const ModInt a) const { return v == a.v; }
    bool operator!=(const ModInt a) const { return v != a.v; }
    bool operator<(const ModInt a) const { return v < a.v; }

    friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.v; }
    friend std::istream &operator>>(std::istream &is, ModInt &a) {
        int val;
        is >> val;
        a = ModInt(val);
        return is;
    }
};

#endif // #ifndef _MODINT_H_

int main()
{
    int n, k;
    std::cin >> n >> k;
    Combination<ModInt<MOD>> com(2005);
    auto ans = com.C(n + k - 1, k - 1);
    std::cout << ans << std::endl;
}



Measured memory_bytes: 3152
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	long n = sc.nextLong();
      	long sum = 0;
      	for(long i = 1; i <= n; i++){
        	if(i%3!=0 && i%5!=0) sum += i;
        }
      	System.out.println(sum);
    }
}

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int h, w;
  cin >> h >> w;
  int ch, cw;
  cin >> ch >> cw;
  int dh, dw;
  cin >> dh >> dw;
  ch--, cw--, dh--, dw--;
  vector<vector<char>> grid(h, vector<char>(w));
  for (vector<char>& row : grid)
    for (char& cell : row)
      cin >> cell;

  vector<vector<int>> cost(h, vector<int>(w, 1e9));
  cost[ch][cw] = 0;
  deque<pair<int, int>> q;
  q.push_back({ch, cw});

  auto valid = [&, h, w, grid](int x, int y) {
    return x < h && x >= 0 && y < w && y >= 0 && grid[x][y] != '#';
  };

  while (!q.empty()) {
    auto [currX, currY] = q.front(); 
    q.pop_front();
    vector<pair<int, int>> next = {{currX + 1, currY}, {currX - 1, currY}, {currX, currY + 1}, {currX, currY - 1}};

    for (auto [x, y]: next) 
      if (valid(x, y) && cost[x][y] > cost[currX][currY]) {
        cost[x][y] = min(cost[x][y], cost[currX][currY]);
        q.push_front({x, y});
      }

    for (int x = currX - 2; x <= currX + 2; x++) 
      for (int y = currY - 2; y <= currY + 2; y++) 
        if (valid(x, y) && cost[x][y] > cost[currX][currY] + 1) {
          cost[x][y] = min(cost[x][y], cost[currX][currY] + 1);
          q.push_back({x, y});
        }
  }

  cout << (cost[dh][dw] == 1e9 ? -1 : cost[dh][dw]);
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // }

  return 0;
}

Measured memory_bytes: 9672
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int res = 0;
  for (int i = 0; i < N; i++){
    vector<bool> X(26,false);
    for (int j = 0; j < i; j++){
      X[S[j] - 'a'] = true;
    }
    vector<bool> Y(26,false);
    for (int j = i; j < N; j++){
      Y[S[j] - 'a'] = true;
    }
    int count = 0;
    for (int j = 0; j < 26; j++) if (X[j] && Y[j]) count++;
    res = max(res,count);
  }
  cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b,c,d;
	bool bj=0;
	cin>>a>>b>>c>>d;
	if(a==b&&b==c)bj=1;
	if(b==c&&c==d)bj=1;
	if(bj)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int x,y,i,j;
   for(;;){
      scanf("%d %d",&y,&x);
      if(x+y==0) break;
      for(i=0;i<y;i++){
         for(j=0;j<x;j++)
            if((i+j)%2==0)
               printf("#");
            else
               printf(".");
         printf("\n");
      }
   printf("\n");
   }
   return 0;
}


Measured memory_bytes: 2108
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2013
//大崎
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

std::vector<std::string> split(const std::string& input, char delimiter){
  std::istringstream stream(input);
  std::string field;
  std::vector<std::string> result;
  while (std::getline(stream, field, delimiter)) {
    result.push_back(field);
  }
  return result;
}

ll solve(){
  vector<vector<vector<ll>>> hms(24+1,vector<vector<ll>>(60+1, vector<ll>(60+1)));
  ll n; cin>>n;
  if (n==0)return -1;
  REP(i,n){
    string s,e; cin>>s>>e;
    auto gett =[](const string& is){
      vector<ll> ret;
      auto lst=split(is,':');
      REP(ii,3){
        int v=std::atoi(lst.at(ii).c_str());  
        ret.push_back(v);
      }
      return ret;
    };
    auto stt = gett(s);
    auto edd = gett(e);
    // dump(stt);
    // dump(edd);
    hms[stt[0]][stt[1]][stt[2]] += 1;

    // edd[2] += 1;
    // if(edd[2]==60){
    //   edd[2]=0;
    //   edd[1]+=1;
    //   if(edd[1]==60){
    //     edd[1]=0;
    //     edd[0]+=1;
    //   }
    // }
    hms[edd[0]][edd[1]][edd[2]] -= 1;
  }

  ll v= 0;
  ll ans=0;
  REP(h,24){
    REP(m,60){
      REP(s,60){
        v += hms[h][m][s];
        chmax(ans,v);
      }
    }
  }
  cout<<ans<<endl;
  return ans;
}
int main() {
#if LOCAL&01
  //std::ifstream in("./test/sample-1.in");
  std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  while(solve()!=-1){
  }
  return 0;
}


Measured memory_bytes: 3828
x = int(input())

if 400 <= x <= 599:
  print(8)
elif 600 <= x <= 799:
  print(7)
elif 800 <= x <= 999:
  print(6)
elif 1000 <= x <= 1199:
  print(5)
elif 1200 <= x <= 1399:
  print(4)
elif 1400 <= x <= 1599:
  print(3)
elif 1600 <= x <= 1799:
  print(2)
elif 1800 <= x <= 1999:
  print(1)


Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int A[] = new int[N];
			for (int i = 0; i < N; i++) {
				A[i] = s.nextInt();
			}

			final int r[] = new int[N + 1];

			for (int i = N - 1; i > 0; i--) {
				r[i] = gcd(A[i], r[i + 1]);
			}

			int ret = 0;
			int left = 0;
			for (int i = 0; i < N; i++) {
				ret = Math.max(gcd(left, r[i + 1]), ret);
				left = gcd(left, A[i]);
			}
			System.out.println(ret);
		}
	}

	static int gcd(int a, int b) {
		if (a == 0 || b == 0) {
			return a == 0 ? b : a;
		}

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


Measured memory_bytes: 51004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    string s; cin >> s;
    int cnt = 0;
    rep(i, s.size()) {
        if(s[i] == '1') cnt++;
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a<b)
{
printf("a < b\n");
}
if(a==b)
{
printf("a == b\n");
}
if(a>b)
{
printf("a > b\n");
}
return 0;
}

Measured memory_bytes: 580
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll h,w;
    cin >> h >> w;
    vector<vector<ll>> a(h,vector<ll>(w));
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    vector<pll> be,af;
    rep(i,h-1){
        rep(j,w){
            if(a[i][j]%2==1){
                a[i][j]--;
                a[i+1][j]++;
                be.push_back(make_pair(i+1,j+1));
                af.push_back(make_pair(i+2,j+1));
            }
        }
    }
    rep(i,w-1){
        if(a[h-1][i]%2==1){
            a[h-1][i]--;
            a[h-1][i+1]++;
            be.push_back(make_pair(h,i+1));
            af.push_back(make_pair(h,i+2));
        }
    }
    cout << be.size() << endl;
    rep(i,be.size()){
        cout << be[i].fi << " " << be[i].se << " " << af[i].fi << " " << af[i].se << endl;
    }
    return 0;
} 

Measured memory_bytes: 8120
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    dp0 = [0] * (w + 1)
    dp1 = [0] * (w + 1)
    dp2 = [0] * (w + 1)
    dp3 = [0] * (w + 1)
    for i in range(h):
        for j in range(w):
            v = vv[i * w + j]
            if v:
                dp3[j] = max(dp3[j], dp2[j] + v)
                dp2[j] = max(dp2[j], dp1[j] + v)
                dp1[j] = max(dp1[j], dp0[j] + v)
            dp3[j + 1] = max(dp3[j + 1], dp3[j])
            dp2[j + 1] = max(dp2[j + 1], dp2[j])
            dp1[j + 1] = max(dp1[j + 1], dp1[j])
            dp0[j] = max(dp1[j], dp2[j], dp3[j])
    print(dp0[-2])

h, w, k = MI()
vv = [0] * h * w
for _ in range(k):
    i, j, v = MI()
    i, j = i - 1, j - 1
    vv[i * w + j] = v
solve()


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

using ll = long long;
using pii = pair<int, int>;

template <typename T> T inf;
template <> int inf<int> = 1e9;
template <> ll inf<ll> = 1e18;

int main() {
    string S;
    cin >> S;
    string s = "AKIHABARA";
    bool ok = true;
    int pos1 = 0, pos2 = 0;
    for(; pos1 < S.size() && pos2 < s.size(); ++pos1) {
        //cout << S[pos1] << ' ' << s[pos2] << endl;
        if(S[pos1] == s[pos2]) {
            pos2++;
        } else if(s[pos2] == 'A') {
            pos2++;
            pos1--;
        } else {
            ok = false;
        }
    }
    //cout << pos1 << ' ' << pos2 << endl;
    if(ok && pos2 + 1 >= s.size() && pos1 == S.size()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N, A, B := getInt(), getInt(), getInt()

	if A != 0 {
		ab := A + B
		n := N / ab
		m := N % ab
		if m > A {
			m = A
		}
		blue := n*A + m
		out(blue)
	} else {
		out(0)
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
const double PI = 3.14159265359;

int main() {
    double r;
    cin >> r;
    double ans = 2*r*PI;
    printf("%.10lf", ans);
    return 0;
}

Measured memory_bytes: 3764
kn_list = input().split(" ")
K = int(kn_list[0])
N = int(kn_list[1])
a_list = [int(num) for num in input().split(" ")]

max_distance = 0
for i in range(N-1):
    distance = a_list[i+1] - a_list[i]
    if max_distance < distance:
        max_distance = distance
if max_distance < K - (a_list[N-1]-a_list[0]):
    max_distance = K - (a_list[N-1]-a_list[0])
print(K - max_distance)


Measured memory_bytes: 26444
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<int, pair<int, int>> tup;

inline void solve()
{
	int n, k;
	cin >> n >> k;
	int cnt = 0;

	while (n)
	{
		n /= k;
		cnt++;
	}

	cout << cnt;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
typedef long long ll;

int main()
{	
	string s;
	cin>>s;
	
	int b=0;
	int w=0;
	int flg=2;
	rep(i,s.size()){
		if(s[i]=='B' && flg!=0){
			b++;
			flg=0;
		}
		else if(s[i]=='W' && flg!=1){
			w++;
			flg=1;
		}
	}
	
	cout<<b+w-1<<endl;
	
	return 0;
}



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

int main(){
  char s[10];
  char t[10];
  char u[10];
  int a,b;
  scanf("%s%s",s,t);
  scanf("%d%d",&a,&b);
  scanf("%s",u);
  int sum=0;
  if(strcmp(s,u)==0) a--;
  if(strcmp(t,u)==0) b--;

  printf("%d %d\n",a,b);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;


int main(){
    int m;
    cin >> m;
    for (int q =0; q <m; q++) {
        string S;
        cin >> S;
        set<string> Q;
        for (int i=0; i<S.length(); i++) {
            string l,lrev,r,rrev;
            l = S.substr(0,i);
            r = S.substr(i,S.length()-i);
            lrev = l;
            rrev = r;
            reverse(lrev.begin(), lrev.end());
            reverse(rrev.begin(), rrev.end());
            //cout << l << endl << r << endl << lrev << endl << rrev <<endl << "==" <<endl;
             Q.insert(l+r);
            Q.insert(r+l);
            Q.insert(lrev+r);
            Q.insert(r+lrev);
            Q.insert(l+rrev);
            Q.insert(rrev+l);
            Q.insert(lrev+rrev);
            Q.insert(rrev+lrev);
        }
        cout << Q.size()<<endl;
    }
}

Measured memory_bytes: 1292
using System;
using System.Collections.Generic;
using System.Linq;

public static class Prg{
    public static Scanner sc = new Scanner();
    public static void Main(){
        var s1 = new string(sc.ReadLine().ToCharArray().Reverse().ToArray());
        var s2 = sc.ReadLine();
        Console.WriteLine(s1==s2?"YES":"NO");
    }
}

public static class Extension{
    public static IEnumerable<int> To(this int from, int to){
        return Enumerable.Range(from, to);
    }

    public static void Times(this int times, Action<int> action){
        0.To(times).ToList().ForEach(x => action(x));
    }
}
public class Scanner{
    private string line;
    private string[] token;
    private int cursole = 0;
    
    public string ReadLine(){
        line = Console.ReadLine();
        token = line.Split(' ');
        cursole = 0;
        return line;    
    }
    
    public string Next(){
        if(token == null) ReadLine();
        if(token.Length <= cursole) ReadLine();
        var ret = token[cursole];
        ++cursole;
        return ret;
    }

    public IEnumerable<double> NextDoubleList(){
        return NextList().Select(s => Double.Parse(s));
    }

    public int NextInt(){return Int32.Parse(Next());}
    
    public long NextLong(){return Int64.Parse(Next());}

    public double NextDouble(){return Double.Parse(Next());}

    public IEnumerable<string> NextList(){
        ReadLine();
        cursole = Int32.MaxValue;
        return token;
    }
    
    public IEnumerable<int> NextIntList(){
        return NextList().Select(s => Int32.Parse(s));
    }
}

Measured memory_bytes: 13268
from collections import deque

def bfs2(g,n,m):
    pre=[0 for _ in range(n+1)]
    pre[1]=1
    q=deque([1])
    while q:
        x=q.popleft()
        for i in range(len(g[x])):
            if pre[g[x][i]]==0:
                q.append(g[x][i])
                pre[g[x][i]]=x
    return pre

def main2():
    #normal input
    n,m=map(int,input().strip().split())
    g=[[] for _ in range(n+1)]
    for _ in range(m):
        a,b=map(int,input().strip().split())
        g[a].append(b)
        g[b].append(a)
        
    pre=bfs2(g,n,m)
    
    print("Yes" if 0 not in pre[1:] else "No")
    for i in range(2,len(pre)):
        print(pre[i])

if __name__=="__main__":
    main2()

Measured memory_bytes: 34528
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;

	auto dp = make_v<int>(s.size() + 1, 3); dp[0][0] = 0;
	for(int i = 0; i < s.size(); i++) {
		for(int j = 0; j < 3; j++) {
			if(i < j) continue;
			
			std::string nt = "";
			std::string pt = s.substr(i - j, j);
			
			for(int k = 1; k < 3 and i + k - 1 < s.size(); k++) {
				nt += s[i + k - 1];
				if(pt == nt) continue;
				
				dp[i + k][k] = std::max(dp[i + k][k], dp[i][j] + 1);
			}
		}
	}
	printf("%d\n", std::max({dp[s.size()][0], dp[s.size()][1], dp[s.size()][2]}));
	return 0;
}


Measured memory_bytes: 11396
while True:
    n,m = map(int,input().split())
    if n==0 and m==0:
        break
    lt=[]
    lh= []
    for i in range(n):
        sn=int(input())
        lt.append(sn)
    for j in range(m):
        sm=int(input())
        lh.append(sm)
    s = (sum(lt)+sum(lh))/2
    st= abs(s-sum(lt))
    lt.sort()  
    lh.sort()
    if sum(lt) < sum(lh):
        ans = -1
        for i in lt:
            if ans==-1:
                for j in lh:
                    if i + st == j:
                        print(i,j)
                        ans = 1
                        break
        if ans==-1:
            print(ans)
    else:
        ans = -1
        for j in lh:
            if ans==-1:
                for i in lt:
                    if j + st == i:
                        print(i,j)
                        ans = 1
                        break 
        if ans==-1:
            print(ans)
    
                


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

int main() {
    //入力
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

    int ans = 0;
    rep(i, n-2) {
        for (int j = i + 1;j < n - 1;++j) {
            for (int k = j + 1;k < n;++k) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) {
                    //一致有り
                }
                else {
                    if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
                        //                    cout << i << ":" << j << ":" << k << endl;
                        ++ans;
                    }
                }
            }
        }
    }

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

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <queue>

using namespace std ;

struct Node
{
    int x , y ;
    bool black ;
} matrix [ 1000 ] [ 1000 ] ;

string arr [ 1000 ] ;

int main()
{
    int h , w , cnt = 0 , res = 0 ;
    cin >> h >> w ;
    for ( int i = 0 ; i < h ; i ++ )
        cin >> arr [ i ] ;
    queue<Node> q ;
    while ( !q.empty() )
        q.pop() ;
    for ( int i = 0 ; i < h ; i ++ )
    {
        for ( int j = 0 ; j < w ; j ++ )
        {
            matrix [ i ] [ j ].x = i ;
            matrix [ i ] [ j ].y = j ;
            matrix [ i ] [ j ].black = ( arr [ i ] [ j ] == '#' ) ;
            if ( matrix [ i ] [ j ].black )
            {
                q.push ( matrix [ i ] [ j ] ) ;
            }
        }
    }
    Node n ;
    while ( !q.empty() )
    {
        cnt = q.size() ;
        while ( cnt -- )
        {
            n = q.front() ;
            q.pop() ;
            if ( n.x > 0 )
            {
                if ( !matrix [ n.x - 1 ][ n.y ].black )
                {
                    matrix [ n.x - 1 ] [ n.y ].black = true ;
                    q.push ( matrix [ n.x - 1 ] [ n.y ] ) ;
                }
            }
            if ( n.y < w - 1 )
            {
                if ( !matrix [ n.x ] [ n.y + 1 ].black )
                {
                    matrix [ n.x ] [ n.y + 1 ].black = true ;
                    q.push ( matrix [ n.x ] [ n.y + 1 ] ) ;
                }
            }
            if ( n.x < h - 1 )
            {
                if ( !matrix [ n.x + 1 ] [ n.y ].black )
                {
                    matrix [ n.x + 1 ] [ n.y ].black = true ;
                    q.push ( matrix [ n.x + 1 ] [ n.y ] ) ;
                }
            }
            if ( n.y > 0 )
            {
                if ( !matrix [ n.x ] [ n.y - 1 ].black )
                {
                    matrix [ n.x ] [ n.y - 1 ].black = true ;
                    q.push ( matrix [ n.x ] [ n.y - 1 ] ) ;
                }
            }
        }
        res ++ ;
    }
    cout << res - 1 << endl ;
}


Measured memory_bytes: 25104
#include <iostream>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int k,p;
		cin>>k>>p;

		int j=1;
		while(--k){
			++j;
			if(j==p+1)j=1;
		}
		cout<<j<<endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    multiset<ll> a;
    rep(i, n)
    {
        ll tempA;
        cin >> tempA;
        a.insert(tempA);
    }
    ll result = 0;
    ll remains = n;
    result += (*a.rbegin());
    --remains;
    --remains;
    for (auto itr = (++a.rbegin()); remains > 0; ++itr)
    {
        if (remains >= 2)
        {
            result += (*itr) * 2;
            remains -= 2;
        }
        else
        {
            result += (*itr);
            --remains;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 12520
from bisect import bisect_left
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)

i = a[-1]
ave_index = bisect_left(a,i/2)
if ave_index == 0:
    j=a[0]
elif ave_index == n-1:
    j=a[-2]
else:
    if a[ave_index]*2 - i < i - a[ave_index-1]*2:
        j = a[ave_index]
    else:
        j = a[ave_index-1]
print(i,j)

Measured memory_bytes: 14420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long T = in.nextLong();
            long[] t = in.nextLongArray(n);

            long ans = n * T;
            for (int i = 0; i < n - 1; i++) {
                if (t[i + 1] - t[i] < T) ans -= T - (t[i + 1] - t[i]);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

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

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 45780
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    dis=[INFI for _ in range(n+1)]
    graph=[[] for _ in range(n+1)]
    for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
    stack=[]
    visited=[0 for _ in range(n+1)]
    dis[0]=0
    dis[1]=0
    for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
    while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
    for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1)




if __name__ == "__main__":

    main()

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

struct UnionFind{
    vector<int> P;

    UnionFind(int n) : P(n, -1){ }
    void init(int n){ P.assign(n, -1); }

    int root(int a){
        if(P.at(a) < 0) return a;
        return P.at(a) = root(P.at(a));
    }
    bool same(int a, int b){
        return root(a) == root(b);
    }
    void unite(int a, int b){
        a = root(a); b = root(b);
        if(a == b) return;
        if(P.at(a) > P.at(b)) swap(a, b);
        P.at(a) += P.at(b);
        P.at(b) = a;
    }
    int size(int a){
        return -P.at(root(a));
    }

};

int main(){
    ll n, m; cin >> n >> m;
    UnionFind tree(n);
    vector<pair<int, int>> e(m);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        e.at(m-1-i) = {a, b};
    }
    vector<ll> ans(m);
    ll tmp = n*(n-1)/2;
    for(int i = 0; i < m; i++){
        ans.at(i) = tmp;
        int a = e.at(i).first , b = e.at(i).second;
        if(tree.same(a, b)) continue;

        ll asize = tree.size(a), bsize = tree.size(b);
        tmp -= asize*bsize;
        tree.unite(a, b);
    }
    reverse(ans.begin(), ans.end());
    for(int i = 0; i < m; i++){
        cout << ans.at(i) << endl;
    }
}

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

int main() {
  int a, b;
  char s[11], t[11], u[11];
  scanf("%s %s %d %d %s", s, t, &a, &b, u);

  if(strcmp(s, u) == 0) printf("%d %d\n", a - 1, b);
  else printf("%d %d\n", a, b - 1);
  return 0;
}


Measured memory_bytes: 1732
H, W = map(int, input().split(' '))
matrix = []
for _ in range(H):
    tmp = [0 if j == '.' else 1 for j in input()]
    matrix.append(tmp)

flag = 'Yes'
for i, row in enumerate(matrix):
    for j, s in enumerate(row):
        if s == 1:
            if (j > 0 and row[j-1] == 0) and (j < W - 1 and row[j+1] == 0):
                if (i > 0 and matrix[i-1][j] == 0) and (i < H - 1 and matrix[i+1][j] == 0):
                    flag = 'No'
                    break

print(flag)


Measured memory_bytes: 3064
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    #print(hako)
    hako="".join(hako)
    #hako=hako.replace(",","")
    #print(hako)
    kotae=eval(hako)
    ans+=kotae
print(ans)

Measured memory_bytes: 39920
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int cnt(int b, int e) {
    if (e - b <= 1) return 0;
    int mid = (b + e) / 2;
    return cnt(b, mid) + cnt(mid, e) + e - b;
}

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

    vector<int> S(N);
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }

    sort(S.begin(), S.end());
    for (int i = 0; i < N; ++i) {
        cout << S[i] << (i == N - 1 ? "" : " ");
    }
    cout << endl;
    cout << cnt(0, N) << endl;
    return 0;
}



Measured memory_bytes: 4684
// 前から解くバージョン
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    // 先頭から見ていくバージョン
    int counter = 0, result = 0;
    int formerHeight;
    int currentHeight;
    for (int i = 0; i < n; i++) {
        cin >> currentHeight;
        if (i > 0 && formerHeight >= currentHeight) {
            ++counter;
        } else {
            counter = 0;
        }
        result = max(result, counter);
        formerHeight = currentHeight;
    }
 
    cout << result << endl;
}
 


Measured memory_bytes: 256
s = input()
ans = 0
for i in range(3):
  if s[i]=="R":
    temp = 1
    count = i
    flg=False
    while count<3 and s[count]=="R":
      flg=True
      temp+=1
      count+=1
    if flg:
      temp-=1
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 61656
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int X;

int main(void) {
    cin >> X;

    REP(i, 20) {
        REP(j, 25) {
            REP(k, 34) {
                REP(l, 50) {
                    REP(m, 100) {
                        int tmp = 105 * i + 104 * j + 103 * k + 102 * l + 102 * m;
                        if (X >= tmp && (X - tmp) % 100 == 0) {
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }

    cout << 0 << endl;
}


Measured memory_bytes: 256
S = input("")
S = list(S)
S_len = len(S)
S_even = []
S_odd = []
index_even = 0
index_odd = 1
while index_even < S_len:
    S_odd.append(S[index_even])
    index_even += 2
while index_odd < S_len:
    S_even.append(S[index_odd])
    index_odd += 2
count_L = S_odd.count("L")
count_R = S_even.count("R")
if count_L == 0 and count_R == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    while (1) {
        string n;
        cin >> n;
        if (n == "0") return 0;
        
        int sm[80020];
        for (int i = 0; i <= n.size(); i++) {
            if (i == 0) sm[i] = 0;
            else sm[i] = sm[i - 1] + pow(-1, i) * char(n[i - 1] - '0');
            if (sm[i] < 0) sm[i] += 11;
            sm[i] %= 11;
        }
        
        int v[80080][11];
        
        for (int i = 0; i <= n.size(); i++) {
            for (int j = 0; j < 11; j++) {
                if (i == 0) {
                    if (j == 0) v[i][j] = 1;
                    else v[i][j] = 0;
                }
                else if (sm[i] == j) v[i][j] = v[i - 1][j] + 1;
                else v[i][j] = v[i - 1][j];
            }
            //cout << sm[i] << " ";
        }
        //cout << endl;
        
        /*
        for (int i = 0; i <= n.size(); i++) {
            for (int j = 0; j < 11; j++) cout << v[i][j] << " ";
            cout << endl;
        }*/
        
        int dp[80080] = {};
        for (int i = 0; i < n.size(); i++) {
            if (i == 0) dp[i] = v[int(n.size())][sm[i]] - v[i][sm[i]];
            else if (char(n[i]) != '0') {
                dp[i] = dp[i - 1] + v[int(n.size())][sm[i]] - v[i][sm[i]];
            }
            else dp[i] = dp[i - 1];
        }
        cout << dp[n.size() - 1] << endl;
        
        
    }
}



Measured memory_bytes: 7376
def gcd(x,y):
    if x < y:
        (x,y) = (y,x)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x


n,m = map(int, input().split())
s = str(input())
t = str(input())
lcm = (n*m) // gcd(n,m)

ind_s = lcm // m
ind_t = lcm // n

list_s = s[0::ind_s]
list_t = t[0::ind_t]

if list_s == list_t:
	print(lcm)
else:
	print(-1)


Measured memory_bytes: 3316