akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=4000005;
int n,m,ne[N],S,cnt,T,id[105][105],tot,cur[N],fi[N],zz[N],sl[N],dis[N];
char s[105][105];
queue<int> Q;
void jb(int x,int y,int z){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
	sl[tot]=z;
	ne[++tot]=fi[y];
	fi[y]=tot;
	zz[tot]=x;
	sl[tot]=0;
}
int bfs(){
	Q.push(S);
	memset(dis,-1,sizeof dis);
	dis[S]=0;
	while (!Q.empty()){
		int now=Q.front();Q.pop();
		for (int i=fi[now];i;i=ne[i])
			if (sl[i]&&dis[zz[i]]==-1){
				dis[zz[i]]=dis[now]+1;
				Q.push(zz[i]);
			}
	}
	return dis[T]!=-1;
}
int dfs(int x,int y){
	if (x==T)return y;
	int b,s=0;
	for (int &i=cur[x];i;i=ne[i])
		if (sl[i]&&dis[zz[i]]==dis[x]+1&&(b=min(sl[i],dfs(zz[i],min(sl[i],y))))){
			sl[i]-=b;
			sl[i^1]+=b;
			y-=b;s+=b;
			if (!y)return s;
		}
	return s;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (s[i][j]=='o')id[i][j]=++cnt;
			else if (s[i][j]=='S'){
				id[i][j]=++cnt,S=id[i][j]*2-1;
				for (int k=1;k<=m;k++)
					if (s[i][k]=='T'){
						puts("-1");
						return 0;
					}
				for (int k=1;k<=n;k++)
					if (s[k][j]=='T'){
						puts("-1");
						return 0;
					}
			}
			else if (s[i][j]=='T')id[i][j]=++cnt,T=id[i][j]*2;
	tot=1;
	for (int i=1;i<=cnt;i++)
		if (i==(S+1)/2||i==(T+1)/2)jb(i*2-1,i*2,1e9);
		else jb(i*2-1,i*2,1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (id[i][j]){
				for (int k=1;k<=m;k++)
					if (j!=k&&id[i][k])jb(id[i][j]*2,id[i][k]*2-1,1);
				for (int k=1;k<=n;k++)
					if (k!=i&&id[k][j])jb(id[i][j]*2,id[k][j]*2-1,1);
			}
	int ans=0;
	while (bfs()){
		for (int i=1;i<=2*cnt;i++)cur[i]=fi[i];
		ans+=dfs(S,1e9);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 65408
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

typedef long long ll;
using namespace std;

string s;

int pot (ll q, ll w){
	ll qw = q;
	q = 1;
	for (int i = 0; i<w; i++)
		q*= qw;
	return q;
}

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

cin >> s;

ll c = s.length();

for (int i = 0; i<c; i++)
	cout << "x";




return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll h, w;
	cin >> h >> w;
	ll minv1 = h * w, minv2 = h * w;
	ll S = h * w;
	for (ll i = 1; i < h; ++i) {
		ll sa = i * w;
		ll sb1 = w / 2 * (h - i);
		ll sc1 = S-sa - sb1;
		minv1 = min(minv1, (max({ sa,sb1, sc1 }) - min({ sa,sb1,sc1 })));
		ll sb2 = (h - i) / 2 * w;
		ll sc2 = S-sa - sb2;
		minv1 = min(minv1, (max({ sa,sb2, sc2 }) - min({ sa,sb2,sc2 })));
	}
	for (ll i = 1; i < w; ++i) {
		ll sa = i * h;
		ll sb1 = h / 2 * (w - i);
		ll sc1 = S-sa - sb1;
		minv2 = min(minv2, (max({ sa,sb1, sc1 })- min({ sa,sb1,sc1 })));
		ll sb2 = (w - i) / 2 * h;
		ll sc2 = S-sa - sb2;
		minv2 = min(minv2, (max({ sa,sb2, sc2 }) - min({ sa,sb2,sc2 })));
	}
	cout << min(minv1,minv2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 100005
char s[maxn];
int n,ans;

int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    char tmp=s[1];
    for (int i=2;i<=n;i++)
        if (s[i]!=tmp) ans++,tmp=s[i];
    printf("%d\n",ans);
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a;
	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		a.pb(t);
	}

	if(n == 1){
		puts("1");
		return 0;
	}
	bool up;
	if(a[0] <= a[1]){
		up = true;
	}else{
		up = false;
	}

	int cnt = 1;
	for(int i=0; i<n-1; i++){
		if(up){
			if(a[i+1] < a[i]){
				int j = i+1;
				while(j < n && a[j] == a[i+1]) j++;
				if(j < n && a[j] < a[i+1]){
					up = false;
				}
				cnt++;
			}
		}else{
			if(a[i+1] > a[i]){
				int j = i+1;
				while(j < n && a[j] == a[i+1]) j++;
				if(j < n && a[j] > a[i+1]){
					up = true;
				}
				cnt++;
			}
		}
	}


	cout << cnt << endl;

	
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll c=max(a,b),d=min(a,b);
  ll r=c%d;
  while(r>0){
    c=d;
    d=r;
    r=c%d;
  }
  return d;
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>n;
  vi A(n);
  cin>>A[0];
  ll hoge=A[0];
  for(int i=1;i<n;i++){
    cin>>A[i];
    hoge=lcm(hoge,A[i]);
  }
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=hoge/A[i];
  }
  printf("%.10f\n",(double)hoge/(double)sum);
  return 0;
}


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

int main(){
    int h,w;
    cin>>h>>w;
    char c[h][w];
    int cnt=0; // 白の数
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            if(c[i][j]=='.') cnt++;
        }
    }
    int dp[h][w]={};
    int INF=1e9;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        dp[i][j]=INF;
    }
    dp[0][0]=0;
    int cc=0;
    while(cc<5){
        for(int i=0;i<h;i++)for(int j=0;j<w;j++){
            if(j!=w-1 && c[i][j+1]=='.') dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
            if(i!=h-1 && c[i+1][j]=='.') dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
            //cerr<<dp[i+1][j+1]<<endl;
        }
        for(int i=h-1;i>=0;i--)for(int j=w-1;j>=0;j--){
            if(j!=0 && c[i][j-1]=='.') dp[i][j-1]=min(dp[i][j-1],dp[i][j]+1);
            if(i!=0 && c[i-1][j]=='.') dp[i-1][j]=min(dp[i-1][j],dp[i][j]+1);
            //cerr<<dp[i-1][j-1]<<endl;
        }
        cc++;
    }
    dp[h-1][w-1]=min(dp[h-1][w-2]+1,dp[h-2][w-1]+1);
    if(dp[h-1][w-1]>5000) {
        cout<<-1<<endl;
        return 0;
    }
    int ans=cnt-dp[h-1][w-1]-1;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, x, i, min=0, mini, add;
  int mn[100003];

  scanf("%d %d", &n, &x);
  mini=x;
  for(i=0;i<n;i++){
    scanf("%d", &mn[i]);
    min=min+mn[i];
    if(mini>mn[i]){
      mini=mn[i];
    }
  }

  add=(x-min)/mini;
  printf("%d\n", n+add);

  return 0;
}


Measured memory_bytes: 128
/**
 * FindingMissingCards.cpp
 * Create:20180421
 * Description:トランプの不足カードを出力する。
 */
#include <iostream>
#include <array>

const int CARDS = 13;
const std::string CARD_SPADE = "S";
const std::string CARD_CLUB = "C";
const std::string CARD_HEART = "H";
const std::string CARD_DIAMOND = "D";

/**
 * カード情報クラス
 */
class Card {
private:
  std::string handle;
  int number;
  bool check;
public:
  /**
   * デフォルトコンストラクタ
   */
  Card(){
    this->handle = "";
    this->number = 0;
    check = false;
  }

  /**
   * コンストラクタ
   * @param handle 柄
   * @param number 数値
   */
  Card(const std::string &handle, int number){
    this->handle = handle;
    this->number = number;
    check = false;
  }

  /**
   * 同じものを見つけた場合　ステータスを変更する
   * @param  handle 柄
   * @param  number 番号
   */
  void set_check(const std::string &handle, int number){
    if (this->handle == handle && this->number == number) {
      check = true;
    }
  }

  /**
   * ゲった
   * @return 現在のステータス
   */
  bool get_check(){
    return check;
  }

  std::string to_string(){
    return handle + " " + std::to_string(number);
  }
};

int main(int argc, char* argv[]){
  // 本来存在するはずのカードのリストを作成する。
  std::array<Card, CARDS * 4> cards;
  std::string handles[] = {CARD_SPADE, CARD_HEART, CARD_CLUB, CARD_DIAMOND};

  for (int i = 0; i < 4; i++){
    for (int j = 0; j < CARDS; j++){
      cards[(j + 1) + (i * CARDS) - 1] = Card(handles[i], j + 1);
    }
  }

  // 情報を入力する
  int cardCount;
  std::string handle;
  int number;

  std::cin >> cardCount;

  for (int i = 0; i < cardCount; i++){
    std::cin >> handle >> number;
    for (int j = 0; j < CARDS * 4; j++){
      cards[j].set_check(handle, number);
    }
  }

  // 情報を出力する。
  for (Card c: cards){
    if (!c.get_check()){
      std::cout << c.to_string() << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3212
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    uf.union(a, b)

result =  0
for root in uf.roots():
    # print(uf.size(root))
    result = max(result, uf.size(root))

print(result)


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

using namespace std;

int main(){
 int n,x;
  cin >> n >> x;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  
  sort(a,a+n);
  
  int sum=0;
  int res=0;
  for(int i=0;i<n;i++){ sum+=a[i];
   if(sum>x) break;
   else res++;
   }                   
  if(res==n && sum==x)  cout << n << endl;
  else if(res==n && sum<x) cout << n-1 << endl;
  else cout << res << endl;
}


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

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

    int len=0;
    string sbuff;
    for (int i=s.size()-2; i>1; i-=2) {
        sbuff=s.substr(0, i);

        bool ans=true;
        rep(i, sbuff.size()/2) {
            if (sbuff[i]!=sbuff[i+sbuff.size()/2]) {
                ans=false;
                break;
            }
        }
        if (ans==true) {
            len=sbuff.size();
            break;
        }
    }

    cout << len << endl;
    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aeroui
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] arr = new int[3];
            for (int i = 0; i < 3; ++i) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);

            out.println(arr[0] + arr[1]);
        }

    }
}



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

int main() {
  int N,X=0;
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int j=0; j < N-1; j++){
    X += vec[j];
  }
  if(X > vec[N-1]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3600
from heapq import *  # heapqライブラリのimport
def solve():
  X, Y, Z, K = map(int, input().split())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  C = list(map(int, input().split()))
  A.sort(reverse=True)
  B.sort(reverse=True)
  C.sort(reverse=True)
  a = []
  heapify(a)
  ans = []
  for i in range(X):
    for j in range(Y):
      if (i+1)*(j+1)>K:
        break
      for k in range(Z):
        if (i+1)*(j+1)*(k+1)>K:
          break
        heappush(a,-A[i]-B[j]-C[k])
  for _ in range(K):
    ans.append(-heappop(a))
  return ans
print(*solve(),sep='\n')

Measured memory_bytes: 15200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<i<<endl;
#define m_p make_pair
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}
int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
  str s;
  cin>>s;
  int cnt=0,ans=0;
  rep(i,s.length()){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      cnt++;
    }
    else {
      ans=max(ans,cnt);
      cnt=0;
    }
  }
  ans=max(ans,cnt);
  out(ans);

  
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int a[100];
 
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int najveci = a[0];
	for (int i = 1; i < n; ++i)
	{
		if (najveci < a[i])
		najveci = a[i];
	}
	int c=0;
	for (int i = 0; i < n; i++)
	{
		c = c + a[i];
	}
  	c = c - najveci/2;
	cout << c;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	private static Scanner sc=new Scanner(System.in);
	private static final int MOD=1000000007;
	
	public static int findPaths(String[] grid,int H,int W){
		int dp[][]=new int[H+1][W+1];
		for(int i=0;i<H;i++)
			dp[i][0]=0;
		for(int i=0;i<W;i++)
			dp[0][i]=0;
		dp[0][1]=1;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				if(grid[i-1].charAt(j-1)=='.'){
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
				}
			}
		}
		
		// for(int i=0;i<=H;i++){
			// for(int j=0;j<=W;j++)
				// System.out.print(dp[i][j]+" ");
			// System.out.println("");
		// }
		
		return dp[H][W];
	}
	
	public static void main(String []args){
		int H=sc.nextInt();
		int W=sc.nextInt();
		String grid[]=new String[H];
		for(int i=0;i<H;i++){
			grid[i]=sc.next();
		}
		System.out.println(findPaths(grid,H,W));
				
	}
	
}

Measured memory_bytes: 46276
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main{


	static int[][] map ;
	static long INF =Long.MAX_VALUE/2;
	static int n,m ;
	static	long[] dis;

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		n = sc.nextInt();
		m = sc.nextInt();
		Edge[] v = new Edge[m];

		for(int i = 0;i < m;i++){
			v[i]=new Edge();
			v[i].from=sc.nextInt();
			v[i].to=sc.nextInt();
			v[i].cost=-sc.nextInt();		//ベルマンフォードを使うためにわざとマイナスにしている
		}

		dis = new long[n+1];
		Arrays.fill(dis, INF);
		dis[1] = 0;

		boolean flag = true;
		long ans = 0;
		int count = 0;

		while(flag){
			flag = false;
			for(int i = 0;i < m;i++){
				if(dis[v[i].from] + v[i].cost < dis[v[i].to]){
					dis[v[i].to]=dis[v[i].from]+v[i].cost;
					flag= true;
				}
			}

			if(count == n){
				ans = dis[n];
			}

			if(count == 2*n){						//閉路に入った時
				if(ans > dis[n]){					//閉路がプラスループ
					System.out.println("inf");
					return;
				}else{								//閉路がマイナスループ
					System.out.println(-dis[n]);
					return;
				}
			}

			count++;
			if(!flag){					//更新なしだったらループ出る
				break;
			}


		}
		System.out.println(-dis[n]);


	}



}
class Edge{
	int to;
	int from;
	int cost;
}

class MyComparator implements Comparator {

	public int compare(Object obj1, Object obj2) {

		int num1 = (int)obj1;
		int num2 = (int)obj2;

		if(num1 < num2) {
			return 1;
		} else if(num1 > num2) {
			return -1;
		} else{
			return 0;
		}
	}
}




Measured memory_bytes: 28132
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t x,k,d;
  cin>>x>>k>>d;
  // cout<<-42%8<<endl;
  //vector<int64_t> A(N);
  if(sqrt(abs(x)) >= sqrt(k)*sqrt(d)){
    cout<< abs(abs(x)-k*d) <<endl;
    return 0;
  }
  else {
    // if(1000000000>=sqrt(k)*sqrt(d)){
    //  if(x<=k*d){
// cout<< min(abs(abs(x)%d),min((abs(abs(x)%d)+d),abs(abs(x)%d-d)))<<endl;
    //  } 
    // }

  k-=abs(x)/d;
  if(k%2==0)cout<<abs(abs(x)%d)<<endl;
  else if(abs(x)%d<0) cout<< abs(abs(x)%d+d)<<endl;
  else if(abs(x)%d>=0) cout<< abs(abs(x)%d-d)<<endl;


    // int tb,b;
    // while(true){
    //   tb=x;
    //   if(x>0)x-=min(k,d);
    //   else x+=min(k,d);
    //   b=x;      
    //   if(x>0)x-=min(k,d);
    //   else x+=min(k,d);  
    //   if(tb==x){
    //     cout<<min(abs(b),abs(tb)) <<endl;
    //     return 0;
    //   }
    // }
  }
  // for(int i=0; i<k; i++){
  //   if(x>=0) x-=d;
  //   else x+=d;
  // }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){
  //   for(int j=0; j<M; j++){
  //       cin>>A[i][j];
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  // cout << abs(x) << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];
    vll ans;
    for(int i=n-1; i>=0; i-=2){
        ans.pb(a[i]);
    }
    for(int i=(n&1); i<n; i+=2){
        ans.pb(a[i]);
    }
    rep(i,n){
        if (i!=0) cout<<" ";
        cout<<ans[i];
    }cout<<endl;
    return 0;
}


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

int main()
{
    const long long mod=1000000000+7;
    long long a;
    int n;
    scanf("%d",&n);
    a=1;
    for(int i=1;i<=n;i++)
        a=(a*i)%mod;
    printf("%lld\n",a);
    return 0;
}


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

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

  int n, p, q;

  int a[100000]={};

  for(int i=0;i<150;i++){
    for(int j=0;j<150;j++){
      if(i==0&&j==0) continue;
      a[i*i+j*j]=1;
    }
  }
  //cout<<a[1]<<endl;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p>>q;
    int cnt=0;
    for(int j=-150;j<150;j++){
      for(int k=-150;k<150;k++){
	if(j==0&&k==0) continue;
	int check=0;
	if((j*p+k*q)%(j*j+k*k)==0&&(k*p-j*q)%(j*j+k*k)==0) check++;
	//int y=(j*q-k*p)/(j*j+k*k), x=(p+k*y)/j;
	//if((j*q-k*p)%(j*j+k*k)==0&&(p+k*y)%j==0) check++;
	//if((j*j+k*k)*(x*x+y*y)==p*p+q*q) check++;
	if((p*p+q*q)%(j*j+k*k)==0&&a[(p*p+q*q)/(j*j+k*k)]) check++;
	if(check==2){
	  cnt++;
	  //cout<<j<<" "<<k<<endl;
	}
      }
    }
    //cout<<cnt<<endl;
    if(cnt==8) cout<<"P"<<endl;
    else cout<<"C"<<endl;
  }

  return 0;
}



Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int ans = 0;
int n;
int a[15];

void dfs(int v, int product_sum = 1) {
    if (v == n) {
        if (!(product_sum&1)) ans++;
        return ;
    }
    for (int i = a[v]+1; i >= max(0,a[v]-1); i--) {
        dfs(v+1,product_sum*i);
    }
}

int main() {
    cin >> n;
    rep(i,n) {
        int x; cin >> x;
        a[i] = x;
    }
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    boolean keyBreak = false;
    List<String> scores = new ArrayList<String>();
    List<String> ranks = new ArrayList<String>();
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      out += func(line) + "\n";
    }
    System.out.print(out);
  }

  private static String func (String line) {
    if (line.length() == 1) {
      return line;
    }
    int len = line.length();
    int[] a = new int[len];
    for (int ii = 0; ii < len; ii++) {
      a[ii] = line.charAt(ii) - '0';
    }
    String s = "";
    for (int ii = 0; ii < a.length; ii++) {
      if (ii == a.length - 1) {
        continue;
      }
      int w = a[ii] + a[ii + 1];
      if (w >= 10) {
        w -= 10;
      }
      s += w;
    }
    return func(s);
  }

}

Measured memory_bytes: 17208
fun main(args: Array<String>) = println(run {
    val ( a,b,k) = readLine()!!.split(" ").map { it.toInt() }

    val l = (a..b).take(k)
    val r = (b downTo a).take(k)
    (l+r).distinct().sorted().joinToString("\n")
  
})


Measured memory_bytes: 37740
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int> r,g,b;
    rep(i,n){
        if(s.at(i) == 'R'){
            r.insert(i);
        }else if(s.at(i) == 'G'){
            g.insert(i);
        }else{
            b.insert(i);
        }
    }
    long ans = 0;
    for(auto x : r){
        for(auto y : g){
            int z1 = b.count(2*x - y);
            int z2 = ((x + y) % 2 == 0 && b.count((x+y)/2));
            int z3 = b.count(2*y - x);
            ans += (b.size() - z1 - z2 - z3);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l=2*i;
    r=2*i+1;
    
    if(l<=H && A[l]>A[i])largest =l;
    else largest = i;
    if (r <= H && A[r]>A[largest])largest = r;
    
    if(largest != i){
        swap (A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1)return -INFTY;
    maxv=A[1];
    A[1]=A[H];
    H--;
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key){
    if (key<A[i])return;
    A[i]=key;
    while (i>1 && A[i/2] < A[i]){
        swap(A[i], A[i/2]);
        i=i/2;
    }
}

void insert(int key){
    H++;
    A[H]=-INFTY;
    increaseKey(H, key);
}

int main(){
    int key;
    char com[10];
    
    while (1){
        scanf("%s", com);
        if (com[0]=='e' && com[1]=='n') break;
        if (com[0]=='i'){
            scanf("%d", &key);
            insert(key);
        }else{
            printf("%d\n", extract());
        }
    }
    return 0;
}




Measured memory_bytes: 7100
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000000;

int main()
{
    int n;
    cin >> n;
    ll x[20], y[20], p[20];
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> p[i];
    ll ans[20];
    for(int i = 0; i <= n; i++) ans[i] = INF;
    for(int m = 0; m < (1 << n); m++){
        ll d1[20];
        int c1 = 0;
        int b[20];
        for(int i = 0; i < n; i++) d1[i] = min(abs(x[i]), abs(y[i]));
        for(int i = 0; i < n; i++){
            if((m >> i) & 1){
                for(int j = 0; j < n; j++) d1[j] = min(d1[j], abs(y[i] - y[j]));
            }
            else{
                b[c1] = i;
                c1++;
            }
        }
        for(int l = 0; l < (1 << c1); l++){
            ll d2[20];
            for(int i = 0; i < n; i++) d2[i] = d1[i];
            int c2 = n - c1;
            for(int u = 0; u < c1; u++){
                int i = b[u];
                if((l >> u) & 1){
                    for(int v = 0; v < c1; v++){
                        int j = b[v];
                        d2[j] = min(d2[j], abs(x[i] - x[j]));
                    }
                    c2++;
                }
            }
            ll s = 0;
            for(int i = 0; i < n; i++) s += d2[i] * p[i];
            ans[c2] = min(ans[c2], s);
        }
    }
    for(int i = 0; i <= n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int a,b;
 cin>>a>>b;
 if(a*b==15)std::cout<<"*"<<std::endl;
 else if(a+b==15)std::cout<<"+"<<std::endl;
 else std::cout<<"x"<<std::endl;

 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int N;
    long long int rui=0;
    long long int ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a)rui+=a;
        else{
            ans+=rui/2;
            rui=0;
        }
    }
    ans+=rui/2;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

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

h = [1] * N

for m in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        h[b-1] = 0
    elif H[a-1] < H[b-1]:
        h[a-1] = 0
    else:
        h[a-1] = 0
        h[b-1] = 0

print(h.count(1))

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

long long n, a, b, c, m = 1, t = 2, w = 1, v;
const long long M = 1000000007;

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

	for (int i = 0; (1ull << i) <= n; i++) {
		if ((1ull << i) & n)
			m = m * t % M;

		t = t * t % M;
	}

	m -= 1;

	c = max(a, b);

	for (int i = 1; i <= c; i++) {
		w = w * i % M;

		t = w;
		v = 1;

		if (i == a || i == b) {
			for (int j = 0; (1ull << j) < M - 1; j++) {
				if ((1ull << j) & (M - 2))
					v = v * t % M;

				t = t * t % M;
			}

			t = 1;
			for (long long k = n; k > n - i; k--)
				t = t * k % M;

			m = (M + m - (t * v % M)) % M;
		}
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner std = new Scanner(System.in);
        String str = std.nextLine();
        int q = Integer.parseInt(std.nextLine());
 
        for(int i=0; i<q; i++){
            String query = std.next();
            int a = Integer.parseInt(std.next());
            int b = Integer.parseInt(std.next());
 
            if(query.equals("print")){
                System.out.println(str.substring(a, b+1));
 
            }else if(query.equals("reverse")){
                StringBuffer sb = new StringBuffer(str.substring(a, b+1));
                String rev = sb.reverse().toString();
                str = str.substring(0, a) + rev + str.substring(b+1, str.length());
 
            }else if(query.equals("replace")){
                String rep = std.next();
                str = str.substring(0, a) + rep + str.substring(b+1, str.length());
            }
        }
    }
}


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

#define ll long long

using namespace std;

char s[100'005];
int a[100'005];
int main() {
    cin >> s;
    int n = strlen(s);

    vector<int> last_r, last_l;
    int last = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'R')
            last = i;
        else {
            if (last >= 0)
                last_r.push_back(last);
            last = -1;
        }
    }

    last = n - 1;
    for (int i = n - 2; i >= 0; --i) {
        if (s[i] == 'L')
            last = i;
        else {
            if (last >= 0)
                last_l.push_back(last);
            last = -1;
        }
    }
//    reverse(last_l.begin(), last_l.end());
    // for (auto x : last_l)
    //     cout << x << " ";

    for (int i = 0; i < n; ++i) {
        int pos;
        if (s[i] == 'R') {
            auto it = lower_bound(last_r.begin(), last_r.end(), i);
            pos = (*it - i) % 2 == 0 ? *it : *it + 1;
            a[pos]++;
        } else {
            auto it = lower_bound(last_l.begin(), last_l.end(), i, greater<int>());
            pos = (i - *it) % 2 == 0 ? *it : *it - 1;
            a[pos]++;
        }
    }

    for (int i = 0; i < n; ++i)
        cout << a[i] << " ";

    return 0;
}


Measured memory_bytes: 1404
pub fn main() {
  fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse::<T>().ok().unwrap()
  }

  fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
      .split_whitespace()
      .map(|e| e.parse().ok().unwrap())
      .collect()
  }

  let nk = read_vec::<i32>();
  let n = nk[0];
  let k = nk[1];

  let mut vec: Vec<i32> = vec![0; n as usize];
  for i in 0..k {
    read::<String>();
    let a = read_vec::<i32>();
    for j in a {
      vec[(j - 1) as usize] = 1;
    }
  }

  let mut ans = 0;
  for k in vec {
    if k == 0 {
      ans = ans + 1;
    }
  }
  println!("{:?}", ans);
}

Measured memory_bytes: 2120
#include<iostream>
using namespace std;
int n,ww;
long long v[105],w[105];
long long dp[105][100005];
long long rec(int i,int rem){
	if(i>=n)return 0;
	if(dp[i][rem])return dp[i][rem];
	long long a1=1<<32,a2=1<<32;
	a1=rec(i+1,rem);
	if(rem-w[i]>=0)a2=v[i]+rec(i+1,rem-w[i]);
	return dp[i][rem]=max(a1,a2);
}
int main(){
	cin>>n;
	cin>>ww;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	long long ans=rec(0,ww);
	cout<<ans;
}

Measured memory_bytes: 78080
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  char c;
  cin>>c;
  if((c-'A') >= 0 && (c-'A') < 26) cout<<'A'<<endl;
  else if((c-'a') >= 0 && (c-'a') < 26) cout<<'a'<<endl;
}

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

using namespace std;

bool isValidMonth(int num) {
    return 0 < num && num < 13;
}

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

    string front = string(S.begin(), S.begin() + 2);
    string back = string(S.begin() + 2, S.end());

    int front_num = atoi(front.data());
    int back_num = atoi(back.data());

    if (isValidMonth(front_num) && isValidMonth(back_num)) {
        cout << "AMBIGUOUS" << endl;
    } else if (!isValidMonth(front_num) && !isValidMonth(back_num)) {
        cout << "NA" << endl;
    } else if (isValidMonth(front_num)) {
        cout << "MMYY" << endl;
    } else if (isValidMonth(back_num)) {
        cout << "YYMM" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def combnk_mod(n, k, p):
    # pが素数かつaとpが互いに素であるとき
    # フェルマーの小定理より以下が成り立つ.
    # 1 / a = a ** (p - 2) (mod p)
    # これを使って (1 / k!) mod p を計算する.

    if  2 * k > n:
        k = n - k
    x = 1 # 分母にあたる数 1 / n! mod p
    y = 1 # 分子にあたる数. n! / (n - k)! mod p
    for i in range(1, k + 1):
        x *= pow(i, p - 2, p)
        y *= n - i + 1
        x %= p
        y %= p
    return (x * y) % p

n, m = map(int, input().split())
MOD = 10 ** 9 + 7
d = defaultdict(int)

for i in range(2, int(m ** 0.5) + 1):
    while(m % i == 0):
        m = m // i
        d[i] += 1
if m > 1:
    d[m] = 1

ans = 1
for i in d.values():
    ans *= combnk_mod(i + n - 1, i, MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr lint mod = 998244353;
lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i], --a[i];
  int w = count(begin(a), end(a), 0);
  if (!w) return cout << 0 << '\n', 0;
  if (w == n) {
    lint res = 1;
    for (int i = 2; i <= n; ++i) (res *= i) %= mod;
    cout << res << '\n';
    return 0;
  }
  for (int i = 1; i < n; ++i) if (a[i - 1] and !a[i]) {
    rotate(begin(a), next(begin(a), i), end(a));
    break;
  }
  bitset<300000> b;
  for (int i = 1; i < n; ++i) {
    if (b[a[i]] and a[i - 1] != a[i]) return cout << 0 << '\n', 0;
    b[a[i]] = true;
  }
  V<> ls(n, -1), rs(n, -1);
  for (int i = 0; i < n; ++i) if (ls[a[i]] == -1) ls[a[i]] = i;
  for (int i = n - 1; i >= 0; --i) if (rs[a[i]] == -1) rs[a[i]] = i + 1;
  for (int i = 0; i < n; ++i) if (ls[i] != -1 and rs[i] - ls[i] > w) return cout << 0 << '\n', 0;
  lint res = 1;
  int c = 0;
  bitset<300001> used;
  for (int i = 0; i < n; ++i) if (ls[i] != -1) {
    if (rs[i] - ls[i] < w) {
      if (!used[ls[i] - 1] and !used[rs[i]]) return cout << 0 << '\n', 0;
      if (used[ls[i] - 1] and used[rs[i]]) (res *= w - (rs[i] - ls[i]) + 1) %= mod;
    }
    for (int j = ls[i]; j < rs[i]; ++j) used[j] = true;
    if (!i) {
      used[n] = true;
      continue;
    }
    if (used[ls[i] - 1] ^ used[rs[i]]) c += rs[i] - ls[i] - 1;
    if (used[ls[i] - 1] and used[rs[i]]) c += rs[i] - ls[i] + w - 2;
  } else {
    (res *= c) %= mod;
    --c;
  }
  cout << emod(res) << '\n';
}

Measured memory_bytes: 3840
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class SegmentTree():
    '''
    非再帰
    segment tree
    '''

    def __init__(self, n, func, init=float('inf')):
        '''
        n->配列の長さ
        func:func(a,b)->val,　func=minだとRMQになる
        木の高さhとすると,
        n:h-1までのノード数。h段目のノードにアクセスするために使う。
        data:ノード。
        parent:k->child k*2+1とk*2+2
        '''
        self.n = 2**(n-1).bit_length()
        self.init = init
        self.data = [init]*(2*self.n)
        self.func = func

    def set(self, k, v):
        '''
        あたいの初期化
        '''
        self.data[k+self.n-1] = v

    def build(self):
        '''
        setの後に一斉更新
        '''
        for k in reversed(range(self.n-1)):
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def update(self, k, a):
        '''
        list[k]=aに更新する。
        更新ぶんをrootまで更新
        '''
        k += self.n-1
        self.data[k] = a

        while k > 0:
            k = (k-1)//2
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        '''
        [l,r)のfuncを求める
        '''
        L = l+self.n
        R = r+self.n
        ret = self.init
        while L < R:
            if R & 1:
                R -= 1
                ret = self.func(ret, self.data[R-1])
            if L & 1:
                ret = self.func(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


N, C = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(C)]
L = sorted(L, key=lambda x: (x[1], -x[2], x[0]), reverse=True)

Seg = SegmentTree(N+1, func=lambda a, b: min(a, b))
Seg.set(N, 0)
Seg.build()

dist = [float("inf")]*(N+1)
dist[-1] = 0
for l, r, c in L:
    new = min(Seg.query(l, r+1)+c, Seg.query(l, l+1))
    Seg.update(l, new)
ans = Seg.query(1, 2)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 149596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c, s, e) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N = 3e5 + 5;
const long long INF = 1e18 + 37;

#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif


void solve(){
    int n , m , k;
    cin >> n >> m >> k;
    vector<vector<char>> s(n , vector<char>(m));

    for(int i=0 ; i<n  ; i++){
        for(int j=0; j<m;j++){
            cin >> s[i][j];
        }
    }
    int ans = 0;
    for(int i=0 ; i<(1<<n); i++){
        for(int j=0 ; j<(1<<m);j++){
            vector<vector<char>> ss(s);
            for(int ii = 0 ; ii<n; ii++){
                if(i&(1<<ii)){
                    for(int jj=0 ; jj<m;jj++) ss[ii][jj] = 'R';
                }
            }
            for(int jj=0; jj<m; jj++){
                if(j&(1<<jj)){
                    for(int ii=0 ; ii<n; ii++) ss[ii][jj] = 'R';
                }
            }
            int cnt =0;
            for(int ii=0 ; ii<n ; ii++){
                for(int jj=0 ; jj<m; jj++){
                    if(ss[ii][jj]=='#')cnt++;
                }
            }
            if(cnt ==k) ans++;
        }
    }
    cout << ans;
}


signed main() {
    FAST
    int tc = 1;
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double a,b,x;
    cin >> a >> b >> x;
    double kizyun = a * a * b / 2.0;
    double theta;
    if (kizyun < x)
    {
        // daikei
        theta = atan(2.0 * b / a - 2.0 * x / (a * a * a)) * 180.0 / M_PI;
    }
    else if (kizyun > x)
    {
        // sankaku
        theta = atan2(a * b * b , 2.0 * x) * 180.0 / M_PI;
    }
    else
    {
        theta = atan2(b,a) * 180.0 / M_PI;
    }
    
    
    cout << fixed << setprecision(10) << theta << endl;
}


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 2000011

lli freq[3];
signed main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == 'R')
      freq[0]++;
    else if (s[i] == 'G')
      freq[1]++;
    else if (s[i] == 'B')
      freq[2]++;
  }
  lli ans = freq[0] * freq[1] * freq[2];
  lli subtract = 0;
  int i = 1;
  while (1)
  {
    int ii = 0, jj = i, kk = i + i;
    if (kk >= n)
      break;
    while (1)
    {
      if (kk >= n)
        break;
      else
      {
        if (s[ii] != s[jj] && s[jj] != s[kk] && s[kk] != s[ii])
          subtract++;
        ii += 1;
        jj += 1;
        kk += 1;
      }
    }
    i++;
  }
  cout << ans - subtract << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	printf("%d\n",a*b);
return 0;
}

Measured memory_bytes: 3832
n = gets.chomp.to_i
l = gets.chomp.split(" ").map(&:to_i)

a = 0
b = 1
c = 2
count = 0
# if n < 3
#     puts "0"
# elsif n >= 3
#     until a == n-3
#         until b == n-2
#             until c == n-1
#                 r = [l[a],l[b],l[c]].sort
#                 if r[0] + r[1] >= r[2]
#                     count += 1
#                 end
#                 c =+ 1
#             end
#         b += 1
#         c = b + 1
#         end
#         a += 1
#         b = a + 1
#     end
# end
 count = 0
[*0..n-1].permutation (3) do |i|
    if i[0] < i[1] && i[1] < i[2]
        arr = []
        r = l[i[0]]
        rr = l[i[1]]
        rrr = l[i[2]]
         arr << r
         arr << rr
         arr<< rrr
         arr = arr.sort
         mae = arr[0] + arr[1]
         usiro = arr[2]
         if mae > usiro 
          
            if arr.uniq.size == 3

                count += 1
            end
        elsif mae == usiro
            if arr[0] ** 2 + arr[1] ** 2 == arr[2] ** 2
                count += 1
            
            end
        end
    end
end
puts count

Measured memory_bytes: 14296
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <bits/stdc++.h>
 
using namespace std;
using namespace  __gnu_pbds;
 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
typedef pair<int,int> pr; 
 
const ll MOD = 1e9 + 7,OOl=LLONG_MAX;
const int N = 1e6+1, M = 1e6+1, OO = INT_MAX,OOmem = 0x4f4f4f4f;
 
inline void WRITE_CHAR(char c)  {putchar_unlocked(c);}
 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  if(ch!='-') while (!isdigit(ch) && ch!=EOF) ch= (char) getchar_unlocked(), minus = (ch == '-'? -1 : minus);
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char (&x)[N]) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
int cost[N],n,dp[N];
int main()
{
  
  READn(n);
  for(int i=0;i<n;++i) READn(cost[i]);
  dp[0] = 0;
  dp[1] = abs(cost[1]-cost[0]);
  for(int i=2;i<n;++i) dp[i] = min(dp[i-1]+abs(cost[i]-cost[i-1]),dp[i-2]+abs(cost[i]-cost[i-2])); 
  
  WRITEn(dp[n-1]);
  return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>

int main(void){
  long long N;
  char S[100000];
  long long n[26]={0};
  long long c=1;
  int i;

  scanf("%lld",&N);
  scanf("%s",S);
  
  for(i=0;i<N;i++){
    n[S[i]-'a']++;
  }

  for(i=0;i<26;i++){
    if(n[i]!=0){
        c*=(n[i]+1);
        c%=1000000007;
    }
  }
    
  printf("%lld\n",c-1);
  
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC120_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int d;
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            d = b / a;
             
            if(d > c)
            {
                Console.WriteLine(c);
            }
            else
            {
                Console.WriteLine(d);
            }

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define maxn 500005 
char s[maxn];
int len[maxn],be[maxn],ed[maxn],tp;
long long res;
int main(){
	scanf("%s",s+1);int l=strlen(s+1);
	tp=1;be[tp]=ed[tp]=0;len[tp]=1;int last_pos=0;
	rep(i,1,l){
		if (s[i]=='<'){
			last_pos++;
			res+=last_pos;
		}
		else{
			int k=i;
			while (k<=l&&s[k]==s[i])k++;
			int c=k-i;
			if (last_pos>=c){
				res+=1ll*(c-1)*c/2;last_pos=0;
			}
			else{
				res-=last_pos;
				res+=1ll*(c+1)*c/2;
				last_pos=0;
			}
			i=k-1;
		}
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 4608