akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[100001][13]={};
int main(){
	string S;
	scan(S);
	int N=S.size();
	ll MOD=1e+9+7;
	dp[0][0]=1;
	rep(i,N){
		if(S[i]=='?'){
			rep(j,10){
				rep(k,13){
					dp[i+1][(k*10+j)%13]+=dp[i][k];
					dp[i+1][(k*10+j)%13]%=MOD;
				}
			}
		}
		else{
			int c=(S[i]-'0');
			rep(k,13){
				dp[i+1][(k*10+c)%13]+=dp[i][k];
				dp[i+1][(k*10+c)%13]%=MOD;
			}
		}
	}
	prin(dp[N][5]);
	return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  while(a>=b){
    b*=2;
    cnt++;
  }
  while(b>=c){
    c*=2;
    cnt++;
  }
  if(cnt<=k) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

const int N = 100;
int Pre[N], In[N];
int root, cnt;

void construct_tree(int left, int right) {
  if (left < right) {
    int node = Pre[root++];
    for (int i = left; i < right; i++) {
      if (In[i] == node) {
        // left subtree
        construct_tree(left, i);
        // right subtree
        construct_tree(i+1, right);
        // print nodes in postorder
        if (cnt++ > 0) cout << " ";
        cout << node;
        break;
      }
    }
  }
}

int main() {
  int i, n;


  // input
  cin >> n;
  for (i = 0; i < n; i++) cin >> Pre[i];
  for (i = 0; i < n; i++) cin >> In[i];
  // initialize
  root = 0;
  cnt = 0;
  // output
  construct_tree(0, n);
  cout << endl;

  return 0;
}



Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, K;
        public string S;
        public long MOD = 1000000007;

        public void Run()
        {
            var line = Input.ReadIntArray();
            N = line[0];
            K = line[1];

            S = Console.ReadLine();

            List<char> lst = new List<char>();
            for (int i = 0; i < S.Length; i++)
            {
                if (i == K - 1)
                {
                    if (S[i] == 'A') lst.Add('a');
                    if (S[i] == 'B') lst.Add('b');
                    if (S[i] == 'C') lst.Add('c');
                }
                else
                {
                    lst.Add(S[i]);
                }

            }

            for (int i = 0; i < S.Length; i++)
            {
                Console.Write(lst[i]);
            }
            Console.WriteLine();
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int a, b, n;

	cin >> a >> b;

	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if ( (a >= 0 && b <= 0) || (a <= 0 && b >= 0) || a==0 || b == 0) {
		cout << "Zero" << endl;
	}
	else {
		if (a == b) {
			cout << "Positive" << endl;
		}
		else if ( ((abs(a) > abs(b) ? abs(a) - abs(b) : abs(b) - abs(a) ) + 1 ) % 2 == 1) {
			cout << "Negative" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}

	getchar();
	getchar();
	return 0;
}

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

int main(){
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    A--;B--;C--;D--;
    int right=max(C,D);

    string S;
    cin>>S;
    bool ans=true;
    for(int i=A;i<=right;i++) {
        char x=S.at(i);
        if(x=='#'&& S.at(i+1)=='#') ans=false;
    }

    bool thr=false;
    if(right==C){
        for(int i=B;i<=D;i++){
            if(S.at(i-1)=='.'&&S.at(i)=='.'&&S.at(i+1)=='.') thr=true;
        }
    }
    else thr=true;

    if(ans&&thr) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int n, a[3];
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        bool flag = false;
        scanf("%d %d %d", &a[0], &a[1], &a[2]);
        for (int j = 0; j < 3; ++j) {
            if (a[j] * a[j] == (a[(j + 1) % 3] * a[(j + 1) % 3] + a[(j + 2) % 3] * a[(j + 2) % 3])) {
                flag = true;
            }
        }
        if (flag) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1008
from collections import deque
N,M = map(int,input().split())
edge = [[] for i in range(N)]
x = [float('inf')]*N
for i in range(M):
  L,R,D = map(int,input().split())
  edge[L-1].append([R-1,D])
  edge[R-1].append([L-1,-D])
for i in range(N):
  if x[i] == float('inf'):
    x[i] = 0
    q = deque([i])
    while len(q) > 0:
      now = q.popleft()
      for e in edge[now]:
        if x[e[0]] == float('inf'):
          x[e[0]] = x[now]+e[1]
          q.append(e[0])
        elif x[e[0]]-x[now] != e[1]:
          print('No')
          exit()
print('Yes')

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

struct Point{
  int x,y;
  Point operator + (const Point p)const{
    return (Point){x+p.x,y+p.y};
  }
  Point operator - (const Point p)const{
    return (Point){x-p.x,y-p.y};
  }
};

struct Segment{
  Point p,v;
};

int dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}

int cross(Point a,Point b){
  return a.x*b.y-b.x*a.y;
}

bool isParallel(Point a,Point b){
  return (0==cross(a,b));
}

int abs(int a){return max(a,-a);}
bool eq(Point a,Point b){
  return (a.x==b.x&&a.y==b.y);
}
bool eq(Segment a,Segment b){
  if(eq(a.v,b.v)&&eq(a.p,b.p))return true;
  if(eq(a.p,b.p+b.v)&&eq(a.p+a.v,b.p))return true;
  return false;
}

bool onSegment(Segment s,Point p){
  Point q=p-s.p;
  if(eq(s.p,p)||eq(s.p+s.v,p))return false;
  if(!isParallel(s.v,q))return false;
  if(dot(s.v,q)<=0)return false;
  Point Q=p-(s.p+s.v);
  if(dot(s.p-s.p-s.v,Q)<=0)return false;
  return true;  
}



int n;
int c;
map<string,int> mp;
vector<Segment> G[10];
int g[10][10];

bool calc(int a,int b){
  for(int i=0;i<(int)G[a].size();i++){
    Segment si=G[a][i];
    for(int j=0;j<(int)G[b].size();j++){
      Segment sj=G[b][j];
      if(!isParallel(si.v,sj.v))continue;
      if(eq(si,sj))return true;
      if(onSegment(si,sj.p))return true;
      if(onSegment(si,sj.p+sj.v))return true;
      if(onSegment(sj,si.p))return true;
      if(onSegment(sj,si.p+si.v))return true;
    }
  }
  return false;
}

void init(){
  c=0;
  mp.clear();  
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      g[i][j]=0;
  for(int i=0;i<10;i++)G[i].clear();
}

int main(){
  int id;
  int px,py;
  string str;
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    for(int i=0;i<n;i++){
      cin>>str;
      if(mp.count(str)==0)mp[str]=id=c++;
      else id=mp[str];
      vector<Point> t;
      while(1){
        scanf("%d",&px);
        if(px==-1)break;
        scanf("%d",&py);
        t.push_back((Point){px,py});
      }
      int size=t.size();
      for(int j=0;j<size;j++)
        G[id].push_back((Segment){t[j],t[(j+1)%size]-t[j]});
    }
    
    for(int i=0;i+1<c;i++)
      for(int j=i+1;j<c;j++)
        if(calc(i,j))g[i][j]=g[j][i]=1;
    
    vector<int> e;
    for(int i=0;i<(1<<c);i++){
      bool flg=true;
      for(int j=0;j+1<c;j++){
        if(i>>j&1){
          for(int k=j+1;k<c;k++){
            if(i>>k&1){
              if(g[j][k])flg=false;
            }
          }
        }
      }
      if(flg)e.push_back(i);
    }
    
    int dp[(1<<c)];
    fill(dp,dp+(1<<c),1e8);
    dp[0]=0;
    for(int S=0;S<(1<<c);S++){
      if(dp[S]==1e8)continue;
      for(int i=0;i<(int)e.size();i++){
        int T=e[i];
        dp[S|T]=min(dp[S|T],dp[S]+1);
      }
    }
    cout<<dp[(1<<c)-1]<<endl;
    
  }
  return 0;
}

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

    for(int i=0;i<T.length();i++){

        if(T[i]=='?'){
            if(T[i-1]=='P'){
                T[i]='D';
            }else{
                if(T[i+1]=='D'||T[i+1]=='?'){
                    T[i]='P';
                }else{
                    T[i]='D';
                }
            }
        }
    }

    cout<<T<<endl;

    return 0;
}

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

using P = pair<int,int>;

int main(){
    int n;
    while(cin >> n, n){
        int depth = 0;
        stack<P> num;
        stack<char> op;
        bool fst = true;
        string s;
        for(int i=0;i<n;i++){
            cin >> s;
            while(depth >= s.size()){
                P tmp = num.top();
                num.pop();
                while(!num.empty() && num.top().second == tmp.second){
                    if(op.top() == '+'){
                        tmp.first += num.top().first;
                    }else{
                        tmp.first *= num.top().first;
                    }
                    num.pop();
                }
                tmp.second--;
                num.push(tmp);
                depth--;
                op.pop();
            }
            if(isdigit(s[depth])){
                int x = s[depth]-'0';
                if(fst){
                    num.push(P(x,depth));
                    fst = false;
                }else{
                    if(op.top() == '+'){
                        num.top().first += x;
                    }else{
                        num.top().first *= x;
                    }
                }
            }else{
                op.push(s[depth]);
                depth++;
                fst = true;
            }
        }
        while(depth >= 0){
            P tmp = num.top();
            num.pop();
            while(!num.empty() && num.top().second == tmp.second){
                if(op.top() == '+'){
                    tmp.first += num.top().first;
                }else{
                    tmp.first *= num.top().first;
                }
                num.pop();
            }
            tmp.second--;
            num.push(tmp);
            depth--;
            op.pop();
        }
        cout << num.top().first << endl;
    }
    return 0;
}



Measured memory_bytes: 3176
import itertools

n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

a, b = -1, -1
for i, L in enumerate(itertools.permutations(sorted(P), n)):
    if P == list(L):
        a = i
    if Q == list(L):
        b = i
print(abs(a - b))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll factorial ( ll a, ll b ) {
    if ( a < b ) return -1;
    ll tmp_num;
    if ( a > b ){
        tmp_num = a * factorial(a-1, b) % mod;
    }
    if ( a == b ) {
        tmp_num = b;
    }
    return tmp_num;
}

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#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 eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool kaibun(int x){
	vi y(5);
	y[0] = x%10;
	rep(i,4) {
		x = (x-y[i])/10;
		y[i+1] = x%10;
	}
	return (y[0] == y[4] && y[1] == y[3]);
}

void Main()
{
	int a, b;
	cin >> a >> b;
	int cnt = 0;
	rep3(i, a, b) if(kaibun(i)) cnt++;
	cout << cnt << endl;
	return;
}

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


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

int main(){
  string S;
  cin >> S;
  int count=0;
  int ans=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='R'){
      count++;
    }else{
      ans=max(ans,count);
      count=0;
    }
  }
  ans=max(ans,count);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int K,X; cin>>K>>X;
  if(K*500>=X){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
a = [0]*n
for i in range(n):
    if i == 0:
        a[0] = b[0]
    else:
        if i == n-1:
            a[i] = b[i-1] 
        elif b[i-1] <= b[i]:
            a[i] = b[i-1]
        else:
            a[i] = b[i]
print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100010],g[100010],gg[100010],ans;
long long gcd(long long aa,long long bb)
{
	if (!bb) return aa;
	return gcd(bb,aa%bb);
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	g[1]=a[1];
	for (int i=2;i<=n;i++) g[i]=gcd(g[i-1],a[i]);
	gg[n]=a[n];
    for (int i=n-1;i>=1;i--) gg[i]=gcd(gg[i+1],a[i]);
    ans=max(gg[2],g[n-1]);
    for (int i=2;i<n;i++)
      ans=max(gcd(g[i-1],gg[i+1]),ans);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLUCK 2
#define INF 200000000
void bfs(int);
void visit(int);
void enqueue(int);
int  dequeue();
 
int matrix[200][200];
int color[200];
int d[300];
int sumvirtex;
int queue[100]; 
int head;
int tail;
 
int main(){
 
  int i,j,virtexnum,connectsum,connect;
 
  //printf("test");
  scanf("%d",&sumvirtex);
  // printf("test");
  for(i = 1; i<=sumvirtex; i++){
 
    scanf("%d",&virtexnum);
    scanf("%d",&connectsum);
 
    for(j = 1; j <= connectsum; j++){
 
      scanf("%d",&connect);
 
      matrix[i][connect] =  1;
      // printf("%d\n",connect);
    }
  }
 

  /* for(i = 1; i<= sumvirtex;i++){
 
    for(j = 1; j <= sumvirtex;j++){
 
      printf("%d",matrix[i][j]);
 
    }
 
    }*/
 
  // printf("test");
   bfs(1);
 
  /* for(i=1; i<= sumvirtex; i++){
 
    printf("%d %d %d\n",i,firstvirtextime[i],finalvirtextime[i]);
 
    }*/
   
  for(i = 1; i <= sumvirtex; i++){

    if(d[i] == INF){

      d[i] = -1;

    }

    printf("%d %d\n",i,d[i]);

  }
 
  return 0;
 
}
 
void bfs(int s){
 
  int i,j,u;
  int dequeuenum;

  // printf("test");
  for(i = 1; i <= sumvirtex; i++){
 
    color[i] = WHITE;
    d[i] = INF;
  }
 
  // printf("test");
  color[s] = GRAY;
 
  d[s] = 0;

  enqueue(s);

  while((u = dequeue()) != -1){

    // printf("%d\n",u);

    for(j = 1; j <= sumvirtex; j++){

      if(matrix[u][j] != 0 && color[j] == WHITE){

	color[j] = GRAY;

	d[j] = d[u] + 1; 

	enqueue(j);

	  }
    }

  }
    color[u] = BLUCK;
}

void enqueue(int key){

  queue[tail] = key;

  tail = tail + 1;
}

int  dequeue(){

  int value;

  if(head == tail){

    return -1;

  }
 
  else{ 

    value = queue[head];

    head = head + 1;

  }
 
 return value;

}


/* for(i =1 ; i <= sumvirtex; i++){
 
    if(color[i] == WHITE){
 
      visit(i);
 
    }
 
    }*/
 
  /*for(i = 1; i <= sumvirtex; i++){
 
    printf("%d %d %d\n",i,firstvirtextime[i],finalvirtextime[i]);
 
    }*/
 
/*}
 
void visit(int i){
 
  int j;
 
  color[i] = GRAY;
 
  firstvirtextime[i] = ++time;
 
  for(j = 1; j <= sumvirtex; j++){
 
    if(matrix[i][j] == 1 && color[j] == WHITE){
 
      visit(j);
 
    }
 
  }
 
  color[i] == BLUCK;
 
  finalvirtextime[i] = ++time;
 
}*/

Measured memory_bytes: 680
#include <cstdio>           // printf(), scanf()

static const double EPS = 1e-10;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
};

typedef Point Vector;

double
norm(Vector a)
{
	return a.x * a.x + a.y * a.y;
}

double
dot(Vector a, Vector b)
{
	return a.x * b.x + a.y * b.y;
}


double
cross(Vector a, Vector b)
{
	return a.x * b.y - a.y * b.x;
}

int
ccw(Point p0, Point p1, Point p2)
{
	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;

	if (cross(a, b) < -EPS)
		return CLOCKWISE;

	if (dot(a, b) < -EPS)
		return ONLINE_BACK;

	if (norm(a) < norm(b))
		return ONLINE_FRONT;

	return ON_SEGMENT;
}

int
main(int argc, char** argv)
{
	/*x                       -2 (#0)         -1 (#1)      0 (#2)        1 (#3)               2 (#4)     x*/
	const char* output[5] = {"ONLINE_FRONT", "CLOCKWISE", "ON_SEGMENT", "COUNTER_CLOCKWISE", "ONLINE_BACK"};
	Point p0, p1, p2;
	int x, y;
	int x1, y1, x2, y2;
	int q, i;
	int ix;

	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	p0.x = x1, p0.y = y1;
	p1.x = x2, p1.y = y2;

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d", &x, &y);
		p2.x = x, p2.y = y;

		ix = ccw(p0, p1, p2);
		printf("%s\n", output[ix + 2]);
	}

	return 0;
}

Measured memory_bytes: 1016
h,w,k = map(int,input().split())
A = [list(input()) for _ in range(h)]
ans = 0
for i in range(2**w):
    for j in range(2**h):
        grid = [k[:] for k in A]
        cnt = 0
        for p in range(h):
            if (j >> p) & 1:
                grid[p] = ["r"]*w
        for q in range(w):
            if (i >> q) & 1:
                for b in grid:
                    b[q] = "r"
        for x in grid:
            cnt += x.count("#")
        if cnt == k:
            ans += 1
print(ans)

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

const ll INF = 1000000009;

void solve(){
  ll ans = 0;
  int n;
  cin >> n;
  for(int i = 0; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0)  ans += i;
  }
  cout << ans << "\n";
}

int main(){
#ifndef LOCAL
  ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  // int t;cin >> t;while(t--) solve();
  solve();
}


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

int main(){
  int n, m, min, max;
  int a,b;
  min = 1;

  cin >> n >> m;
  
  max = n;
  
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    if ( min < a ){
      min = a;
    }
    if (b < max ){
      max = b;
    }
  }
  if (min <= max){
	  cout << max - min + 1 << endl;
  }else{
    cout << '0' << endl;
  }
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<list>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
#define ao(a) (a.begin(),a.end())
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int n,m;
vector<int> v[100010];
vector<int> lj;
int sss[100010];
int fi;

bool dfs(int now,int last){
	lj.pb(now);
	sss[now]=1;
	if(now==n){
		fi=lj[(lj.size()+1)/2];
	}
	for(int i=0;i<v[now].size();i++)
		if(v[now][i]!=last){
			dfs(v[now][i],now);
			sss[now]+=sss[v[now][i]];
		}
	lj.ppb();
	return false;
}

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	cin>>n;
	m=n-1;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1,-1);
	if(sss[fi]*2<n)
		cout<<"Fennec";
	else
		cout<<"Snuke";
	return 0;
}


Measured memory_bytes: 11384
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int main()
{
    int n,cnt=0,d[110];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n,greater<int>());
    for(int i=0;i<n;i++){
        if(d[i]!=d[i+1])
        cnt++;
    }
    cout<<cnt<<endl;
}

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

int n;

struct Node
{
  int id = -1, parent = -1, left = -1, right = -1;
};

vector<Node> nodes(25);

void preorder(queue<int> &Q, Node u)
{
  // ベースケース
  if (u.left == -1 && u.right == -1)
  {
    // uが葉のとき
    Q.push(u.id);
    return;
  }
  // 再帰ステップ
  Q.push(u.id);
  if (u.left != -1)
  {
    // 左に子が存在するとき
    preorder(Q, nodes.at(u.left));
  }
  if (u.right != -1)
  {
    // 右に子が存在するとき
    preorder(Q, nodes.at(u.right));
  }
  return;
}

void inorder(queue<int> &Q, Node u)
{
  // ベースケース
  if (u.left == -1 && u.right == -1)
  {
    // uが葉のとき
    Q.push(u.id);
    return;
  }
  // 再帰ステップ
  if (u.left != -1)
  {
    // 左に子が存在するとき
    inorder(Q, nodes.at(u.left));
  }
  Q.push(u.id);
  if (u.right != -1)
  {
    // 右に子が存在するとき
    inorder(Q, nodes.at(u.right));
  }
  return;
}

void postorder(queue<int> &Q, Node u)
{
  // ベースケース
  if (u.left == -1 && u.right == -1)
  {
    // uが葉のとき
    Q.push(u.id);
    return;
  }
  // 再帰ステップ
  if (u.left != -1)
  {
    // 左に子が存在するとき
    postorder(Q, nodes.at(u.left));
  }
  if (u.right != -1)
  {
    // 右に子が存在するとき
    postorder(Q, nodes.at(u.right));
  }
  Q.push(u.id);
  return;
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int id, left, right;
    cin >> id >> left >> right;
    nodes.at(id).id = id;
    nodes.at(id).left = left;
    nodes.at(id).right = right;
    if (left != -1)
    {
      nodes.at(left).parent = id;
    }
    if (right != -1)
    {
      nodes.at(right).parent = id;
    }
  }

  Node root;
  for (int i = 0; i < n; i++)
  {
    if (nodes.at(i).parent == -1)
    {
      root = nodes.at(i);
      break;
    }
  }

  queue<int> Q;
  preorder(Q, root);
  cout << "Preorder" << endl;
  cout << " ";
  for (int i = 0; i < n; i++)
  {
    cout << Q.front();
    Q.pop();
    if (i == n - 1)
    {
      cout << endl;
    }
    else
    {
      cout << " ";
    }
  }
  inorder(Q, root);
  cout << "Inorder" << endl;
  cout << " ";
  for (int i = 0; i < n; i++)
  {
    cout << Q.front();
    Q.pop();
    if (i == n - 1)
    {
      cout << endl;
    }
    else
    {
      cout << " ";
    }
  }
  postorder(Q, root);
  cout << "Postorder" << endl;
  cout << " ";
  for (int i = 0; i < n; i++)
  {
    cout << Q.front();
    Q.pop();
    if (i == n - 1)
    {
      cout << endl;
    }
    else
    {
      cout << " ";
    }
  }
}


Measured memory_bytes: 3132
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main{
	
	Map<Integer, Integer> number_of_cards;
	
	Main(int... cards){
		this.number_of_cards = new HashMap<Integer, Integer>();
		for(int c = 1; c <= 13; c++) this.number_of_cards.put(c, 0);
		for(int i: cards) this.number_of_cards.put(i, this.number_of_cards.get(i) + 1);
	}
	
	Poker judge() {
		//onepair, twopair, threecard, fourcard, fullhouse
		int num_pair = 0;
		int num_three = 0;
		int num_four = 0;
		for(Map.Entry<Integer, Integer> e: this.number_of_cards.entrySet()) {
			if(e.getValue() == 2) num_pair++;
			else if(e.getValue() == 3) num_three++;
			else if(e.getValue() == 4) num_four++;
		}
		
		//straight
		boolean straight = false;
		out: for(int c = 1; c <= 9; c++) {
			for(int i = c; i < c+5; i++) {
				if(this.number_of_cards.get(i) != 1) continue out;
			}
			straight = true;
			break;
		}
		
		//straight 10 J Q K A
		out: if(this.number_of_cards.get(1) == 1) {
			for(int c = 10; c <= 13; c++) {
				if(this.number_of_cards.get(c) != 1) break out;
			}
			straight = true;
		}
		
		//judge
		if(num_four == 1) return Poker.FOURCARDS;
		else if(num_three == 1 && num_pair == 1) return Poker.FULLHOUSE;
		else if(straight) return Poker.STRAIGHT;
		else if(num_three == 1) return Poker.THREECARDS;
		else if(num_pair == 2) return Poker.TWOPAIR;
		else if(num_pair == 1) return Poker.ONEPAIR;
		else return Poker.NULL;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String line = sc.nextLine();
			Scanner scstr = new Scanner(line);
			scstr.useDelimiter(",");
			
			int[] cards = new int[5];
			for(int i = 0; i < cards.length; i++) {
				cards[i] = scstr.nextInt();
			}
			scstr.close();
			
			System.out.println(new Main(cards).judge());
			scstr.close();
		}
		sc.close();
	}
	
}



enum Poker{
	NULL("null"), ONEPAIR("one pair"), TWOPAIR("two pair"), THREECARDS("three card"), 
	STRAIGHT("straight"), FULLHOUSE("full house"), FOURCARDS("four card");
	
	String name;
	
	public String toString() {
		return this.name;
	}
	
	Poker(String str) {
		this.name = str;
	}
}

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

int main() {
	int a, b;	
	cin >> a >> b;
	
	if (a < b)
		cout << "a < b" << endl;
	else if (a > b)
		cout << "a > b" << endl;
	else
		cout << "a == b" << endl;
	
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 100
using namespace std;

int main(void) {
  int N;
  cin >> N;
  int H[MAX_N];
  rep(i, N) { cin >> H[i]; }

  int Ans = 0;
  int lp = 0;
  int rp = N - 1;
  while (1) {
    while (lp <= rp && H[lp] == 0)
      lp++;
    while (lp < rp && H[rp] == 0)
      rp--;
    if (lp > rp)
      break;

    int minH = H[lp];
    int m;
    for (m = lp+1; m <= rp; m++) {
      if (H[m] == 0)
        break;
      minH = min(minH, H[m]);
    }
    for (int i = lp; i < m; i++) {
      H[i] -= minH;
    }
    Ans += minH;
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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() {
    int n, m; cin >> n >> m;
    int two = 1; rep(i, m) two *= 2;
    cout << (1900*m + 100*(n-m))*two;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int Fibonacci(int);

int main(){
  int n;

  scanf("%d",&n);
  if( n<1 || 44<n ) exit(1);

  printf("%d\n",Fibonacci(n));
  return 0;
}

int Fibonacci(int x){
  static int F[45]={};

  if( x==1 || x==0 ){
    F[x] = 1;
    return F[x];
  }

  if( F[x] != 0 ){
    return F[x];
  }

  F[x] = Fibonacci(x-2) + Fibonacci(x-1);

  return F[x];
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> aString = Arrays.asList(br.readLine().split(""));
            List<String> bString = Arrays.asList(br.readLine().split(""));

            List<Integer> A = new ArrayList<>();
            for (String str : aString) {
                A.add(Integer.parseInt(str));
            }

            List<Integer> B = new ArrayList<>();
            for (String str : bString) {
                B.add(Integer.parseInt(str));
            }

            String ans = "EQUAL";
            if (A.size() > B.size()) {
                ans = "GREATER";
            } else if (A.size() < B.size()) {
                ans = "LESS";
            } else if (A.size() == B.size()) {
                for (int i = 0; i < A.size(); i++) {
                    if (A.get(i) == B.get(i)) {
                        continue;
                    } else if (A.get(i) > B.get(i)) {
                        ans = "GREATER";
                        break;
                    } else if (A.get(i) < B.get(i)) {
                        ans = "LESS";
                        break;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23124
D, N = (int(i) for i in input().split())
A = 100 * N
B = 10000 * N
if N == 100:
  if D == 0:
    print(101)
  if D == 1:
    print(10100)
  if D == 2:
    print(1010000)
elif D == 0:
    print(N)
elif D == 1:
    print(A)
else:
    print(B)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

short getshortest(short a, short b, short c)
{
	if (a <= b && a <= c){
		return (a);
	}
	else if (b <= c && b <= a){
		return(b);
	}
	return(c);
}

int main(void)
{
	char map[1000][1000];
	static short sq[1000][1000];
	int i, j;
	int n;
	int max;
	
	while (1){
		scanf("%d", &n);
		
		if (!n){
			break;
		}
		
		for (i = 0; i < n; i++){
			memset(map[i], '\0', sizeof(map[i]));
			memset(sq[i], 0, sizeof(sq[i]));
			scanf("%s", map[i]);
		}
		
		max = 0;
		
		for (i = 0; i < n; i++){
			sq[i][0] = map[i][0] == '.' ? 1 : 0;
			sq[0][i] = map[0][i] == '.' ? 1 : 0;
			if (sq[i][0] == 1 || sq[0][i] == 1){
				max = 1;
			}
		}
		
		for (i = 1; i < n; i++){
			for (j = 1; j < n; j++){
				if (map[i][j] == '*'){
					sq[i][j] = 0;
				}
				else {
					sq[i][j] = getshortest(sq[i][j - 1], sq[i - 1][j], sq[i - 1][j - 1]) + 1;
					if (sq[i][j] > max){
						max = sq[i][j];
					}
				}
			}
		}
		printf("%d\n", max);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>

#include<algorithm>

using namespace std;

int N;

pair<long,int>A[2000];

long dp[2001][2001];

main()

{

	cin>>N;	for(int i=0;i<N;i++)

	{

		cin>>A[i].first;

		A[i].second=i;

	}

	sort(A,A+N);

	reverse(A,A+N);

	for(int i=0;i<N;i++)

	{

		for(int j=0;j<=i;j++)

		{

			int k=N-(i-j);

			dp[j+1][k]=max(dp[j+1][k],dp[j][k]+A[i].first*abs(A[i].second-j));

			dp[j][k-1]=max(dp[j][k-1],dp[j][k]+A[i].first*abs(A[i].second-(k-1)));

		}

	}

	long ans=0;

	for(int i=0;i<=N;i++)ans=max(ans,dp[i][i]);

	cout<<ans<<endl;

}

Measured memory_bytes: 26284
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>



using ll = long long;


using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}
	
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int factorial(ll n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else
		return 1;
}
int main()
{/*9日目*/
	int n, m; cin >> n >> m;
		vector<pair<int,int>> pp(m);
	for (int i = 0;i < m;i++) {
		cin >> pp[i].first >> pp[i].second;
}//条件列挙
	for (int x = 0;x < 1000;x++) {
		int keta = 1;
		int nx = x / 10;
		vector<int> d(1, x %10);
		while (nx)
		{
			d.push_back(nx%10);
			nx /= 10;
			keta++;
		}
		if (keta != n) continue;
		reverse(d.begin(), d.end());
		bool ok = true;
		for (int i = 0;i < m;i++) {
			if (d[0,pp[i].first - 1] != pp[i].second) ok = false;
		}if (ok) {
			cout << x;
			return 0;
		}
	}
	cout << "-1";
	return 0;
	
	
}
	
	


Measured memory_bytes: 256
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range(D)]

# 初期化
Ans = 0 # 満足度
last = [-1]*26

# 満足度を計算
for d in range(D):
    max_ans = -999999999
    max_i = 0
    # 開催するコンテストID
    for contest_id in range(26):
        ans = 0
        # 満足度をプラス
        ans += S[d][contest_id]
        # 開催されなかったコンテストの処理
        for i in range(26):
            if i != contest_id:
                ans -= C[i]*(d - last[i])
        # 大きい方をとる
        if ans > max_ans:
            max_ans = ans
            max_i = contest_id
    # 最終開催日を更新
    last[max_i] = d
    # 出力
    print(max_i + 1)
#    Ans += max_ans
#    print(Ans)

Measured memory_bytes: 9420
n = int(input())
l = {}
max = 0
for _ in range(n):
  s = input()
  l[s] = l.get(s, 0) + 1
  if max < l[s]:
    max = l[s]

for i in sorted(list(filter(lambda s: l[s] == max, l.keys()))):
  print(i)


Measured memory_bytes: 96604
def grading(m, f, r):
    if m == -1 or f == -1:
        return 'F'

    total = m + f
    if total < 30:
        return 'F'
    elif total < 50:
        if 50 <= r:
            return 'C'
        return 'D'
    elif total < 65:
        return 'C'
    elif total < 80:
        return 'B'
    else:
        return 'A'

if __name__ == "__main__":
    while True:
        m, f, r = map(int, input().split())
        if m == f == r == -1:
            break

        print(grading(m, f, r)) 


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;

  ll ans = min(abs(n % k), abs((n % k) - k));

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dl;
#define pb push_back
#define F first
#define S second
#define inf 1e18
#define mod 1000000007
#define PI 3.1415926536
#define vll vector <ll>
#define pll pair <ll,ll>
#define dbg(n) cout<<n<<' '
#define cu continue
#define br break
#define N 1000005
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    string s;
    cin>>s;
    ll a=0,b=0;
    for(ll i=0;i<3;i++)
    {
        if(s[i]=='A') a++;
        else b++;
    }
    if(a==0 || b==0) cout<<"No\n";
    else cout<<"Yes\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC171Test
{
    class Program
    {
        static void Main()
        {
            var buf = Console.ReadLine().Trim().Split();
            int N = int.Parse(buf[0]);
            int K = int.Parse(buf[1]);
            List<int> p=new List<int>();
            buf = Console.ReadLine().Trim().Split();
            foreach (var bf in buf) {
                p.Add(int.Parse(bf));
            }
            int sum = 0;
            int k = K;
            while (k-- > 0) {
                var min = p.Min();
                p.Remove(min);
                sum += min;
            }
            Console.WriteLine(sum);

        }


    }

}


Measured memory_bytes: 28468
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	var p, q, t int
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		p = p*10 + t
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		q = q*10 + t
	}

	ps := make([]int, 0)
	var dfs func(s int)
	dfs = func(s int) {
		a := fmt.Sprint(s)
		if len(a) == n {
			ps = append(ps, s)
			return
		}
		for i := 1; i <= n; i++ {
			if !strings.Contains(a, fmt.Sprint(i)) {
				dfs(s*10 + i)
			}
		}
	}
	dfs(0)

	pi, qi := 0, 0
	for i := 0; i < len(ps); i++ {
		if ps[i] == p {
			pi = i + 1
		}
		if ps[i] == q {
			qi = i + 1
		}
	}

	ans := abs(pi - qi)
	fmt.Println(ans)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main()
{
    int N, S, ans, vmax, vmin, sum, x, y;
    while(true){
        cin >> N;
        if (N == 0) break;
        cin >> x >> y;
        vmin = min(x,y);
        vmax = max(x,y);
        sum = x + y;
        
        for (int i=0; i< N - 2;i++){
            cin>>S;
            vmin = min(vmin, S);
            vmax = max(vmax, S);
            sum+=S;
        }
        sum -= (vmin+vmax);
        cout << sum / (N-2)<<endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        cout << s << '\n' << s << '\n';
    }
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 2000 + 10;

string maze[lim];

int ver[lim][lim];
int hor[lim][lim];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0; i<h; i++) cin >> maze[i];

    for(int y=1; y<=h; y++){
        for(int x=1; x<=w; x++){
            if(maze[y-1][x-1] == '.') hor[y][x] += hor[y][x-1] + 1;
        }
    }
    for(int y=1; y<=h; y++){
        for(int x=w; x>0; x--){
            if(hor[y][x-1] != 0 && hor[y][x] != 0) hor[y][x-1] = hor[y][x];
        }
    }

    for(int x=1; x<=w; x++){
        for(int y=1; y<=h; y++){
            if(maze[y-1][x-1] == '.') ver[y][x] += ver[y-1][x] + 1;
        }
    }
    for(int x=1; x<=w; x++){
        for(int y=h; y>0; y--){
            if(ver[y-1][x] != 0 && ver[y][x] != 0) ver[y-1][x] = ver[y][x];
        }
    }

    int ans = 0;

    for(int y=1; y<=h; y++){
        for(int x=1; x<=w; x++){
            if(maze[y-1][x-1] == '.') ans = max(ans, hor[y][x] + ver[y][x] - 1);
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> p(n), used;
  rep(i,n)cin>>p[i];
  int result=0, c_min=p[0];

  rep(i,n){
    if(p[i]<=c_min){
      result++;
      c_min=min(c_min, p[i]);
    }
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 1024
e1,e2,e3,e4 = map(int,input().split())
if e1==e2 and e3==e4:
    print("yes")
elif e1==e3 and e2==e4:
    print("yes")
elif e1==e4 and e2==e3:
    print("yes")
else:
    print("no")


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

int main(){
  int X, Y;
  cin >> X >> Y;
  bool flg = false;
  int c=X, t;
  
  rep(i,X){
    if(i * 2 + (X-i) *4 ==Y){
     flg = true;
      break;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3580
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

typedef complex<double> P;

int main(){
	P p(0,0),v(0,1);
	int x,y;
	while(1){
		scanf("%d,%d", &x, &y);
		if(x==0 && y==0){
			double rx = floor(real(p));
			if(rx<0)rx+=1.01;
			double ry = floor(imag(p));
			if(ry<0)ry+=1.01;
			printf("%.0f\n%.0f\n", rx, ry);
			break;
		}
		p+=v*P(x*1.0, 0.0);
		v*=P(cos(-y*1.0/180.0*acos(-1.0)), sin(-y*1.0/180.0*acos(-1.0)));
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,k,l,o,p;
    cin>>n>>m>>k;
    vector<ll> a,b;
    a.push_back(0);
    b.push_back(0);
    for(ll i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x;
        y=x+a[i-1];
        a.push_back(y);
    }
    for(ll i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x;
        y=x+b[i-1];
        b.push_back(y);
    }
    ll ans=0;
    o=m;
    for(ll i=0;i<=n;i++)
    {
        for(ll j=o;j>=0;j--){
            if(a[i]+b[j]<=k){
                o=j;
                if(i+j>ans){
                    ans=i+j;
                }
                break;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 7976
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def best(string):
    dp = [[-1, -1, -1] for i in range(len(string))]
    dp[0][0] = R if string[0] == 's' else 0
    dp[0][1] = P if string[0] == 'r' else 0
    dp[0][2] = S if string[0] == 'p' else 0
    for i in range(1, len(string)):
        dp[i][0] = (R if string[i] == 's' else 0) + max(dp[i-1][1], dp[i-1][2])
        dp[i][1] = (P if string[i] == 'r' else 0) + max(dp[i-1][0], dp[i-1][2])
        dp[i][2] = (S if string[i] == 'p' else 0) + max(dp[i-1][0], dp[i-1][1])
    # print(string, dp)
    return max(dp[-1])

strings = []
for i in range(K):strings.append(T[i::K])

print(sum(map(best, strings)))


Measured memory_bytes: 62172
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var joinFirst = s[0][0].ToString() + s[1][0].ToString() + s[2][0].ToString();
            Console.WriteLine(joinFirst.ToUpper());
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
a = list(map(int, input().split()))

alice, bob = 0, 0

for i in range(len(a)):
    if i % 2 == 0:
        alice += max(a)
        a.remove(max(a))
    else:
        bob += max(a)
        a.remove(max(a))

print(alice - bob)

Measured memory_bytes: 3060
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {

			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			double d = sc.nextDouble();
			double e = sc.nextDouble();
			double f = sc.nextDouble();

			double x,y;

			/*クラメルの公式*/

			x = ((c*e)-(b*f))/((a*e)-(b*d));
			y = ((a*f)-(c*d))/((a*e)-(d*b));
			
			BigDecimal bd1 = new BigDecimal(x);
			BigDecimal bd2 = new BigDecimal(y);
			
			BigDecimal x_bd = bd1.setScale(3,BigDecimal.ROUND_UP);
			BigDecimal y_bd = bd2.setScale(3,BigDecimal.ROUND_UP);
			
			String x_ans = x_bd.toString().format("%.3f", x_bd);
			String y_ans = y_bd.toString().format("%.3f", y_bd);

			System.out.println(x_ans+ " " +y_ans);
		}
	}
}

Measured memory_bytes: 20612