akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> void Exit(T first){cout << first << endl;exit(0); };

int main(){
    iosetup;
    string S; cin >> S;
    string hi = "hi";
    string tmp = hi;
    rep(i, 0, 6){
        if(S == tmp) Exit("Yes");
        tmp  += hi;
    }
    Exit("No");

    return 0;
}

Measured memory_bytes: 256
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const ll INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1000000007;
// const ll MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("input.txt", "r", stdin);
       // freopen("output.txt", "w", stdout);
#endif
}

void solve(){
    int n;
    cin >> n;
    vi kek = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << kek[n-1] << endl;
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    while(q--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long y = sc.nextLong();

		sc.close();

		if(y > x) {
			long tmp;
			tmp = x;
			x = y;
			y = tmp;
		}

		long ans = gcd(x, y);

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {

		if(y == 0) return x;

		return gcd(y, x%y);

	}
}

Measured memory_bytes: 26384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	bool ans = true;
	if (N % 2 == 1)
		ans = 0;
	else {
		rep(i, N / 2) {
			if (S[i] != S[i + N / 2])
				ans = 0;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}

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

namespace arc100_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < n; i++) x[i] -= i + 1;
            Array.Sort(x);
            long median = x[(n - 1) / 2] + x[n / 2]; median /= 2;
            long ret = 0;
            for (int i = 0; i < n; i++) ret += Math.Abs(x[i] - median);
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 30940
//There was and will always be only one Chester. RIP legend
//--------------------Life is beautiful--------------------
#include<bits/stdc++.h>
using namespace std;
#define Nilesh ios_base::sync_with_stdio(false);
int main()
{
	Nilesh
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-b)%c;

}


Measured memory_bytes: 256
X, Y = map(int, input().split())
if X % Y == 0:
    print(-1)
    exit()

# for i in range(int(1e9), 0, -1):
for i in range(1, int(1e9)):
    if X * i % Y != 0:
        print(X * i)
        exit()
print(-1)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            long n = int.Parse(Console.ReadLine());

            var a = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = int.Parse(Console.ReadLine()) - 1;
            }

            var hash = new HashSet<int>();

            var last = a[0];

            var result = -1;

			for (int i = 1; ; i++) {
                if (last == 1) {
                    result = i;
                    break;
                }

                if (hash.Contains(last)) {
                    break;
				}

                hash.Add(last);
                last = a[last];
            }

            Console.WriteLine(result);
        }

        public static long Pow(long a, long b, long mod = 0L)
        {
            var temp = a;
            var ans = 1L;

            for(int i = 1; i <= b;i <<= 1) {
                if((b & i) != 0) {
                    ans *= temp;
                    if (mod != 0) {
                        ans %= mod;
                    }
                }

                temp *= temp;
                if(mod != 0) {
                    temp %= mod;
                }
            }

            return ans;
        }
    }
}


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

int main() {
	// your code goes here
	int n;
	while(cin >> n && n){
	for(int i=0;i<n;i++){
		int f[4][4]={},s;
		for(int k=0;k<2;k++)
			for(int j=0;j<4;j++)
				cin >> f[j][k];
		for(int j=0;j<4;j++)
			for(int k=0;k<4;k++){
				s=f[j][0]*f[k][1];
				if(j==k)
					if(j==0)
						f[0][3]+=s;
					else
						f[0][3]-=s;
				else if(k+j==3)
					if(k==1)
						f[3][3]-=s;
					else
						f[3][3]+=s;
				else if((j+2)%4==k)
					if(k==3)
						f[2][3]-=s;
					else
						f[2][3]+=s;
				else
					if(k==2)
						f[1][3]-=s;
					else 
						f[1][3]+=s;
			}
	cout << f[0][3] <<" "<< f[1][3] <<" "<< f[2][3] <<" "<< f[3][3]<< endl;

	}
	}
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scanf("%d", &k)

	bf := 7

	n := bf % k
	cache := map[int]bool{}

	if n == 0 {
		fmt.Println(1)
		return
	}
	cache[n] = true

	for i := 0; i < 1000000; i++ {
		if n = (n*10 + 7) % k; n == 0 {
			fmt.Println(i + 2)
			return
		}
		if _, ok := cache[n]; ok {
			break
		}
		cache[n] = true
	}
	fmt.Println(-1)
}


Measured memory_bytes: 51728
import math
N = int(input())

min_value = -1
limit = math.floor(math.sqrt(N))
for n in range(1, limit+1):
  if (N % n != 0):
    continue
  else:
    A = n
    B = N // n
    len_A = len(str(A))
    len_B = len(str(B))
    F = len_A if (len_A > len_B) else len_B
    if (min_value == -1):
      min_value = F
    else:
      if (min_value > F):
        min_value = F

print(min_value)

Measured memory_bytes: 3064
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}

int a, b, c, d;
signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0 && s[i] == '0') {
			a++;
		}
		if (i % 2 == 0 && s[i] == '1') {
			b++;
		}
		if (i % 2 == 1 && s[i] == '0') {
			c++;
		}
		if (i % 2 == 1 && s[i] == '1') {
			d++;
		}
	}
	cout << min(a + d, b + c) << endl;
}





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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	cin>>r;
	if(r<1200){
		cout<<"ABC"<<'\n';
	}
	else if(r<2800){
		cout<<"ARC"<<'\n';
	}
	else{
		cout<<"AGC"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
struct data{int l,r;};
int N,M,r,q;
vector<data> g[10001];

void init(){
  for(int i=0;i<10001;i++)g[i].clear();
}

int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    init();
    stack<int> st[10001];
    cin>>r;
    for(int i=0;i<r;i++){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      if(s){
	st[m].push(t);
      }else{
	int x=st[m].top();st[m].pop();
	if(st[m].empty())g[m].push_back((data){x,t});
      }
    }
    cin>>q;
    for(int i=0;i<q;i++){
      int a,b,m,sum=0;
      cin>>a>>b>>m;
      for(int i=0;i<(int)g[m].size();i++){
	data d=g[m][i];
	if(d.r<=a||b<=d.l)continue;
	sum+=(min(d.r,b)-max(d.l,a));
      }
      cout<<sum<<endl;
    }
  }
}

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

int main(){
  
  int N;
  cin >> N;
  
  string Ans = "YES" ;
  
  vector<int> a(N);
  
  for(int i = 0; i<N;i++){
  cin >> a.at(i);
  }
 
  sort(a.begin(),a.end());
  
  for(int i = 0; i<N-1;i++){
  	if(a.at(i) == a.at(i+1)){
    	Ans = "NO";
      	break;
    }
  }
  
  cout << Ans << endl;
  
}

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

using namespace std;

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

    int64_t a = 2, b = 1, c;

    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    for (n -= 1; n > 0; --n) {
        c = a + b;
        a = b;
        b = c;
    }

    cout << c << endl;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int n, k;
  cin >> n >> k;
  cout << (n % k == 0 ? 0 : 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> L(2*N);
  for(int i=0;i<2*N;i++){
    cin>>L.at(i);
  }
  sort(L.begin(),L.end());
  int count=0;
  for(int i=0;i<2*N;i++){
    if(i%2==0){
     count+=L.at(i); 
    }
  }
  cout<<count;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc128/tasks/abc128_a
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int A, P;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> P;

	P += A * 3;
	int ans = P / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
a = 0
b = 0
c = 0
for i in range(N):
  if P[i] <= A: a += 1
  elif P[i] >= B + 1: c += 1
  else: b += 1
print(min(a,b,c))


Measured memory_bytes: 3060
from collections import Counter
N=int(input())
S=sorted([input() for _ in range(N)])
S=Counter(S).most_common()
m=S[0][1]

ans=[]
for i in S:
  if i[1]==m:
    ans.append(i[0])
  else:
    break

ans.sort()
for i in ans:
  print(i)

Measured memory_bytes: 120016
A, B, K = list(map(int, input().split()))
Co = [A, B]

for i in range(K):
  if Co[i % 2] % 2 == 1:
    Co[i % 2] -= 1
  Co[i % 2] /= 2
  Co[(i+1) % 2] += Co[i % 2]

Co = list(map(int, Co))
print(Co[0], Co[1])

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

using namespace std;

int main(){
  int n,m,l;
  cin>>n>>m>>l;
  int A[n+1][m+1],B[m+1][l+1];
  for(int i=1;i<=n;i++){
    for(int v=1;v<=m;v++){
      cin>>A[i][v];
    }
  }
  for(int i=1;i<=m;i++){
    for(int v=1;v<=l;v++){
      cin>>B[i][v];
    }
  }
  // ここまでインプット
  long C[n+1][l+1];
  for(int i=1;i<=n;i++){
    for(int v=1;v<=l;v++){
      C[i][v]=0;
    }
  }
  for(int i=1;i<=n;i++){
      for(int v=1;v<=l;v++){
        for(int k=1;k<=m;k++){
        C[i][v]+=A[i][k]*B[k][v];
      }
    }
  }
  for(int i=1;i<=n;i++){
    for(int v=1;v<=l;v++){
      if(v==l){
        cout<<C[i][v]<<endl;
      }else{
        cout<<C[i][v]<<" ";
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    mp::cpp_int N, K;
    cin >> N >> K;
    vector<mp::cpp_int> A((int)N);
    for (int i = 0; i < N; i++) cin >> A[i];
    mp::cpp_int ans = 0;
    for (int i = 0; i < N; i++) {
        mp::cpp_int temp = 0;
        for (int j = 0; j < N; j++) {
            if (K == 1 && j == 0) continue;
            if (A[i] > A[j]) {
                if (i >= j) temp += ((K - 1) * K / 2) % mod;
                else temp += (K * (K + 1) / 2) % mod;
            }
            temp %= mod;
        }
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

static const int MOD = 1000000007;

map<int, int> mp;

void primeFact(int n) {
    for(int i = 2; i <= n; i++) {
        while(n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
}

signed main() {
    int n; cin >> n;

    for(int i = 1; i <= n; i++) {
        primeFact(i);
    }

    int res = 1;
    for(auto i = mp.begin(); i != mp.end(); i++) {
        res *= i -> second + 1;
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}


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

int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a.at(i);
  }

  int64_t money = 1000;
  for (int i = 1; i < n; i++) {
    if (a.at(i) < a.at(i + 1)) {
      int64_t stock = money / a.at(i);
      money += stock * (a.at(i + 1) - a.at(i));
    }
  }

  cout << money << endl;
}

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

const ll INF = 1e18;
ll d[305][305];
ll cnt[305][305];

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    rep(i, n) rep(j, n) d[i][j] = cnt[i][j] = INF;
    int a, b, c;
    rep(i, m) {
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = d[b][a] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    }
    rep(i, n) rep(j, n) {
        if (d[i][j] <= l) cnt[i][j] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        cnt[i][j] = min(cnt[i][j], cnt[i][k]+cnt[k][j]);
    }
    int q;
    cin >> q;
    rep(i, q) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if (cnt[s][t]==INF) {
            cout << -1 << endl;
        } else {
            int ans = cnt[s][t] - 1;
            cout << ans << endl;
        }
    }
    return 0;
}

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

using namespace std;

const int mod = (int)1e9 + 7;

int mul[100005];
int p[100005];

int quickPow(const int& x, const int& d) {
  int n = d;
  long long ret = 1, temp = x;
  while (n) {
    if (n & 1)
      ret = ret * temp % mod;
    temp = temp * temp % mod;
    n >>= 1;
  }
  return ret % mod;
}

void init(const int& n) {
  mul[0] = 1;
  for (int i = 1; i <= n; ++i)
    mul[i] = (long long)mul[i - 1] * i % mod;
}

int c(const int& n, const int& m) {
  if (m > n)
    return 0;
  return (long long) mul[n] * quickPow(mul[n - m], mod - 2) % mod * quickPow(mul[m], mod - 2) % mod;
}

int main()
{
  int n;
  scanf("%d", &n);
  ++n;
  init(n);
  int d;
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    if (p[x] != 0)
      d = (p[x] - 1) + (n - i);
    p[x] = i;
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\n", (c(n, i) - c(d, i - 1) + mod) % mod);
  return 0;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        long t_pre = 1, a_pre = 1;
        for(int i=0; i<n; i++){
            String[] str = br.readLine().split(" ");
            long t = Integer.parseInt(str[0]);
            long a = Integer.parseInt(str[1]);

            long rate = Math.max(t_pre/t + (t_pre%t==0 ?0:1), a_pre/a + (a_pre%a==0?0:1));
            t_pre = rate * t;
            a_pre = rate * a;
        }
        System.out.println(t_pre + a_pre);
    }
}


Measured memory_bytes: 22996
import sys
s = input()
pre = []
back = []
for i in range((len(s)-1)//2):
    pre.append(s[i])
s1 = ''.join(pre)

for i in range((len(s)+3)//2-1,len(s)):
    back.append(s[i])
s2 = ''.join(back)

if s != s[::-1]:
    print('No')
    sys.exit()
elif s1 != s1[::-1]:
    print('No')
    sys.exit()
elif s2 != s2[::-1]:
    print('No')
    sys.exit()
print('Yes')

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



int n,m,k;
pair <int,int> bl[100005], fr[100005];
int nfr[100005],nbl[100005];
int r[100005];

void inp()
{
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++)
    cin >> fr[i].first >> fr[i].second;
    for (int i = 0; i < k; i++)
    cin >> bl[i].first >> bl[i].second;
}


int root(int x)
{
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
}

int merg(int r1,int r2)
{
    if (r1 < r2 ) swap(r1,r2);
    r[r1] += r[r2];
    r[r2] = r1;
}


void pre()
{
    for (int i = 1; i <= n; i++) r[i] = -1;
    for (int i = 0; i < m; i++)
    {
        nfr[fr[i].first]++;
        nfr[fr[i].second]++;
        int r1 = root(fr[i].first);
        int r2 = root(fr[i].second);
        if (r1 != r2)
        merg(r1,r2);
    }
}



void proc()
{
    for (int i = 0; i < k; i++)
    {
        int b1,b2;
        b1 = bl[i].first;
        b2 = bl[i].second;
        int r1 = root(b1);
        int r2 = root(b2);
        if (r1 == r2)
        {
            nbl[b1]++;
            nbl[b2]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        int t = root(i);
        t = r[t];
        t = -t;
        cout << t - nbl[i] - nfr[i] - 1 << ' ';
    }
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    inp();
    pre();
    proc();
    return 0;
}


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

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, a;
	cin >> n;
	bool res = true;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0))
				res = false;
	}
	cout << (res? "APPROVED": "DENIED") << endl;
	return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b_ls = list(map(int,input().split()))
temp_sum = c
ans = 0
for i in range(n):
    a_ls = list(map(int,input().split()))
    temp_sum = c
    for j in range(m):
        temp_sum += a_ls[j] * b_ls[j]
    if temp_sum > 0:
        ans += 1
print(ans)

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

const int N = 2 * 1000 * 100 + 10;
int n, K, L, col[2][N], cnt[2], ans[N];
vector<int> adj[2][N];
bool vis[2][N];
map<pair<int, int>, int> res;
	

void dfs(int root, bool tp) {
	if (tp) {
		res[make_pair(cnt[tp], col[0][root])]++;
		res[make_pair(col[0][root], cnt[tp])]++;
	}
	vis[tp][root] = true;
	col[tp][root] = cnt[tp];
	for (auto u: adj[tp][root])
		if (!vis[tp][u])
			dfs(u, tp);
}

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> K >> L;
	for (int i = 1, v, u; i <= K; i++) {
		cin >> v >> u;
		adj[0][v].push_back(u);
		adj[0][u].push_back(v);
	}
	for (int i = 1, v, u; i <= L; i++) {
		cin >> v >> u;
		adj[1][v].push_back(u);
		adj[1][u].push_back(v);
	}
	for (int i = 1; i <= n; i++)
		ans[i] = 1;
	for (int i = 1; i <= n; i++)
		if (!vis[0][i]) {
			cnt[0]++; 
			dfs(i, 0);
		}
	cnt[1] = cnt[0];
	for (int i = 1; i <= n; i++)
		if (!vis[1][i]) {
			cnt[1]++;
			dfs(i, 1);
		}
	for (int i = 1; i <= n; i++)
		cout << res[make_pair(col[0][i], col[1][i])] << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 39552
n = int(input())
h = list(map(int,input().split()))
ans = 'Yes'
h.reverse()
for i in range(n-1):
    if h[i]==h[i+1]-1:
        h[i+1]-=1
    elif h[i]<h[i+1]:
        ans = 'No'
print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<queue>
#include<map>

using namespace std;

typedef pair < int , int > Pi;
const int INFTY = ( 1 << 28 );

int main(){
  int n, m, c, s, g;
  int station[21][101][101];
  int COST[21][20001];

  while(cin >> n >> m >> c >> s >> g, n){
    fill_n(**station, 21*101*101, INFTY);
    fill_n(*COST, 21 * 20001, 0);
    for(int i = 0 ; i < 21 ; i++ ){
      for(int j = 0 ; j < 101 ; j++ ) station[i][j][j] = 0;
    }
    for(int i = 0 ; i < m ; i++ ){
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      station[c][x][y] = station[c][y][x] = min( station[c][x][y], d);
    }

    //わーしゃる
    for(int i = 1 ; i <= c ; i++ ){
      for(int j = 1 ; j <= n ; j++ ){
        for(int k = 1 ; k <= n ; k++ ){
          for(int l = 1 ; l <= n ; l++ ){
            station[i][k][l] = min( station[i][k][l], station[i][k][j] + station[i][j][l]);
          }
        }
      }
    }
    int p[21];
    for(int i = 1 ; i <= c ; i++ ){
      cin >> p[i];
    }
    int cost[52], dist[52];
    for(int i = 1 ; i <= c ; i++ ){
      fill_n( dist, 52, 0);
      fill_n( cost, 52, 0);
      for(int j = 1 ; j < p[i] ; j++ ){
        cin >> dist[j];
      }
      for(int j = 1 ; j <= p[i] ; j++ ){
        cin >> cost[j];
      }
      int diff = cost[1];
      int pos = 1;
      for(int j = 1 ; j < 20001 ; j++ ){
        if( pos < p[i] && dist[pos] < j) pos++;
        COST[i][j]= COST[i][j-1] + cost[pos];
      }
    }
    int ret[101][101];
    fill_n( *ret, 101 * 101, INFTY);
    for(int i = 1 ; i <= c ; i++ ){
      for(int j = 1 ; j <= n ; j++ ){
        for(int k = 1 ; k <= n ; k++ ){
          if(station[i][j][k] != INFTY) ret[j][k] = min( ret[j][k], COST[i][station[i][j][k]]);
        }
      }
    }
    for(int i = 1 ; i <= n ; i++ ){
      for(int j = 1 ; j <= n ; j++ ){
        for(int k = 1 ; k <= n ; k++ ){
          ret[j][k] = min( ret[j][k], ret[j][i] + ret[i][k]);
        }
      }
    }

    if(ret[s][g] == INFTY) cout << -1 << endl;
    else cout << ret[s][g] << endl;
  }
    return(0);

}

Measured memory_bytes: 3676
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        M: usize,
        tmpXs: [i64; M],
    }

    if N >= M {
        println!("0");
        return;
    }

    let mut Xs: Vec<i64> = Vec::new();
    Xs.extend_from_slice(&tmpXs);
    Xs.sort();

    let mut diffs: Vec<i64> = vec![0i64; M - 1];
    for i in 0..M - 1 {
        diffs[i] = Xs[i + 1] - Xs[i];
    }

    diffs.sort();
    let ans: i64 = diffs.iter().take(M - N).sum();

    println!("{}", ans);
}


Measured memory_bytes: 5132
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] strAry = br.readLine().split(" ");
			int m = Integer.parseInt(strAry[0]);
			int f = Integer.parseInt(strAry[1]);
			int r = Integer.parseInt(strAry[2]);
			if (m == -1 && f == -1 && r == -1) {
				break;
			}
			if (m == -1 || f == -1 || m + f < 30) System.out.println("F");
			else if (80 <= m + f) System.out.println("A");
			else if (65 <= m + f && m + f < 80) System.out.println("B");
			else if (50 <= m + f && m + f < 65) System.out.println("C"); 
			else if (30 <= m + f && m + f < 50) {
				if (50 <= r) System.out.println("C");
				else System.out.println("D");
			}
		}
	}
}

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

int main(void){
  int num[5];

  for( int i = 0 ; i < 5 ; i++ ) cin >> num[i];

  sort( num , num+5 );

  for( int i = 4 ; i >= 0 ; i-- ){
    if( i == 4 ) cout << num[i];
    else cout << " " << num[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1176
#pragma warning (disable:4996)
#include<stdio.h>

int main(void) {
	int n;
	int a[100];
	int b[100];
	int ans = 0;

	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i) {
		scanf("%d", &b[i]);
	}

	a[0] = b[0];
	for (int i = 0; i < n-1; ++i) {
		if (b[i] < b[i + 1] || i == n - 2) {
			a[i + 1] = b[i];
		}
		else{
			a[i + 1] = b[i + 1];
		}
	}

	for (int i = 0; i < n; ++i) {
		ans += a[i];
	}
	printf("%d\n", ans);
}

/*
2 2 5   ...9
2 5
5
3 3   ...6
3

0 0   10 10 10 23  ...53
0 153 10 10 23

a[0]=b[0]

*/

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc172_b solver = new abc172_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc172_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String t = in.next();
            int count = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != t.charAt(i)) {
                    count++;
                }

            }
            out.println(count);
        }

    }
}



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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

using ARRAY = vector<int>;
using CONTAINER = vector<ARRAY>;
using POS = pair<size_t, size_t>;

int dx[] = {-1,0,1,-1,0,1,-1,0,1};
int dy[] = {1,1,1,0,0,0,-1,-1,-1};

bool isMatch(const CONTAINER &m, size_t h, size_t w){
	vector<vector<vector<bool>>> f({ {{1,1,0}, {1,0,0}, {0,0,0}} });
	for(auto e : f){
		bool flag = true;
		for(size_t i = 0; i < 9; i++){
			if(e[1+dx[i]][1+dy[i]]){
				if(m[h+dx[i]][w+dy[i]] != 0){
					flag = false;
					break;
				}
			}
			/*
			else{
				if(m[h+dx[i]][w+dy[j]] == 0){
					flag = false;
					i = j = (size_t)1e9;
					break;
				}
			}
			*/
		}
		if(flag){
//			cerr << h << ":" << w << endl;
			return true;
		}
	}
	return false;
}

void reduce(CONTAINER &m, size_t h, size_t w){
	for(size_t i = 0; i < 9; i++){
		m[h+dx[i]][w+dy[i]] -= 1;
	}
//	cerr << "pass" << endl;
}
			
bool isSwipe(const CONTAINER &m){
	for(auto a : m)for(auto e : a)
		if(e != 0)return false;
	return true;
}

signed main(){
	size_t h,w; cin >> h >> w;
	CONTAINER m(h+2, ARRAY(w+2,0));
	CONTAINER p(m);

	for(size_t i = 1; i <= h; i++)for(size_t j = 1; j <= w; j++)cin >> m[i][j];
//	for(auto a : m){for(auto e : a)cerr << e << " ";cerr << endl;}

	while(!isSwipe(m)){
		for(size_t i = 1; i <= h; i++){
			for(size_t j = 1; j <= w; j++){
				if(m[i][j] > 0 && isMatch(m,i,j)){
					size_t r = i+1, c = j+1;
					p[r][c] += 1;
					reduce(m, r, c);
//					for(auto a : m){for(auto e : a)cerr << e << " ";cerr << endl;}
					break;
				}
			}
		}
	}

//	for(auto a : p){for(auto e : a)cerr << e << " ";cerr << endl;}
	vector<POS> ans;
	{
		int acc = 0;
		for(auto a : p)for(auto e : a)if(e > 0)acc++;
		if(acc == 1){
		for(size_t i = 1; i <= h; i++){
			for(size_t j = 1; j <= w; j++){
				if(p[i][j] > 0){
					cout << (i-1) << " " << (j-1) << " ";
					cout << (i-1) << " " << (j-1) << endl;
					return 0;
				}
			}
		}
		}
	}
			
	for(size_t i = 1; i <= h; i++){
		for(size_t j = 1; j <= w; j++){
			if(p[i][j] > 0){
				int acc = 0;
				for(size_t k = 0; k < 9; k++){
					if(p[i+dx[k]][j+dy[k]] > 0)acc++;
				}
				if(acc == 2)ans.push_back({i,j});
			}
		}
	}
	if(ans[0].first*10000 + ans[0].second < ans[1].first*10000 + ans[1].second){
		swap(ans[0], ans[1]);
	}
	cout << (ans[0].first-1) << " " << (ans[0].second-1) << " ";
	cout << (ans[1].first-1) << " " << (ans[1].second-1) << endl;
	return 0;
}




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

int main() {
	ll K;
	cin >> K;
//	if (K % 2 == 0) {
//		cout << -1 << endl;
//		return(0);
//	}

	ll c = 1;
	ll s = 7;
	ll ss = 7;
	set<pair<ll, ll> > H;
	H.insert(pair<ll, ll>(s, ss));
	while (true) {
		if ((ss % K) == 0) {
			cout << c << endl;
			return(0);
		}
		c++;
		s = (s * 10) % K;
		ss = (ss + s) % K;
		if (H.find(pair<ll, ll>(s, ss)) != H.end()) {
			cout << -1 << endl;
			return(0);
		}
		H.insert(pair<ll, ll>(s, ss));
	}
	return(0);
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint n;
    cin >> n;

    llint ans = 0;
    for(llint in=1;in*in<=n-1;in++) {
        if((n-1)%in==0) {
            ans += 2;
        }
        if(in*in==n-1) ans--;
    }
    ans--;

    vector<llint> ndiv;
    for(llint in=1;in*in<=n;in++) {
        if(n%in==0) {
            if(in!=1) ndiv.push_back(in);
            if(in*in!=n)ndiv.push_back(n/in);
        }
    }

    llint ntmp;
    for(auto k:ndiv) {
        ntmp = n;
        while(ntmp%k==0) {
            ntmp /= k;
        }
        if(ntmp%k==1) ans++;
    }

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


Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF INT_MAX / 2

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    string s;
    cin>>s;
    vector<char>c;
    ll ans=0;
    rep(i,s.length()-1){
        if(s[i]!=s[i+1]){
            ++ans;
        }
    }
    cout<<ans;
}
/*

*/


Measured memory_bytes: 3768
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ll x;
	cin >> x;
	for (ll i = 0;; i++)
	{
		ll tmp = pow(i, 5) - x;
		ll b;
		if (tmp < 0)
		{
			b = pow((double)-tmp, 0.2);
			if (pow(i, 5) + pow(b, 5) == x)
			{
				cout << i << ' ' << -b << endl;
				return 0;
			}
		}
		else
		{
			b = pow((double)tmp, 0.2);
			if (pow(i, 5) - pow(b, 5) == x)
			{
				cout << i << ' ' << b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4040
N = int(input())
S = input()

right_black = S.count('#')
right_white = S.count('.')
left_black, left_white = 0, 0

ans = left_black + right_white
for s in S:
    if s == '#':
        right_black -= 1
        left_black += 1
    else:
        right_white -= 1
        left_white += 1

    ans = min(ans, left_black + right_white)

print(ans)

Measured memory_bytes: 42332
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int arr[4];

int main()
{
	cio;

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;

		if (s.compare("AC") == 0)
			arr[0] += 1;
		else if (s.compare("WA") == 0)
			arr[1] += 1;
		else if (s.compare("TLE") == 0)
			arr[2] += 1;
		else if (s.compare("RE") == 0)
			arr[3] += 1;
	}

	cout << "AC x " << arr[0] << endl;
	cout << "WA x " << arr[1] << endl;
	cout << "TLE x " << arr[2] << endl;
	cout << "RE x " << arr[3] << endl;
}

Measured memory_bytes: 3228
def dfs(x):
    visited[x] = True
    for x2 in xrange(n):
        if graph[x][x2] == False: continue
        if visited[x2] == True: continue
        dfs(x2)

def main():
    global n, m, graph, visited

    n, m = map(int, raw_input().split())
    graph = [[False for _ in xrange(n)] for _ in xrange(n)]
    ai = []
    bi = []
    for _ in xrange(m):
        a, b = map(int, raw_input().split())
        a -= 1
        b -= 1
        ai.append(a)
        bi.append(b)
        graph[a][b] = graph[b][a] = True
    ans = 0

    for i in xrange(m):
        graph[ai[i]][bi[i]] = graph[bi[i]][ai[i]] = False
        visited = [False for _ in xrange(n)]
        bridge = True

        dfs(0)
        if all(visited): bridge = False
        if bridge: ans += 1
        graph[ai[i]][bi[i]] = graph[bi[i]][ai[i]] = True

    print ans
    return 0

if __name__ == '__main__':
    main()


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

int main()
{
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}

Measured memory_bytes: 3604
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    string s; cin>>s;
    queue<int> q;
    for(int i=0;i<s.length();i++){
        if(s[i]=='W') q.push(i);
    }
    reverse(s.begin(),s.end());
    int p=0;
    for(int i=0;i<q.size();i++){
        if(s[i]=='R') p++;
    }
    cout<<p<<"\n";

    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 16868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 998244353
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    int n;
    cin>>n;
    map<ll,ll> m;
    ll d[n];
    rep(i,n) cin>>d[i];
    if(d[0]!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ma=0;
    rep(i,n){
        ma=max(ma,d[i]);
        if(i!=0 && d[i]==0){
            cout<<0<<endl;
            return 0;
        }
        m[d[i]]++;
    }
    for(int i=1;i<=ma;i++){
        if(m[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    for(int i=1;i<n;i++){
        ans=ans*modpow(m[i-1],m[i],MOD)%MOD;
    }
    cout<<ans%MOD<<endl;
 }

Measured memory_bytes: 7296
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	int32_t N, M;
	cin >> N >> M;

	vector<string> A(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector<string> B(M);
	for (int32_t i = 0; i < M; i++) {
		cin >> B[i];
	}

	for (int32_t row = 0; row <= N - M; row++) {
		for (int32_t col = 0; col <= N - M; col++) {
			bool matched = true;
			for (int32_t row_m = 0; row_m < M; row_m++) {
				for (int32_t col_m = 0; col_m < M; col_m++) {
					if (A[row + row_m][col + col_m] != B[row_m][col_m]) {
						matched = false;
						break;
					}
				}
			}
			if (matched) {
				cout << "Yes"  << endl;
				return 0;
			}
		}
	}

	cout << "No"  << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import defaultdict, Counter
from itertools import permutations, product, combinations
from bisect import bisect, bisect_left
from fractions import gcd
MOD = 10**9 + 7

def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [1]*101
    sieve[0] = 0
    sieve[0] = 1
    P = []
    for i in range(2, 101):
        if sieve[i]:
            P.append(i)
            for j in range(i*2, 101, i):
                sieve[j] = 0
    return P

P = primes(100)
N = int(input())

X = (N*(N+1))//2
for p in P:
    if X%p == 0:
        break

groups = []
searched = set()
for j in range(p):
    target = X//p
    A = []
    for i in range(N, 0, -1):
        if i <= target and not i in searched:
            A.append(i)
            target -= i
    assert target == 0
    A = set(A)
    searched.update(A)
    groups.append(A)

M = 0
for g in groups:
    M += (N-len(g))*len(g)
print(M//2)
S = set(range(1, N+1))

for g in groups:
    for x in g:
        for y in S - g:
            print(x, y)
        S = S - g

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

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

    l1 h[n],memo[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        memo[i]=1;
    }
    int a,b;

    for(int i=0;i<m;i++){
        cin>>a>>b;

        if(h[a-1]<h[b-1]){
            memo[a-1]=0;
            continue;
        }else if(h[a-1]>h[b-1]){
            memo[b-1]=0;
            continue;
        }else{
            memo[a-1]=0;
            memo[b-1]=0;
        }
    }

    int ans=0;
    for(int i=0;i<n;i++){
        ans+=memo[i];
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 5160
N,x=map(int,input().split())
A=[int(i) for i in input().split()]
ans=0
if A[0]+A[1]>x:
  if A[0]>x:
    ans+=A[1]+A[0]-x
    A[1],A[0]=0,x
  else:
    ans+=A[1]-x+A[0]
    A[1]=x-A[0]
for i in range(1,N):
  if A[i-1]+A[i]>x:
    ans+=A[i-1]+A[i]-x
    A[i]=x-A[i-1]
print(ans)

Measured memory_bytes: 63984