akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n,m;
vector<int> c;
vector<vector<pair<int,int>>> q;
vector<int> ans, cnt;
vector<int> BIT;

void update(int ind, int value) {
	++ind;
	for(; ind <= n; ind += ind&-ind)
		BIT[ind] += value;
}

int query(int ind) {
	//++ind;
	int sum  = 0;
	for(; ind > 0; ind -= ind&-ind)
		sum += BIT[ind];
	return sum;
}

void solve() {
	read(n,m);
	c = vector<int>(n);
	q = vector<vector<pair<int,int>>>(n);
	BIT = vector<int>(n + 1);
	read(c);
	for(int i = 0; i < m; ++i) {
		int x,y;
		read(x,y);
		--x;
		--y;
		q[y].push_back({x, i});
	}
	ans = vector<int>(m);
	cnt = vector<int>(n, -1);
	map<int,int> mp;
	for(int i = 0; i < n; ++i) {
		if(mp.find(c[i]) != mp.end())
			update(mp[c[i]], -1);
		update(i, 1);
		for(auto a : q[i]) {
			ans[a.second] = query(n) - query(a.first);
		}
		mp[c[i]] = i;
	}
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


Measured memory_bytes: 65952
// Aizu Vol-2 0219: A Popular Ice-cream Shop
// 2017.8.7

#include <stdio.h>

int f[10];

int main()
{
	int n, c;
	int i, j;

	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		for (i = 0; i < 10; i++) f[i] = 0;
		for (i = 0; i < n; i++) scanf("%d", &c), f[c]++;
		for (i = 0; i < 10; i++) {
			if (f[i] == 0) puts("-");
			else for (j = f[i]; j > 0; j--) putchar('*'); putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 572
using System;
using System.Linq;
using System.Collections.Generic;
    
class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();

        int length = T.Length;

        T = T.Substring(0, length-1);

        if(S == T) {
            Console.WriteLine("Yes");
        }else {
            Console.WriteLine("No");
        }
    }
}

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

int main() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time1 = h1*60 + m1;
    int time2 = h2*60 + m2;
    time2-=k;
    int ans = time2-time1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */


int main() {
  string s;
  cin >> s;
  ll ans = INF;
  REP(i, s.size() - 2) {
    ll t = stoi(s.substr(i, 3));
    // DEBUG(t);
    ans = min((ll)abs(t - 753), ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#define N 12
using namespace std;

const int Roll[4][6]{
	// 1 2 3 4 5 6
	{2, 6, 3, 4, 1, 5},//N
	{3, 2, 6, 1, 5, 4},//W
	{4, 2, 1, 6, 5, 3},//E
	{5, 1, 3, 4, 6, 2}//S
};

int main (){
	int dice[N] = {0};
	for(int i = 0; i < 6; i++){
		cin >> dice[i];
	}
	string c;
	cin >> c;
	int newdice[N];
	for(int i = 0; i < c.size(); i++){
		if(c[i] == 'N'){
			for(int j = 0; j < 6; j++){
				newdice[j] = dice[Roll[0][j]-1];
			}
		}else if(c[i] == 'W'){
			for(int j = 0; j < 6; j++){
				newdice[j] = dice[Roll[1][j]-1];
			}
		}else if(c[i] == 'E'){
			for(int j = 0; j < 6; j++){
				newdice[j] = dice[Roll[2][j]-1];
			}
		}else if(c[i] == 'S'){
			for(int j = 0; j < 6; j++){
				newdice[j] = dice[Roll[3][j]-1];
			}
		}
		for(int j = 0; j < 6; j++){
			dice[j] = newdice[j];
		}
	}
	cout << dice[0] << endl;
}


Measured memory_bytes: 3208
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int x,y;
ll solve(){
   ll ans=0;
   

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

    cin>>x>>y;
    rep(i,x+1){
        if(2*i+4*(x-i)==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val N,M = sc.nextInt()
    val list = for (i <- 0.until(N)) yield {
      val K = sc.nextInt()
      List.fill(K)(sc.nextInt()).foldLeft(0)((pre, i) => pre | (1 << i))
    }
    val num = list.foldLeft(~0)((pre, i) => pre & i)
    println(Integer.bitCount(num))
  }
}


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

int main() {
	string S;
	cin >> S;
  int yyyy = stoi(S.substr(0,4));
  int mm = stoi(S.substr(5,2));
  int dd = stoi(S.substr(8,2));
  if(yyyy >= 2020){
    cout << "TBD" << endl;
  } else if(yyyy == 2019 && mm >= 5){
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
}

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

int main () {
  string S;
  cin >> S;
  
  vector<char> data = {S.at(0),S.at(1),S.at(2)};
  bool A = false, B = false, C = false;
  for (char x : data) {
    if (x == 'a') {
      A = true;
    }
    if (x == 'b') {
      B = true;
    }
    if (x == 'c') {
      C = true;
    }
  }
  if (A && B && C) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
#n,k=100,100000
#a=[k//2]*n
mod=pow(10,9)+7
dp=[0]*(k+1) # dp[j]:j個の飴を分ける分け方。人が一人以上のとき、0個の時は明らかに1通り。0人に飴を分ける方法はないので0通り
sdp=[0]*(k+2)
for i in range(a[0]+1):#一人目だけいる時、その人が持てる飴の個数以下なら1
  dp[i]=1 
for i in range(1,n):
      # 累計和にする
      s=0
      for l in range(k+1):
            s+=dp[l]
            sdp[l+1]=s%mod
      for j in range(1,k+1):
        dp[j]=(sdp[1+j]-sdp[max(0,j-a[i])])%mod
print(dp[-1]%mod)

Measured memory_bytes: 44380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, K; cin >> N >> K;
  multiset<ll> S;
  rep(i, N){
    ll p; cin >> p;
    S.insert(p);
  }
  ll ans = 0;
  auto itr = S.begin();
  rep(i, K){
    ans += *itr;
    itr++;    
  }
  cout << ans << endl;
}


Measured memory_bytes: 3664
import Control.Monad
import Control.Applicative
import Data.List

isTriangle :: [Int] -> Bool
isTriangle [a,b,c] = a*a + b*b == c*c

main = do
    n <- readLn
    replicateM_ n $ do
        lines <- (map (read :: String -> Int) . words) <$> getLine
        if isTriangle $ sort lines
           then putStrLn "YES"
           else putStrLn "NO"

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

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)
#define INF 1123456789
#define MOD 1000000007LL
#define ff first
#define ss second
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pi> vpi;



void solve(int testcase)
{
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, 0, n-1) cin >> a[i];
    int cnt = 0;
    int i = 1;
    while(i < n)
    {
        cnt++;
        i += (k-1);
    }
    cout << cnt;

}

signed main()
{
//    #ifdef VPAL
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(10);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

typedef long long ll;
using namespace std;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> grid(H);

  for (ll i = 0; i < H; i++) {
    cin >> grid[i];
  }

  queue<pair<ll, ll>> q;
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      if (grid[i][j] == '#') {
        q.push(make_pair(i, j));
      }
    }
  }

  vector<vector<ll>> distance(H, vector<ll>(W, 0));

  while (!q.empty()) {
    pair<ll, ll> p = q.front();
    q.pop();

    ll h = p.first;
    ll w = p.second;
    // up
    if (h - 1 >= 0 && grid[h - 1][w] == '.') {
      grid[h - 1][w] = '#';
      distance[h - 1][w] = distance[h][w] + 1;
      q.push(make_pair(h-1, w));
    }
    // down
    if (h + 1 < H && grid[h + 1][w] == '.') {
      grid[h + 1][w] = '#';
      distance[h + 1][w] = distance[h][w] + 1;
      q.push(make_pair(h + 1, w));
    }
    // right
    if (w + 1 < W && grid[h][w + 1] == '.') {
      grid[h][w + 1] = '#';
      distance[h][w + 1] = distance[h][w] + 1;
      q.push(make_pair(h, w + 1));
    }
    // left
    if (w - 1 >= 0 && grid[h][w - 1] == '.') {
      grid[h][w - 1] = '#';
      distance[h][w - 1] = distance[h][w] + 1;
      q.push(make_pair(h, w - 1));
    }
  }

  ll ans = 0;
  for(auto row : distance) {
    for (auto d : row) {
      ans = max(ans, d);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 25524
#include <stdio.h>

struct DICE{
	int s1;
	int s2;
	int s3;
	int s4;
	int s5;
	int s6;
};

struct DICE rotateE(struct DICE d) {
	int a;
	a = d.s1;
	d.s1 = d.s4;
	d.s4 = d.s6;
	d.s6 = d.s3;
	d.s3 = a;
	
	return d;
}

struct DICE rotateN(struct DICE d) {
	int a;
	a = d.s1;
	d.s1 = d.s2;
	d.s2 = d.s6;
	d.s6 = d.s5;
	d.s5 = a;
	
	return d;
}

struct DICE rotateS(struct DICE d) {
	int a;
	a = d.s1;
	d.s1 = d.s5;
	d.s5 = d.s6;
	d.s6 = d.s2;
	d.s2 = a;
	
	return d;
}

struct DICE rotateW(struct DICE d) {
	int a;
	a = d.s1;
	d.s1 = d.s3;
	d.s3 = d.s6;
	d.s6 = d.s4;
	d.s4 = a;
	
	return d;
}


int main(void) {
	
	struct DICE d;
	char s[100];
	int i;
	int n = 0;
	
	scanf("%d %d %d %d %d %d", &d.s1, &d.s2, &d.s3, &d.s4, &d.s5, &d.s6);
	
	scanf("%s", s);
	
	for(i = 0; s[i] != '\0'; i++) {
		n++;
	}

	
	for(i = 0; i < n; i++) {
		if(s[i] == 'E') {
			d = rotateE(d);
		} else if(s[i] == 'N') {
			d = rotateN(d);
		} else if(s[i] == 'S') {
			d = rotateS(d);
		} else if(s[i] == 'W') {
			d = rotateW(d);
		}
	}
	
	printf("%d\n", d.s1);
	
	return 0;
}
  

Measured memory_bytes: 596
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <sstream>
using namespace std;
string p;
int n, q;
int a[10000], b[500];
int k, l;
int main()
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
	}
	cin >> q;
	l=0;
	for(int j=0; j<q; j++)
	{
		cin >> k;
		for(int i=0; i<n; i++)
		{
			if(k==a[i])
			{
				l+=1;
				break;
			}
		}
	}
	cout << l << endl;
    return 0;
}

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

int main(){
  int N,A,B;cin>>N>>A>>B;
  int ans=0;
  for(int i=1;i<=N;i++){
    int count=0;
    int X=i;
    while(X>0){
      count+=X%10;
      X/=10;
    }
    if(count>=A && count <=B) ans+=i;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3580
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7

vector<pair<pair<int,int>,pair<int,int>>> quad;
int n,m,q; int seq[11] = {0}; ll ans = 0;
int a[51],b[51],c[51],d[51]; int t = 0;

ll score()
{
	ll ans = 0;
	for(int i=0; i<t; i++)
		if(seq[b[i]]-seq[a[i]]==c[i])		
			ans += d[i];
	
	return ans;
}

void solve(int cur)
{
	if(cur==n+1)
		ans = max(ans,score());
	else if(cur < n+1)
	{
		for(int i=seq[cur-1]; i<=m; i++)
		{
			seq[cur] = i; 
			solve(cur+1);
		}
	}
}

int main()
{
	NeedForSpeed(); seq[0] = 1; 
	cin>>n>>m>>q; t = q; 
	while(q--) cin>>a[q]>>b[q]>>c[q]>>d[q];
	solve(1); cout<<ans<<endl;
	return 0;
} 

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

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

	ll X;
	cin >> X;

	ll ans = 1;
	while(ans * (ans + 1) / 2 < X) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int i,j = 0,a,ans = 1;
  int flag = 0;
  char s[11];
  scanf("%d", &a);
	scanf("%s", s);
  if (a >= 3200) {
    printf("%s", s);
  }
  else {
    printf("red");
  }
	return 0;
}

Measured memory_bytes: 128
A, B, K = gets.split.map(&:to_i)
size = (B-A+1)
if size <= K * 2
    (A..B).each{ |n| puts n }
else
    (A..(A+K-1)).each{ |n| puts n }
    ((B-K+1)..B).each{ |n| puts n }
end

Measured memory_bytes: 1788
#include <iostream>

using ll=long long int;

ll k;

ll ans[50];

int main() {

    std::cin>>k;

    std::cout<<50<<std::endl;

    int m=k%50;
    ll n=k/50;

    for(int i=0;i<m;++i)
        ans[i]=n+50-i;

    for(int i=m;i<50;++i)
        ans[i]=n+50-m-1;

    for(int i=0;i<49;++i)
        std::cout<<ans[i]<<' ';
    std::cout<<ans[49]<<std::endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val sc = java.util.Scanner(System.`in`)
  val N = sc.nextInt()
  val A = arrayOf(0) + Array(N) { sc.nextInt() } + arrayOf(0)
  val d = (0..(A.count() - 2)).map { i ->
                                    val d = A[i] - A[i + 1]
                                    if (d > 0) d else -d
                                   }
  val sum = d.sum()
  for (i in 0..(N-1)) {
    println(sum - d[i] - d[i + 1] + Math.abs(A[i] - A[i + 2]))
  }
}


Measured memory_bytes: 68752
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC054C_OneStrokePath();

#if 1
int main()
{
	ABC054C_OneStrokePath();
	fflush(stdout);
	return 0;
}
#endif

static int ABC054C_dfs(std::set<int> visit, std::vector<std::vector<int>>& graph, int now, int vCnt) 
{
	if (visit.find(now) != visit.end()) {
		return 0;
	}
	visit.insert(now);
	if (visit.size() == vCnt) {
		return 1;
	}

	int ans = 0;
	for (auto it = graph[now].begin(); it != graph[now].end(); it++) {
		ans += ABC054C_dfs(visit, graph, *it, vCnt);
	}
	return ans;
}
static void ABC054C_OneStrokePath()
{
	int N, M;
	get2int(N, M);

	std::vector<std::vector<int>> edge(N);
	for (int i = 0; i < M; i++) {
		int from, to;
		get2int(from, to); from--; to--;
		edge[from].push_back(to);
		edge[to].push_back(from);
	}

	std::set<int> visit;
	printf("%d\n", ABC054C_dfs(visit, edge, 0, N));
}


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

int min3(int a, int b, int c){
	int min;
	if(a<b) min = a;
	else min = b;
	if(c<min) min = c;
	return min;
}

int main(){
	vector <string> grid;
	static int dp[1000][1000];

	while(1){
		int n;
		cin >> n;
		if(n==0) break;

		for(int i=0;i<n;i++){
			string buf;
			cin >> buf;
			grid.push_back(buf);
		}
		for(int i=0;i<n;i++){
			if(grid[0][i]=='*') dp[0][i] = 0;
			else dp[0][i] = 1;
		}
		for(int i=1;i<n;i++){
			if(grid[i][0]=='*') dp[i][0] = 0;
			else dp[i][0] = 1;
		}

		int maxWidth = 0;
		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				if(grid[i][j]=='*') dp[i][j] = 0;
				else{
					dp[i][j] = min3(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]) + 1;
					if(dp[i][j]>maxWidth) maxWidth = dp[i][j];
				}
			}
		}
		cout << maxWidth << endl;
		grid.clear();
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,m;
	char s[101];

	scanf("%d%s",&n,s);
	if(n%2!=0){
		printf("No\n");
		return 0;
	}
	m=strlen(s);
	for(i=0;i<m/2;i++)
		if(s[i]!=s[m/2+i]){
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;
using PP = pair<P,llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, Ma, Mb;
	vector<PP> drug;

	cin >> N >> Ma >> Mb;
	drug.resize(N);
	for(int i = 0; i < N; i++)
		cin >> drug[i].first.first >> drug[i].first.second >> drug[i].second;

	vector<vector<llong> > dp(401, vector<llong>(401,inf));
	dp[0][0] = 0;
	for(int i = 0; i < N; i++){
		P check = drug[i].first;
		llong cost = drug[i].second;
		for(int j = 400; j >= check.first; j--)
			for(int k = 400; k >= check.second; k--)
				dp[j][k] = min(dp[j][k], dp[j-check.first][k-check.second] + cost);
	}

	llong ans = inf;
	for(int i = 1; Ma*i <= 400 && Mb*i <= 400; i++)
		ans = min(ans, dp[Ma*i][Mb*i]);

	if(ans == inf)
		ans = -1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
int main(){
	ll n,m;
	cin>>n>>m;
	ll a[200100]={0};
	rep(i,0,m){
		ll f,t;
		cin>>f>>t;
		if(f==1)a[t]++;
		if(t==n)a[f]++;
	}
	rep(i,0,n){
		if(a[i]>1){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define r(i, j) for (int i = 1; i <= j; i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int N, M, Q;
int A[55], B[55], C[55], D[55];
int ans = 0;

void dfs(vec<int> Z) {
    int size = Z.size();
    if (size == N) {
        int tmpans = 0;
        rep(i, Q) {
            if (Z[B[i]] - Z[A[i]] == C[i]) tmpans += D[i];
        }
        ans = max(ans, tmpans);
        return;
    }

    Z.push_back(Z.back());
    for (int i = Z.back(); i <= M; ++i) {
        Z[size] = i;
        dfs(Z);
    }
}

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

    rep(i, Q) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        --A[i];
        --B[i];
    }
    dfs(vec<int>(1, 1));
    cout << ans << endl;
}


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

int a, b, c;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> a >> b >> c;
	
	int t = b * c;
	if (t >= a) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


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

const int MAXN = 1e2+5;
const int MAXNN = 1e5+7;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

ll w[MAXN],val[MAXN],dp[MAXN][MAXNN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n,cap;cin >> n >> cap;
    for(int i=1;i<=n;++i) cin >> w[i] >> val[i];

    for(int i=1;i<=1e5;++i) dp[0][i] = INF;

    for(int i=1;i<=n;++i){
        dp[i][0] = 0;
        for(int j=1;j<=1e5;++j){
            dp[i][j] = dp[i-1][j];
            if(val[i] <= j){
                dp[i][j] = min(dp[i][j],dp[i-1][j - val[i]] + w[i]);
            }
        }
    }

    int maxs=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=1e5;++j){
            if(dp[i][j] <= cap) maxs = max(maxs,j);
        }
    }
    cout << maxs;
}


Measured memory_bytes: 80128
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll N, Y; cin >> N >> Y;
    for(int x= 0 ; x <= N ;x++){
        for(int y = 0;y <= N; y++){
            int z= N - x - y;
            if(Y==10000*x + 5000*y + 1000*z && 0 <= z &&z <=N){
                cout << x <<" "<< y <<" "<< z << endl;
                return 0;
            }
            
        }
    }
    cout << "-1 -1 -1" << endl;
    
}


Measured memory_bytes: 3648
a = map(str, input().split())
three_num_list = list(a)

if '5' in three_num_list:
    three_num_list.remove('5')
    two_num_list = three_num_list
    if '5' in two_num_list and '7' in two_num_list:
        print('YES')
    else:
        print('NO')
else:
    print('NO')

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n ;i++)
    cin >> a[i];
    int cnt = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] == a[i + 1]){
        a[i + 1] = 0;
        cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():
    n, m = map(int,input().split())
    s = []
    for i in range(m):
        s.append(list(map(int,input().split()))[1:])
    p = list(map(int, input().split()))

    ans = 0

    for i in range(2 ** n):

        flag = False
        if flag == False:
            light = 0
            for a in range(m):
                tmp = p[a]
                count = 0
                for j in s[a]:
                    if (i >> (j - 1)) & 1:
                        count += 1
                if count % 2 != tmp:
                    flag = True
                    break

                light += 1


        if light == m:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 15488
n, d = map(int, input().split())
x = []
for i in range(n):
  x.append(list(map(int, input().split())))

ans = 0

for i in range(n - 1):
  for j in range(i + 1, n):
    distance = 0
    for k in range(d):
      distance += (x[i][k] - x[j][k]) ** 2
    if int(distance ** (1/2)) == distance ** (1/2):
      ans += 1

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {if(a < b) {a= b;return 1;}return 0;}
template <class T> inline bool chmin(T &a, T b) {if(a > b) {a= b;return 1;}return 0;}
ll mod= 1e9 + 7;

  ll dp[3010][3010][6]={};
int main() {
  int r,c,k;
  cin >> r >>c >> k;

  ll a[r][c]={};
  rep(i,k){
    int rr,cc,vv;
    cin >> rr >>cc >>vv;
    a[rr-1][cc-1]=vv;
  }
  rep(i,r){
    rep(ii,c){
      for(int d=2;d>=0;d--){
        chmax(dp[i][ii][d+1],dp[i][ii][d]+a[i][ii]);
      }
      rep(d,4){
        chmax(dp[i+1][ii][0],dp[i][ii][d]);
        chmax(dp[i][ii+1][d],dp[i][ii][d]);
      }
    }
  }
  ll ans=0;
  rep(i,4)chmax(ans,dp[r-1][c-1][i]);
  cout << ans << endl;
}

Measured memory_bytes: 497304
#!/usr/bin/env python3
a, b, c, d, e, f = map(int, input().split())

lim = (f // c) + 1
ans_n = 0
ans_total = 0
ans_su = 0

for ac in range(31):
    for bc in range(31):

        wt = a * ac * 100 + b * bc * 100
        if wt == 0:
            break

        max_su = wt / 100 * e

        for cc in range(lim):
            for dc in range(lim):

                su = c * cc + d * dc

                if (su > max_su) or (wt + su > f):
                    break

                n = (100 * su) / (wt + su)
                if n >= ans_n:
                    ans_n = n
                    ans_total = wt+su
                    ans_su = su

print(ans_total, ans_su)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

// Nの桁数
int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x); 
    y -= a / b * x;
    return d;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

bool prime(long long N) {
    ll p = N;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
    }
    if (N == p) return true;
    return false; 
}

int func(int n,int m) {
    int l=1,r=100000000;
    while (r-l>1) {
        int mid = (l+r)/2;
        int sum=0;
        int t = mid;
        while (t) {
            sum+=t/n;
            t/=n;
        }
        if (sum>=m) {
            r=mid;
        } else {
            l=mid;
        }
    }
    return r;
}

int main() {
    ll x;cin>>x;
    while (1) {
        if (prime(x)) {
            cout<<x<<endl;
            break;
        } else {
            x++;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

template<class Pair>
struct CompBySecond {
	bool operator()(const Pair& left, const Pair& right) {
		return left.second < right.second || (left.second == right.second && left.first < right.first);
	}
};

int N, K;
LL X[50], Y[50];

bool E(int d,int u, int l, int r) {
	int sum = 0;
	REP(i, 0, N) {
		if (d <= X[i] && X[i] <= u && l <= Y[i] && Y[i] <= r) sum++;
	}
	return sum >= K;
}

int main() {
	cin >> N >> K;
	REP(i, 0, N) {
		cin >> X[i] >> Y[i];
	}
	LL mn = INFLL;
	REP(i, 0, N) {
		REP(j, 0, N) {
			REP(k, 0, N) {
				REP(l, 0, N) {
					if (E(X[i], X[j], Y[k], Y[l])) {
						mn = min(mn, (X[j] - X[i]) * (Y[l] - Y[k]));
					}
				}
			}
		}
	}
	cout << mn << endl;

	return 0;
}



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

As.sort(reverse=True)

minAOK = As[0]+1
sumSubsets = set([0])
for A in As:
    if A >= K:
        minAOK = A
        continue
    for sumSubset in sumSubsets.copy():
        if K - A <= sumSubset:
            minAOK = A
        if sumSubset + A < K:
            sumSubsets.add(sumSubset + A)

ans = len([A for A in As if A < minAOK])
print(ans)


Measured memory_bytes: 48152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int ans = 0, x = 0;
	rep(i, s.size()) {
		if (s[i] == 'S') x++;
		else {
			if (x) x--;
			else ans++;
		}
	}
	ans += x;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
import sys

def main():
    """ ????????? """
    istr = sys.stdin.read()
    wi = istr.splitlines()
    for i in wi:
        a = list(map(int,i.split()))
        b = str(a[0] + a[1])
        print(len(b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7596
IDENTIFICATION DIVISION.
program-id. kyopuro.

data division.
working-storage section.
01 in-str pic x(22).
01 n pic 9(10).
01 m pic 9(10).
01 res pic 9(19).
01 t pic 9(5).
01 view-res pic z(18)9.

procedure division.
main.
    accept in-str.
    unstring in-str delimited by all SPACE
    into n m.
    
    if n = 1 and m = 1
    then
        move 1 to view-res
    else if n = 1 or m = 1
    then
        compute view-res = function max(n, m) - 2
    else
        compute view-res = (n - 2) * (m - 2)
    end-if
    end-if.
    
    display view-res.
    stop run.


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	ll N = 2*n;
	vc c(N);
	vl a(N);
	rep(i,N) cin >> c[i] >> a[i];
	vvl pos(2,vl(n+1));
	vector<vvl> pl(N+1,vvl(n+1,vl(2,0)));
	rep(i,N){
		if(c[i]=='B') pos[0][a[i]] = i;
		else pos[1][a[i]] = i;
	}
	for(ll i=N-1; i>=0; i--){
		rep(j,n+1){
			if(j >= a[i]){
				pl[i][j][0] += pl[i+1][j][0] + (c[i] == 'B');
				pl[i][j][1] += pl[i+1][j][1] + (c[i] == 'W');
			}else{
				rep(k,2) pl[i][j][k] = pl[i+1][j][k];
			}
		}
	}
	auto calc = [&](ll c, ll num, ll id){
		return pos[c][num] - id + pl[pos[c][num]][num-1][c] + pl[pos[c][num]][id+1-num][!c];
	};
	vvl dp(n+1,vl(n+1,inf));
	dp[0][0] = 0;
	REP(i,1,N+1){
		rep(j,i+1){
			if(j > n || i-j > n) continue;
			if(j>0) chmin(dp[i-j][j], dp[i-j][j-1] + calc(1,j,i-1));
			if(j<i) chmin(dp[i-j][j], dp[i-j-1][j] + calc(0,i-j,i-1));
		}
	}
	cout << dp[n][n] << "\n";
}

Measured memory_bytes: 471680
#include<iostream>
using namespace std;
int main() {
    long long int N,A,B;cin>>N>>A>>B;
    if (A==0) {
        cout << 0 << endl;
    } else {
        long long x = N / (A+B);
        long long y = N % (A+B);
        x = x * A;
        if (y > A) y = A;
        cout << (x+y) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Stable Sort
//2019-01-19
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 36

char char1[N][4], char2[N][4];
char temp[4];
int n;

void BubbleSort();
void SelectionSort();
void Print();

int main(){
  int i;

  scanf("%d", &n);
  if(n < 1 || n > N){
    printf("カードの枚数が適当ではありません。\n");
    exit(1);
  }

  for(i = 0 ; i < n ; i++){
    scanf("%s", char1[i]);
    strcpy(char2[i], char1[i]);
  }

  BubbleSort();
  SelectionSort();
  Print();

  return 0;
}

void BubbleSort() {
  int i, j;

  for(i = 0 ; i < n-1 ; i++){
    for(j = n-1 ; j > i ; j--){
      if(char1[j][1] < char1[j-1][1]){
        strcpy(temp, char1[j]);
        strcpy(char1[j], char1[j-1]);
        strcpy(char1[j-1], temp);
      }
    }
  }
}

void SelectionSort(){
  int i, j, min;

  for(i = 0 ; i < n ; i++){
    min = i;
    for(j = i ; j < n ; j++){
      if(char2[j][1] < char2[min][1])
        min = j;
      }
    if(i != min){
      strcpy(temp, char2[i]);
      strcpy(char2[i], char2[min]);
      strcpy(char2[min], temp);
    }
  }
}

void Print(){
  int i;

  for(i = 0 ; i < n ; i++){
    printf("%s", char1[i]);
    if(i == n-1)
      break;
    printf(" ");
  }
  printf("\nStable\n");

  for(i = 0 ; i < n ; i++){
    printf("%s", char2[i]);
    if(i == n-1)
      break;
    printf(" ");
  }

  int mark = 1;
  for(i = 0 ; i < n ; i++){
    if(strcmp(char1[i], char2[i]) == 0){
      mark = 1;
    }
    else if(strcmp(char1[i], char2[i]) != 0){
      mark = 0;
      break;
    }
  }
  if(mark == 1){
    printf("\nStable\n");
  }
  else if(mark == 0){
      printf("\nNot stable\n");
  }
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>

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

    int prime[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    int count[25];

    memset(count,0,sizeof(count));

    for(int i=1; i <= N; i++){
        int cur = i;
        for(int j=0; j<25; j++){
            
            int prime_tmp = prime[j];
            while (cur % prime_tmp == 0){
                cur /= prime_tmp;
                count[j] += 1;
            }
        }
    }

    //cout << count[0] << endl;
    //cout << count[1] << endl;
    //cout << count[2] << endl;
    //cout << count[3] << endl;

    int ans = 0;

    //1: 2*24 //
    int c_2 = 0;
    int c_24 = 0;
    for(int j=0; j<25; j++){
        if(count[j] >= 2){c_2++;}
        if(count[j] >= 24){c_24++;}
    }

    //ans += (c_2-c_24) * c_24 + (c_24 * (c_24-1)/2);
    ans += (c_2-1) * c_24; 

    //2: 2*4*4 //
    c_2 = 0;
    int c_4 = 0;
    for(int j=0; j<25; j++){
        if(count[j] >= 2){c_2++;}
        if(count[j] >= 4){c_4++;}
    }

    ans += (c_2-2) * (c_4*(c_4-1)/2);
    
    //3: 74 //
    int c_74 = 0;
    for(int j=0; j<25; j++){
        if(count[j] >= 74){c_74++;}
    }
    ans += c_74;

    //4: 14*4 //
    int c_14 = 0;
    c_4 = 0;
    for(int j=0; j<25; j++){
        if(count[j] >= 14){c_14++;}
        if(count[j] >= 4){c_4++;}
    }
    ans += (c_4-1) * c_14;

    
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

vector<lint> prime_factorization(lint N) {
	//素因数分解して配列で返す
	vector<lint> R;
	if (N < 2)return R;
	for (lint i = 2; i * i <= N; i++) {
		while (N % i == 0) {
			R.push_back(i);
			N /= i;
		}
	}
	if (N != 1) {
		R.push_back(N);
	}
	return R;
}

int main() {
	lint N, P;
	cin >> N >> P;
	vector<lint>V = prime_factorization(P);
	sort(V);
	lint VS = V.size();
	if (VS == 0) {
		cout << P << endl;
		return 0;
	}
	lint cnt = 1;
	lint ans = 1;
	for (int i = 1; i < VS; i++) {
		if (V[i - 1] == V[i]) {
			cnt++;
		}
		else {
			if (cnt / N * V[i - 1] != 0) {
				ans *= pow(V[i - 1], cnt / N);
			}
			cnt = 1;
		}
	}
	if (cnt / N * V[VS - 1] != 0) {
		ans *= pow(V[VS - 1], cnt / N);
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_A

class Dice
    def initialize(n)
        @numbers = n
    end
    
    def print
        p @numbers
    end
    
    def s
        buf = @numbers[0]
        @numbers[0] = @numbers[4]
        @numbers[4] = @numbers[5]
        @numbers[5] = @numbers[1]
        @numbers[1] = buf
    end
    def n
        buf = @numbers[0]
        @numbers[0] = @numbers[1]
        @numbers[1] = @numbers[5]
        @numbers[5] = @numbers[4]
        @numbers[4] = buf
    end
    def w
        buf = @numbers[0]
        @numbers[0] = @numbers[2]
        @numbers[2] = @numbers[5]
        @numbers[5] = @numbers[3]
        @numbers[3] = buf
    end
    def e
        buf = @numbers[0]
        @numbers[0] = @numbers[3]
        @numbers[3] = @numbers[5]
        @numbers[5] = @numbers[2]
        @numbers[2] = buf
    end
    
    def top
        @numbers[0]
    end
end

d = Dice.new(gets.split.map(&:to_i))
str = gets.chomp
str.chars.each do |c|
    d.s if c == "S"
    d.n if c == "N"
    d.w if c == "W"
    d.e if c == "E"
end
p d.top

Measured memory_bytes: 6120
package main

import "fmt"

func main() {
	ar := make([]int, 5)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	var sum, min int
	min = -1
	for _, v := range ar {
		m := v % 10
		if m == 0 {
			sum += v
		} else {
			sum += (v/10 + 1) * 10
			if min == -1 {
				min = m
			} else if m < min {
				min = m
			}
		}
	}
	if min > 0 {
		sum -= 10 - min
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
#define MOD 1000000007
const int MAX = 510000;


int main(){
  ll N;
  cin>>N;
  ll num=N;
  queue<char>memo;
  for(ll i=35;i>=0;i--){
    if(i%2==0){
      ll k=i/2ll;
      ll upper=((ll)pow(4,k+1)-1ll)/3ll;
      ll neupper=((ll)pow(4,k)-1ll)/3ll;;
      if(neupper<num&&num<=upper){memo.push('1');num-=(ll)pow(2,i);}
      else{memo.push('0');}
    }
    if(i%2==1){
      ll k=i/2ll;
      ll lower=((-2)*((ll)pow(4,k+1)-1ll))/3ll;;
      ll nelower=(-2)*((ll)pow(4,k)-1ll)/3ll;;
      if(lower<=num&&num<nelower){num+=(ll)pow(2,i);memo.push('1');}
      else{memo.push('0');}
    }
  }
  while(!memo.empty()){
    auto t=memo.front();
    if(t=='1'){break;}
    else{memo.pop();}
  }
  if(memo.empty()){cout<<0<<endl;}
  else{
    while(!memo.empty()){
      cout<<memo.front();
      memo.pop();
    }
    cout<<endl;
  }
  
  
}



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

int main()
{
	long long X, rep = 100, Cast = 0;
	scanf("%lld", &X);
	while (1)
	{
		rep = (long long)(rep * 1.01);
		Cast++;
		if (rep >= X) { printf("%lld\n", Cast); return 0; }
	}
}

Measured memory_bytes: 3832
import sys
input = sys.stdin.readline

mod=998244353

N=int(input())
M1=int(input())
E1=[[] for i in range(N+1)]
for i in range(M1):
    x,y=map(int,input().split())
    E1[x].append(y)
    E1[y].append(x)

M2=int(input())
E2=[[] for i in range(N+1)]
for i in range(M2):
    x,y=map(int,input().split())
    E2[x].append(y)
    E2[y].append(x)

M3=int(input())
E3=[[] for i in range(N+1)]
for i in range(M3):
    x,y=map(int,input().split())
    E3[x].append(y)
    E3[y].append(x)

G1=[-1]*(N+1)
G1[N]=0
for i in range(N-1,-1,-1):
    GS=set()
    for to in E1[i]:
        GS.add(G1[to])
    for j in range(N+1):
        if j in GS:
            continue
        else:
            G1[i]=j
            break

G2=[-1]*(N+1)
G2[N]=0
for i in range(N-1,-1,-1):
    GS=set()
    for to in E2[i]:
        GS.add(G2[to])
    for j in range(N+1):
        if j in GS:
            continue
        else:
            G2[i]=j
            break

G3=[-1]*(N+1)
G3[N]=0
for i in range(N-1,-1,-1):
    GS=set()
    for to in E3[i]:
        GS.add(G3[to])
    for j in range(N+1):
        if j in GS:
            continue
        else:
            G3[i]=j
            break

from collections import Counter
C1=Counter()
C2=Counter()
C3=Counter()

for i in range(1,N+1):
    C1[G1[i]]=(C1[G1[i]]+pow(10,18*i,mod))%mod
    C2[G2[i]]=(C2[G2[i]]+pow(10,18*i,mod))%mod
    C3[G3[i]]=(C3[G3[i]]+pow(10,18*i,mod))%mod
        
C12=Counter()

for c1 in C1:
    for c2 in C2:
        C12[c1^c2]=(C12[c1^c2]+C1[c1]*C2[c2])%mod

ANS=0
for c3 in C3:
    ANS=(ANS+C3[c3]*C12[c3])%mod

print(ANS)

Measured memory_bytes: 58784
#include<bits/stdc++.h>
 
 
//      DEEP
 
 
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
      ll n;
      cin>>n;
      map<string,ull>M;
      for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(all(s));
        M[s]+=1;
      }
      map<string,ull>::iterator ip=M.begin();
      ll ans=0;
      for(ip;ip!=M.end();ip++){
        if(ip->second>=2)ans+=(ip->second)*(ip->second-1)/2;
      }
      cout<<ans<<endl;
    }
}
/* Be careful about integer ranges;
   Check the corner cases before submitting.
*/
 

Measured memory_bytes: 11264
while 1:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break

    mat = []
    for _ in range(h):
        mat.append(list(input()))

    x = 0
    y = 0
    cnt = 0
    flag = False
    while mat[x][y] != '.':
        cnt += 1
        if mat[x][y] == '>':
            y += 1
        elif mat[x][y] == '<':
            y -= 1
        elif mat[x][y] == '^':
            x -= 1
        elif mat[x][y] == 'v':
            x += 1

        if cnt == 10**4:
            flag = True
            break

    if flag:
        print("LOOP")
    else:
        print(y, x)



Measured memory_bytes: 5684