akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m;
char num[50][50];
 int dfs(int i,int j){
    if(i>=1&&num[i-1][j]=='#') return 1;
    else if(i<=n-2&&num[i+1][j]=='#') return 1;
    else if(j>=1&&num[i][j-1]=='#') return 1;
    else if(j<=m-2&&num[i][j+1]=='#') return 1;
    return 0;
 }
int main()
{
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>num[i][j];
            if(num[i][j]=='#') sum++;
        }
    }
    if(sum==0) {
        cout<<"Yes"<<endl;
        return 0;
    }
    int t=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(num[i][j]=='#'){
                t=dfs(i,j);
                if(t==0){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin>>a>>b;
    if(a==2)a=1;
    else if(a==4||a==6||a==9||a==11)a=2;
    else a=3;
    if(b==2)b=1;
    else if(b==4||b==6||b==9||b==11)b=2;
    else b=3;
    if(a==b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
int plus(int data[], int start, int num) {
  int sum = 0;
  for (int i = start; i < start+num; i++) {
    sum += data[i];
  }
  return sum;
}

int main(){
  int N;
  int i, j;
  scanf("%d", &N);
  while (N != 0) {
    int data[1000] = {0};
    int ctr = 0;
    for (i = 0; i < N; i++) {
      data[i] = i;
    }
    int sum = 0;
    for (i = 1; i < N-1; i++) { //?§?????±????
      for (j = 1; j <= N-i; j++) { //?????°?±????
        
        sum = plus(data,i,j);
        //    printf("sum = %d\n",sum);
        if (sum == N) {
          ctr++;
        }
      }
    }
    printf("%d\n", ctr);
    scanf("%d", &N);
  }
  return 0;
}

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

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u) cout << a- 1 << " "<< b << endl;
    else cout << a << " "<<b - 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int main ()
{
	int a[100001],b[100001],n,m,k,t,i,j,c,d,e=0,f;
		scanf ("%d%d%d",&n,&m,&k);
		if (m==1) printf ("%d",n);
		else {
		
	for (i=0;i<n;i++)
	scanf ("%d",&a[i]);
	qsort(a,n,sizeof a[0],cmp);
	for (i=0;i<n;i++)
	{
		for (c=i,d=i+1;d-c<m&&a[d]-a[c]<=k&&d<n;d++)
		{
		}
		e++;
		i=d-1;
	}
	printf ("%d",e);
}
	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main()
{
	int n;
	int a;
	int count = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &a);
		if (i % 2 != 0 && a % 2 != 0)
			count++;
	}

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

	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define il inline
#define ll long long
const int N=605,P=1e9+7;

int n,K,ans,to[N],s[N],f[N][N],g[N];

il int cal(int l,int r)
{
	if ((s[r]-s[l-1]&1)||(r-l+1&1)) return 0; int i;
	for (i=l; i<=r; i++) if (to[i]&&(to[i]<l||to[i]>r)) return 0;
	f[l][r]=g[s[r]-s[l-1]>>1];
	for (i=l+1; i<r; i++) f[l][r]=(f[l][r]-(ll)f[l][i]*g[s[r]-s[i]>>1]%P+P)%P;
	return (ll)f[l][r]*g[s[l-1]+s[n]-s[r]>>1]%P;
}

int main()
{
	scanf("%d%d",&n,&K),n+=n; int i,j,u,v;
	for (i=1; i<=K; i++) scanf("%d%d",&u,&v),to[u]=v,to[v]=u;
	for (i=1; i<=n; i++) s[i]=s[i-1]+(!to[i]);
    for (i=g[0]=1; i<N; i++) g[i]=(ll)g[i-1]*(i+i-1)%P;
	
	for (i=1; i<=n; i++) for (j=i+1; j<=n; j++) ans=(ans+cal(i,j))%P;
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 5128
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var bells = new[] { consoleReader.Int, consoleReader.Int, consoleReader.Int };
            Array.Sort(bells);
            return bells[1] + bells[0];
        }


        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 5e2 + 10;

long long ans, n, k;
int main()
{
    cin >> n >> k;

    if (k == 0)
        ans = n * n;
        else
    for (int b = k + 1; b <= n; b++)
    {
        ans += (n / b) * (b - k);
        if (n % b >= k)
            ans += n % b - k + 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define ll long long 
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//typedef long long  MOD=1000000009;
ll MOD=998244353;
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void iofoj(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}


void solution()
{
    ll k,i,j,h,m,w,n;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    ll sum[n+2]={0};
    ll mod=1000000007;
    for(i=n;i>0;i--)
    sum[i]=sum[i+1]+a[i],sum[i]%=mod;
    ll ans=0;
    
    for(i=1;i<=n;i++)
    {
        ans+=((a[i]%mod)*(sum[i+1]%mod))%mod;
        ans%=mod;
    }
    cout<<ans;
}

int main(){
    fio
    //iofoj();
    // ll t;
    // cin>>t;
    // while(t--)
    solution();
    return 0; 
}





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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int x = 0;
            int max =0;
            string input = Console.ReadLine();
            foreach (char c in input)
            {
                if (c == 'I')
                {
                    ++x;
                    if (x > max) max = x;
                }
                else
                    --x;
            }
            Console.WriteLine(max.ToString());
        }
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    fastio;
    ll ans=0, N;
    cin >> N;
    set<string> m;
    string s;
    rep(i,N) {
        cin >> s;
        m.insert(move(s));
    }
    ans = m.size();
    cout << ans << endl;
}


Measured memory_bytes: 19260
class Depth_First_Search:
    def __init__(self, bolls):
        self.bolls = bolls
        self.possible = False

    def search(self, left, right, remaining):
        if len(remaining) == 0:
            self.possible = True
        else:
            boll = remaining[0]
            if boll > max(left):
                self.search(left+[boll], right, remaining[1:])
            if boll > max(right):
                self.search(left, right+[boll], remaining[1:])

    def run(self):
        self.search([-1], [-1], self.bolls)

if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        bolls = list(map(int, input().split(' ')))
        DFS = Depth_First_Search(bolls)
        DFS.run()
        if DFS.possible:
            print('YES')
        else:
            print('NO')

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    IOS;
    ll ans=0;
    rep(i,5)
    {
        ll a;
        cin>>a;
        if(a==0) ans=i;
    }
    cout<<ans+1;
}


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

int main(){
  //入力
  string S;
  cin >> S;
  //処理
  string T="ACGT";
  
  int ans=0;//ATCG文字列の最大長
  int now=0;//今見ている文字列を末尾とするATCG文字列の最大長
 
 for(int i = 0; i <(int) S.size(); i++) { 
     bool isACGT=false;
       for(int j=0;j<(int)T.size();j++){
         if(S[i]==T[j]) isACGT=true;
          }
    
       if(!isACGT){
         now=0;
       } 
       else{
         //ATCG文字列の場合は、1を足す。
         now++;
         //最大値を更新する
         ans=max(now,ans);
       }          
   }
   cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct SCC{//O(V+E)
    static const int MAX_V = 1e5+10;
    int V;
    vector<int> G[MAX_V], rG[MAX_V];
    vector<int> vs;
    bool used[MAX_V];
    int cmp[MAX_V];
    vector<vector<int> > res;


    SCC(int v) : V(v){assert(v < MAX_V);};
    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }

    void dfs(int v){
        used[v] = true;
        for(int i = 0; i < G[v].size(); i++){
            if(!used[G[v][i]]) dfs(G[v][i]);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k){
        used[v] = true;
        cmp[v] = k;
        for(int i = 0; i < rG[v].size(); i++){
            if(!used[rG[v][i]]) rdfs(rG[v][i], k);
        }
    }

    int scc(){
        memset(used, 0, sizeof(used));
        vs.clear();
        for(int v = 0; v < V; v++){
            if(!used[v]) dfs(v);
        }
        memset(used, 0, sizeof(used));
        int k = 0;
        for(int i = vs.size() - 1; i >= 0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++);
        }

        res.clear();
        res.resize(k);
        for(int i = 0; i < V; i++){
            res[cmp[i]].push_back(i);
        }
        return k;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    SCC scc(n);
    rep(i, n + m -1) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        scc.add_edge(u, v);
    }
    auto k = scc.scc();
    vi par(n);
    repr(i, k) {
        for(auto&& v : scc.res[i]) {
            int a = -1, b = -1;
            for(auto&& p : scc.rG[v]) {
                if(b < scc.cmp[p]) {
                    b = scc.cmp[p];
                    a = p;
                }
            }
            if(a != -1) par[v] = a+1;
        }
    }
    rep(i, n) cout << par[i] << endl;
    // cout << endl;
    // rep(i, n) cout << scc.cmp[i] << endl;
    return 0;
}

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

int main(){
  int A,B;
  cin >>A>>B;
  
  string ans;
  
  if(A==1) A=14;
  if(B==1) B=14;
  
  if(A==B) ans = "Draw";
  else if(A>B) ans = "Alice";
  else if(A<B) ans = "Bob";
  
  cout <<ans<<endl;
}


Measured memory_bytes: 256
a,b,k = map(int,input().split())
li = []
for i in range(k):
    if a <= a+i <= b:
        li.append(a+i)
for i in range(k):
    if a <= b+i+1-k <= b:
        li.append(b+i+1-k)
li = list(set(li))
li.sort()
for i in li:
    print(i)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  char s[102], t[102];
  scanf("%s %s", s, t);
  int ans = 0;
  for(int i=0; i<n; i++){
    int flag = 1;
    for(int j=0; j+i<n; j++)
      if(s[j+i] != t[j]){
	flag = 0;
	break;
      }
    if(flag){
      ans = i + n;
      break;
    }
  }
  if(!ans)  ans = n * 2;

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


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

typedef struct{
	string prod ;
	int num ;
}Prod_st;

int N;
Prod_st tmp;
vector<Prod_st> VC ;
map<string,int> MP ;

bool operator<( const Prod_st& a , const Prod_st& b ){
	return (a.prod.size()==b.prod.size())?(a.prod<b.prod):(a.prod.size()<b.prod.size());
}
bool operator>( const Prod_st& a , const Prod_st& b ){
	return (a.prod.size()==b.prod.size())?(a.prod>b.prod):(a.prod.size()>b.prod.size());
}

int main(){
	
	cin >> N;
	while( N-- ){
		cin >> tmp.prod >> tmp.num ;
		if( MP[tmp.prod]==0 ){
			VC.push_back( tmp ) ;
			MP[tmp.prod] = VC.size();
		}else VC[MP[tmp.prod]-1].num += tmp.num ;
	}
	
	sort( VC.begin() , VC.end() ) ;
	for( int i=0 ; i<VC.size() ; i++ ){
		cout << VC[i].prod << " " << VC[i].num << endl ;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

void bfs(int start_node_id, const vector<vector<int>>& g, vector<int>& color,
         vector<int>& d) {
  int u;
  queue<int> q;
  d[start_node_id] = 0;
  color[start_node_id] = 1;
  q.push(start_node_id);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (auto v : g[u]) {
      if (color[v] == 0) {
        q.push(v);
        color[v] = 1;
        d[v] = d[u] + 1;
      }
    }
    color[u] = 1;
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> S[i][j];
    }
  }
  debug(S);
  vector<vector<int>> g(H * W);
  int idx = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (S[i][j] == '#') {
        idx++;
        continue;
      }
      if (S[i][j - 1] == '.') {
        g[idx].push_back(idx - 1);
      }
      if (S[i][j + 1] == '.') {
        g[idx].push_back(idx + 1);
      }
      if (S[i - 1][j] == '.') {
        g[idx].push_back(idx - W);
      }
      if (S[i + 1][j] == '.') {
        g[idx].push_back(idx + W);
      }
      idx++;
    }
  }
  debug(g);
  int ans = 0;
  for (int i = 0; i < H * W; i++) {
    vector<int> color(H * W), d(H * W);
    bfs(i, g, color, d);
    int tmp = *max_element(d.begin(), d.end());
    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N%10==9)
  {
    cout << "Yes" << endl;
    return 0;
  }
  else
  {
    N /= 10;
    if(N==9)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

#define RT3 1.7320508075


struct point {
    double x, y;
};


void print_point(point p)
{
    printf("%.08f %.08f\n", p.x, p.y);
}


void koch(point l, point r, int depth)
{
    if (depth == 0)
        return;

    double th = M_PI * 60.0 / 180.0;

    point new_l, new_r, middle;

    new_l.x = (2.0 * l.x + 1.0 * r.x) / 3.0;
    new_l.y = (2.0 * l.y + 1.0 * r.y) / 3.0;
    new_r.x = (1.0 * l.x + 2.0 * r.x) / 3.0;
    new_r.y = (1.0 * l.y + 2.0 * r.y) / 3.0;
    middle.x = (new_r.x - new_l.x) * cos(th) - (new_r.y - new_l.y) * sin(th) + new_l.x;
    middle.y = (new_r.x - new_l.x) * sin(th) + (new_r.y - new_l.y) * cos(th) + new_l.y;


    koch(l, new_l, depth - 1);

    print_point(new_l);
    koch(new_l, middle, depth - 1);

    print_point(middle);
    koch(middle, new_r, depth - 1);

    print_point(new_r);
    koch(new_r, r, depth - 1);
}


int main()
{
    int n;
    cin >> n;
    point l, r;

    l.x = 0;
    l.y = 0;
    r.x = 100;
    r.y = 0;

    print_point(l);
    koch(l, r, n);
    print_point(r);
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define pii     pair<ll,ll>
#define vi      vector<ll>
#define mp      make_pair
#define pb      push_back
#define F       first
#define S       second
#define pf(n)   printf("%lld\n",n)
#define sf(n)   scanf("%lld",&n)
#define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)  x.begin(),x.end()
#define ms(n,i) memset(n,i,sizeof n)
#define sz(x)   (ll)x.size()
#define pi      3.141592653589793238
#define hell    1000000007
#define hell2   1000000009
#define endl    '\n'
#define inf     1e18
#define N       100005

ll dp[1005][1005];
int main()
{   
    ll h,w,i,j,k;
    cin>>h>>w;
    string s[h];
    for(i=0;i<h;i++){
        cin>>s[i];
    }
    dp[0][0]=1;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i)dp[i][j]+=dp[i-1][j];
            if(j)dp[i][j]+=dp[i][j-1];
            if(s[i][j]=='#')dp[i][j]=0;
          	dp[i][j]%=hell;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define int long long

using namespace std;

int a[100][100];
int c[100];

signed main(){
    int n, m, x;
    cin >> n >> m >> x;

    for(int i = 1; i <= n; i++){
        cin >> c[i];
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }

    vector<int> dp(n + 3, 0);

    int ans = 1e9;
    while(dp[0] == 0){
        int pos = n;
        while(dp[pos] == 1){
            dp[pos] = 0;
            pos--;
        }
        dp[pos] = 1;

        int sum = 0;
        vector<int> v(n + 3, 0);
        for(int i = 1; i <= n; i++){
            if(dp[i]){
                sum += c[i];
                for(int i1 = 1; i1 <= m; i1++){
                    v[i1] += a[i][i1];
                }
            }
        }

        int f = 1;
        for(int i = 1; i <= m; i++){
            if(v[i] < x){
                f = 0;
                break;
            }
        }
        if(f){
            ans = min(ans, sum);
        }
    }

    if(ans != 1e9){
        cout << ans;
    }
    else{
        cout << -1;
    }
    return 0;
}


Measured memory_bytes: 3628
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE Strict #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L
import Data.Maybe

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [n] = sum [f a b c | a <- [1..n], b <- [1..n], c <- [1..n]]
  where
    f 1 _ _ = 1
    f _ 1 _ = 1
    f _ _ 1 = 1
    f a b c = gcd (gcd a b) c

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    int h,w,d;cin>>h>>w>>d;
    int g[h][w];
    pint number[h*w+1]={};
    rep(i,h){
        rep(j,w){
            cin>>g[i][j];
            number[g[i][j]]=(make_pair(i,j));
        }
    }
    int dist[h*w+1]={};
    for(int i=d+1;i<h*w+1;i++){
        dist[i]=dist[i-d]+abs(number[i].first-number[i-d].first)+abs(number[i].second-number[i-d].second);
    }
    int q;cin>>q;
    pint lr[q]={};
    rep(i,q) cin>>lr[i].first>>lr[i].second;
    rep(i,q){
        int ans=dist[lr[i].second]-dist[lr[i].first];
        cout<<ans<<"\n";
    }
}


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

using namespace std;

vector<vector<int>> graph;
vector<int> ret;
vector<bool> visited;

void dfs(int from, int x) {
    x += ret[from];
    ret[from] = x;
    visited[from] = true;

    for (auto to:graph[from]) {
        if (!visited[to])dfs(to, ret[from]);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    graph = vector<vector<int>>(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ret = vector<int>(n);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        ret[p - 1] += x;
    }
    visited = vector<bool>(n);
    dfs(0, 0);

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

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

const int INF = 1e9;

// pair -> cost, to
using P = pair<int, int>;

vector<int> dijkstra(const int start,const int N,const vector<P>* G) {
    vector<int> dist(N, INF);
    vector<bool> used(N, false);
    dist[start] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,start));
    while(!que.empty()) {
        int d, v;
        tie(d, v) = que.top();
        que.pop();
        if (used[v]) continue;
        used[v] = true;
        dist[v] = d;
        for (const P& e: G[v]) {
            if (dist[e.second] <= d + e.first) continue;
            que.push(P(d + e.first, e.second));
        }
    }
    return dist;
}

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

    int V, E, start;
    cin >> V >> E >> start;
    vector<P> G[V];
    for (int i = 0; i < E; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        G[from].push_back(P(cost, to));
    }
    auto d = dijkstra(start, V, G);
    for (int i = 0; i < d.size(); i++) {
        if (d[i] >= INF)  cout << "INF" << endl;
        else cout << d[i] << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

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




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

int main(){
	char alpha;
	cin >> alpha;
	if (alpha >= 'a' && alpha <= 'z') {
		cout << "a" << endl;
	}
	if (alpha >= 'A' && alpha <= 'Z') {
		cout << "A" << endl;
	}
}


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

int main(int argc, char const *argv[]) {
  char a[1000];
  scanf("%s",a);
  int b=strlen(a);
  int c=1;
  for (int i = 0; i < b/2; i++) {
    if (a[i]!=a[b-1-i]) {
      c=0;
    }
  }
  int f=(b+3)/2;
  int k=f;
  for (int i = b-1; i > f; i--) {
    if (a[i]!=a[k-1]) {
      c=0;
    }
    k++;
  }
  int l=(b-1)/2;
  int g=l;
  for (int i = 0; i < l; i++) {
    if (a[i]!=a[g-1]) {
      c=0;
    }
    g--;
  }
  if (c==1) {
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N;
int A[3][110];
int sum[2][110];
int main(){
    cin>>N;
    REP(j,0,2) {
        REP(i, 1, N+1) {
            cin >> A[j][i];
            sum[j][i]=sum[j][i-1] + A[j][i];
        }
    }
    int ans = 0;
    REP(i,1,N+1){
        ans = max(ans,sum[0][i]+sum[1][N]-sum[1][i-1]);
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        a: u128,
        b: u128,
        c: u128,
    }
    let d = c - a - b;
    if a + b < c && d.pow(2) > 4 * a * b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;
const int N = 1100000;

int n, a[N], f[N];
ll k;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

inline bool check(ll mid) {
    ll tmp = k;
    for (R int i = 1; i <= n; ++i)
        tmp -= max(0ll, a[i] - mid / f[i]);
    return tmp >= 0;
}

int main() {
    read(n), read(k);
    for (R int i = 1; i <= n; ++i)
        read(a[i]);
    for (R int i = 1; i <= n; ++i)
        read(f[i]);
    sort(a + 1, a + 1 + n);
    sort(f + 1, f + 1 + n);
    reverse(f + 1, f + 1 + n);
    ll l = 0, r = 1e12, mid;
    while (l < r) mid = (l + r) >> 1, check(mid) ? r = mid : l = mid + 1;
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

int main(){
    int n, W; cin >> n >> W;
    vector<ll> dp(W+1, -1);
    dp[0] = 0;
    int w, v;
    for(int i=0; i<n; i++){
        cin >> w >> v;
        for(int j=W; j>-1; j--){
            if(dp[j] == -1){continue;}
            if(j+w > W){continue;}
            dp[j+w] = max(dp[j+w], dp[j] + v);
        }
    }
    // for(auto& v:dp){
    //     cout << v << " ";
    // }
    // cout << "\n";

    ll ans = 0;
    for(int i=0; i<W+1; i++){
        ans = max(ans, dp[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =2*1e5+5;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

vector<string> alphabet={"?","a","b","c","d","e","f","g","h","i","j","k",
                        "l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};  
int keta_max(ll a){
    ll x = 0;
    int keta;
    rep(i,20){
        x += pow(26,i);
        keta = i;
        if(a<x) break;
    }
    return keta;
}
ll n_max(int a){
    ll ret = 0;
    for(int i=1; i<=a; i++){
        ret = ret + pow(26,i);
    }
    return ret;
}

int main(){
    ll n;
    cin >> n;
    ll x = 0;
    int keta = keta_max(n);
    ll a = n - n_max(keta-1);
    string ans="";
    for(int i=keta; i>0; i--){
        int j = ceil(a/pow(26,i-1));
        a = a - pow(26,i-1)*(j-1);
        ans += alphabet[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4108
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 1e8 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
int a[88];

int main () {
	SpeedForce;
	
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll ans = 1000;
	int curmn = 200;
	for (int i = 1; i <= n; ++i) {
		if (a[i] > curmn) {
			ans = (ans/curmn) * a[i] + (ans%curmn);
			curmn = a[i];
		} else {
			curmn = a[i];
		}
	}
	cout << ans << '\n';
    return Accepted;
}

// B...a

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

int main() {
    int D;
    cin >> D;
    if (D == 25) cout << "Christmas" << endl;
    else if (D == 24) cout << "Christmas Eve" << endl;
    else if (D == 23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

def same(l1, l2, n):
    for i in range(n):
        if l1[i] != l2[i]:
            return False
    return True

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

P = [p-1 for p in P]
Q = [q-1 for q in Q]

for i,pattern in enumerate(permutations(range(N))):
    if same(P, pattern, N):
        i_p = i
    if same(Q, pattern, N):
        i_q = i

print(abs(i_p - i_q))

Measured memory_bytes: 80468
class Node
  def solve(n, node_info)
    nd = Array.new
    for j in 0..(n-1)
      i = node_info[j]
      if i[1] == 0
        unless nd[i[0]]
          nd[i[0]] = [nil, nil]
        end
      else
        if(nd[i[0]])
          nd[i[0]][1] = i[2,i[1]]
        else
          nd[i[0]] = [nil, i[2,i[1]]]
        end
        (1..i[1]).each do |x|
          if(nd[i[x+1]])
            nd[i[x+1]][0] = i[0]
          else
            nd[i[x+1]] = [i[0], nil]
          end
        end
      end
    end

    (0...n).each do |i|
      depth = 0
      prt = nd[i][0]
      while (prt)
        depth += 1
        prt = nd[prt][0]
      end
      print "node #{i}: parent = #{nd[i][0] ? nd[i][0] : -1}, depth = #{depth}, #{nd[i][0] ? (nd[i][1] ? "internal node" : "leaf") : "root"}, "
      print "["
      if nd[i][1]
        print "#{nd[i][1].join(", ")}"
      end
      puts "]"
    end
  end
end


n  = gets.chomp.to_i
node_info = []
n.times do
  i = gets.split(/\s/).map(&:to_i)
  node_info.push(i)
end


node = Node.new
node.solve(n, node_info)

Measured memory_bytes: 31360
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/




void Calc() {


  string s = in;

  int n = 0;
  int ans = 0;
  for (auto& i : s) {
    if (i == 'g') {
      if (n) {
        ans++;
        n--;
      } else {
        n++;
      }
    } else {
      if (n)n--;
      else {
        n++;
        ans--;
      }
    }
  }
  cout << (ans) << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,s,c=0;
    cin>>k>>s;
       for(int x=0; x<=k; x++)
    {
        for(int y=0; y<=k; y++)
        {
            int z=s-(x+y);
            if(z>=0&&z<=k)
                c++;
        }
    }
    cout<<c;
}


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

int main(void){
    int n,k;
    cin >> n >> k;
    int cnt[n]={};
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        cnt[a-1]++;
    }
    sort(cnt,cnt+n,greater<int>());
    int sortOfNum=0;
    for (size_t i = 0; i < n; i++)
    {
        if (cnt[i]==0)break;
        sortOfNum++;
    }
    int ans=0;
    for (size_t i = 0; i < (sortOfNum-k<0?0:sortOfNum-k); i++)
    {
        ans+=cnt[sortOfNum-1-i];
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

L, R = map(int, input().split())
L_mod = L % 2019
R_mod = R % 2019
min_mod = pow(2018,2)
num = 0

if abs(L - R) >= 2019:
    min_mod = 0
elif L_mod < R_mod:
    for i in range(L_mod, R_mod):
        for j in range(i + 1, R_mod + 1):
            num = (i * j) % 2019
            if min_mod > num:
                min_mod = num
elif L_mod > R_mod:
    for i in range(R_mod, L_mod):
        for j in range(i + 1, L_mod + 1):
            num = (i * j) % 2019
            if min_mod > num:
                min_mod = num
else:
    min_mod = L_mod * R_mod % 2019
print(min_mod)

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

primes = runSTUArray $ do
    arr <- newArray (1,999999) 1 :: ST s (STUArray s Int Int)
    writeArray arr 1 0
    forM_ [2..1000] $ \p -> do
      forM_ [2*p,3*p..999999] $ \n -> writeArray arr n 0
    forM_ [3..999999] $ \i -> (+) <$> readArray arr (i-1) <*> readArray arr i >>= writeArray arr i
    return arr


main = map readInt . lines <$> getContents >>= mapM_ (print . (primes!))


Measured memory_bytes: 20180
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int n;
	cin >> n;

	vector<char> s(n);
	rep(i, 0, n) cin >> s[i];

	int count = 1;
	rep(i, 0, n - 1) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

bool check(string& s, int l, int r){
	for(int i=0;i<(r-l);i++){
		if(s[l+i]!=s[r-i]){
			return 0;
		}
	}
	return 1;
}

int32_t main(){
	string s;
	cin>>s;
	if(((s.length()&1) == 1) && check(s,0,s.length()-1)
		&& check(s,0,s.length()/2-1) && check(s,s.length()/2+1,s.length()-1)){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}


Measured memory_bytes: 256
#!python
import math
import itertools

cnt = 0
n, d = [int(i) for i in input().split()]

ipt = []
for i in range(n):
    ipt.append([int(i) for i in input().split()])

for i in itertools.combinations(ipt, 2):
    dist_b = 0
    for j in range(d):
        dist_b += pow(abs(i[0][j] - i[1][j]), 2)
    
    if math.floor(math.sqrt(dist_b)) == math.ceil(math.sqrt(dist_b)):
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  string s; cin >> s;

  int i = 0 , j = s.size() - 1;
  int cnt = 0;

  while(i<j){
    if(s[i]=='R') i++;
    else if(s[j]=='W') j--;
    else{
      swap(s[i],s[j]);
      i++;
      j--;
      cnt++;
    }
  }

  cout << cnt << '\n';

  return 0;
}

Measured memory_bytes: 3776
### main

while true
  line = gets.strip
  break if line == '0'

  bds = []
  bds << line.split('')

  bds << gets.strip.split('')
  bds << gets.strip.split('')

  draw = true

  for y in (0..2)
    ch = bds[y][0]
    if ch != '+' && ch == bds[y][1] && ch == bds[y][2]
      puts ch
      draw = false
      break
    end
  end
  next if ! draw

  for x in (0..2)
    ch = bds[0][x]
    if ch != '+' && ch == bds[1][x] && ch == bds[2][x]
      puts ch
      draw = false
      break
    end
  end
  next if ! draw

  ch = bds[0][0]
  if ch != '+' && ch == bds[1][1] && ch == bds[2][2]
    puts ch
    draw = false
    next
  end

  ch = bds[0][2]
  if ch != '+' && ch == bds[1][1] && ch == bds[2][0]
    puts ch
    draw = false
    next
  end

  puts 'NA'
end

Measured memory_bytes: 6116
import sys,bisect,heapq

mod = 10**9+7
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(input())
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while(a%b != 0):
        a,b = b,a%b
    return b

def LCM(a,b):
    return a*b//GCD(a,b)

def main():
    N,L = LI()
    A = LI()
    ans = "Impossible"

    for i in range(N-1):
        if A[i]+A[i+1] >= L:
            ans = "Possible"
            last = i+1
            break

    if ans == "Impossible":
        print(ans)
    else:
        print(ans)
        for i in range(1,last):
            print(i)
        for i in range(N-1,last,-1):
            print(i)
        print(last)







    

if __name__ == "__main__":
    main()


Measured memory_bytes: 59872
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,h;
    cin>>n>>h;
    int count = 0;
    int hoge=0;
    for(int i=0;i<n;i++){
        cin>>hoge;
        if(hoge>=h)count++;
    }
    cout<<count;
}

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

struct Vec2 {
  double x, y;
  Vec2(double x_, double y_) : x(x_), y(y_) {}
};

bool in_the_triangle(const Vec2& a, const Vec2& b, const Vec2& c, const Vec2& p) {
  Vec2 aa(a.x-p.x, a.y-p.y);
  Vec2 bb(b.x-p.x, b.y-p.y);
  Vec2 cc(c.x-p.x, c.y-p.y);
  double k = aa.x*bb.y - bb.x*aa.y;
  double l = bb.x*cc.y - cc.x*bb.y;
  double m = cc.x*aa.y - aa.x*cc.y;
  return (k * l > 0 && k * m > 0);
}

int main() {
  double a,b,c,d,e,f,g,h;
  while (8==scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f,&g,&h)) {
    puts(in_the_triangle(Vec2(a,b),Vec2(c,d),Vec2(e,f),Vec2(g,h)) ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 1040
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

from math import gcd
k = int(input())
sum = 0
for a in range(k):
    for b in range(k):
        gcd_ab = gcd(a + 1, b + 1)
        for c in range(k):
            sum += gcd(gcd_ab, c + 1)
print(sum)

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

int cnt[5]={0};

void march(int fcnt,int x,long long tmp){
    static long long sum=0;
    
    if(fcnt<3 && x<5){
        march(fcnt,x+1,tmp);
        if(cnt[x]){march(fcnt+1,x+1,tmp*cnt[x]);}
    }
    
    if(fcnt==3){
        sum+=tmp;
    }
    
    if(x==0){
        cout<<sum<<endl;
    }
}

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

    string str;
    for(int i=0;i<N;i++){
        cin>>str;
        if(str[0]=='M'){cnt[0]++;}
        if(str[0]=='A'){cnt[1]++;}
        if(str[0]=='R'){cnt[2]++;}
        if(str[0]=='C'){cnt[3]++;}
        if(str[0]=='H'){cnt[4]++;}
    }

    march(0,0,1);
    

    return 0;
}


Measured memory_bytes: 384