akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 3000 + 5;
ll dp[MAXN][MAXN][4];
ll W[MAXN][MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll R, C, K;
	cin >> R >> C >> K;
	//vector<vector<ll>> W(R, vector<ll> (C, 0));
	for (int i = 0; i < K; i++) {
		ll r, c, v;
		cin >> r >> c >> v;
		r--; c--;
		W[r][c] = v;
	}
	//ll dp[R][C][4];
	dp[0][0][0] = 0;
	dp[0][0][1] = W[0][0];
	dp[0][0][2] = 0;
	dp[0][0][3] = 0;
	for (int i = 1; i < R; i++) {
		dp[i][0][0] = max(dp[i - 1][0][0], dp[i - 1][0][1]);
		dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][0][1]) + W[i][0];
		dp[i][0][2] = 0;
		dp[i][0][3] = 0;
	}
	for (int i = 0; i < R; i++) {
		for (int j = 1; j < C; j++) {
			ll max_above;
			if (i == 0) max_above = 0;
			else max_above = max(max(dp[i - 1][j][0], dp[i - 1][j][1]), max(dp[i - 1][j][2], dp[i - 1][j][3]));
			dp[i][j][3] = max(dp[i][j - 1][3], dp[i][j - 1][2] + W[i][j]);
			dp[i][j][2] = max(dp[i][j - 1][2], dp[i][j - 1][1] + W[i][j]);
			dp[i][j][1] = max(dp[i][j - 1][1], max(dp[i][j - 1][0] + W[i][j], W[i][j] + max_above));
			dp[i][j][0] = max(dp[i][j - 1][0], max_above);
		}
	}
	cout << max(max(dp[R - 1][C - 1][0], dp[R - 1][C - 1][1]), max(dp[R - 1][C - 1][2], dp[R - 1][C - 1][3])) << endl;
}



Measured memory_bytes: 355680
D=int(input())
c = list(map(int,input().split()))

s=[None]*D
for i in range(D):
    s[i] = list(map(int,input().split()))

def maxarg(l):
    nl=len(l)
    ma=-10**20
    idx=-1
    for i in range(nl):
        if l[i]>ma:
            ma=l[i]
            idx=i
    return (idx,ma)

last=[0]*26
for j,ss in enumerate(s):
    
    cand = [ss[i]+c[i]*(j+1-last[i]) for i in range(26)]
    idx,val = maxarg(cand)
    
    last[idx]=j+1

    print(idx+1)

Measured memory_bytes: 68148
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S[N];
  int t[N];
  for(int i=0;i<N;++i) {
    cin>>S[i]>>t[i];
  }
  string X;
  cin>>X;
  bool ok = false;
  int ans = 0;
  for(int i=0;i<N;++i) {
    if(ok) {
      ans += t[i];
    }
    if(S[i]==X) ok = true;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3588
/*
The year is 2050, league is played by less than 100 people. T1 has finally reached Masters,
"Macaiyla I did it!" he yells excitedly. The sound echoes through the empty trailer. Macaiyla left long ago...
 */
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int x = sc.nextInt(), y = sc.nextInt();
        pw.println(x + y/2);
        pw.close();
    }
}

// ceil(a/b) = (a+b-1)/b
// PRO TIP: THE BEST ANSWER IS THE RIGHT ANSWER


Measured memory_bytes: 22356
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    string s; cin >> s;
    sort(s.begin(),s.end());
    
    if(s[0] == s[1] && s[2] == s[3] && s[2] != s[1]) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3600
N = int(input())
S = list(map(str,input()))
target = len(set(S))
count = list()
for i in range(1,N):
	X = set(S[:i])
	Y = set(S[i:])
	# 対称差集合
	symmetric_difference = X ^ Y
	count.append(target - len(symmetric_difference))
	# print('X:',X,'Y:',Y)
	# print(len(symmetric_difference))
print(max(count))

Measured memory_bytes: 3060
# coding: utf-8
import math
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B=  []
for i in range(n):
    B.append(A[i]-(i+1))
B.sort()
if n==1:
    m=B[0]
    m2=B[0]
else:
    m = B[n//2]
    m2=B[n//2+1]
tmp1=0
tmp2=0
#print(m,m2)
for i in range(n):
    tmp1 += abs(A[i]-(i+1)-m)
    tmp2 += abs(A[i]-(i+1)-m2)
print(min(tmp1, tmp2))

Measured memory_bytes: 32312
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
const int INF=0x3f3f3f3f;
typedef long long LL;
unordered_map<string,int> mp;
string A[maxn];
string str;
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        sort(str.begin(),str.end());
        A[i]=str;
        mp[str]++;
    }
    LL sum=0;
    for(int i=0;i<n;i++)
        sum+=mp[A[i]]-1;
    cout<<sum/2<<endl;
}

Measured memory_bytes: 16036
MODULE intQsortMod
! 整数型のクイックソート
! precisionで整数の精度を定める．
! インデックスの小さいほうが値も小さい(昇順)．

! 参考
! https://t.doujin-constant.net/post/143374686394/fortranをより使いこなしたquick-sort

      implicit none
      integer,parameter,private :: precision = 4
      
      interface qSort
        module procedure :: intQsort
      end interface
      
      contains
      pure recursive function intQsort( a ) result( r )
        implicit none
        integer(precision), intent(in) :: a(:)
        integer(precision) :: r( size(a) )
        integer(precision) :: sample(3), len, i,j
        
        len = size( a(:) )
        if( len<=1 )then
          r = a
        else
          !select pivot
          sample(1:3) = [a(1), a(len/2), a(len)]
          do i = 1,2
            do j = 2,3
              if( sample(i)>sample(j) )then
                len = sample(i) !len is buffer
                sample(i) = sample(j)
                sample(j) = len
              end if
            end do
          end do
          
          r = [ qSort( pack(a(:), a(:)< sample(2) ) ), &
                       pack(a(:), a(:)==sample(2) )  , &
                qSort( pack(a(:), a(:)> sample(2) ) ) ]
        end if
      end function intQsort
      END MODULE intQsortMod


      module piyoMod
      implicit none
      integer :: n,numA=0
      integer :: mkdArray(5*10**5)=0
      
      
      contains
      !cnt 新しく作る桁
      recursive subroutine mkA( cnt,array,flag )
        implicit none
        integer,intent(in) :: cnt,array(:)
        integer :: a(size(array))
        logical,intent(in) :: flag(:)
        logical :: f(size(flag))
        integer :: i
        
        if( cnt>n )then
          numA = numA + 1
          do i = 1,n
            mkdArray(numA) = mkdArray(numA) + array(i)*10**(i-1)
          end do
          return
        else
          a = array(:)
          f = flag(:)
          do i = 1,n
            if( flag(i) ) cycle
            a(cnt) = i
            f(i) = .true.
            call mkA( cnt+1,a,f )
            f(i) = .false.
          end do
        end if
      end subroutine
      
      end module
      
      PROGRAM countOrder
      use piyoMod
      use intQsortMod
      IMPLICIT NONE
      integer :: valP=0,valQ=0,indP,indQ,i
      integer,allocatable :: p(:),q(:),dummy(:)
      logical,allocatable :: flag(:)
      
      read*,n
      allocate( p(n),q(n),dummy(n), flag(n) )
      read*,p(n:1:-1)
      read*,q(n:1:-1)
      
      
      
      flag = .false.
      call mkA( 1,dummy,flag )
      
      mkdArray(1:numA) = qsort( mkdArray(1:numA) )
      
      
      
      do i = 1,n
        valP = valP + p(i)*10**(i-1)
        valQ = valQ + q(i)*10**(i-1)
      end do
      
      do i = 1,numA
        if( mkdArray(i)==valP )then
          indP = i
        end if
        if( mkdArray(i)==valQ )then
          indQ = i
        end if
      end do
      
      print*,abs(indP - indQ)
      
      
!      print*,mkdArray(1:numA)
      
      
      
      END PROGRAM

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

int main(){
    bool p=true;
    int x,y;
    string S;
    cin>>S;
    string T;
    cin>>T;
x=S.size(); y=T.size();
if(x==y-1){
for(int i=0;i<x;i++){
    if(S[i]!=T[i]){p=false;break;}
    else  p=true;
    }}
else p=false;

if(p)cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 3096
num = int(input())
for i in range(1, num + 1):
    x = i
    if x % 3 == 0:
        print(f' {i}', end='')
    elif x % 10 == 3:
        print(f' {i}', end='')
    else:
        while x > 0:
            x = x // 10
            if x % 10 == 3:
                print(f' {i}', end='')
                break
print()



Measured memory_bytes: 5880
import math
# N, A, B, C = 7, 100, 90, 80
# ARR = [
#     98,
#     40,
#     30,
#     21,
#     80,
#     25,
#     100
# ]

N, A, B, C = map(int, input().split())
ARR = []
for i in range(N):
    ARR.append(int(input()))
result = []


def dfs(deep, crr):
    if deep == N:
        ok, res = calculate(crr)
        if ok:
            result.append(int(res))
    else:
        for i in range(4):
            crr[deep] = i
            dfs(deep + 1, crr)


def calculate(crr):
    sA = []
    sB = []
    sC = []
    sN = []
    for index, cr in enumerate(crr):
        if cr == 0:
            sN.append(ARR[index])
        if cr == 1:
            sA.append(ARR[index])
        if cr == 2:
            sB.append(ARR[index])
        if cr == 3:
            sC.append(ARR[index])

    if len(sA) == 0:
        return False, -1
    if len(sB) == 0:
        return False, -1
    if len(sC) == 0:
        return False, -1


    s1 = (len(sA) - 1) * 10 + math.fabs(sum(sA) - A)
    s2 = (len(sB) - 1) * 10 + math.fabs(sum(sB) - B)
    s3 = (len(sC) - 1) * 10 + math.fabs(sum(sC) - C)

    return True, s1 + s2 + s3


dfs(0, [0 for i in range(N)])

print(min(result))

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

S = input()
mx = 0

for i in range(len(S)):
    cnt = 0
    j = i
    while j < len(S) and (S[j] == "A" or S[j] == "T" or S[j] == "C" or S[j] == "G"):
        cnt += 1
        j += 1
    if cnt > mx:
        mx = cnt

print(mx)


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int l,k;

int dfs(int x){
  if(x<0) return 0;
  return 1+dfs(x-2)+dfs(x-k-1);
}

int main(){
  cin >> l >> k;
  vector<LL> a(100,0);
  LL ans=0;
  a[0]=1,a[k-1]=1;
  repp(i,0,l){
    if(i>=2) a[i]+=a[i-2];
    if(i>=k+1) a[i]+=a[i-k-1];
    ans+=a[i];
  }
  cout << ans << endl;
  return 0;
}



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

bool Hantei( char C ) {
  if (   C == 'A'
      || C == 'C'
      || C == 'G'
      || C == 'T' ) return true;

  return false;
}

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

  int Ans = 0;
  int Count = 0;
  rep( i, 0, S.size() ) {
    bool flag = Hantei( char( S.at(i) ) );
    if ( flag ) {
      Count++;
      if ( i == int( S.size() )-1 ) {
        Ans = max( Count, Ans );
      }
    }
    else {
      Ans = max( Count, Ans );
      Count = 0;
    }
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
	int n, e;
	scanf("%d", &n);
	list<int> v;
	bool lor = (n % 2 == 0);
	rep(i, 0, n) 
	{	
		cin >> e;
		if (lor) {
			v.push_back(e);
			lor = false;
		} else {
			v.push_front(e);
			lor = true;
		}
	}
	for (int x : v)
		cout << x << " ";
	cout << endl;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// 整数スキャン（複数）
/*
int x;
scanf("%d",&x);
int y;
scanf("%d",&y);
int z;
scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


int main() {
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);

    int ans = 0;

    ans = x*y - x - y + 1;

    cout << ans << endl;
   
    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<set>
#include<functional>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
using p = pair<ll,ll>;
const ll INF = (ll)1e9;
void a(){
    int n,m;
    cin >> n >> m;
    cout << (n==m?"Yes":"No");
}

void b(){
    int a,b;
    cin >> a >> b;
    int _min = min(a,b);
    int _max = max(a,b);
    for(int i=0;i<_max;i++){
        cout << _min;   
    }
}

void c(){
    int n;
    cin >> n;
    auto p = vector<int>(n,0);
    for(int i=0;i<n;i++) cin >>p[i];
    int _min = p[0];
    int ans =1;
    for(int i=1;i<n;i++){
        if(_min>=p[i]){
            ans++;
            _min = p[i];
        }
    }
    cout << ans;
}

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

Measured memory_bytes: 1024
N = int(input())
s = list(map(int, input().split()))
ans = 0
for c in range(1, N):
    res = 0
    for k in range(1, (N-1)//c+1):
        a = N-1-c*k
        b = a-c
        res+=s[c*k]+s[-c*k-1]
        if b<0 or (a%c==0 and a//c<=k) :
            continue
        ans = max(ans, res)
print(ans)


        


Measured memory_bytes: 14860
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

#define INF 2000000000

typedef pair<int, int> P;
struct edge{ int to, cost;};

int V, E;
vector<edge> G[100010];
int d[100010];

void dijkstra(int s){
  
  priority_queue<P, vector<P>, greater<P> > que;
  
  for(int i = 0;i < V;i++) d[i] = INF;
  d[s] = 0;
  que.push(P(0, s));
  
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    
    if(d[v] < p.first) continue;
    for(int i = 0;i < G[v].size();i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  
  int r, s;
  edge e;
  
  cin >> V >> E >> r;
  for(int i = 0;i < E;i++){
    cin >> s >> e.to >> e.cost;
    G[s].push_back(e);
  }
  
  dijkstra(r);
  
  for(int i = 0;i < V;i++){
    if(d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
  
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    map< string, int > mp;
    int n;
    cin >> n;
    string before;
    cin >> before;
    mp[before] = 1;
    bool flg = true;
    for( int i = 1; i < n; ++i ) {
        string s;
        cin >> s;
        if( before[before.size() - 1] != s[0] ||
                mp[s] != 0 ) {
            flg = false;

        }
        mp[s] = 1;
        before = s;

    }
    if( flg ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
    string s;
    cin >> s;
    int a=0,ans;
    rep(i,s.size()){
      if(s[i]=='(') a++;
      if (s[i]==')') a--;
      if (s[i]=='*') ans=a;
    }
    cout << ans << endl;
}



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

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

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    string s;
    cin >> s;
    rep(i, s.length()) {
        if (i % 2 == 1) {
            if ( s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if ( s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
    } 
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
    ll n;
    cin>>n;
    set<ll> s;
    rep(i,0,n){
        ll d; cin>>d;
        s.insert(d);
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxn 100005
int pre[maxn];
int dis[maxn];
int n,m,l,r,d,fl,fr;
void init()
{
    for(int i=1;i<=n;i++)
        pre[i]=i,dis[i]=0;
}
int Find(int x)
{
    if(pre[x]==x)
        return x;
    int fa=pre[x];
    pre[x]=Find(pre[x]);
    dis[x]+=dis[fa];
    return pre[x];
}
int same(int l,int r)
{
    fl=Find(l);
    fr=Find(r);
    if(fl==fr)
        return 1;
    else
        return 0;
}
void unite()
{
    pre[fr]=fl;
    dis[fr]=dis[l]+d-dis[r];
}
int main()
{
    cin>>n>>m;
    init();
    int flag=0;
    while(m--)
    {
        cin>>l>>r>>d;
        if(flag)
            continue;
        if(!same(l,r))
        {
            unite();
            //cout<<dis[l]<<" "<<dis[r]<<endl;
        }
        else
        {
            //cout<<dis[l]<<" "<<dis[r]<<endl;
            if(dis[r]-dis[l]!=d)
                flag=1;
        }
    }
    if(flag)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


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

long long n;
long long pos1;
long long pos2;
long long a[100005];
long long memo[100005];
set<long long>done;

#define DIV 1000000007

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

void pre(){
	memo[0] = 1;
	memo[1] = 1;
	for(long long i = 1; i < 100003; i++){
		memo[i+1] = memo[i] * (i+1);
		memo[i+1] %= DIV;
	}
}

long long comb(long long A, long long B){
	if(A < B){
		return 0;
	}
	long long ans = memo[B] * memo[A-B];
	ans %= DIV;
	ans = memo[A] * modpow(ans, DIV - 2);
	ans %= DIV;
	return ans;
}

long long cal(long long num){
	long long ans;
	ans = comb(n + 1, num);
	ans %= DIV;

	ans -= comb(pos1 + n - pos2, num - 1);
	ans += DIV;
	ans %= DIV;

	/*
	for(long long i = 0; i < num; i++){
		long long tmp;
		tmp = comb(pos1, i) * comb(n - pos2, num - 1 - i);
		tmp %= DIV;
		ans -= tmp;
		ans += DIV;
		ans %= DIV;
	}
	*/

	return ans;
}

int main(){
	pre();
	cin >> n;
	for(long long i = 0; i <= n; i++){
		cin >> a[i];
		if(done.count(a[i]) != 0){
			pos2 = i;
		}else{
			done.insert(a[i]);
		}
	}

	for(long long i = 0; i <= n; i++){
		if(a[i] == a[pos2]){
			pos1 = i;
			break;
		}
	}

	for(long long i = 1; i <= n + 1; i++){
		cout << cal(i) << endl;
	}
}


Measured memory_bytes: 7424
#include <stdio.h>

int main(){
	int a, b, c, i, s = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a; i <= b; i++){
		if(c % i == 0){
			s++;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 596
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	// N/K回またはN/K +1回の操作で最小値が得られる
	fmt.Println(min(n%k, abs(n%k-k)))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ios()                \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)

signed main()
{
	ios();
	int P,Q,R;
	cin >> P >> Q >> R;
	cout << min({P+Q,Q+R,R+P}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
int  main(){
  vector<ll>a(3);
  vector<int>b={4,2,1};
  for(int i=0;i<3;i++){
    cin>> a.at(i);
    a.at(i)*=b.at(i);
    }
  sort(a.begin(),a.end());
  ll z,n;  
  cin >> z>>n;
  if(z>a.at(0)*2){
    ll ans = a.at(0)*n;
    cout << ans << endl;
    return 0;
  }
  ll ans = 0;
while(n>=2){
  n-=2;
  ans+=z;
  }
  if(n==0){
    cout << ans <<endl;
    }
  else {
    ans+=a.at(0);
    cout << ans<<endl;
    }
}


Measured memory_bytes: 256
H, W, A, B = map(int, input().split())

col1 = []
col2 = []

for _ in range(A):
    col1.append("0")
    col2.append("1")
    
for _ in range(W - A):
    col1.append("1")
    col2.append("0")
    
row1 = "".join(col1)  # 011
row2 = "".join(col2)  # 100

for _ in range(B):
    print(row1)
    
for _ in range(H - B):
    print(row2)

Measured memory_bytes: 3956
n,k=map(int,input().split())
a=list(map(int, input().split()))
f=list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

maxaf=a[0]*f[0]
for i in range(n):
	if a[i]*f[i]>maxaf:
		maxaf=a[i]*f[i]

def solve(x):
	total=0
	for i in range(n):
		total+=max(0,a[i]-x//f[i]) #負になりうる懸念ができていなかった、とほほ
	return total<=k

#xの範囲 ngは実現が難しい方
ok=maxaf
ng=-1

while ok-ng>1:
	mid=(ok+ng)//2
	if solve(mid):
		ok=mid
	else:
		ng=mid
print(ok)

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

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

int div2(ll n) {
    int cnt = 0;
    while(n%2==0){
        cnt++;
        n/=2;
    }
    return cnt;
}

int main(){
    ll N, M;  cin >> N >> M;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i]/=2;
    }
    for(int i=1; i<N; i++){
        if(div2(A[i-1]) != div2(A[i])){
            cout << 0 << endl;
            return 0;
        }
    }

    ll common = 1;
    for(int i=0; i<N; i++){
        common = A[i]/gcd(common, A[i])*common;
        if(common > M){
            cout << 0 << endl;
            return 0;
        }
    }
    
    ll MM = M/common - 1;
    if(MM < 0){
        cout << 0 << endl;
    }else{
        cout << MM/2+1 << endl;
    }
}


Measured memory_bytes: 1024
import sys

N, M = map(int, input().split())

As = []
for i in range(N):
    As.append(list(input()))

Bs = []
for i in range(M):
    Bs.append(list(input()))


def isEqual(A_i, A_j):
    try:
        for i in range(M):
            for j in range(M):
                if As[A_i+i][A_j+j] != Bs[i][j]:
                    return
    except IndexError:
        return

    print('Yes')
    sys.exit(0)


for A_i in range(N):
    for A_j in range(N):
        isEqual(A_i, A_j)

print('No')


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

int k,a,b;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>k>>a>>b;
    
    int x;
    for (int i=1; i<=100; i++){
        x=k*i;
        if (x>=a && x<=b) return cout<<"OK",0;
    }
    
    cout<<"NG";
    
    
    return 0;
}

Measured memory_bytes: 3652
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;




int main()
{
	Nayon;
	ll i,j,k,n,cnt=0;
	cin>>n;
	ll a[n+1];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n;k++){
				if(a[i]==a[j] || a[i]==a[k] || a[j]==a[k]){
					continue;
				}
				else{
					if(a[i]+a[j]>a[k]){
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<nl;
}

//Happy Coding......

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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define mp make_pair
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
string s;

int dp[301][301][301];
	

inline int calc(int l, int r, int k)
{
	if(l > r) return 0;
	if(l == r)
		return 1;
	if(dp[l][r][k] != -1)
		return dp[l][r][k];
	int &res = dp[l][r][k];
	res = 0;
	
	if(s[l] == s[r])
		res = max(res, calc(l + 1, r - 1, k) + 2);
	res = max(res, calc(l + 1, r, k));
	res = max(res, calc(l, r - 1, k));
	if(s[l] != s[r] && k > 0)
		res = max(res, calc(l + 1, r - 1, k - 1) + 2);
	return res;
}

int main()
{
	//ios::sync_with_stdio(0); cin.tie(0);
	cin >> s;
	memset(dp,-1,sizeof dp);
	int k;
	cin >> k;
	cout << calc(0,s.length()-1,k);	
	return 0;
}


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

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<pair<int, int> > box(N, make_pair(1, 0));
    box[0].second = 1;
    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if(box[x].second == 1) {
            box[y].second = 1;
            if(box[x].first == 1) box[x].second = 0;
        }
        box[x].first--;
        box[y].first++;
    }

    int ans = 0;
    for(auto &it : box) {
        ans += it.second;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << 1 << endl;
    return;
  }
  ll ans;
  ll L0 = 2, L1 = 1;
  rep(i, 1, N) {
    ans = L0 + L1;
    L0 = L1;
    L1 = ans;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
	int n;
	string s;
	cin >> n >> s;
	if (n >= 3200)
		cout << s;
	else
		cout << "red";
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
	private static BufferedReader br = null;
	
	public static void main(String[] args) {
		String[] strs = read(1)[0].split(" ");
		int n = Integer.parseInt(strs[0]);
		int t = Integer.parseInt(strs[1]);
		
		strs = read(n);
		
		int minCost = Integer.MAX_VALUE;
		for (String str : strs) {
			String[] strs2 = str.split(" ");
			int c = Integer.parseInt(strs2[0]);
			int t2 = Integer.parseInt(strs2[1]);
			
			if (t2 <= t && c < minCost) {
				minCost = c;
			}
		}
		
		if (minCost == Integer.MAX_VALUE) {
			System.out.println("TLE");
		} else {
			System.out.println(minCost);
		}
	}
	
	private static String[] read(int len) {
		List<String> strList = new ArrayList<>();
		
		try {
			if (br == null) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			
			for (int i = 0; i < len; i++) {
				strList.add(br.readLine());
			}
		} catch (IOException e) {
		}
		
		return strList.toArray(new String[0]);
	}
	
	private static void close() {
		try {
			if (br != null) {
				br.close();
			}
		} catch (IOException e) {
		}
	}
}


Measured memory_bytes: 21204
h, w = map(int, input().split())
s = []
s.append("."*(w+2))
for _ in range(h):
    s.append("."+input()+".")
s.append("."*(w+2))
for i in range(1, h+1):
    ans = ""
    for j in range(1, w+1):
        if s[i][j] == ".":
            ans += str([s[i-1][j-1], s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]].count("#"))
        else:
            ans += "#"
    print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int N; cin >> N;
	vector<vector<int>>nums(3, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> nums[j][i];
		}
	}
	vector<int>scores(N);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (count(nums[j].begin(), nums[j].end(), nums[j][i]) == 1)scores[i] += nums[j][i];
		}
	}
	for (auto s : scores) {
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef pair< int , int > Pi;
int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};
int main(){
  int tmp[] = {10,50,100,500},n;
  bool ok = false;
  while(cin >> n && n){
    if(ok) cout << endl;
    ok = true;
    int a[4],b[4]={};
    for(int i=0;i<4;i++){
      cin >> a[i];
    }
    int money = (a[3] * 500 + a[2] * 100 + a[1] * 50 + a[0] * 10) - n;
    b[3] = money/500;
    b[2] = money%500/100;
    b[1] = money%100/50;
    b[0] = money%50/10;
    for(int i=0;i<4;i++){
      if(a[i] - b[i] > 0){
        cout << tmp[i] << " " << a[i] - b[i] << endl;
      }
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0;i<n;i++)
pair<pair<string, int>, int> pr[110];

int main() {
  int n; cin>>n;
  rep(i, n) {
    string s; int t; cin>>s>>t;
    pr[i] = make_pair(make_pair(s,-t),i);
  }
  sort(pr,pr+n);
  rep(i,n) {
    cout<<pr[i].second+1<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,sum,frag;
    cin>>n;
    int *a = new int[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=a[j]-i;
            if(sum<0){
                cout<<i-1<<endl;
                goto fin;
            }
        }
    }
    fin:
    delete[] a;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
int main(int argc, char const* argv[])
{
	int n;
	string s;
	cin >> n >> s;
	VVL dp(n+1, VL(n+1,0));
	for (int i = 0; i < n; i++) {
		dp[i][i] = n-i;
	}
	for (int i = n-1; i >= 0; i--) {
		for (int j = n-1; j >= 0; j--) {
			if (i == j) continue;
			if (s[i] == s[j]) {
				dp[i][j] = dp[i+1][j+1] + 1;
			}
		}
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (dp[i][j] <= j-i) {
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 195840
import numpy as np
from collections import Counter

def prime_factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp //= i
    if(tmp != 1):
        arr.append(tmp)
    if not arr:
        arr.append(n)
    return arr

mod = 1000000007
N = int(input())
prime_factors = {}
for i in range(2, N+1):
    counts = Counter(prime_factorization(i))
    for k,v in counts.items():
        prime_factors[k] = prime_factors.get(k, 0) + v
ans = 1
for v in prime_factors.values():
    ans *= (v+1)
    ans %= mod
print(ans)

Measured memory_bytes: 12480
#include <stdio.h>
#include <math.h>

#define SIZE 1024

int main(void){
  int n, i;
  double  m, sigma, a;

  for (;;){
    m = 0, sigma = 0;
    double s[SIZE] = {0};
    
    scanf("%d", &n);
    if (n == 0)
      break;
    for (i = 0; i < n; i++) {
      scanf("%lf", &s[i]);
      m += s[i];
    }
    m /= n;

    for (i = 0; i < n; i++)
      sigma += pow(s[i] - m, 2);
    a = sqrt(sigma / n);

    printf("%lf\n", a);
  }
  return 0;
}

Measured memory_bytes: 664
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<ll> a(n), sum(n + 1);
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
    sum[i + 1] %= MOD;
  }
  for (int i = 0; i < n - 1; i++) {
    ans += a[i] * (MOD + sum[n] - sum[i + 1]);
    ans %= MOD;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  ll ans;
  if((b-a) % 2 == 1){
    ans = min(n-max(a,b), min(a,b)-1);
    ans += (b-a)/2 + 1;
  }
  else{
    ans = (b-a)/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NUM 100000


int main(){
  int left=0,right,mid,n1,n2,i,j,key,count=0;
  int a[NUM];

  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&n2);

  for(i=0;i<n2;i++){
    scanf("%d",&key);
    left=0;
    right=n1;
    while(left<right){
      mid=(left+right)/2;
      if(a[mid]==key){
	count++;
	break;
      }
      else if(key<a[mid]){
	right=mid;
      }
      else left=mid+1;
    }
  }

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



  
  return 0;
}



Measured memory_bytes: 2144
n=int(input())
S=[int(i) for i in input().split()]
INF=10**10

def merge(A,l,m,r):
    cnt=0
    n1=m-l
    n2=r-m
    L,R=[0 for i in range(n1)],[0 for i in range(n2)]
    cnt=0
    L=A[l:l+n1]
    R=A[m:m+n2]
    L.append(INF)
    R.append(INF)
    i,j=0,0
    for k in range(l,r):
        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1   
        else:
            A[k]=R[j]
            j+=1
    return cnt     

def mergesort(A,l,r):
    cnt=0
    if l+1<r:
        m=(l+r)//2
        cnt+=mergesort(A,l,m)
        cnt+=mergesort(A,m,r)
        cnt+=merge(A,l,m,r)
    return cnt


cnt=mergesort(S,0,n)
print(*S)
print(cnt)


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

using namespace std;

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  int res = 0, mx = 1 << 28;
  for (int i = 0; i < N; i++) {
    if (chmin(mx, P[i])) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
import math

a, b, h, m = map(int, input().split())
minute = m * 360 / 60
hours = (h * 360 / 12)
hours += m * 360 / 720
angle = abs(minute - hours)

if angle > 180:
    angle = 360 - angle
angle = math.radians(angle)
ans = math.sqrt((a**2) + (b**2) - (2*a*b*math.cos(angle)))
print(ans)


Measured memory_bytes: 9192
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#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)--)
typedef long long ll;

void Main(){
 string s;
   cin >> s;
   
  if((s == "a")||(s == "e")||(s == "i")|(s == "o")||(s == "u") )  cout << "vowel" << endl;
  else cout << "consonant" << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		
		long scc = Math.min(n, m / 2);
		scc += Math.max(0, m - scc * 2) / 4;
		
		System.out.println(scc);
		
		sc.close();
	}
	
}



Measured memory_bytes: 26892
#include"bits/stdc++.h"

using namespace std;

int main()
{
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int x3, y3;
	x3 = x2 + (y1 - y2);
	y3 = y2 - (x1 - x2);

	int x4, y4;
	x4 = x1 + (y1 - y2);
	y4 = y1 - (x1 - x2);

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
double f[N];
vector<int> g[N];
int n, m;

double work(int x) {
  for(int i = 1; i <= n; ++i) f[i] = 0;
  for(int u = n - 1; u >= 1; --u) {
    double mx = 0.0;
    for(int i = 0; i < (int)g[u].size(); ++i) {
      int to = g[u][i];
      mx = max(mx, f[to] + 1);
      f[u] += f[to] + 1;
    }
    if(u == x && g[u].size() > 1) {
      f[u] = (f[u] - mx) / (g[u].size() - 1);
    } else {
      f[u] = f[u] / g[u].size();
    }
  }
  return f[1];
}

int main() {
  scanf("%d%d", &n, &m);
  for(int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
  }
  double ans = 1e9;
  for(int i = 1; i <= n; ++i) {
    ans = min(ans, work(i));
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1408
//49
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>

using namespace std;

long long pow10(int x){
  long long r=1;
  while(x--){
    r*=10;
  }
  return r;
}

string itos(int x){
  stringstream ss;
  ss<<x;
  return ss.str();
}

int main(){
  long long r[11]={0,1};
  for(int i=2;i<=10;i++){
    r[i]=r[i-1]+pow10(i-2)*9*(i-1);
  }
  for(int n,k;cin>>n>>k,n|k;){
    int l=upper_bound(r,r+11,n)-r-1;
    int f=(n-r[l])/l+pow10(l-1);
    int h=(n-r[l])%l;
    string s;
    for(;s.size()<k+h;f++){
      s+=itos(f);
    }
    cout<<s.substr(h,k)<<endl;
  }
  return 0;
}
    

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

using namespace std;

int u[100001];
int d1[] = {1, -1, 0, 0};
int d2[] = {0, 0, 1, -1};
int d[1001][1001];
queue <pair <int, int> > q;
char a[1001][1001];

 main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int n, m, k;
	cin >> n >> m >> k;
	int starti, startj;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			cin >> a[i][j];
			if (a[i][j] == 'S') {
				starti = i;
				startj = j;
			}
		}
	}
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			d[i][j] = 1e9 + 7;
		}
	}        
	d[starti][startj] = 0;
	q.push (make_pair (starti, startj)); 
	while (q.size ()) {
		int r = q.front ().first;
		int c = q.front ().second;
		q.pop ();
		for (int i = 0;i <= 3;i ++) {
			int x = d1[i];
			int y = d2[i];
			if (r + x < 1 || r + x > n || c + y  < 1 || c + y > m) continue;
			if (d[r][c] + 1 < d[r + x][y + c] && a[r + x][y + c] == '.') {
				q.push (make_pair (r + x, c + y));	
				d[r + x][y + c] = d[r][c] + 1;
			}
		}
	}
	int ans = 1e9 + 7;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			if (d[i][j] > k) continue;
			int mn = min ({n - i, i - 1, m - j, j - 1});
			int jkl = mn / k;
			if (mn % k) jkl ++;
			ans = min (ans, jkl + 1);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4224