akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int r = GetInputInt();

        Console.WriteLine(3 * (r *r));

    }

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<(int) (n);i++)
using namespace std;
int main(){
  int64_t n,c=0;
  cin >> n;
  rep(i, n+1){
    int64_t y=n/i;
    c+=(y*(y+1)*i)/2;
  }
  cout << c << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


inline li calc(string& s) {
    //cerr << s << endl;
    li num_open = 0;
    li res = 0;
    rep(i, sz(s)) {
        if (s[i] == '(') {
            num_open++;
        } else {
            res += num_open;
        }
    }
    return res;
}

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

    if (sz(s) < 3) {
        puts("0");
        return 0;
    }
    vector<string> ss;
    string ts = "";
    rep(i, sz(s)) {
        if (s[i] == 'A') {
            ts = ts + "(";
        } else if (i < sz(s) - 1 && s.substr(i, 2) == "BC") {
            ts = ts + ")";
            i++;
        } else {
            if (!ts.empty()) {
                ss.pb(ts);
                ts = "";
            }
        }
    }
    if (!ts.empty()) {
        ss.pb(ts);
    }

    li res = 0;
    for (auto && sss : ss) {
        res += calc(sss);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;

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

    for(int i = 0; i < N - 1; i++){
      int min = i;
      for(int j = i; j <= N - 1; j++){
        if(nums[min] > nums[j]){
          min = j;
        }
      }
      if(min != i){
        int dum = nums[min];
        nums[min] = nums[i];
        nums[i] = dum;
        counter++;
      }
    }

    for(int i = 0; i < N-1; i++){
      System.out.print(nums[i] + " ");
    }
    System.out.println(nums[N-1]);
    System.out.println(counter);
  }

}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int in;cin>>in;
    int a = in/1000,b=in/100%10,c=in/10%10,d=in%10;

    int tb,tc,td;
    int i;

    for(int i = 0;i<(1<<3);i++)
    {
        tb = ((i >> 2) % 2 ? 1 : -1) * b;
        tc = ((i >> 1) % 2 ? 1 : -1) * c;
        td = ((i >> 0) % 2 ? 1 : -1) * d;
        
        if(a+tb+tc+td==7)
        {
            cout << a
                 << (tb > 0 ? "+" : "-") << b
                 << (tc > 0 ? "+" : "-") << c
                 << (td > 0 ? "+" : "-") << d
                 << "=7" << endl;
            break;
        }
    }

    return 0;
}

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

int main(){
  int R;
  cin >>R;
  if(R<1200){
    cout << "ABC" <<endl;
  }
  else if(R>=1200 && R<2800){
    cout << "ARC" <<endl;
  }
  else{
    cout << "AGC" <<endl;
  }
}


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

int main () {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long res = a*c;
	res = max(res, a*d);
	res = max(res, b*c);
	res = max(res, b*d);
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3628
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
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;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    sort(h.begin(), h.end());

    int l = 0;
    ll ans = INF;
    for(int r = k - 1; r < n; r++){
        ans = min(ans, h[r] - h[l]);
        l++;
    }

    cout << ans << endl;
}

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

using namespace std;

using Graph = vector<vector<int>>;

// 二部グラフ判定
vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
  color[v] = cur;
  for (auto next_v : G[v]) {
    // 隣接頂点がすでに色確定していた場合
    if (color[next_v] != -1) {
      if (color[next_v] == cur) return false;  // 同じ色が隣接したらダメ
      continue;
    }

    // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
    if (!dfs(G, next_v, 1 - cur)) return false;
  }
  return true;
}

int main() {
  long long N, M;
  cin >> N >> M;
  Graph G(N);
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  color.assign(N, -1);
  if (dfs(G, 0)) {
    long long b = 0, w = 0;
    for (int i = 0; i < N; i++) {
      if (color[i])
        b++;
      else
        w++;
    }
    cout << b * w - M << endl;
  } else {
    cout << N * (N - 1) / 2 - M << endl;
  }

  return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/18/20
 */
public class Main {

    private int N;
    private Node root;

    class Node {
        long val;
        Node left;
        Node right;

        public Node (long val) {
            this.val = val;
            this.left = null;
            this.right = null;
        }
    }

    private void inOrder(Node root, StringBuilder sb) {
        if (root == null) return;

        if (root.left != null) {
            inOrder(root.left, sb);
            sb.append(" ");
        }

        sb.append(root.val);

        if (root.right != null) {
            sb.append(" ");
            inOrder(root.right, sb);
        }
    }

    private void preOrder(Node root, StringBuilder sb) {
        if (root == null) return;

        sb.append(root.val);
        if (root.left != null) {
            sb.append(" ");
            preOrder(root.left, sb);
        }
        if (root.right != null) {
            sb.append(" ");
            preOrder(root.right, sb);
        }
    }

    public Main(Scanner sc) {
        N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            String str = sc.next();
            if (str.equals("insert")) {
                long val = sc.nextLong();
                Node currNode = new Node(val);
                if (root == null) {
                    root = currNode;
                } else {
                    Node tmp = root;
                    while (true) {
                        if (currNode.val < tmp.val) {
                            if (tmp.left != null) {
                                tmp = tmp.left;
                            } else {
                                tmp.left = currNode;
                                break;
                            }
                        } else {
                            if (tmp.right != null) {
                                tmp = tmp.right;
                            } else {
                                tmp.right = currNode;
                                break;
                            }
                        }
                    }
                }
            } else if (str.equals("print")) {
                StringBuilder sb = new StringBuilder();
                inOrder(root, sb);
                System.out.println(" " + sb.toString());
                sb.setLength(0);
                preOrder(root, sb);
                System.out.println(" " + sb.toString());
            }
        }
    }

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


Measured memory_bytes: 191408
n=int(input())
ans=0
for i in range(n):
    ans+= (i+1)*(n-i)
for j in range(n-1):
    u,v= map(int,input().split(' '))
    if u<=v:
        ans-= u*(n-v+1)
    else:
        ans-= v*(n-u+1)
print(ans)


Measured memory_bytes: 9200
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> s(N), d(N);
	for (int i = 0; i < N; ++i) {
		int x, y; cin >> x >> y;
		s[i] = x + y;
		d[i] = x - y;
	}
	sort(s.begin(), s.end());
	sort(d.begin(), d.end());
	int res = max(s[N - 1] - s[0], d[N - 1] - d[0]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4828
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;

int main()
{
	int n;
	int a, b;
	cin >> n;
	if (n == 1) {
		cout<<"Hello World"<<endl;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,ans=0,tmp;
  vector<int> a1(n),a2(n);
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a1[i];
  }
  for(i=0;i<n;i++){
    cin>>a2[i];
  }
  
  for(i=0;i<n;i++){
	tmp=0;
    for(j=0;j<n;j++){
		if(j<i){
          tmp+=a1[j];
        }else if(j>i){
		  tmp+=a2[j];
        }else{
          tmp+=a1[j]+a2[j];
        }
    }
    if(ans<tmp){
		ans=tmp;
    }
  }
  
  cout<<ans<<endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);
  string out;

  for (auto e : s) {
    if (e == '0' || e == '1') out.push_back(e);
    if (e == 'B')
      if (sz(out)) out.pop_back();
  }

  puts(out.c_str());

  return 0;
}

Measured memory_bytes: 256
N = int(input())
Blist = [int(i) for i in input().split()]

Alist = [0 for i in range(N)]
for i in range(N):
    if i == 0:
        A_left = 1000000
    else:
        A_left = Blist[i-1]
    if i == N-1:
        A_right = 1000000
    else:
        A_right = Blist[i]
    Alist[i] = min(A_left,A_right)
#print(Alist)
print(sum(Alist))

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N, T, E;
	cin >> N >> T >> E;
	
	for_(i,0,N) {
		int x;
		cin >> x;
		int X = x;
		
		while (X <= T + E) {
			if (T - E <= X && X <= T + E) {
				cout << i + 1 << endl;
				return 0;
			}
			
			X += x;
		}
	}
	
	cout << -1 << endl;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] arr = new long[n + 1];
		for (int i = 1; i <= n; i++) {
		    arr[i] = arr[i - 1] + sc.nextInt();
		}
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
		for (int i = 0; i <= n; i++) {
		    arr[i] = (arr[i] - i + k) % k;
		    int key = (int)arr[i];
		    ArrayList<Integer> list;
		    if (map.containsKey(key)) {
		        map.get(key).add(i);
		    } else {
		        list = new ArrayList<Integer>();
		        list.add(i);
		        map.put(key, list);
		    }
		}
		long count = 0;
		for (ArrayList<Integer> list : map.values()) {
		    int left = 0;
		    int right = 0;
		    for (; left < list.size(); left++) {
		        int leftIdx = list.get(left);
		        while (right + 1 < list.size() && list.get(right + 1) - leftIdx < k) {
		            right++;
		        }
		        count += right - left;
		    }
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 130876
class Stack:
    def __init__(self):
        self.values = []
        self.n = 0

    def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

    def push(self,x):
        self.values.append(x)
        self.n += 1


operators = set(['+', '-', '*'])
stack = Stack()

for op in raw_input().split(' '):
    if op in operators:
        b = stack.pop()
        a = stack.pop()
        if op == '+':
            stack.push(a+b)
        elif op == '-':
            stack.push(a-b)
        elif op == '*':
            stack.push(a*b)
        else:
            raise Exception("Unkown operator")
    else:
        stack.push(int(op))

print stack.pop()

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

typedef long long lli;

const lli MOD = 1000000;
int n;
string str[1000];
vector<string> pat[4];

void init(){
  for(int i=0;i<4;i++) pat[i].clear();
  pat[0].push_back("0xxxxxxx");

  pat[1].push_back("110yyyyx");
  pat[1].push_back("10xxxxxx");

  pat[2].push_back("1110yyyy");
  pat[2].push_back("10yxxxxx");
  pat[2].push_back("10xxxxxx");

  pat[3].push_back("11110yyy");
  pat[3].push_back("10yyxxxx");
  pat[3].push_back("10xxxxxx");
  pat[3].push_back("10xxxxxx");
}

void solve(){
  lli dp[1001][4][4][8][2];
  for(int i=0;i<n;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) for(int l2=0;l2<8;l2++) for(int l=0;l<2;l++) dp[i][j][k][l2][l] = 0;

  for(int i=0;i<n;i++){
    for(int j=0;j<4;j++){
      if(pat[j][0][0] == '1' && str[i][0] != '0' || pat[j][0][0] == '0' && str[i][0] != '1'){
        int pos = pat[j][0][0] == '0';
        if(i == 0) dp[i][j][0][0][pos] = 1;
        else{
          for(int k=0;k<4;k++) dp[i][j][0][0][pos] = (dp[i][j][0][0][pos] + dp[i-1][k][k][7][1]) % MOD;

          for(int k=0;k<j;k++)
            for(int l=0;l<2;l++)
              dp[i][j][k+1][0][l] = (dp[i][j][k+1][0][l] + dp[i-1][j][k][7][l]) % MOD;
        }
      }
    }

    for(int j=0;j<4;j++){
      for(int k=0;k<=j;k++){
        for(int l=1;l<8;l++){
          for(int l2=0;l2<2;l2++){
            if(pat[j][k][l] == '1' && str[i][l] != '0' || pat[j][k][l] == '0' && str[i][l] != '1') dp[i][j][k][l][l2] = (dp[i][j][k][l][l2] + dp[i][j][k][l-1][l2]) % MOD;
            if(pat[j][k][l] == 'y'){
              if(str[i][l] == '0' || str[i][l] == 'x') dp[i][j][k][l][l2] = (dp[i][j][k][l][l2] + dp[i][j][k][l-1][l2]) % MOD;
              if(str[i][l] == '1' || str[i][l] == 'x') dp[i][j][k][l][1] = (dp[i][j][k][l][1] + dp[i][j][k][l-1][l2]) % MOD;
            }
            if(pat[j][k][l] == 'x'){
              if(str[i][l] == 'x') dp[i][j][k][l][l2] = (dp[i][j][k][l][l2] + dp[i][j][k][l-1][l2] * 2) % MOD;
              else dp[i][j][k][l][l2] = (dp[i][j][k][l][l2] + dp[i][j][k][l-1][l2]) % MOD;
            }
          }
        }
      }
    }
  }

  lli ans = 0;
  for(int i=0;i<4;i++) ans = (ans + dp[n-1][i][i][7][1]) % MOD;
  cout << ans << endl;

}

int main(){
  init();
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> str[i];
    solve();
  }
}

Measured memory_bytes: 3268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(A + B / 2);
	}
	int A,B;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

int SumOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void){
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for(int i = 1; i <= N; ++i){
    int sum = SumOfDigits(i);
    if(sum >= A && sum <= B){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())

members_p = list(k-q for _ in range(n))
a_list = []

for _ in range(q):
  a_list.append(int(input()))
  
for i in range(q):
  target_index = a_list[i]-1
  members_p[target_index] += 1

res = ['Yes' if member > 0 else 'No' for member in members_p]  
  
print(*res, sep = '\n')

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

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

    static class DKnight {
        static int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            int y = in.nextInt();
            long res = 0;
            if ((x + y) % 3 != 0) {
                // res == 0
            } else {
                int el = (x + y) / 3;
                x -= el;
                y -= el;
                if (x >= 0 && y >= 0) {
                    res = ((
                            (modfact(x + y) * modinv(modfact(x))) % MOD)
                            * modinv(modfact(y))) % MOD;
                }
            }
            out.println(res);
        }

        public static long modfact(long n) {
            long res = 1;
            for (int i = 1; i <= n; i++) {
                res = (res * i) % MOD;
            }
            return res;
        }

        public static long modinv(long n) {
            return modpow(n, MOD - 2);
        }

        public static long modpow(long n, long a) {
            long res = 1;
            while (a != 0) {
                if (a % 2 == 1) {
                    res = n * res % MOD;
                }
                a /= 2;
                n = (n * n) % MOD;
            }
            return (int) res;
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	double l;
	cin >> l;
	l /= 3;
	cout << fixed << setprecision(16);
	cout << l * l * l << endl;
} 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to, cor; };
vector<int>G[114514];
double p[3000];
double dp[3001][3001];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> p[i];
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, n+1) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}
	double ans = 0;
	for (int i = n / 2 + 1; i <= n; i++)ans += dp[n][i];
	printf("%.13lf\n", ans);
}

Measured memory_bytes: 73344
// ABC177-B 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    string s,t;
    cin>>s>>t;
    int s_l=s.size(),t_l=t.size(),ans=s_l;
    for(int i=0;i<=s_l-t_l;i++){
        int now=0;
        for(int j=i;j<=i+t_l-1;j++){
            if(s[j]!=t[j-i]) now++;
        }
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
A = list(map(int, input().split()))

count = 0

inf = 999999999999999999

def mergeSort(left, right):
  if right - left <= 1:
    return A[left:right]
  mid = (left + right) // 2
  return merge(mergeSort(left, mid), mergeSort(mid, right))

def merge(left, right):
  global count
  result = []
  
  left.append(inf)
  right.append(inf)
  left_i = 0
  right_i = 0
  while True:
    if right[right_i] == inf:
      result.extend(left[left_i:-1])
      count += len(left[left_i:-1])
      break
    if left[left_i] == inf:
      result.extend(right[right_i:-1])
      count += len(right[right_i:-1])
      break

    if left[left_i] < right[right_i]:
      result.append(left[left_i])
      left_i += 1
    else:
      result.append(right[right_i])
      right_i += 1
    count += 1
  return result

print(*mergeSort(0, n))
print(count)


Measured memory_bytes: 61648
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

//abbabbababaaaajjjakaakbbbbbkk
//aaaaaaaaaaaaaaaaaaaaabbbbbbkk

char com(char c){
    if(c=='r')return 'p';
    if(c=='p')return 's';
    if(c=='s')return 'r';
}

signed main(){
    FASTER;
    int n,k;cin>>n>>k;
    int r,s,p;cin>>r>>s>>p;
    map<char,int> cst;
    cst['r']=r;
    cst['s']=s;
    cst['p']=p;
    vector<char> v[k];
    for(int i=0;i<n;i++){
        char c;cin>>c;
        v[i%k].push_back(c);
    }
    
    int ans=0;
    for(int i=0;i<k;i++){
        
        for(int j=0;j<v[i].size();j++){
            int cnt=1;
            char c=v[i][j];
            while(j+1<v[i].size() && v[i][j]==v[i][j+1])cnt++,j++;
            ans+=ceil(cnt,2)*cst[com(c)];
        }
        
    }
    cout<<ans;
}


Measured memory_bytes: 8368
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    vector<vector<char>> tmp(h, vector<char>(w));
    for(int i = 0; i< h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j]; 
        }
    }
    int ans = 0;
    for(int bith = 0; bith < (1<<h); bith++){
        for(int bitw = 0; bitw < (1<<w); bitw++){
        tmp = c;
        
        for(int i = 0; i < h; i++){

            if(bith & (1 << i)){
                for(int a = 0; a < w; a++){
                    tmp[i][a] = 'r';
                }
            }
        }

            
                for(int j = 0; j < w; j++){
                    if(bitw & (1 << j)){
                        for(int a = 0; a < h; a++){
                            tmp[a][j] = 'r';
                        }
                    }
                    
                }
                int num = 0;
                    for(int l = 0; l< h; l++){
                        for(int b = 0; b < w; b++){
                            
                            //cout << tmp[l][b];
                            if(tmp[l][b] == '#') num++; 
                        }
                    }
                    //cout << endl
                    //cout << "--" << endl;
                    
                    if(num == k) ans++;
            }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
A[4][3][10],N,i,j,k,t;
main(void){
    for(scanf("%d",&N);N--;){
        scanf("%d%d%d%d",&i,&j,&k,&t);
        A[i-1][j-1][k-1]+=t;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d%s",A[i][j][k],k==9?"\n":"");
            }
        }
        if(i!=3)
        puts("####################");
    }
}

Measured memory_bytes: 1808
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int sum = 0;
	rep(i, 10){
		int x;
		cin>>x;
		sum +=x;
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 1164
import copy


def dfs(A):
    global ans
    if len(A) == N:
        score = 0
        for a, b, c, d in buff:
            if A[b - 1] - A[a - 1] == c:
                score += d
        ans = max(ans, score)
        return

    A.append(A[-1])
    while A[-1] <= M:
        dfs(copy.copy(A))
        A[-1] += 1


N, M, Q = map(int, input().split())
buff = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
dfs([1])
print(ans)


Measured memory_bytes: 9180
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=time(0);
	return seed^=seed<<13,seed^=seed>>7,seed^=seed<<17;
}
const int N = 404000;
int n,fa[N],v[N],f[N],cnt0[N],cnt1[N];
inline int find(int x) {return x==f[x]?x:f[x]=find(f[x]);}
inline void merge(int x, int y) {
	x=find(x);y=find(y);
	if (x!=y) f[x]=y,cnt0[y]+=cnt0[x],cnt1[y]+=cnt1[x];
}
struct node {
	int cnt1,cnt0,u; //top vertex
	node(int a=0, int b=0, int c=0) {cnt1=a; cnt0=b; u=c;}
	bool operator < (const node &x) const {
		return 1LL*cnt1*x.cnt0!=1LL*cnt0*x.cnt1?1LL*cnt1*x.cnt0<1LL*cnt0*x.cnt1:u<x.u;
	}
};
set<node> Set;
int main() {
	read(n);rep(i,2,n)read(fa[i]);rep(i,1,n)read(v[i]);
	rep(i,1,n) f[i]=i,cnt1[i]=v[i]==1,cnt0[i]=v[i]==0;
	rep(i,2,n) Set.insert(node(v[i]==1,v[i]==0,i));
	ll ans=0;
	per(t,n-1,1) {
		node u=*Set.begin(); Set.erase(Set.begin());
	//	if (!fa[u.u]) continue;
		int v=find(fa[u.u]);
		ans+=1LL*cnt1[v]*cnt0[u.u];
	//	printf("merge %d %d\n",u.u,v);
		if (fa[v]) Set.erase(node(cnt1[v],cnt0[v],v));
		merge(u.u,v); if (fa[v]) Set.insert(node(cnt1[v],cnt0[v],v));
	}
	cout<<ans;
	return 0;
}


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

using namespace std;
mt19937_64 rng(58);

#define UNSET_RIGHTMOST_BIT(n)  (n &= n - 1)

// sum the first n elements of original array (0 to n-1)
template <typename T>
T fenwick_prefix_sum(T* f, int n) {
  T sum = 0;
  for (; n > 0; UNSET_RIGHTMOST_BIT(n)) sum += f[n - 1];
  return sum;
}

// sum in [begin, end)
template <typename T>
T fenwick_range_sum(T* f, int begin, int end) {
  return fenwick_prefix_sum(f, end) - fenwick_prefix_sum(f, begin);
}

// update the fenwick tree for A[idx] += val, A.length = f_size
template <typename T>
void fenwick_inc_point(T* f, int f_size, int idx, T val) {
  for (; idx < f_size; idx |= (idx + 1)) f[idx] += val;
}

// Point Update, Range Query
template <typename T>
struct Fenwick {
  vector<T> ft;
  Fenwick(int sz): ft(sz, 0) {}
  T sum(int n) { T sum = 0; for (; n > 0; n &= n - 1) sum += ft[n - 1]; return sum; } // sum of [0, n) (not including n)
  T sum(int begin, int end) { return sum(end) - sum(begin); } // sum of [begin, end) (not including end)
  void inc(int idx, T val) { for (; idx < ft.size(); idx |= (idx + 1)) ft[idx] += val; }
  T at(int idx) { return sum(idx, idx + 1); }
  void set(int idx, T val) { inc(idx, val - at(idx)); }
};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, q;
    cin >> n >> q;
    vector<int> color(n);

    for (int i=0; i<n; i++)
        cin >> color[i];

    vector<tuple<int, int, int>> queries(q);
    for (int i=0; i<q; i++) {
        int l, r;
        cin >> l >> r;
        queries[i] = {r-1, l-1, i};
    }
    sort(queries.begin(), queries.end());
    vector<int> ans(q);

    Fenwick<int> ft(n);
    vector<int> last(500000 + 1, -1);
    int idx = 0;
    for (int i=0; i<n; i++) {
        int c = color[i];
        if (last[c] >= 0) ft.set(last[c], 0);
        last[c] = i;
        ft.set(i, 1);
        for (; idx<q && get<0>(queries[idx]) == i; idx++) {
            int r = get<0>(queries[idx]);
            int l = get<1>(queries[idx]);
            int o = get<2>(queries[idx]);
            ans[o] = ft.sum(l, r + 1);
        }
    }
    for (auto a : ans) cout << a << endl;
}

Measured memory_bytes: 17400
for i in range(10**8):
    n,x = map(int,input().split())
    if n==0 and x==0:
        exit()
    cou = 0
    for j in range(1,n-1):
        for t in range(j+1,n):
            for p in range(t+1,n+1):
                if j+t+p==x:
                    cou += 1
    print(cou)


Measured memory_bytes: 5592
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    float x,y;
    cin>>x>>y;
    int cnt=x+y+2;
    for (int i=0; i<=x; i++) {
        float a=y/(x*2)*(2*i);
        if(fmod(a, 1)==0){
            cnt--;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3344
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    let K:usize = sc.read();
    let A:Vec<usize> = sc.vec(N);
    let mut dp = vec![vec![true;2];K+1];
    for i in 0..A[0]{
        dp[i][0] = false;
        dp[i][1] = true;
    }
    for k in A[0]..(K+1){
        let mut win = false;
        for i in 0..(A.len()){
            let a = A[i];
            if a <= k{
                if dp[k-a][1]{
                    win = true;
                    break
                }
            }
        }
        dp[k][0] = win;
        win = true;
        for i in 0..(A.len()){
            let a = A[i];
            if a <= k{
                if !dp[k-a][0]{
                    win = false;
                    break
                }
            }
        }
        dp[k][1] = win;
    }
    if dp[K][0]{
        println!("First");
    }
    else{
        println!("Second");
    }

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 8444
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

ll binary_search(ll val, vector<ll> &v){
  ll left = -1, right = v.size();
  while(right - left > 1){
    ll mid = left + (right - left) / 2;
    if ( v[mid] >= val ) right = mid;
    else left = mid;
  }
  return right;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  
  ll ans = 0;
  rep(i, n){
    ll top = binary_search(b[i], a);
    ll under = n - binary_search(b[i]+1, c);
    ans += top * under;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2560
q = int(input())
s = []
rs = [] # for discretization

# download the input
for i in range(q):
    s.append(list(map(int, input().split())))
    if s[i][0] == 3:
        rs.append(s[i][1])
        rs.append(s[i][2])
    else:
        rs.append(s[i][1])

rs.append(10**9 + 1)
rs = sorted(list(set(rs)))
index = {rs[i]:i for i in range(len(rs))} # discretization
used = [False for i in range(len(rs) + 1)] # tag the elements in set
cnt = 0
for i in range(q):
    op, x = s[i][0], s[i][1]
    idx = index[x]
    if op == 0:
        if not used[idx]:
            cnt += 1
        used[idx] = True
        print(cnt)
    elif op == 1:
        print(+used[idx])
    elif op == 2:
        if used[idx]:
            cnt -= 1
        used[idx] = False
    else:
        l = idx
        r = index[s[i][2]]
        for j in range(l, r+1):
            if used[j]:
                print(rs[j])



Measured memory_bytes: 62688
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    t=[]
    for _ in range(n):
        t.append(ni())


    def lcm_base(x, y):
        return x * y // fractions.gcd(x, y)

    def lcm_list(numbers):
        return functools.reduce(lcm_base, numbers, 1)

    print(lcm_list(t))


if __name__ == '__main__':
    main()


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

int main() {
	ll n,m;
	cin >> n >> m;
	ll ans = 0;
	if (n==1 && m==1) ans = 1;
	else if (n==1 && m>=2) ans = m-2;
	else if (n>=2 && m==1) ans = n-2;
	else ans = (n-2)*(m-2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)
k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(a,k+1):
    for c in range(b,k+1):
      d = gcd(a, b)
      if len({a,b,c}) == 1:
        ans += gcd(c, d)
      elif len({a,b,c}) == 2:
        ans += 3*gcd(c, d)
      else:
        ans += 6*gcd(c, d)
print(ans)

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

bool check(int start, const vector<string> &words) {
	const array<int, 5> num{{5, 7, 5, 7, 7}};

	int idx = 0;
	int sum = 0;
	for(int i = start; i < words.size(); ++i) {
		sum += words[i].size();

		if(sum == num[idx]) {
			if(++idx == 5) return true;
			sum = 0;
		}
		else if(sum > num[idx]) {
			return false;
		}
	}
	return false;
}

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

	for(int n; cin >> n && n;) {
		vector<string> words(n);
		for(auto &e : words) cin >> e;

		for(int i = 0; i < n; ++i) {
			if(check(i, words)) {
				cout << i + 1 << endl;
				break;
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3156
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	total := 0
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		total += a[i]
	}
	border := total / m / 4
	modB := total%m == 0 && total%4 == 0
	ok := 0
	for i := 0; i < n; i++ {
		if modB {
			if a[i] >= border {
				ok++
			}
		} else {
			if a[i] > border {
				ok++
			}
		}

	}
	if ok >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

int H,W;
  cin >> H>> W;
  vector<vector<char>> a(H, vector<char>(W));
  
  for (int i=0;i<H;i++){
    for (int j=0; j<W;j++){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<bool> gyo(H,0);
  for (int i=0;i<H;i++){
    for (int j=0; j<W;j++){
        if(a.at(i).at(j)=='#') gyo.at(i)=1;
    }
  }
  
  vector<bool> retu(W,0);
  for (int j=0;j<W;j++){
    for (int i=0; i<H;i++){
        if(a.at(i).at(j)=='#') retu.at(j)=1;
    }
  }
  
   for (int i=0;i<H;i++){
    if (gyo.at(i)==1){
        for (int j=0; j<W;j++){
         if (retu.at(j)==1){
         cout << a.at(i).at(j);
         }
        }
        cout <<endl;
    }
   }
	
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin()+1, (a).end()
#define mod 2019
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  vi changed, ans(n);
  rep(i, n - 1){
    if(s[i] == 'R' && s[i + 1] == 'L'){
      changed.push_back(i);
      ans[i]++;
      ans[i + 1]++;
    }
  }
  changed.push_back(n);
  int before = 0;
  for(int i : changed){
    for(int j = before; j < i; j++){
      if(s[j] == 'L'){
        if((j - before) & 1){
          ans[before - 1]++;
        }else ans[before - 2]++;
      }else{
        if((i - j) & 1){
          ans[i + 1]++;
        }else ans[i]++;
      }
    }
    before = i + 2;
  }
  rep(i, n - 1) cout << ans[i] << " ";
  cout << ans[n - 1] << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

lli a, b, n;

lli evaluate(lli x)
{
  x = min(n, x / b * b + b - 1);
  return (a*x)/b - a*(x/b);
}
lli ternarySearch(lli lo = 0, lli hi = n)
{
  while (lo < hi - 3)
  {
    lli midlo = (2*lo + hi) / 3, midhi = (lo + 2*hi) / 3;
    lli elo = evaluate(midlo), ehi = evaluate(midhi);
    if (elo > ehi) hi = midhi;
    else if (ehi > elo) lo = midlo;
    else lo = midlo, hi = midhi;
  }
  lli ans = evaluate(lo++);
  while (lo <= hi) ans = max(ans, evaluate(lo++));
  return ans;
}

int main()
{
  while (scanf("%lld %lld %lld", &a, &b, &n) != EOF)
    printf("%lld\n", ternarySearch());
  return 0;
}

Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r=scan.nextInt();
		int d=scan.nextInt();
		int x=scan.nextInt();
		scan.close();
		func(r,d,x,1);
	}

	private static void func(int r, int d, int x,int cnt) {
		int ans = r*x-d;
		System.out.println(ans);
		if(cnt<10)func(r,d,ans,cnt+=1);
	}
}

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

s = input()
t = input()

s1 = list(s)
t1 = list(t)

s1.sort()
t1.sort(reverse=True)

# print(s1,t1)

ans = 0

for i in range(min(len(s), len(t))):
    if s1[i] < t1[i]:
        ans += 1
if len(s) < len(t) and s1[:len(s)] == t1[:len(s)]:
    ans += 100000000

print('Yes' if ans >= 1 else 'No')

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

def dis(P1,P2):
  ans=0
  for i in range(len(P1)):
    ans+=(P1[i]-P2[i])**2
  ans=ans**0.5
  return ans

cnt=0
for i in range(n):
  for j in range(i+1,n):
    if dis(P[i],P[j])%1==0:
      cnt+=1
print(cnt)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void)
{
	double height,max=0.0,min=10000.0;//エベレスト8844.43

	while(scanf("%lf",&height)!=EOF){
		if(height>=max)
			max=height;
		if(height<=min)
			min=height;
	}
	printf("%f.1",max-min);

	return 0;
}

Measured memory_bytes: 648
from __future__ import print_function
from sys import stdin
class Node:
    def __init__(self, id):
        self.id = id
        self.left = None
        self.right = None
        self.parent = None

def preorder_tree_walk(root):
    print('', root.id, end='')
    if root.left != None:
        preorder_tree_walk(root.left)
    if root.right != None:
        preorder_tree_walk(root.right)

def inorder_tree_walk(root):
    if root.left != None:
        inorder_tree_walk(root.left)
    print('', root.id, end='')
    if root.right != None:
        inorder_tree_walk(root.right)

def insert(root, z):
    y = None
    x = root
    while isinstance(x, Node):
        y = x
        if z.id < x.id:
            x = x.left
        else:
            x = x.right
    z.parent = y

    if y == None:
        root = z
    elif z.id < y.id:
        y.left = z
    else:
        y.right = z
    return root

n = int(raw_input())
root = None
for i in xrange(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        num = int(cmd[7:])
        root = insert(root, Node(num))
    else:
        inorder_tree_walk(root)
        print()
        preorder_tree_walk(root)
        print()
    

Measured memory_bytes: 197084
def isPalindrome(s):
    for i in range(len(s) // 2):
        if s[i] != s[len(s) - i - 1]:
            return False
    return True


s = input()
N = len(s)

print("Yes" if isPalindrome(s) and isPalindrome(s[:(N - 1) // 2]) and isPalindrome(s[(N + 3) // 2 - 1:]) else "No")


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

const long long MOD = 998244353;

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

void solve(long long N, std::vector<long long> D) {
    vector<ll> distance(N);
    rep(i, N) {
        if ((i == 0 && D[i] != 0) || (i != 0 && D[i] == 0)) {
            cout << 0 << endl;
            return;
        }
        distance[D[i]]++;
    }
    ll ans = 1;
    for (ll i = 1; i < N; i++) {
        ans = ans * modpow(distance[i - 1], distance[i], MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> D(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &D[i]);
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 1792