akhauriyash/Code-Regression huggingface dataset:
count = 0
role = {".": True, "@": False, "#": False}
def now(xpoint, ypoint):
    return role[room[ypoint][xpoint]]

def search(xpoint, ypoint):
    global count
    if 0 <= xpoint < wh[0] and 0 <= ypoint < wh[1] and now(xpoint, ypoint):
        count += 1
        room[ypoint][xpoint] = "@"
        search(xpoint - 1, ypoint)
        search(xpoint + 1, ypoint)
        search(xpoint, ypoint + 1)
        search(xpoint, ypoint - 1)

while True:
    wh = map(int, raw_input().split())
    room = []
    count = 0
    for ypoint in range(wh[1]):
        line = raw_input().replace("\n", "")
        if "@" in line:
            xp = line.index("@")
            yp = ypoint
        room.append([x for x in line])
    if not room: break
    room[yp][xp] = "."
    search(xp, yp)
    print count

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

int main(){ 
  int h, w, n;
  cin >> h >> w >> n;
  int a = max(h, w);
  cout << (n + a - 1) / a << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

void Print() { cout << endl; }
template <class Head, class... Args> void Print(Head &&head, Args&&... args)
{
    cout << head;
    Print(args...);
}

#define Repeat(x, i, j) for (size_t x = i; x < j; ++x)

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif


using ull_t = unsigned long long;


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

    vector<ull_t> A(N), S(N, 0);
    for (size_t i = 0; i < N; ++i)
    {
        cin >> A[i];
        S[i] = A[i] + ((i > 0) ? S[i - 1] : 0);
    }
    Dumps(S);

    // {(x - y) % M == 0}  is equal to  {(x % M) == (y % M)}

    unordered_map<ull_t, size_t> C;
    for (size_t i = 0; i < N; ++i)
    {
        auto p = C.insert({S[i] % M, 1});
        if (not p.second)
            ++p.first->second;
    }
    
    ull_t out = 0;
    for (const auto &p : C)
    {
        if (p.first == 0)
            out += p.second;
        if (p.second > 1)
            out += (p.second * (p.second - 1)) / 2;
    }
    
    cout << out << endl;
}


Measured memory_bytes: 5260
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int K,X;
    cin >> K >> X;
    for(int i = X - K + 1; i < X + K; ++i) cout << i << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//素数判定
//#include <cmath>
bool is_prime(long long n) {
	if (n == 1) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	for (long long i = 3; i <= sqrt(n); i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

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

	ll n;
	cin >> n;

	//n!を素因数分解
	vll v(n + 1, 0);
	for (ll i = 2; i <= n; i++) {
		if (is_prime(i)) {
			ll x = i;
			while (x <= n) {
				v[i] += n / x;
				x *= i;
			}
		}
	}

	ll cnt2 = 0, cnt4 = 0, cnt14 = 0, cnt24 = 0, cnt74 = 0;
	for (ll i = 2; i <= n; i++) {
		if (v[i] >= 2) cnt2++;
		if (v[i] >= 4) cnt4++;
		if (v[i] >= 14) cnt14++;
		if (v[i] >= 24) cnt24++;
		if (v[i] >= 74) cnt74++;
	}

	ll ans = 0;

	//p^74
	ans += cnt74;

	//p^2 * q^24
	ans += (cnt2 - cnt24) * cnt24;
	ans += cnt24 * (cnt24 - 1);

	//p^4 * q^14
	ans += (cnt4 - cnt14) * cnt14;
	ans += cnt14 * (cnt14 - 1);

	//p^2 * q^4 * r^4
	ans += cnt4 * (cnt4 - 1) / 2 * (cnt2 - cnt4);
	ans += (cnt4 - 1) * (cnt4 - 2) / 2 * cnt4;

	cout << ans << endl;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int n, m, a[100000] = {};
	map<int, int> mod;
	usd llong int sum = 0;
	usd llong int ans = 0;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
		ans += mod[sum%m] + (sum%m == 0);
		mod[sum%m]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
using namespace std;
int main() {
    string word;
    stack<int> S;
    while(cin >> word)
    {
        if(word == "+")
        {
            int x = S.top();
            S.pop();
            int y = S.top();
            S.pop();
            S.push(x+y);
        }
        else if(word == "-")
        {
            int x = S.top();
            S.pop();
            int y = S.top();
            S.pop();
            S.push(y-x);
        }
        else if(word == "*")
        {
            int x = S.top();
            S.pop();
            int y = S.top();
            S.pop();
            S.push(x*y);
        }
        else
        {
            S.push(atoi(word.c_str()));
        }
    }
    int s = S.top();
    cout<<s<<endl;
    return 0;
}

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

int cross[200] = {0};

bool ok() {
	if (cross[1] % 2 == 0) return false;
	if (cross[2] % 2 == 0) return false;
	for (int i = 3; i < 200; i++) {
		if (cross[i] % 2 == 1) return false;
	}
	return true;
}

int main() {
	int a, b;
	while (cin >> a >> b) {
		cross[a]++;
		cross[b]++;
		if (a == 0) {
			if (ok()) cout << "OK" << endl;
			else cout << "NG" << endl;
			for (int i = 0; i<200; i++) cross[i] = 0;
		}
	}
	return 0;

}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true)
		{
			if(!sc.hasNextInt()) break;
			double a = sc.nextInt();
			double b = sc.nextInt();
			double c = sc.nextInt();
			double d = sc.nextInt();
			double e = sc.nextInt();
			double f = sc.nextInt();
			
			double x = (c*e - b*f) / (a*e - b*d);
			double y = (a*f - c*d) / (a*e - b*d);

			if(Math.abs(x)<0.001) x = 0;
			if(Math.abs(y)<0.001) y = 0;
			System.out.printf("%.3f %.3f\n",x,y);
		}
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 10
using namespace std;
bool vis[MAXN+5];
int digit[MAXN+5],len;
int N,K;
bool Check(int x)
{
	len=0;
	while(x)
	{
		digit[++len]=x%10;
		x/=10;
	}
	for(int i=1;i<=len;i++)
		if(vis[digit[i]]==false)
			return false;
	return true;
}
int main()
{
	scanf("%d %d",&N,&K);
	int x;
	for(int i=1;i<=K;i++)
	{
		scanf("%d",&x);
		vis[x]=true;
	}
	int min1=-1,min2=-1;
	for(int i=0;i<=9;i++)
	{
		if(vis[i]==false)
			vis[i]=true;
		else
			vis[i]=false;
	}
	for(;1;N++)
	{
		if(Check(N)==true)
		{
			printf("%d\n",N);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

const li mod = 1e9 + 7;

li n;
li memo[1000005];
li smemo[1000005];
li rec(li l) {
    if (l < 0) {
        return 1;
    }

    if (memo[l] != -1) {
        return memo[l];
    }

    if (l == 0) {
        smemo[l] = n;
        return memo[l] = n;
    }

    li ans = 0;
    ans += (n - 1) * (n - 1) % mod;
    ans %= mod;
    if (l < 2) {
        ans += rec(l - 1) + n - 1;
        ans %= mod;
    } else {
        ans += (smemo[l - 1] - rec(l - 2) + mod) % mod;
        ans %= mod;
        ans += n - (l - 2) - 1;
        ans %= mod;
    }

    smemo[l] = (smemo[l-1] + ans) % mod;
    //cout << l << " " << ans << " " << smemo[l] << endl;
    return memo[l] = ans;
}


int main() {
    rep(i, 1000005) {
        memo[i] = -1;
    }
    cin >> n;
    rep(i, n) {
        rec(i);
    }
    cout << rec(n - 1) << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
   int n,m,l;cin>>n>>m>>l;
   vvi v(n,vi(n,inf));
   vvi g(n,vi(n,inf));
   rep(i,n){
      g[i][i]=0;
      v[i][i]=0;
   }
   rep(i,m){
      int a,b,c;cin>>a>>b>>c;
      a--;b--;
      v[a][b]=c;
      v[b][a]=c;
   }
   rep(k,n)rep(i,n)rep(j,n){
      chmin(v[i][j],v[i][k]+v[k][j]);
   }
   rep(i,n)rep(j,n)if(v[i][j]<=l&&i!=j)g[i][j]=1;
   rep(k,n)rep(i,n)rep(j,n){
      chmin(g[i][j],g[i][k]+g[k][j]);
   }
   int q;cin>>q;
   rep(i,q){
      int s,t;
      cin>>s>>t;
      s--;t--;
      if(g[s][t]==inf)cout<<-1<<endl;
      else cout<<g[s][t]-1<<endl;
   }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for(int i=0; i<n; i++) cin >> x[i] >> y[i];
  double d = 0.0;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      d += sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
    }
  }
  printf("%.10lf\n", d*2 / n);

  return 0;
}
// a * n + b * d(n) <= x

// EOF


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define myfill(a, val, type) fill((type *)a, (type *)a+sizeof(a)/sizeof(type), val)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }


int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	int dp[n+1][n+1]; myfill(dp, 0, int);
	for (int i = n-1; i >= 0; i--) {
		for (int j = n-1; j >= 0; j--) {
			if (s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
			chmax(ans, min(abs(i-j), dp[i][j]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 101212
x = int(input())
a = list(map(int,input().split()))
count = 0
mod = 0
while mod == 0:
    count += 1
    for i in range(x):
        if a[i]%2 == 0:
            a[i] = a[i]/2
        
        else:
            mod += 1
            break
print(count-1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
#include <climits>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string s, ans;
    cin >> s;
    rep(i,0,s.length()) {
        if(!ans.empty() && s[i] == 'B') ans.pop_back();
        else if(s[i] != 'B') ans += s[i];
    }

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

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
ab = []
for _ in range(m):
    tmp = [int(x) for x in input().split()]
    ab.append(tmp)

l = [1] * n

for x in ab:
    if h[x[0]-1] > h[x[1]-1]:
        l[x[1]-1] = 0
    elif h[x[0]-1] < h[x[1]-1]:
        l[x[0]-1] = 0
    elif h[x[0]-1] == h[x[1]-1]:
        l[x[0]-1] = 0
        l[x[1]-1] = 0


print(sum(l))

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

using namespace std;


typedef int32_t h_int32;
typedef int64_t h_int64;
typedef uint32_t uh_int32;
typedef uint64_t uh_int64;
typedef h_int64 h_int;

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

#define VINIT( v, type, n )vector<type> v; v.resize( n );
#define VINIT2( v, type, n, a )vector<type> v; v.resize( n, a );
#define VCIN( v, type, n ) VINIT( v, type, n ) REP( i, n ) cin >> v[i];

#define DOUT( x ) cerr << #x << " = " << x << "\n";
#define COUT( x ) cout << ( x ) << "\n";

#define INF 999999999



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

        string s;
        cin >> s;
        int a = s.size() - 2;
        cout << s[0] << a << s[s.size() - 1];

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    ll a[n];
    vector<ll> cnt(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        ll t = sum;
        t -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        t += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        cout << t << endl;
    }
}

Measured memory_bytes: 5760
#include <iostream>

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

    if ((a == b && b == c) || (a != b && b != c && c != a))
    {
        std::cout << "No" << std::endl;
    }
    else
    {
        std::cout << "Yes" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
var input = require( 'fs' ).readFileSync( '/dev/stdin' ).toString();
  var data = input.split( " " ).map( Number );
  var a = data[0];
  var b = data[1];
  var C = data[2]*(Math.PI/180);
  var h = Math.sin( C )*b;
  var ta = Math.cos( C )*b;   
  var S = (a*h)/2;
  var L = a+b+Math.sqrt( Math.pow( (a-ta), 2 )+Math.pow( h, 2 ) );
  console.log( S+'\n'+L+'\n'+h );

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

using namespace std;

int main(){
  int H,W; cin >> H >> W;
  int cnt[26];
  for(int i=0;i<26;i++) cnt[i]=0;
  for(int i=0;i<H;i++){
    string str; cin >> str;
    for(int j=0;j<W;j++) cnt[str[j]-'a']++;
  }
  int ff=0,d_4=0;
  for(int i=0;i<26;i++){
    while(cnt[i]>=4){
      d_4++;
      cnt[i]=cnt[i]-4;
    }
    if(cnt[i]%2==1) ff++;
  }
  int a,b;
  if(H<=W){
    a=H-2; b=W;
  }else{
    a=W-2; b=H;
  }
  int r_4=0;
  while(a>=0 && b>=0){
    r_4=r_4+a/2+b/2;
    a=a-2;
    b=b-2;
  }
  int flag=0;
  if(a==-1 && b>=1){
    if(b%2==1){
      flag=1;
    }
  }
  if(r_4<=d_4 && ff==flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define all(c) (c).begin(),(c).end()
#define INF (1<<29)

using namespace std;

typedef unsigned long long ull;

ull B=100000007;

int overlap(string a,string b){
  int al=a.size(),bl=b.size(),ans=0;
  ull ah=0,bh=0,t=1;
  for(int i=1;i<=min(al,bl);i++){
    ah+=a[al-i]*t;
    bh=bh*B+b[i-1];
    if(ah==bh)ans=i;
    t*=B;
  }
  return ans;
}

bool contain(string a,string b){
  int al=a.size(),bl=b.size();
  ull ah=0,bh=0,t=1;

  for(int i=0;i<al;i++)t*=B;
  for(int i=0;i<al;i++)ah=ah*B+a[i];
  for(int i=0;i<al;i++)bh=bh*B+b[i];

  for(int i=0;i+al<=bl;i++){
    if(ah==bh)return true;
    if(i+al<bl)bh=bh*B+b[i+al]-b[i]*t;
  }
  return false;
}


int dp[16][(1<<16)];

int main(void){

  int n;
  while(cin >> n,n){
    vector<string>a(n);
    int cnt=0;
    for(int i=0;i<n;i++)cin >> a[i];

    vector<string>b;
    for(int i=0;i<n;i++){
      bool fg=true;
      for(int j=0;j<n;j++)
        if(a[i].size()<a[j].size())fg&=!contain(a[i],a[j]);
      if(fg)b.push_back(a[i]);
    }

    int bl=b.size();
    fill(dp[0],dp[16],INF);
    for(int i=0;i<bl;i++)dp[i][(1<<i)]=b[i].size();

    for(int S=0;S<(1<<bl);S++){
      for(int i=0;i<bl;i++){
        if(!((S>>i)&1))continue;
        for(int j=0;j<bl;j++){
          if((S>>j)&1)continue;
          dp[j][S|(1<<j)]=min(dp[j][S|(1<<j)],dp[i][S]+(int)b[j].size()-overlap(b[i],b[j]));
        }
      }
    }
    int ans=INF;
    for(int i=0;i<bl;i++)ans=min(ans,dp[i][(1<<bl)-1]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5312
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

class Vector {
public:
	double x, y;

	Vector(double x = 0, double y = 0) :x(x), y(y) {}
	Vector operator + (Vector v) { return Vector(x + v.x, y + v.y); }
	Vector operator - (Vector v) { return Vector(x - v.x, y - v.y); }
	Vector operator * (double a) { return Vector(a*x, a*y); }
	Vector operator / (double a) { return Vector(a / x, a / y); }
	Vector operator +=(Vector v) {
		x += v.x;
		y += v.y;
		return *this;
	}
	Vector operator -=(Vector v) {
		x -= v.x;
		y -= v.y;
		return *this;
	}
	Vector operator *= (double a) {
		x *= a;
		y *= a;
		return *this;
	}
	Vector operator /=(double a) {
		x /= a;
		y /= a;
		return *this;
	}

	bool operator < (Vector p) { return (x != p.x) ? (x < p.x) : (y < p.y); }
	bool operator == (Vector p) { return (fabs(x - p.x) < EPS) && (fabs(y - p.y) < EPS); }

	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }
	double equals(double a, double b) { return fabs(a - b) < EPS; }

	double dot(Vector b) { return x * b.x + y * b.y; }
	double cross(Vector b) { return x * b.y - y * b.x; }

	bool isOrthogonal(Vector b) { return equals(this->dot(b), 0.0); }
	bool isParallel(Vector b) { return equals(this->cross(b), 0.0); }

};
typedef Vector Point;


typedef struct {
	Point p1, p2;
}Segment;

Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = base.dot(p - s.p1) / base.norm();
	return s.p1 + base * r;
}

Point reflection(Segment s, Point p) {
	return p + (project(s, p)-p)*2.0;
}

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

	int xp1, yp1, xp2, yp2;
	cin >> xp1 >> yp1 >> xp2 >> yp2;
	Segment s = { Point(xp1,yp1),Point(xp2,yp2) };

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int xpi, ypi;
		cin >> xpi >> ypi;
		Point res = reflection(s, Point(xpi, ypi));
		cout << setprecision(20) <<res.x << " " << res.y << endl;
	}


	return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	int k; cin >> k;
	vector<int> a = { 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 };

	dunk(a[k - 1]);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

//#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rrep(i,a,b) for (int i = a; i >= b; i--)



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int te=1;
	//cin>>te;
	while(te--){
        ll a,b,c,ans=0LL,n;
        //cin>>n;
        char ch;
        cin>>ch;
        if(ch>='A' && ch<='Z') cout<<'A';
        else cout<<'a';

        //cout<<  ans<<endl;

	}
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    if(S == "SUN")
    {
        cout << 7;
    }
    else if(S == "MON")
    {
        cout << 6;
    }
    else if(S == "TUE")
    {
        cout << 5;
    }
    else if(S == "WED")
    {
        cout << 4;
    }
    else if(S == "THU")
    {
        cout << 3;
    }
    else if(S == "FRI")
    {
        cout << 2;
    }
    else if(S == "SAT")
    {
        cout << 1;
    }

    return 0;
}

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

int main(){
  int n,k,i;
  cin>>n>>k;
  if((n-1)*(n-2)/2<k){
    cout<<-1<<endl;
    return 0;
  }

  k=(n-1)*(n-2)/2-k;//減らす本数
  cout<<(n-1)+k<<endl;
  for(i=0;i<n-1;i++){
    cout<<"1 "<<i+2<<endl;
  }
  int j=2,l=1;
  for(i=0;i<k;i++){
    if(l+j>n){
      j++;
      l=1;
    }
    cout<<j<<" "<<j+l<<"\n";
    l++;
  }

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from heapq import heappop, heappush, heapify

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K,T=MAP()
A=LIST()
A=[(-A[i], i) for i in range(T)]
heapify(A)

prev=-1
while len(A):
    v,i=heappop(A)
    if i!=prev:
        v+=1
        prev=i
        if v!=0:
            heappush(A, (v, i))
    else:
        if len(A)==0:
            print(-v)
            exit()
        v2,i2=heappop(A)
        v2+=1
        prev=i2
        if v2!=0:
            heappush(A, (v2, i2))
        heappush(A, (v, i))
print(0)


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

int ans, n, c;
int main()
{
	int i;
	cin >> n >> c;
	ans = c;
	for (i = 0; i < n - 1; i++) {
		ans *= c - 1;
	}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

signed main(){

  int n, m, d; cin >> n >> m >> d;
  if(d == 0){
    printf("%.7f\n", 1.0 * (m - 1) / n);
  }else{
    printf("%.7f\n", 1.0 * (m - 1) * 2 * (n - d) / (n * n));
  }

  return 0;
}


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

int main(){
  int n;
  while(std::cin >> n, n){
    if(n == 1){
      std::cout << "deficient number" << std::endl;
      continue;
    }
    int sum = 1;
    for (int i = 2; i*i <= n; i++) {
      if(i*i == n)sum += i;
      else if(n%i == 0)sum += i + (n/i);
    }
    if(sum < n){
      std::cout << "deficient number" << std::endl;
    }else if(sum > n){
      std::cout << "abundant number" << std::endl;
    }else{
      std::cout << "perfect number" << std::endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3056
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000
#define MAX 100000

bool isprime[MAX];
vector<int> primes;

void make_list(){
    fill(isprime, isprime+MAX, true);
    isprime[0]=isprime[1]=false;
    for(int i=2; i<=MAX/2; i++){
        if(isprime[i]){
            for(int j=i*2; j<=MAX; j+=i) isprime[j]=false;
            primes.pb(i);
        }
    }
}

int main(){
    make_list();
    int m,a,b;
    int n=primes.size();
    while(cin>>m>>a>>b, m|a|b){
        bool flg=true;
        int p,q;
        if(m%2==0) m--;
        while(flg){
            rep(i,n){
                if(m/2 < primes[i] || primes[i]>400) break;
                if( m%primes[i]==0 && isprime[m/primes[i]]==true ){
                    p = primes[i];
                    q = m/primes[i];
                    if(p>q) swap(p,q);
                    if(a*q>b*p) break;
                    flg=false;
                    break;
                }
            }
            m--;
            if(m>4)m--;
        }
        cout<<p<<" "<<q<<endl;
    }

    return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void){
    int n, ok = 1;
    string s;
    char c;
    map<string, int> m;

    cin >> n;

    cin >> s;

    c = s[s.size()-1];
    m[s] = 1;

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

        if (s[0] != c || m[s] != 0){
            ok = 0;
        }

        m[s] = 1;
        c = s[s.size()-1];
    }

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
int main()
{
    fio;
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    if(c>b && c>a && b>a)
    cout<<"Yes\n";
    else
    {
        int r = 0 , x = 0,p=0,h=0,l=0,y=0;
        if(a>=b)
        {
            while(1)
            {
                if(b>a)
                    break;
                b*=2;
                p++;
            }
            if(b>=c)
            {
             while(1)
            {
                if(c>b)
                    break;
                c*=2;
                l++;
            }
            }
        }
        else if(b>=c)
        {
           while(1)
            {
                if(c>b)
                    break;
                c*=2;
                l++;
            }
        }
        if(l+p<=k)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 405
#define LL long long
#define MO 1000000007
LL dp[MAXN][MAXN],p[MAXN][MAXN];
int a[MAXN],b[MAXN];
LL PowMod(LL a,LL b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
void Pre()
{
	for(int i=1;i<=400;i++)
		for(int j=0;j<=400;j++)
			p[i][j]=PowMod(i,j);
	for(int j=0;j<=400;j++)
		for(int i=1;i<=400;i++)
		{
			p[i][j]+=p[i-1][j];
			p[i][j]%=MO;
		}
}
int main()
{
	int n,c;
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	for(int i=1;i<=n;i++)
		scanf("%d",b+i);
	Pre();
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
			{
				dp[i][j]+=dp[i-1][j-k]*((p[b[i]][k]-p[a[i]-1][k]+MO)%MO)%MO;
				dp[i][j]%=MO;
			}
	printf("%lld\n",dp[n][c]);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	int ans=1000000007;
	cin>>a>>b;
	for (int i=0;i<a.size()-b.size()+1;i++)
	{
		int need=0;
		for (int n=0;n<b.size();n++)
		{
			if (a[i+n]!=b[n])
				need++;
		}
		ans=min(ans,need);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,i,j,x,y,z,l,r,mid,ans,mi[140005];
vector<pair<long long,long long> > bi[140005];
struct ii
{
	long long x,y;
};
vector<ii> v[140005];
bool cmpx(ii x,ii y){return x.x<y.x;}
bool cmpy(ii x,ii y){return x.y<y.y;}
void merge(vector<ii> &v0,vector<ii> v1,vector<ii> v2)
{
	if(v1.empty()||v2.empty()) return;
	if(v1.size()>v2.size()) swap(v1,v2);
	sort(v1.begin(),v1.end(),cmpx);
	sort(v2.begin(),v2.end(),cmpy);
	fz0k(i,v2.size()){
		if(i)mi[i]=min(mi[i-1],v2[i].x); else mi[i]=v2[i].x;
	}
	int i,j=v2.size()-1;
	fz0k(i,v1.size()){
		while(j>=0&&v1[i].x+v2[j].y>mid) j--;
		if(j>=0){
			v0.push_back((ii){mi[j],v1[i].y});
		}
	}
	sort(v1.begin(),v1.end(),cmpy);
	sort(v2.begin(),v2.end(),cmpx);
	fz0k(i,v2.size()){
		if(i)mi[i]=min(mi[i-1],v2[i].y); else mi[i]=v2[i].y;
	}
	j=v2.size()-1;
	fz0k(i,v1.size()){
		while(j>=0&&v1[i].y+v2[j].x>mid) j--;
		if(j>=0){
			v0.push_back((ii){v1[i].x,mi[j]});
		}
	}
}
void dfs(long long x,long long fa)
{
	bool f=0;
	vector<vector<ii> > seq;
	v[x].clear();
	ff(bi[x],it){
		if(it->first==fa) continue;
		dfs(it->first,x);
		ff(v[it->first],it2){
			it2->x+=it->second;
			it2->y+=it->second; 
		}
		seq.push_back(v[it->first]);
	}
	if(seq.empty()){
		v[x].push_back((ii){0,0});
	}
	else{
		merge(v[x],seq[0],seq[1]);
	}
}
int main()
{
	scanf("%lld",&n);
	fz1(i,n-1){
		scanf("%lld%lld",&x,&z);
		bi[x].push_back(make_pair(i+1,z));
		bi[i+1].push_back(make_pair(x,z));
	}
	l=-1;r=1000000000000000ll;ans=-1;
	while(l<r){
		mid=(l+r+1)/2;
		dfs(1,0);
		if(v[1].empty())l=mid;
		else{
			r=mid-1;
			ans=mid;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 37668
n = int(input())

sqrt = int((n ** (1/2)) // 1)
ans = 20
for i in range(1, sqrt+1):
    if n % i == 0:
        a = i
        b = int(n / i)
        if len(str(b)) < ans:
            ans = len(str(b))

print(ans)

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

#define _ << " " <<
#define tr(x) cout << #x _ x << endl
#define fi first
#define se second

#ifdef _WIN32
#define LD "%I64d"
#else
#define LD "%ld"
#endif

using namespace std;

typedef long long ll;

int n;

vector<pair<int, int> > p;

int read() {
    if (scanf("%d", &n) < 1) {
        return 0;
    }
    p.clear();
    for (int i = 1; i <= n; i++) {
        int x; scanf("%d", &x);
        p.push_back(make_pair(min(i, x), max(i, x)));
    }
    return 1;
}

void solve() {
    int ans = 0;
    sort(p.begin(), p.end());
    for (int i = 0; i < n - 1; i++) {
        if (p[i] == p[i + 1]) ans++;
    }
    printf("%d\n", ans);
}

int main(int argc, char *argv[]) {
    while (read()) {
        solve();
    }
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

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

    int ans;
    if (n >= 10) ans = r;
    else ans = r+100*(10-n);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int mod=998244353;
int w[1000050],cnt[1000050];
int main(){
	int n,m=0,i,j,x,sum,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",&x);
		if(x>m)m=x;
		++cnt[x];
	}
	for(i=2,w[1]=1;i<=m;++i)w[i]=(ll)(mod-mod/i)*w[mod%i]%mod;
	for(i=1;i<=(m>>1);++i)
		for(j=(i<<1);j<=m;j+=i){w[j]-=w[i];if(w[j]<0)w[j]+=mod;}
	for(i=1;i<=m;++i){
		for(j=i,sum=0;j<=m;j+=i){
			ans=(ans+((ll)sum*j%mod*cnt[j]+((ll)cnt[j]*(cnt[j]-1)>>1ll)%mod*j%mod*j)%mod*w[i])%mod;
			sum=(sum+(ll)j*cnt[j])%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n,a[5];
int main()
{
	cin>>n;
	rep(i,5)cin>>a[i];
	long long b=a[0];
	rep(i,5)
	{
		if(b>a[i])b=a[i];
	}
	if(n%b==0)cout<<n/b+4<<endl;
	else cout<<(long long)n/b+5<<endl;
	return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef pair<int, int> Pii;

int main() {

  int n, k;
  int a[100001];

  while( cin >> n >> k, n+k ) {
    int ans = 0;
    for(int i=0; i<k; i++) {
      cin >> a[i];
    }

    sort(a, a+k);

    queue<Pii> q;
    int l, r;
    int flag = 0;
    if( a[0] == 0 ) {
      flag = 1;
      l = r = a[1];
    } 
    else l = r = a[0];
    for(int i=1+flag; i<k; i++) {
      if( a[i] == a[i-1]+1 ) {
	r++;
	if( i == k-1 ) {
	  q.push(Pii(l, r));
	  ans = max(ans, r-l+1);
	}
      }
      else {
	q.push(Pii(l, r));
	ans = max(ans, r-l+1);
	l = a[i]; 
	r = a[i];
      }
    }

    if( flag ) {
      Pii p = q.front(); q.pop();

      int l1, l2, r1, r2;
      l1 = p.fr, r1 = p.sc;
      while( !q.empty() ) { 
	p = q.front(); q.pop();
	l2 = p.fr, r2 = p.sc;
	if( r1+2 == l2 ) {
	  ans = max(ans, (r1-l1+1) + (r2-l2+1) + 1);
	}
	l1 = l2;
	r1 = r2;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long set,start,end;
  long ans = 0;
  for (long i = 1; i <= n; i++) {
    set = n/i;
    start = i;
    end = i*set;
    ans += (start+end)*set/2;
  }
  printf("%ld\n", ans);

  return 0;
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    int H, W;
    cin >> H >> W;

    vec2<char> field(H, vec<char>(W, 0));

    for(int i=0; i < H; i++){
        for(int j=0; j < W; j++){
            while(true){
                char temp;
                cin >> temp;
                if(temp == '#'){
                    field[i][j] = '#';
                }else if(temp == '.'){
                    field[i][j] = '.';
                }else{
                    assert(0);
                }
                break;
            }
        }
    }

    // solve
    vec2<char> rowRed;
    for(int i=0; i < H; i++){
        if(count(field.at(i).begin(), field.at(i).end(), '.') != W){
            rowRed.push_back(field.at(i));
        }
    }

    set<int> cols;
    for(int j=0; j < W; j++){
        ll cnt = 0;
        for(int i=0; i < rowRed.size(); i++){
            if(rowRed.at(i).at(j) == '.'){
                cnt++;
            }
        }
        if(cnt == rowRed.size()){
            cols.insert(j);
        }
    }


    vec2<char> res;
    for(int i=0; i < rowRed.size(); i++){
        res.push_back(vec<char>());
        for(int j=0; j < W; j++){
            if(cols.find(j) != cols.end()){
                continue;
            }
            res.back().push_back(rowRed.at(i).at(j));
        }
    }

    for(int i=0; i < res.size(); i++){
        for(int j=0; j < res[0].size(); j++){
            cout << res[i][j];
        }
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
ans_list = []

if a > b:
    a, b = b, a

for i in range(a, 0, -1):
    if a % i == 0 and b % i == 0:
        ans_list.append(i)
        if len(ans_list) == k:
            print(i)
            break


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>

int main()
{
	char s[8];

	scanf("%s", s);
	if (strlen(s) == 2) printf("%s\n", s);
	else printf("%c%c%c\n", s[2], s[1], s[0]);

	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

const int MOD = 1e9 + 7;

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0, sum = 0, sum1 = 0;
	for (int i = 0; i < k; i++){
        sum += i, sum1 += n - i;
	}
	for (int i = k; i <= n + 1; i++){
        ans += sum1 - sum + 1;
        ans %= MOD;
        sum += i, sum1 += n - i;
	}
	cout << ans;
	return 0;
}


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

using namespace std;

// input
int n,m;
int p[1001][1001];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int ans;
  while(true) {
    cin >> n >> m;
    if(n == 0) break;
    rep(i,m) {
      rep(j,n) cin >> p[i][j];
    }

    ans = 0;
    rep(i,n) {
      int tmp = 0;
      rep(j,m) tmp += p[j][i];
      ans = max(ans,tmp);
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 3332
h, w, k = map(int, input().split())

c = []
ans = 0
c = [list(input()) for _ in range(h)]
# print(c)
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        cnt = 0
        for m in range(h):
            for n in range(w):
                if ((i >> m) & 1 == 0) and ((j >> n) & 1 == 0):
                    if c[m][n] == '#':
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 9120
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int D,N;cin>>D>>N;
    int p=pow(100,D),q=pow(100,D+1);
    int s=p,count=0;
    while(true){
        if(s%q!=0){
            count++;
            if(count==N){
                cout<<s<<endl;
                break;
            }
        }
        s+=p;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i)
#define rep(i,n) REP(i,0,n)
int main(){
    int K, X;
    cin >> K >> X;
    X -= K - 1;
    rep(i,2*K-1) cout<<X+i<<" ";
    cout<<endl;

    return 0;

}

Measured memory_bytes: 256
n=int(input())

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

memo = []

for i in range(n):
    memo.append(t[i]-i-1)
memo.sort()

if n%2 == 0:
  p = n//2-1
else:
  p = (n-1)//2

ans = 0

for j in range(n):
  ans += abs(memo[j] - memo[p])

print(ans)


Measured memory_bytes: 99924
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>
 
#define N_MAX (200001)
 
typedef struct _range {
    int upper, lower, depth;
    struct _range *ubound, *lbound;
} Range;
 
Range *newRange(int lower, int upper) {
    Range *range = (Range*)malloc(sizeof(Range));
    range->lower = lower;
    range->upper = upper;
    range->ubound = range->lbound = NULL;
    range->depth = 1;
    return range;
}

int depth(Range* range) {
    if (range) { return range->depth; }
    else { return 0; }
}

Range* rotate(Range* range) {
    return range;
}

Range* appendMax(Range* range, Range* newone) {
    if (range == NULL) { 
        return newone;
    }
    range->ubound = appendMax(range->ubound, newone);
    return rotate(range);
}

Range* appendMin(Range* range, Range* newone) {
    if (range == NULL) {
        return newone;
    }
    range->lbound = appendMin(range->lbound, newone);
    return rotate(range);
}
 
int idx[N_MAX];
long long sum, len;

Range* calc(Range *range, int value, int index) {
    if (range->lower <= index && index <= range->upper) {
        len = (long long)(range->upper - range->lower + 1);
        sum += (len * (len + 1LL) / 2LL) * (long long)value;
        len = (long long)(range->upper - index);
        sum -= (len * (len + 1LL) / 2LL) * (long long)value;
        len = (long long)(index - range->lower);
        sum -= (len * (len + 1LL) / 2LL) * (long long)value;
        if (range->lower == index) {
            range->lower++;
        } else if (range->upper == index) {
            range->upper--;
        } else if (range->upper - index > index - range->lower) {
            range->lbound = appendMax(range->lbound, newRange(range->lower, index - 1));
            range->lower = index + 1;
        } else {
            range->ubound = appendMin(range->ubound, newRange(index + 1, range->upper));
            range->upper = index - 1;
        }
    } else if (index < range->lower) {
        range->lbound = calc(range->lbound, value, index);
    } else {
        range->ubound = calc(range->ubound, value, index);
    }
    return rotate(range);
}
 
 
int main(void){
    int i, n;
    
    scanf("%d", &n);
 
    for (i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        idx[a] = i;
    }
    
    Range *range = newRange(0, n - 1);
    
    for (i = 1; i <= n; i++) {
        range = calc(range, i, idx[i]);
    }
    
    printf("%lld\n", sum);
 
    return 0;
}

Measured memory_bytes: 4096
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.text.DecimalFormat;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        double x1, y1, x2, y2, x3, y3, xp, yp;
        double abx, aby, bcx, bcy, cax, cay;
        double apx, apy, bpx, bpy, cpx, cpy;

        while (sc.hasNextDouble()) {
            x1 = sc.nextDouble();
            y1 = sc.nextDouble();
            x2 = sc.nextDouble();
            y2 = sc.nextDouble();
            x3 = sc.nextDouble();
            y3 = sc.nextDouble();
            xp = sc.nextDouble();
            yp = sc.nextDouble();

            abx = x2 - x1;
            aby = y2 - y1;
            bcx = x3 - x2;
            bcy = y3 - y2;
            cax = x1 - x3;
            cay = y1 - y3;

            apx = xp - x1;
            apy = yp - y1;
            bpx = xp - x2;
            bpy = yp - y2;
            cpx = xp - x3;
            cpy = yp - y3;

            if (crossProduct(abx, aby, apx, apy) * crossProduct(abx, aby, -cax, -cay) > 0 &&
            crossProduct(bcx, bcy, bpx, bpy) * crossProduct(bcx, bcy, -abx, -aby) > 0 &&
            crossProduct(cax, cay, cpx, cpy) * crossProduct(cax, cay, -bcx, -bcy) > 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

    private static double crossProduct(double ux, double uy, double vx, double vy) {
        return ux * vy - uy * vx;
    }
}

Measured memory_bytes: 31004
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            int B = Integer.parseInt(sl[1]);
            int C = Integer.parseInt(sl[2]);

            System.out.println(A <= C && C <= B ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

ll N;
vector<ll> lcs;
vector<multiset<ll>> st;

vector<ll> ans;
vector<vector<ll>> connection;
vector<ll> A;

void dfs(ll now, ll before) {
  ll a = A.at(now);
  ll index = lower_bound(lcs.begin(), lcs.end(), a) - lcs.begin();
  lcs.at(index) = a;
  st.at(index).insert(a);
  ans.at(now) = lower_bound(lcs.begin(), lcs.end(), INF) - lcs.begin();
  for (ll i = 0; i < connection.at(now).size(); ++i) {
    ll next = connection.at(now).at(i);
    if (next == before) {
      continue;
    }
    dfs(next, now);
  }
  st.at(index).erase(st.at(index).lower_bound(a));
  lcs.at(index) = *st.at(index).begin();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;
  lcs = vector<ll>(N, INF);
  ans =  vector<ll>(N);
  st = vector<multiset<ll>>(N);
  for (ll i = 0; i < N; ++i) {
    st.at(i).insert(INF);
  }
  A = vector<ll>(N);
  connection = vector<vector<ll>>(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 0; i < N - 1; ++i) {
    ll u, v;
    cin >> u >> v;
    u -= 1;v -= 1;
    connection.at(u).push_back(v);
    connection.at(v).push_back(u);
  }
  dfs(0, -1);
  for (ll i = 0; i < N; ++i) {
    cout << ans.at(i) << "\n";
  }
}


Measured memory_bytes: 63312