akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {

    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String[] sl;

    s = r.readLine();
    int n = Integer.parseInt(s);

    int[] prime = {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[] factor = new int[25];

    for(int i = 1; i <= n; i++)
    {
      int v = i;
      for(int j = 0; j < 25; j++)
      {
        while(v % prime[j] == 0)
        {
          factor[j]++;
          v /= prime[j];
        }
      }
    }

    int f[] = new int[100];
    for(int i = 0; i < 25; i++)
    {
      f[factor[i]]++;
    }

    for(int i = 99; i > 0; i--)
    {
      f[i - 1] += f[i];
    }
    
    
    int a = 0;

    if(f[4] >= 2 && f[2] >= 3)
    {
      a += (f[2] - f[4]) * f[4] * (f[4] - 1) / 2;
    }
    if(f[4] >= 3)
    {
      a += f[4] * (f[4] - 1) * (f[4] - 2) / 2;
    }


    if(f[24] >= 1 && f[2] >= 2)
    {
      a += f[24] * (f[2] - f[24]);
    }
    if(f[24] >= 2)
    {
      a += f[24] * (f[24] - 1);
    }


    if(f[14] >= 1 && f[4] >= 2)
    {
      a += f[14] * (f[4] - f[14]);
    }
    if(f[14] >= 2)
    {
      a += f[14] * (f[14] - 1);
    }

    if(f[74] >= 1)
    {
      a += f[74];
    }

    System.out.println(a);



  }

}


Measured memory_bytes: 21204
n,mw=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(mw+1)] for _ in range(n+1)]
for i in range(n):
    weight,value=l[i]
    for j in range(mw+1):
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
        if j+weight<=mw:
            dp[i+1][j+weight]=max(dp[i][j+weight],dp[i][j]+value)
print(dp[-1][-1])

Measured memory_bytes: 217648
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);

   var sortTable = [a,b,c].sort(function(a,b) {
    return a - b;
   });
   console.log(sortTable.join(' '));
});

process.stdin.resume();
process.stdin.setEncoding('utf8');

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


int main(){
  string s;
  cin >> s;  
  
  string t="keyence";
  int n = s.size();
  
  for(int i = 0; i <t.size(); i++){
      
    string s1 = s.substr(0,i); // lay gia tri tu 0 -> 3
    string s2 = s.substr(i+n-7); // lay gia tri tu (3+n-7) den cuoi
      
    if (s1+s2 == t)
    {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
// numeric_limits<int>::max()

int main(void)
{
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    switch (S[K-1]) {
        case 'A':
            S[K-1] = 'a';
            break;
        case 'B':
            S[K-1] = 'b';
            break;
        case 'C':
            S[K-1] = 'c';
            break;
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(K):
    ans += P[i] + 1
s = ans
for i in range(K, N):
    s -= P[i-K] + 1
    s += P[i] + 1
    if s > ans:
        ans = s
print(ans/2)

Measured memory_bytes: 25060
n = int(input())
l = list(int(i) for i in input().split())
s = l.copy()
s.sort()

flag = False
if s == l:
  flag = True
else:
  for i in range(n):
    for j in range(i+1, n):
      t = l.copy()
      t[i], t[j] = t[j], t[i]
      if s == t:
        flag = True

if flag:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let max = 100_000_000_000_000_000_0;
    let n: i64 = read();
    let elem: Vec<i64> = (0..n).map(|_| read()).collect();
    if elem.contains(&0) {
        print!("{}", 0);
        return;
    }
    let mut ans = 1;
    for i in elem {
        if i <= max / ans {
            ans *= i;
        } else {
            ans = -1;
            break;
        }
    }
    print!("{}", ans)
}


Measured memory_bytes: 2772
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin >> n;
    if (n == 0) {
        cout << 0;
    }
    else{vector<int> vec;
        int count = 0;
        ll ret = 0;
        while (n) {
            if ((n%2 == 1)||(n%2 == -1)){
                vec.push_back(1);
                n -= 1;
            }
            else {
                vec.push_back(0);
            }
            n /= (-2);
           count++;
        }
        for (int i = vec.size() - 1; i >= 0; i--) {
            cout << vec[i];
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll t[n],a[n];
  cin >>t[0]>>a[0];
  ll p=t[0],q=a[0];
  for(ll i=1;i<n;i++){
    cin >>t[i]>>a[i];
    if(p<=t[i]&&q<=a[i]){
      p=t[i];
      q=a[i];
    }
    else{
        ll k=p/t[i],l=q/a[i];
        if(k>l){
          if(p%t[i]!=0){
            p=(k+1)*t[i];q=(k+1)*a[i];
          }
          else{
            p=k*t[i];q=k*a[i];
          }
        }
        else{
          if(q%a[i]!=0){
            p=(l+1)*t[i];q=(l+1)*a[i];
          }
          else{
            p=l*t[i];q=l*a[i];
          }
        }
      }
  }
  cout <<p+q<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005, M = 1000000007;

int n, k;
vector<int> a[N];

int q[N];
int ans;
void dfs(int x, int p)
{
    if (x == 1)
        ans = k;
    else
    {
        if (p == 1)
        {
            if (k - q[p] - 1 <= 0)
                ans = 0;
            else
                ans = (ans * 1LL * (k - q[p] - 1)) % M;
        }
        else
        {
            if (k - q[p] - 2 <= 0)
                ans = 0;
            else
                ans = (ans * 1LL * (k - q[p] - 2)) % M;
        }
    }
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (h == p)
            continue;
        dfs(h, x);
        q[x]++;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1, 1);
    cout << ans << endl;
    return 0;
}


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

struct fentree {
  vector<int> bit;  // binary indexed tree
  int n;

  fentree(int n) {
    this->n = n;
    bit.assign(n, 0);
  }

  fentree(vector<int> a) : fentree(a.size()) {
    for (size_t i = 0; i < a.size(); i++) 
      add(i, a[i]);
  }

  int sum(int r) {
    if (r < 0) return 0;
    int ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1)
      ret += bit[r];
    return ret;
  }

  void add(int idx, int delta) {
    for (; idx < n; idx = idx | (idx + 1))
      bit[idx] += delta;
  }
};

const int mod = 998244353;

void add(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

int sub(int x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
  return x;
}

int mult(int x, int y) {
  return (1LL * x * y) % mod;
}

int powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for ( ; b; b >>= 1) {
    if (b & 1)
      res = res * a %mod;
    a = a * a % mod;
  }
  return (int) res;
}

const int N = 2e5 + 10;

int n;
vector<int> a[N];

void compress() {
  vector<int> xc, yc;
  for (int i = 0; i < n; i++) {
    xc.push_back(a[i][0]);
    yc.push_back(a[i][1]);
  }

  sort(xc.begin(), xc.end());
  sort(yc.begin(), yc.end());

  map<int, int> mpx, mpy;
  int cur = 1;
  for (int i = 0; i < n; i++)
    mpx[xc[i]] = cur++;
  cur = 1;
  for (int i = 0; i < n; i++)
    mpy[yc[i]] = cur++;

  for (int i = 0; i < n; i++) {
    a[i][0] = mpx[a[i][0]];
    a[i][1] = mpy[a[i][1]];
  }
}

int f(int x) {
  return sub(powmod(2, x), 1);
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    a[i] = vector<int>(6);
    scanf("%d %d", &a[i][0], &a[i][1]);
  }
  sort(a, a + n);
  compress();

  fentree ft(n + 1);
  for (int i = 0; i < n; i++) {
    int bawah = ft.sum(a[i][1]);
    a[i][5] = i - bawah;
    a[i][4] = i - a[i][5];
    ft.add(a[i][1], 1);
  }

  ft = fentree(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    int bawah = ft.sum(a[i][1]);
    a[i][2] = n - 1 - i - bawah;
    a[i][3] = n - 1 - i - a[i][2];
    ft.add(a[i][1], 1);
  }
  
  int ans = mult(n, powmod(2, n - 1));
  for (int i = 0; i < n; i++) {
    int z = f(n - 1);
    for (int j = 2; j < 5; j++)
      z = sub(z, f(a[i][j] + a[i][j + 1]));
    z = sub(z, f(a[i][2] + a[i][5]));
    for (int j = 2; j < 6; j++)
      add(z, f(a[i][j]));
    add(ans, z);
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 31948
#include<iostream>

using namespace std;


int main(){
  int a,b;
  string s;
  cin>>s;
  char c;

  a=(s[1]-'0')+(s[0]-'0')*10;
  b=(s[3]-'0')+(s[2]-'0')*10;

  bool ym=0,my=0;

  if(12>=b&&b>=1) ym=1;
  if(12>=a&&a>=1) my=1;

  if(ym){
    if(my) cout<<"AMBIGUOUS"<<endl;
    else cout<<"YYMM"<<endl;
  }
  else{
    if(my) cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, n, s;
    
    while(cin >> a >> b >> n)
    {
        s = 0;
        
        while(a >= b)
        {
            a -= b;
        }
        
        for(int i = 0; i < n; i++)
        {
            a *= 10;
            
            while(a >= b)
            {
                a -= b;
                
                s++;
            }
        }
        
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3064
N, M = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)
distance = Array.new(M-1, 0)
ans = 0

if N < M
  X.sort!
  (M-1).times do |i|
    distance[i] = X[i+1] - X[i]
  end
  distance.sort!
  ans = distance[0, M-N].inject(:+)
end

puts ans

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
string s;
bool flag=false;
int len;
int main()
{
    cin>>s;
    len=s.length();
    for(int i=0;i<len;i++)
    {
    	if(s[i]=='C')
    	{
    		flag=true;
		}
    	if((s[i]=='F')&&(flag))
    	{
    		cout<<"Yes";
    		return 0;
		}
	}
	cout<<"No";
    return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, a, ans = 0;
	map<int, int> amap;
	set<int> aset;
	
	cin >> N;
	rep(i, N) {
		cin >> a;

		aset.insert(a);
		if (amap.count(a) == 0) amap[a] = 1;
		else amap[a]++;
	}

	for (set<int>::iterator it = aset.begin(); it != aset.end(); it++) {
		if (amap[*it] >= (*it)) ans += amap[*it] - (*it);
		else ans += amap[*it];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
    public int getMaximumNumberOfConsecutiveRainyDays(String s) {
        int maxStreak = 0;
        int streak = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == 'R') {
                streak++;
            } else {
                maxStreak = Math.max(maxStreak, streak);
                streak = 0;
            }
        }
        maxStreak = Math.max(maxStreak, streak);

        return maxStreak;
    }

    public static void main(String[] args) throws Exception {
        Main solution = new Main();

        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        int answer = solution.getMaximumNumberOfConsecutiveRainyDays(s);
        System.out.println(answer);
    }
}

Measured memory_bytes: 35560
#include<bits/stdc++.h>
using namespace std;
const int maxn=600060,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
struct seg{
	int l,r;
	bool operator<(const seg &s)const{
		return l<s.l;
	}
};
int n,q,s[maxn],t[maxn],x[maxn],tmp[maxn*2],sz,tl,val[maxn*4],cov[maxn*4],d[maxn];
inline int binary(int x){
	return lower_bound(tmp+1,tmp+sz+1,x)-tmp;
}
void pushdown(int x){
	if(cov[x]!=2e9){
		val[x<<1]=min(val[x<<1],cov[x]);
		val[x<<1|1]=min(val[x<<1|1],cov[x]);
		cov[x<<1]=min(cov[x<<1],cov[x]);
		cov[x<<1|1]=min(cov[x<<1|1],cov[x]);
		cov[x]=2e9;
	}
}
void build(int o,int l,int r){
	cov[o]=val[o]=2e9;
	if(l==r) return;
	int mid=(l+r)>>1;
	build(lson);build(rson);
}
void update(int o,int l,int r,int ql,int qr,int v){
	if(l>=ql && r<=qr) return void((cov[o]=min(cov[o],v),val[o]=min(val[o],v)));
	pushdown(o);
	int mid=(l+r)>>1;
	if(mid>=ql) update(lson,ql,qr,v);
	if(mid<qr) update(rson,ql,qr,v);
}
int query(int o,int l,int r,int p){
	if(l==r) return val[o];
	pushdown(o);
	int mid=(l+r)>>1;
	if(mid>=p) return query(lson,p);
	else return query(rson,p);
}
int main(){
	n=read();q=read();
	FOR(i,1,n){
		s[i]=read();t[i]=read();x[i]=read();
		tmp[++tl]=s[i]-x[i];
		tmp[++tl]=t[i]-1-x[i];
	}
	FOR(i,1,q) d[i]=read(),tmp[++tl]=d[i];
	sort(tmp+1,tmp+tl+1);
	sz=unique(tmp+1,tmp+tl+1)-tmp-1;
	build(1,1,sz);
	FOR(i,1,n) update(1,1,sz,binary(s[i]-x[i]),binary(t[i]-1-x[i]),x[i]);
	FOR(i,1,q){
		int x=query(1,1,sz,binary(d[i]));
		printf("%d\n",x==2e9?-1:x);
	}
}

Measured memory_bytes: 32768
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  ll N = S.size();
  int j = N-1;
  ll ans = 0;
  bool ng = false;
  for(int i = 0; i < N; i++){
    if(S.at(i) == S.at(j)){
      j--;
    }
    else if(S.at(i) == 'x'){
      ans++;
    }
    else if(S.at(j) == 'x'){
      while(S.at(j) == 'x'){
        ans++;
        j--;
      }
      i--; //iは動かさない。インクリメントの調整
    }
    else ng = true;
    if(i+1 >= j) break;
  }
  if(ng) cout << -1 << endl;
  else cout << ans << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int a = ri();
	int b = ri();
	int c = ri();
	if (a > b) std::swap(a, b);
	if (b > c) std::swap(b, c);
	if (a > b) std::swap(a, b);
	std::cout << a + b << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int H;
    int W;
    int N;
    scanf("%d", &H);
    scanf("%d", &W);
    scanf("%d", &N);
    int ctr = 0;
    int total = 0;
    while (N > total){
        if(W >= H){
            total += W;
            ctr++;
        }else if(H > W){
            total += H;
            ctr++;
        }
    }
    printf("%d\n",ctr);
    
    return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    vector<ll> c(n-1), s(n-1), f(n-1);
    REP(i, n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    //cout << c << endl;
    REP(i, n-1){
        ll time = c[i] + s[i];
        for(int j = i+1; j<n-1; j++){
            if(time < s[j]){
                time += (s[j] - time);
                time += c[j];
            }
            else if(time%f[j] == 0){
                time += c[j];
            }
            else{
                ll dep = s[j];
                while(dep < time){
                    dep += f[j];
                }
                time = dep;
                time += c[j];
            }
            //cout << time << endl;
        }
        cout << time << endl;
    }
    cout << 0 << endl;
}

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

Measured memory_bytes: 256
N=gets.to_i
s1=gets.chomp
s2=gets.chomp
MOD=10**9+7

i = 0
arr = []
while i < N
    if s1[i] == s2[i]
        arr << 1
        i += 1
    else
        arr << 2
        i += 2
    end
end

ret = (arr[0] == 1 ? 3 : 6)
arr.each_cons(2) do |a,b|
    if a==1 && b==1
        ret *= 2
    elsif a==1 && b==2
        ret *= 2
    elsif a==2 && b==1
        ret *= 1
    elsif a==2 && b==2
        ret *= 3
    end
end

p ret%MOD

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

int main(void){
    int n;
    int d_1[100], d_2[100];
    int flag = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d_1[i] >> d_2[i];
        
        if (d_1[i] - d_2[i] == 0) {
            flag++;
        } else {
            flag = 0;
        }
        
        if (flag == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    S = input()
    N = len(S)
    #solve
    left = 0
    right = N-1

    ans = 0
    while left<=right:
        if right==left:
            break
        if S[left]==S[right]:
            left+=1
            right-=1
            continue
        if S[left]!='x' and S[right]!='x':
            print(-1);exit()
        if S[left]=='x':
            left+=1
            ans+=1
        if S[right]=='x':
            right-=1
            ans+=1
    if right>left:
        print(-1)
    else:
        print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 9180
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	ll n, x = 0;
	cin >> n;
	ll a[n], b[n];
	rep(i, 0, n)
	cin >> a[i], x ^= a[i];
	rep(i, 0, n)
	b[i] = x ^ a[i];
	rep(i, 0, n)
	cout << b[i] << " ";
	return 0;
}

Measured memory_bytes: 6772
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	string s;
	cin >> s;

	int ans = 700;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'o'){
			ans += 100;
		}
	}

	cout << ans << endl;

}



Measured memory_bytes: 256
n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):
 if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]=A[n],A[i]
print(" ".join(map(str,A[:i]))+" ["+str(A[i])+"] "+" ".join(map(str,A[i+1:])))


Measured memory_bytes: 16388
n = int(input())
n = n % 10
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print('hon') 
elif n == 0 or n == 1 or n == 6 or n == 8:
    print('pon')
elif n == 3:
    print('bon')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;
const int dx[8] = {1,0,-1,0,1,-1,-1,1};
const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main() {
  int h, w; cin >> h >> w;
  vector<string> board(50);
  rep(i,h) cin >> board[i];
  rep(i,h)rep(j,w){
    if(board[i][j] == '#') continue;
    int num = 0;
    rep(d,8) {
      int ni = i + dy[d];
      int nj = j + dx[d];
      if(ni < 0 or h <= ni) continue;
      if(nj < 0 or w <= nj) continue;
      if(board[ni][nj] == '#') num++; 
    }
    board[i][j] = char(num + '0');
  }
  rep(i,h) cout << board[i] << endl;
  
  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    if(n==1){
        COUT(0);
        return 0;
    }
    else if(n==2){
        COUT(1);
        return 0;
    }
    else{
        ans += (n)*(n-1);
        ans /= 2;
    }
    COUT(ans);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b= int(input())
# 文字列の入力
c = int(input())

d = int(input())

x = min([a,b])+min([c,d])
# 出力
print(str(x))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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


int main() {
  ll N,M;

  cin>>N>>M;
  ll a[N][N];
  ll ans =0;
  ll tempa,tempb;
  FOR(i,0,N-1){
    FOR(j,0,N-1){
      a[i][j]=0;
      
    }
  }
  FOR(i,0,M-1){
    cin>>tempa>>tempb;
    a[tempa-1][tempb-1]=1;
    a[tempb-1][tempa-1]=1;
  }
  FOR(i,0,N-1){
    FOR(j,0,N-1){
     // cout<<a[i][j];
      
    }
      //cout<<endl;
  }

  vector<ll> v(N);
  iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
  do {
      ll flag=0;
      if(v[0]!=1){
        flag=1;
      }
      FOR(i,0,N-2){
        if(a[v[i]-1][v[i+1]-1]!=1){
          flag=1;
          break;
        }
      }
      if(flag!=1){
        ans++;
      }
      //for(auto x : v) cout << x << " "; cout  <<" "<<flag<<"\n";
  } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成





  cout<<ans<<endl;
  return 0;


 
}
 


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstdio>
#define MAX 10000
#define NIL -1

using namespace std;
struct Node { 
	int p, l, r;
};
struct Node T[MAX];
int n;

//先行順巡回
void preParse(int u) {
	if (u == NIL)return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}
//中間順巡回
void inParse(int u) {
	if (u == NIL)return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}
//後行順巡回
void postParse(int u) {
	if (u == NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}


int main() {
	int i, v, l, r,root=0;
	scanf("%d",&n);
    //scanf_s("%d", &n);
	//printf("%d", n);
	for (i = 0;i < n;i++) {
		T[i].p = NIL;
		//cout << i << endl;
	}
	for (i = 0;i < n;i++) {
		scanf("%d %d %d", &v, &l, &r);
	//	scanf_s("%d %d %d", &v, &l, &r);

		T[v].l = l;
		T[v].r = r;
		if (l != NIL) {
			T[l].p = v;
		}
		if (r != NIL) {
			T[r].p = v;
		}
	}

		
		for (i = 0;i < n;i++) {
			if (T[i].p == NIL) {
				root = i;

			}
		}

	
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");

	printf("Inorder\n");
	inParse(root);
	printf("\n");

	printf("Postorder\n");
	postParse(root);
	printf("\n");
}


Measured memory_bytes: 3224
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int c0 = 0, c1 = 0;
	for (char c : s) {
		if (c == '0') ++c0;
		if (c == '1') ++c1;
	}
	cout << min(c0, c1) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
ULL sum(ULL n) { return (n * (n + 1) / 2) % ((LL)1e9 + 7); }

int main() {
  ULL N, K;
  cin >> N >> K;
  VEC<ULL> A(N);
  VEC<LL> same(2002, 0);
  REP(i, 0, N) {
    cin >> A[i];
    same[A[i]]++;
  }
  ULL orig = 0;
  REP(i, 0, N) {
    REP(j, i + 1, N) {
      if (A[i] > A[j]) orig++;
    }
  }
  // DUMP(orig);
  ULL MOD = 1e9 + 7;
  sort(ALL(A));
  reverse(ALL(A));
  ULL num;
  ULL ans = orig * K;
  // DUMP(A);
  VEC<ULL> lowerNum(2002, 0);
  REP(i, 0, N - 1) {
    if (A[i] == A[i + 1]) continue;
    lowerNum[A[i]] = N - i - 1;
  }
  // DUMP(lowerNum);
  REP(i, 0, lowerNum.size()) {
    ULL s = (lowerNum[i] * sum(K - 1)) % MOD;
    // DUMP(lowerNum[i], sum(K-1), s);
    ans = (ans +  (s*same[i])%MOD)%MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
var
x,i,j,c,n,d,b:longint;
a:array[1..1000] of longint;
e:int64;
begin
readln(n,x);
for i:=1 to n do
read(a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then begin d:=a[i];a[i]:=a[j];a[j]:=d;end;
for i:=1 to x do
e:=e+a[i];
writeln(e);
end.

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);

  ll m = max(A, max(B, C));
  ll diff = 3 * m - (A + B + C);
  put(diff / 2 + 2 * (diff % 2));
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
n,k=map(int,input().split())
k=min(k,20)
S=list(input())
for i in range(n):
  S[i]=ord(S[i])-97
T=S[::-1]
U=S+T
f=0
for i in range(26):
  A=[]
  for j in range(2*n):
    if U[j]==i:
      f=1
      A.append(j)
  if f==1:
    c=i
    break
B=[]
a=1
for i in range(1,len(A)):
  if A[i]==A[i-1]+1:
    a=a+1
    if A[i]>=n:
      B.append([a,A[i]])
  else:
    a=1
    if A[i]>=n:
      B.append([a,A[i]])
C=[]
b=max(B[i][0] for i in range(len(B)))
for i in range(len(B)):
  if B[i][0]==b:
    C.append(B[i][1])
if b*2**(k-1)>=n:
  for i in range(n):
    print(chr(97+c),end="")
  print()
  exit()
Ans=[]
d=n-b*2**(k-1)
for i in range(len(C)):
  AAns=U[C[i]-d-b+1:C[i]-b+1]
  Ans.append(AAns[::-1])
Ans.sort()
for i in range(b*2**(k-1)):
  print(chr(97+c),end="")
for i in range(n-b*2**(k-1)):
  print(chr(97+Ans[0][i]),end="")
print()

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("io\\in.txt", "r", stdin);
    freopen("io\\out.txt", "w", stdout);
#endif

    int n, q;
    string s;
    cin >> n >> s >> q;

    map<char, set<int>> m;
    rep(i, n) m[s[i]].insert(i);
    
    while (q--) {
        int t;
        cin >> t;

        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            m[s[i]].erase(i);
            m[c].insert(i);
            s[i] = c;
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            
            int cnt = 0;
            for (auto& i : m) {
                auto it = i.se.lower_bound(l);
                if (it != i.se.end() && *it <= r) cnt++;
            }
            cout << cnt << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 27236
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

string s[50];
string z[50];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> s[i];

    for (int i = 0; i < m; ++i)
        cin >> z[i];

    for (int i = 0; i <= n - m; ++i)
    {
        for (int j = 0; j <= n - m; ++j)
        {
            int match = 0;
            for (int k = 0; k < m; ++k)
                for (int l = 0; l < m; ++l)
                    if (s[i + k][j + l] == z[k][l])
                        match++;
            if (match == m * m)
                return cout << "Yes", 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    long N = long.Parse(Console.ReadLine());
    var A = new long[N];
   var zen = Console.ReadLine().Split();
   for(long i = 0;i<N;i++){
     A[i] = long.Parse(zen[i]);
   }
    var Bi = new long[N];
    for (int i = 0; i < N; i++)
    {
        Bi[i] = A[i] + i;
    }
    // Bj = j - A[j]
    var Bj = new long[N];
    for (int j = 0; j < N; j++)
    {
        Bj[j] = j - A[j];
    }
    
    var dic = new Dictionary<long, int>();
for (int i = 0; i < N; i++)
{
    if (!dic.ContainsKey(Bj[i])) dic.Add(Bj[i], 0);
    dic[Bj[i]]++;
}
var ans = 0L;
for (int i = 0; i < N; i++)
{
    if (dic.ContainsKey(Bi[i])) ans += dic[Bi[i]];
}
Console.WriteLine(ans);
  }
}

Measured memory_bytes: 61312
import sys
text = input()
flag = 0
for s in text:
    if flag == 0 and s == "h":
        flag = 1
    elif flag ==1 and s == "i":
        flag = 0
    else:
        print("No")
        sys.exit()
if flag == 0:
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef unsigned long long ull;

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int m;
bool isIn(int x, int y){
    return 0 <= x && x < m && 0 <= y && y < m;
}

int main(){
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    bool field[110][110];
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        if(p != 0) cout << endl;
        cin >> m;
        if(m == 1){cout << "#" << endl; continue;}
        else if(m == 2){cout << "##" << endl; cout << "# " << endl; continue;}
        rep(i, 110)rep(j, 110)field[i][j] = false;
        int x = 0, y = 0, d = 0;
        field[0][0] = true;
        while(true){
            bool change = false;
            while(isIn(x+dx[d], y+dy[d])){
                if(field[x+dx[d]][y+dy[d]]){
                    field[x][y] = false;
                    x -= dx[d]; y -= dy[d];
                    break;
                }
                change = true;
                x += dx[d]; y += dy[d];
                field[x][y] = true;
            }
            if(!change) break;
            d = (d+1)%4;
        }
        if(m%2 == 1){
            x += dx[d]; y += dy[d];
            field[x][y] = true;
        }

        for(int i=m-1; 0 <= i; i--){
            for(int j=0; j < m; j++){
                cout << (field[i][j] ? "#" : " ");
            }
            cout << endl;
        }
    }
}

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



int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = ((n+x-1)/x)*t;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3552
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop();

int top,kinbo[1000];

int main()
{
  int chonda,yamagami;
  top = 0;
  char null[100];

  while(scanf("%s",null) != EOF)
    {
      if(null[0] == '+')
	{
	  chonda = pop();
	  yamagami = pop();
	  push(chonda + yamagami);
	}
      else if(null[0] == '-')
	{
	    yamagami = pop();
	    chonda = pop();
	    push(chonda - yamagami);
	}
      else if(null[0] == '*')
	{
	   chonda = pop();
	   yamagami = pop();
	   push(chonda * yamagami);
	}
      else
	push(atoi(null));
    }

  printf("%d\n",pop());

  return 0;
}

void push(int chonda)
{
  kinbo[++top] = chonda;
}

int pop()
{
  top--;
  return kinbo[top + 1];
}



Measured memory_bytes: 2096
#include <iostream>

using namespace std;

int gcd(int n, int m) {
  if (m == 0) return n;
  if (n < m) return gcd(m, n);
  
  return gcd(m, n%m);
}

int main()
{
  int n;
  cin >> n;
  int a[101000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int r = a[0];
  for (int i = 1; i < n; i++)
    r = gcd(r, a[i]);
  
  cout << r << endl;
  
  
  return 0;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long n,m;
	cin>>n>>m;
	vector<long long> yakusu;

	for(long long i=1;i*i<=m;i++){
		if(m%i==0){
			yakusu.push_back(i);
			yakusu.push_back(m/i);
		}
	}

	sort(yakusu.begin(),yakusu.end());
	reverse(yakusu.begin(),yakusu.end());

	for(auto a:yakusu){
		if(m/a>=n){
			cout<<a<<endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

const lines = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line)
});
reader.on('close', () => {
  const first = lines[0].split(' ');
  const second = lines[1].split(' ');
  const secondNumber = second.map( str => parseInt(str, 10));
  secondNumber.sort(compareFunc);
  const sumCount = sum(secondNumber)  
  if(secondNumber[Number(first[1])-1] < (sumCount / (4 * Number(first[1])))){
    console.log('No')
  }else{
    console.log('Yes')
  }
});

function compareFunc(a, b) {
  return b - a;
}

function sum(arr) {
  return arr.reduce(function(prev, current) {
    return prev + current;
  });
};

Measured memory_bytes: 7756
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,x) for(int i=0;i<x;++i)
 
int main()
{
    vector<char> S;
    string s;cin>>s;
    rep(i,s.size()){
        char c=s[i];
        if (c=='B'){if(S.size())S.pop_back();}
        else S.push_back(c);
    }
    rep(i,S.size())cout<<S[i];
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
 
  int sum = 0;
  int X;
  int i = 0;
   
  while (i < M) {
    cin >> X;
    sum += X;
    i++;
  }
  
  if (sum <= N) {
    cout << N-sum << endl;
  }
  
  else if (sum > N) {
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3640
while str = $stdin.gets
  a, b, c  = str.strip.split(' ')
  a = a.to_i
  b = b.to_i
  c = c.to_i
  if a < b && b < c
    puts 'Yes'
  else
    puts 'No'
  end
#  if a > b
#    puts 'a > b'
#  elsif a < b
#    puts 'a < b'
#  else
#    puts 'a == b'
#  end
end

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

using ll = long long;
#define sz(x) ((int)x.size())
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int n,m,k;
string c[20],C[20];

int ok(){
	int cnt=0;
	for(int i=0;i<n;++i)for(int j=0;j<m;++j)cnt+=(C[i][j]=='#'?1:0);
	return (cnt==k?1:0);
}

void paint(int mask){
	for(int i=0;i<n;++i){
		C[i]=c[i];
		for(int j=0;j<m;++j){
			if(mask&(1<<i))C[i][j]='.';
			if(mask&(1<<(n+j)))C[i][j]='.';
		}
	}
}

int main() {
	fastio();
	cin>>n>>m>>k;
	for(int i=0;i<n;++i)cin>>c[i];
	int cnt=0;
	for(int mask=0;mask<(1<<(n+m));++mask){
		paint(mask);
		cnt+=ok();
	}
	cout<<cnt<<endl;
}


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


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


  map<string,int>memo;
  rep(i,n){
    string s;
    cin>>s;
    memo[s]++;
  }
  cout<<memo.size()<<endl;
  
  
}







Measured memory_bytes: 19224
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  int m,f,r;
  int i;

  for(i=0;;i++){
    cin >> m >> f >> r;
    if(m+f+r==-3)break;

    if(m==-1 || f==-1)cout << 'F' << endl;
    else if(m+f>=80)cout << 'A' << endl;
    else if(m+f>=65)cout << 'B' << endl;
    else if(m+f>=50)cout << 'C' << endl;
    else if(m+f>=30 && r>=50)cout << 'C' << endl;
    else if(m+f>=30)cout << 'D' << endl;
    else cout << 'F' << endl;
  }

    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;
double round(double value);

int main(){
  double a,b,c,d,e,f;
  vector<double> al,bl,cl,dl,el,fl;
  double x,y,n,m;

  while(cin >> a >> b >> c >> d >> e >> f){
    al.push_back(a);
    bl.push_back(b);
    cl.push_back(c);
    dl.push_back(d);
    el.push_back(e);
    fl.push_back(f);
  }

  for(int i=0; i<al.size(); i++){
    /*
    n = bl[i]/el[i];
    m = al[i]/dl[i];
    x = (cl[i]-n*fl[i])/(al[i]-n*dl[i]); 
    y = (cl[i]-m*fl[i])/(bl[i]-m*el[i]);
    */
    y = (cl[i]*dl[i]-al[i]*fl[i])/(bl[i]*dl[i]-el[i]*al[i]);
    x = (cl[i] - ( bl[i] * y)) /al[i];
    printf("%0.3f %0.3f\n", x,y);
  }

  return 0;
}


double round(double value){
  return floor(value*1000 + 0.5)/1000;
}

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

std::string s;
std::vector<char> s1,s2,s3;
void input()
{
    std::cin>>s;
    s1.resize(s.size());
    s2.resize(s.size());
    s3.resize(s.size());
    for(int i=0;i<(int)s.size();i++)s1[i] = s[i];
    s2 = s1;
    // 1010101010---の配列を作る
    for(int i=0;i<(int)s.size();i++){
        if(i%2)s3[i] = '1';
        else s3[i] = '0';
    }
}

int main()
{
    input();
    int cnt1=0,cnt2=0; 
    //奇数なら黒偶数なら白
    for(int i=0;i<(int)s1.size();i++){
        if(s1[i]==s3[i])cnt1++;
        if(s2[i]!=s3[i])cnt2++;
    }
    std::cout<<std::min(cnt1,cnt2)<<std::endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		for(int i=1;i<=n;i++){
			BigInteger a=in.nextBigInteger();
			BigInteger b=in.nextBigInteger();
			String ans=a.add(b).toString();
			if(ans.length()>80)System.out.println("overflow");
			else System.out.println(ans);
		}
		in.close();
	}
}

Measured memory_bytes: 26440
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
seq = [i+1 for i in range(n)]
a = 0
b = 0
from itertools import permutations
per = list(permutations(seq,n))
for i in range(len(per)):
    if per[i] == p:
        a = i
    if per[i] == q:
        b = i
print(abs(a-b))

Measured memory_bytes: 8052
N, M, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)
A.sort()
cnt = 0
R = 0
for a, b in A:
    if R <= a:
        cnt += 1
        R = b
    elif b < R:
        R = b
print(cnt)


Measured memory_bytes: 31720
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  int N;
  cin>>N;
  multiset<int>A;
  rep(i,N){
    int a;
    cin>>a;
    if(A.find(a)!=A.end()){
      A.erase(a);
    }else{
      A.insert(a);
    }
  }
  cout<<A.size()<<endl;
}

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

int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}

for(int i=n-1;i>0;i--){
cout<<a[i]<<" ";
}
cout<<a[0]<<endl;
}

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

void a();
void b();
void c();
void d();
void e();
void f();

int main() {
	a();
	return 0;
}

void a() {
	int A, B;
	std::cin >> A >> B;
	std::cout << std::max({A + B, A - B, A * B}) << std::endl;
}

Measured memory_bytes: 888